leanprover-community / mathlib4

The math library of Lean 4

Home Page:https://leanprover-community.github.io/mathlib4_docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Porting notes: additional beta_reduction necessary

grunweg opened this issue · comments

This issue is tracking all porting notes where additional beta_reduction is necessary.
Often, these porting notes take a form like

-- Porting note: `dsimp` is required for beta reduction.

or
-- Porting note (#10752): added `dsimp only`

We might just declare victory on this one: I don't think we're planning to remove the need for these beta_reduces, so the porting note is not actionable.

I think it would be good to track down the "structure constructor" occurrence further; it seems that the lack of beta reduction only happens sometimes.

Is there some explanation of what changed here? What was doing a beta reduction before that is no longer done?

Here's one example:

namespace nested

structure Foo where
  toFun : Nat → Nat

structure Bar extends Foo where
  prop : toFun 0 = 0

def bar : Bar where
  toFun x := x
  prop :=
    -- goal is { toFun := fun x => x }.toFun 0 = 0
    sorry

end nested

namespace flat

structure FlatHack

structure Foo extends FlatHack where
  toFun : Nat → Nat

structure Bar extends FlatHack, Foo where
  prop : toFun 0 = 0

def bar : Bar where
  toFun x := x
  prop :=
    -- goal is (fun x => x) 0 = 0
    sorry

end flat

vs the lean3 behavior:

set_option old_structure_cmd true

structure foo :=
  (to_fun : nat → nat)

structure bar extends foo :=
 (prop : to_fun 0 = 0)

def the_bar : bar :=
  { to_fun := λ x, x,
    prop :=
      -- goal is 0 = 0
      sorry }

(it would be really great if leanprover/lean4#2666 could be ok'd just so we can test this kind of thing without creating FlatHack every time...)