Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
552e8c1
figures: derive the codec model's global addresses from its layout
claude Nov 14, 2026
53717c0
figures: refuse the parametric release while any fixed figure is listed
claude Nov 14, 2026
e389185
docs: the figures ratchet, its release refusal and the derivation cla…
claude Nov 14, 2026
e33a0d2
Performance: canonical form of parametricRelease (lexlean fmt)
claude Nov 14, 2026
e03fbc0
engine: decide the codec's coordinates by outcome over the κ corpus
claude Nov 14, 2026
c46c08f
engine: keep every claim a cut coordinate stage decided; a coordinate…
claude Nov 14, 2026
127ce3d
coordinates: bound floor and gain by the proved plasticity ceiling, g…
claude Nov 14, 2026
bc8df43
generated: restore the exported crates' committed form (cargo fmt tou…
claude Nov 14, 2026
0b2f705
ncm: key the kept warmed models by the coordinates
claude Nov 15, 2026
541c38f
engine: decide a coordinate when no family loses bytes at the corpus …
claude Nov 15, 2026
5189a2d
Merge main (#172) into the ratchet branch
claude Nov 15, 2026
02d313f
Merge main (#176) into the ratchet branch; register lowered to the me…
claude Nov 15, 2026
efc081e
uorc: set coordinates only in their own test process
claude Nov 15, 2026
56b3003
WIP: byte singletons by prim update; whole gate on one LexLean pin
claude Nov 15, 2026
1647b26
Byte singletons from prim update; evaluations checked by the kernel; …
claude Nov 15, 2026
ddd81ec
Build the pinned LexLean beside its tool, not in the container's /tmp
claude Nov 15, 2026
c619170
Run the pinned LexLean in the projection review and offline construct…
claude Nov 15, 2026
bb8da4b
Declare the Justfile's pin inputs wherever the Justfile is an input
claude Nov 15, 2026
c5cc732
Build the pinned LexLean beside its tool root, outside the checkout's…
claude Nov 15, 2026
f31a747
Name the pinned LexLean instead of putting it on PATH
claude Nov 15, 2026
13b8da0
Run the pinned LexLean in the integrity and executed-controls checks
claude Nov 15, 2026
b6c6441
Link the pinned LexLean crate, not the SDK's 0.4.0
claude Nov 15, 2026
64a6ef0
Merge the merged ratchet branch's history (#173, squashed on main); t…
claude Nov 15, 2026
d9c0a53
gen: derive the coder's figures from declared domains
claude Nov 15, 2026
35401a5
Give the pinned LexLean dependency its version
claude Nov 15, 2026
ddbe0fe
coordinates: re-decide on the merged v0.7 coder (#174)
claude Nov 15, 2026
8ebb47f
Merge main (#174, #173, #176) into the byte-singleton branch
claude Nov 15, 2026
f0a7748
Merge branch 'pr179' into claude/project-thread-kkzl28
claude Nov 15, 2026
e8875c8
local: combine #179 and #180
claude Nov 15, 2026
f81d23d
Type Search and Core numbers by declared domains
claude Nov 15, 2026
ed87dc2
srcdomains: inner tree nodes are written as radix children of whole o…
claude Nov 15, 2026
9c1227b
srcdomains: seals, octet digits, node bounds and bit positions
claude Nov 15, 2026
52fed01
srcslots: state kernel graph references as differences of slot indices
claude Nov 15, 2026
6b775dd
srcslots: the Huffman program's main block, whose first part takes th…
claude Nov 15, 2026
dbea85f
Domains: every quantity built from the identities 0 and 1
claude Nov 16, 2026
fe6d6b9
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 16, 2026
e4ae722
generated/rust: export the client closure with Search and Core typed …
claude Nov 16, 2026
45dfebe
Carry only this lane: main's coder, generator and export; register on…
claude Nov 16, 2026
93554bf
Merge remote-tracking branch 'origin/main' into claude/project-thread…
claude Nov 16, 2026
eb67a1b
generated/rust: export the client closure with Search and Core typed …
claude Nov 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
405 changes: 405 additions & 0 deletions client/gen/srcdomains.py

Large diffs are not rendered by default.

274 changes: 274 additions & 0 deletions client/gen/srcslots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
# The slots of the model's kernel graph blocks, and the pass that states their references from them.
#
# A kernel graph block names its values by slot: its parameters first, then one slot for each
# instruction, in order. An instruction refers to an earlier value by its distance back from the slot it
# defines (Uorc.Core.Graph::slotType: index = slots - distance). A distance is therefore not a free
# number: it is the difference of two slot indices, and a slot index is the one before it plus one.
#
# The pass reads each block of Search and Core whose instruction list is written out (directly, or
# through the parts a large list is split into), simulates its slots, and states the block as that
# layout: every slot index is bound once (the first is zero, each next is the one before it plus one),
# and every slot reference is the difference of the referring instruction's slot and the slot it names.
# A part of a split list takes the slot indices it refers to as parameters. Block references (the
# distance of a called block among those before it) are left as they are: they are the next layout.
#
# python3 client/gen/srcslots.py rewrite in place, report what is left
# python3 client/gen/srcslots.py --check exit 1 unless the sources are at the pass's fixpoint
import collections
import re
import sys

import srcdomains as S

INSTR = 'Uorc.Core.Graph::Instruction.'
JOIN = 'joinBoundedList0'

# Fields of each instruction that name a block (a distance among prior blocks), not a slot.
BLOCK_FIELDS = {'apply': {0}, 'tabulate': {1}, 'fold': {2}, 'scan': {2, 4}}
# Fields that are not references at all (constants).
CONSTANTS = {'naturalConstant', 'byteConstant', 'predicateConstant', 'sequenceConstant',
'sequenceRopeConstant'}


def name(i):
"""The name of slot i: slotA, slotB, ... slotZ, slotAA, ..."""
s, i = '', i + 1
while i:
i, r = divmod(i - 1, 26)
s = chr(ord('A') + r) + s
return 'slot' + s


class Ref:
"""A slot reference in an instruction: the leaf token, the slot it names (once simulated)."""

def __init__(self, leaf):
self.leaf, self.target = leaf, None


def instructions(node):
"""The instruction ctors of a cons-chain, in order, each as (opcode, [Ref or None per Nat leaf]),
or None if the list is not written out."""
out = []
cur = node
while True:
if not isinstance(cur, S.Node):
return None
k = cur.kids
if k and S.tok(k[0]) == 'nil':
return out
if not (k and S.tok(k[0]) == 'cons' and len(k) == 3 and isinstance(k[1], S.Node) and isinstance(k[2], S.Node)):
return None
ins = k[1].kids
if not (ins and S.tok(ins[0]) == 'ctor' and (S.tok(ins[1]) or '').startswith(INSTR)):
return None
op = S.tok(ins[1])[len(INSTR):]
refs = []
if op not in CONSTANTS:
for fi, f in enumerate(ins[2:]):
block = fi in BLOCK_FIELDS.get(op, ())
if isinstance(f, tuple):
if not f[0].isdigit():
return None # a computed reference: the block is built, not written
refs.append((fi, block, [f]))
else:
leaves = []
sub = f
while sub.kids and S.tok(sub.kids[0]) == 'cons':
x = sub.kids[1]
if not (isinstance(x, tuple) and x[0].isdigit()):
return None
leaves.append(x)
sub = sub.kids[2]
if not (sub.kids and S.tok(sub.kids[0]) == 'nil'):
return None
refs.append((fi, block, leaves))
out.append((op, refs))
cur = k[2]


def count_types(node):
"""The number of entries of a written-out (List ValueType)."""
if not isinstance(node, S.Node):
return None
n, cur = 0, node
while cur.kids and S.tok(cur.kids[0]) == 'cons':
n += 1
cur = cur.kids[2]
if not isinstance(cur, S.Node):
return None
return n if cur.kids and S.tok(cur.kids[0]) == 'nil' else None


def field(rec, fname):
"""The value node of `fname := value` in a record's brace group."""
k = rec.kids
for i in range(len(k) - 2):
if S.tok(k[i]) == fname and S.tok(k[i + 1]) == ':=':
return k[i + 2]
return None


class Defs:
def __init__(self, text):
self.text = text
self.defs = {}
for m in re.finditer(r'definition\{', text):
s = m.end()
e = text.find('\n}', s)
d = text[s:e]
n = re.search(r'name: (\S+),', d).group(1)
b = d.find('body:') + 5
self.defs[n] = (s, e, d, s + b)


def parts_of(node, defs):
"""The part definitions a joinBoundedList0 tree concatenates, in order, or None."""
k = node.kids
if k and S.tok(k[0]) == JOIN and len(k) == 3:
a, b = parts_of(k[1], defs), parts_of(k[2], defs)
return None if a is None or b is None else a + b
if k and S.tok(k[0]) in defs and all(isinstance(x, tuple) for x in k):
return [S.tok(k[0])] # a part, called with the block's own values
return None


def main():
check = '--check' in sys.argv
names = S.closure()
files = sorted(p for d in S.SCOPE for p in (S.ROOT / d).glob('*.lex.tex')
if 'Uorc.%s.%s' % (p.parent.name, p.name.split('.')[0]) in names)
stated = collections.Counter()
changed = []
for p in files:
text = p.read_text()
defs = Defs(text)
edits = [] # (start, end, replacement)
part_params = {} # part name -> (start slot name, [external slot names])
for dn, (s, e, d, b) in defs.defs.items():
tree = S.parse(text[b:e], b)
for rec in blocks(tree):
params = count_types(field(rec, 'parameters')) if field(rec, 'parameters') else None
ins_node = field(rec, 'instructions')
if params is None or not isinstance(ins_node, S.Node):
continue
written = instructions(ins_node)
if written is not None:
state(text, edits, ins_node, [(None, written)], params, stated)
continue
parts = parts_of(ins_node, defs.defs)
if not parts:
continue
seq = []
for pn in parts:
ps, pe, pd, pb = defs.defs[pn]
pt = S.parse(text[pb:pe], pb)
w = instructions(pt.kids[0]) if pt.kids and isinstance(pt.kids[0], S.Node) else None
if w is None:
seq = None
break
seq.append((pn, w, pt.kids[0], ps, pd))
if seq:
state_parts(text, edits, ins_node, seq, params, stated, dn,
min(defs.defs[pn][0] for pn in parts))
if edits:
new = text
for a, z, r in sorted(edits, reverse=True):
new = new[:a] + r + new[z:]
if new != text:
changed.append(p)
if not check:
p.write_text(new)
print('slot references stated:', sum(stated.values()), dict(stated))
if check and changed:
print('not at fixpoint:', *[str(c.relative_to(S.ROOT)) for c in changed])
sys.exit(1)


def blocks(node):
"""Every `record Uorc.Core.Graph::Block {...}` brace group under node."""
k = node.kids
for i, x in enumerate(k):
if isinstance(x, S.Node):
if x.open == '{' and i >= 2 and S.tok(k[i - 1]) == 'Uorc.Core.Graph::Block' and S.tok(k[i - 2]) == 'record':
yield x
yield from blocks(x)


def group_span(text, node):
"""The span of a group node in text, its brackets included."""
return node.start, node.end


def simulate(seq, params):
"""Slot of each instruction and the slot each reference names. seq: [(part, written)]."""
slot = params
out = []
for part, written in seq:
for op, refs in written:
rs = []
for fi, block, leaves in refs:
for leaf in leaves:
d = int(leaf[0])
rs.append((leaf, block, None if block else slot - d))
out.append((part, slot, op, rs))
slot += 1
return out, slot


def chain(names_upto):
"""`let slotA : Nat := 0; (let slotB : Nat := (slotA + 1); ...` as (prefix, closing)."""
pre, close = [], 0
for i in range(names_upto):
val = '0' if i == 0 else '(%s + 1)' % name(i - 1)
pre.append('(let %s : Nat := %s; ' % (name(i), val))
close += 1
return ''.join(pre), ')' * close


def ref(at, target):
return '(prim subtract %s %s : Nat)' % (name(at), name(target))


def state(text, edits, ins_node, seq, params, stated):
sim, end = simulate(seq, params)
if any(t is not None and t < 0 for _, _, _, rs in sim for _, _, t in rs):
return
for _, at, op, rs in sim:
for leaf, block, t in rs:
if t is not None:
edits.append((leaf[1], leaf[2], ref(at, t)))
stated[op] += 1
a, z = group_span(text, ins_node)
need = max([at for _, at, _, rs in sim if any(t is not None for _, _, t in rs)], default=-1) + 1
if need:
pre, close = chain(need)
edits.append((a, a, pre))
edits.append((z, z, close))


def state_parts(text, edits, ins_node, seq, params, stated, block, first_part_start):
"""A block whose list is split into parts: its slot indices are definitions of the module (a
chain of lets as deep as a large block would pass the depth a module's data form holds), and each
part, still parameterless, refers to them."""
sim, end = simulate([(pn, w) for pn, w, _, _, _ in seq], params)
if any(t is not None and t < 0 for _, _, _, rs in sim for _, _, t in rs):
return
slot = lambda i: '(%s%s)' % (block, name(i)[0].upper() + name(i)[1:])
for part, at, op, rs in sim:
for leaf, blk, t in rs:
if t is not None:
edits.append((leaf[1], leaf[2], '(prim subtract %s %s : Nat)' % (slot(at), slot(t))))
stated[op] += 1
need = max([at for _, at, _, rs in sim if any(t is not None for _, _, t in rs)], default=-1) + 1
out = []
for i in range(need):
body = '0' if i == 0 else '(%s + 1)' % slot(i - 1)
out.append('definition{\n name: %s,\n parameters: [],\n result: Nat,\n body: %s,\n executable: true,\n axioms: []\n}\n\n'
% (slot(i)[1:-1], body))
at = text.rfind('definition{', 0, first_part_start)
edits.append((at, at, ''.join(out)))


if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion generated/rust/factory.identity
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export c6b6641423da371f457f15f3d2073fd6dccf5d23208ae3e4b8b362860ab05eea
export 19f46d9511c0c6f3be727b654ce05783a8cd745cbaccc923af77a32dbf9d25cf
2 changes: 1 addition & 1 deletion generated/rust/result.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion generated/rust/uorc_compress/package.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion generated/rust/uorc_compress/provenance.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"compiler_semantics":"75b3d9e78fc27199a7d4e9ec85a5aabb6cb0955510d728de97d33f8592144ad3","effects":["allocation","overflow","recursion"],"exports":[{"function":0,"name":"run"}],"files":{"Cargo.toml":"cde57240f2d89276727ad22fe352bdaadcee1135fda57b34fb52996e4339ae0e","src/lib.rs":"e49a411697438e54089f78e7fbf4330a110e554c74753cb60327d8af375638fb"},"name":"uorc_compress","profile":"rust-std","program":"606068de774827385257bdbe3ba2b1d1f3b831ff4763eaaa7208dbea1d49681b","runtime":"8551b0f864da7656da8aa57928d23b907b4b837111b1f4aebefb1096c8e2a741","sources":["4fdabfcfff61ea4488f91f224193f15735e8d0eabb99b6b80d126b0546c4c11e"],"spec":"lexlean/rust-provenance/1","version":"0.1.0"}
{"compiler_semantics":"75b3d9e78fc27199a7d4e9ec85a5aabb6cb0955510d728de97d33f8592144ad3","effects":["allocation","overflow","recursion"],"exports":[{"function":0,"name":"run"}],"files":{"Cargo.toml":"cde57240f2d89276727ad22fe352bdaadcee1135fda57b34fb52996e4339ae0e","src/lib.rs":"09a10d464ee6ba15459178bb03641c6b12de8df20d37bc8502ac38b3a5ea6c40"},"name":"uorc_compress","profile":"rust-std","program":"5dbefdc73a3ddff420b59ad853b79015953deacf58bb8f69c1b6773706d9334e","runtime":"8551b0f864da7656da8aa57928d23b907b4b837111b1f4aebefb1096c8e2a741","sources":["902510a05f1bb920f67821d910172b3ef557576552ad889d1d35bcf556bc6326"],"spec":"lexlean/rust-provenance/1","version":"0.1.0"}
Loading
Loading