Skip to content

Model template field equalities from constructor hypotheses - #1943

Closed
oxura wants to merge 1 commit into
bendlang:mainfrom
oxura:fix/1182-projection-models-20261029
Closed

oxura wants to merge 1 commit into
bendlang:mainfrom
oxura:fix/1182-projection-models-20261029

Conversation

@oxura

@oxura oxura commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Refs #1182.

This handles the constructor-equality case without needing an inj helper. Model search can use an available equation directly, or build a total field projection and use ordinary rewrite/reflexivity. Fields must have non-dependent types; the kernel is unchanged.

This is not a general model-search fix: k and pick from the thread are not addressed. Erased evidence, unrelated fields and impossible result models stay out of scope. No root-constant backtracking.

Requalified on main 4982c105, after #1930 actually merged. Seven consumer inputs and ten existing model/proof inputs keep the expected kernel verdicts; bun gates/repo.ts passes 54/54 with the existing caps. These were real local --verdict runs on Linux with Lean 4.34.0, not the cluster gate.

This no-helper input now prints ALL PROOFS CHECK with bend case.bend --verdict:

import Base

type N is Data:
  Z{}
  S{p: N}

law use:
  for ~F: @a: N -> @b: N -> {S{a} == S{b} : N} -> {a == b : N}
  for a: N
  for b: N
  for e: {S{a} == S{b} : N}
  {a == b : N}

def use(F, a, b, e):
  F(a, b, e)

def main() -> N:
  Z{}

@Lorenzobattistela

Copy link
Copy Markdown
Collaborator

Thanks for the careful work here, and for being upfront about the scope. We're going to close this one, though.

The new branch in model_at recognizes one shape: an equation hypothesis between the same constructor, with the goal's two sides in the same field position, and that field's type not depending on other fields. It doesn't cover the symmetric goal ({b == a} from S{a} == S{b}), nested constructors, dependent fields, or the other #1182 repros (k, pick). Each of those would need another special case like this one, and we'd rather not grow model search one shape at a time.

It also costs about 635 ttok in safe.ts, which is at 23,993/24,000 on main, so merged onto main it no longer fits under the cap. For a single pattern that's too much budget.

@oxura

oxura commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Fair point — this only handles one projection shape, and the cap makes the tradeoff worse. I won’t add more cases to this branch. Thanks for reviewing it.

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.

2 participants