leanprover / leanprover/lean4

`If` inside `conv`

Open
#2,063 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement P-low
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Prerequisites
  • [ x] Put an X between the brackets on this line if you have done all of the following:
    • Checked that your issue isn't already filed.
    • Reduced the issue to a self-contained, reproducible test case.
Description

if doesn't work inside of conv mode.

Steps to Reproduce
import Lean

open Lean

opaque foo : Int → Int
axiom foo.pos (x : Int) (h : x ≥ 0) : foo x =  1
axiom foo.neg (x : Int) (h : ¬(x ≥ 0)) : foo x = -1

example : foo = λ (x : Int) => if x ≥ 0 then 1 else -1 :=
by

  conv =>
    lhs; enter [x]

    if h : x ≥ 0 then
      rw [foo.pos x h]
    else
      rw [foo.neg x h]

  done

Expected behavior: This proof to work

Actual behavior: if tactic is not accepted, giving "expected command" error.

Reproduces how often: 100%

Versions

Lean (version 4.0.0-nightly-2023-01-21, commit a125a36bcc79, Release)
Windows 10.

Additional Information

On the Zulip Chat, Tomas Skrivan posted a working implementation for if and match inside of conv, including the example proof above:
https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/If.20and.20match.20in.20conv.20mode

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 with the self-contained reproduction in the issue and compare it with the working implementation linked in the Zulip discussion. The work is done when the example proof accepts the if tactic inside conv mode, including both branches shown.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.