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

128 declarations. Mathlib docs · Source

Intuitionistic tautology (itauto) decision procedure

The itauto tactic will prove any intuitionistic tautology. It implements the well-known G4ip algorithm: [Dyckhoff, Contraction-free sequent calculi for intuitionistic logic][dyckhoff_1992].

All built in propositional connectives are supported: True, False, And, Or, →, Not, Iff, Xor, as well as Eq and Ne on propositions. Anything else, including definitions and predicate logical connectives (∀ and ∃), are not supported, and will have to be simplified or instantiated before calling this tactic.

The resulting proofs will never use any axioms except possibly propext, and propext is only used if the input formula contains an equality of propositions p = q. Using itauto!, one can enable the selective use of LEM for case splitting on specified propositions.

Implementation notes

The core logic of the prover is in three functions:

  • prove : Context → IProp → StateM Nat (Bool × Proof): The main entry point. Gets a context and a goal, and returns a proof object or fails, using StateM Nat for the name generator.
  • search : Context → IProp → StateM Nat (Bool × Proof): Same meaning as proof, called during the search phase (see below).
  • Context.add : IProp → Proof → Context → Except (IProp → Proof) Context: Adds a proposition with its proof into the context, but it also does some simplifications on the spot while doing so. It will either return the new context, or if it happens to notice a proof of false, it will return a function to compute a proof of any proposition in the original context.

The intuitionistic logic rules are separated into three groups:

  • level 1: No splitting, validity preserving: apply whenever you can. Left rules in Context.add, right rules in prove.
    • Context.add:
      • simplify Γ, ⊤ ⊢ B to Γ ⊢ B
      • Γ, ⊥ ⊢ B is true
      • simplify Γ, A ∧ B ⊢ C to Γ, A, B ⊢ C
      • simplify Γ, ⊥ → A ⊢ B to Γ ⊢ B
      • simplify Γ, ⊤ → A ⊢ B to Γ, A ⊢ B
      • simplify Γ, A ∧ B → C ⊢ D to Γ, A → B → C ⊢ D
      • simplify Γ, A ∨ B → C ⊢ D to Γ, A → C, B → C ⊢ D
    • prove:
      • Γ ⊢ ⊤ is true
      • simplify Γ ⊢ A → B to Γ, A ⊢ B
    • search:
      • Γ, P ⊢ P is true
      • simplify Γ, P, P → A ⊢ B to Γ, P, A ⊢ B
  • level 2: Splitting rules, validity preserving: apply after level 1 rules. Done in prove
    • simplify Γ ⊢ A ∧ B to Γ ⊢ A and Γ ⊢ B
    • simplify Γ, A ∨ B ⊢ C to Γ, A ⊢ C and Γ, B ⊢ C
  • level 3: Splitting rules, not validity preserving: apply only if nothing else applies. Done in search
    • Γ ⊢ A ∨ B follows from Γ ⊢ A
    • Γ ⊢ A ∨ B follows from Γ ⊢ B
    • Γ, (A₁ → A₂) → C ⊢ B follows from Γ, A₂ → C, A₁ ⊢ A₂ and Γ, C ⊢ B

This covers the core algorithm, which only handles True, False, And, Or, and →. For Iff and Eq, we treat them essentially the same as (p → q) ∧ (q → p), although we use a different IProp representation because we have to remember to apply different theorems during replay. For definitions like Not and Xor, we just eagerly unfold them. (This could potentially cause a blowup issue for Xor, but it isn't used very often anyway. We could add it to the IProp grammar if it matters.)

Tags

propositional logic, intuitionistic logic, decision procedure

abbrev Mathlib.Tactic.ITauto.IProp.brecOn.go E1 #

{motive : Mathlib.Tactic.ITauto.IProp → Sort u} →
  (t : Mathlib.Tactic.ITauto.IProp) →
    ((t : Mathlib.Tactic.ITauto.IProp) → Mathlib.Tactic.ITauto.IProp.below t → motive t) →
      motive t ×' Mathlib.Tactic.ITauto.IProp.below t

theorem Mathlib.Tactic.ITauto.Proof.orInR.inj E1 #

∀ {p p_1 : Mathlib.Tactic.ITauto.Proof}, p.orInR = p_1.orInR → p = p_1

theorem Mathlib.Tactic.ITauto.Proof.andLeft.injEq E0 #

∀ (ak : Mathlib.Tactic.ITauto.AndKind) (p : Mathlib.Tactic.ITauto.Proof) (ak_1 : Mathlib.Tactic.ITauto.AndKind)
  (p_1 : Mathlib.Tactic.ITauto.Proof),
  (Mathlib.Tactic.ITauto.Proof.andLeft ak p = Mathlib.Tactic.ITauto.Proof.andLeft ak_1 p_1) = (ak = ak_1 ∧ p = p_1)

theorem Mathlib.Tactic.ITauto.Proof.andRight.inj E1 #

∀ {ak : Mathlib.Tactic.ITauto.AndKind} {p : Mathlib.Tactic.ITauto.Proof} {ak_1 : Mathlib.Tactic.ITauto.AndKind}
  {p_1 : Mathlib.Tactic.ITauto.Proof},
  Mathlib.Tactic.ITauto.Proof.andRight ak p = Mathlib.Tactic.ITauto.Proof.andRight ak_1 p_1 → ak = ak_1 ∧ p = p_1

theorem Mathlib.Tactic.ITauto.Proof.curry.injEq E0 #

∀ (ak : Mathlib.Tactic.ITauto.AndKind) (p : Mathlib.Tactic.ITauto.Proof) (ak_1 : Mathlib.Tactic.ITauto.AndKind)
  (p_1 : Mathlib.Tactic.ITauto.Proof),
  (Mathlib.Tactic.ITauto.Proof.curry ak p = Mathlib.Tactic.ITauto.Proof.curry ak_1 p_1) = (ak = ak_1 ∧ p = p_1)

theorem Mathlib.Tactic.ITauto.IProp.var.injEq E0 #

∀ (a a_1 : ℕ), (Mathlib.Tactic.ITauto.IProp.var a = Mathlib.Tactic.ITauto.IProp.var a_1) = (a = a_1)

theorem Mathlib.Tactic.ITauto.AndKind.ofNat_ctorIdx E1 #

∀ (x : Mathlib.Tactic.ITauto.AndKind), Mathlib.Tactic.ITauto.AndKind.ofNat x.ctorIdx = x

abbrev Mathlib.Tactic.ITauto.AndKind.ofNat E1 #

ℕ → Mathlib.Tactic.ITauto.AndKind

theorem Mathlib.Tactic.ITauto.IProp.brecOn.eq E1 #

∀ {motive : Mathlib.Tactic.ITauto.IProp → Sort u} (t : Mathlib.Tactic.ITauto.IProp)
  (F_1 : (t : Mathlib.Tactic.ITauto.IProp) → Mathlib.Tactic.ITauto.IProp.below t → motive t),
  Mathlib.Tactic.ITauto.IProp.brecOn t F_1 = F_1 t (Mathlib.Tactic.ITauto.IProp.brecOn.go t F_1).2

theorem Mathlib.Tactic.ITauto.Proof.orImpR.injEq E0 #

∀ (p p_1 : Mathlib.Tactic.ITauto.Proof), (p.orImpR = p_1.orImpR) = (p = p_1)

theorem Mathlib.Tactic.ITauto.IProp.and'.inj E1 #

∀ {a : Mathlib.Tactic.ITauto.AndKind} {a_1 a_2 : Mathlib.Tactic.ITauto.IProp} {a_3 : Mathlib.Tactic.ITauto.AndKind}
  {a_4 a_5 : Mathlib.Tactic.ITauto.IProp},
  Mathlib.Tactic.ITauto.IProp.and' a a_1 a_2 = Mathlib.Tactic.ITauto.IProp.and' a_3 a_4 a_5 →
    a = a_3 ∧ a_1 = a_4 ∧ a_2 = a_5

theorem Mathlib.Tactic.ITauto.Proof.orImpR.inj E1 #

∀ {p p_1 : Mathlib.Tactic.ITauto.Proof}, p.orImpR = p_1.orImpR → p = p_1

theorem Mathlib.Tactic.ITauto.IProp.imp.injEq E0 #

∀ (a a_1 a_2 a_3 : Mathlib.Tactic.ITauto.IProp), (a.imp a_1 = a_2.imp a_3) = (a = a_2 ∧ a_1 = a_3)

abbrev Mathlib.Tactic.ITauto.IProp.ctorElimType E1 #

{motive : Mathlib.Tactic.ITauto.IProp → Sort u} → ℕ → Sort (max 1 u)

theorem Mathlib.Tactic.ITauto.Proof.orElim'.injEq E0 #

∀ (p₁ : Mathlib.Tactic.ITauto.Proof) (x : Lean.Name) (p₂ p₃ p₁_1 : Mathlib.Tactic.ITauto.Proof) (x_1 : Lean.Name)
  (p₂_1 p₃_1 : Mathlib.Tactic.ITauto.Proof),
  (p₁.orElim' x p₂ p₃ = p₁_1.orElim' x_1 p₂_1 p₃_1) = (p₁ = p₁_1 ∧ x = x_1 ∧ p₂ = p₂_1 ∧ p₃ = p₃_1)

theorem Mathlib.Tactic.ITauto.IProp.or.injEq E0 #

∀ (a a_1 a_2 a_3 : Mathlib.Tactic.ITauto.IProp), (a.or a_1 = a_2.or a_3) = (a = a_2 ∧ a_1 = a_3)

abbrev Mathlib.Tactic.ITauto.Proof.ctorElimType E1 #

{motive : Mathlib.Tactic.ITauto.Proof → Sort u} → ℕ → Sort (max 1 u)

theorem Mathlib.Tactic.ITauto.Proof.app'.injEq E0 #

∀ (a a_1 a_2 a_3 : Mathlib.Tactic.ITauto.Proof), (a.app' a_1 = a_2.app' a_3) = (a = a_2 ∧ a_1 = a_3)

theorem Mathlib.Tactic.ITauto.Proof.andRight.injEq E0 #

∀ (ak : Mathlib.Tactic.ITauto.AndKind) (p : Mathlib.Tactic.ITauto.Proof) (ak_1 : Mathlib.Tactic.ITauto.AndKind)
  (p_1 : Mathlib.Tactic.ITauto.Proof),
  (Mathlib.Tactic.ITauto.Proof.andRight ak p = Mathlib.Tactic.ITauto.Proof.andRight ak_1 p_1) = (ak = ak_1 ∧ p = p_1)

theorem Mathlib.Tactic.ITauto.IProp.and'.injEq E0 #

∀ (a : Mathlib.Tactic.ITauto.AndKind) (a_1 a_2 : Mathlib.Tactic.ITauto.IProp) (a_3 : Mathlib.Tactic.ITauto.AndKind)
  (a_4 a_5 : Mathlib.Tactic.ITauto.IProp),
  (Mathlib.Tactic.ITauto.IProp.and' a a_1 a_2 = Mathlib.Tactic.ITauto.IProp.and' a_3 a_4 a_5) =
    (a = a_3 ∧ a_1 = a_4 ∧ a_2 = a_5)

theorem Mathlib.Tactic.ITauto.IProp.var.inj E1 #

∀ {a a_1 : ℕ}, Mathlib.Tactic.ITauto.IProp.var a = Mathlib.Tactic.ITauto.IProp.var a_1 → a = a_1

theorem Mathlib.Tactic.ITauto.Proof.andIntro.inj E1 #

∀ {ak : Mathlib.Tactic.ITauto.AndKind} {p₁ p₂ : Mathlib.Tactic.ITauto.Proof} {ak_1 : Mathlib.Tactic.ITauto.AndKind}
  {p₁_1 p₂_1 : Mathlib.Tactic.ITauto.Proof},
  Mathlib.Tactic.ITauto.Proof.andIntro ak p₁ p₂ = Mathlib.Tactic.ITauto.Proof.andIntro ak_1 p₁_1 p₂_1 →
    ak = ak_1 ∧ p₁ = p₁_1 ∧ p₂ = p₂_1

theorem Mathlib.Tactic.ITauto.Proof.curry.inj E1 #

∀ {ak : Mathlib.Tactic.ITauto.AndKind} {p : Mathlib.Tactic.ITauto.Proof} {ak_1 : Mathlib.Tactic.ITauto.AndKind}
  {p_1 : Mathlib.Tactic.ITauto.Proof},
  Mathlib.Tactic.ITauto.Proof.curry ak p = Mathlib.Tactic.ITauto.Proof.curry ak_1 p_1 → ak = ak_1 ∧ p = p_1

abbrev Mathlib.Tactic.ITauto.AndKind.ctorElimType E1 #

{motive : Mathlib.Tactic.ITauto.AndKind → Sort u} → ℕ → Sort (max 1 u)

theorem Mathlib.Tactic.ITauto.Proof.intro.injEq E0 #

∀ (x : Lean.Name) (p : Mathlib.Tactic.ITauto.Proof) (x_1 : Lean.Name) (p_1 : Mathlib.Tactic.ITauto.Proof),
  (Mathlib.Tactic.ITauto.Proof.intro x p = Mathlib.Tactic.ITauto.Proof.intro x_1 p_1) = (x = x_1 ∧ p = p_1)

theorem Mathlib.Tactic.ITauto.Proof.impImpSimp.inj E1 #

∀ {x : Lean.Name} {p : Mathlib.Tactic.ITauto.Proof} {x_1 : Lean.Name} {p_1 : Mathlib.Tactic.ITauto.Proof},
  Mathlib.Tactic.ITauto.Proof.impImpSimp x p = Mathlib.Tactic.ITauto.Proof.impImpSimp x_1 p_1 → x = x_1 ∧ p = p_1

theorem Mathlib.Tactic.ITauto.Proof.orImpL.injEq E0 #

∀ (p p_1 : Mathlib.Tactic.ITauto.Proof), (p.orImpL = p_1.orImpL) = (p = p_1)

theorem Mathlib.Tactic.ITauto.Proof.andLeft.inj E1 #

∀ {ak : Mathlib.Tactic.ITauto.AndKind} {p : Mathlib.Tactic.ITauto.Proof} {ak_1 : Mathlib.Tactic.ITauto.AndKind}
  {p_1 : Mathlib.Tactic.ITauto.Proof},
  Mathlib.Tactic.ITauto.Proof.andLeft ak p = Mathlib.Tactic.ITauto.Proof.andLeft ak_1 p_1 → ak = ak_1 ∧ p = p_1

theorem Mathlib.Tactic.ITauto.Proof.decidableElim.injEq E0 #

∀ (classical : Bool) (p₁ x : Lean.Name) (p₂ p₃ : Mathlib.Tactic.ITauto.Proof) (classical_1 : Bool)
  (p₁_1 x_1 : Lean.Name) (p₂_1 p₃_1 : Mathlib.Tactic.ITauto.Proof),
  (Mathlib.Tactic.ITauto.Proof.decidableElim classical p₁ x p₂ p₃ =
      Mathlib.Tactic.ITauto.Proof.decidableElim classical_1 p₁_1 x_1 p₂_1 p₃_1) =
    (classical = classical_1 ∧ p₁ = p₁_1 ∧ x = x_1 ∧ p₂ = p₂_1 ∧ p₃ = p₃_1)

theorem Mathlib.Tactic.ITauto.Proof.em.inj E1 #

∀ {classical : Bool} {p : Lean.Name} {classical_1 : Bool} {p_1 : Lean.Name},
  Mathlib.Tactic.ITauto.Proof.em classical p = Mathlib.Tactic.ITauto.Proof.em classical_1 p_1 →
    classical = classical_1 ∧ p = p_1

theorem Mathlib.Tactic.ITauto.Proof.intro.inj E1 #

∀ {x : Lean.Name} {p : Mathlib.Tactic.ITauto.Proof} {x_1 : Lean.Name} {p_1 : Mathlib.Tactic.ITauto.Proof},
  Mathlib.Tactic.ITauto.Proof.intro x p = Mathlib.Tactic.ITauto.Proof.intro x_1 p_1 → x = x_1 ∧ p = p_1

theorem Mathlib.Tactic.ITauto.IProp.imp.inj E1 #

∀ {a a_1 a_2 a_3 : Mathlib.Tactic.ITauto.IProp}, a.imp a_1 = a_2.imp a_3 → a = a_2 ∧ a_1 = a_3

theorem Mathlib.Tactic.ITauto.Proof.hyp.inj E1 #

∀ {n n_1 : Lean.Name}, Mathlib.Tactic.ITauto.Proof.hyp n = Mathlib.Tactic.ITauto.Proof.hyp n_1 → n = n_1

theorem Mathlib.Tactic.ITauto.Proof.orElim'.inj E1 #

∀ {p₁ : Mathlib.Tactic.ITauto.Proof} {x : Lean.Name} {p₂ p₃ p₁_1 : Mathlib.Tactic.ITauto.Proof} {x_1 : Lean.Name}
  {p₂_1 p₃_1 : Mathlib.Tactic.ITauto.Proof},
  p₁.orElim' x p₂ p₃ = p₁_1.orElim' x_1 p₂_1 p₃_1 → p₁ = p₁_1 ∧ x = x_1 ∧ p₂ = p₂_1 ∧ p₃ = p₃_1

theorem Mathlib.Tactic.ITauto.Proof.exfalso'.inj E1 #

∀ {p p_1 : Mathlib.Tactic.ITauto.Proof}, p.exfalso' = p_1.exfalso' → p = p_1

theorem Mathlib.Tactic.ITauto.IProp.or.inj E1 #

∀ {a a_1 a_2 a_3 : Mathlib.Tactic.ITauto.IProp}, a.or a_1 = a_2.or a_3 → a = a_2 ∧ a_1 = a_3

theorem Mathlib.Tactic.ITauto.Proof.app'.inj E1 #

∀ {a a_1 a_2 a_3 : Mathlib.Tactic.ITauto.Proof}, a.app' a_1 = a_2.app' a_3 → a = a_2 ∧ a_1 = a_3

theorem Mathlib.Tactic.ITauto.Proof.orInL.inj E1 #

∀ {p p_1 : Mathlib.Tactic.ITauto.Proof}, p.orInL = p_1.orInL → p = p_1

theorem Mathlib.Tactic.ITauto.Proof.em.injEq E0 #

∀ (classical : Bool) (p : Lean.Name) (classical_1 : Bool) (p_1 : Lean.Name),
  (Mathlib.Tactic.ITauto.Proof.em classical p = Mathlib.Tactic.ITauto.Proof.em classical_1 p_1) =
    (classical = classical_1 ∧ p = p_1)

def Mathlib.Tactic.ITauto.AndKind.ctorIdx E1 #

Mathlib.Tactic.ITauto.AndKind → ℕ

theorem Mathlib.Tactic.ITauto.Proof.brecOn.eq E1 #

∀ {motive : Mathlib.Tactic.ITauto.Proof → Sort u} (t : Mathlib.Tactic.ITauto.Proof)
  (F_1 : (t : Mathlib.Tactic.ITauto.Proof) → Mathlib.Tactic.ITauto.Proof.below t → motive t),
  Mathlib.Tactic.ITauto.Proof.brecOn t F_1 = F_1 t (Mathlib.Tactic.ITauto.Proof.brecOn.go t F_1).2

def Mathlib.Tactic.ITauto.IProp.ctorIdx E1 #

Mathlib.Tactic.ITauto.IProp → ℕ

theorem Mathlib.Tactic.ITauto.Proof.orInL.injEq E0 #

∀ (p p_1 : Mathlib.Tactic.ITauto.Proof), (p.orInL = p_1.orInL) = (p = p_1)

theorem Mathlib.Tactic.ITauto.Proof.hyp.injEq E0 #

∀ (n n_1 : Lean.Name), (Mathlib.Tactic.ITauto.Proof.hyp n = Mathlib.Tactic.ITauto.Proof.hyp n_1) = (n = n_1)

theorem Mathlib.Tactic.ITauto.Proof.curry₂.inj E1 #

∀ {ak : Mathlib.Tactic.ITauto.AndKind} {p q : Mathlib.Tactic.ITauto.Proof} {ak_1 : Mathlib.Tactic.ITauto.AndKind}
  {p_1 q_1 : Mathlib.Tactic.ITauto.Proof},
  Mathlib.Tactic.ITauto.Proof.curry₂ ak p q = Mathlib.Tactic.ITauto.Proof.curry₂ ak_1 p_1 q_1 →
    ak = ak_1 ∧ p = p_1 ∧ q = q_1

abbrev Mathlib.Tactic.ITauto.Proof.brecOn.go E1 #

{motive : Mathlib.Tactic.ITauto.Proof → Sort u} →
  (t : Mathlib.Tactic.ITauto.Proof) →
    ((t : Mathlib.Tactic.ITauto.Proof) → Mathlib.Tactic.ITauto.Proof.below t → motive t) →
      motive t ×' Mathlib.Tactic.ITauto.Proof.below t

theorem Mathlib.Tactic.ITauto.Proof.orImpL.inj E1 #

∀ {p p_1 : Mathlib.Tactic.ITauto.Proof}, p.orImpL = p_1.orImpL → p = p_1

theorem Mathlib.Tactic.ITauto.Proof.decidableElim.inj E1 #

∀ {classical : Bool} {p₁ x : Lean.Name} {p₂ p₃ : Mathlib.Tactic.ITauto.Proof} {classical_1 : Bool}
  {p₁_1 x_1 : Lean.Name} {p₂_1 p₃_1 : Mathlib.Tactic.ITauto.Proof},
  Mathlib.Tactic.ITauto.Proof.decidableElim classical p₁ x p₂ p₃ =
      Mathlib.Tactic.ITauto.Proof.decidableElim classical_1 p₁_1 x_1 p₂_1 p₃_1 →
    classical = classical_1 ∧ p₁ = p₁_1 ∧ x = x_1 ∧ p₂ = p₂_1 ∧ p₃ = p₃_1

theorem Mathlib.Tactic.ITauto.Proof.orInR.injEq E0 #

∀ (p p_1 : Mathlib.Tactic.ITauto.Proof), (p.orInR = p_1.orInR) = (p = p_1)

theorem Mathlib.Tactic.ITauto.Proof.impImpSimp.injEq E0 #

∀ (x : Lean.Name) (p : Mathlib.Tactic.ITauto.Proof) (x_1 : Lean.Name) (p_1 : Mathlib.Tactic.ITauto.Proof),
  (Mathlib.Tactic.ITauto.Proof.impImpSimp x p = Mathlib.Tactic.ITauto.Proof.impImpSimp x_1 p_1) = (x = x_1 ∧ p = p_1)

def Mathlib.Tactic.ITauto.Proof.ctorIdx E1 #

Mathlib.Tactic.ITauto.Proof → ℕ

theorem Mathlib.Tactic.ITauto.Proof.exfalso'.injEq E0 #

∀ (p p_1 : Mathlib.Tactic.ITauto.Proof), (p.exfalso' = p_1.exfalso') = (p = p_1)

theorem Mathlib.Tactic.ITauto.Proof.curry₂.injEq E0 #

∀ (ak : Mathlib.Tactic.ITauto.AndKind) (p q : Mathlib.Tactic.ITauto.Proof) (ak_1 : Mathlib.Tactic.ITauto.AndKind)
  (p_1 q_1 : Mathlib.Tactic.ITauto.Proof),
  (Mathlib.Tactic.ITauto.Proof.curry₂ ak p q = Mathlib.Tactic.ITauto.Proof.curry₂ ak_1 p_1 q_1) =
    (ak = ak_1 ∧ p = p_1 ∧ q = q_1)

theorem Mathlib.Tactic.ITauto.Proof.andIntro.injEq E0 #

∀ (ak : Mathlib.Tactic.ITauto.AndKind) (p₁ p₂ : Mathlib.Tactic.ITauto.Proof) (ak_1 : Mathlib.Tactic.ITauto.AndKind)
  (p₁_1 p₂_1 : Mathlib.Tactic.ITauto.Proof),
  (Mathlib.Tactic.ITauto.Proof.andIntro ak p₁ p₂ = Mathlib.Tactic.ITauto.Proof.andIntro ak_1 p₁_1 p₂_1) =
    (ak = ak_1 ∧ p₁ = p₁_1 ∧ p₂ = p₂_1)

inductive Mathlib.Tactic.ITauto.AndKind E1 #

Type

Different propositional constructors that are variants of "and" for the purposes of the theorem prover.

ctor Mathlib.Tactic.ITauto.AndKind.eq E0 #

Mathlib.Tactic.ITauto.AndKind

ctor Mathlib.Tactic.ITauto.AndKind.iff E0 #

Mathlib.Tactic.ITauto.AndKind

ctor Mathlib.Tactic.ITauto.AndKind.and E0 #

Mathlib.Tactic.ITauto.AndKind

def Mathlib.Tactic.ITauto.instToExprAndKind.toExpr E1 #

Mathlib.Tactic.ITauto.AndKind → Lean.Expr

instance Mathlib.Tactic.ITauto.instDecidableEqAndKind E0 #

DecidableEq Mathlib.Tactic.ITauto.AndKind

instance Mathlib.Tactic.ITauto.instToExprAndKind E0 #

Lean.ToExpr Mathlib.Tactic.ITauto.AndKind

instance Mathlib.Tactic.ITauto.instInhabitedAndKind E0 #

Inhabited Mathlib.Tactic.ITauto.AndKind

inductive Mathlib.Tactic.ITauto.IProp E1 #

Type

A reified inductive type for propositional logic.

ctor Mathlib.Tactic.ITauto.IProp.var E0 #

ℕ → Mathlib.Tactic.ITauto.IProp

ctor Mathlib.Tactic.ITauto.IProp.true E0 #

Mathlib.Tactic.ITauto.IProp

ctor Mathlib.Tactic.ITauto.IProp.false E0 #

Mathlib.Tactic.ITauto.IProp

ctor Mathlib.Tactic.ITauto.IProp.and' E0 #

Mathlib.Tactic.ITauto.AndKind → Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.IProp

ctor Mathlib.Tactic.ITauto.IProp.or E0 #

Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.IProp

ctor Mathlib.Tactic.ITauto.IProp.imp E0 #

Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.IProp

instance Mathlib.Tactic.ITauto.instToExprIProp E0 #

Lean.ToExpr Mathlib.Tactic.ITauto.IProp

def Mathlib.Tactic.ITauto.instToExprIProp.toExpr E1 #

Mathlib.Tactic.ITauto.IProp → Lean.Expr

def Mathlib.Tactic.ITauto.IProp.and E1 #

Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.IProp

Constructor for p ∧ q.

def Mathlib.Tactic.ITauto.IProp.iff E1 #

Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.IProp

Constructor for p ↔ q.

def Mathlib.Tactic.ITauto.IProp.eq E1 #

Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.IProp

Constructor for p = q.

def Mathlib.Tactic.ITauto.IProp.not E1 #

Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.IProp

Constructor for ¬ p.

def Mathlib.Tactic.ITauto.IProp.xor E1 #

Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.IProp

Constructor for xor p q.

instance Mathlib.Tactic.ITauto.instInhabitedIProp E0 #

Inhabited Mathlib.Tactic.ITauto.IProp

def Mathlib.Tactic.ITauto.AndKind.sides E1 #

Mathlib.Tactic.ITauto.AndKind →
  Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.IProp × Mathlib.Tactic.ITauto.IProp

Given the contents of an And variant, return the two conjuncts.

def Mathlib.Tactic.ITauto.IProp.format E1 #

Mathlib.Tactic.ITauto.IProp → Std.Format

Debugging printer for propositions.

instance Mathlib.Tactic.ITauto.instToFormatIProp E0 #

Std.ToFormat Mathlib.Tactic.ITauto.IProp

def Mathlib.Tactic.ITauto.AndKind.cmp E1 #

Mathlib.Tactic.ITauto.AndKind → Mathlib.Tactic.ITauto.AndKind → Ordering

A comparator for AndKind. (There should really be a derive handler for this.)

def Mathlib.Tactic.ITauto.IProp.cmp E1 #

Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.IProp → Ordering

A comparator for propositions. (There should really be a derive handler for this.)

instance Mathlib.Tactic.ITauto.instLTIProp E0 #

LT Mathlib.Tactic.ITauto.IProp

instance Mathlib.Tactic.ITauto.instDecidableLTIProp E0 #

DecidableLT Mathlib.Tactic.ITauto.IProp

inductive Mathlib.Tactic.ITauto.Proof E1 #

Type

A reified inductive proof type for intuitionistic propositional logic.

ctor Mathlib.Tactic.ITauto.Proof.sorry E0 #

Mathlib.Tactic.ITauto.Proof

⊢ A, causes failure during reconstruction

ctor Mathlib.Tactic.ITauto.Proof.hyp E0 #

Lean.Name → Mathlib.Tactic.ITauto.Proof

(n: A) ⊢ A

ctor Mathlib.Tactic.ITauto.Proof.triv E0 #

Mathlib.Tactic.ITauto.Proof

⊢ ⊤

ctor Mathlib.Tactic.ITauto.Proof.exfalso' E0 #

Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof

(p: ⊥) ⊢ A

ctor Mathlib.Tactic.ITauto.Proof.intro E0 #

Lean.Name → Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof

(p: (x: A) ⊢ B) ⊢ A → B

ctor Mathlib.Tactic.ITauto.Proof.andLeft E0 #

Mathlib.Tactic.ITauto.AndKind → Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof
  • ak = .and: (p: A ∧ B) ⊢ A
  • ak = .iff: (p: A ↔ B) ⊢ A → B
  • ak = .eq: (p: A = B) ⊢ A → B

ctor Mathlib.Tactic.ITauto.Proof.andRight E0 #

Mathlib.Tactic.ITauto.AndKind → Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof
  • ak = .and: (p: A ∧ B) ⊢ B
  • ak = .iff: (p: A ↔ B) ⊢ B → A
  • ak = .eq: (p: A = B) ⊢ B → A

ctor Mathlib.Tactic.ITauto.Proof.andIntro E0 #

Mathlib.Tactic.ITauto.AndKind → Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof
  • ak = .and: (p₁: A) (p₂: B) ⊢ A ∧ B
  • ak = .iff: (p₁: A → B) (p₁: B → A) ⊢ A ↔ B
  • ak = .eq: (p₁: A → B) (p₁: B → A) ⊢ A = B

ctor Mathlib.Tactic.ITauto.Proof.curry E0 #

Mathlib.Tactic.ITauto.AndKind → Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof
  • ak = .and: (p: A ∧ B → C) ⊢ A → B → C
  • ak = .iff: (p: (A ↔ B) → C) ⊢ (A → B) → (B → A) → C
  • ak = .eq: (p: (A = B) → C) ⊢ (A → B) → (B → A) → C

ctor Mathlib.Tactic.ITauto.Proof.curry₂ E0 #

Mathlib.Tactic.ITauto.AndKind → Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof

This is a partial application of curry.

  • ak = .and: (p: A ∧ B → C) (q : A) ⊢ B → C
  • ak = .iff: (p: (A ↔ B) → C) (q: A → B) ⊢ (B → A) → C
  • ak = .eq: (p: (A ↔ B) → C) (q: A → B) ⊢ (B → A) → C

ctor Mathlib.Tactic.ITauto.Proof.app' E0 #

Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof

(p: A → B) (q: A) ⊢ B

ctor Mathlib.Tactic.ITauto.Proof.orImpL E0 #

Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof

(p: A ∨ B → C) ⊢ A → C

ctor Mathlib.Tactic.ITauto.Proof.orImpR E0 #

Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof

(p: A ∨ B → C) ⊢ B → C

ctor Mathlib.Tactic.ITauto.Proof.orInL E0 #

Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof

(p: A) ⊢ A ∨ B

ctor Mathlib.Tactic.ITauto.Proof.orInR E0 #

Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof

(p: B) ⊢ A ∨ B

ctor Mathlib.Tactic.ITauto.Proof.orElim' E0 #

Mathlib.Tactic.ITauto.Proof →
  Lean.Name → Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof

(p₁: A ∨ B) (p₂: (x: A) ⊢ C) (p₃: (x: B) ⊢ C) ⊢ C

ctor Mathlib.Tactic.ITauto.Proof.decidableElim E0 #

Bool → Lean.Name → Lean.Name → Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof

(p₁: Decidable A) (p₂: (x: A) ⊢ C) (p₃: (x: ¬ A) ⊢ C) ⊢ C

ctor Mathlib.Tactic.ITauto.Proof.em E0 #

Bool → Lean.Name → Mathlib.Tactic.ITauto.Proof
  • classical = false: (p: Decidable A) ⊢ A ∨ ¬A
  • classical = true: (p: Prop) ⊢ p ∨ ¬p

ctor Mathlib.Tactic.ITauto.Proof.impImpSimp E0 #

Lean.Name → Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof

The variable x here names the variable that will be used in the elaborated proof.

  • (p: ((x:A) → B) → C) ⊢ B → C

instance Mathlib.Tactic.ITauto.instToExprProof E0 #

Lean.ToExpr Mathlib.Tactic.ITauto.Proof

def Mathlib.Tactic.ITauto.instToExprProof.toExpr E1 #

Mathlib.Tactic.ITauto.Proof → Lean.Expr

instance Mathlib.Tactic.ITauto.instInhabitedProof E0 #

Inhabited Mathlib.Tactic.ITauto.Proof

def Mathlib.Tactic.ITauto.Proof.format E1 #

Mathlib.Tactic.ITauto.Proof → Std.Format

Debugging printer for proof objects.

instance Mathlib.Tactic.ITauto.instToFormatProof E0 #

Std.ToFormat Mathlib.Tactic.ITauto.Proof

def Mathlib.Tactic.ITauto.Proof.exfalso E1 #

Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof

A variant on Proof.exfalso' that performs opportunistic simplification.

def Mathlib.Tactic.ITauto.Proof.orElim E1 #

Mathlib.Tactic.ITauto.Proof →
  Lean.Name → Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof

A variant on Proof.orElim' that performs opportunistic simplification.

def Mathlib.Tactic.ITauto.Proof.app E1 #

Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof

A variant on Proof.app' that performs opportunistic simplification. (This doesn't do full normalization because we don't want the proof size to blow up.)

def Mathlib.Tactic.ITauto.freshName E1 #

StateM ℕ Lean.Name

Get a new name in the pattern h0, h1, h2, ...

abbrev Mathlib.Tactic.ITauto.Context E1 #

Type

The context during proof search is a map from propositions to proof values.

def Mathlib.Tactic.ITauto.Context.format E1 #

Mathlib.Tactic.ITauto.Context → Std.Format

Debug printer for the context.

instance Mathlib.Tactic.ITauto.instToFormatContext E0 #

Std.ToFormat Mathlib.Tactic.ITauto.Context

opaque Mathlib.Tactic.ITauto.Context.add E1 #

Mathlib.Tactic.ITauto.IProp →
  Mathlib.Tactic.ITauto.Proof →
    Mathlib.Tactic.ITauto.Context →
      Except (Mathlib.Tactic.ITauto.IProp → Mathlib.Tactic.ITauto.Proof) Mathlib.Tactic.ITauto.Context

Insert a proposition and its proof into the context, as in have : A := p. This will eagerly apply all level 1 rules on the spot, which are rules that don't split the goal and are validity preserving: specifically, we drop ⊤ and A → ⊤ hypotheses, close the goal if we find a ⊥ hypothesis, split all conjunctions, and also simplify ⊥ → A (drop), ⊤ → A (simplify to A), A ∧ B → C (curry to A → B → C) and A ∨ B → C (rewrite to (A → C) ∧ (B → C) and split).

def Mathlib.Tactic.ITauto.Context.withAdd E1 #

Mathlib.Tactic.ITauto.Context →
  Mathlib.Tactic.ITauto.IProp →
    Mathlib.Tactic.ITauto.Proof →
      Mathlib.Tactic.ITauto.IProp →
        (Mathlib.Tactic.ITauto.Context → Mathlib.Tactic.ITauto.IProp → StateM ℕ (Bool × Mathlib.Tactic.ITauto.Proof)) →
          StateM ℕ (Bool × Mathlib.Tactic.ITauto.Proof)

Add A to the context Γ with proof p. This version of Context.add takes a continuation and a target proposition B, so that in the case that ⊥ is found we can skip the continuation and just prove B outright.

def Mathlib.Tactic.ITauto.mapProof E1 #

(Mathlib.Tactic.ITauto.Proof → Mathlib.Tactic.ITauto.Proof) →
  Bool × Mathlib.Tactic.ITauto.Proof → Bool × Mathlib.Tactic.ITauto.Proof

Map a function over the proof (regardless of whether the proof is successful or not).

def Mathlib.Tactic.ITauto.isOk E1 #

(Bool × Mathlib.Tactic.ITauto.Proof) × ℕ → Option (Mathlib.Tactic.ITauto.Proof × ℕ)

Convert a value-with-success to an optional value.

def Mathlib.Tactic.ITauto.whenOk E1 #

Bool →
  Mathlib.Tactic.ITauto.IProp →
    StateM ℕ (Bool × Mathlib.Tactic.ITauto.Proof) → StateM ℕ (Bool × Mathlib.Tactic.ITauto.Proof)

Skip the continuation and return a failed proof if the Boolean is false.

opaque Mathlib.Tactic.ITauto.search E1 #

Mathlib.Tactic.ITauto.Context → Mathlib.Tactic.ITauto.IProp → StateM ℕ (Bool × Mathlib.Tactic.ITauto.Proof)

The search phase, which deals with the level 3 rules, which are rules that are not validity preserving and so require proof search. One obvious one is the or-introduction rule: we prove A ∨ B by proving A or B, and we might have to try one and backtrack.

There are two rules dealing with implication in this category: p, p → C ⊢ B where p is an atom (which is safe if we can find it but often requires the right search to expose the p assumption), and (A₁ → A₂) → C ⊢ B. We decompose the double implication into two subgoals: one to prove A₁ → A₂, which can be written A₂ → C, A₁ ⊢ A₂ (where we used A₁ to simplify (A₁ → A₂) → C), and one to use the consequent, C ⊢ B. The search here is that there are potentially many implications to split like this, and we have to try all of them if we want to be complete.

opaque Mathlib.Tactic.ITauto.prove E1 #

Mathlib.Tactic.ITauto.Context → Mathlib.Tactic.ITauto.IProp → StateM ℕ (Bool × Mathlib.Tactic.ITauto.Proof)

The main prover. This receives a context of proven or assumed lemmas and a target proposition, and returns a proof or none (with state for the fresh variable generator). The intuitionistic logic rules are separated into three groups:

  • level 1: No splitting, validity preserving: apply whenever you can. Left rules in Context.add, right rules in prove
  • level 2: Splitting rules, validity preserving: apply after level 1 rules. Done in prove
  • level 3: Splitting rules, not validity preserving: apply only if nothing else applies. Done in search

The level 1 rules on the right of the turnstile are Γ ⊢ ⊤ and Γ ⊢ A → B, these are easy to handle. The rule Γ ⊢ A ∧ B is a level 2 rule, also handled here. If none of these apply, we try the level 2 rule A ∨ B ⊢ C by searching the context and splitting all ors we find. Finally, if we don't make any more progress, we go to the search phase.

opaque Mathlib.Tactic.ITauto.reify E1 #

Q(Prop) → Mathlib.Tactic.AtomM Mathlib.Tactic.ITauto.IProp

Reify an Expr into a IProp, allocating anything non-propositional as an atom in the AtomM state.

opaque Mathlib.Tactic.ITauto.applyProof E1 #

Lean.MVarId → Lean.NameMap Lean.Expr → Mathlib.Tactic.ITauto.Proof → Lean.MetaM Unit

Once we have a proof object, we have to apply it to the goal.

def Mathlib.Tactic.ITauto.itautoCore E1 #

Lean.MVarId → Bool → Bool → Array Lean.Expr → Lean.MetaM Unit

A decision procedure for intuitionistic propositional logic.

  • useDec will add a ∨ ¬ a to the context for every decidable atomic proposition a.
  • useClassical will allow a ∨ ¬ a to be added even if the proposition is not decidable, using classical logic.
  • extraDec will add a ∨ ¬ a to the context for specified (not necessarily atomic) propositions a.

def Mathlib.Tactic.ITauto.itauto E1 #

Lean.ParserDescr

itauto solves the main goal when it is a tautology of intuitionistic propositional logic. Unlike grind and tauto! this tactic never uses the law of excluded middle (without the ! option), and the proof search is tailored for this use case. itauto is complete for intuitionistic propositional logic: it will solve any goal that is provable in this logic.

  • itauto [a, b] will additionally attempt case analysis on a and b assuming that it can derive Decidable a and Decidable b.
  • itauto * will case on all decidable propositions that it can find among the atomic propositions.
  • itauto! will work as a classical SAT solver, but the algorithm is not very good in this situation.
  • itauto! * will case on all propositional atoms. Warning: This can blow up the proof search, so it should be used sparingly.

Example:

example (p : Prop) : ¬ (p ↔ ¬ p) := by itauto

def Mathlib.Tactic.ITauto.itauto! E1 #

Lean.ParserDescr

itauto solves the main goal when it is a tautology of intuitionistic propositional logic. Unlike grind and tauto! this tactic never uses the law of excluded middle (without the ! option), and the proof search is tailored for this use case. itauto is complete for intuitionistic propositional logic: it will solve any goal that is provable in this logic.

  • itauto [a, b] will additionally attempt case analysis on a and b assuming that it can derive Decidable a and Decidable b.
  • itauto * will case on all decidable propositions that it can find among the atomic propositions.
  • itauto! will work as a classical SAT solver, but the algorithm is not very good in this situation.
  • itauto! * will case on all propositional atoms. Warning: This can blow up the proof search, so it should be used sparingly.

Example:

example (p : Prop) : ¬ (p ↔ ¬ p) := by itauto