README · Reference · Playground
Ajisai Language Semantics
Status: Canonical
Specification version: 1.0.0-beta.4
Release stage: Beta. A breaking change to the vocabulary, to program meaning, or to the host protocol raises the specification version and is named in spec/CHANGELOG.md and in the release that ships it; a compatibility guarantee begins at 1.0.0.
This document defines the correspondence between Ajisai source programs and observable values, states, effects, and diagnoses. It is a compact semantic kernel: differences between individual Words belong to the machine-readable vocabulary registry, not to parallel prose definitions.
Ajisai is built from ten concepts. Everything below is one of them, or a consequence of one of them.
- Exact arithmetic over fractions, closed under square roots and under division by zero, with no rounding.
- Three outcomes: a value, a reasoned absence, or an error.
- A stack of values and vectors of values.
- Code blocks, evaluated only when a Word asks for it.
- One consumption rule: a Word consumes what it reads, and
BINDnames a value for reuse. - A two-tier dictionary — sealed Core, user-defined User — with content-addressed identity.
- A machine-readable contract for every Word.
- A pre-execution check of user declarations against those contracts.
- One host protocol, which is the only way anything outside the language observes it.
- An executable conformance corpus that decides whether an implementation is Ajisai.
1. Authority and Compatibility
LANG.AUTHORITY.SOURCES — Normative sources
日本語の要約(非正典)
言語の各部分について権威を持つ規範的な源泉は8つあり、それぞれ担当が異なる。本Language Semanticsはプログラムの意味、spec/grammar.jsonは字句文法(ソーステキストからトークン列または名前付きの1つのソースエラー条件への全域的な対応)、spec/words.jsonは語彙とワードが共有する法則、spec/identity.jsonは2つのものが同じであるとき、spec/termination.jsonはすべての評価が有限である理由、spec/outcomes.jsonはNILの理由とERRORカテゴリの閉じた一覧である結果空間、spec/gui-semantics.mdは表示、spec/host-protocol.schema.jsonはその両者の境界について権威を持つ。SPECIFICATION.htmlは2つの散文の源泉(本文書とspec/gui-semantics.md)を描画したもので、直接は編集されない。6つのデータ源泉は実装とそのゲートが直接読み、源泉が権威を持つのはこの表がそう定めるからであって、その文書に現れるからではない。実装の配置も説明文も観測可能な契約を上書きできず、この表にない文書は何も定義しない(docs/dev/はその前提で設計メモと履歴を置く)。本文書の中でInformativeと記されたブロックも、それが置かれた節を説明するだけで何も定義しない。
Eight sources are authoritative, each for a different part of the language:
| Source | Authoritative for |
|---|---|
| This Language Semantics | Program meaning |
spec/grammar.json | The lexical grammar — the total correspondence from source text to a token sequence or one named source-error condition |
spec/words.json | The vocabulary, and the laws Words share — a family's laws are the clauses every one of its Words cites |
spec/identity.json | When two things are the same — the one law, and what each level that decides it can deliver |
spec/termination.json | Why every evaluation is finite — the recursion sites, the measure each one decreases, and the invariant the argument rests on |
spec/outcomes.json | The outcome space — the closed list of NIL reasons and ERROR categories a contract's names resolve into, including those no contract reaches (literal) and those belonging to no single Word (arity, source, dictionary, resource) |
spec/gui-semantics.md | Presentation |
spec/host-protocol.schema.json | The boundary between them |
SPECIFICATION.html renders the two prose sources — this document and spec/gui-semantics.md — and is not edited directly. The six data sources are read directly by the implementation and its gates rather than through it: a source is authoritative because this table says so, not by appearing in that document.
Neither implementation layout nor explanatory text can override an observable contract. A document that is not in the table above defines nothing; docs/dev/ holds design notes and history on those terms. Within this document, a block marked Informative explains the clause it stands in and defines nothing either.
LANG.AUTHORITY.PRESENT — Present-tense description
日本語の要約(非正典)
Ajisaiの読み物はREADME、Reference、Specificationの3つであり、いずれも言語を現在の姿として記述する。定義、例、説明は言語が持つ概念だけに依拠してよく、名指すワードはすべて語彙レジストリに存在しなければならない。置き換えられた設計、移行の履歴、変更の理由はこの3つの外にある、何も定義しないメモに記録される。否定文が読み物に置かれてよいのは実装を制約する場合だけであり、「an implementation must not convert malformed use to NIL」はそうした制約である。言語にない設計との対比だけを内容とする否定文は置かれない。
Ajisai has three reading surfaces: the README, the Reference, and this Specification. Each describes the language as it currently is. A definition, an example, or an explanation may rest only on concepts the language has, and every Word it names must exist in the vocabulary registry.
Superseded designs, migration history, and the reasoning behind a change are recorded outside these three surfaces, in notes that define nothing. A negative statement belongs on a reading surface only when it constrains an implementation — "an implementation must not convert malformed use to NIL" is such a constraint — and not when its only content is a contrast with a design the language does not have.
LANG.AUTHORITY.IDENTITY — Language identity
日本語の要約(非正典)
Ajisaiの同一性とは、正規化されたソースから、スタック、出力、辞書状態、構造化された診断の順序付きの観測への対応である。2つの実装は、すべての適合プログラムについてこの対応が一致するとき意味的に等価だ。正準ワードは78個で(件数の記録はdocs/word-manifest.json)、そのうち49個が言語の意味的同一性を担うSemantic Kernelワード、29個が実用面を担うStandardワードである。KernelとStandardはどちらも1つの平坦な辞書にある普通のCoreワードで、素の名前で到達でき、契約、法則、適合性は同じ基準で扱われる。語彙の拡大は目的ではなく、既存の語彙の上のユーザー定義として表現できるワードはCoreに属さない。ただし、そう表現すると核で同じ処理を行うより漸近的にコストが高くなる場合は例外で、そのときその定義が示すのは語彙の欠落である。
Ajisai identity is the correspondence from normalized source to the ordered observation of stack, output, dictionary state, and structured diagnosis. Two implementations are semantically equivalent when that correspondence agrees for every conforming program.
| Count | What |
|---|---|
| 78 | Canonical Words — the vocabulary (docs/word-manifest.json is the count of record) |
| 49 | Semantic Kernel Words, within the 78 — carry the language's semantic identity |
| 29 | Standard Words, within the 78 — carry its practical surface |
Kernel and Standard are both ordinary Core Words in one flat dictionary, reached by their plain names, with contracts, laws, and conformance held to the same standard. Growth is not the goal: a proposed Word that is expressible as a user definition over the existing vocabulary does not belong in Core — unless expressing it that way costs asymptotically more than the same work done in the kernel, in which case what the definition demonstrates is a gap in the vocabulary rather than the absence of one.
LANG.AUTHORITY.FREEDOM — Implementation freedom
日本語の要約(非正典)
AST、IR、ディスパッチ、キャッシュ、ストレージ配置、数値表現、最適化は観測不能であり、すべての観測とホストプロトコルのペイロードの意味が変わらない限り自由に変えてよい。内部の厳密実数表現、Rustのenum名、デバッグ文字列、割り当ての同一性、GUIの色、非公開のシリアライズは意味上の判別子ではない。特に、実装はワードを好きな経路で実行してよいが、その経路が観測不能であることが条件である。
| Category | Examples |
|---|---|
| Unobservable — free to change when all observations and host protocol payload meanings stay unchanged | AST, IR, dispatch, caching, storage layout, numeric representation, optimization |
| Not a semantic discriminant | Internal exact-real representation, Rust enum names, debug strings, allocation identity, GUI colors, private serialization |
In particular an implementation may execute a Word by any route it likes, provided the route is unobservable.
2. Source and Desugaring
LANG.SOURCE.TEXT — Source domain
日本語の要約(非正典)
プログラムは封印されたAjisaiの字句文法(spec/grammar.json)でトークン化されるUnicodeテキストであり、トークンは数、文字列、名前、区切り記号[と]の5種類で、名前がどのワードか、ベクトルがコードか、定義とは何かはトークン化の後で決まる。小数リテラルは小数点の両側に少なくとも1桁を持ち(0.5と5.0は数、.5と5.は数でない)、単独の.は名前である。この数値文法が数を表すテキストの唯一の定義であり、テキストからScalarへの変換はソースのリテラルと同じ字句だけを受け付けて他をNILに投影し、1/0は1/2と同じく数で、非ゼロの分子なら符号によらず1/0、ゼロなら0/0という0の上の点を表す。字句が表せる数の大きさは、この文法を読むすべての入口で数値リテラルの上限(LANG.MACHINE.LIMITS)により、文字数ではなく表す桁数で制限される(1e5000は5001桁の整数を表す)。空白が唯一のトークン区切りで改行も他の空白と同じなので、複数行で書いたプログラムと1行で書いた同じプログラムは1つのプログラムであり、#は語頭にあるとき行末までのコメントとなり、[と]も単独で立たねばならず([ 1 2 3 ]は正しく[1 2 3]はソースエラー)、引用文字列は内部に空白を含めてよいが閉じる'の後には空白か入力の終わりが必要だ。ソースエラーは閉じていない文字列、何かに接した区切り記号、対応しない区切り記号だけで、他の規則が退ける字句はすべて名前となり、ソースエラーはどこも実行する前にプログラム全体を拒否し、NILを表さない。
A program is Unicode text tokenized by the sealed Ajisai lexical grammar (spec/grammar.json). There are five kinds of token: a number, a string, a name, and the two delimiters [ and ]. Everything else — which Word a name is, whether a Vector is code, what a definition is — is decided after tokenizing, not by it.
A decimal literal carries at least one digit on both sides of the point: 0.5 and 5.0 are numbers, .5 and 5. are not. The point is therefore never the first or last character of a number, so a lone . is unambiguously a name rather than a truncated literal.
This numeric grammar is the single definition of what text denotes a number. A conversion from Text to a Scalar accepts exactly the lexemes a source literal accepts and projects everything else to NIL, so the language has one numeric grammar rather than one per entry point. A pair whose denominator is zero, 1/0, is a number like 1/2: in source and as text alike it denotes one of the two points over zero (LANG.VALUES.EXACT): 1/0 for a nonzero numerator of either sign, 0/0 for zero. How large a number a lexeme may denote is bounded by the numeric-literal ceiling (LANG.MACHINE.LIMITS), counted in the digits it denotes rather than the characters it takes — 1e5000 denotes a 5001-digit integer — at every entry point that reads this grammar.
Whitespace is the sole token delimiter and is otherwise insignificant; a line break is whitespace like any other, so a program written across lines and the same program written flat are one program, with one Word identity (LANG.DICTIONARY.MUTATION). A line break ends a comment, which is the only thing it ends: # at the start of a word runs to the end of its line. No other character splits a token, the delimiters included: each of [ and ] must stand alone like every other word, so [ 1 2 3 ] is well-formed and [1 2 3] is a source error asking for the missing space, and # glued to a preceding lexeme is just part of that one name, not a comment. A quoted string is the one delimiter of its own: it may hold whitespace internally ('hello world'), but its closing ' must itself be followed by whitespace or end of input to close.
An unclosed string, a delimiter glued to anything and an unbalanced delimiter are the source errors, and there are no others: every lexeme the other rules decline is a name, so no name is invalid as text. A source error refuses the whole program before any of it runs. It does not denote NIL.
LANG.SOURCE.NORMALIZE — Name normalization
日本語の要約(非正典)
ワードの検索は正準正規化によって大文字小文字を区別しない。正規化が畳み込むのは大文字小文字だけであり、ワードはちょうど1つの名前を持ち、別の綴りがそれに解決されることはない。正規化は異なる値のタグを併合せず、辞書の項目を作り出さず、文字列やコードブロックの内容を変えない。
Word lookup is case-insensitive through the canonical normalization, and case is all it folds: a Word has exactly one name, and no second spelling resolves to it.
Normalization does not merge distinct value tags, invent dictionary entries, or change string and code-block contents.
LANG.SOURCE.DESUGAR — Surface forms
日本語の要約(非正典)
脱糖は決定的で、意味を保存する。登録された区切り記号の形式は、評価の前に正準的な概念へと下ろされる。脱糖をD、観測をOとすると、すべての整形式プログラムpについてO(p)とO(D(p))が等しい。糖衣構文は新しい値ドメインも失敗カテゴリも持ち込めない。
Desugaring is deterministic and semantics-preserving. The registered delimiter forms lower to canonical concepts before evaluation.
If \(D\) is desugaring and \(O\) observation, then \(O(p)=O(D(p))\) for every well-formed program \(p\). Sugar cannot introduce a new value domain or failure category.
LANG.SOURCE.CODE — Code values
日本語の要約(非正典)
コードは後で評価するためのソースを保持するベクトルであり、データと別のドメインではなく、契約がそれを求めるワードによって実行可能と読まれる同じベクトルドメインである(LANG.VALUES.DISJOINT)。[ ]が両者に共通の唯一の括弧で、[ 1 2 ADD ]はデータリテラルでもあり、ワードの契約が求める場所では実行可能なコードでもあり、値の構築の履歴は値の一部ではないので、使う前から「コード」か「データ」かが印付けられることはない。コードとして評価されたベクトルの要素は順に実行され、Symbolはワードを名指し、それ以外の要素は理由を持つNIL、Record、厳密な無理数も含め、ソーステキストが表すかどうかにかかわらず保持されたそのままの姿でプッシュされる。ベクトルをコードとして生成、格納、表示、評価することは別々の操作であり、引用されたコードは即座には実行されず、評価は契約がそれを求めるワード(EXECと高階ファミリー)を通じてのみ起こり、CONTRACTはブロックを評価せずに読む。分岐はそこに含まれず、SELECTはプログラムがすでに構築した2つの値から選ぶだけなので、何も評価せず何もスキップしない。ベクトルの要素を集めている位置に書かれた素の名前はSymbolを表し(LANG.VALUES.VECTOR)、名前はリテラルの中に現れるだけでは解決されない。コードとして走るベクトルは「書かれた」ものか「データから組み立てた」もので、どちらかは構築の履歴ではなく、走る場所でその値と走っているコードによって決まる。走っているコード(プログラム、ワードの本体、または実行中のブロック)のベクトルリテラルかその中に入れ子になったベクトルに等しいか、どこにもワードを名指さず何も走らせないなら書かれたもので、それ以外(分解して組み立て直したブロックや、別のフレームで束縛されこのフレームで走るブロック)はデータから組み立てたものである。書かれたブロックはそれを走らせるコードの一部なので、走らせると走るコードは小さくなる。データから組み立てたブロックは走れるが、別のデータから組み立てたブロックが走っている間は走れず、EXEC、MAP、FILTER、FOLD、SCANはオペランドを取る前にERRORnestedDataBlockで拒否する。これがブロックが自分の複製を走らせることを防ぐ(LANG.DICTIONARY.ACYCLIC)。[ 1 COLLECT [ 0 0 ] GET EXEC EXEC ] 1 COLLECT [ 0 0 ] GET EXEC EXECは2回目の実行で拒否される。代価は、与えられたブロックを走らせるコードに同じことをするブロックを与えられないことで、オペランドを走らせるワードは[ 2 ADD ]は走らせるが、Wがそのワードのとき[ [ 2 ADD ] W ]は拒否する。DEFで名付けたコードはこの代価を払わない(ワードの呼び出しはブロックを走らせない)ので、渡されたコードが2段以上要る計算はワードとして書く。
Code is a Vector holding source for later evaluation — not a distinct domain from data, but the same Vector domain (LANG.VALUES.DISJOINT) read as executable by a Word whose contract requests it. [ ] is the sole bracket, for both: [ 1 2 ADD ] is equally a data literal and, wherever a Word's contract requests it, executable code. A value's construction history is not part of it (LANG.VALUES.DENOTATION), so nothing about how a Vector came to exist marks it as "code" or "data" ahead of use. Evaluated as code, a Vector's elements run in order: a Symbol names a Word, and every other element pushes itself exactly as it is held — a NIL with its reason, a Record, an exact irrational — whether or not any source text denotes it.
Producing, storing, displaying, and evaluating a Vector as code are distinct operations. Quoted code is not eagerly executed: evaluation occurs only through a Word whose contract requests it — EXEC and the higher-order family — never merely by building or holding the value; CONTRACT reads a block without evaluating it. Branching is not among them: SELECT chooses between two values the program has already built, so a branch evaluates nothing and skips nothing. A bare name written where a Vector element is being collected denotes a Symbol (LANG.VALUES.VECTOR) — data until something executes it — so a name is not resolved merely by appearing inside a literal. A Vector run as code is either written or built from data, and which one is decided where it runs, by its value and the code running it, never by how it was built. It is written when it equals a Vector literal of the code running it — the program, a Word's body, or the block whose code is running — or a Vector nested inside one of those literals, or when it names no Word anywhere inside it and so runs nothing. Anything else is built from data: a block taken apart and put back together, or one bound in another frame and run in this one. A written block is part of the code that runs it, so running it runs less code. A block built from data may run, but not while another block built from data is running: EXEC, MAP, FILTER, FOLD and SCAN refuse it as ERROR nestedDataBlock, before taking their operands. This is what keeps a block from running a copy of itself (LANG.DICTIONARY.ACYCLIC): [ 1 COLLECT [ 0 0 ] GET EXEC EXEC ] 1 COLLECT [ 0 0 ] GET EXEC EXEC is refused at its second run. The price is that code which runs a block it is given cannot be given a block that does the same: a Word that runs its operand runs [ 2 ADD ], and refuses [ [ 2 ADD ] W ] when W is that Word. Code named by DEF does not pay it, since a Word call runs no block, so a computation needing more than one level of passed-in code is written as Words.
LANG.SOURCE.FRAME — What a block sees
日本語の要約(非正典)
ブロックは独自のスタック規律を持たず、何に届き何を残してよいかはブロックを評価するワードが決め、ブロックのテキストはどちらの規則が適用されるかを示さない。ユーザーワードの本体(DEF)とEXECはスタック全体をフレームとし、いくつでも値を残してよい全スタック規則に従い、MAPとFILTER(現在の要素)、FOLDとSCAN(アキュムレータと現在の要素)は決まった数の値だけを持つ分離フレームの規則に従い、ちょうど1つを残さねばならず、何も残さなければERRORで、最上位より下のものはフレームとともに捨てられる。ブロックの中に書かれたブロックは書かれた場所ではデータであり、受け取ったワードが実行するときに外側のブロックではなくそのワードの規則で評価され、そうした入れ子のブロックを通じてのみ到達する定義中のワードの名前も、LANG.DICTIONARY.ACYCLICから見ればそのワードへの参照である。フレームは局所束縛も持ち、BINDは値と名前を消費してフレームの残りでその名前をその値にし、複数の名前は同じ長さのベクトルを分解する。分離されるのはスタックであって名前ではないので、ワードが評価するブロックは書かれたフレームを読むが、ワード呼び出しはそうではなく、本体は自身の束縛とオペランドだけを読んで呼び出し元のものを何も読まないので、ワードの意味は呼ばれる場所に依存しない。束縛はフレームとともに終わり、名前はワードか束縛のどちらかであって両方であることはない。
A block has no stack discipline of its own: the Word that evaluates it decides what the block reaches and what it may leave, and the block's text does not say which rule applies. The difference is whether an ADD written inside it finds two operands or none. Two rules cover every case.
| Rule | Applies to | Frame holds | On leaving |
|---|---|---|---|
| Whole-stack | A user Word's body (DEF) and EXEC | The whole stack | Leaves whatever it pushes, however many values |
| Isolated frame | MAP FILTER — the current element · FOLD SCAN — the accumulator and the current element | A fixed number of values (one for MAP and FILTER, two for FOLD and SCAN) | Must leave exactly one; leaving none is ERROR, and anything below the top goes with the frame |
A block written inside another block is data where it is written, evaluated only when the Word receiving it runs it, under that Word's rule and not the enclosing block's. This holds regardless of what name the block writes: a name naming the word being defined, reached only through such a nested block, is still a reference to that word for LANG.DICTIONARY.ACYCLIC to see, even though nothing here evaluates it.
A frame also holds local bindings. BIND consumes a value and a name and makes the name that value for the rest of the frame, however many times it is written; several names destructure a Vector of the same length. The isolation above is of the stack, not of names, so the blocks a Word evaluates read the frame they were written in — and a Word call does not: a body reads its own bindings and its operands and nothing of its caller's, so what a Word means never depends on where it is called. A binding ends with its frame, and a name is a Word or a binding and never both.
3. Value Domains
LANG.VALUES.DISJOINT — Tagged domains
日本語の要約(非正典)
値はScalar、真偽値、文字列、ベクトル、Record、NIL、Symbolのちょうど7つのドメインからなる互いに素なタグ付き和である。Recordはキー付きの対応(LANG.RECORDS.STRUCTURE)でありベクトルではなく、ペアのベクトルはRecordではなく、両者の間に暗黙の変換はない。Symbolは何かが実行するまではデータである素の名前で(LANG.SOURCE.CODE)、独立したドメインであり、ベクトルの中に入れ子になっていても単独でも到達できる([ ADD ] 0 GETはSymbolのADDをスタックに残す)。2つの値は符号化が似ているというだけで等しくなることはなく、Symbolは同じ綴りの文字列ではない。特にFALSEはScalarのゼロではなく、TRUEはScalarの1ではなく、欠如した値はERRORではない。
Values form a disjoint tagged sum of exactly seven domains: Scalar, Boolean, String, Vector, Record, NIL, and Symbol. A Record is a keyed correspondence (LANG.RECORDS.STRUCTURE); it is not a Vector, a Vector of pairs is not a Record, and nothing converts between them implicitly. A Symbol is a bare name, data until something executes it (LANG.SOURCE.CODE); it is its own domain, reachable standalone ([ ADD ] 0 GET leaves the Symbol ADD on the stack) as well as nested inside a Vector. Two values are never equal merely because their encodings resemble one another: a Symbol is not the String of the same spelling.
In particular FALSE is not scalar zero, TRUE is not scalar one, and an absent value is not an ERROR.
LANG.VALUES.DENOTATION — Identity is denotation
日本語の要約(非正典)
値はそれが表すものであり、どう作られたかではない。2つの値は、どの演算で作られたかにかかわらず同じものを表すときちょうど1つの値であり、8の平方根と2の平方根2つの和は1つの値、100 0 DIVと5 0 DIVは1つの値(1/0、LANG.VALUES.EXACT)、同じ理由を持つ2つのNILは1つの値である。構築の履歴は値の一部ではなく値から読み出すこともできないので、内部表現は観測不能であり、表示は値を生んだソースではなく値から導かれる。同一性を判定する手続きは値が表すものについて答え、判定できないときは判定できないと答え、決して「異なる」とは答えない。厳密な体の上の比較は判定でき(LANG.VALUES.EXACT)、LANG.DICTIONARY.MUTATIONの内容同一性は一方向だけを判定し、spec/identity.jsonがその法則と各レベルが提供するものを述べる。
A value is what it denotes, never how it was made. Two values are one value exactly when they denote the same thing, whatever operations produced each of them: \(\sqrt{8}\) and \(\sqrt{2}+\sqrt{2}\) are one value, 100 0 DIV and 5 0 DIV are one value (1/0, LANG.VALUES.EXACT), and two NILs carrying one reason are one value. Construction history is not part of a value and cannot be read back out of one.
An internal representation is therefore unobservable, and a display is derived from the value rather than from the source that produced it. A procedure that decides identity answers about denotation, and where it cannot decide it answers that it cannot, never "different": comparison over the exact field decides (LANG.VALUES.EXACT), and the content identity of LANG.DICTIONARY.MUTATION decides only one direction. spec/identity.json states the law and what each level delivers.
LANG.VALUES.EXACT — Exact scalars
日本語の要約(非正典)
Scalarは厳密な数であり、そのドメインは列挙ではなく条件で定まり、それは加減乗除(ゼロ以外による除算)で閉じ、実装が示す正規形によって等号と順序を有限時間で判定できる体に、ゼロ除算について閉じさせる2つの値を加えたもの、つまりその体の上の分数の輪(wheel of fractions)である。数は非ゼロの因子を除いた整数の組で、正規形である既約の組は両方を最大公約数で割って分母を非負にしたものであり、分母がゼロの組はすべて符号のない無限遠点1/0か輪の底0/0のちょうど2つのどちらかに既約化され(100 0 DIVと-5 0 DIVはともに1/0、-1/0は1/0の別の綴り)、これらは手で付け足したものではない。演算は輪の組の公式(和は(ad+bc)/bd、積はac/bd、逆数は分子と分母の交換、除算は逆数との積)を分母がゼロの組も含むすべての組に適用して後で既約化するもので、除算は全域的であり、非ゼロのxを0で割ると1/0、0を0で割ると0/0、1/0同士の和は0/0、0/0はすべての演算を吸収し、2 SQRT 0 DIVは1/0である。輪の公理は両点で成り立つが、ゼロに言及する体の法則(0·x=0、x-x=0、x÷x=1、分配法則)は両点でだけ崩れ、実装はそれを特例で復元してはならず、1/0に符号を与えてもならない。等号はどこでも判定され(0/0 0/0 EQと1/0 -1/0 EQはTRUE)、順序は体の上で判定され、両点は順序を持たないので、LT、GT、MIN、MAX、SORT、ORDER、BSEARCHがそれらの順序を求めるとdomainMissを投影し、これが厳密なドメインが判定しない唯一の比較で、UNKNOWNが真理ドメインに入る2つ目の経路である。条件を満たす証拠は有理数に非負有理数の平方根を添加した体で、平方因子のないdによる多重二次正規形は数ごとに1つなので表示とexactTermsは値から読まれ、根号内の因数分解は数値作業として課金されて残りの作業で分解できなければresourceLimitExceededとなり、POW、GCD、RATIO、FORMATもこのドメインに沿って答え(0 -1 POWは1/0、1/0 RATIOは[ 1 0 ]、無理数のRATIOや両点のFORMATはdomainMiss)、算術は途中で丸めず、示された正規形を持たない実数はAjisaiの値ではない。
A scalar is an exact number. The domain is fixed by a condition rather than by a list: it is a field — closed under addition, subtraction, multiplication and division by anything but zero — whose equality and order an implementation decides in finite time through a normal form it exhibits, together with the two values that close it under division by zero, and the whole is the wheel of fractions over that field. A number is an integer pair taken up to a nonzero factor: \((a,b)\) and \((ka,kb)\) are one number for every \(k\neq 0\). Its normal form, the reduced pair, divides both halves by their greatest common divisor and makes the denominator non-negative; since the gcd of \(n\) and \(0\) is \(|n|\) and the factor \(-1\) relates \((1,0)\) and \((-1,0)\), every pair over zero reduces to one of exactly two — 1/0, the one unsigned point at infinity, and 0/0, the wheel's bottom. Nothing is added to the field by hand: the two are what the one normal form already holds, 100 0 DIV and -5 0 DIV are both 1/0 for the reason 4/2 is 2/1, and 1/0 is a literal as 1/2 is, with -1/0 another spelling of it (LANG.SOURCE.TEXT).
The operations are the wheel's pair formulas — \(\frac{a}{b}+\frac{c}{d}=\frac{ad+bc}{bd}\), \(\frac{a}{b}\cdot\frac{c}{d}=\frac{ac}{bd}\), and the reciprocal \(/\frac{a}{b}=\frac{b}{a}\), with division as multiplication by the reciprocal — applied to every pair, a denominator of zero included, and reduced afterwards. Division is therefore total, every number has a reciprocal, and what follows is read off the formulas rather than decided separately: \(x\div 0\) is 1/0 for every nonzero \(x\) and 0/0 for zero; \(x+\frac{1}{0}\) is \(\frac{1}{0}\) for every finite \(x\), and \(\frac{1}{0}+\frac{1}{0}\) is \(\frac{0}{0}\); \(\frac{1}{0}\cdot x\) is \(\frac{1}{0}\) for every nonzero \(x\), and \(0\cdot\frac{1}{0}\) is \(\frac{0}{0}\); \(1\div\frac{1}{0}\) is \(0\); the negation of 1/0 is 1/0; and \(\frac{0}{0}\) absorbs every operation. Over a pair with denominator zero only whether a finite operand is zero reaches the result, which is all an irrational operand contributes there: 2 SQRT 0 DIV is 1/0. Every axiom of a wheel holds at both points — the reciprocal is an involution, \(/(xy)=/x\,/y\), and the laws of addition carry the term \(0x\) that records where a point was met — while the laws of a field that mention zero, \(0\cdot x=0\), \(x-x=0\), \(x\div x=1\) and the distributive law, give way at the two points and nowhere else: 1 1 ADD 1/0 MUL is 1/0 while 1/0 1/0 ADD is 0/0. An implementation must not restore them by special case, nor give 1/0 a sign; where they do hold is read off the contract instead (LANG.CONTRACT.FIELD), and their shapes are LANG.VALUES.SHAPE. FLOOR and ROUND leave the two points as they are, since no integer lies at them; SQRT answers each as its own root. Equality is decided everywhere — identity is denotation (LANG.VALUES.DENOTATION), so 0/0 0/0 EQ and 1/0 -1/0 EQ are TRUE — and order is decided over the field. Neither point has an order: 1/0 is unsigned and lies neither below nor above any number, and 0/0 lies nowhere, so a Word that asks for the order of either — LT, GT, MIN, MAX, SORT, ORDER, BSEARCH — has a well-formed operand outside the operation's domain and projects domainMiss (LANG.FAILURE.PROJECT). That is the one comparison the exact domain does not decide, and the second way UNKNOWN enters the truth domain (LANG.VALUES.TRUTH); every other comparison of two scalars yields TRUE or FALSE in finite time, not as a separate guarantee but as the half of the condition that fixes the domain.
The field \(\mathbb{Q}(\sqrt{d_1},\dots,\sqrt{d_k})\) generated over the rationals by square roots of non-negative rationals, in multiquadratic normal form \(\sum_d c_d\sqrt{d}\) with rational \(c_d\) and square-free integer \(d\), is the witness that meets the condition. Because every \(d\) is square-free the form is one per number, so a display and the protocol's exactTerms are read off the value and never off the operations that built it (LANG.VALUES.DENOTATION): 8 SQRT and 2 SQRT 2 MUL are one value written one way. Reaching the square-free part factors the radicand, which no cheap algorithm does for every integer, so that factoring is charged to the run's numeric work and a radicand the remaining work cannot factor is resourceLimitExceeded (LANG.MACHINE.LIMITS). Integer, fraction, decimal, and scientific-notation literals are source forms for exact rationals and the two points over zero, and SQRT generates the rest from a rational radicand: it is what builds the field rather than an operation the field is closed under. POW answers inside the domain — an integer exponent is repeated multiplication or division, so 0 -1 POW is 1/0 as 1 0 DIV is, and an exponent p/2 over a non-negative rational base is a power of its square root; every other exponent, 1/0 included, leaves the field and projects domainMiss, while 0/0 absorbs POW in either operand as it absorbs every operation — and GCD and RATIO read the integers and the reduced numerator and denominator that every rational and every point over zero carries, 1/0 RATIO being [ 1 0 ]; an irrational carries no such pair, so a total division widening the domain by two points makes no irrational a ratio, and RATIO projects domainMiss for it as GCD does for a non-integer. Arithmetic performs no intermediate rounding, and coefficients are arbitrary-precision, so a coefficient grows to whatever size the value requires. Rounding happens only where a program names it and only into text: FORMAT renders a scalar as decimal text with a stated number of digits, a tie rounding away from zero as ROUND rounds, and the field's decidable order settles every digit, an irrational's last one included; no decimal lies at the two points over zero, so FORMAT projects domainMiss for them, as STR does for an irrational. A real with no exhibited normal form is not an Ajisai value: widening the domain means exhibiting a new normal form that meets the condition, not amending the condition.
LANG.VALUES.TRUTH — Three-valued truth
日本語の要約(非正典)
真偽値ドメインはSQLが用いる強Kleene論理の3つの真理値TRUE、FALSE、UNKNOWNをちょうど持ち、TRUEとFALSEは2つの真偽値のデータだが、UNKNOWNは3つ目の変種ではなく、真理位置で読まれたNILである。ANDは真理の順序FALSE < UNKNOWN < TRUEにおける交わり、NOTはTRUEとFALSEを交換してUNKNOWNをそのまま残し、これらから書かれる結合子(論理和はa NOT b NOT AND NOT)も同じ表に従い、欠如したオペランドがUNKNOWNを生むのは他方のオペランドが単独で結果を決めない場合だけである。出力がUNKNOWNのときは該当するオペランドの欠如の理由を運び、両方が欠如していれば左のオペランドの理由をとるので、理由は真理が不明である理由を示す。UNKNOWNが入る経路は3つで、真理位置で読まれた欠如したオペランド、0の上の点1/0や0/0の順序を問うこと(点そのものは数でありUNKNOWNではなく、0/0 NIL?はFALSE)、2つの源泉の不一致であり、RECONCILEは異なる2つの値にconflictを投影し、結合的、可換的、冪等である。SELECTは真偽がTRUEのときだけ1つ目の候補を、FALSEとUNKNOWNのときは2つ目の候補をとり(SQLのCASE WHENがUNKNOWNでELSEをとるのと同じ)、FILTERは述語がTRUEとした要素だけを残し、不正な演算はERRORを上げ、ERRORは真理値ではない。ホストプロトコルは2つの真偽値をsemantics.truthValueが"true"か"false"のbooleanノードとして、UNKNOWNを欠如の理由を持つnilノードとして観測し、UNKNOWNはNILのままなのでNIL?はTRUEを答えNIL-REASONは理由を報告し('x' NUM TRUE ANDの理由はinvalidEncodingのまま)、UNKNOWNを存在すると報告したり理由を落としたりする実装はLANG.VALUES.NILに反する。
The Boolean domain has exactly three truth values, those of the strong Kleene logic SQL uses: TRUE, FALSE and UNKNOWN. A truth value says what a program has been told: TRUE that something holds, FALSE that it does not, and UNKNOWN neither. TRUE and FALSE are the two Boolean data values; UNKNOWN is not a third variant but NIL (LANG.VALUES.NIL) read in truth position — a Word with nothing to decide from produces NIL, and NIL standing where a truth value is expected reads as UNKNOWN. AND and NOT compose all three by the tables below, and so does every connective written from them — a disjunction is a NOT b NOT AND NOT; composition is not passthrough, so an absent operand yields UNKNOWN only where the other operand does not already settle the result by itself.
AND | TRUE | FALSE | UNKNOWN |
|---|---|---|---|
| TRUE | TRUE | FALSE | UNKNOWN |
| FALSE | FALSE | FALSE | FALSE |
| UNKNOWN | UNKNOWN | FALSE | UNKNOWN |
NOT | TRUE | FALSE | UNKNOWN |
|---|---|---|---|
| FALSE | TRUE | UNKNOWN |
AND is the meet of the truth order FALSE < UNKNOWN < TRUE: FALSE dominates even against an UNKNOWN operand, and TRUE leaves the other operand as it is. NOT exchanges TRUE and FALSE and leaves UNKNOWN where it is. Where the output is UNKNOWN it carries whichever operand's absence reason applies — the left operand's, when both are absent (LANG.FAILURE.PASSTHROUGH's left-to-right rule) — so the reason says why the truth is unknown: domainMiss for an order nothing decides, conflict for two sources that disagree, and so on.
UNKNOWN enters the truth domain three ways. An absent operand is read in truth position. An order is asked of a point over zero, 1/0 or 0/0, which has none and projects the absence that then reads as UNKNOWN (LANG.VALUES.EXACT); the point itself is a number and never an UNKNOWN — 0/0 NIL? is FALSE and 0/0 0/0 EQ is TRUE — and only the question of its order is the absence 0/0 1 LT NIL? finds. And two sources disagree: RECONCILE answers what two sources agree on — equal values agree, an absence yields to what the other source holds, and 0/0 yields to any other number as the bottom of the zero shapes (LANG.VALUES.SHAPE) — and any two different values, two truth values included, have nothing they agree on, so RECONCILE projects conflict (LANG.FAILURE.PROJECT): TRUE FALSE RECONCILE reads as UNKNOWN and its reason says the sources disagreed. That absence alone is not settled by a third source, so RECONCILE is associative, commutative and idempotent and a fold of it over many sources does not depend on their order. Every other comparison over the exact domain decides in finite time and yields TRUE or FALSE: that is a domain property of the field (LANG.VALUES.EXACT), not a limit this clause imposes. SELECT takes its first candidate only when its truth is TRUE and its second on FALSE and on UNKNOWN alike, as an SQL CASE WHEN takes THEN only when its condition is true and ELSE otherwise, and FILTER keeps only the elements its predicate calls TRUE, as an SQL WHERE clause keeps only the rows whose condition is true. Misuse still lives outside this domain: an operation that is malformed raises ERROR, which is never a truth value. The host protocol observes the two Boolean values as boolean nodes carrying semantics.truthValue "true" or "false", and UNKNOWN as the NIL it is — a nil node carrying its absence reason (LANG.OBSERVATION.PROTOCOL); a consumer reads these rather than display text (LANG.OBSERVATION.FIREWALL). Being read in truth position adds an observation; it takes none away. UNKNOWN is still the NIL it is: NIL? answers TRUE for it, NIL-REASON reports the reason it arrived with, a fallback can be chosen in its place, and a passthrough Word passes it on — so 'x' NUM TRUE AND is an UNKNOWN whose reason is still invalidEncoding. An implementation that reports UNKNOWN as present, or that drops its reason, contradicts LANG.VALUES.NIL.
LANG.VALUES.SHAPE — Zero-shape arithmetic
日本語の要約(非正典)
数のゼロ形状とは分子と分母がそれぞれ非ゼロかどうかであり、0、点1/0、0/0、それ以外の有限で非ゼロの数の4つがある。どれだけ多くを伝えるかで順序付けると0/0が底、有限で非ゼロの数が頂で、0と1/0はその間に並ぶ。積の形状はオペランドの形状の交わり(成分ごとのAND、1/0 0 MULは0/0)、逆数は成分を交換して0と1/0を入れ替え、和の形状は2つの有限で非ゼロの数が打ち消し合って0になる場合を除いて正確で、点はすべての有限の数を吸収し1/0 1/0 ADDは0/0となり、各形状はMULのもとで群をなし、分配法則が崩れるのは1/0が乗数のときだけである。ゼロ形状は真理ドメインではなく抽象ドメインであり、どのワードが体を離れうるかを示し(LANG.CONTRACT.FIELD)、有限のオペランドから0の上の点を答えうるのは商、冪、構文解析だけである。0/0が形状の底であることはそれをUNKNOWNにはせず、0/0は数であり、数を真理値に変換するワードはない。算術とRECONCILEはこの節を引用するknowledgeOrderファミリー、真理値とその結合子および順序を問うEQ、LT、GT、MIN、MAXはLANG.VALUES.TRUTHを引用するtruthOrderファミリーであり、点の順序を問うところで両者が出会う。
A number's zero shape is whether its numerator and its denominator are nonzero (LANG.VALUES.EXACT): 0, the point 1/0, 0/0, and every other number, finite and nonzero. Ordered by how much each tells — a nonzero half tells more than a zero one — 0/0 is the bottom, finite nonzero the top, and 0 and 1/0 lie between, beside each other. The pair formulas read over those two-valued halves grade the arithmetic by the shapes: a product's shape is the meet of its operands' shapes, halfwise AND — 1/0 0 MUL is 0/0; the reciprocal exchanges the halves, swapping 0 and 1/0 and fixing the others; and a sum's shape is \((a\land d)\lor(b\land c)\) over \(b\land d\), exact everywhere but where two finite nonzero numbers cancel to 0, so a point absorbs every finite number and 1/0 1/0 ADD is 0/0. Each shape is a group under MUL — the field's nonzero numbers, 1/0 alone, 0 alone and 0/0 alone — so the numbers are four groups laid over the shapes, and a division by zero steps from one layer to another rather than out of the domain. The distributive law fails only with 1/0 as the multiplier.
The zero shapes are an abstract domain, not a truth domain. They say which Words can leave the field (LANG.CONTRACT.FIELD): only a quotient, a power and a parse can answer a point over zero from finite operands. That 0/0 is the bottom of the shapes, as UNKNOWN is the bottom of what a program has been told, does not make it an UNKNOWN: it is a number (LANG.VALUES.TRUTH), and no Word converts a number into a truth value (LANG.VALUES.DISJOINT). The Words divide along the two orders: the arithmetic and RECONCILE, which act on what is known of a value, are the knowledgeOrder family and cite this clause; the truth values, their connectives and the Words that ask an order — EQ, LT, GT, MIN, MAX — are the truthOrder family and cite LANG.VALUES.TRUTH; an order asked of a point is where the two meet.
Informative. This block explains the clause and defines nothing (LANG.AUTHORITY.SOURCES).
Where the arithmetic sits. The domain is Carlström's wheel of fractions over the integers, extended to the algebraic numbers SQRT builds. Anderson's transreal arithmetic totalizes division over the same pairs but keeps two signed infinities and sends \(\infty+\infty\) to \(\infty\); that keeps an order at infinity and gives up the reciprocal's involution, since both infinities have the one reciprocal 0. Ajisai takes the wheel's side: with one zero, a signed infinity and an involutive reciprocal exclude each other, and the wheel keeps the involution and every wheel axiom at the price of an order at infinity.
The shapes and the truth values. Read as two bits, the four shapes form the lattice Belnap called FOUR, and a product's shape is its knowledge meet. The truth domain is not that lattice: it is the three values of strong Kleene logic, which is FOUR without the value told both true and false (LANG.VALUES.TRUTH). The resemblance is why 0/0 and UNKNOWN both sit at the bottom, and it stops there.
LANG.VALUES.NIL — Diagnostic absence
日本語の要約(非正典)
NILは整形式の部分的な演算における欠如を表す値であり、生成に失敗した理由を示す安定した機械可読の識別子である理由を運ぶ。理由はNIL-REASONとプロトコルを通じて観測できる。理由の空間は2層からなり、spec/outcomes.jsonが登録する閉じた識別子の集合と、そのうちの1つで、プログラムがABSENTによって到達し、パラメータとして与えたテキストを運ぶuserDeclaredであり、NIL-REASONはそのテキストを答える。理由がNILの観測可能な内容のすべてであり、userDeclaredのNILが宣言したテキストもそれに含まれるので、2つのABSENTのNILはテキストが等しいときちょうど同じ値である。実装はホストのチャネルにより豊かな診断を出してよいが、プログラムの振る舞いがそれに依存してはならない。
NIL is a value representing absence from a well-formed partial operation. It carries a reason: a stable, machine-readable identifier for why production failed. The reason is observable through NIL-REASON and through the protocol. The reason space has two layers: the closed set of identifiers spec/outcomes.json registers, and one of them, userDeclared, which a program reaches by ABSENT and which carries the Text the program gave as its parameter — that Text is what NIL-REASON answers for it.
The reason is the entire observable content of a NIL, the declared Text of a userDeclared NIL included; so two ABSENT NILs are the same value exactly when their Texts are equal. An implementation may emit richer diagnostics on the host channel, and no program behavior may depend on them.
LANG.VALUES.ORDER — Order and grouping
日本語の要約(非正典)
2つの値が順序を持つのは両方が数か両方が文字列のときであり、数は厳密な体で順序付けられ(0の上の点は位置を持たない)、文字列はUnicodeスカラー値を左から読んで順序付けられ、真の接頭辞はそれを延ばすより長い文字列の前に来る(SQLのバイナリ照合で、ロケール、大文字小文字の畳み込み、正規化は入らず、'abc' 'abd' LT、'Z' 'a' LT、'ab' 'abc' LTはTRUE)。それ以外の組は数と文字列の組も含め順序を持たず、LT、GT、MIN、MAX、SORT、ORDER、BSEARCHがそれを求めるとオペランドのどこにその組があってもnonNumericを上げ、先に0の上の点に出会ってもこの誤用はそのdomainMissにならない。NILが順序を問われることはなく、比較の欠如したオペランドは素通りし、SORTとORDERはすべてのNIL要素を元の順序のまま存在する要素の後に置き(SQLのNULLS LASTで、[ 3 NIL 1 ] SORTは[ 1 3 NIL ])、BSEARCHはどのキーでもNILを見つけない。グループ化はEQとは別の問いであり、UNIQUE、TALLY、GROUPは2つの要素が1つの値であるとき1つのキーとするが、例外として深さを問わずすべてのNILは理由にかかわらず1つのキーとなり、そのキーは最初に出会ったNILで、その理由も保たれる。Recordのキーも同じキーであり、2つのNILキーは理由にかかわらず重複とされ、MERGEは別の理由のNILキーを見つけ、キーは最初に与えられた綴りを保つ。それでもEQとRECONCILEは2つのNILを理由で区別し、ベクトルの中の2つのNILは理由が一致するときちょうど等しい。集約はSQLの集約がNULLを飛ばすのと同じく欠如を飛ばし、SUMはベクトルの存在する要素を左からADDで足してすべてのNILを脇に置くので[ 1 NIL 2 ] SUMは3、存在する要素がないベクトルは足すものがなくdomainMissを投影する(SQLの行のないSUMはNULL)。
Two values have an order when both are numbers or both are Strings. Numbers are ordered by the exact field (LANG.VALUES.EXACT), where neither point over zero has a place. Strings are ordered by their Unicode scalar values, read left to right, a proper prefix before every longer String that extends it — SQL's binary collation, the same on every host because no locale, case folding or normalization enters it: 'abc' 'abd' LT, 'Z' 'a' LT and 'ab' 'abc' LT are TRUE. Any other pair, a number against a String included, has no order, and a Word that asks for one — LT, GT, MIN, MAX, SORT, ORDER, BSEARCH — raises nonNumeric, wherever in its operands the pair stands: a point over zero met first does not turn that misuse into its domainMiss (LANG.FAILURE.TRICHOTOMY). A NIL is never asked its order. An absent operand of a comparison passes through (LANG.FAILURE.PASSTHROUGH), and SORT and ORDER place every NIL element after every present one, the NILs in their original order — SQL's ORDER BY … NULLS LAST, with SORT REVERSE the descending order that puts them first — so [ 3 NIL 1 ] SORT is [ 1 3 NIL ]: a sort drops nothing, and the permutation ORDER answers keeps every other column of a table aligned. BSEARCH reads an ascending Vector in this order, and no key finds a NIL in it, as SQL's = NULL matches no row. Grouping asks a different question from EQ. UNIQUE, TALLY and GROUP make two elements one key when they are one value (LANG.VALUES.DENOTATION), with one exception that SQL's DISTINCT and GROUP BY make too: every NIL, at any depth, is one key whatever its reason. A null a source stored and a key a record lacked therefore fall in one group, whose key is the first NIL met, its reason kept. A Record's keys are the same keys (LANG.RECORDS.STRUCTURE): two NIL keys repeat whatever their reasons, MERGE finds a NIL key under another reason, and the key keeps the spelling it was first given. EQ and RECONCILE still tell two NILs apart by their reasons (LANG.VALUES.NIL): two NILs held inside Vectors are equal exactly when their reasons agree. An aggregate skips absence as SQL's aggregates skip NULL: SUM adds the present elements of a Vector by ADD from the left, setting every NIL aside, so [ 1 NIL 2 ] SUM is 3; a Vector with no element present has nothing to add and projects domainMiss (LANG.FAILURE.PROJECT), as SQL's SUM over no rows is NULL.
LANG.VALUES.VECTOR — Vectors
日本語の要約(非正典)
ベクトルは値の順序付きの有限な集まりであり、インデックスは0始まりで、負のインデックスは末尾から数える。ベクトルは入れ子にでき、入れ子は不揃いなデータやグループ化されたデータを表す。ストレージが平坦化、共有、遅延実体化されていてもベクトルの長さは意味を持ち、順序と長さがベクトルの観測可能な構造のすべてで、入れ子のベクトルも他と同じ1つの要素である。ベクトルリテラルの中の名前はSymbolを表し、リテラルの構築は実行ではないので辞書の検索は起こらず、[ FOO ]はFOOが定義済みかどうかにかかわらずSymbolのFOOを1つ持つベクトルであり、ベクトルリテラルはどの辞書状態でも同じ値を表す。TRUE、FALSE、NILだけはその名前を持つSymbolではなく値を表し、その帰結として、ベクトルリテラルの中の綴りを誤った名前はエラーではなくSymbolの要素となる。
A Vector is an ordered finite collection of values. Indexing is 0-origin and negative indices count from the end. Vectors nest, and nesting expresses ragged and grouped data.
Vector length is semantic even when storage is flattened, shared, or lazily materialized. Order and length are a Vector's whole observable structure, and a nested Vector is an element like any other.
Inside a Vector literal a name denotes a Symbol (LANG.VALUES.DISJOINT): data until something executes it, and building the literal is not itself execution, so no dictionary lookup occurs there. [ FOO ] is the one-element Vector holding the Symbol FOO whether or not FOO is a defined Word, so a Vector literal denotes the same value under every dictionary state. Only TRUE, FALSE and NIL denote values rather than a Symbol carrying their name. A consequence worth stating: a misspelled name inside a Vector literal is a Symbol element, not an error.
LANG.RECORDS.STRUCTURE — Records
日本語の要約(非正典)
Recordはキー付きの対応であり、任意の値でよい互いに異なるキーの列と値の列を位置ごとに対にしたもので、この2つの列(KEYSとVALUESで揃えて読み戻せる)が観測可能な構造のすべてなので、2つのRecordはキーの列と値の列がともに同じときちょうど1つの値であり、キーの順序は観測可能である。PUTは存在するキーをその場で置き換えて存在しないキーを末尾に追加し、MERGEは左のオペランドの順序を保ち、両方にあるキーでは右の値をとり、右の残りのキーを追加する。RECORDはキーのベクトルと値のベクトルから構築し、プログラムに代わって選ぶことはせず、2つの列の長さの不一致と重複したキー(duplicateKey、キーはグループ化が1つとみなすときちょうど1つのキー)をERRORとし、GETとPUTはベクトルをインデックスで読み書きするのと同じくRecordをキーで読み書きし、存在しないキーの読み出しや削除(GET、WITHOUT)はnotFoundを投影し、HAS?は存在だけを問うので格納されたNILと存在しないキーを区別する。これら4つのワードのキーオペランドはインデックスと同じくleafなので、キーのベクトルは複数のキーを一度に名指し、それ自体がベクトル、Record、NILであるキーはキーでは扱えず、KEYSとVALUESを通じて各キーをEQで丸ごと比べて読む。leafやtruthのオペランドにあるRecordはワードをその値の上に持ち上げてキーを保ち、ベクトルを読むワードのdataオペランドでは契約が宣言するオペランドのERRORを上げ、Recordのワードにそれ以外を渡すとnonRecordとなり、TALLYとGROUPはRecordを答える。JSON-DECODEはJSONのオブジェクトをRecord、配列をベクトル、数をそれが綴る厳密な有理数、nullをNILとして読み、1つのJSON値でないテキストにはinvalidEncodingを投影し、機械の上限を超える入れ子はresourceLimitExceededとして拒否し、JSON-ENCODEはその逆を書いて有限小数を持たない有理数を丸めずに文字列内の字句として綴り、JSONの像を持たない値にはdomainMissを投影する。
A Record is a keyed correspondence: a sequence of distinct keys, each any value, paired position by position with a sequence of values. Those two sequences are its whole observable structure — KEYS and VALUES read them back, aligned — so two Records are one value exactly when their key sequences and their value sequences are (LANG.VALUES.DENOTATION), and key order is observable: PUT replaces a present key in place and appends an absent one, and MERGE keeps the left operand's order, takes the right operand's value where both hold a key, and appends the right's remaining keys. RECORD builds one from a Vector of keys and a Vector of values, and raises two ERRORs rather than making a choice for the program — a key left without a value under it is the length mismatch between the two sequences, and a repeated key is duplicateKey, keys being one key exactly when grouping makes them one (LANG.VALUES.ORDER). A Record is read and written by key with the same two Words that read and write a Vector by index, GET and PUT. Reading or removing an absent key (GET, WITHOUT) projects notFound; HAS? asks presence alone, so a stored NIL is told apart from an absent key. The key operand of these four Words is a leaf, as an index is, so a Vector of keys names several keys at once (LANG.COLLECTIONS.LIFT) and a key that is itself a Vector, a Record or NIL — which RECORD, TALLY and GROUP accept like any other — is not addressed by key: its value is read through the two sequences, KEYS and VALUES, comparing each key whole with EQ. A Record in a leaf or truth operand lifts the Word over its values, keys kept (LANG.COLLECTIONS.LIFT); in a data operand of a Word that reads a Vector it raises the operand ERROR the contract declares, and a Record Word given anything else raises nonRecord. TALLY and GROUP answer Records, keyed by the distinct elements and the keys they bundle by. JSON-DECODE reads JSON text into these domains — an object is a Record, an array a Vector, a number the exact rational it spells, null a NIL — projecting invalidEncoding for text that is not one JSON value and refusing nesting past the machine's bound as resourceLimitExceeded (LANG.MACHINE.LIMITS); JSON-ENCODE writes the inverse, spelling a rational with no finite decimal as its lexeme inside a string rather than rounding it, and projects domainMiss for a value with no JSON image.
4. Machine State and Evaluation
LANG.MACHINE.STATE — State
日本語の要約(非正典)
機械状態は、データスタック、辞書、出力ストリーム、および観測可能な契約が必要とする実行制御を含む。ホスト専用のキャッシュ、割り当てアリーナ、コンパイル済みのプランは意味的な状態ではない。カウンタも意味的な状態ではない。
A machine state contains the data stack, the dictionary, the output stream, and the execution controls needed by observable contracts.
Host-only caches, allocation arenas, compiled plans, and counters are not semantic state.
LANG.MACHINE.TRANSFORMERS — Programs
日本語の要約(非正典)
実行可能な各トークンは部分的な状態変換子を表す。プログラムは、脱糖と名前解決の後のそれら変換子の左から右への合成を表す。実行は初期状態に対して決定的である。最適化が内部の作業を組み替えてよいのは、観測可能な列が変わらない場合だけである。
Each executable token denotes a partial state transformer. A program denotes left-to-right composition of those transformers after desugaring and name resolution.
Execution is deterministic relative to the initial state. Optimization may reassociate internal work only when the observable sequence is unchanged.
LANG.MACHINE.WORD — Word contracts
日本語の要約(非正典)
正準的なワード契約は意味ファミリーを選び、その差分として、スタックのアリティ、NILポリシー、投影の条件と理由、エラー条件、純粋性、決定性、効果、節へのリンク、ドキュメント、実行器キーを与える。決定性は結果が何に相対的かを分類するもので、オペランドだけから決まるdeterministic、より広いスタック、フレームの束縛、辞書も結果を決めるstate-relative(LANG.MACHINE.STATE)、ホスト自身による効果の描画、捕捉、破棄も結果を決めるhost-relative(LANG.EFFECTS.OUTPUT)がある。純粋性(LANG.EFFECTS.OUTPUT)は同じスタックと辞書が常に同じ結果を生むかだけを問うので、純粋なワードでもstate-relativeでありうる。実行器はその契約を詳細化しなければならない。ドキュメントは同じ正準項目の投影であって、独立した意味上の権威ではない。
A canonical Word contract selects a semantic family and supplies its differences: stack arity, NIL policy, projection condition and reason, error conditions, purity, determinism, effects, clause links, documentation, and executor key. Determinism classifies what the result is relative to: deterministic from operands alone, state-relative when the wider stack, frame bindings, or dictionary also decide it (LANG.MACHINE.STATE) — a pure Word can still be state-relative, since purity (LANG.EFFECTS.OUTPUT) asks only whether the same stack and dictionary always yield the same result — or host-relative when the host's own rendering, capture, or discard of the effect also decides it (LANG.EFFECTS.OUTPUT).
The executor must refine its contract. Documentation is a projection of the same canonical entry, not an independent semantic authority.
LANG.MACHINE.ORDER — Evaluation order
日本語の要約(非正典)
トークンの評価、出力の発行、辞書の変更は、それらの観測可能な順序を保つ。
Token evaluation, output emission, and dictionary mutation preserve their observable order.
LANG.MACHINE.LIMITS — Work limits
日本語の要約(非正典)
ホストは実行をいくつかの軸で制限し、軸を区別するのは計る資源ではなく、使い果たしたときに3つの結果(LANG.FAILURE.TRICHOTOMY)のどれを生むかである。実行ステップの上限は実行全体の総作業量を制限してexecutionLimitExceededのERRORとなり、実体化の上限は生成される1つの集まりの大きさを制限してmaterializedElementsを名指すresourceLimitExceeded、呼び出し深さの上限は同時に有効なユーザーワードの呼び出しとブロックの評価(EXEC、MAP、FILTER、FOLD、SCAN)の数を合わせて制限して上限callDepthのresourceLimitExceeded、値と作業の上限は1つの値や入力(ソースのバイト数、数値リテラルが表す桁数、整数の幅、代数項の数、入れ子の深さ)や累積した数値と集まりの作業を制限してresourceLimitExceededとなる。各行はホストが続行を拒否することであり、各行が名指すカテゴリは規範的だが、最後の行をいくつの上限に分けるかとすべての数値は実装の自由である。上限はプログラムではなくホストに属するので、上限を超えることは決して値(NIL)にならず、ERRORとして上限が発火した場所で実行を止めて上限とその値と超えた大きさを名指すので、ホスト間の違いは常に異なる答えではなく失敗として見え、プログラムが観測する値はどのホストでも同じものを表す。上限を超えて結果を作るよう求められたワード(実体化や入れ子の上限を超えるRANGE、FILL、RESHAPE、JSON-DECODE、CHARS、TOKENIZE、数の桁数を超えるNUMやJSON-DECODE、数の幅を超えるPOW)は構築の前に、他の経路で同じ大きさに達した場合と同じカテゴリと上限名で拒否し、オペランドをそのまま残す。これらは意味上の制約ではなく安全のための制御であり、停止性はすでにLANG.DICTIONARY.ACYCLICとLANG.SOURCE.CODEから従うので、上限はコストを制限するだけで停止性を決めない。
A host bounds a run along several axes, and what distinguishes them is not which resource they meter but which of the three outcomes (LANG.FAILURE.TRICHOTOMY) exhausting one produces:
| Ceiling | Bounds | On exhaustion |
|---|---|---|
| Execution-step limit | Total work across the run | ERROR, category executionLimitExceeded |
| Materialization ceiling | Size of one generated collection | ERROR, category resourceLimitExceeded, naming materializedElements |
| Call-depth ceiling | How many User Word calls and block evaluations (EXEC, MAP, FILTER, FOLD, SCAN) are active at once, counted together — a chain of distinct Words each calling the next, blocks nested inside them, or blocks nested inside them | ERROR, category resourceLimitExceeded, ceiling callDepth |
| Value and work ceilings | One value or input (source bytes, the digits a numeric literal denotes, integer width, algebraic term count, nesting depth), or the numeric and collection work the run has accumulated | ERROR, category resourceLimitExceeded |
Every row is the host refusing to continue, and the category each row names is normative: how many ceilings a host divides the last row into, and every numeric value, is implementation freedom. A ceiling belongs to the host, not to the program, so crossing one is never a value — not a NIL, which would flow on like any other value (LANG.FAILURE.PASSTHROUGH) and let one program answer ok with different values on two conforming hosts, each choosing a different branch of NIL? SELECT. An ERROR instead stops the run where the ceiling fired and names it (the ceiling, its value, and the size that crossed it), so a difference between hosts is always visible as a failure and never as a different answer, and a value a program observes denotes the same thing on every host (LANG.VALUES.DENOTATION). A Word asked to build a result past a ceiling — RANGE, FILL, RESHAPE, JSON-DECODE, CHARS and TOKENIZE past the materialization or nesting ceiling (LANG.COLLECTIONS.BUDGET), NUM or JSON-DECODE past the digits of a number, POW past the width of a number — refuses before building, by the same category and the same ceiling name as the same size reached any other way, and leaves its operands where they were. These are safety controls, not semantic constraints — termination already follows from LANG.DICTIONARY.ACYCLIC and LANG.SOURCE.CODE, so they bound cost rather than decide it.
5. Stack and Consumption
LANG.STACK.ORDER — Stack observation
日本語の要約(非正典)
スタックは区別された最上位を持つ順序付きの列である。ワードはオペランドを最上位から取り、結果を最上位に返す。表示のための変換は、スタックの値を並べ替えたり、型変換したり、落としたり、作り出したりできない。
The stack is an ordered sequence with a distinguished top. A Word takes its operands from the top and returns its results to the top.
A display transformation cannot reorder, coerce, drop, or invent stack values.
LANG.STACK.CONSUMPTION — Consumption
日本語の要約(非正典)
ワードは読んだオペランドを消費し、それらはスタックを離れ、結果がその場所を占める。これを変えるものはなく、結果が空のワードも例外ではなく、BIND、DEF、DELもオペランドを消費する。複数回使う値はBINDで名前を付け、必要なだけその名前で読み(5 'N' BIND N N 1 ADDは5 6を残す)、すべての呼び出しが読んだものをちょうど消費するので、ユーザーワードの本体をそのワードの位置に書いても消費されるオペランドは変わらず、これによってプログラムをCoreワードだけに展開できる。ワードはスタックの最上位からオペランドを選び、登録された契約を検証し、結果を計算または投影し、その後でオペランドを消費する。ERRORが成功したNILの投影を装うことはない。
A Word consumes the operands it reads: they leave the stack, and its results take their place. Nothing modifies this, and a Word whose result is empty is no exception — BIND, DEF and DEL consume their operands too. A value used more than once is named with BIND and read by that name as often as it is needed: 5 'N' BIND N N 1 ADD leaves 5 6. Because every call consumes exactly what it reads, writing a User Word's body in place of the Word never changes which operands are consumed, which is what lets a program be expanded into Core Words alone.
A Word selects operands from the top of the stack, validates its registered contract, computes or projects the result, and then consumes its operands. ERROR does not masquerade as a successful NIL projection.
6. Partiality and Failure
LANG.FAILURE.TRICHOTOMY — Value, absence, misuse
日本語の要約(非正典)
試みられたすべての演算は3つのカテゴリのちょうど1つで終わり、成功は登録された出力、整形式の部分的な失敗は理由付きのNIL、不正な使用はERRORとなる。実装は不正な使用をNILに変換してはならず、登録された部分的な投影が値を持たないというだけでERRORを上げてもならない。回復は欠如だけに作用し、プログラムはNILの代わりにフォールバックを選べるが、ERRORは伝播して評価を停止する。プログラムはどちらの結果も自ら宣言でき、ABSENTは与えたテキストを理由とするNILを作り、FAILは与えたテキストをメッセージとするERROR(カテゴリdeclaredFailure)を上げる。宣言されたERRORも完全なERRORであってどのワードも捕捉しないので、この三分法は実装に対してだけでなくプログラムに対しても閉じている。
Every attempted operation ends in exactly one of three categories:
| Category | Outcome |
|---|---|
| Success | Its registered outputs |
| Well-formed partial failure | NIL with a reason |
| Malformed use | ERROR |
An implementation must not convert malformed use to NIL and must not raise ERROR merely because a registered partial projection has no value. Recovery operates on absence alone: a program can choose a fallback in place of a NIL, while an ERROR propagates and halts evaluation. A program declares either outcome itself: ABSENT makes a NIL whose reason is the Text it is given, and FAIL raises an ERROR (category declaredFailure) whose message is the Text it is given. A declared ERROR is an ERROR in full — no Word catches it — so the trichotomy is closed against the program as well as against the implementation.
LANG.FAILURE.PROJECT — Projection
日本語の要約(非正典)
投影条件は整形式の入力の上の意味的な述語である。それが成り立つとき、ワードは契約が登録する理由を持つNILを生む。ドメインからの除外、範囲外のインデックス、探す場所に値がないこと、構文解析の失敗、空間の枯渇は投影条件が区別する理由の一部であり、網羅的な一覧はspec/outcomes.json(LANG.AUTHORITY.SOURCES)で、この節は共有される理由の振る舞いを定めるだけである。ワード自身の契約はそのワードが投影する理由をその部分集合として名指し、どの契約も現在到達していなくても理由は結果空間に存在する。
A projection condition is a semantic predicate over well-formed inputs. When it holds, the Word produces NIL with the reason its contract registers.
Domain exclusion, out-of-range indexing, a value not found where one is sought, failed parsing, and space exhaustion are among the reasons a projection condition keeps distinct — spec/outcomes.json (LANG.AUTHORITY.SOURCES) is the exhaustive list, this clause only fixes how the shared ones behave. A Word's own contract names the reasons that Word projects for, which is a subset: a reason exists in the outcome space whether or not any contract currently reaches it.
LANG.FAILURE.ERROR — Errors
日本語の要約(非正典)
アリティの失敗、適合しない型、不正なソース、無効な辞書操作、使い果たした実行ステップの上限は、登録されたERRORカテゴリを上げる。ERRORは評価を停止して伝播する。ERRORは決して真理値ではなく、スタックの値でもない。
Arity failure, nonconforming type, malformed source, invalid dictionary operation, and an exhausted execution-step limit raise their registered ERROR category.
ERROR halts evaluation and propagates. It is never a truth value and never a stack value.
LANG.FAILURE.PASSTHROUGH — NIL passthrough
日本語の要約(非正典)
ワードがNILのオペランドをどう扱うかは、そのオペランドをどう扱うかだけから決まり、各オペランドの位置はspec/words.jsonのstack.operandsでワードごとに宣言される1つの役割を持つ。dataやleafのオペランド(leafはScalar、文字列、真偽値、Symbolのようなコンテナでない1つの値として読まれ、ベクトルやRecordの上に持ち上げられる)は読まれるもので、欠如していればそれが理由を変えずにそのまま結果となり、プリミティブは実行されず、投影条件も再実行されず付け替えもせず、複数のdataオペランドが欠如していれば最も左のものが結果となる。elementは読まれずに運ばれるもの(格納、束縛、出力、符号化、検査される値、アキュムレータ、等価で比較される探索値)で、そこにあるNILは普通の値である。controlのオペランドは評価するブロック、束縛、定義、削除、検索する名前、上げるメッセージのようにワードを方向付けるもので、欠如できないのでそこにあるNILは不正な使用となり、ワードがそこに属さない他のオペランドについて宣言する条件を上げ、これはどのdataオペランドが素通りするより前に決まり、truthのオペランドはNILをUNKNOWNとして読む(LANG.VALUES.TRUTH)。ワードのnilPolicyはその役割を要約するもので独自の選択ではないので、オペランドを同じように扱う2つのワードはそこにあるNILも同じように扱う。データに依存するアリティを持つワードは役割を宣言せず、NILの扱いを契約で述べる。
What a Word does with a NIL operand follows from what it does with that operand, and from nothing else. Each operand position has one role, declared per Word as stack.operands in spec/words.json. A data or leaf operand is read (a leaf as one value that is not a container — a Scalar, String, Boolean or Symbol — lifted over a Vector or Record, LANG.COLLECTIONS.LIFT): an absent one is the result, flowing to the output position without changing its reason; the primitive does not run, no projection condition is re-run or relabels it, and when several data operands are absent the leftmost is the result. An element is carried without being read (a value stored, bound, printed, encoded or inspected, an accumulator, a needle compared by equality): a NIL there is an ordinary value (LANG.VALUES.NIL). A control operand directs the Word rather than being data it transforms — a block it evaluates, a name it binds, defines, deletes or looks up, or a message it raises: it cannot be absent, so a NIL there is malformed use, raising the condition the Word declares for any other operand that does not belong there, and this is decided before any data operand passes through. A truth operand reads a NIL as UNKNOWN (LANG.VALUES.TRUTH).
A Word's nilPolicy summarises its roles and is never a choice of its own, so two Words that treat an operand alike treat a NIL there alike. A Word of data-dependent arity declares no roles and states its NIL handling in its contract.
LANG.FAILURE.RECOVERY — Recovery
日本語の要約(非正典)
回復は独自の形式ではなく、1つの言い回しである。NIL?は値を消費してそれが欠如しているかを答え、それをSELECTが真理オペランドとして読むので、1度名付けて2度読んだ対象は自身とフォールバックのどちらかを選べる。subject 'S' BIND fallback S S NIL? SELECTは対象が存在すれば対象を、存在しなければフォールバックを残し、フォールバックは他のすべてのオペランドと同様に選択の前に計算される普通のオペランドである。問いは値全体に対して発せられ、欠如したレーンを持つベクトルは存在しているので、ベクトルの中のレーンの回復はベクトルの外側ではなくその内側で行われる。回復はすでに発行された出力から欠如を消さない。
Recovery is a phrase, not a form of its own. NIL? consumes a value and answers whether it is absent, which is what SELECT reads as its truth operand, so a subject named once and read twice chooses between itself and a fallback: subject 'S' BIND fallback S S NIL? SELECT leaves the subject when it is present and the fallback when it is not, the fallback an ordinary operand computed before the choice like every other operand. The question is asked of the whole value: a Vector holding an absent lane is present, so a lane recovered inside a Vector is recovered there rather than around it.
Recovery does not erase absence from already emitted output.
7. Collections and Higher-order Evaluation
LANG.COLLECTIONS.LIFT — Element lifting
日本語の要約(非正典)
ワードはオペランドを1つの値として読む場所、すなわちleafオペランド(Scalar、文字列、真偽値、Symbolのようなコンテナでない1つの値)とtruthオペランドで要素ごとに適用され、そこにベクトルが与えられれば要素ごとの答えのベクトルを、Recordが与えられれば変わらないキーのもとでの答えのRecordを返し、算術、比較、論理、テキストのすべてのワードがこの1つの規則で持ち上がり、1要素のベクトルもその要素ではなくベクトルである。Scalarはどれだけ入れ子で不揃いでもベクトルのすべての要素と組み合わさり、Recordが先に持ち上がり、他のオペランドはその各値と組み合わさり、キーの列が等しい2つのRecordは値ごとに組み合わさり、キーの列が異なればshapeMismatchのERRORとなる。2つのベクトルは軸を対にして組み合わさり、矩形のベクトルの形状(外側から順の軸の長さ)を最も内側の軸で揃え、短い形状が届かない軸は長さ1とみなし、長さが等しいか一方が1なら組み合わさって長い方の長さをとり([ 1 2 3 ] [ 10 ] MULは[ 10/1 20/1 30/1 ])、それ以外の対や、どちらかが不揃いな2つのベクトルの対はERRORとなる。SHAPEは矩形のベクトルの軸の長さを答え、不揃いなものには理由付きの欠如domainMissを答え、RESHAPEは葉を順に積がその個数に等しい形状のもとで組み直し、FLATTENはすべての軸を1つに潰し、DEPTHは値の入れ子の深さ(葉は0)を答える。後の2つはユーザー定義として書けず、入れ子の深さは前もってわからず、再帰も無制限のループもない言語では未知の深さの構造をたどれないからである(LANG.DICTIONARY.ACYCLIC)。各レーンはスカラーの法則の厳密性、真理、NIL、ERRORの区別を保ち、ベクトル化がERRORのレーンをNILに変えることはない。
A Word applies element-wise wherever it reads an operand as one value: a leaf operand, read as one value that is not a container — a Scalar, String, Boolean or Symbol — and a truth operand (LANG.FAILURE.PASSTHROUGH). Given a Vector there, it answers a Vector of its answers for the elements; given a Record, a Record of its answers under the unchanged keys (LANG.RECORDS.STRUCTURE). Every Word lifts by this one rule, arithmetic, comparison, logic and text alike, and a one-element Vector is a Vector there, never its element. A scalar combines with every element of a vector, however that vector is nested, including a ragged one. A Record lifts first: any other operand combines with each of its values, two Records combine value by value when their key sequences are equal, and two whose key sequences differ are a shapeMismatch ERROR.
Two vectors combine by pairing their axes. A vector whose nesting is rectangular has a shape: the lengths of its axes, outermost first. The two shapes are aligned at their innermost axis, and an axis the shorter shape does not reach counts as length 1. Paired axes combine when their lengths are equal, and when one of them is 1 that operand's single lane is reused across the other's length; the result carries the longer length on that axis. This makes a one-element vector combine with a vector of any length, and [ 1 2 3 ] [ 10 ] MUL is [ 10/1 20/1 30/1 ]. Any other pairing is ERROR, and so is any pairing of two vectors where either one is ragged. A program reads this shape with SHAPE, which answers a rectangular vector's axis lengths and, for a ragged one, the reasoned absence domainMiss — a ragged vector has no shape; RESHAPE regroups a vector's leaves, in order, under a shape whose product is their count; FLATTEN collapses every axis into one; DEPTH answers how deeply a value nests, a leaf being 0. The last two cannot be written as user definitions: nesting depth is not known in advance, and a language with no recursion and no unbounded loop cannot walk a structure of unknown depth (LANG.DICTIONARY.ACYCLIC).
Each lane preserves the exactness, truth, NIL, and ERROR distinctions of the scalar law. Vectorization cannot turn an ERROR lane into NIL.
LANG.COLLECTIONS.HIGHER — Higher-order evaluation
日本語の要約(非正典)
MAP、FILTER、FOLD、SCANはコードオペランド(LANG.SOURCE.CODE)を訪れる要素ごとに1回、インデックス順に評価し、ブロックのスタック効果は自身のオペランドに分離され、内側の軸には入れ子で届く([ [ f ] MAP ] MAPはfを1段下で適用する)。コードオペランドが書かれたものかデータから組み立てたものかはLANG.SOURCE.CODEのとおりで、データから組み立てたものは別のものが走っている間はnestedDataBlockで拒否される。FOLDとSCANはブロックが各要素で書き換えるアキュムレータを運ぶ1回の走査であり、FOLDは最後のアキュムレータを答えるので訪れる要素がなければ与えられた初期値を答え、SCANは訪れた要素ごとに1つずつすべて(初期値は含まない)を答えるので訪れる要素がなければ要素なしを答え、欠如した集まりにはその欠如を答える。ワードは自身を呼べず(LANG.DICTIONARY.ACYCLIC)無制限のループもないので、要素から要素へ状態を運ぶ計算がとりうる形はこれだけであり、与えられたブロックが出力や辞書の変更をしうる場合、要素の訪問順は観測可能である。ブロックの結果は終了時に最上位に残したものをそのまま、どのドメインであれとったもので、1要素のベクトルは1要素のベクトルのままであり([ 1 2 ] [ 1 COLLECT ] MAPは[ [ 1 ] [ 2 ] ])、長さを理由に結果を開くワードはない。ブロックはちょうど1つの値を残して終わり、何も残さないか2つ以上残せば呼び出し元の契約が登録するblockContractViolationを上げてワードは何も答えず、余りを捨てることはLANG.FAILURE.TRICHOTOMYが排除する静かな誤答なので、[ 1 2 3 ] [ 1 GT TRUE ] FILTERはERRORである。途中で計算した値はブロックの終了前に消費するか、スタックに何も残さないBINDで名前を付ける。
MAP, FILTER, FOLD, and SCAN evaluate their code operand (LANG.SOURCE.CODE) once per visited element, in index order, with the block's stack effect isolated to its own operands. A block reaches an inner axis by nesting: [ [ f ] MAP ] MAP applies f one level down. The code operand is written or built from data as LANG.SOURCE.CODE says, and one built from data is refused as nestedDataBlock while another runs.
FOLD and SCAN are one walk over the elements, carrying an accumulator the block rewrites at each one; they differ in which accumulators the walk answers with. FOLD answers the last, so a walk with nothing to visit answers the seed it was given. SCAN answers every one of them, one per visited element and the seed not among them, so a walk with nothing to visit answers no elements and an absent collection answers that same absence. This is the one shape a computation carrying state from one element to the next can take, because a Word cannot call itself (LANG.DICTIONARY.ACYCLIC) and there is no unbounded loop.
Element visitation order is observable where a supplied block can emit output or mutate dictionary state. The block's result is what it leaves on top when it finishes, taken as it stands, whatever domain it is in: a Vector of one element is a Vector of one element (LANG.VALUES.DISJOINT), so [ 1 2 ] [ 1 COLLECT ] MAP answers [ [ 1 ] [ 2 ] ] and no Word unwraps a result on the grounds of its length. A block finishes having left exactly one value, and that value is its result: a block that leaves nothing, or more than one, raises the blockContractViolation its caller's contract registers, and the Word answers nothing. The rule is the same for every count other than one, because a discarded surplus is a quiet wrong answer of the kind LANG.FAILURE.TRICHOTOMY rules out: [ 1 2 3 ] [ 1 GT TRUE ] FILTER is an ERROR, not a predicate that keeps every element on the strength of a TRUE written above the comparison it was meant to make. A value computed along the way is consumed before the block finishes, or named with BIND, which leaves nothing on the stack.
LANG.COLLECTIONS.BUDGET — Materialization
日本語の要約(非正典)
RANGE、FILL、RESHAPE、JSON-DECODEは実体化の上限を守り、CHARSとTOKENIZEも、切り出す部分が生成される集まりであるので同じ上限を守る。FILL、RESHAPE、JSON-DECODEは入れ子の上限も守る。形状が名指す軸の数やJSONテキストの入れ子の深さは、構築を求められたものの大きさだからである。上限内で実体化できない整形式の要求は何かを構築する前に拒否され、上限(materializedElementsまたはnestingDepth)、その値、要求された大きさを名指すカテゴリresourceLimitExceededのERRORとなる(LANG.MACHINE.LIMITS)。不正な次元はそれ自身の名前のERRORのままである。拒否は決して値ではなく、上限はホストのものであり、プログラムがそれを答えとして観測できてはならない。
RANGE, FILL, RESHAPE and JSON-DECODE honor the materialization ceiling, and so do CHARS and TOKENIZE, whose parts are a generated collection too; FILL, RESHAPE and JSON-DECODE honor the nesting ceiling as well, since the number of axes a shape names and the depth a JSON text nests are sizes of what they were asked to build. A well-formed request that cannot materialize within them is refused before anything is built, as ERROR with category resourceLimitExceeded naming the ceiling (materializedElements or nestingDepth), its value and the size requested (LANG.MACHINE.LIMITS); malformed dimensions remain ERROR under their own names. The refusal is never a value: a ceiling is the host's, and a program must not be able to observe one as an answer.
8. Dictionary and Effects
LANG.DICTIONARY.RESOLUTION — Deterministic lookup
日本語の要約(非正典)
辞書は2つの層からなり、その2つが辞書のすべてである。Coreは78個の正準ワードを持つ封印された層で、Coreの名前は再定義も削除もできず、UserはDEFによる定義を持つ。解決は正規化された名前と現在の辞書の決定的な関数であり、UserがCoreを覆い隠すことはない。ホストの検索、ホバー、Reference、実行は同じ正準項目を特定しなければならない。
The dictionary has two tiers, and those two are the whole of it. Core holds the 78 canonical Words and is sealed: a Core name cannot be redefined or deleted. User holds definitions made by DEF. Resolution is a deterministic function of the normalized name and the current dictionary, and User never shadows Core. The host's lookup, hover, the Reference, and execution must identify the same canonical entry.
LANG.DICTIONARY.MUTATION — User Words
日本語の要約(非正典)
DEFは名前をコードブロックに束縛し、DELはユーザーワードを取り除くが、他の定義がまだそれに依存していればERRORで失敗し、他の定義がまだ依存している名前へのDEFも同様に失敗する(definitionConflict)。呼び出し元は実行時に名前を解決するので、呼ばれる定義をその下で変えることはできず、呼び出し元を消した後に削除できるだけであり、定義は本体が名指すすべてのユーザーワードに、どちらが先に定義されたかにかかわらず依存する。辞書の変更は原子的にコミットされるか、部分的な変更を見せずにERRORを上げる。定義はソースとして保持され、DEFは任意のベクトルを本体にとり、本体が書かれたままではなく丸ごと運ぶ値(Record、厳密な無理数、それらを持つベクトル)はそれを構築するソースとして書き戻されるので、辞書が保持、表示、保存、識別する本体はどのセッションでも1つのテキストであり、理由を持つNILにはソースがないのでそれを含む本体は拒否される(invalidDefinitionBody)。すべてのワードは正規化された定義と呼び出すワードの同一性に対するダイジェストである内容同一性を持ち、依存先の変更は依存するものすべての同一性を変え、ワードや依存先の名前は同一性に届かず、同一性が等しければ1つのワードだが、等しくないことは何も意味しない(LANG.VALUES.DENOTATION)。DIGESTはワードを名指すSymbolにはその同一性を、他の値にはそれが表すもののダイジェストを同じ非対称性のもとで答え、ワード名を綴る文字列もそうした値なので、値のダイジェストは辞書に依存しない。
DEF binds a name to a code block; DEL removes a User Word and fails with ERROR if any other definition still depends on it, and DEF of a name that other definitions still depend on fails the same way (definitionConflict): a caller resolves the name when it runs, so the definition it calls cannot be changed under it, only deleted after the caller is. A definition depends on every User Word its body names, whichever of the two was defined first. A dictionary mutation commits atomically or raises ERROR with no partial visible mutation. A definition is kept as its source: DEF takes any Vector as a body, and a value that body carries whole rather than as written — a Record, an exact irrational, a Vector holding either — is written back as the source that builds it ([ keys ] [ values ] RECORD, the normal form over SQRT, … n COLLECT), so the body the dictionary holds, shows, saves and identifies is one text in every session; a NIL carrying a reason has no source, and a body holding one is refused (invalidDefinitionBody).
Every Word has a content identity: a digest over its normalized definition and the identities of the Words it calls, so a change to a dependency changes the identity of everything that depends on it, and what a Word or its dependencies are named does not reach it. Equal identities mean one Word, which is what lets a host deduplicate by content; unequal identities mean nothing, since two definitions can denote one function and normalize differently (LANG.VALUES.DENOTATION). DIGEST answers that identity for a Symbol naming a Word, and for any other value the digest of its denotation, under the same asymmetry. A String is such a value even when its text spells a Word's name, so a value's digest never depends on the dictionary.
LANG.DICTIONARY.ACYCLIC — No definition may name itself
日本語の要約(非正典)
Userの辞書の参照グラフは非巡回であり、DEFは定義中のワードを直接または他のユーザーワードの連鎖を通じて、どのように到達しても(LANG.SOURCE.FRAME)名指す定義をコミットせずERRORを上げ、BINDも自身の束縛を直接またはフレームから見える他の束縛を通じて名指す値を拒否する。どちらの検査も本体や値が持つすべてのSymbol(ベクトルから構築された本体が丸ごと運ぶRecordなどの中のものも含む)を読み、ワードはSymbolが名指すときだけ実行され、テキストをSymbolに変えるワードはなく文字列はコードではない(LANG.SOURCE.CODE)ので、検査は完全であり、呼び出しが計算されることはない。ワードは自身を呼べず、ブロックも自身を走らせられない(ブロックが走らせるのは中に書かれたブロックとワード、そしてほかに走っているものがないときに限りデータから組み立てたブロックである、LANG.SOURCE.CODE)ので、繰り返しはすでに有限なベクトルの上の有界な高階ワード(MAP、FILTER、FOLD、SCAN)だけであり、すべての評価は構造的に有限で、停止性は辞書の形とコードの入れ子から従い、実行ステップの上限(LANG.MACHINE.LIMITS)はコストを制限するだけである。したがってAjisaiは全域的でチューリング完全ではなく、これは意図的なトレードオフである。その代価は、収束するまで走らねばならない計算を、プログラムが先に構築する有限なベクトルの上に書き直す必要があることで、見返りは、発散がなくボトムも連続性の義務も不動点構成もないので、言語が領域理論なしに意味を持つことである。完全な論証はspec/termination.jsonにある。
The User dictionary's reference graph is acyclic: DEF raises ERROR rather than commit a definition that names the word being defined, directly or through a chain of other User words, however that name is reached (LANG.SOURCE.FRAME), and BIND refuses a value that names its own binding, directly or through other bindings the frame can see, since a binding is looked up when its Vector runs and would otherwise call itself with no Word in between. Both checks read every Symbol the body or value holds, including one inside a Record or other value a body built from a Vector carries whole, and they are complete because a Word runs only when a Symbol names it: no Word turns text into a Symbol, and a String is not code (LANG.SOURCE.CODE), so a call can never be computed. No Word can call itself, and no block can run itself: a block runs the blocks written inside it, Words, and a block built from data only when no other is running (LANG.SOURCE.CODE). So repetition is only the bounded higher-order Words (MAP, FILTER, FOLD, SCAN) over an already-finite Vector, and every evaluation is structurally finite: termination follows from the dictionary's shape and the nesting of the code, and the execution-step ceiling (LANG.MACHINE.LIMITS) is left to bound cost, not decide it. Ajisai is therefore total and not Turing-complete — a deliberate trade, whose price is that a computation which must run until it converges has to be re-expressed over a finite Vector the program builds first, and whose return is that the language denotes without domain theory: no divergence, so no bottom, no continuity obligation and no fixed-point construction. spec/termination.json carries the argument in full.
LANG.EFFECTS.OUTPUT — Output
日本語の要約(非正典)
出力は機械の外に出る唯一の効果であり、PRINTはオペランドを消費して順序付きの出力ストリームに追加し、他に出力を発するワードはないので、出力ストリームがホストが観測するプログラムの行いのすべてである。ホストは出力ストリームを描画、捕捉、破棄してよいが、並べ替えたり言語側の検証を変えたりしてはならない。ワードはもう1つだけ効果を持ちうるが、それは機械の内側にとどまり、DEFとDELがLANG.DICTIONARY.MUTATIONのもとで辞書を変える。したがって効果は出力の発行と辞書の変更の2つであり、LANG.MACHINE.ORDERがその両方をトークンの評価に対して順序付ける。他のすべてのワードは何も変えず、同じスタックと辞書から同じ結果を生む。与えられたコードブロックを評価するワードはそのブロックの効果だけを持ち、ブロックが純粋であるときちょうど純粋である。
Output is the only effect that leaves the machine. PRINT consumes its operand and appends it to the ordered output stream. No other Word emits output, so the output stream is the whole of what a host observes a program doing.
A host may render, capture, or discard the output stream, but may not reorder it or change language-side validation.
A Word may have exactly one other effect, and it stays inside the machine: DEF and DEL change the dictionary, under LANG.DICTIONARY.MUTATION. Output emission and dictionary mutation are therefore the two effects, and LANG.MACHINE.ORDER orders both of them against token evaluation.
Every other Word changes nothing: given the same stack and dictionary it produces the same result. A Word that evaluates a supplied code block has the effects of that block and no others, so it is pure exactly when the block is.
9. Contracts and Static Checking
LANG.CONTRACT.REGISTRY — Machine-readable contracts
日本語の要約(非正典)
すべてのCoreワードの契約はspec/words.jsonにある機械可読なレコードであり、spec/words.schema.jsonに適合する。そのレコードが、ワードのアリティ、NILポリシー、投影の理由、エラー条件、純粋性、ドキュメントを述べる唯一の場所である。契約を言い直す散文はそのレコードの投影であり、独立した権威を持たない。CONTRACTは言語の内側から契約をinputs、outputs、fieldをキーとするRecordとして答え、Coreワードには登録された契約を、ユーザーワードやコードのブロックにはLANG.CONTRACT.CHECKで推論された契約を、同じキーと同じ語彙で返す。ワードはDEF、BIND、DELと同様に文字列で、あるいはSymbolで名指され、契約を読んでも何も呼ばれないので文字列が呼び出しになることはなく(LANG.SOURCE.CODE)、どのワードの名前でもなければnotFoundを投影する。
Every Core Word's contract is a machine-readable record in spec/words.json, conforming to spec/words.schema.json. The record is the single place a Word's arity, NIL policy, projection reason, error conditions, purity, and documentation are stated.
Prose that restates a contract is a projection of that record and carries no independent authority. CONTRACT answers a contract from inside the language as a Record keyed inputs, outputs and field: the registered one for a Core Word, the inferred one of LANG.CONTRACT.CHECK for a User Word or a block of code, in the same keys and the same vocabulary. It names a Word by a String, as DEF, BIND and DEL do, or by a Symbol; reading a contract calls nothing, so a String there never becomes a call (LANG.SOURCE.CODE). For a name of no Word it projects notFound.
LANG.CONTRACT.CHECK — Pre-execution check
日本語の要約(非正典)
ユーザー定義は自身の契約の宣言を、契約Recordのキーinputs、outputs、fieldとその値として持てる。宣言はインタプリタにはコメント行、検査には指令であり(#:contract DOUBLE inputs=1 outputs=1 field=closed、ワードごとに1行で、宣言するワードを名指す)、inputsとoutputsは推論された数と等しくなければならず、fieldは推論された契約が超えてはならない上限であり、省いたキーは検査されず、他のキーは指令を不正にする。ajisai checkはプログラムを実行せずに本体が呼ぶワードの契約に照らして宣言を検証し、プログラムを実行するすべてのホスト操作も同様で、宣言に違反したプログラムは実行されず所見とともにERROR(contractViolation)として答えられ、MAP、FILTER、FOLD、SCANの直前に書かれたブロックの推論されたアリティが与えられた値からちょうど1つを残せない場合は、実行が上げるERRORとして答えられる(ただしプログラムを実行するホストは、空の集まりではブロックが実行されないので、それを実行に委ねる)。CONTRACTはコードのベクトルやユーザーワードの名前について言語の内側から同じ推論に到達し、オペランドを評価しないのでその効果を持たず、推論が決められないときはより弱い主張('variable'のアリティや'leaving')を答え、それが検証不能という結果をデータとしてプログラムに届ける。検査は意図的に保守的かつ部分的であり、宣言ごとに検証済み(実行時の値に対応)、検証不能(理由付きの欠如に対応)、違反(エラーに対応)の3つの結果だけを報告し、推論が解析する構文的な断片の外にあるもの(ブロックが静的にわからない高階の本体や動的な制御)は検証不能とされ黙って通されることはなく、解析できない本体を検証済みと報告するツールは非適合である。この対応は仕組みではなく結果を分類するもので、検査にプログラムを評価させるものではない。
A user definition may carry a declaration of its own contract, written as keys of a contract Record with the values those keys take — inputs, outputs and field. The declaration is a comment line to the interpreter and a directive to the check: #:contract DOUBLE inputs=1 outputs=1 field=closed, one line per Word, naming the Word it declares. inputs and outputs must equal the inferred counts; field is a bound the inferred contract must not exceed; a key left out is not checked, and any other key makes the directive malformed. ajisai check verifies the declaration against the contracts of the Words the body calls, without running the program, and so does every host operation that would run it: a program whose declaration is violated is not executed, and is answered as an ERROR (contractViolation) with the findings beside it. The check reads one contract no program declares, the higher-order Word's own of LANG.SOURCE.FRAME: a block written immediately before MAP, FILTER, FOLD or SCAN whose inferred arity cannot leave exactly one value from those its Word gives it is answered as the ERROR running it raises, while a host that runs the program leaves it to the run, since over an empty collection the block never runs. CONTRACT reaches the same inference from inside the language, over a Vector of code (LANG.SOURCE.CODE) or the name of a User Word: it never evaluates its operand, so calling it carries none of the operand's own effects. Where the inference cannot decide, its answer is the weaker claim — a 'variable' arity, or 'leaving' — which is how the outcome cannot verify below reaches a program as data.
The check is deliberately conservative and partial. It reports exactly three outcomes per declaration, each the trichotomy of LANG.FAILURE.TRICHOTOMY applied at check time rather than at run time:
| Check-time outcome | Run-time counterpart |
|---|---|
| Verified | A value — the inferred contract itself |
| Cannot verify | A reasoned absence |
| Violated | An error |
Anything outside the syntactic fragment the inference analyzes — a higher-order body whose block is not statically known, or dynamic control — is reported as cannot verify and is never silently passed. A tool that reports verified for an unanalyzable body is nonconforming.
The correspondence classifies outcomes, not mechanisms, and does not make the check evaluate the program: a negative radicand, a failed parse and an out-of-range index already share one outcome category while sharing no mechanism, and an inference that could not decide joins that list on the same terms.
LANG.CONTRACT.FIELD — Where the field ends
日本語の要約(非正典)
除算は全域的なのでゼロの除数で実行が止まることはなく、その代価は0の上の2点でゼロに言及する体の法則(0·x=0、x-x=0、x÷x=1、分配法則)が崩れることであり、プログラムが何を仮定できるかは「このコードは0の上の点を持たないオペランドから0の上の点を答えうるか」という問いで決まり、契約が実行前にキーfieldでそれに答える。読む数がすべて体にあるとき答える数もすべて体にあるワードはclosed、点を持たないオペランドから1/0か0/0を答えうるワードはleavingであり、Coreワードでleavingなのは設計上体の外に届くDIV(1 0 DIV)、POW(0 -1 POW)、NUM('1/0' NUM)のちょうど3つで、他はすべてclosedであり、ブロックを実行するワード自身もclosedで、そのブロックのワードが決める。ユーザーワードやブロックの値は本体を評価せずに読まれ、呼ぶワードの1つがleavingか書かれたリテラルの1つが0の上にあればleaving、そうでなければclosedであり、DIVやPOWの直前に書かれた数リテラルはそれを決めるオペランドとして読まれるので[ 2 DIV ]と[ 2 POW ]はclosed、[ 0 DIV ]、[ -1 POW ]、[ LENGTH DIV ]はleavingのままで、本体が計算するオペランドは読まれないので[ 2 SQRT DIV ]も弱い主張としてleavingとなる。高階ワードが実行するコードはその直前に書かれたリテラルなら読まれるが、それ以外の経路で届くコード(束縛、データから取り出したベクトル、定義中のワードのオペランド)は読まれず、本体は名指す出口なしにleavingとされ、leavingの本体の報告と違反したfield=closedは出口(体を離れうる呼び出しと0の上に書かれたリテラル)を本体が書く順に名指す。closedで有限のオペランドを与えられたコードの中ではすべての数が体の数で体のすべての法則が成り立つので、a(b+c)をab+acに、x-xを0に書き換えても何も変わらないが、leavingの境界でその許可は止まり、どこでも成り立つ法則(加法と乗法の結合性と可換性、逆数の対合性)だけが残り、有限のオペランドの上のclosedの本体は点の順序を問うことがない(欠如したオペランドはどこでもUNKNOWNとして読まれる)。宣言field=closedはLANG.CONTRACT.CHECKの意味での上限であり、出口を名指す推論leavingはそれに違反し、読めなかったコードだけに基づくleavingはそれを検証できず、field=leavingはどちらも許す。
Division is total (LANG.VALUES.EXACT), so no run is ever stopped by a zero divisor, and the price of that is paid in one place: the two points over zero, where the field laws that mention zero — \(0\cdot x=0\), \(x-x=0\), \(x\div x=1\) and the distributive law — give way. What a program may assume therefore depends on one question, and the contract answers it before anything runs: can this code answer a point over zero from operands that hold none? Every contract carries the answer under the key field, with one of two values. A Word is closed when every number it answers lies in the field whenever every number it reads does; it is leaving when it can answer 1/0 or 0/0 from operands holding none of them. Among the Core Words exactly three are leaving, each because it reaches past the field by design rather than by failure: DIV (1 0 DIV), POW (0 -1 POW, the reciprocal of zero) and NUM ('1/0' NUM, a point spelled in text). Every other Word is closed: one that adds, multiplies, orders, rounds or takes roots keeps finite operands finite, and one that only carries numbers creates none. A Word that runs a block is closed itself; the Words of its block decide for it. For a User Word or a block the value is read off the body without evaluating any of it: the body is leaving as soon as one Word it calls is leaving or one literal it writes lies over zero, and closed otherwise. One operand is read where it is written: a number literal written immediately before DIV or POW is the very operand that decides it, so [ 2 DIV ] and [ 2 POW ] are closed while [ 0 DIV ], [ -1 POW ] and [ LENGTH DIV ] — a length may be zero — stay leaving; an operand the body computes is not read, so [ 2 SQRT DIV ] is leaving too, the weaker claim. A literal over zero leaves as surely, [ 1/0 MIN ] as [ 0 DIV ]. Code a higher-order Word runs is read when it is the literal written immediately before that Word; code that reaches it any other way — a binding, a Vector taken out of data, an operand of the Word being defined — was never read, so the body counts as leaving, with no exit to name. A report of a leaving body names its exits, the calls that can leave the field and the literals written over zero, in the order the body writes them, and a violated field=closed names them too, so the finding says what to change. The answer is what makes the field laws usable again without taking total division back. Inside code that is closed and fed finite operands, every number is a number of the field and every law of the field holds, so a reader, a tool or an agent may rewrite \(a(b+c)\) as \(ab+ac\) or \(x-x\) as \(0\) there and change nothing; at a leaving boundary that licence stops, and only the laws that hold everywhere — addition and multiplication remain associative and commutative, and the reciprocal an involution, over both points — survive it. The same boundary is where the one bridge into the truth domain begins: a point over zero reaches an order Word only by way of a leaving Word or literal, so over finite operands a closed body never asks the order of a point, the one route by which arithmetic itself enters UNKNOWN (LANG.VALUES.TRUTH); an absent operand still reads as UNKNOWN wherever it stands. A declaration field=closed is a bound in the sense of LANG.CONTRACT.CHECK: an inferred leaving that names an exit violates it, one resting only on code the walk could not read cannot verify it, and field=leaving admits either.
10. Observation and Host Protocol
LANG.OBSERVATION.PROJECTIONS — Observable surfaces
日本語の要約(非正典)
AjisaiはInput、Output、Stack、Dictionaryの4つの投影を公開する。表示はPresentation Profileに従ってそれらを並べたり選んだりしてよいが、言語側の内容はこの節が定める。Outputは順序付きのテキストの観測、Stackは順序付きの型付きの値、Dictionaryは解決済みのCoreとUserの目録、Inputは正規化されたソースと、該当する場合はホストの編集状態である。
Ajisai exposes four projections: Input, Output, Stack, and Dictionary. Presentation may tile or select them according to the Presentation Profile, but their language-side contents are determined here.
| Projection | Content |
|---|---|
| Output | The ordered text observation |
| Stack | The ordered typed values |
| Dictionary | The resolved Core and User catalog |
| Input | Normalized source and host editing state, where applicable |
LANG.OBSERVATION.PROTOCOL — The host protocol
日本語の要約(非正典)
すべてのスタックの値は、ホスト間で共有される単一のシリアライザ(spec/host-protocol.schema.json)が描画する1つの再帰的なノード形状で観測され、ノードは値のドメインを名指すtype(7つのドメインに対応するnil、boolean、number、string、vector、symbol、recordで、recordは揃ったキー列と値列をノードの2つの配列として運ぶ)、その型に応じた形のvalue、真偽値の真理、NILの欠如の理由、無理数の厳密項を運ぶ任意のsemanticsを持つ。すべてのフィールドは値そのものから導かれ、それを生んだワードからは導かれない(LANG.VALUES.DENOTATION)。CLI/MCPのエージェント面はこれらのノードの配列を独自のJSONエンベロープで包み(docs/dev/agent-cli-output-contract.md、非正準)、WASM/GUIの境界は同じノードを自身のエンベロープなしで直接公開し、これが言語の外のものがスタックを観測する唯一の構造化されたチャネルであって、CLIのstackDisplayのようなテキスト描画はこれらのノードのビューであり2つ目のプロトコルではない。スキーマは強制され、MCPのセルフテストはライブサーバーが返すすべてのスタックをそれに照らして検証する。このノード形状には現在バージョンのフィールドがなく、CLIのエンベロープは独自の整数schemaVersionを持つがWASMの境界はバージョンの信号を持たないので、この節が定める形状への破壊的変更はバージョンが追加されるまで気づかれない。それでも既存フィールドの削除、改名、意味の変更、タプルの並べ替えや形の変更は禁じられ、実装はちょうど1つのプロトコルを提供する。
One recursive node shape observes every stack value, rendered by a single serializer shared across hosts (spec/host-protocol.schema.json): a type naming the value's domain (LANG.VALUES.DISJOINT's seven domains as seven wire types — nil, boolean, number, string, vector, symbol, and record, the last carrying its aligned key and value sequences as two arrays of nodes), a value shaped by that type, and an optional semantics bag carrying a Boolean's truth, a NIL's absence reason, and an irrational's exact terms. Every field is derived from the value itself, never from the Word that produced it (LANG.VALUES.DENOTATION). The CLI/MCP agent surface wraps an array of these nodes in its own JSON envelope (docs/dev/agent-cli-output-contract.md, non-canonical); the WASM/GUI boundary exposes the same nodes directly from its own methods, with no enclosing envelope of its own. It is the only structured channel through which anything outside the language observes the stack; a text rendering such as the CLI's stackDisplay is a view of these nodes, not a second protocol. The schema is enforced: the MCP self-test validates every stack the live server returns against it.
No version field exists on this node shape today: the CLI envelope around it carries its own plain integer schemaVersion, and the WASM boundary carries no version signal at all, so a breaking change to the shape this clause fixes would be silent until one is added. Existing field deletion, rename, semantic change, and tuple reorder or reshape remain forbidden regardless: an implementation offers exactly one protocol.
LANG.OBSERVATION.FIREWALL — Semantic firewall
日本語の要約(非正典)
外部の利用者は、公開されたプロトコルの軸だけに基づいて分岐する。Rustの型、デバッグ文字列、表示テキスト、内部の数値形式、付随的なGUIの状態に基づいて分岐することはない。GUIは厳密な等価性、スタック効果、名前解決、欠如の理由を独自に推論しない。
External consumers branch only on published protocol axes. They do not branch on Rust types, debug strings, display text, internal numeric form, or incidental GUI state.
The GUI never infers exact equality, stack effect, resolution, or absence reasons on its own.
LANG.OBSERVATION.DIAGNOSIS — Diagnosis
日本語の要約(非正典)
ERRORは安定したカテゴリ識別子と人間が読めるメッセージを運ぶ。NILはその理由を運ぶ。これらの識別子が機械可読な面であり、人間向けの文言はそれらが保たれる場合に限って変わってよい。
An ERROR carries a stable category identifier and a human-readable message; a NIL carries its reason. Those identifiers are the machine-readable surface, and human wording may evolve only where they are preserved.
11. Conformance
LANG.CONFORMANCE.CORPUS — Executable correspondence
日本語の要約(非正典)
適合性コーパスは各ケースを1つ以上の節IDに結び付け、スタック、出力、辞書状態、診断の識別子を比較する。実装は、すべてのケースについてソースから観測への対応を保つときAjisaiである。コーパスは「これはAjisaiか」という問いの判定手続きであり、散文はそれに答えない。
The conformance corpus links each case to one or more clause IDs and compares stack, output, dictionary state, and diagnosis identifiers. An implementation is Ajisai when it preserves the source-to-observation correspondence for every case.
The corpus is the decision procedure for the question "is this Ajisai?". No prose answers it.
LANG.CONFORMANCE.FAMILIES — Family laws
日本語の要約(非正典)
すべての意味ファミリーは法則テストを持つ。その対象は、該当するものについて、アリティ、消費、NILポリシー、投影、ERRORの境界、持ち上げ、純粋性、効果である。すべてのワード契約は、そのファミリーと節IDへの適合性の経路を少なくとも1つ持つ。
Every semantic family has law tests for arity, consumption, NIL policy, projection, ERROR boundaries, lifting, purity, and effects as applicable. Every Word contract has at least one conformance path to its family and clause IDs.
LANG.CONFORMANCE.CHANGE — Change discipline
日本語の要約(非正典)
意味の変更は1つの権威ある源泉から始まる。そのうえで導出されたすべての面を再生成し、節に結び付いた適合性ケースを更新する。そして、変更が明示的にバージョン付けされていない限り、観測が変わらないことを示す。
A semantic change begins in one authoritative source, regenerates all derived surfaces, updates clause-linked conformance cases, and demonstrates unchanged observations unless the change is explicitly versioned.
Presentation Profile
Current GUI contract
Presentation ranks below the language semantics: a conforming Ajisai need not present any surface visually, and a host with no display still defines the four observation projections. What follows is the contract the current Web and Tauri GUI realizes, stated concretely rather than as a formal system.
The GUI has four named surfaces: Input, Output, Stack, and Dictionary. Desktop presentation uses two columns (Input or Output on the left; Stack or Dictionary on the right), while mobile presentation exposes one selected surface at a time.
The operations Run, Step, Abort, and Reset retain their current behavior. The desktop shortcuts are respectively Shift+Enter, Ctrl+Enter, Escape, and Ctrl+Alt+Enter; Format is Shift+Alt+F, Stack clear is Ctrl+Alt+S, Editor clear is Ctrl+Alt+E, and Lookup is Ctrl+Alt+L. The mobile presentation has Run as a triple-tap on the Input surface, and Format, Stack clear, and Editor clear as controls in their own surfaces; Step, Abort, Lookup, and Reset are reachable there only from an attached keyboard, and the Input surface's own text says so. Stack clear discards the stack's values and leaves the dictionary — that is what distinguishes it from Reset. Editor clear discards only the Input surface's typed text, leaving the stack, the dictionary, and everything else untouched. Output copy and focus behavior, Core/User dictionary sheets, search, deletion, canonical stack display, opt-in LaTeX display, nested-vector bracket coloring, stack snapshots, and persistence of user words are compatibility requirements.
Editing affordances. These too retain their current behavior. A Run that ends OK empties the Input surface, and the submitted programs of the session are recalled into it with Ctrl+↑ (older) and Ctrl+↓ (newer); a Run that fails leaves its text in place. A click on a Dictionary word writes that word into the Input surface, with a space between it and any name it would otherwise run into; a click on the space between the word buttons writes a space, and a double-click there takes the last word back. Each of these is an ordinary edit of the Input surface, taken back with the platform's undo. A User Word is deleted from its button's context menu. User Words are exported to and imported from a file with the Dictionary surface's Export and Import controls. On desktop, Run is Shift+Enter alone: a triple-click on the Input surface selects the line, as it does in any text field, and does not run the program. A double-click on the Output surface returns the left column to Input. A #code= fragment in the page address preloads the Input surface with that text. On mobile, a swipe changes surface, a double-tap on Stack shows Output, and a double-tap on Output shows Input.
Format before a run. Run and Step apply Format to the Input surface before they read it, and what they submit, record in the session's history, and leave in place on a failure is the formatted text. Format lays the program out one way: it puts whitespace around every [ and ], indents by bracket depth, collapses runs of blank lines, and changes no other token. So a program with a bracket glued to other text, [1 2 3], runs in the Playground as [ 1 2 3 ], although the language rejects it as a source error (LANG.SOURCE.TEXT) and a host that runs the typed text as it stands, such as ajisai or the agent protocol, answers that error. Format leaves text it cannot lay out without risk of changing its meaning, such as an unclosed string or a string that spans lines, exactly as typed, and the run then sees that text. The rewrite is an ordinary edit of the Input surface, taken back with the platform's undo.
The Stack surface reads in ordinary reading order: top to bottom, left to right, with the top of the stack last. The top of the stack is marked, so the value the next Word reads is identifiable without counting, at any number of values and whatever the wrapping.
Operations without a typed spelling. Reset, Stack clear, Editor clear, and Lookup are reached by a shortcut or a control and have no typed spelling; none of them can be typed into the Input surface and run. This is deliberate in both directions: the vocabulary holds nothing that throws away the values a program was handed, the text it was typed as, or the dictionary it was defined in, and the Input surface holds nothing but the program being written. A name typed there — including RESET, STACK-CLEAR, or EDITOR-CLEAR — resolves as an ordinary program, exactly like any other name, and is a User Word or an unknown word like any other.
Lookup resolves the word at the current cursor position in the Input surface against the current dictionary and answers without running anything, always in the Output surface: a Core Word's reference text and a User Word's reconstructed DEF source are shown the same way, as prose to read rather than text loaded back for editing. The cursor can be anywhere in a program still being written, so nothing about a lookup may overwrite the Input surface. A name the dictionary does not hold is reported as an unknown word. This too is deliberately not a Word: reference prose is not a value, no program can do anything with the answer, and a Word whose entire result reached the output rather than the stack would be claiming otherwise. The lookup observes and changes nothing — the stack, the dictionary, and the Input surface are the same afterwards — and it must identify the same canonical entry that hover, the Reference, and execution do.
Four rules are normative, because each ties what is shown, or what can be reached, to what the user is doing rather than to geometry:
- Every surface stays reachable. A hidden surface is concealed, never destroyed, and some finite sequence of operations exposes it again from any state.
- Editing and execution are observable. Any state in which source text can be entered shows Input, and a Run shows each surface it changed, so what it produced is surfaced: on desktop a changed Output takes the left column and a changed Stack or Dictionary the right (Dictionary before Stack); on mobile, which shows one surface, the first changed of Dictionary, Output, Stack. A Run that changed nothing leaves the presentation as it was.
- At least one surface is always visible. The user is never shown nothing.
- Nothing a surface is reached by goes unsaid. A gesture is invisible — no control on screen shows that it exists — so wherever a surface can only be reached, or an operation only run, by a gesture or a shortcut, that surface says so in its own text, and what it says stays readable at the moment it is needed. This is a rule about telling, deliberately not a rule about supplying a control for everything: a control is not free, it is taken out of the surface it sits on, and an editor shrunk to a third of itself to seat a row of buttons has paid more than the buttons were worth. Where the cost is not worth paying, the operation may stay on a shortcut the surface names and a keyboard reaches.
Everything else — column geometry, the breakpoint at which the layout switches, which control sits where, gesture thresholds, tap counts — is tuning, not semantics, and has the same standing as the execution step limit: a host control rather than a language constraint.
The GUI consumes the current host protocol and does not independently decide exact-real equality, Word stack effects, dictionary resolution, absence metadata, or numeric representation. Web and Tauri platform adapters may supply capabilities, but may not change language observations. Existing accessibility names, focus paths, keyboard operation, and panel transitions are part of this GUI contract.