Zulip Chat Archive

Stream: lean4

Topic: array getelem simp nf


James Gallicchio (Jun 01 2023 at 02:15):

is it possible for simp to normalize getElems to use either Fin arr.size or Nat in the index? Right now both are simp-normal, and rewriting between these forms is quickly becoming not worth the pain :weary:

I'm guessing the Nat-indexed access is quite reasonable to be simp-normal, and everything should be rewritten into that form.

James Gallicchio (Jun 01 2023 at 02:16):

(I still am suspicious whether the Fin form is even necessary, but I haven't tried removing it)

James Gallicchio (Jun 01 2023 at 02:19):

I'm also realizing the value of moving a SetElem class into std so we can do similar normalization for sets. I'm doing lots of manual proving that should just be solved by simp.

Mario Carneiro (Jun 01 2023 at 02:24):

James Gallicchio said:

is it possible for simp to normalize getElems to use either Fin arr.size or Nat in the index? Right now both are simp-normal, and rewriting between these forms is quickly becoming not worth the pain :weary:

are you sure? I see this:

@[simp] theorem getElem_fin [GetElem Cont Nat Elem Dom] (a : Cont) (i : Fin n) (h : Dom a i) :
    a[i] = a[i.1] := rfl

which suggests that the Nat form is simp-normal

James Gallicchio (Jun 01 2023 at 02:28):

:thinking: that does suggest that

James Gallicchio (Jun 01 2023 at 02:28):

why is that one not triggering? I will investigate

James Gallicchio (Jun 01 2023 at 03:03):

okay, I think this is just me not understanding simp :) I have a hypothesis roughly like \forall (i : Fin arr.size), arr[i] ..., and simp doesn't rewrite that getElem until the hypothesis is specialized.

James Gallicchio (Jun 01 2023 at 03:05):

er, no, it is rewriting it

James Gallicchio (Jun 01 2023 at 03:05):

hm. cannot reproduce anymore


Last updated: Dec 20 2023 at 11:08 UTC