The areas / V34. The tactics of Mathlib
Mathlib.Tactic.Zify
6 declarations. Mathlib docs · Source
zify tactic
The zify tactic is used to shift propositions from Nat to Int.
This is often useful since Int has well-behaved subtraction.
example (a b c x y z : Nat) (h : ¬ x*y*z < 0) : c < a + 3*b := by
zify
zify at h
/-
h : ¬↑x * ↑y * ↑z < 0
⊢ ↑c < ↑a + 3 * ↑b
-/
def Mathlib.Tactic.Zify.zify E1 #
Lean.ParserDescr
zify rewrites the main goal by shifting propositions from ℕ to ℤ.
This is often useful since ℤ has well-behaved subtraction.
zify makes use of the @[zify_simps] attribute to insert casts into propositions, and the
push_cast tactic to simplify the ℤ-valued expressions.
zify is in some sense dual to the lift tactic. lift (z : Int) to Nat will change the type of
an integer z (in the supertype) to Nat (the subtype), given a proof that z ≥ 0; propositions
concerning z will still be over Int. zify changes propositions about Nat (the subtype) to
propositions about Int (the supertype), without changing the type of any variable.
zify at l1 l2 ...rewrites at the given locations.zify [h₁, ..., hₙ]uses the expressionsh₁, ...,hₙas extra lemmas for simplification. This is especially useful in the presence of nat subtraction or of division: passing arguments of type· ≤ ·will allowpush_castto do more work.
Examples:
example (a b c x y z : Nat) (h : ¬ x*y*z < 0) : c < a + 3*b := by
zify
zify at h
/-
h : ¬↑x * ↑y * ↑z < 0
⊢ ↑c < ↑a + 3 * ↑b
-/
sorry
example (a b c : Nat) (h : a - b < c) (hab : b ≤ a) : False := by
-- Nonnegativity hypothesis allows pushing `· - ·`.
zify [hab] at h
/- h : ↑a - ↑b < ↑c -/
sorry
def Mathlib.Tactic.Zify.mkZifyContext E1 #
Option (Lean.Syntax.TSepArray `Lean.Parser.Tactic.simpStar ",") →
Lean.Elab.Tactic.TacticM Lean.Elab.Tactic.MkSimpContextResult
The Simp.Context generated by zify.
def Mathlib.Tactic.Zify.applySimpResultToProp' E1 #
Lean.Expr → Lean.Expr → Lean.Meta.Simp.Result → Lean.MetaM (Lean.Expr × Lean.Expr)
A variant of applySimpResultToProp that cannot close the goal, but does not need a meta
variable and returns a tuple of a proof and the corresponding simplified proposition.
def Mathlib.Tactic.Zify.zifyProof E1 #
Option (Lean.Syntax.TSepArray `Lean.Parser.Tactic.simpStar ",") →
Lean.Expr → Lean.Expr → Lean.Elab.Tactic.TacticM (Lean.Expr × Lean.Expr)
Translate a proof and the proposition into a zified form.
theorem Mathlib.Tactic.Zify.natCast_ne E1 #
∀ (a b : ℕ), a ≠ b ↔ ↑a ≠ ↑b
theorem Mathlib.Tactic.Zify.Nat.cast_sub_of_lt E1 #
∀ {R : Type u_1} [inst : AddGroupWithOne R] {m n : ℕ}, m < n → ↑(n - m) = ↑n - ↑m