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 / V32. Logic, model theory and computability

Mathlib.ModelTheory.Algebra.Ring.Basic

51 declarations. Mathlib docs · Source

First-Order Language of Rings

This file defines the first-order language of rings, as well as defining instance of Add, Mul, etc. on terms in the language.

Main Definitions

  • FirstOrder.Language.ring : the language of rings, with function symbols +, *, -, 0, 1
  • FirstOrder.Ring.CompatibleRing : A class stating that a type is a Language.ring.Structure, and that this structure is the same as the structure given by the classes Add, Mul, etc. already on R.
  • FirstOrder.Ring.compatibleRingOfRing : Given a type R with instances for each of the Ring operations, make a compatibleRing instance.

Implementation notes

There are implementation difficulties with the model theory of rings caused by the fact that there are two different ways to say that R is a Ring. We can say Ring R or Language.ring.Structure R and Theory.ring.Model R (The theory of rings is not implemented yet).

The recommended way to use this library is to use the hypotheses CompatibleRing R and Ring R on any theorem that requires both a Ring instance and a Language.ring.Structure instance in order to state the theorem. To apply such a theorem to a ring R with a Ring instance, use the tactic let _ := compatibleRingOfRing R. To apply the theorem to K a Language.ring.Structure K instance and for example an instance of Theory.field.Model K, you must add local instances with definitions like ModelTheory.Field.fieldOfModelField K and FirstOrder.Ring.compatibleRingOfModelField K. (in Mathlib/ModelTheory/Algebra/Field/Basic.lean), depending on the Theory.

def FirstOrder.ringFunc.ctorIdx E1 #

{a : ℕ} → FirstOrder.ringFunc a → ℕ

def FirstOrder.Ring.CompatibleRing.ctorIdx E1 #

{R : Type u_2} →
  {inst : Add R} →
    {inst_1 : Mul R} → {inst_2 : Neg R} → {inst_3 : One R} → {inst_4 : Zero R} → FirstOrder.Ring.CompatibleRing R → ℕ

abbrev FirstOrder.ringFunc.ctorElimType E1 #

{motive : (a : ℕ) → FirstOrder.ringFunc a → Sort u} → ℕ → Sort (max 1 u)

inductive FirstOrder.ringFunc E1 #

ℕ → Type

The type of Ring functions, to be used in the definition of the language of rings. It contains the operations (+,*,-,0,1)

ctor FirstOrder.ringFunc.add E0 #

FirstOrder.ringFunc 2

ctor FirstOrder.ringFunc.mul E0 #

FirstOrder.ringFunc 2

ctor FirstOrder.ringFunc.neg E0 #

FirstOrder.ringFunc 1

ctor FirstOrder.ringFunc.zero E0 #

FirstOrder.ringFunc 0

ctor FirstOrder.ringFunc.one E0 #

FirstOrder.ringFunc 0

def FirstOrder.instDecidableEqRingFunc.decEq E1 #

{a : ℕ} → (x x_1 : FirstOrder.ringFunc a) → Decidable (x = x_1)

instance FirstOrder.instDecidableEqRingFunc E0 #

{a : ℕ} → DecidableEq (FirstOrder.ringFunc a)

def FirstOrder.Language.ring E3 #

FirstOrder.Language

The language of rings contains the operations (+,*,-,0,1)

instance FirstOrder.Language.instIsAlgebraicRing E0 #

FirstOrder.Language.ring.IsAlgebraic

abbrev FirstOrder.Ring.addFunc E1 #

FirstOrder.Language.ring.Functions 2

RingFunc.add, but with the defeq type Language.ring.Functions 2 instead of RingFunc 2

abbrev FirstOrder.Ring.mulFunc E1 #

FirstOrder.Language.ring.Functions 2

RingFunc.mul, but with the defeq type Language.ring.Functions 2 instead of RingFunc 2

abbrev FirstOrder.Ring.negFunc E1 #

FirstOrder.Language.ring.Functions 1

RingFunc.neg, but with the defeq type Language.ring.Functions 1 instead of RingFunc 1

abbrev FirstOrder.Ring.zeroFunc E1 #

FirstOrder.Language.ring.Functions 0

RingFunc.zero, but with the defeq type Language.ring.Functions 0 instead of RingFunc 0

abbrev FirstOrder.Ring.oneFunc E1 #

FirstOrder.Language.ring.Functions 0

RingFunc.one, but with the defeq type Language.ring.Functions 0 instead of RingFunc 0

instance FirstOrder.Ring.instZeroTermRing E0 #

(α : Type u_2) → Zero (FirstOrder.Language.ring.Term α)

theorem FirstOrder.Ring.zero_def E0 #

∀ (α : Type u_2), 0 = FirstOrder.Language.Constants.term FirstOrder.Ring.zeroFunc

instance FirstOrder.Ring.instOneTermRing E0 #

(α : Type u_2) → One (FirstOrder.Language.ring.Term α)

theorem FirstOrder.Ring.one_def E0 #

∀ (α : Type u_2), 1 = FirstOrder.Language.Constants.term FirstOrder.Ring.oneFunc

instance FirstOrder.Ring.instAddTermRing E0 #

(α : Type u_2) → Add (FirstOrder.Language.ring.Term α)

theorem FirstOrder.Ring.add_def E0 #

∀ (α : Type u_2) (t₁ t₂ : FirstOrder.Language.ring.Term α), t₁ + t₂ = FirstOrder.Ring.addFunc.apply₂ t₁ t₂

instance FirstOrder.Ring.instMulTermRing E0 #

(α : Type u_2) → Mul (FirstOrder.Language.ring.Term α)

theorem FirstOrder.Ring.mul_def E0 #

∀ (α : Type u_2) (t₁ t₂ : FirstOrder.Language.ring.Term α), t₁ * t₂ = FirstOrder.Ring.mulFunc.apply₂ t₁ t₂

instance FirstOrder.Ring.instNegTermRing E0 #

(α : Type u_2) → Neg (FirstOrder.Language.ring.Term α)

theorem FirstOrder.Ring.neg_def E0 #

∀ (α : Type u_2) (t : FirstOrder.Language.ring.Term α), -t = FirstOrder.Ring.negFunc.apply₁ t

instance FirstOrder.Ring.instFintypeSymbolsRing E0 #

Fintype FirstOrder.Language.ring.Symbols

theorem FirstOrder.Ring.card_ring E0 #

FirstOrder.Language.ring.card = 5

class FirstOrder.Ring.CompatibleRing E3 #

(R : Type u_2) → [Add R] → [Mul R] → [Neg R] → [One R] → [Zero R] → Type u_2

A Type R is a CompatibleRing if it is a structure for the language of rings and this structure is the same as the structure already given on R by the classes Add, Mul etc.

It is recommended to use this type class as a hypothesis to any theorem whose statement requires a type to have be both a Ring (or Field etc.) and a Language.ring.Structure

instance FirstOrder.Ring.CompatibleRing.toStructure E0 #

{R : Type u_2} →
  {inst : Add R} →
    {inst_1 : Mul R} →
      {inst_2 : Neg R} →
        {inst_3 : One R} →
          {inst_4 : Zero R} → [self : FirstOrder.Ring.CompatibleRing R] → FirstOrder.Language.ring.Structure R

ctor FirstOrder.Ring.CompatibleRing.mk E0 #

{R : Type u_2} →
  [inst : Add R] →
    [inst_1 : Mul R] →
      [inst_2 : Neg R] →
        [inst_3 : One R] →
          [inst_4 : Zero R] →
            [toStructure : FirstOrder.Language.ring.Structure R] →
              (∀ (x : Fin 2 → R), FirstOrder.Language.Structure.funMap FirstOrder.Ring.addFunc x = x 0 + x 1) →
                (∀ (x : Fin 2 → R), FirstOrder.Language.Structure.funMap FirstOrder.Ring.mulFunc x = x 0 * x 1) →
                  (∀ (x : Fin 1 → R), FirstOrder.Language.Structure.funMap FirstOrder.Ring.negFunc x = -x 0) →
                    (∀ (x : Fin 0 → R), FirstOrder.Language.Structure.funMap FirstOrder.Ring.zeroFunc x = 0) →
                      (∀ (x : Fin 0 → R), FirstOrder.Language.Structure.funMap FirstOrder.Ring.oneFunc x = 1) →
                        FirstOrder.Ring.CompatibleRing R

theorem FirstOrder.Ring.CompatibleRing.funMap_add E0 #

∀ {R : Type u_2} {inst : Add R} {inst_1 : Mul R} {inst_2 : Neg R} {inst_3 : One R} {inst_4 : Zero R}
  [self : FirstOrder.Ring.CompatibleRing R] (x : Fin 2 → R),
  FirstOrder.Language.Structure.funMap FirstOrder.Ring.addFunc x = x 0 + x 1

Addition in the Language.ring.Structure is the same as the addition given by the Add instance

theorem FirstOrder.Ring.CompatibleRing.funMap_mul E0 #

∀ {R : Type u_2} {inst : Add R} {inst_1 : Mul R} {inst_2 : Neg R} {inst_3 : One R} {inst_4 : Zero R}
  [self : FirstOrder.Ring.CompatibleRing R] (x : Fin 2 → R),
  FirstOrder.Language.Structure.funMap FirstOrder.Ring.mulFunc x = x 0 * x 1

Multiplication in the Language.ring.Structure is the same as the multiplication given by the Mul instance

theorem FirstOrder.Ring.CompatibleRing.funMap_neg E0 #

∀ {R : Type u_2} {inst : Add R} {inst_1 : Mul R} {inst_2 : Neg R} {inst_3 : One R} {inst_4 : Zero R}
  [self : FirstOrder.Ring.CompatibleRing R] (x : Fin 1 → R),
  FirstOrder.Language.Structure.funMap FirstOrder.Ring.negFunc x = -x 0

Negation in the Language.ring.Structure is the same as the negation given by the Neg instance

theorem FirstOrder.Ring.CompatibleRing.funMap_zero E0 #

∀ {R : Type u_2} {inst : Add R} {inst_1 : Mul R} {inst_2 : Neg R} {inst_3 : One R} {inst_4 : Zero R}
  [self : FirstOrder.Ring.CompatibleRing R] (x : Fin 0 → R),
  FirstOrder.Language.Structure.funMap FirstOrder.Ring.zeroFunc x = 0

The constant 0 in the Language.ring.Structure is the same as the constant given by the Zero instance

theorem FirstOrder.Ring.CompatibleRing.funMap_one E0 #

∀ {R : Type u_2} {inst : Add R} {inst_1 : Mul R} {inst_2 : Neg R} {inst_3 : One R} {inst_4 : Zero R}
  [self : FirstOrder.Ring.CompatibleRing R] (x : Fin 0 → R),
  FirstOrder.Language.Structure.funMap FirstOrder.Ring.oneFunc x = 1

The constant 1 in the Language.ring.Structure is the same as the constant given by the One instance

theorem FirstOrder.Ring.realize_add E0 #

∀ {α : Type u_1} {R : Type u_2} [inst : Add R] [inst_1 : Mul R] [inst_2 : Neg R] [inst_3 : One R] [inst_4 : Zero R]
  [inst_5 : FirstOrder.Ring.CompatibleRing R] (x y : FirstOrder.Language.ring.Term α) (v : α → R),
  FirstOrder.Language.Term.realize v (x + y) =
    FirstOrder.Language.Term.realize v x + FirstOrder.Language.Term.realize v y

theorem FirstOrder.Ring.realize_mul E0 #

∀ {α : Type u_1} {R : Type u_2} [inst : Add R] [inst_1 : Mul R] [inst_2 : Neg R] [inst_3 : One R] [inst_4 : Zero R]
  [inst_5 : FirstOrder.Ring.CompatibleRing R] (x y : FirstOrder.Language.ring.Term α) (v : α → R),
  FirstOrder.Language.Term.realize v (x * y) =
    FirstOrder.Language.Term.realize v x * FirstOrder.Language.Term.realize v y

theorem FirstOrder.Ring.realize_neg E0 #

∀ {α : Type u_1} {R : Type u_2} [inst : Add R] [inst_1 : Mul R] [inst_2 : Neg R] [inst_3 : One R] [inst_4 : Zero R]
  [inst_5 : FirstOrder.Ring.CompatibleRing R] (x : FirstOrder.Language.ring.Term α) (v : α → R),
  FirstOrder.Language.Term.realize v (-x) = -FirstOrder.Language.Term.realize v x

theorem FirstOrder.Ring.realize_zero E0 #

∀ {α : Type u_1} {R : Type u_2} [inst : Add R] [inst_1 : Mul R] [inst_2 : Neg R] [inst_3 : One R] [inst_4 : Zero R]
  [inst_5 : FirstOrder.Ring.CompatibleRing R] (v : α → R), FirstOrder.Language.Term.realize v 0 = 0

theorem FirstOrder.Ring.realize_one E0 #

∀ {α : Type u_1} {R : Type u_2} [inst : Add R] [inst_1 : Mul R] [inst_2 : Neg R] [inst_3 : One R] [inst_4 : Zero R]
  [inst_5 : FirstOrder.Ring.CompatibleRing R] (v : α → R), FirstOrder.Language.Term.realize v 1 = 1

def FirstOrder.Ring.compatibleRingOfRing E3 #

(R : Type u_2) →
  [inst : Add R] →
    [inst_1 : Mul R] → [inst_2 : Neg R] → [inst_3 : One R] → [inst_4 : Zero R] → FirstOrder.Ring.CompatibleRing R

Given a Type R with instances for each of the Ring operations, make a Language.ring.Structure R instance, along with a proof that the operations given by the Language.ring.Structure are the same as those given by the Add or Mul etc. instances.

This definition can be used when applying a theorem about the model theory of rings to a literal ring R, by writing let _ := compatibleRingOfRing R. After this, if, for example, R is a field, then Lean will be able to find the instance for Theory.field.Model R, and it will be possible to apply theorems about the model theory of fields.

This is a def and not an instance, because the path Ring => Language.ring.Structure => Ring cannot be made to commute by definition

def FirstOrder.Ring.languageEquivEquivRingEquiv E1 #

{R : Type u_2} →
  {S : Type u_3} →
    [inst : NonAssocRing R] →
      [inst_1 : NonAssocRing S] →
        [inst_2 : FirstOrder.Ring.CompatibleRing R] →
          [inst_3 : FirstOrder.Ring.CompatibleRing S] → FirstOrder.Language.ring.Equiv R S ≃ (R ≃+* S)

An isomorphism in the language of rings is a ring isomorphism

abbrev FirstOrder.Ring.addOfRingStructure E1 #

(R : Type u_2) → [FirstOrder.Language.ring.Structure R] → Add R

A def to put an Add instance on a type with a Language.ring.Structure instance.

To be used sparingly, usually only when defining a more useful definition like, [Language.ring.Structure K] -> [Theory.field.Model K] -> Field K

abbrev FirstOrder.Ring.mulOfRingStructure E1 #

(R : Type u_2) → [FirstOrder.Language.ring.Structure R] → Mul R

A def to put an Mul instance on a type with a Language.ring.Structure instance.

To be used sparingly, usually only when defining a more useful definition like, [Language.ring.Structure K] -> [Theory.field.Model K] -> Field K

abbrev FirstOrder.Ring.negOfRingStructure E1 #

(R : Type u_2) → [FirstOrder.Language.ring.Structure R] → Neg R

A def to put an Neg instance on a type with a Language.ring.Structure instance.

To be used sparingly, usually only when defining a more useful definition like, [Language.ring.Structure K] -> [Theory.field.Model K] -> Field K

abbrev FirstOrder.Ring.zeroOfRingStructure E1 #

(R : Type u_2) → [FirstOrder.Language.ring.Structure R] → Zero R

A def to put an Zero instance on a type with a Language.ring.Structure instance.

To be used sparingly, usually only when defining a more useful definition like, [Language.ring.Structure K] -> [Theory.field.Model K] -> Field K

abbrev FirstOrder.Ring.oneOfRingStructure E1 #

(R : Type u_2) → [FirstOrder.Language.ring.Structure R] → One R

A def to put an One instance on a type with a Language.ring.Structure instance.

To be used sparingly, usually only when defining a more useful definition like, [Language.ring.Structure K] -> [Theory.field.Model K] -> Field K

abbrev FirstOrder.Ring.compatibleRingOfRingStructure E1 #

(R : Type u_2) → [inst : FirstOrder.Language.ring.Structure R] → FirstOrder.Ring.CompatibleRing R

Given a Type R with a Language.ring.Structure R, the instance given by addOfRingStructure etc. are compatible with the Language.ring.Structure instance on R.

This definition is only to be used when addOfRingStructure, mulOfRingStructure etc are local instances.