Skip to content

Commit 82c2c4c

Browse files
authored
feat: add zetaHave/letToHave simp options (#8788)
This PR adds the `zetaHave` and `letToHave` options to `simp`. Implementations will appear in future PRs.
1 parent 019ea2a commit 82c2c4c

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

src/Init/MetaTypes.lean

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ It is immediately converted to `Lean.Meta.Simp.Config` by `Lean.Elab.Tactic.elab
5757
-/
5858
structure Config where
5959
/--
60-
When `true` (default: `true`), performs zeta reduction of let expressions.
60+
When `true` (default: `true`), performs zeta reduction of `let` and `have` expressions.
6161
That is, `let x := v; e[x]` reduces to `e[v]`.
62+
If `zetaHave` is `false` then `have` expressions are not zeta reduced.
6263
See also `zetaDelta`.
6364
-/
6465
zeta : Bool := true
@@ -107,7 +108,8 @@ structure Config where
107108
unfoldPartialApp : Bool := false
108109
/--
109110
When `true` (default: `false`), local definitions are unfolded.
110-
That is, given a local context containing entry `x : t := e`, the free variable `x` reduces to `e`.
111+
That is, given a local context containing `x : t := e`, then the free variable `x` reduces to `e`.
112+
Otherwise, `x` must be provided as a `simp` argument.
111113
-/
112114
zetaDelta : Bool := false
113115
/--
@@ -116,10 +118,17 @@ structure Config where
116118
-/
117119
index : Bool := true
118120
/--
119-
When `true` (default : `true`), then simps will remove unused let-declarations:
121+
When `true` (default : `true`), then `simp` will remove unused `let` and `have` expressions:
120122
`let x := v; e` simplifies to `e` when `x` does not occur in `e`.
121123
-/
122124
zetaUnused : Bool := true
125+
/--
126+
(Unimplemented)
127+
When `false` (default: `true`), then disables zeta reduction of `have` expressions.
128+
If `zeta` is `false`, then this option has no effect.
129+
Unused `have`s are still removed if `zeta` or `zetaUnused` are true.
130+
-/
131+
zetaHave : Bool := true
123132
deriving Inhabited, BEq
124133

125134
end DSimp
@@ -161,8 +170,9 @@ structure Config where
161170
-/
162171
singlePass : Bool := false
163172
/--
164-
When `true` (default: `true`), performs zeta reduction of let expressions.
173+
When `true` (default: `true`), performs zeta reduction of `let` and `have` expressions.
165174
That is, `let x := v; e[x]` reduces to `e[v]`.
175+
If `zetaHave` is `false` then `have` expressions are not zeta reduced.
166176
See also `zetaDelta`.
167177
-/
168178
zeta : Bool := true
@@ -226,7 +236,8 @@ structure Config where
226236
unfoldPartialApp : Bool := false
227237
/--
228238
When `true` (default: `false`), local definitions are unfolded.
229-
That is, given a local context containing entry `x : t := e`, the free variable `x` reduces to `e`.
239+
That is, given a local context containing `x : t := e`, then the free variable `x` reduces to `e`.
240+
Otherwise, `x` must be provided as a `simp` argument.
230241
-/
231242
zetaDelta : Bool := false
232243
/--
@@ -240,7 +251,7 @@ structure Config where
240251
-/
241252
implicitDefEqProofs : Bool := true
242253
/--
243-
When `true` (default : `true`), then simps will remove unused let-declarations:
254+
When `true` (default : `true`), then `simp` will remove unused `let` and `have` expressions:
244255
`let x := v; e` simplifies to `e` when `x` does not occur in `e`.
245256
-/
246257
zetaUnused : Bool := true
@@ -249,6 +260,19 @@ structure Config where
249260
convert them into `simp` exceptions.
250261
-/
251262
catchRuntime : Bool := true
263+
/--
264+
(Unimplemented)
265+
When `false` (default: `true`), then disables zeta reduction of `have` expressions.
266+
If `zeta` is `false`, then this option has no effect.
267+
Unused `have`s are still removed if `zeta` or `zetaUnused` are true.
268+
-/
269+
zetaHave : Bool := true
270+
/--
271+
(Unimplemented)
272+
When `true` (default : `true`), then `simp` will attempt to transform `let`s into `have`s
273+
if they are non-dependent. This only applies when `zeta := false`.
274+
-/
275+
letToHave : Bool := true
252276
deriving Inhabited, BEq
253277

254278
-- Configuration object for `simp_all`
@@ -270,6 +294,7 @@ def neutralConfig : Simp.Config := {
270294
ground := false
271295
zetaDelta := false
272296
zetaUnused := false
297+
letToHave := false
273298
}
274299

275300
structure NormCastConfig extends Simp.Config where

0 commit comments

Comments
 (0)