Repository navigation
emitter(v1-seed): numeric tower Nat/Int -> host i64 in seed branch - #5392
Merged
Merged
Conversation
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>
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.
What
Adds
rust_seed_host_numeric_aliasto the v1 Rust emitter (src/v1/05_emit_rust.dag): in the seed corpus branch only (gated by the samerust_corpus_includes_v1_compilerauthority as the String text carrier — single lever, no parallel mechanism), the algebraic numeric tower renders as the host primitivei64: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 toi64; usages render as the alias name, which now resolves toi64.Why
The v1 stage0 seed consumes
dsl/std, where the numeric tower is an algebraic dict-with-fn-fields. Emitting it asRc<CommutativeSemiring<Magnitude>>means:Serialize/Debug/PartialEq→ every Nat-as-number consumer fails (E0277)PartialOrd→ the seed's ownnat_compare/nat_max/nat_minfail (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 rebuildingv1-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_aliasinto the compiler's ownv1_compiler_emit_rust.rs(definition + call site), and the edited.dagparses/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