File tree Expand file tree Collapse file tree 3 files changed +21
-4
lines changed
Expand file tree Collapse file tree 3 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -4,14 +4,11 @@ Released under Apache 2.0 license as described in the file LICENSE.
44Authors: Leonardo de Moura
55-/
66module
7-
87prelude
98public import Lean.AddDecl
109public import Lean.Meta.AppBuilder
1110public import Lean.DefEqAttrib
12-
1311public section
14-
1512namespace 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
469469private def mkSizeOfSpecTheorems (indTypeNames : Array Name) (sizeOfFns : Array Name) (recMap : NameMap Name) : MetaM Unit := do
470470 for indTypeName in indTypeNames do
Original file line number Diff line number Diff line change 1+ // update me!
12#include " util/options.h"
23
34namespace lean {
Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments