Zulip Chat Archive

Stream: lean4

Topic: nested inductive equational lemmas?


James Gallicchio (Nov 29 2023 at 05:09):

an MWE:

import Std.Data.Array.Basic

inductive ReducedForm (L : Type u) : Type u
| and (fs : Array (ReducedForm L)) : ReducedForm L
| or  (fs : Array (ReducedForm L)) : ReducedForm L
| lit (l : L) : ReducedForm L

theorem ReducedForm.toPropFun (r : ReducedForm L) : Nat :=
  match r with
  | and fs =>
    let fs' := fs.attach.map (fun x,_ => ReducedForm.toPropFun x)
    Array.size fs'
  | or fs  =>
    let fs' := fs.attach.map (fun x,_ => ReducedForm.toPropFun x)
    Array.size fs'
  | lit _ => 0

example : ReducedForm.toPropFun (.lit l : ReducedForm L) = 0 := by
  simp [ReducedForm.toPropFun]

example : ReducedForm.toPropFun (.lit l : ReducedForm L) = 0 := by
  unfold ReducedForm.toPropFun
  rw [WellFounded.fix_eq]

I expected the first example to prove by its equational lemmas, but it doesn't. is this expected?

Mario Carneiro (Nov 29 2023 at 05:11):

you made it a theorem, this is like opaque

James Gallicchio (Nov 29 2023 at 05:11):

:man_facepalming:

James Gallicchio (Nov 29 2023 at 05:12):

forgot that turns off the equational lemma generation :sob: then this is a feature request for a warning when you try to simp a theorem

Mario Carneiro (Nov 29 2023 at 05:12):

um...

Mario Carneiro (Nov 29 2023 at 05:12):

people use theorems in simp all the time

James Gallicchio (Nov 29 2023 at 05:12):

err, you are right :stuck_out_tongue: i have no clue what this request is then

Mario Carneiro (Nov 29 2023 at 05:13):

probably to make defTheorem a lean linter

James Gallicchio (Nov 29 2023 at 05:13):

I think mathlib also has a linter for theorems with return type not in Prop right?

James Gallicchio (Nov 29 2023 at 05:13):

yeah

Mario Carneiro (Nov 29 2023 at 05:13):

you can run #lint but it's not as obvious

James Gallicchio (Nov 29 2023 at 05:13):

thanks for the fast response :racecar: my proofing is once again proceeding


Last updated: Dec 20 2023 at 11:08 UTC