Documentation

MathematicalLogic.FirstOrder.Proof

Proof system of first-order logic #

This file formalizes a Hilbert-style proof system of first-order logic.

  1. Axiom and Proof define the first-order axioms and Hilbert-style proofs as inductive families. Proof Γ p (or Γ ⊢ p) where Γ is a set of formulas, says that proposition p is provable from the first-order axioms and the propositions in Γ (hypotheses).
  2. A few tactics are provided to facilitate proof writing -- e.g. pintro to introduce local hypothesis as a formula added to Γ, papply to apply a theorem onto the proof goal, and prw to rewrite the equalities or iffs in the proof goal.
  3. A lot of theorems (e.g. principle of explosion Proof.false_elim) and metatheorems (e.g. deduction theorem Proof.deduction) are proved.

Design note #

There are different ways to design a proof system for first-order logic.

  1. Hilbert-style systems, which promote minimality in their design, typically have a minimal set of axioms and minimal inference rules (typically, only Modus Ponens).
  2. Natural deduction usually has a weak notion of axioms and focuses more on inference rules. Those rules include introduction and elimination rules for each logical connectives. Some metatheorems in Hilbert-style systems, like the deduction theorem, become rules in natural deduction.
  3. Sequent calculus is similar to natural deduction, but has a more "bottom-up" style. In cut-free sequent calculus, a nice property, subformula property, holds, which makes it easy to do automated proof search. Gentzen's cut elimination, a standard result, ensures that any proof using cut can be transformed into a cut-free proof.

We are using Hilbert-style system because it's elegant, it can be easily applied to first-order theories with infinite axioms (since Γ can be any set) and it's easier to do encoding for proofs (since Γ does not change in the proof tree). Moreover, with the help of proof tactics, we are able to write proofs in the style of natural deduction (just as in Lean).

There are formalizations of other systems in Lean, e.g. FFL(lean4-logic) formalizes Tait calculus (a variant of sequent calculus) for first-order logic, and flypitch formalizes natural deduction.

Even within Hilbert-style systems, there are different choices on selecting the axioms and inference rules. The axioms and rules we selected have the following property:

  1. The only inference rule is Modus Ponens (Proof.mp). Some systems (e.g. in Mendelson's book) include a GEN rule to introduce universal quantifiers, but in our system it's a metatheorem (Proof.generalization). Also in such systems, the deduction theorem is restricted (e.g. in Mendelson's system, the deduction theorem for Γ ⊢ p ⇒ q requires no free variable in p used by GEN rule in Γ, p ⊢ q), while ours (Proof.deduction) is not.
  2. The logical axioms do not refer to propositional logic. Some systems (e.g. in Enderton's book) include all propositional tautologies as logical axioms.
  3. Equality axioms are formalized as logical axioms, not as a theory, because we want equality to be a part of first-order logic itself. This also makes prw tactic usable for all first-order theories.
  4. Empty structures are admitted (i.e. ∅ ⊬ ∃ x. ⊤ in general). This thanks to the "dependent type design" of Term and Formula: to prove ∃ x. ⊤ as a Sentence, a closed term t : L.Term 0 is needed for Proof.exists_intro; but in a language with no constants, no closed term exists.

References #

First-order axioms. Note that these are logical axioms -- theory related axioms (e.g. arithmetic) should occur as hypotheses.

The axioms in our proof system include:

  1. 3 axioms for propositional logic, imp_imp_self, imp_distrib and imp_contra;
  2. 3 axioms for quantifiers, forall_elim, forall_self and forall_imp;
  3. 5 axioms for equality, eq_refl, eq_symm, eq_trans, eq_congr_func and eq_congr_rel;
  4. the universal closure of all axioms generated by 1-3.
Instances For
    theorem FirstOrder.Language.Axiom.subst {L : Language} {n m : } {p : L.Formula n} {σ : L.Subst n m} :
    p L.Axiomp[σ]ₚ L.Axiom
    inductive FirstOrder.Language.Proof {L : Language} {n : } (Γ : L.FormulaSet n) :
    L.Formula nProp

    Hilbert-style proof.

    Instances For
      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        class FirstOrder.Language.Subtheory {L : Language} {n : } (Γ Δ : L.FormulaSet n) :

        Theory T₁ is a subtheory of T₂ (T₁ ⊆ᵀ T₂) if T₂ can proves all formulas in T₁. When that is true, all theorems of T₁ are also theorems of T₂ (see Proof.cut).

        This is designed as a typeclass so that, if there is an instance of T₁ ⊆ᵀ T₂, all theorems proved for T₁ can be applied to T₂ automatically when using papply tactic.

        Note: we define Subtheory for FormulaSet n in general, but the instances should always be for Theory.

        • subtheory (p : L.Formula n) : p ΓΔp
        Instances

          Theory T₁ is a subtheory of T₂ (T₁ ⊆ᵀ T₂) if T₂ can proves all formulas in T₁. When that is true, all theorems of T₁ are also theorems of T₂ (see Proof.cut).

          This is designed as a typeclass so that, if there is an instance of T₁ ⊆ᵀ T₂, all theorems proved for T₁ can be applied to T₂ automatically when using papply tactic.

          Note: we define Subtheory for FormulaSet n in general, but the instances should always be for Theory.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            theorem FirstOrder.Language.Subtheory.of_subset {L✝ : Language} {n✝ : } {Γ Δ : L✝.FormulaSet n✝} :
            Γ ΔΓ ⊆ᵀ Δ
            theorem FirstOrder.Language.Proof.hyp_append {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} :
            Γ,' pp
            theorem FirstOrder.Language.Proof.cut {L✝ : Language} {n✝ : } {Γ Δ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} :
            Γ ⊆ᵀ ΔΓpΔp
            theorem FirstOrder.Language.Proof.weaken {L✝ : Language} {n✝ : } {Γ Δ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} :
            Γ ΔΓpΔp
            theorem FirstOrder.Language.Proof.weaken_append {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
            ΓpΓ,' qp
            theorem FirstOrder.Language.Proof.mp₂ {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q r : L✝.Formula n✝} (h₁ : Γp q r) (h₂ : Γp) (h₃ : Γq) :
            Γr
            theorem FirstOrder.Language.Proof.identity {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} :
            Γp p
            theorem FirstOrder.Language.Proof.deduction {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
            Γp q Γ,' pq

            Deduction theorem.

            theorem FirstOrder.Language.Proof.cut_append {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} (h₁ : Γp) (h₂ : Γ,' pq) :
            Γq
            theorem FirstOrder.Language.Proof.subst {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} {m✝ : } {σ : L✝.Subst n✝ m✝} :
            Γp(fun (x : L✝.Formula n✝) => x[σ]ₚ) '' Γp[σ]ₚ
            theorem FirstOrder.Language.Proof.shift {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} :
            Γp↑ᴳ^[1] Γ↑ₚp
            theorem FirstOrder.Language.Proof.shiftk {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} {m : } :
            Γp↑ᴳ^[m] Γ↑ₚ^[m] p
            theorem FirstOrder.Language.Proof.forall_imp {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula (n✝ + 1)} :
            Γ∀' (p q) ∀' p ∀' q
            theorem FirstOrder.Language.Proof.forall_elim {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula (n✝ + 1)} (t : L✝.Term n✝) :
            Γ∀' p p[↦ₛ t]ₚ
            theorem FirstOrder.Language.Proof.forall_self {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} :
            Γp ∀' ↑ₚp
            theorem FirstOrder.Language.Proof.generalization {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula (n✝ + 1)} :
            ↑ᴳ^[1] Γp Γ∀' p

            Generalization theorem.

            theorem FirstOrder.Language.Proof.forall_intro {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula (n✝ + 1)} :
            ↑ᴳ^[1] ΓpΓ∀' p
            theorem FirstOrder.Language.Proof.compactness {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} :
            ΓpΔΓ, Set.Finite Δ Δp

            Proof compactness theorem.

            instance FirstOrder.Language.Subtheory.refl {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} :
            Γ ⊆ᵀ Γ
            theorem FirstOrder.Language.Subtheory.trans {L✝ : Language} {n✝ : } {Γ₁ Γ₂ Γ₃ : L✝.FormulaSet n✝} (h₁ : Γ₁ ⊆ᵀ Γ₂) (h₂ : Γ₂ ⊆ᵀ Γ₃) :
            Γ₁ ⊆ᵀ Γ₃
            theorem FirstOrder.Language.Subtheory.trans' {L✝ : Language} {n✝ : } {Γ₂ Γ₃ Γ₁ : L✝.FormulaSet n✝} (h₁ : Γ₂ ⊆ᵀ Γ₃) (h₂ : Γ₁ ⊆ᵀ Γ₂) :
            Γ₁ ⊆ᵀ Γ₃
            theorem FirstOrder.Language.Subtheory.append {L✝ : Language} {n✝ : } {Γ Δ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} (h : Γ ⊆ᵀ Δ) :
            Γ ⊆ᵀ Δ,' p
            theorem FirstOrder.Language.Subtheory.append_append {L✝ : Language} {n✝ : } {Γ Δ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} (h : Γ ⊆ᵀ Δ) :
            Γ,' p ⊆ᵀ Δ,' p
            theorem FirstOrder.Language.Subtheory.shiftk {L✝ : Language} {n✝ : } {Γ Δ : L✝.FormulaSet n✝} {k : } (h : Γ ⊆ᵀ Δ) :
            theorem FirstOrder.Language.Subtheory.shift {L✝ : Language} {n✝ : } {Γ Δ : L✝.FormulaSet n✝} (h : Γ ⊆ᵀ Δ) :
            theorem FirstOrder.Language.Subtheory.shiftT {L : Language} {n : } {T₁ T₂ : L.Theory} (h : T₁ ⊆ᵀ T₂) :

            Introduce a new hypothesis or a new variable.

            Equations
            Instances For

              Repeatedly introduce new hypotheses and variables. pintros n introduces exactly n hypotheses and variables, while pintros introduces as many as possible.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                Equations
                • One or more equations did not get rendered due to their size.
                Instances For

                  Close the proof goal using assumption. passumption n will use the n-th assumption (from right to left, counting from 0), while passumption tries to search for such an assumption.

                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For

                    For goal Γ ⊢ p, phave q proves Γ ⊢ q first and then proves Γ, q ⊢ p.

                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For

                      For goal Γ ⊢ p, psuffices q proves Γ, q ⊢ p first and then proves Γ ⊢ q.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For

                        pclear n removes the n-th assumption.

                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For

                          Remove all assumptions except the theory (or formula set) itself.

                          Equations
                          Instances For

                            pswap n m swaps the n-th assumption and the m-th assumption.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For

                              preplace n p replaces the n-th assumption with a new proposition p, and generate a new goal to prove p.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For

                                Revert an assumption through deduction theorem. prevert n reverts the n-th assumption, and prevert reverts the 0-th assumption.

                                Equations
                                • One or more equations did not get rendered due to their size.
                                Instances For
                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For

                                    Unify Γ as a subtheory of Δ and return a term of type Γ ⊆ᵀ Δ.

                                    Equations
                                    • One or more equations did not get rendered due to their size.
                                    Instances For
                                      Equations
                                      • One or more equations did not get rendered due to their size.
                                      Instances For
                                        Equations
                                        • One or more equations did not get rendered due to their size.
                                        Instances For
                                          Equations
                                          • One or more equations did not get rendered due to their size.
                                          Instances For
                                            Equations
                                            • One or more equations did not get rendered due to their size.
                                            Instances For

                                              Given a proof term t of Γ ⊢ p₁ ⇒ ⋯ ⇒ pₙ ⇒ q, papply t apply it on a proof goal of Δ ⊢ ⋯ (Γ should be a subset/subtheory of Δ) with a chain Proof.mp.

                                              • papply t will apply t on the current goal Δ ⊢ q and create goals for each Δ ⊢ pᵢ.
                                              • papply t at h (where h is an identifier) will apply t on the local hypothesis h with type Δ ⊢ pₙ, replace it with Δ ⊢ q and create goals for other Δ ⊢ pᵢ.
                                              • papply t at k (where k is an number) will apply t on the k-th assumption pₙ in Δ (counting from right to left), replace it with q and create goals for other Δ ⊢ pᵢ.

                                              papply t with d controls the number of Proof.mp (equal to n) to be d. If with is not presented, papply will try from n = 0 until it succeeds or exhausts all . For papply at h or papply at k, d should be greater than or equal to 1.

                                              Equations
                                              • One or more equations did not get rendered due to their size.
                                              Instances For

                                                Apply the n-th assumption using Proof.mp.

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For

                                                  Close the goal with given proof term.

                                                  Equations
                                                  • One or more equations did not get rendered due to their size.
                                                  Instances For

                                                    If k-th assumption is p₁ ⇒ p₂ ⇒ ⋯ ⇒ pₙ ⇒ q, pspecialize k replace it with q and generate proof goals for each pᵢ (goals for pᵢ will occur before the original goal). pspecialize k with d controls the number of Proof.mp.

                                                    Equations
                                                    • One or more equations did not get rendered due to their size.
                                                    Instances For
                                                      Equations
                                                      • One or more equations did not get rendered due to their size.
                                                      Instances For
                                                        Equations
                                                        • One or more equations did not get rendered due to their size.
                                                        Instances For
                                                          Equations
                                                          • One or more equations did not get rendered due to their size.
                                                          Instances For
                                                            Equations
                                                            • One or more equations did not get rendered due to their size.
                                                            Instances For
                                                              theorem FirstOrder.Language.Proof.composition {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q r : L✝.Formula n✝} :
                                                              Γ ⊢ (p q) (q r) p r
                                                              theorem FirstOrder.Language.Proof.imp_contra {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
                                                              Γ ⊢ (~ p ~ q) q p
                                                              theorem FirstOrder.Language.Proof.true_intro {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} :
                                                              Γ
                                                              theorem FirstOrder.Language.Proof.false_elim {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} :
                                                              Γ p
                                                              theorem FirstOrder.Language.Proof.imp_double_neg {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} :
                                                              Γp ~ ~ p
                                                              theorem FirstOrder.Language.Proof.double_neg_imp {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} :
                                                              Γ~ ~ p p

                                                              Proof by contradiction.

                                                              Equations
                                                              Instances For
                                                                theorem FirstOrder.Language.Proof.and_intro {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
                                                                Γp q p q
                                                                theorem FirstOrder.Language.Proof.and_left {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
                                                                Γp q p
                                                                theorem FirstOrder.Language.Proof.and_right {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
                                                                Γp q q
                                                                theorem FirstOrder.Language.Proof.or_inl {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
                                                                Γp p q
                                                                theorem FirstOrder.Language.Proof.or_inr {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {q p : L✝.Formula n✝} :
                                                                Γq p q
                                                                theorem FirstOrder.Language.Proof.or_elim {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q r : L✝.Formula n✝} :
                                                                Γp q (p r) (q r) r
                                                                theorem FirstOrder.Language.Proof.or_elim' {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p r q : L✝.Formula n✝} :
                                                                Γ ⊢ (p r) (q r) p q r
                                                                theorem FirstOrder.Language.Proof.excluded_middle {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} (p : L✝.Formula n✝) :
                                                                Γ~ p p
                                                                theorem FirstOrder.Language.Proof.andN_intro {L : Language} {n m : } {Γ : L.FormulaSet n} {v : Vec (L.Formula n) m} :
                                                                (∀ (i : Fin m), Γv i)Γ (i : Fin m), v i
                                                                theorem FirstOrder.Language.Proof.andN_elim {L : Language} {n m : } {Γ : L.FormulaSet n} {v : Vec (L.Formula n) m} (i : Fin m) :
                                                                Γ( (i : Fin m), v i) v i
                                                                theorem FirstOrder.Language.Proof.orN_intro {L : Language} {n m : } {Γ : L.FormulaSet n} {v : Vec (L.Formula n) m} (i : Fin m) :
                                                                Γv i (i : Fin m), v i
                                                                theorem FirstOrder.Language.Proof.orN_elim' {L : Language} {n m : } {Γ : L.FormulaSet n} {p : L.Formula n} {v : Vec (L.Formula n) m} :
                                                                (∀ (i : Fin m), Γv i p)Γ( (i : Fin m), v i) p
                                                                theorem FirstOrder.Language.Proof.orN_elim {L : Language} {n m : } {Γ : L.FormulaSet n} {p : L.Formula n} {v : Vec (L.Formula n) m} :
                                                                Γ (i : Fin m), v i(∀ (i : Fin m), Γv i p)Γp
                                                                theorem FirstOrder.Language.Proof.iff_intro {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
                                                                Γ ⊢ (p q) (q p) p q
                                                                theorem FirstOrder.Language.Proof.iff_mp {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
                                                                Γ ⊢ (p q) p q
                                                                theorem FirstOrder.Language.Proof.iff_mpr {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
                                                                Γ ⊢ (p q) q p
                                                                theorem FirstOrder.Language.Proof.iff_refl {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} :
                                                                Γp p
                                                                theorem FirstOrder.Language.Proof.iff_symm {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
                                                                Γ ⊢ (p q) q p
                                                                theorem FirstOrder.Language.Proof.iff_comm {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
                                                                Γ ⊢ (p q) (q p)
                                                                theorem FirstOrder.Language.Proof.iff_trans {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q r : L✝.Formula n✝} :
                                                                Γ ⊢ (p q) (q r) p r
                                                                theorem FirstOrder.Language.Proof.iff_congr_imp {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p₁ p₂ q₁ q₂ : L✝.Formula n✝} :
                                                                Γ ⊢ (p₁ p₂) (q₁ q₂) (p₁ q₁) (p₂ q₂)
                                                                theorem FirstOrder.Language.Proof.iff_congr_neg {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
                                                                Γ ⊢ (p q) ~ p ~ q
                                                                theorem FirstOrder.Language.Proof.iff_congr_and {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p₁ p₂ q₁ q₂ : L✝.Formula n✝} :
                                                                Γ ⊢ (p₁ p₂) (q₁ q₂) p₁ q₁ p₂ q₂
                                                                theorem FirstOrder.Language.Proof.iff_congr_or {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p₁ p₂ q₁ q₂ : L✝.Formula n✝} :
                                                                Γ ⊢ (p₁ p₂) (q₁ q₂) p₁ q₁ p₂ q₂
                                                                theorem FirstOrder.Language.Proof.iff_congr_iff {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p₁ p₂ q₁ q₂ : L✝.Formula n✝} :
                                                                Γ ⊢ (p₁ p₂) (q₁ q₂) (p₁ q₁) (p₂ q₂)
                                                                theorem FirstOrder.Language.Proof.double_neg_iff {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} :
                                                                Γ~ ~ p p
                                                                theorem FirstOrder.Language.Proof.neg_and_iff {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
                                                                Γ~ (p q) ~ p ~ q
                                                                theorem FirstOrder.Language.Proof.neg_or_iff {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
                                                                Γ~ (p q) ~ p ~ q
                                                                theorem FirstOrder.Language.Proof.imp_iff {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
                                                                Γ ⊢ (p q) ~ p q
                                                                theorem FirstOrder.Language.Proof.neg_imp_iff {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
                                                                Γ~ (p q) p ~ q
                                                                theorem FirstOrder.Language.Proof.imp_contra_iff {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
                                                                Γ ⊢ (~ p ~ q) (q p)
                                                                theorem FirstOrder.Language.Proof.neg_andN_iff {L : Language} {n m : } {Γ : L.FormulaSet n} {v : Vec (L.Formula n) m} :
                                                                Γ ⊢ (~ (i : Fin m), v i) (i : Fin m), ~ v i
                                                                theorem FirstOrder.Language.Proof.neg_orN_iff {L : Language} {n m : } {Γ : L.FormulaSet n} {v : Vec (L.Formula n) m} :
                                                                Γ ⊢ (~ (i : Fin m), v i) (i : Fin m), ~ v i
                                                                theorem FirstOrder.Language.Proof.and_imp_iff {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q r : L✝.Formula n✝} :
                                                                Γ ⊢ (p q r) (p q r)
                                                                theorem FirstOrder.Language.Proof.and_comm {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
                                                                Γp q q p
                                                                theorem FirstOrder.Language.Proof.and_assoc {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q r : L✝.Formula n✝} :
                                                                Γ ⊢ (p q) r p q r
                                                                theorem FirstOrder.Language.Proof.or_comm {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula n✝} :
                                                                Γp q q p
                                                                theorem FirstOrder.Language.Proof.or_assoc {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q r : L✝.Formula n✝} :
                                                                Γ ⊢ (p q) r p q r
                                                                theorem FirstOrder.Language.Proof.iff_congr_forall {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula (n✝ + 1)} :
                                                                Γ∀' (p q) ∀' p ∀' q
                                                                theorem FirstOrder.Language.Proof.iff_congr_exists {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula (n✝ + 1)} :
                                                                Γ∀' (p q) ∃' p ∃' q
                                                                theorem FirstOrder.Language.Proof.neg_forall_iff {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula (n✝ + 1)} :
                                                                Γ~ ∀' p ∃' (~ p)
                                                                theorem FirstOrder.Language.Proof.neg_exists_iff {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula (n✝ + 1)} :
                                                                Γ~ ∃' p ∀' (~ p)
                                                                theorem FirstOrder.Language.Proof.neg_forall_neg_iff {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula (n✝ + 1)} :
                                                                Γ~ ∀' (~ p) ∃' p
                                                                theorem FirstOrder.Language.Proof.neg_exists_neg_iff {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula (n✝ + 1)} :
                                                                Γ~ ∃' (~ p) ∀' p
                                                                theorem FirstOrder.Language.Proof.exists_intro {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula (n✝ + 1)} (t : L✝.Term n✝) :
                                                                Γp[↦ₛ t]ₚ ∃' p
                                                                theorem FirstOrder.Language.Proof.exists_elim {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula (n✝ + 1)} {q : L✝.Formula n✝} :
                                                                Γ∃' p ∀' (p ↑ₚq) q
                                                                theorem FirstOrder.Language.Proof.exists_elim' {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula (n✝ + 1)} {q : L✝.Formula n✝} :
                                                                Γ∀' (p ↑ₚq) ∃' p q
                                                                theorem FirstOrder.Language.Proof.exists_self {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} :
                                                                Γ∃' ↑ₚp p
                                                                theorem FirstOrder.Language.Proof.exists_imp {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula (n✝ + 1)} :
                                                                Γ∀' (p q) ∃' p ∃' q
                                                                theorem FirstOrder.Language.Proof.forallN_intro {m : } {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula (n✝ + m)} :
                                                                ↑ᴳ^[m] ΓpΓ∀^[m] p
                                                                theorem FirstOrder.Language.Proof.forallN_elim' {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {m a✝ : } {p : L✝.Formula (a✝ + m)} {σ₂ : L✝.Subst a✝ n✝} (σ₁ : Vec (L✝.Term n✝) m) :
                                                                Γ ⊢ (∀^[m] p)[σ₂]ₚ p[σ₁ ++ᵥ σ₂]ₚ
                                                                theorem FirstOrder.Language.Proof.forallN_elim {L : Language} {m n : } {Γ : L.FormulaSet n} {p : L.Formula (n + m)} (σ : L.Subst m n) :
                                                                Γ∀^[m] p p[σ ++ᵥ idₛ]ₚ
                                                                theorem FirstOrder.Language.Proof.forallN_imp {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {m : } {p q : L✝.Formula (n✝ + m)} :
                                                                Γ∀^[m] p ∀^[m] (p q) ∀^[m] q
                                                                theorem FirstOrder.Language.Proof.existsN_intro' {L : Language} {k m n✝ : } {Γ : L.FormulaSet n✝} {σ₂ : Vec (L.Term n✝) k} {p : L.Formula (k + m)} (σ₁ : Vec (L.Term n✝) m) :
                                                                Γp[σ₁ ++ᵥ σ₂]ₚ (∃^[m] p)[σ₂]ₚ
                                                                theorem FirstOrder.Language.Proof.existsN_intro {L : Language} {n m : } {Γ : L.FormulaSet n} {p : L.Formula (n + m)} (σ : Vec (L.Term n) m) :
                                                                Γp[σ ++ᵥ idₛ]ₚ ∃^[m] p
                                                                theorem FirstOrder.Language.Proof.existsN_elim {L : Language} {n m : } {Γ : L.FormulaSet n} {q : L.Formula n} {p : L.Formula (n + m)} :
                                                                Γ∃^[m] p ∀^[m] (p ↑ₚ^[m] q) q
                                                                theorem FirstOrder.Language.Proof.existsN_elim' {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {m : } {p : L✝.Formula (n✝ + m)} {q : L✝.Formula n✝} :
                                                                Γ∀^[m] (p ↑ₚ^[m] q) ∃^[m] p q
                                                                theorem FirstOrder.Language.Proof.eq_refl {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {t : L✝.Term n✝} :
                                                                Γt t
                                                                theorem FirstOrder.Language.Proof.eq_symm {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {t₁ t₂ : L✝.Term n✝} :
                                                                Γt₁ t₂ t₂ t₁
                                                                theorem FirstOrder.Language.Proof.eq_trans {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {t₁ t₂ t₃ : L✝.Term n✝} :
                                                                Γt₁ t₂ t₂ t₃ t₁ t₃
                                                                theorem FirstOrder.Language.Proof.eq_comm {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} (t₁ t₂ : L✝.Term n✝) :
                                                                Γt₁ t₂ t₂ t₁

                                                                Close the proof goal t ≐ t or p ⇔ p using reflexivity.

                                                                Equations
                                                                Instances For

                                                                  If the proof goal is t₁ ≐ t₂ or p ⇔ q, replace it with t₂ ≐ t₁ or q ⇔ p using symmetry.

                                                                  Equations
                                                                  Instances For

                                                                    If the proof goal is t₁ ≐ t₂ (or p ⇔ q), replace it with two goals, t₁ ≐ t and t ≐ t₂ (or p ⇔ r and r ⇔ q) using transitivity.

                                                                    A meta variable is generated for t or r if it is not given.

                                                                    Equations
                                                                    • One or more equations did not get rendered due to their size.
                                                                    Instances For
                                                                      theorem FirstOrder.Language.Proof.eq_andN_refl {L : Language} {n m : } {Γ : L.FormulaSet n} {v : Vec (L.Term n) m} :
                                                                      Γ (i : Fin m), v i v i
                                                                      theorem FirstOrder.Language.Proof.eq_andN_cons {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {t₁ t₂ : L✝.Term n✝} {n✝¹ : } {v₁ v₂ : Vec (L✝.Term n✝) n✝¹} :
                                                                      Γt₁ t₂ ( (i : Fin n✝¹), v₁ i v₂ i) (i : Fin (n✝¹ + 1)), (t₁ ∷ᵥ v₁) i (t₂ ∷ᵥ v₂) i
                                                                      theorem FirstOrder.Language.Proof.eq_congr_func {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {n✝¹ : } {v₁ v₂ : Fin n✝¹L✝.Term n✝} {f : L✝.Func n✝¹} :
                                                                      Γ( (i : Fin n✝¹), v₁ i v₂ i) f ⬝ᶠ v₁ f ⬝ᶠ v₂
                                                                      theorem FirstOrder.Language.Proof.eq_subst_eq {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {n✝¹ : } {σ₁ σ₂ : L✝.Subst n✝¹ n✝} {t : L✝.Term n✝¹} :
                                                                      Γ( (i : Fin n✝¹), σ₁ i σ₂ i) t[σ₁]ₜ t[σ₂]ₜ
                                                                      theorem FirstOrder.Language.Proof.eq_congr_eq {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {t₁ t₁' t₂ t₂' : L✝.Term n✝} :
                                                                      Γt₁ t₁' t₂ t₂' t₁ t₂ t₁' t₂'
                                                                      theorem FirstOrder.Language.Proof.eq_congr_eq_iff {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {t₁ t₁' t₂ t₂' : L✝.Term n✝} :
                                                                      Γt₁ t₁' t₂ t₂' t₁ t₂ t₁' t₂'
                                                                      theorem FirstOrder.Language.Proof.eq_congr_rel {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {n✝¹ : } {v₁ v₂ : Fin n✝¹L✝.Term n✝} {r : L✝.Rel n✝¹} :
                                                                      Γ( (i : Fin n✝¹), v₁ i v₂ i) r ⬝ʳ v₁ r ⬝ʳ v₂
                                                                      theorem FirstOrder.Language.Proof.eq_congr_rel_iff {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {n✝¹ : } {v₁ v₂ : Fin n✝¹L✝.Term n✝} {r : L✝.Rel n✝¹} :
                                                                      Γ( (i : Fin n✝¹), v₁ i v₂ i) r ⬝ʳ v₁ r ⬝ʳ v₂
                                                                      theorem FirstOrder.Language.Proof.eq_subst_iff {L : Language} {n n✝ : } {σ₁ σ₂ : L.Subst n✝ n} {p : L.Formula n✝} {Γ : L.FormulaSet n} :
                                                                      Γ( (i : Fin n✝), σ₁ i σ₂ i) p[σ₁]ₚ p[σ₂]ₚ
                                                                      theorem FirstOrder.Language.Proof.eq_subst {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {n✝¹ : } {σ₁ σ₂ : L✝.Subst n✝¹ n✝} {p : L✝.Formula n✝¹} :
                                                                      Γ( (i : Fin n✝¹), σ₁ i σ₂ i) p[σ₁]ₚ p[σ₂]ₚ
                                                                      theorem FirstOrder.Language.Proof.eq_subst' {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {a✝ : } {p : L✝.Formula a✝} {σ₁ σ₂ : L✝.Subst a✝ n✝} :
                                                                      Γp[σ₁]ₚ ( (i : Fin a✝), σ₁ i σ₂ i) p[σ₂]ₚ
                                                                      Equations
                                                                      • One or more equations did not get rendered due to their size.
                                                                      Instances For
                                                                        def FirstOrder.Language.Proof.Tactic.prwRuleToTactic (rule : Lean.TSyntax `FirstOrder.Language.Proof.Tactic.prwRule) :
                                                                        Lean.MacroM (Lean.TSyntax `Lean.Parser.Tactic.tacticSeq)
                                                                        Equations
                                                                        • One or more equations did not get rendered due to their size.
                                                                        Instances For
                                                                          def FirstOrder.Language.Proof.Tactic.prwSolve (rule : Lean.TSyntax `FirstOrder.Language.Proof.Tactic.prwRule) (goal : Lean.MVarId) (debug? : Bool) :
                                                                          Equations
                                                                          • One or more equations did not get rendered due to their size.
                                                                          Instances For
                                                                            def FirstOrder.Language.Proof.Tactic.runPrwAtMainGoal (rules : Lean.Syntax.TSepArray `FirstOrder.Language.Proof.Tactic.prwRule ",") (debug? : Bool) :
                                                                            Equations
                                                                            • One or more equations did not get rendered due to their size.
                                                                            Instances For
                                                                              def FirstOrder.Language.Proof.Tactic.runPrwAtLocalHyp (rules : Lean.Syntax.TSepArray `FirstOrder.Language.Proof.Tactic.prwRule ",") (target : Lean.TSyntax `ident) (debug? : Bool) :
                                                                              Equations
                                                                              • One or more equations did not get rendered due to their size.
                                                                              Instances For
                                                                                def FirstOrder.Language.Proof.Tactic.runPrwAtAssumption (rules : Lean.Syntax.TSepArray `FirstOrder.Language.Proof.Tactic.prwRule ",") (target : ) (debug? : Bool) :
                                                                                Equations
                                                                                • One or more equations did not get rendered due to their size.
                                                                                Instances For

                                                                                  prw [e₁, ⋯, eₙ] rewrites a proof goal Γ ⊢ p using given rules. A rule e can be either proof term or a number (refer to an assumption in Γ), having type Δ ⊢ t₁ ≐ t₂ or Δ ⊢ q ⇔ r (and Δ should be a subset/subtheory of Γ). ←e reverse the direction of rewrite.

                                                                                  • prw [e₁, ⋯, eₙ] will rewrite on the current goal.
                                                                                  • prw [e₁, ⋯, eₙ] at h (where h is an identifier) will rewrite at the local hypothesis h.
                                                                                  • prw [e₁, ⋯, eₙ] at k (where k is a number) will rewrite on the k-th assumption in Γ.

                                                                                  prw_debug runs prw tactic while printing debug information.

                                                                                  Equations
                                                                                  • One or more equations did not get rendered due to their size.
                                                                                  Instances For
                                                                                    theorem FirstOrder.Language.Proof.ne_symm {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {t₁ t₂ : L✝.Term n✝} :
                                                                                    Γ~ t₁ t₂ ~ t₂ t₁
                                                                                    theorem FirstOrder.Language.Proof.ne_comm {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} (t₁ t₂ : L✝.Term n✝) :
                                                                                    Γ~ t₁ t₂ ~ t₂ t₁
                                                                                    theorem FirstOrder.Language.Proof.exists_of_exists_unique {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula (n✝ + 1)} :
                                                                                    Γ∃!' p ∃' p
                                                                                    theorem FirstOrder.Language.Proof.unique_of_exists_unique {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula (n✝ + 1)} {t₁ t₂ : L✝.Term n✝} :
                                                                                    Γ∃!' p p[↦ₛ t₁]ₚ p[↦ₛ t₂]ₚ t₁ t₂
                                                                                    theorem FirstOrder.Language.Proof.iff_congr_exists_unique {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p q : L✝.Formula (n✝ + 1)} :
                                                                                    Γ∀' (p q) ∃!' p ∃!' q
                                                                                    theorem FirstOrder.Language.Theory.generalization_alls {L : Language} {T : L.Theory} {n : } {p : L.Formula n} :
                                                                                    ↑ᵀ^[n] Tp T∀* p
                                                                                    theorem FirstOrder.Language.Theory.foralls_intro {L : Language} {T : L.Theory} {n : } {p : L.Formula n} :
                                                                                    ↑ᵀ^[n] TpT∀* p
                                                                                    theorem FirstOrder.Language.Theory.foralls_elim {L : Language} {T : L.Theory} {n m : } {p : L.Formula n} (σ : L.Subst n m) :
                                                                                    T∀* p↑ᵀ^[m] Tp[σ]ₚ
                                                                                    theorem FirstOrder.Language.Theory.foralls_imp {L : Language} {T : L.Theory} {a✝ : } {p q : L.Formula a✝} :
                                                                                    T∀* (p q) ∀* p ∀* q
                                                                                    theorem FirstOrder.Language.Theory.iff_congr_foralls {L : Language} {T : L.Theory} {a✝ : } {p q : L.Formula a✝} :
                                                                                    T∀* (p q) ∀* p ∀* q
                                                                                    theorem FirstOrder.Language.Theory.iff_congr_subst {L : Language} {T : L.Theory} {k : } {p q : L.Formula k} {n : } {σ : L.Subst k n} :
                                                                                    ↑ᵀ^[k] Tp q↑ᵀ^[n] Tp[σ]ₚ q[σ]ₚ

                                                                                    The deductive closure of a theory.

                                                                                    Equations
                                                                                    Instances For
                                                                                      @[simp]
                                                                                      Equations
                                                                                      • One or more equations did not get rendered due to their size.
                                                                                      Instances For

                                                                                        A theory (formula set in general) is consistent if it does not prove .

                                                                                        Equations
                                                                                        Instances For
                                                                                          theorem FirstOrder.Language.Consistent.weaken {L✝ : Language} {n✝ : } {Γ Δ : L✝.FormulaSet n✝} :
                                                                                          Γ ΔConsistent ΔConsistent Γ
                                                                                          theorem FirstOrder.Language.Consistent.append {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} :
                                                                                          Consistent (Γ,' p) ¬Γ~ p
                                                                                          theorem FirstOrder.Language.Consistent.append_neg {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} :
                                                                                          Consistent (Γ,' ~ p) ¬Γp
                                                                                          theorem FirstOrder.Language.Consistent.undisprovable_of_provable {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} :
                                                                                          Consistent ΓΓp¬Γ~ p
                                                                                          theorem FirstOrder.Language.Consistent.unprovable_of_disprovable {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} :
                                                                                          Consistent ΓΓ~ p¬Γp
                                                                                          @[simp]
                                                                                          theorem FirstOrder.Language.inconsistent_iff {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} :
                                                                                          ¬Consistent Γ Γ

                                                                                          A theory (formula set in general) is complete if for each p it either proves p or proves ~ p.

                                                                                          Note: we do not assume the theory to be consistent. Under this definition, inconsistent theories are also complete.

                                                                                          Equations
                                                                                          Instances For
                                                                                            theorem FirstOrder.Language.Complete.disprovable_of_unprovable {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} (h : Complete Γ) :
                                                                                            ¬ΓpΓ~ p
                                                                                            theorem FirstOrder.Language.Complete.unprovable_iff_disprovable {L✝ : Language} {n✝ : } {Γ : L✝.FormulaSet n✝} {p : L✝.Formula n✝} (h₁ : Complete Γ) (h₂ : Consistent Γ) :
                                                                                            ¬Γp Γ~ p
                                                                                            Equations
                                                                                            Instances For