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.ModCases

13 declarations. Mathlib docs · Source

mod_cases tactic

The mod_cases tactic does case disjunction on e % n, where e : ℤ or e : ℕ, to yield n new subgoals corresponding to the possible values of e modulo n.

def Mathlib.Tactic.ModCases.IntMod.OnModCases E1 #

ℕ → ℤ → ℕ → Sort u_1 → Sort u_1

OnModCases n a lb p represents a partial proof by cases that there exists 0 ≤ z < n such that a ≡ z (mod n). It asserts that if ∃ z, lb ≤ z < n ∧ a ≡ z (mod n) holds, then p (where p is the current goal).

def Mathlib.Tactic.ModCases.IntMod.onModCases_start E1 #

(p : Sort u_1) → (a : ℤ) → (n : ℕ) → Nat.ble 1 n = true → Mathlib.Tactic.ModCases.IntMod.OnModCases n a 0 p → p

The first theorem we apply says that ∃ z, 0 ≤ z < n ∧ a ≡ z (mod n). The actual mathematical content of the proof is here.

def Mathlib.Tactic.ModCases.IntMod.onModCases_stop E1 #

(p : Sort u_1) → (n : ℕ) → (a : ℤ) → Mathlib.Tactic.ModCases.IntMod.OnModCases n a n p

The end point is that once we have reduced to ∃ z, n ≤ z < n ∧ a ≡ z (mod n) there are no more cases to consider.

def Mathlib.Tactic.ModCases.IntMod.onModCases_succ E1 #

{p : Sort u_1} →
  {n : ℕ} →
    {a : ℤ} →
      (b : ℕ) →
        (a ≡ OfNat.ofNat b [ZMOD OfNat.ofNat n] → p) →
          Mathlib.Tactic.ModCases.IntMod.OnModCases n a (b.add 1) p → Mathlib.Tactic.ModCases.IntMod.OnModCases n a b p

The successor case decomposes ∃ z, b ≤ z < n ∧ a ≡ z (mod n) into a ≡ b (mod n) ∨ ∃ z, b+1 ≤ z < n ∧ a ≡ z (mod n), and the a ≡ b (mod n) → p case becomes a subgoal.

opaque Mathlib.Tactic.ModCases.IntMod.proveOnModCases E1 #

{u : Lean.Level} →
  (n : Q(ℕ)) →
    (a : Q(ℤ)) →
      (b : Q(ℕ)) →
        (p : Q(Sort u)) →
          Lean.MetaM (Q(Mathlib.Tactic.ModCases.IntMod.OnModCases «$n» «$a» «$b» «$p») × List Lean.MVarId)

Proves an expression of the form OnModCases n a b p where n and b are raw nat literals and b ≤ n. Returns the list of subgoals ?gi : a ≡ i [ZMOD n] → p.

def Mathlib.Tactic.ModCases.IntMod.modCases E1 #

Lean.TSyntax `Lean.binderIdent → Q(ℤ) → ℕ → Lean.Elab.Tactic.TacticM Unit

Int case of mod_cases h : e % n.

def Mathlib.Tactic.ModCases.NatMod.OnModCases E1 #

ℕ → ℕ → ℕ → Sort u_1 → Sort u_1

OnModCases n a lb p represents a partial proof by cases that there exists 0 ≤ m < n such that a ≡ m (mod n). It asserts that if ∃ m, lb ≤ m < n ∧ a ≡ m (mod n) holds, then p (where p is the current goal).

def Mathlib.Tactic.ModCases.NatMod.onModCases_start E1 #

(p : Sort u_1) → (a n : ℕ) → Nat.ble 1 n = true → Mathlib.Tactic.ModCases.NatMod.OnModCases n a 0 p → p

The first theorem we apply says that ∃ m, 0 ≤ m < n ∧ a ≡ m (mod n). The actual mathematical content of the proof is here.

def Mathlib.Tactic.ModCases.NatMod.onModCases_stop E1 #

(p : Sort u_1) → (n a : ℕ) → Mathlib.Tactic.ModCases.NatMod.OnModCases n a n p

The end point is that once we have reduced to ∃ m, n ≤ m < n ∧ a ≡ m (mod n) there are no more cases to consider.

def Mathlib.Tactic.ModCases.NatMod.onModCases_succ E1 #

{p : Sort u_1} →
  {n a : ℕ} →
    (b : ℕ) →
      (a ≡ b [MOD n] → p) →
        Mathlib.Tactic.ModCases.NatMod.OnModCases n a (b.add 1) p → Mathlib.Tactic.ModCases.NatMod.OnModCases n a b p

The successor case decomposes ∃ m, b ≤ m < n ∧ a ≡ m (mod n) into a ≡ b (mod n) ∨ ∃ m, b+1 ≤ m < n ∧ a ≡ m (mod n), and the a ≡ b (mod n) → p case becomes a subgoal.

opaque Mathlib.Tactic.ModCases.NatMod.proveOnModCases E1 #

{u : Lean.Level} →
  (n a b : Q(ℕ)) →
    (p : Q(Sort u)) → Lean.MetaM (Q(Mathlib.Tactic.ModCases.NatMod.OnModCases «$n» «$a» «$b» «$p») × List Lean.MVarId)

Proves an expression of the form OnModCases n a b p where n and b are raw nat literals and b ≤ n. Returns the list of subgoals ?gi : a ≡ i [MOD n] → p.

def Mathlib.Tactic.ModCases.NatMod.modCases E1 #

Lean.TSyntax `Lean.binderIdent → Q(ℕ) → ℕ → Lean.Elab.Tactic.TacticM Unit

Nat case of mod_cases h : e % n.

def Mathlib.Tactic.ModCases.«tacticMod_cases_:_%_» E1 #

Lean.ParserDescr

mod_cases h : e % n, where n is a positive numeral and e is an expression of type ℕ or ℤ, performs a case disjunction on the value of e modulo n. If e : ℤ, the goal is split into n subgoals containing the new hypotheses h : e ≡ 0 [ZMOD n], ..., h : e ≡ n-1 [ZMOD n] respectively. If e : ℕ instead, then the hypotheses contain [MOD n] instead of [ZMOD n].

  • mod_cases e % n, with h omitted, gives the default name H to the new hypotheses.