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_negcontrapose 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
An option to turn off the feature that contrapose negates both sides of ↔ goals.
This may be useful for teaching.
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 contraposeturns 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_negtactic 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
Equations
- One or more equations did not get rendered due to their size.
Instances For
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 contraposeturns 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_negtactic 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
Equations
- One or more equations did not get rendered due to their size.