ASCII forall and exists fail to parse with binder predicates

Open
#16,315 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
66/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Domain
compilers

Research direction

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.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Lean
Stars
10.3k
Forks
1.1k
Avg merge
19h 8m
Merged PRs (30d)
421

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from leanprover/lean4

All issues in leanprover/lean4

Similar issues

More Compilers issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.