Skip to content

emitter(v1-seed): numeric tower Nat/Int -> host i64 in seed branch - #5392

Merged
briansrls merged 1 commit into
mainfrom
emitter/numeric-tower-seed
Jun 20, 2026
Merged

briansrls merged 1 commit into
mainfrom
emitter/numeric-tower-seed

Conversation

@gunbai-bot

@gunbai-bot gunbai-bot Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

What

Adds rust_seed_host_numeric_alias to the v1 Rust emitter (src/v1/05_emit_rust.dag): in the seed corpus branch only (gated by the same rust_corpus_includes_v1_compiler authority as the String text carrier — single lever, no parallel mechanism), the algebraic numeric tower renders as the host primitive i64:

  • type Nat = CommutativeSemiring<Magnitude> → pub type Nat = i64;
  • type Int = AbelianGroup<GroupCompletion<Nat>> → pub type Int = i64;

One site (the type-alias emit in emit_typed_item). No op-realization needed: the seed nat ops (nat_compare/nat_max/nat_min) use only </>/.clone(), all native to i64; usages render as the alias name, which now resolves to i64.

Why

The v1 stage0 seed consumes dsl/std, where the numeric tower is an algebraic dict-with-fn-fields. Emitting it as Rc<CommutativeSemiring<Magnitude>> means:

  • fn-field structs can't derive Serialize/Debug/PartialEq → every Nat-as-number consumer fails (E0277)
  • no PartialOrd → the seed's own nat_compare/nat_max/nat_min fail (E0369)

Per DESIGN §7, the Rust seed is one realization that keeps host primitives; the algebraic carrier is the v2/model representation. v2-target faithful numeric representation is escalated to operator + non-blocking; the faithful branch leaves the algebraic alias intact.

Verification

The full 2-stage regen self-host oracle is blocked (the stage0 crate couples the broken std consumers into the compiler bin, so a non-fixpoint intermediate can't rebuild the self-hosted compiler). Measured the slice by hand-applying the emitter's exact output (the two alias lines → i64) to a regenerated seed and rebuilding v1-compiler:

182 → 130 errors (−52): E0277 25→3, E0369 11→2, E0308 55→45, E0599 4→1.

Emission itself confirmed: a fresh regen on this branch writes rust_seed_host_numeric_alias into the compiler's own v1_compiler_emit_rust.rs (definition + call site), and the edited .dag parses/typechecks/compiles (regen exit 0).

Scope

.dag-only — the committed seed is unchanged, so main keeps building. emitter-completeness slice, NOT seed-green; seed-green lands in #5325.

🤖 Generated with Claude Code

The v1 stage0 seed consumes dsl/std, where the numeric tower is algebraic:
`type Nat = CommutativeSemiring<Magnitude>`, `type Int = AbelianGroup<
GroupCompletion<Nat>>`. The emitter renders these dict-with-fn-fields aliases
as `Rc<CommutativeSemiring<Magnitude>>`, which (a) can't derive
Serialize/Debug/PartialEq (fn fields), breaking every Nat-as-number consumer
(E0277), and (b) has no PartialOrd, breaking the seed's own nat_compare/
nat_max/nat_min comparisons (E0369).

Per DESIGN §7 (the Rust seed is one realization that keeps host primitives;
the algebraic carrier is the v2/model representation), map Nat/Int to the host
primitive i64 in the SEED corpus branch only — gated by the SAME
`rust_corpus_includes_v1_compiler` authority as the String text carrier (single
lever, no parallel mechanism). One site (the type-alias emit). No op-realization
needed: the seed nat ops use only </>/.clone(), all native to i64; usages render
as the alias name, which now resolves to i64.

v2-target faithful numeric representation is escalated to operator + non-blocking;
the faithful branch leaves the algebraic alias intact.

Verified by execution: hand-applying the emitter's output (the two alias lines
-> i64) to a regenerated seed and rebuilding v1-compiler drops 182 -> 130 errors
(E0277 25->3, E0369 11->2, E0308 55->45, E0599 4->1). DISSOLUTION: remove when
the numeric tower gains a faithful host-realization seam mirroring the text carrier.

emitter-completeness slice, NOT seed-green; seed-green lands in #5325.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@briansrls
briansrls merged commit 58fd158 into main Jun 20, 2026
1 check passed
@briansrls
briansrls deleted the emitter/numeric-tower-seed branch June 20, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant