11# Tactics
22
3- Mathlib version: ` 14bfbad331fcd848aa37830a3fb4103af552de12 `
3+ Mathlib version: ` c0952c46eb2fda6a7909a689a8a371ed38503611 `
44
55## \# adaptation_note
66Defined in: ` «tactic#adaptation_note_» `
@@ -1129,6 +1129,20 @@ Create a `calc` proof.
11291129## cancel_denoms
11301130Defined in: ` tacticCancel_denoms_ `
11311131
1132+ ` cancel_denoms ` attempts to remove numerals from the denominators of fractions.
1133+ It works on propositions that are field-valued inequalities.
1134+
1135+ ``` lean
1136+ variable [LinearOrderedField α] (a b c : α)
1137+
1138+ example (h : a / 5 + b / 4 < c) : 4*a + 5*b < 20*c := by
1139+ cancel_denoms at h
1140+ exact h
1141+
1142+ example (h : a > 0) : a / 5 > 0 := by
1143+ cancel_denoms
1144+ exact h
1145+ ```
11321146
11331147## cancel_denoms
11341148Defined in: ` cancelDenoms `
@@ -2214,14 +2228,6 @@ Defined in: `tacticEconstructor`
22142228(it calls ` apply ` using the first matching constructor of an inductive datatype)
22152229except only non-dependent premises are added as new goals.
22162230
2217- ## elementwise
2218- Defined in: ` Tactic.Elementwise.tacticElementwise___ `
2219-
2220-
2221- ## elementwise!
2222- Defined in: ` Tactic.Elementwise.tacticElementwise!___ `
2223-
2224-
22252231## else
22262232Defined in: ` Lean.Parser.Tactic.tacDepIfThenElse `
22272233
@@ -2592,6 +2598,14 @@ Note that this involves a lot of case splitting, so may be slow.
25922598## find
25932599Defined in: ` Mathlib.Tactic.Find.tacticFind `
25942600
2601+ Display theorems (and definitions) whose result type matches the current goal,
2602+ i.e. which should be ` apply ` able.
2603+ ``` lean
2604+ example : True := by find
2605+ ```
2606+ ` find ` will not affect the goal by itself and should be removed from the finished proof.
2607+ For a command that takes the type to search for as an argument,
2608+ see ` #find ` , which is also available as a tactic.
25952609
25962610## finiteness
25972611Defined in: ` finiteness `
@@ -3281,6 +3295,31 @@ useful within `conv` mode.
32813295## have
32823296Defined in: ` Mathlib.Tactic.tacticHave_ `
32833297
3298+ The ` have ` tactic is for adding opaque definitions and hypotheses to the local context of the main goal.
3299+ The definitions forget their associated value and cannot be unfolded, unlike definitions added by the ` let ` tactic.
3300+
3301+ * ` have h : t := e ` adds the hypothesis ` h : t ` if ` e ` is a term of type ` t ` .
3302+ * ` have h := e ` uses the type of ` e ` for ` t ` .
3303+ * ` have : t := e ` and ` have := e ` use ` this ` for the name of the hypothesis.
3304+ * ` have pat := e ` for a pattern ` pat ` is equivalent to ` match e with | pat => _ ` ,
3305+ where ` _ ` stands for the tactics that follow this one.
3306+ It is convenient for types that have only one applicable constructor.
3307+ For example, given ` h : p ∧ q ∧ r ` , ` have ⟨h₁, h₂, h₃⟩ := h ` produces the
3308+ hypotheses ` h₁ : p ` , ` h₂ : q ` , and ` h₃ : r ` .
3309+ * The syntax ` have (eq := h) pat := e ` is equivalent to ` match h : e with | pat => _ ` ,
3310+ which adds the equation ` h : e = pat ` to the local context.
3311+
3312+ The tactic supports all the same syntax variants and options as the ` have ` term.
3313+
3314+ ## Properties and relations
3315+
3316+ * It is not possible to unfold a variable introduced using ` have ` , since the definition's value is forgotten.
3317+ The ` let ` tactic introduces definitions that can be unfolded.
3318+ * The ` have h : t := e ` is like doing ` let h : t := e; clear_value h ` .
3319+ * The ` have ` tactic is preferred for propositions, and ` let ` is preferred for non-propositions.
3320+ * Sometimes ` have ` is used for non-propositions to ensure that the variable is never unfolded,
3321+ which may be important for performance reasons.
3322+ Consider using the equivalent ` let +nondep ` to indicate the intent.
32843323
32853324## have
32863325Defined in: ` Lean.Parser.Tactic.tacticHave__ `
@@ -3697,6 +3736,31 @@ The syntax is the same as term-mode `let rec`.
36973736## let
36983737Defined in: ` Mathlib.Tactic.tacticLet_ `
36993738
3739+ The ` let ` tactic is for adding definitions to the local context of the main goal.
3740+ The definition can be unfolded, unlike definitions introduced by ` have ` .
3741+
3742+ * ` let x : t := e ` adds the definition ` x : t := e ` if ` e ` is a term of type ` t ` .
3743+ * ` let x := e ` uses the type of ` e ` for ` t ` .
3744+ * ` let : t := e ` and ` let := e ` use ` this ` for the name of the hypothesis.
3745+ * ` let pat := e ` for a pattern ` pat ` is equivalent to ` match e with | pat => _ ` ,
3746+ where ` _ ` stands for the tactics that follow this one.
3747+ It is convenient for types that let only one applicable constructor.
3748+ For example, given ` p : α × β × γ ` , ` let ⟨x, y, z⟩ := p ` produces the
3749+ local variables ` x : α ` , ` y : β ` , and ` z : γ ` .
3750+ * The syntax ` let (eq := h) pat := e ` is equivalent to ` match h : e with | pat => _ ` ,
3751+ which adds the equation ` h : e = pat ` to the local context.
3752+
3753+ The tactic supports all the same syntax variants and options as the ` let ` term.
3754+
3755+ ## Properties and relations
3756+
3757+ * Unlike ` have ` , it is possible to unfold definitions introduced using ` let ` , using tactics
3758+ such as ` simp ` , ` dsimp ` , ` unfold ` , and ` subst ` .
3759+ * The ` clear_value ` tactic turns a ` let ` definition into a ` have ` definition after the fact.
3760+ The tactic might fail if the local context depends on the value of the variable.
3761+ * The ` let ` tactic is preferred for data (non-propositions).
3762+ * Sometimes ` have ` is used for non-propositions to ensure that the variable is never unfolded,
3763+ which may be important for performance reasons.
37003764
37013765## let'
37023766Defined in: ` Lean.Parser.Tactic.tacticLet'__ `
@@ -4347,7 +4411,7 @@ Defined in: `Lean.Parser.Tactic.mdup`
43474411Duplicate a stateful ` Std.Do.SPred ` hypothesis.
43484412
43494413## measurability
4350- Defined in: ` tacticMeasurability `
4414+ Defined in: ` Mathlib.Tactic.measurability `
43514415
43524416The tactic ` measurability ` solves goals of the form ` Measurable f ` , ` AEMeasurable f ` ,
43534417` StronglyMeasurable f ` , ` AEStronglyMeasurable f μ ` , or ` MeasurableSet s ` by applying lemmas tagged
@@ -4361,13 +4425,25 @@ with `fun_prop` rather that `measurability`. The `measurability` attribute is eq
43614425## measurability!
43624426Defined in: ` measurability! `
43634427
4428+ The tactic ` measurability ` solves goals of the form ` Measurable f ` , ` AEMeasurable f ` ,
4429+ ` StronglyMeasurable f ` , ` AEStronglyMeasurable f μ ` , or ` MeasurableSet s ` by applying lemmas tagged
4430+ with the ` measurability ` user attribute.
4431+
4432+ Note that ` measurability ` uses ` fun_prop ` for solving measurability of functions, so statements
4433+ about ` Measurable ` , ` AEMeasurable ` , ` StronglyMeasurable ` and ` AEStronglyMeasurable ` should be tagged
4434+ with ` fun_prop ` rather that ` measurability ` . The ` measurability ` attribute is equivalent to
4435+ ` fun_prop ` in these cases for backward compatibility with the earlier implementation.
43644436
43654437## measurability!?
43664438Defined in: ` measurability!? `
43674439
4440+ The tactic ` measurability? ` solves goals of the form ` Measurable f ` , ` AEMeasurable f ` ,
4441+ ` StronglyMeasurable f ` , ` AEStronglyMeasurable f μ ` , or ` MeasurableSet s ` by applying lemmas tagged
4442+ with the ` measurability ` user attribute, and suggests a faster proof script that can be substituted
4443+ for the tactic call in case of success.
43684444
43694445## measurability?
4370- Defined in: ` tacticMeasurability ?`
4446+ Defined in: ` Mathlib.Tactic.measurability ?`
43714447
43724448The tactic ` measurability? ` solves goals of the form ` Measurable f ` , ` AEMeasurable f ` ,
43734449` StronglyMeasurable f ` , ` AEStronglyMeasurable f μ ` , or ` MeasurableSet s ` by applying lemmas tagged
@@ -6711,10 +6787,48 @@ runs `X` and verifies that it still prints "Try this: Y".
67116787## set
67126788Defined in: ` Mathlib.Tactic.setTactic `
67136789
6790+ ` set a := t with h ` is a variant of ` let a := t ` . It adds the hypothesis ` h : a = t ` to
6791+ the local context and replaces ` t ` with ` a ` everywhere it can.
6792+
6793+ ` set a := t with ← h ` will add ` h : t = a ` instead.
6794+
6795+ ` set! a := t with h ` does not do any replacing.
6796+
6797+ ``` lean
6798+ example (x : Nat) (h : x + x - x = 3) : x + x - x = 3 := by
6799+ set y := x with ← h2
6800+ sorry
6801+ /-
6802+ x : Nat
6803+ y : Nat := x
6804+ h : y + y - y = 3
6805+ h2 : x = y
6806+ ⊢ y + y - y = 3
6807+ -/
6808+ ```
67146809
67156810## set!
67166811Defined in: ` Mathlib.Tactic.tacticSet!_ `
67176812
6813+ ` set a := t with h ` is a variant of ` let a := t ` . It adds the hypothesis ` h : a = t ` to
6814+ the local context and replaces ` t ` with ` a ` everywhere it can.
6815+
6816+ ` set a := t with ← h ` will add ` h : t = a ` instead.
6817+
6818+ ` set! a := t with h ` does not do any replacing.
6819+
6820+ ``` lean
6821+ example (x : Nat) (h : x + x - x = 3) : x + x - x = 3 := by
6822+ set y := x with ← h2
6823+ sorry
6824+ /-
6825+ x : Nat
6826+ y : Nat := x
6827+ h : y + y - y = 3
6828+ h2 : x = y
6829+ ⊢ y + y - y = 3
6830+ -/
6831+ ```
67186832
67196833## set_option
67206834Defined in: ` Lean.Parser.Tactic.set_option `
@@ -7235,6 +7349,11 @@ If `h :` is omitted, the name `this` is used.
72357349## suffices
72367350Defined in: ` Mathlib.Tactic.tacticSuffices_ `
72377351
7352+ Given a main goal ` ctx ⊢ t ` , ` suffices h : t' from e ` replaces the main goal with ` ctx ⊢ t' ` ,
7353+ ` e ` must have type ` t ` in the context ` ctx, h : t' ` .
7354+
7355+ The variant ` suffices h : t' by tac ` is a shorthand for ` suffices h : t' from by tac ` .
7356+ If ` h : ` is omitted, the name ` this ` is used.
72387357
72397358## suggestions
72407359Defined in: ` Lean.Parser.Tactic.suggestions `
@@ -7282,7 +7401,7 @@ Defined in: `Mathlib.Tactic.Tauto.tauto`
72827401
72837402` tauto ` breaks down assumptions of the form ` _ ∧ _ ` , ` _ ∨ _ ` , ` _ ↔ _ ` and ` ∃ _, _ `
72847403and splits a goal of the form ` _ ∧ _ ` , ` _ ↔ _ ` or ` ∃ _, _ ` until it can be discharged
7285- using ` reflexivity ` or ` solve_by_elim ` .
7404+ using ` rfl ` or ` solve_by_elim ` .
72867405This is a finishing tactic: it either closes the goal or raises an error.
72877406
72887407The Lean 3 version of this tactic by default attempted to avoid classical reasoning
@@ -7665,6 +7784,7 @@ This is similar to the `trivial` tactic but doesn't do things like `contradictio
76657784## use_finite_instance
76667785Defined in: ` tacticUse_finite_instance `
76677786
7787+ Try using ` Set.toFinite ` to dispatch a ` Set.Finite ` goal.
76687788
76697789## valid
76707790Defined in: ` CategoryTheory.ComposableArrows.tacticValid `
0 commit comments