feat: no [defeq] attribute on sizeOf_spec lemmas (#13320)

This PR changes the auto-generated `sizeOf` definitions to be not
exposed and the `sizeOf_spec` theorem to be not marked `[defeq]`.
This commit is contained in:
Joachim Breitner 2026-04-08 13:10:50 +02:00 committed by GitHub
parent 8353964e55
commit 2398d2cc66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 19 additions and 23 deletions

View file

@ -149,17 +149,15 @@ partial def mkSizeOfFn (recName : Name) (declName : Name): MetaM Unit := do
trace[Meta.sizeOf] "declName: {declName}" trace[Meta.sizeOf] "declName: {declName}"
trace[Meta.sizeOf] "type: {sizeOfType}" trace[Meta.sizeOf] "type: {sizeOfType}"
trace[Meta.sizeOf] "val: {sizeOfValue}" trace[Meta.sizeOf] "val: {sizeOfValue}"
-- We expose the `sizeOf` functions so that the `spec` theorems can be publicly `defeq` addDecl <| Declaration.defnDecl {
withExporting do name := declName
addDecl <| Declaration.defnDecl { levelParams := levelParams
name := declName type := sizeOfType
levelParams := levelParams value := sizeOfValue
type := sizeOfType safety := DefinitionSafety.safe
value := sizeOfValue hints := ReducibilityHints.abbrev
safety := DefinitionSafety.safe }
hints := ReducibilityHints.abbrev enableRealizationsForConst declName
}
enableRealizationsForConst declName
/-- /--
Create `sizeOf` functions for all inductive datatypes in the mutual inductive declaration containing `typeName` Create `sizeOf` functions for all inductive datatypes in the mutual inductive declaration containing `typeName`
@ -469,7 +467,6 @@ private def mkSizeOfSpecTheorem (indInfo : InductiveVal) (sizeOfFns : Array Name
type := thmType type := thmType
value := thmValue value := thmValue
} }
inferDefEqAttr thmName
simpAttr.add thmName default .global simpAttr.add thmName default .global
grindAttr.add thmName grindAttrStx .global grindAttr.add thmName grindAttrStx .global

View file

@ -1,5 +1,7 @@
import Lean.Meta.Basic import Lean.Meta.Basic
set_option warn.sorry false
inductive StructLike α where inductive StructLike α where
| mk : α → StructLike α | mk : α → StructLike α
@ -8,7 +10,7 @@ inductive Nested where
| other | other
/-- /--
info: @[defeq] theorem Nested.nest.sizeOf_spec : ∀ (a : StructLike Nested), sizeOf (Nested.nest a) = 1 + sizeOf a := info: theorem Nested.nest.sizeOf_spec : ∀ (a : StructLike Nested), sizeOf (Nested.nest a) = 1 + sizeOf a :=
fun a => Eq.refl (1 + sizeOf a) fun a => Eq.refl (1 + sizeOf a)
-/ -/
#guard_msgs in #guard_msgs in

View file

@ -1,2 +0,0 @@
issue5661.lean:48:0-48:8: warning: declaration uses `sorry`
issue5661.lean:66:8-66:23: warning: declaration uses `sorry`

View file

@ -1,5 +1,5 @@
@[defeq] theorem TreePos.leaf.sizeOf_spec.{u, v} : ∀ {α : Type u} {β : Type v} [inst : SizeOf α] [inst_1 : SizeOf β] theorem TreePos.leaf.sizeOf_spec.{u, v} : ∀ {α : Type u} {β : Type v} [inst : SizeOf α] [inst_1 : SizeOf β] (a : α),
(a : α), sizeOf (TreePos.leaf a) = 1 + sizeOf a := sizeOf (TreePos.leaf a) = 1 + sizeOf a :=
fun {α} {β} [SizeOf α] [SizeOf β] a => Eq.refl (1 + sizeOf a) fun {α} {β} [SizeOf α] [SizeOf β] a => Eq.refl (1 + sizeOf a)
theorem TreePos.node.sizeOf_spec.{u, v} : ∀ {α : Type u} {β : Type v} [inst : SizeOf α] [inst_1 : SizeOf β] theorem TreePos.node.sizeOf_spec.{u, v} : ∀ {α : Type u} {β : Type v} [inst : SizeOf α] [inst_1 : SizeOf β]
(children : List (List (TreeNeg α β))), sizeOf (TreePos.node children) = 1 + sizeOf children := (children : List (List (TreeNeg α β))), sizeOf (TreePos.node children) = 1 + sizeOf children :=

View file

@ -1,11 +1,10 @@
@[defeq] theorem AList.nil.sizeOf_spec.{u} : ∀ {α β : Type u} [inst : SizeOf α] [inst_1 : SizeOf β], theorem AList.nil.sizeOf_spec.{u} : ∀ {α β : Type u} [inst : SizeOf α] [inst_1 : SizeOf β], sizeOf AList.nil = 1 :=
sizeOf AList.nil = 1 :=
fun {α β} [SizeOf α] [SizeOf β] => Eq.refl 1 fun {α β} [SizeOf α] [SizeOf β] => Eq.refl 1
@[defeq] theorem AList.cons.sizeOf_spec.{u} : ∀ {α β : Type u} [inst : SizeOf α] [inst_1 : SizeOf β] (a : α) theorem AList.cons.sizeOf_spec.{u} : ∀ {α β : Type u} [inst : SizeOf α] [inst_1 : SizeOf β] (a : α) (t : BList α β),
(t : BList α β), sizeOf (AList.cons a t) = 1 + sizeOf a + sizeOf t := sizeOf (AList.cons a t) = 1 + sizeOf a + sizeOf t :=
fun {α β} [SizeOf α] [SizeOf β] a t => Eq.refl (1 + sizeOf a + sizeOf t) fun {α β} [SizeOf α] [SizeOf β] a t => Eq.refl (1 + sizeOf a + sizeOf t)
@[defeq] theorem BList.cons.sizeOf_spec.{u} : ∀ {α β : Type u} [inst : SizeOf α] [inst_1 : SizeOf β] (b : β) theorem BList.cons.sizeOf_spec.{u} : ∀ {α β : Type u} [inst : SizeOf α] [inst_1 : SizeOf β] (b : β) (t : AList α β),
(t : AList α β), sizeOf (BList.cons b t) = 1 + sizeOf b + sizeOf t := sizeOf (BList.cons b t) = 1 + sizeOf b + sizeOf t :=
fun {α β} [SizeOf α] [SizeOf β] b t => Eq.refl (1 + sizeOf b + sizeOf t) fun {α β} [SizeOf α] [SizeOf β] b t => Eq.refl (1 + sizeOf b + sizeOf t)
theorem Boo.mk.sizeOf_spec.{u} : ∀ {α : Type u} [inst : SizeOf α] (a : α) (cs : BList (Foo α) (Boo α)), theorem Boo.mk.sizeOf_spec.{u} : ∀ {α : Type u} [inst : SizeOf α] (a : α) (cs : BList (Foo α) (Boo α)),
sizeOf (Boo.mk a cs) = 1 + sizeOf a + sizeOf cs := sizeOf (Boo.mk a cs) = 1 + sizeOf a + sizeOf cs :=