Skip to content

Commit 2ed025a

Browse files
authored
feat: mark sizeOf theorems as grind theorems (#11265)
This PR marks the automatically generated `sizeOf` theorems as `grind` theorems. closes #11259 Note: Requested update stage0, we need it to be able to solve example in the issue above. ```lean example (a: Nat) (b: Nat): sizeOf a < sizeOf (a, b) := by grind ```
1 parent 827a96a commit 2ed025a

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

src/Lean/Meta/SizeOf.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@ Released under Apache 2.0 license as described in the file LICENSE.
44
Authors: Leonardo de Moura
55
-/
66
module
7-
87
prelude
98
public import Lean.AddDecl
109
public import Lean.Meta.AppBuilder
1110
public import Lean.DefEqAttrib
12-
1311
public section
14-
1512
namespace Lean.Meta
1613

1714
/-- Create `SizeOf` local instances for applicable parameters, and execute `k` using them. -/
@@ -430,6 +427,8 @@ private def mkSizeOfSpecTheorem (indInfo : InductiveVal) (sizeOfFns : Array Name
430427
let ctorInfo ← getConstInfoCtor ctorName
431428
let us := ctorInfo.levelParams.map mkLevelParam
432429
let simpAttr ← ofExcept <| getAttributeImpl (← getEnv) `simp
430+
let grindAttr ← ofExcept <| getAttributeImpl (← getEnv) `grind
431+
let grindAttrStx ← `(attr| grind =)
433432
forallTelescopeReducing ctorInfo.type fun xs _ => do
434433
let params := xs[*...ctorInfo.numParams]
435434
let fields := xs[ctorInfo.numParams...*]
@@ -464,7 +463,8 @@ private def mkSizeOfSpecTheorem (indInfo : InductiveVal) (sizeOfFns : Array Name
464463
value := thmValue
465464
}
466465
inferDefEqAttr thmName
467-
simpAttr.add thmName default AttributeKind.global
466+
simpAttr.add thmName default .global
467+
grindAttr.add thmName grindAttrStx .global
468468

469469
private def mkSizeOfSpecTheorems (indTypeNames : Array Name) (sizeOfFns : Array Name) (recMap : NameMap Name) : MetaM Unit := do
470470
for indTypeName in indTypeNames do

stage0/src/stdlib_flags.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// update me!
12
#include "util/options.h"
23

34
namespace lean {

tests/lean/run/grind_11259.lean

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
inductive Lst (α : Type u) where
2+
| nil : Lst α
3+
| cons (head : α) (tail : Lst α) : Lst α
4+
5+
structure Prd (α : Type u) (β : Type v) where
6+
fst : α
7+
snd : β
8+
9+
example : sizeOf (@Lst.nil Nat) < sizeOf (Lst.cons 10 .nil) := by
10+
grind
11+
12+
example (a b : Nat) : sizeOf a < sizeOf { fst := a, snd := b : Prd _ _ } := by
13+
grind
14+
15+
example (a : α) (b : β) : sizeOf a < sizeOf { fst := a, snd := b : Prd _ _ } := by
16+
grind

0 commit comments

Comments
 (0)