ASCII forall and exists fail to parse with binder predicates

Aperta
#16,315 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
66/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Ambito
compilers

Direzione di ricerca

Start with the bounded-binder syntax declarations in src/Init/BinderPredicates.lean and the ASCII quantifier spelling in src/Lean/Parser/Term.lean. Run the bounded_binders.lean reproductions from the issue and compare their parse behavior with the Unicode forms. Done when ASCII bounded binders parse equivalently and regression coverage checks the cases listed in the issue, including the exists tactic and pretty-printing.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Prerequisites
  • Check that your issue is not already filed:
    https://github.com/leanprover/lean4/issues
  • Reduce the issue to a minimal, self-contained, reproducible test case.
    Avoid dependencies to Mathlib or Batteries.
  • Test your test case against the latest nightly release, for example on
    https://live.lean-lang.org/#project=lean-nightly
    (You can also use the settings there to switch to “Lean nightly”)
  • When reporting a perceived soundness bug: Does it affect lake check --paranoid?
    If in doubt, please reach out on [email protected] for responsible disclosure.
Description

ASCII forall and exists fail to parse with binder predicates, although the equivalent Unicode ∀ and ∃ forms work. Plain binders accept both spellings; adding ∈ s or < n unexpectedly requires switching the quantifier to Unicode.

Context

This affects projects using ASCII quantifier keywords. The motivating example is microsoft/CCF, whose downstream compatibility module adds ASCII bounded-binder syntax rewriting to the Unicode forms; this workaround was reported to compile on Lean 4.35.0 without breaking the exists tactic.

Searches of Lean issues, PRs, and the public Zulip archive did not find a duplicate or prior discussion specifically about these ASCII spellings.

Steps to Reproduce
  1. Save this self-contained file as bounded_binders.lean (no additional imports):
example : forall n ∈ [1, 2], n > 0 := by decide
example : exists n ∈ [1, 2], n > 1 := by decide
example : forall n < 3, n < 5 := by omega
  1. Run lean bounded_binders.lean.
  2. Compare with the following successful Unicode equivalents and plain ASCII binders:
example : ∀ n ∈ [1, 2], n > 0 := by decide
example : ∃ n ∈ [1, 2], n > 1 := by decide
example : ∀ n < 3, n < 5 := by omega

example : forall n : Nat, n = n := by intro n; rfl
example : exists n : Nat, n = 1 := by exists 1
example : ∃ n, n = 1 := by exists 1

Expected behavior: All three ASCII bounded-binder examples should elaborate with the same meaning as their Unicode equivalents.

Actual behavior: The first two examples report unexpected token '∈'; expected ','. The third reports unexpected token '<'; expected ','.

Versions

#eval Lean.versionString outputs "4.35.0"; lean --version reports Lean (version 4.35.0, Release).

Also reproduced all three errors on the latest published nightly as of 2026-11-06: nightly-2026-11-06.

Lean (version 4.37.0-nightly-2026-11-06, x86_64-unknown-linux-gnu, commit d4cada4c0c02734da4a3a00dac27faa8ca2b912b, Release)

The Unicode equivalents and plain ASCII binders elaborate successfully on both versions.

OS: Azure Linux 4.0 (Container Image Beta), x86_64; Linux kernel 6.8.0-1064-azure.

Additional Information

The plain universal binder uses unicodeSymbol "∀" "forall" in src/Lean/Parser/Term.lean, but the separate bounded-binder rules in src/Init/BinderPredicates.lean register only Unicode tokens:

syntax "∃ " binderIdent binderPred ", " term : term
syntax "∀ " binderIdent binderPred ", " term : term

A possible fix is to use the existing syntax DSL mechanism for alternate spellings:

syntax unicode("∃ ", "exists ") binderIdent binderPred ", " term : term
syntax unicode("∀ ", "forall ") binderIdent binderPred ", " term : term

The suggested fix has not yet been implemented or verified. Regression tests should check equivalent macro expansion (including anonymous binders), continued parsing of the exists tactic, and pretty-printing with Unicode enabled and disabled.

Soundness prerequisite: N/A; this is a parser inconsistency, not a perceived soundness bug.

Investigation and issue drafting assisted by GitHub Copilot.

Lingua principale
Lean
Stelle
10.3k
Fork
1.1k
Merge medio
19h 8m
PR unite (30g)
421

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di leanprover/lean4

Tutte le issue di leanprover/lean4

Issue simili

Altre issue su Compilers

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.