Ajisai

v0.9.0
io.github.masamoto1982/ajisai Checked 2 hours ago Published 1 month ago

Exact rational and algebraic computation, with machine-readable Word contracts, in Ajisai.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

compute

Execute a bounded Ajisai program and return its stack. Ajisai is postfix (RPN) and its numbers are exact rationals closed under square root — no floats, so results are reproducible and comparisons decide. Its 77 Words cover arithmetic (ADD SUB MUL DIV FLOOR ROUND MIN MAX SQRT POW GCD RATIO — negate with -1 MUL), comparison (EQ LT GT — not-equal is EQ NOT, at-most is GT NOT), three-valued logic (TRUE FALSE AND NOT, a NIL read as unknown — or is a NOT b NOT AND NOT; RECONCILE answers what two sources agree on, a NIL(conflict) for two different values), vectors — arithmetic broadcasts e…

ParameterTypeDescription
source *stringAjisai source text (file paths are not accepted). The effective limit is 65536 UTF-8 bytes, so non-ASCII text reaches it at fewer characters than maxLength suggests. Syntax is postfix: operands first,…

check

Parse and resolve Ajisai source without executing it; also verifies declared contracts conservatively.

ParameterTypeDescription
source *stringAjisai source text (file paths are not accepted). The effective limit is 65536 UTF-8 bytes, so non-ASCII text reaches it at fewer characters than maxLength suggests. Syntax is postfix: operands first,…

infer_contracts

Infer each user-defined Word's stack contract without executing its body: `inputs` and `outputs` (a count, or `variable`), `field` (`closed`, or `leaving` with the `fieldExits` that leave it) and a paste-ready `#:contract` line in `suggested`. Source that does not parse is the same `malformedSource` error check reports.

ParameterTypeDescription
source *stringAjisai source text (file paths are not accepted). The effective limit is 65536 UTF-8 bytes, so non-ASCII text reaches it at fewer characters than maxLength suggests. Syntax is postfix: operands first,…

word_contract

Return the generated canonical registry entry for a Word — its arity, purity, NIL policy, contract, and `cost`: what the Word charges on each metered resource (`steps`/`numeric`/`collection`), as a growth class in its input. Cost classes join pointwise under concatenation, so a phrase's bound is the widest bound among its Words — read them here to budget a program before running it rather than discovering the ceiling by hitting it. A class is how the charge *grows*, never how large it is: two programs of the same class can differ by orders of magnitude. Measured, `[ 1 2 3 4 5 ] [ 0 ] [ ADD…

ParameterTypeDescription
word *string