Eine aufbereitete Darstellung der Quelle

 
     
 
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung


Quelle  FreeRing.lean   Sprache: Lean

 

/-
Copyright (c) 2019 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Johan Commelin
-/

module

public import Mathlib.Algebra.MonoidAlgebra.Basic

/-!
# Free rings

The theory of the free ring over a type.

## Main definitions

* `FreeRing α` : the free (not commutative in general) ring over a type.
* `lift (f : α → R)` : the ring hom `FreeRing α →+* R` induced by `f`.
* `map (f : α → β)` : the ring hom `FreeRing α →+* FreeRing β` induced by `f`.

## Implementation details

`FreeRing α` is implemented as the `ℤ` monoid algebra over the free monoid on `α`.

## Tags

free ring
-/


@[expose] public noncomputable section


universe u v

/--
If `α` is a type, then `FreeRing α` is the free ring generated by `α`.
This is a ring equipped with a function `FreeRing.of : α → FreeRing α` which has
the following universal property: if `R` is any ring, and `f : α → R` is any function,
then this function is the composite of `FreeRing.of` and a unique ring homomorphism
`FreeRing.lift f : FreeRing α →+* R`.

A typical element of `FreeRing α` is a `ℤ`-linear combination of
formal products of elements of `α`.
For example if `x` and `y` are terms of type `α` then `3 * x * y * x - 2 * y * x + 1` is a
"typical" element of `FreeRing α`. In particular if `α` is empty
then `FreeRing α` is isomorphic to `ℤ`, and if `α` has one term `t`
then `FreeRing α` is isomorphic to the polynomial ring `ℤ[t]`.
If `α` has two or more terms then `FreeRing α` is not commutative.
One can think of `FreeRing α` as the free non-commutative polynomial ring
with coefficients in the integers and variables indexed by `α`.
-/

def FreeRing (α : Type u) : Type u :=
  MonoidAlgebra ℤ <| FreeMonoid α
deriving Ring, Inhabited, Nontrivial

namespace FreeRing

variable {α : Type u}

/-- The canonical map from α to `FreeRing α`. -/
def of (x : α) : FreeRing α :=
  MonoidAlgebra.single (FreeMonoid.of x) 1

theorem of_injective : Function.Injective (of : α → FreeRing α) :=
  MonoidAlgebra.of_injective.comp FreeMonoid.of_injective

@[simp]
theorem of_ne_zero (x : α) : of x ≠ 0 := MonoidAlgebra.single_ne_zero.2 Int.one_ne_zero

@[simp]
theorem zero_ne_of (x : α) : 0 ≠ of x := (of_ne_zero x).symm

@[simp]
theorem of_ne_one (x : α) : of x ≠ 1 := MonoidAlgebra.of_injective.ne <| FreeMonoid.of_ne_one _

@[simp]
theorem one_ne_of (x : α) : 1 ≠ of x := MonoidAlgebra.of_injective.ne <| FreeMonoid.one_ne_of _

@[elab_as_elim, induction_eliminator]
protected theorem induction_on {motive : FreeRing α → Prop} (z : FreeRing α) (neg_one : motive (-1))
    (of : ∀ b, motive (of b)) (add : ∀ x y, motive x → motive y → motive (x + y))
    (mul : ∀ x y, motive x → motive y → motive (x * y)) :
    motive z :=
  have neg (x : FreeRing α) (hx : motive x) : motive (-x) := by simpa using mul (-1) x neg_one hx
  have one : motive 1 := by simpa using neg (-1) neg_one
  have nsmul (n : ℕ) (x : FreeRing α) (hx : motive x) : motive (n • x) := by
    induction n with
    | zero => simpa using add (-1) 1 neg_one one
    | succ n ih => rw [succ_nsmul]; exact add (n • x) x ih hx
  have zsmul (n : ℤ) (x : FreeRing α) (hx : motive x) : motive (n • x) := by
    induction n using Int.negInduction with
    | nat n => rw [natCast_zsmul]; simpa using nsmul n x hx
    | neg ih n => rw [neg_zsmul]; exact neg _ (ih n)
  have fmof (x : FreeMonoid α) : motive (MonoidAlgebra.of ℤ _ x) :=
    FreeMonoid.inductionOn x one of (fun x y hx hy => by rw [map_mul]; exact mul _ _ hx hy)
  MonoidAlgebra.induction_on z fmof add zsmul

section lift

variable {R : Type v} [Ring R] (f : α → R)

/-- The ring homomorphism `FreeRing α →+* R` induced from a map `α → R`. -/
def lift : (α → R) ≃ (FreeRing α →+* R) :=
  (FreeMonoid.lift.trans (MonoidAlgebra.lift ℤ R _)).trans (RingHom.equivIntAlgHom _ _).symm

@[simp]
theorem lift_of (x : α) : lift f (of x) = f x :=
  congr($(lift.left_inv f) x)

@[simp]
theorem lift_comp_of (f : FreeRing α →+* R) : lift (f ∘ of) = f :=
  lift.right_inv f

@[ext]
theorem hom_ext ⦃f g : FreeRing α →+* R⦄ (h : ∀ x, f (of x) = g (of x)) : f = g :=
  lift.symm.injective (funext h)

end lift

variable {β : Type v} (f : α → β)

/-- The canonical ring homomorphism `FreeRing α →+* FreeRing β` generated by a map `α → β`. -/
def map : FreeRing α →+* FreeRing β :=
  lift <| of ∘ f

@[simp]
theorem map_of (x : α) : map f (of x) = of (f x) :=
  lift_of _ _

end FreeRing

Messung
CHZG
9310010097

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet am  2026-11-24) ¤

*© Formatika GbR, Deutschland







                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Gedichte
Musik
Bilder

Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1,188,109
#Domains=863,032