wikifn-fstar · Demos

Primitive Grounding

The ranked frontier below counts wrong. It reports how many functions each missing primitive "blocks", which counts a function once per blocking leaf. Those leaf sets overlap almost completely, so several entries each appear to block about 1,400 of the same functions. What matters is the marginal unlock: add the primitive, re-run the fixpoint, take the difference. That is now a mode of the tool rather than something done by hand: `` node scripts/analyze-closure.js --set engine --marginal 20 ` Read every "blocks N" figure below this line as an upper bound on a shared total, not as a count of what grounding that one thing would buy. **Status, re-measured (68 primitives).** Errors as values and quoting are done: Z5, Z851 throw, Z850 try-catch, Z853 get-error; Z99 quote, Z805 reify, Z808 abstract, Z899 unquote, Z29267 quoted reference. Reify and abstract are proved inverses in Wikifn.Roundtrip. Also done and once on this list: records, Z803 value by key, Z16829 type of object, Z13052/Z29294 equality, Z22693/Z22717 codepoint conversions, Z12668/Z12961 reverse and append, Z13546 natural division, Z22764 String from Type, Z10047/Z10018 Unicode case mapping, and the generic type constructors Z881/Z882/Z883. Closure over the current primitives, counting the compositions written in compositions/: **1,074** functions without recursion, **1,365** more with. The largest marginal unlock left is Z6820 Fetch Wikidata entities at **+316**, which is a data fetch rather than a function and would mean pinning a second dump. After that the numbers fall off sharply: Z828 fetch persistent object +20, Z20854 Rational number as float +15, Z21028 exponentiation (float64) +9, Z150 Validate error type +8. Z12316` regular expression substitute was +45 before quoting landed and is 0 now. Sections below this line predate all of that and are kept for the reasoning, not for the counts.

Current checked primitive modules:

The kernel currently covers:

These are F*-checked specs, not yet Low* buffer implementations.

The current checked kernel is intentionally small. It gives us a concrete place to attach Wikifunctions primitive IDs, tests, and later Low* refinements.

Mapping Candidates

Immediate Wikifunctions candidates:

Z10008, Z10075, Z10901, Z14124, Z14456, Z14520, and Z802 have checked F* kernel definitions over codepoint-list text. Z10000, Z10615, Z11040, Z866, Z10174, Z10184, Z10216, Z13522, Z13569, Z13582, Z13676, Z13682, Z13689, and Z13695 are now grounded for the extracted expression interpreter as scalar primitive calls. They still need canonical ZObject adapter work before arbitrary function calls can be loaded directly from wiki JSON at runtime.

Direct Specialization Targets

These are good follow-ons for the C-priority path: generate selected closed composition paths into direct F* functions, then extract them through OCaml/JavaScript before attempting a general compiler. The current generated direct module is src/fstar/Wikifn.Compiled.Compositions.fst; src/fstar/Wikifn.Specialized.Compositions.fst remains a hand-maintained reference path.

Implemented direct specializations:

ZIDEnglish labelKernel coverageDemo value
Z10627ROT13, Latin alphabetCovered through Z14613 character-set replacementRecognizable example: hello -> uryyb.
Z11082fallback if string is emptyCovered by Z802 and Z10008Demonstrates control flow, not just replacement.
Z19612turn to superscriptCovered through Z14613 character-set replacementReadable formatting example: x2+y3 -> ˣ²⁺ʸ³.
Z22649Arabic numerals to Devanagari numeralsCovered through Z14613 character-set replacementShows round-trip script conversion with existing Z22294.
Z27053convert digits to lower indicesCovered through Z14613 character-set replacementUseful chemistry-style example: H2O -> H₂O.

Good remaining candidates:

PriorityZIDEnglish labelKernel coverageBlockerDemo value
1Z15838ASCII Braille encodeCovered through Z14613Confirm direction from cached tests and browser displayStrong visual Unicode demo.
2Z10888 / Z10891Hebrew normal/final form conversionCovered through Z14613 character-set replacementHandle right-to-left rendering carefully on the siteGood internationalization example beyond digit scripts.
3Z15175join two strings with separatorPartial: kernel has concat and starts-withRegister Z10000 and Z10615; confirm separator semanticsGood readable text-composition demo after string adapters land.
4Z28209expand condensed electron configurationMostly covered by repeated Z10075 replacementsInspect exact scientific strings and constantsShows domain text transformation rather than toy strings.

Other good frontier-expansion candidates from the local dump, ordered by usefulness in composition graphs:

Current Priority Split

The local SQLite pass shows two different notions of "important".

Low-risk scalar primitives are now the immediate extracted-interpreter substrate: Z866, Z10000, Z10174, Z10184, Z10216, Z10615, Z11040, Z13522, Z13569, Z13582, Z13676, Z13682, Z13689, and Z13695. These are good eventual Low* candidates because their specs are small and deterministic.

The largest graph unlocks are not all low-risk primitives. Z803 value by key, Z805 reify, Z808 abstract, and Z22475 value by key safer need an honest object/key semantics. Z873 map function and Z876 reduce function need first-class function values, typed-list adapters, explicit fuel, and useful trace semantics. They should be treated as evaluator work, not just more scalar builtins.

Ranked Frontier From Local SQLite

Source: cache/wikifunctions.sqlite, built from the vendored 20260801 dump. These counts are local composition-call edges only; no live Wikifunctions crawling was used.

RankZIDEnglish labelComposition-call frequencyCached Z8 shapeWhy ground it nextRepresentative functions moved closer to closed
1Z811first element571one typed-list argument, returns Z1Core recursive-list primitive; highest ungrounded call count.Z37209 German noun phrase from determiner and noun; Z35874 preferred implementation of function as ZID; Z19601 N-ifs
2Z10000join two strings419Z6, Z6 -> Z6Grounded in the extracted expression interpreter; next work is canonical call adaptation.Z26333 Latin first declension table; Z35334 print Gregorian year limited by precision, English; Z12203 English regular superlative form
3Z813is empty list229one typed-list argument, returns Z40Pairs with Z811/Z812 for structural recursion over lists.Z19601 N-ifs; Z12864 lists have equal length; Z13558 product of list natural numbers
4Z812list without first element246one typed-list argument, returns typed listCompletes the basic list-recursion trio with head and empty.Z35874 preferred implementation of function as ZID; Z13397 get nth element of a list; Z31019 Levenshtein distance between lists is at most n?
5Z873map function428Z8, list Z1 -> list Z1Very high reuse, but it requires first-class function values and typed-list adapters, so it should follow the basic list kernel.Z30157 group by selector; Z32585 group typed pairs by first element; Z21347 sort integer-keyed list ascending
6Z21394concatenate many strings283list Z6 -> Z6A good text-generation demo primitive once list traversal and string concat are grounded.Z28748 name and lifespan from Wikidata item; Z26712 subject is an instance of, German; Z37677 inject Wikidata link if missing label
7Z12899join list of strings with delimiter149list Z6, Z6 -> Z6Common readable text output operation; gives useful end-user demos.Z28885 Luxembourgish short description for album; Z17687 convert RGB to hex colour; Z17954 substitute MediaWiki edit-change-tags query
8Z13522equality of natural numbers182Z13518, Z13518 -> Z40Grounded in the extracted expression interpreter; next work is canonical call adaptation.Z19343 Hindi ordinal; Z19892 same Rational number object; Z13397 get nth element of a list
9Z10216not151Z40 -> Z40Grounded in the extracted expression interpreter.Z24307 fallback language codes; Z10215 Boolean identity; Z31019 Levenshtein distance between lists is at most n?
10Z10174and160Z40, Z40 -> Z40Grounded in the extracted expression interpreter.Z24307 fallback language codes; Z11828 and quaternary; Z12203 English regular superlative form
11Z10184or109Z40, Z40 -> Z40Grounded in the extracted expression interpreter.Z11595 Breton mutation check; Z11863 vowel membership; Z11991 German noun declension helper
12Z13582decrement natural number by one157Z13518 -> Z13518Grounded with floor-at-zero semantics matching local tester labels.Z14859 Delannoy number; Z15334 unsigned Stirling number; Z15386 Wedderburn-Etherington number
13Z12681length of a list167list Z1 -> Z13518Useful after list representation is in place; supports algorithms and validation.Z31019 Levenshtein distance bound; Z29791 zip multiple lists; Z30977 length of common prefix of many lists
14Z810prepend element to list110Z1, list Z1 -> list Z1Needed for constructive list recursion and map-like functions.Z33762 Japanese verb conjugation table; Z13155 interleave lists; Z27878 create wikitable with headers
15Z866string equality130Z6, Z6 -> Z40Grounded as codepoint-list equality in the extracted expression interpreter.Z21438 64-bit binary string to float64 special value; Z21750 read special float value; Z14392 monolingual text equality

High-frequency functions deliberately not first in this list:

Z36070 Frontier

Z36070 is the recursive composition implementation of Z14613 "replace character set". Its direct calls are:

That means the Z36070 blocker is not primarily a Python/JavaScript-only dependency. It is the need to ground the string and codepoint substrate precisely enough that these direct calls can be treated as checked primitives or lowered into checked compositions.

Low* Plan

The high-level specs use lists because they are simple to prove against. A Low* implementation should refine text to explicit buffers:

spec text = list codepoint
Low* text = pointer + length + capacity / slice

Then each Low* primitive gets a proof obligation against the list spec. This keeps the executable C path separate from the mathematical meaning.

Rendered from primitives.md by make docs. That file is the source; this page is generated.