@@ -77,25 +77,6 @@ public meta section
7777
7878open Lean Meta Elab Tactic
7979
80- /-- Configuration for the `convert` family of tactics.
81- This is `Congr!.Config` with different, less aggressive, defaults.
82- -/
83- structure Convert.Config extends Congr!.Config where
84- postTransparency := .default -- Will be set to .reducible in a follow-up PR
85-
86- /-- Elaborator for `Convert.Config` (which is equivalent to `Congr!.Config`
87- but with different, less aggressive, defaults). -/
88- declare_config_elab Convert.elabConfig Convert.Config
89-
90- /--
91- A configuration option that makes `convert` do the sorts of aggressive unfoldings that `congr`
92- does while also similarly preventing `convert` from considering partial applications or congruences
93- between different functions being applied.
94- -/
95- abbrev Convert.Config.unfoldSameFun : Convert.Config :=
96- { Congr!.Config.unfoldSameFun with
97- postTransparency := .default } -- Will be set to .reducible in a follow-up PR
98-
9980/--
10081Close the goal `g` using `Eq.mp v e`,
10182where `v` is a metavariable asserting that the type of `g` and `e` are equal.
@@ -151,7 +132,8 @@ pattern-matched, like `rintro` would, using the `with` keyword.
151132See also `convert_to t`, where `t` specifies the expected type, instead of a proof term of type `t`.
152133In other words, `convert_to t` works like `convert (?_ : t)`. Both tactics use the same options.
153134
154- * `convert! e` uses default transparency, rather than reducible, when solving side goals.
135+ * `convert! e` uses default transparency when solving side goals. This is currently the same
136+ behaviour as `convert`, but `convert` will use reducible transparency in the future.
155137* `convert ← e` creates equality goals in the opposite direction (with the goal type on the right).
156138* `convert e using n`, where `n` is a positive numeral, controls the depth with which congruence is
157139 applied. For example, if the main goal is `⊢ Prime (n + n + 1)` and `e : Prime (2 * n + 1)`, then
@@ -174,7 +156,6 @@ example {n : ℕ} (e : Prime (2 * n + 1)) :
174156 ring
175157
176158-- `convert` can fail where `exact` succeeds.
177- def p (n : ℕ) := True
178159example (h : p 0) : p 1 := by
179160 fail_if_success
180161 convert h -- fails, left-over goal 1 = 0
@@ -221,7 +202,7 @@ def elabTermForConvert (term : Syntax) (expectedType? : Option Expr) :
221202elab_rules : tactic
222203| `(tactic| convert%$tk $[!%$semireducible]? $cfg $[←%$sym]? $term $[using $n]? $[with $ps?*]?) =>
223204 withMainContext do
224- let config := { ← Convert .elabConfig cfg with }
205+ let config ← Congr! .elabConfig (mkOptionalNode cfg)
225206 let patterns := (ps?.getD #[]).toList
226207 let expectedType ← mkFreshExprMVar (mkSort (← getLevel (← getMainTarget)))
227208 let (e, gs) ← elabTermForConvert term expectedType
@@ -243,7 +224,8 @@ pattern-matched, like `rintro` would, using the `with` keyword.
243224`convert e`, where `e` is a term of type `t`, uses `e` to close the new main goal. In other words,
244225`convert e` works like `convert_to t; refine e`. Both tactics use the same options.
245226
246- * `convert_to! t` uses default transparency, rather than reducible, when solving side goals.
227+ * `convert_to! t` uses default transparency when solving side goals. This is currently the same
228+ behaviour as `convert_to`, but `convert_to` will use reducible transparency in the future.
247229* `convert_to ty at h` changes the type of the local hypothesis `h` to `ty`. If later local
248230 hypotheses or the goal depend on `h`, then `convert_to t at h` may leave a copy of `h`.
249231* `convert_to ← t` creates equality goals in the opposite direction (with the original goal type on
@@ -259,7 +241,7 @@ pattern-matched, like `rintro` would, using the `with` keyword.
259241* `convert_to (config := cfg) t` uses the configuration options in `cfg` to control the congruence
260242 rules (see `Congr!.Config`).
261243 -/
262- syntax (name := convertTo) "convert_to" ( "!" )? Parser.Tactic.optConfig " ←" ? ppSpace term
244+ syntax (name := convertTo) "convert_to" Lean. Parser.Tactic.optConfig " ←" ? ppSpace term
263245 (" using " num)? (" with" (ppSpace colGt rintroPat)*)? (Parser.Tactic.location)? : tactic
264246
265247@ [tactic_alt convertTo]
@@ -268,20 +250,13 @@ syntax (name := convert_to!) "convert_to!" Lean.Parser.Tactic.optConfig " ←"?
268250
269251macro_rules
270252| `(tactic| convert_to! $cfg $[←%$l]? $t $[using $n]? $[with $w]? $[$loc]?) =>
271- `(tactic| convert_to ! $cfg $[←%$l]? $t:term $[using $n]? $[with $w]? $[$loc]?)
253+ `(tactic| convert_to $cfg $[←%$l]? $t:term $[using $n]? $[with $w]? $[$loc]?)
272254
273255elab_rules : tactic
274- | `(tactic| convert_to $[!%$semireducible]? $ cfg $[←%$sym]? $newType $[using $n]?
256+ | `(tactic| convert_to $cfg $[←%$sym]? $newType $[using $n]?
275257 $[with $ps?*]? $[$loc?:location]?) => do
276258 let n : ℕ := n |>.map (·.getNat) |>.getD 1
277- let mut config := { ← Convert.elabConfig cfg with }
278- if semireducible.isSome then
279- config := { config with
280- -- TODO: also enable this in the future? (Not right now, for backwards compatibility).
281- -- transparency := default,
282- -- preTransparency := default,
283- -- postTransparency := default -- Disabled while the port to `convert!` happens.
284- }
259+ let config ← Congr!.elabConfig cfg
285260 let patterns := (ps?.getD #[]).toList
286261 withLocation (expandOptLocation (mkOptionalNode loc?))
287262 (atLocal := fun fvarId ↦ do
@@ -307,7 +282,8 @@ into new goals, using the hole's name, if any, as the goal case name.
307282Like `congr!`, `convert_to` introduces variables while applying congruence rules. These can be
308283pattern-matched, like `rintro` would, using the `with` keyword.
309284
310- * `ac_change! t` uses default transparency, rather than reducible, when solving side goals.
285+ * `ac_change! t` uses default transparency when solving side goals. This is currently the same
286+ behaviour as `ac_change`, but `ac_change` will use reducible transparency in the future.
311287* `ac_change t using n`, where `n` is a positive numeral, controls the depth with which congruence
312288 is applied. For example, if the main goal is `⊢ Prime ((a * b + 1) + c)`,
313289 then `ac_change Prime ((1 + a * b) + c) using 2` solves the side goals, and
@@ -332,4 +308,5 @@ macro_rules
332308| `(tactic| ac_change! $t $[using $n]?) =>
333309 `(tactic| convert_to! $t:term $[using $n]? <;> try ac_rfl)
334310
311+
335312end Mathlib.Tactic
0 commit comments