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

`unsafe` 利用例: in-place な実装を用意して、それで置き換える

Open
#2,515 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

This PR gives Array.mapFinIdxM an @[implemented_by] unsafe
implementation so that mapFinIdx, mapIdxM, and mapIdx map in
place, like Array.map.

https://github.com/leanprover/lean4/commit/068011713f00d41059c2346d97fbb41ec4daf576

これは興味深いと思う。理由は

  • そもそも Lean で in-place な実装を与える方法は難しいが、unsafe を使うことで in-place 実装を与えられるという可能性を示唆している
  • unsafe を使うことが必須なのか、通常の in-place でない実装と等しいことを証明して csimp で置き換えるわけにはいかなかったのかなど、他にも気になることがある

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

Begin by reading the linked Lean commit and the definitions of Array.mapFinIdxM, mapFinIdx, mapIdxM, and mapIdx. Compare the unsafe in-place approach with the ordinary implementation and investigate whether equivalence plus csimp is viable; the issue does not specify a concrete completion criterion, so confirm the intended approach before making changes.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.