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

Coe ↑ の明示的な指定で違いが出る例

Open
#544 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

TPiL に載っている例

def Set (α : Type u) := α → Prop
def Set.empty {α : Type u} : Set α := fun _ => False
def Set.mem (a : α) (s : Set α) : Prop := s a
def Set.singleton (a : α) : Set α := fun x => x = a
def Set.union (a b : Set α) : Set α := fun x => a x ∨ b x
notation "{ " a " }" => Set.singleton a
infix:55 " ∪ " => Set.union
def List.toSet : List α → Set α
  | []    => Set.empty
  | a::as => {a} ∪ as.toSet

instance : Coe (List α) (Set α) where
  coe a := a.toSet

def s : Set Nat := {1}
#check s ∪ [2, 3]

-- この x は Set になっている
#check let x := ↑[2, 3]; s ∪ x

-- この x は List のまま
#check let x := [2, 3]; s ∪ x

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

The issue provides a TPiL Lean example contrasting an explicit Coe conversion with an inferred one. First locate the corresponding example section in the repository and run the three #check cases in Lean. Done means documenting the observed difference and making the intended explanation or example clear to readers.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.