Aiur kernel: fix Lean.Syntax.rec (shard 53) + ix name-of#464
Open
arthurpaulino wants to merge 2 commits into
Open
Aiur kernel: fix Lean.Syntax.rec (shard 53) + ix name-of#464arthurpaulino wants to merge 2 commits into
ix name-of#464arthurpaulino wants to merge 2 commits into
Conversation
`ix name-of --ixe <path> <hex>`: given a 32-byte hex address, scan the `.ixe` env's `named` map and print the fully-qualified Lean.Name of the const stored under that address. Prints an error + exits 1 if no named const matches (the address might be an unnamed intermediate constant or a blob). Complements `ix addr-of` (name → address). Used to backtrack from an assertion-failure address logged mid-kernel-execution to the offending Lean constant.
Three interlocking bugs in the Aiur block-flattening / recursor-type builder caused `ix check --interp bytecode Lean.Syntax.rec` to fail with `assert_eq mismatch: 0 != 1` on the declared-vs-canonical type equality: - `build_flat_block` traversed originals once; nested-aux members (`Array Syntax`, `List Syntax`) never had their own ctors scanned, so `flat` had 2 motives when Lean's recursor declares 3. Replaced with a queue-based fixed point mirroring `crates/kernel/src/inductive.rs: build_flat_block:531-599`. - `is_rec_field` classified any ctor field as recursive when its spine head Const-idx matched a flat member's ind idx. For `Lean.Syntax.ident`, the field `preresolved : List Preresolved` shares the base List const idx with the block's `List Lean.Syntax` aux and got a spurious `motive_2 preresolved` IH binder. Match key is now (head_idx, spine-arg prefix ≡ member.spec_params) — direct members carry `spec_params = []` and match on idx alone, auxes require the concrete occurrence. - `build_all_minors` was iterating `flat` and passing the shrinking suffix into `build_minor_doms`, so field classification for later members was blind to earlier members. Split into a wrapper + `build_all_minors_walk` that pins the caller's full flat while the iteration state shrinks. Pin `Lean.Syntax.rec` in the ixvm test suite; rebump every FFT cost shifted by the codegen refresh (`ix codegen`).
ad157a6 to
6197f48
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
IxVM Aiur kernel: fix Lean.Syntax.rec (shard 53) aux-recursor genix check --interp bytecode Lean.Syntax.recfailed withassert_eq mismatch: 0 != 1on the declared-vs-canonical type equality. Threeinterlocking bugs in the Aiur block-flattening / recursor-type builder:
Single-pass flat traversal.
build_flat_blockscanned originalsonce; nested-aux members (
Array Syntax,List Syntax) never hadtheir own ctors scanned, so
flathad 2 motives when Lean's recursordeclares 3. Replaced with a queue-based fixed point mirroring
crates/kernel/src/inductive.rs:build_flat_block:531-599.is_rec_fieldmatched on const idx alone. ForLean.Syntax.identthe field
preresolved : List Preresolvedshares the baseListconst idx with the block's
List Lean.Syntaxaux, so it got aspurious
motive_2 preresolvedIH binder. Match key is now(head_idx, spine-arg prefix ≡ member.spec_params)— direct memberscarry
spec_params = []and match on idx alone; auxes require theconcrete occurrence via new
find_flat_member_match+spine_prefix_eq+kexpr_struct_eqhelpers.build_all_minorsshrunkflatin-flight. It iteratedflatandpassed the shrinking suffix into
build_minor_doms, so later members'ctor-field classification was blind to earlier members. Split into a
thin wrapper
build_all_minors+build_all_minors_walkthat pinsthe caller's full flat while iteration state shrinks.
Every recursor gen call site (
build_minor_at_depth,build_minor_doms,build_rule_rhs,populate_rules) now threads the fullflatalongsideflat_idxs.Ships pinned FFT cost for
Lean.Syntax.recin the ixvm test suite andre-pins every stdlib / primitive / prelude cost that shifted from the
codegen refresh.
List.rec,Array.rec,Lean.Syntax.rec_1,Lean.Syntax.rec_2verified to still pass.ix name-of: reverse-lookup a Lean.Name from its content addressix name-of --ixe <path> <hex>: given a 32-byte hex address, scan the.ixeenv'snamedmap and print the fully-qualifiedLean.Nameofthe const stored at that address. Exits 1 with an error if no named
const matches (unnamed intermediate const or a blob).
Complements
ix addr-of(name → address). Primary use: backtrack froman assertion-failure address logged mid-kernel-execution to the
offending Lean constant.
Test plan
lake test -- --ignored ixvmpasses end-to-end with the new pins.ix check --interp bytecode Lean.Syntax.recexits 0.ix check Lean.Syntax.rec(codegen path, afterix codegen) exits 0.ix check --interp bytecode List.rec Array.rec Lean.Syntax.rec_1 Lean.Syntax.rec_2all exit 0.ix name-of --ixe <ixe> <hex-of-known-named>prints the expected fully-qualified name; unknown address exits 1.