The areas / V34. The tactics of Mathlib
Mathlib.Tactic.Contrapose
11 declarations. Mathlib docs · Source
Contrapose
The contrapose tactic transforms the goal into its contrapositive when that goal is an
implication or an iff. It also avoids creating a double negation if there already is a negation.
contraposeturns a goalP → Qinto¬ Q → ¬ Pand a goalP ↔ Qinto¬ P ↔ ¬ Qcontrapose!runscontraposeand then pushes negations insidePandQusingpush Notcontrapose hfirst reverts the local assumptionh, and then usescontraposeandintro hcontrapose! hfirst reverts the local assumptionh, and then usescontrapose!andintro hcontrapose h with new_huses the namenew_hfor the introduced hypothesis
opaque Mathlib.Tactic.Contrapose.contrapose.negate_iff E0 #
Lean.Option Bool
An option to turn off the feature that contrapose negates both sides of ↔ goals.
This may be useful for teaching.
theorem Mathlib.Tactic.Contrapose.contrapose₁ E1 #
∀ {p q : Prop}, (¬q → ¬p) → p → q
theorem Mathlib.Tactic.Contrapose.contrapose₂ E1 #
∀ {p q : Prop}, (¬q → p) → ¬p → q
theorem Mathlib.Tactic.Contrapose.contrapose₃ E1 #
∀ {p q : Prop}, (q → ¬p) → p → ¬q
theorem Mathlib.Tactic.Contrapose.contrapose₄ E1 #
∀ {p q : Prop}, (q → p) → ¬p → ¬q
theorem Mathlib.Tactic.Contrapose.contrapose_iff₁ E1 #
∀ {p q : Prop}, (¬p ↔ ¬q) → (p ↔ q)
theorem Mathlib.Tactic.Contrapose.contrapose_iff₂ E1 #
∀ {p q : Prop}, (p ↔ ¬q) → (¬p ↔ q)
theorem Mathlib.Tactic.Contrapose.contrapose_iff₃ E1 #
∀ {p q : Prop}, (¬p ↔ q) → (p ↔ ¬q)
theorem Mathlib.Tactic.Contrapose.contrapose_iff₄ E1 #
∀ {p q : Prop}, (p ↔ q) → (¬p ↔ ¬q)
def Mathlib.Tactic.Contrapose.contrapose E1 #
Lean.ParserDescr
contrapose transforms the main goal into its contrapositive. If the goal has the form ⊢ P → Q,
then contrapose turns it into ⊢ ¬ Q → ¬ P. If the goal has the form ⊢ P ↔ Q, then contrapose
turns it into ⊢ ¬ P ↔ ¬ Q.
contrapose hon a goal of the formh : P ⊢ Qturns the goal intoh : ¬ Q ⊢ ¬ P. This is equivalent torevert h; contrapose; intro h.contrapose h with new_huses the namenew_hfor the introduced hypothesis. This is equivalent torevert h; contrapose; intro new_h.contrapose!,contrapose! handcontrapose! h with new_hpush negation deeper into the goal after contraposing (but before introducing the new hypothesis). See thepush Nottactic for more details on the pushing algorithm.contrapose! (config := cfg)controls the options for negation pushing. All options forMathlib.Tactic.Push.Configare supported:contrapose! +distribrewrites¬ (p ∧ q)into¬ p ∨ ¬ qinstead ofp → ¬ q.
Examples:
variables (P Q R : Prop)
example (H : ¬ Q → ¬ P) : P → Q := by
contrapose
exact H
example (H : ¬ P ↔ ¬ Q) : P ↔ Q := by
contrapose
exact H
example (H : ¬ Q → ¬ P) (h : P) : Q := by
contrapose h
exact H h
example (H : ¬ R → P → ¬ Q) : (P ∧ Q) → R := by
contrapose!
exact H
example (H : ¬ R → ¬ P ∨ ¬ Q) : (P ∧ Q) → R := by
contrapose! +distrib
exact H
def Mathlib.Tactic.Contrapose.contrapose! E1 #
Lean.ParserDescr
contrapose transforms the main goal into its contrapositive. If the goal has the form ⊢ P → Q,
then contrapose turns it into ⊢ ¬ Q → ¬ P. If the goal has the form ⊢ P ↔ Q, then contrapose
turns it into ⊢ ¬ P ↔ ¬ Q.
contrapose hon a goal of the formh : P ⊢ Qturns the goal intoh : ¬ Q ⊢ ¬ P. This is equivalent torevert h; contrapose; intro h.contrapose h with new_huses the namenew_hfor the introduced hypothesis. This is equivalent torevert h; contrapose; intro new_h.contrapose!,contrapose! handcontrapose! h with new_hpush negation deeper into the goal after contraposing (but before introducing the new hypothesis). See thepush Nottactic for more details on the pushing algorithm.contrapose! (config := cfg)controls the options for negation pushing. All options forMathlib.Tactic.Push.Configare supported:contrapose! +distribrewrites¬ (p ∧ q)into¬ p ∨ ¬ qinstead ofp → ¬ q.
Examples:
variables (P Q R : Prop)
example (H : ¬ Q → ¬ P) : P → Q := by
contrapose
exact H
example (H : ¬ P ↔ ¬ Q) : P ↔ Q := by
contrapose
exact H
example (H : ¬ Q → ¬ P) (h : P) : Q := by
contrapose h
exact H h
example (H : ¬ R → P → ¬ Q) : (P ∧ Q) → R := by
contrapose!
exact H
example (H : ¬ R → ¬ P ∨ ¬ Q) : (P ∧ Q) → R := by
contrapose! +distrib
exact H