The areas / V34. The tactics of Mathlib
Mathlib.Tactic.WLOG
14 declarations. Mathlib docs · Source
Without loss of generality tactic
The tactic wlog h : P will add an assumption h : P to the main goal,
and add a new goal that requires showing that the case h : ¬ P can be reduced to the case
where P holds (typically by symmetry). wlog! h : P is a variant that will also call push Not
at h : ¬ P.
The new goal will be placed at the top of the goal stack.
theorem Mathlib.Tactic.WLOGResult.mk.inj E1 #
∀ {reductionGoal : Lean.MVarId} {reductionFVarIds : Lean.FVarId × Lean.FVarId} {hypothesisGoal : Lean.MVarId}
{hypothesisFVarId : Lean.FVarId} {revertedFVarIds : Array Lean.FVarId} {reductionGoal_1 : Lean.MVarId}
{reductionFVarIds_1 : Lean.FVarId × Lean.FVarId} {hypothesisGoal_1 : Lean.MVarId} {hypothesisFVarId_1 : Lean.FVarId}
{revertedFVarIds_1 : Array Lean.FVarId},
{ reductionGoal := reductionGoal, reductionFVarIds := reductionFVarIds, hypothesisGoal := hypothesisGoal,
hypothesisFVarId := hypothesisFVarId, revertedFVarIds := revertedFVarIds } =
{ reductionGoal := reductionGoal_1, reductionFVarIds := reductionFVarIds_1, hypothesisGoal := hypothesisGoal_1,
hypothesisFVarId := hypothesisFVarId_1, revertedFVarIds := revertedFVarIds_1 } →
reductionGoal = reductionGoal_1 ∧
reductionFVarIds = reductionFVarIds_1 ∧
hypothesisGoal = hypothesisGoal_1 ∧ hypothesisFVarId = hypothesisFVarId_1 ∧ revertedFVarIds = revertedFVarIds_1
theorem Mathlib.Tactic.WLOGResult.mk.injEq E0 #
∀ (reductionGoal : Lean.MVarId) (reductionFVarIds : Lean.FVarId × Lean.FVarId) (hypothesisGoal : Lean.MVarId)
(hypothesisFVarId : Lean.FVarId) (revertedFVarIds : Array Lean.FVarId) (reductionGoal_1 : Lean.MVarId)
(reductionFVarIds_1 : Lean.FVarId × Lean.FVarId) (hypothesisGoal_1 : Lean.MVarId) (hypothesisFVarId_1 : Lean.FVarId)
(revertedFVarIds_1 : Array Lean.FVarId),
({ reductionGoal := reductionGoal, reductionFVarIds := reductionFVarIds, hypothesisGoal := hypothesisGoal,
hypothesisFVarId := hypothesisFVarId, revertedFVarIds := revertedFVarIds } =
{ reductionGoal := reductionGoal_1, reductionFVarIds := reductionFVarIds_1, hypothesisGoal := hypothesisGoal_1,
hypothesisFVarId := hypothesisFVarId_1, revertedFVarIds := revertedFVarIds_1 }) =
(reductionGoal = reductionGoal_1 ∧
reductionFVarIds = reductionFVarIds_1 ∧
hypothesisGoal = hypothesisGoal_1 ∧ hypothesisFVarId = hypothesisFVarId_1 ∧ revertedFVarIds = revertedFVarIds_1)
def Mathlib.Tactic.WLOGResult.ctorIdx E1 #
Mathlib.Tactic.WLOGResult → ℕ
structure Mathlib.Tactic.WLOGResult E1 #
Type
The result of running wlog on a goal.
ctor Mathlib.Tactic.WLOGResult.mk E0 #
Lean.MVarId → Lean.FVarId × Lean.FVarId → Lean.MVarId → Lean.FVarId → Array Lean.FVarId → Mathlib.Tactic.WLOGResult
abbrev Mathlib.Tactic.WLOGResult.reductionGoal E1 #
Mathlib.Tactic.WLOGResult → Lean.MVarId
The reductionGoal requires showing that the case h : ¬ P can be reduced to the case where
P holds. It has two additional assumptions in its context:
h : ¬ P: the assumption thatPdoes not holdH: the statement that in the original contextPsuffices to prove the goal.
abbrev Mathlib.Tactic.WLOGResult.reductionFVarIds E1 #
Mathlib.Tactic.WLOGResult → Lean.FVarId × Lean.FVarId
The pair (HFVarId, negHypFVarId) of FVarIds for reductionGoal:
HFVarId:H, the statement that in the original contextPsuffices to prove the goal.negHypFVarId:h : ¬ P, the assumption thatPdoes not hold
abbrev Mathlib.Tactic.WLOGResult.hypothesisGoal E1 #
Mathlib.Tactic.WLOGResult → Lean.MVarId
The original goal with the additional assumption h : P.
abbrev Mathlib.Tactic.WLOGResult.hypothesisFVarId E1 #
Mathlib.Tactic.WLOGResult → Lean.FVarId
The FVarId of the hypothesis h in hypothesisGoal
abbrev Mathlib.Tactic.WLOGResult.revertedFVarIds E1 #
Mathlib.Tactic.WLOGResult → Array Lean.FVarId
The array of FVarIds that was reverted to produce the reduction hypothesis H in
reductionGoal, which are still present in the context of reductionGoal (but not necessarily
hypothesisGoal).
def Lean.MVarId.wlog E1 #
Lean.MVarId →
Option Lean.Name →
Lean.Expr →
optParam (Option (Lean.TSyntaxArray `ident)) none →
optParam (Option Lean.Name) none → Lean.Elab.Tactic.TacticM Mathlib.Tactic.WLOGResult
wlog goal h P xs H will return two goals: the hypothesisGoal, which adds an assumption
h : P to the context of goal, and the reductionGoal, which requires showing that the case
h : ¬ P can be reduced to the case where P holds (typically by symmetry).
In reductionGoal, there will be two additional assumptions:
h : ¬ P: the assumption thatPdoes not holdH: which is the statement that in the old contextPsuffices to prove the goal. IfHisnone, the namethisis used.
If xs is none, all hypotheses are reverted to produce the reduction goal's hypothesis H.
Otherwise, the xs are elaborated to hypotheses in the context of goal, and only those
hypotheses are reverted (and any that depend on them).
If h is none, the hypotheses of types P and ¬ P in both branches will be inaccessible.
def Mathlib.Tactic.wlogCore E1 #
Lean.TSyntax `Lean.binderIdent →
Lean.Term →
Option (Lean.TSyntaxArray `ident) →
Option (Lean.TSyntax `ident) →
optParam (Option (Lean.TSyntax `Lean.Parser.Tactic.optConfig)) none → Lean.Elab.Tactic.TacticM Unit
The implementation of wlog and wlog!
def Mathlib.Tactic.wlog E1 #
Lean.ParserDescr
wlog h : P adds an assumption h : P to the main goal, and adds a side goal that
requires showing that the case h : ¬ P can be reduced to the case where P holds
(typically by symmetry). The side goal will be at the top of the stack. In this side goal,
there will be two additional assumptions:
h : ¬ P: the assumption thatPdoes not holdthis: which is the statement that in the old contextPsuffices to prove the goal. By default, the entire context is reverted to producethis.
wlog h : P with Hgives the nameHto the statement thatPproves the goal.wlog h : P generalizing x y ...reverts certain parts of the context before creating the new goal. In this way, the wlog-claimthiscan be applied toxandyin different orders (exploiting symmetry, which is the typical use case).wlog! h : Palso callspush Notat the generated hypothesish.wlog! h : P ∧ Qwill transform¬ (P ∧ Q)toP → ¬ Qwlog! +distrib h : Palso callspush +distrib Notat the generated hypothesish.wlog! +distrib h : P ∧ Qwill transform¬ (P ∧ Q)to¬P ∨ ¬Q.
def Mathlib.Tactic.wlog! E1 #
Lean.ParserDescr
wlog h : P adds an assumption h : P to the main goal, and adds a side goal that
requires showing that the case h : ¬ P can be reduced to the case where P holds
(typically by symmetry). The side goal will be at the top of the stack. In this side goal,
there will be two additional assumptions:
h : ¬ P: the assumption thatPdoes not holdthis: which is the statement that in the old contextPsuffices to prove the goal. By default, the entire context is reverted to producethis.
wlog h : P with Hgives the nameHto the statement thatPproves the goal.wlog h : P generalizing x y ...reverts certain parts of the context before creating the new goal. In this way, the wlog-claimthiscan be applied toxandyin different orders (exploiting symmetry, which is the typical use case).wlog! h : Palso callspush Notat the generated hypothesish.wlog! h : P ∧ Qwill transform¬ (P ∧ Q)toP → ¬ Qwlog! +distrib h : Palso callspush +distrib Notat the generated hypothesish.wlog! +distrib h : P ∧ Qwill transform¬ (P ∧ Q)to¬P ∨ ¬Q.