The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V34. The tactics of Mathlib

Mathlib.Tactic.Qify

5 declarations. Mathlib docs · Source

qify tactic

The qify tactic is used to shift propositions from ℕ or ℤ to ℚ. This is often useful since ℚ has well-behaved division.

example (a b c x y z : ℕ) (h : ¬ x*y*z < 0) : c < a + 3*b := by
  qify
  qify at h
  /-
  h : ¬↑x * ↑y * ↑z < 0
  ⊢ ↑c < ↑a + 3 * ↑b
  -/

  sorry

def Mathlib.Tactic.Qify.qify E1 #

Lean.ParserDescr

qify rewrites the main goal by shifting propositions from ℕ or ℤ to ℚ. This is often useful since ℚ has well-behaved subtraction and division.

qify makes use of the @[zify_simps] and @[qify_simps] attributes to insert casts into propositions, and the push_cast tactic to simplify the ℚ-valued expressions.

qify is in some sense dual to the lift tactic. lift (q : ℚ) to ℤ will change the type of a rational number q (in the supertype) to ℤ (the subtype), given a proof that q.den = 1; propositions concerning q will still be over ℚ. qify changes propositions about ℕ or ℤ (the subtype) to propositions about ℚ (the supertype), without changing the type of any variable.

  • qify at l1 l2 ... rewrites at the given locations.
  • qify [h₁, ..., hₙ] uses the expressions h₁, ..., hₙ as extra lemmas for simplification. This is especially useful in the presence of nat subtraction or of division: passing arguments of type · ≤ · or · ∣ · will allow push_cast to do more work.

Examples:

example (a b c x y z : ℕ) (h : ¬ x*y*z < 0) : c < a + 3*b := by
  qify
  qify at h
  /-
  h : ¬↑x * ↑y * ↑z < 0
  ⊢ ↑c < ↑a + 3 * ↑b
  -/
  sorry

example (a b c : ℤ) (h : a / b = c) (hab : b ∣ a) (hb : b ≠ 0) : a = c * b := by
  -- Divisibility hypothesis allows pushing `· / ·`.
  qify [hab] at h hb ⊢
  exact (div_eq_iff hb).1 h

theorem Mathlib.Tactic.Qify.intCast_eq E0 #

∀ (a b : ℤ), a = b ↔ ↑a = ↑b

theorem Mathlib.Tactic.Qify.intCast_le E1 #

∀ (a b : ℤ), a ≤ b ↔ ↑a ≤ ↑b

theorem Mathlib.Tactic.Qify.intCast_lt E1 #

∀ (a b : ℤ), a < b ↔ ↑a < ↑b

theorem Mathlib.Tactic.Qify.intCast_ne E1 #

∀ (a b : ℤ), a ≠ b ↔ ↑a ≠ ↑b