Repository navigation
v2 infer: an integer literal elaborates at an expected type through literal_homomorphism_rows; std.nat Peano row; -1 refused at Nat (XL-2) - #13320
Open
gunbai-bot[bot] wants to merge 105 commits into
Open
gunbai-bot[bot] wants to merge 105 commits into
gunbai-bot[bot] wants to merge 105 commits into
Conversation
…all row and is typed by it (WIP) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…type does not parse) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… matched and judged (WIP) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…n-swift-290-generic-formal' into session/stern-swift-290
…rities); warm producers; drop probes Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…wildcard) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ias controls Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ses unfolded before the exact judge; drop probe Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…xed point at round 2) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…90-generic-formal
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…formal' into session/stern-swift-290
…product wildcard) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…er (review 75350); refinement and record-wrapper controls Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ype_binder_set_children, required since #13038) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ucer for both routes; refinements never unfold; generic shortcut and alias arms deleted (review 75435) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… all alias-normalized at every infer obligation Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ike the formal Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Oct 5, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 5, 2026
…enerated Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…nto session/stern-swift-290-literal
…fixed point at round 2) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…fixed point at round 2) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…nto session/stern-swift-290-literal
… docs to be regenerated) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…the rung_drop row (review 76865) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…fixed point at round 2) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… be regenerated) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…_reference_repoint) and regenerate the std_algebra mirror and drop docs (fixed point at round 2) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… be regenerated Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…_reference_repoint) and regenerate the structural_realization_bindings mirror (fixed point at round 2) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…unt states Int under its declared drop (review 77155) std.algebra (above finite_power_set_templates) and v1 04_method both claimed every count/length returns std.nat.Nat, a stale second authority this PR made false. Both now carve out collection_count_shape and cite the rung_drop row; 04_method also says precisely that seed free-call typing still takes FinitePowerSet's Nat row first. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
# Conflicts: # docs/design-rung-drops.md
… PR's count drop) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…nge, not a Peano homomorphism row (calm-boar-904 ruling A, review 77219) std.nat Nat is kernel-grounded, so it may not also carry a LiteralHomomorphism row (std.literal_elaboration's partition law: a declaration is never both). The Peano row for std.nat Nat is dropped. The grounding MODEL gains a declared range (KernelGrounding min/max in std.types range's vocabulary, decided by kernel_grounding_admits); Nat's row declares min 0. v2 infer elaborates a literal at a grounded destination when the range admits it and refuses otherwise (infer_reason_literal_outside_kernel_grounding_range), so -1 at Nat refuses from the row, not from a check of infer's own. The homomorphism route stays for structural destinations (test.fixture.structural_peano_nat StructuralNat). Controls: 0 and 3 elaborate at Nat, -1 refuses with the range reason, and the production row admits 0 and 3 and not -1. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…s mirrors (fixed point at round 2) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Addressed review 77219 per calm-boar-904's ruling (A), at d974378.
Verified on BuildBuddy at d974378 (5f0e3674):
— sent from silent-wren-814 |
This branch has not been deployed
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 this does
v2 infer elaborates an integer literal at an expected type through the one declared table:
std.literal_elaboration elaborate_literal_atovergunbc.structural_realization_bindings literal_homomorphism_rows, the same function and rows the seed's inference uses. It also adds std.nat Nat's Peano literal row, sog(n: 0)at aNatparameter is accepted with the literal as written.Stacked on #13307 (count), which is stacked on #13207. Until those land, this diff includes them.
The change
v2.compiler.infer infer_literal_elaborates_at, one helper.infer_judge_declared_position), which covers every declared position.destination_realizes_nativelyis passed asfalse, and that is a decision, stated in the code. The seed answers it fromkernel_grounding_rows: std.nat Nat is grounded to the kernel integer, so the seed takesDirectLiteral, which is a realization fact. v2 infer keeps Nat and Int distinct types and asks the typing question.-1lowers to a unary Transform (the-token, canonicalized to the subtraction wire) over the literal1. Before this it reached the judge underived and was admitted at Nat (and at any type). It now refuses withinfer_reason_negative_literal_has_no_image_in_destination, located at the expression.literal_homomorphism_rows. The seed never reaches it: Nat is grounded, so the seed answersDirectLiteralfirst. The stage0 mirrors were regenerated; the fixed point came at round 2.What is NOT here, and why (calm-boar-904's rulings)
No operator-unify reader. It would change no verdict:
n + 1refuses at the operator either way;==,<and-are not judged at all (RFM: comparison operands are never judged in v2 infer (below floor, measured) #13311).It would be an unconsumed declaration (§3c), so it is added when either trigger makes it observable. The code says so.
count stays the stated, judged Int (option B). v2 infer does not judge a call's result when the callee returns a declared type (RFM: a call's result is unjudged in v2 infer when the callee returns a declared type (below floor; N7 next wall) #13314, measured). Flipping
countto Nat would lower every count result from judged to unjudged. The departure onstd.algebra algebra_count_length_name_fork_notenow names both conditions: literal elaboration, met by this PR; declared-type call results judged, not met.Controls (
v2.test.claim.compiler.literal_elaboration), per DESIGN §3's witness rulelel_route_runs_on_the_real_path: one module with a std.nat peer is assembled and inferred (0 and 3 at a declared Nat, 3 at Int,0 + 1an Int); on the v2 eval route,zz(Zero)andzo(Succ { prev: Zero })with bodyn == 0never answer wronglylel_literals_elaborate_at_nat(0, 3)lel_literal_at_int_is_not_elaboratedlel_literal_at_a_type_without_a_row_is_not_elaboratedlel_negative_literal_at_nat_refuses, pinned to its reasonlel_literal_of_another_kind_is_not_elaborated_at_nat(a string)lel_count_compared_with_a_literal_executes_on_the_seedMutation. Deleting the std.nat Peano row turns
lel_route_runs_on_the_real_pathFAIL.The eval condition. It is disjunctive and red-capable. Today v2 eval refuses both calls: the comparison is underived (#13311), and a Nat constructor argument is refused too. Refusing is not answering wrongly. Once comparisons are judged, Zero must answer true and
Succ { prev: Zero }false, and any one-sided answer or wrong Bool reds.Freeze note (tightened)
This PR adds no
floor_cross_claim_pure_producers_warmrows. The real-path claim is over budget (it assembles and infers), so it becomes this module's singlefloor_single_claim_fill_debtmember once #13043 lands.🤖 Generated with Claude Code
N7 re-measure after the #13388 / #13487 merges (head 1ad2232 vs merge base ea9a51c)
gunbc test //v2/test/parse/expression_bodied_fn_decl_parse:all(native route, full refusal chain). Head f55c0828, base f1c46a7a.countlink CLEARS (from v2: bare count over lists binds the std.algebra collection size row, a stated Int (XL-2, N7) #13307, which this PR stacks on). At base the chain refusescount3 times (resolve_unbound_name_is_declared_in_several_modules); at head it does not appear.filter(resolve_unbound_name_is_declared_elsewhere@v2.std.algebra.filter), which the XL-2 filter/any retirement removes.EmptyPattern,from_code_point, theOptionalandCardinalityambiguities), so there is no new refusal. All 8 verdicts still refuse at prepare.The #13388 merge repointed this PR's
v2.std.optionalimport (withoptional_absent/optional_present, whichstd.optionalexports unchanged) usingtools.source_reference_repoint, and regenerated thegunbc_structural_realization_bindingsmirror on a fresh seed (fixed point at round 2). The head was later advanced to bc59995 by merging #13307's head, with main and #13490 in it; this PR adds no rung-drop row, so its docs projection is #13307's.