lean-ja / lean-ja/lean-by-example

notation の priority の効果についての謎

Open
#1,516 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

要調査
Dominant language
Lean
Stars
188
Forks
15
Avg merge
9h 8m
Merged PRs (30d)
6

Description

このコードはなぜ priority := high を付けても付けなくても効果がないのか。

同じ構文に異なる解釈があるときの優先度の違いを決めているのではないのか???

/- ## 記法の重複問題
`notation` を使って定義した記法のパース優先順位が意図通りに反映されないことがあります。-/
section

  -- 排他的論理和の記号を定義
  local notation:60 (priority := high) x:60 " ⊕ " y:61 => xor x y

  -- メタ変数を表示させないため
  set_option pp.mvars false

  -- 等号(パース優先順位 50)より優先順位が低いという問題でエラーになる
  -- 上では60で定義しているのに、なぜ?
  #check_failure true ⊕ true = false

  -- 括弧を付けるとエラーにならない
  #check (true ⊕ true) = false

end

Contributor guide

Open the contributing guide

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.

Research direction

Start by running the notation declarations and #check_failure examples from the issue, then inspect the surrounding Lean notation and parser-precedence documentation. Determine why the priority annotation has no visible effect in this expression and document the distinction between notation precedence and priority, including the parenthesized form.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.