Skip to content

docs(lean,#9568): document the Decidable-instance non-propagation pitfall - #9788

Merged
jsboige merged 1 commit into
mainfrom
feature/lean-decidable-instance-doc
Aug 7, 2026
Merged

jsboige merged 1 commit into
mainfrom
feature/lean-decidable-instance-doc

Conversation

@jsboige

@jsboige jsboige commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Summary

Grain : MED/docs — nouveau doc docs/lean/decidable_instance_propagation.md (FR-first) capturant le piège Lean 4 rencontré en livrant le Livrable B #9780 : une def foo : Prop := Bar x wrapper n'hérite pas de l'instance Decidable (Bar x), donc by native_decide/by decide sur foo witness échoue avec failed to synthesize Decidable (foo witness) alors que l'instance sous-jacente existe. Demandé par ai-01 (DM msg-ngg5o3) : la leçon méritait de vivre hors d'un DM — « typiquement ce qui se reperd ».

Le piège

Lean ne réduit pas une def non-@[reducible] lors de la synthèse d'instance. L'unificateur trouve Decidable (Bar x) pour la tête Bar, mais le wrapper foo est opaque — il ne le déplie pas pour découvrir l'instance recouverte. La synthèse échoue au niveau du wrapper, pas de la Prop sous-jacente.

Les 3 fixes documentés

  1. Instance compagnon (pattern canonique codebase) — inferInstanceAs, exactement comme BoxAssezGrandN déclare la sienne au-dessus de l'instance native (Conway/Life/HashlifeCorrectness.lean ~L227).
  2. abbrev — @[reducible] par construction, instance trouvée par réduction.
  3. @[reducible] def — même effet, conserve le mot-clé def.

Incident fondateur

PR #9780 (Livrable B #9568) : le prédicat supportInMargin c k := BoxAssezGrandN (c.toGrid (0,0)) (2^k) → 4 sanity-checks by native_decide échouaient failed to synthesize Decidable (supportInMargin ...). Fix appliqué : instance compagnon (option 1), build repassé vert (FR/EN 8500 jobs EXIT 0). Vérifié firsthand WSL v4.31.0-rc1.

Diagnostic (le tell)

failed to synthesize Decidable (<votre_def> ...) alors que la Prop sous-jacente a démontrablement une instance Decidable → ne pas chercher une instance manquante (elle existe), déclarer l'instance compagnon au niveau du wrapper.

Détails

See #9568 (Livrable B, PR #9780 où le piège a été rencontré).

🤖 Generated with Claude Code

…fall

New FR-first doc `docs/lean/decidable_instance_propagation.md` capturing the Lean 4
gotcha hit while delivering Livrable B (PR #9780): a `def foo : Prop := Bar x` wrapper
does NOT inherit the `Decidable (Bar x)` instance, so `by native_decide`/`by decide` on
`foo witness` fails with `failed to synthesize Decidable (foo witness)` even though the
underlying instance exists. Lean does not reduce a non-reducible def during instance
synthesis. Documented the 3 fixes (companion instance — canonical codebase pattern, e.g.
BoxAssezGrandN at HashlifeCorrectness L227 — / abbrev / reducible def), the founding
incident (#9780 supportInMargin), and the diagnostic tell.

Requested by ai-01 (DM msg-ngg5o3): the lesson deserved to live outside a DM — typically
the kind of knowledge that gets lost. Was only in machine memory
(lean-decidable-instance-not-propagated-through-def-prop, c.939); now in repo docs/ for
cross-machine/cross-session visibility.

FR-first (readme-french-first mandate). §E docs audit: new file, internally coherent,
codebase references (L227, PR #9780, issue #9568) verified firsthand. Catalogue
byte-identical (doc-only, no .lean/.ipynb touched). See #9568.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added the variation-tag-lane-missing Tag Grain sans 'lane <machine:workspace>' (cap G-VAR-2 incomptable) label Aug 7, 2026
@jsboige
jsboige merged commit 36a6f73 into main Aug 7, 2026
14 checks passed
jsboige added a commit that referenced this pull request Aug 9, 2026
…ry) (#10132)

Create docs/lean/README.md — thematic index (pièges tactiques · prover
& LLM · i18n FR/EN · toolchain) wiring the 9 reference docs that were
orphaned (no pointer linked them, incl. the #9568 Decidable-instance
non-propagation pitfall from #9788). Found via check_docs_links.py
--orphans. French-first per readme-french-first.

See #7422. Grain: LIGHT/docs — lane myia-po-2024:CoursIA — prev: MED/docs #10125

Co-authored-by: Claude-Code <noreply@anthropic.com>
@jsboige
jsboige deleted the feature/lean-decidable-instance-doc branch September 2, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

variation-tag-lane-missing Tag Grain sans 'lane <machine:workspace>' (cap G-VAR-2 incomptable)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant