Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit 1dddcf6

Browse files
committed
doc(*): blurbs galore
Document all `def`, `class`, and `inductive` that are reasonably public-facing
1 parent 2ffd72c commit 1dddcf6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+2216
-970
lines changed

algebra/big_operators.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ variables {α : Type u} {β : Type v} {γ : Type w}
1414
namespace finset
1515
variables {s s₁ s₂ : finset α} {a : α} {f g : α → β}
1616

17+
/-- `prod s f` is the product of `f x` as `x` ranges over the elements of the finite set `s`. -/
1718
@[to_additive finset.sum]
1819
protected def prod [comm_monoid β] (s : finset α) (f : α → β) : β := (s.1.map f).prod
1920
attribute [to_additive finset.sum.equations._eqn_1] finset.prod.equations._eqn_1

algebra/group.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ end ordered_comm_group
325325

326326
variables {β : Type*} [group α] [group β] {a b : α}
327327

328+
/-- Predicate for group homomorphism. -/
328329
def is_group_hom (f : α → β) : Prop :=
329330
∀ a b : α, f (a * b) = f a * f b
330331

@@ -342,6 +343,8 @@ inv_eq_of_mul_eq_one $ by simp [(H a a⁻¹).symm, one H]
342343

343344
end is_group_hom
344345

346+
/-- Predicate for group anti-homomorphism, or a homomorphism
347+
into the opposite group. -/
345348
def is_group_anti_hom (f : α → β) : Prop :=
346349
∀ a b : α, f (a * b) = f b * f a
347350

algebra/group_power.lean

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ variable {α : Type u}
2121
@[simp] theorem inv_inv' [discrete_field α] {a:α} : a⁻¹⁻¹ = a :=
2222
by rw [inv_eq_one_div, inv_eq_one_div, div_div_eq_mul_div]; simp [div_one]
2323

24+
/-- The power operation in a monoid. `a^n = a*a*...*a` n times. -/
2425
def monoid.pow [monoid α] (a : α) : ℕ → α
2526
| 0 := 1
2627
| (n+1) := a * monoid.pow n
@@ -143,6 +144,10 @@ end nat
143144

144145
open int
145146

147+
/--
148+
The power operation in a group. This extends `monoid.pow` to negative integers
149+
with the definition `a^(-n) = (a^n)⁻¹`.
150+
-/
146151
@[simp] def gpow (a : α) : ℤ → α
147152
| (of_nat n) := a^n
148153
| -[1+n] := (a^(nat.succ n))⁻¹

algebra/linear_algebra/basic.lean

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ finset.smul_sum
6262

6363
end finsupp
6464

65+
/-- The type of linear coefficients, which are simply the finitely supported functions
66+
from the module `β` to the scalar ring `α`. -/
6567
@[reducible] def lc (α : Type u) (β : Type v) [ring α] [module α β] : Type (max u v) := β →₀ α
6668

6769
namespace lc
@@ -120,6 +122,7 @@ variables [ring α] [module α β] [module α γ] [module α δ]
120122
variables {a a' : α} {s t : set β} {b b' b₁ b₂ : β}
121123
include α
122124

125+
/-- Linear span of a set of vectors -/
123126
def span (s : set β) : set β := { x | ∃(v : lc α β), (∀x∉s, v x = 0) ∧ x = v.sum (λb a, a • b) }
124127

125128
@[instance] lemma is_submodule_span : is_submodule (span s) :=
@@ -213,6 +216,7 @@ lemma linear_eq_on {f g : β → γ} (hf : is_linear_map f) (hg : is_linear_map
213216
simp [this, h, hf.smul, hg.smul]
214217
end
215218

219+
/-- Linearly independent set of vectors -/
216220
def linear_independent (s : set β) : Prop :=
217221
∀l : lc α β, (∀x∉s, l x = 0) → l.sum (λv c, c • v) = 0 → l = 0
218222

@@ -432,6 +436,7 @@ lemma linear_independent.eq_0_of_span : ∀a∈span s, f a = 0 → a = 0
432436

433437
end
434438

439+
/-- A set of vectors is a basis if it is linearly independent and all vectors are in the span -/
435440
def is_basis (s : set β) := linear_independent s ∧ (∀x, x ∈ span s)
436441

437442
section is_basis

algebra/linear_algebra/linear_map_module.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ hpq _ $ some_spec _
2323

2424
end classical
2525

26+
/-- The type of linear maps `β → γ` between α-modules β and γ -/
2627
def linear_map {α : Type u} (β : Type v) (γ : Type w) [ring α] [module α β] [module α γ] :=
2728
subtype (@is_linear_map α β γ _ _ _)
2829

@@ -45,6 +46,7 @@ lemma is_linear_map_coe : is_linear_map A := A.property
4546

4647
/- kernel -/
4748

49+
/-- Kernel of a linear map, i.e. the set of vectors mapped to zero by the map -/
4850
def ker (A : linear_map β γ) : set β := {y | A y = 0}
4951

5052
section ker
@@ -71,6 +73,7 @@ end ker
7173

7274
/- image -/
7375

76+
/-- Image of a linear map, the set of vectors of the form `A x` for some β -/
7477
def im (A : linear_map β γ) : set γ := {x | ∃ y, A y = x}
7578

7679
@[simp] lemma mem_im {A : linear_map β γ} {z : γ} :
@@ -222,6 +225,7 @@ def endomorphism_ring : ring (linear_map β β) :=
222225
by refine {mul := (*), one := 1, ..linear_map.add_comm_group, ..};
223226
{ intros, apply linear_map.ext, simp }
224227

228+
/-- The group of invertible linear maps from `β` to itself -/
225229
def general_linear_group :=
226230
@units (linear_map β β) (@ring.to_semiring _ (endomorphism_ring α β))
227231

algebra/linear_algebra/multivariate_polynomial.lean

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ instance {α : Type u} [semilattice_sup α] : is_idempotent α (⊔) := ⟨assum
2020
namespace finset
2121
variables [semilattice_sup_bot α]
2222

23+
/-- Supremum of a finite set: `sup {a, b, c} f = f a ⊔ f b ⊔ f c` -/
2324
def sup (s : finset β) (f : β → α) : α := s.fold (⊔) ⊥ f
2425

2526
variables {s s₁ s₂ : finset β} {f : β → α}
@@ -91,6 +92,8 @@ have ∀(s : finset α) (f : α →₀ β), s = f.support → p f,
9192
end),
9293
this _ _ rfl
9394

95+
/-- Multivariate polynomial, where `σ` is the index set of the variables and
96+
`α` is the coefficient ring -/
9497
def mv_polynomial (σ : Type*) (α : Type*) [comm_semiring α] := (σ →₀ ℕ) →₀ α
9598

9699
namespace mv_polynomial
@@ -105,10 +108,13 @@ instance : has_add (mv_polynomial σ α) := finsupp.has_add
105108
instance : has_mul (mv_polynomial σ α) := finsupp.has_mul
106109
instance : comm_semiring (mv_polynomial σ α) := finsupp.to_comm_semiring
107110

111+
/-- monomial s a is the monomial `a * X^s` -/
108112
def monomial (s : σ →₀ ℕ) (a : α) : mv_polynomial σ α := single s a
109113

114+
/-- C a is the constant polynomial with value a -/
110115
def C (a : α) : mv_polynomial σ α := monomial 0 a
111116

117+
/-- X n is the polynomial with value X_n -/
112118
def X (n : σ) : mv_polynomial σ α := monomial (single n 1) 1
113119

114120
@[simp] lemma C_0 : C 0 = (0 : mv_polynomial σ α) := by simp [C, monomial]; refl
@@ -165,6 +171,7 @@ finsupp.single_induction_on p
165171
section eval
166172
variables {f : σ → α}
167173

174+
/-- Evaluate a polynomial `p` given a valuation `f` of all the variables -/
168175
def eval (p : mv_polynomial σ α) (f : σ → α) : α :=
169176
p.sum (λs a, a * s.prod (λn e, f n ^ e))
170177

@@ -209,6 +216,7 @@ end eval
209216

210217
section vars
211218

219+
/-- `vars p` is the set of variables appearing in the polynomial `p` -/
212220
def vars (p : mv_polynomial σ α) : finset σ := p.support.bind finsupp.support
213221

214222
@[simp] lemma vars_0 : (0 : mv_polynomial σ α).vars = ∅ :=
@@ -230,11 +238,13 @@ calc (X n : mv_polynomial σ α).vars = (single n 1).support : vars_monomial h.s
230238
end vars
231239

232240
section degree_of
241+
/-- `degree_of n p` gives the highest power of X_n that appears in `p` -/
233242
def degree_of (n : σ) (p : mv_polynomial σ α) : ℕ := p.support.sup (λs, s n)
234243

235244
end degree_of
236245

237246
section total_degree
247+
/-- `total_degree p` gives the maximum |s| over the monomials X^s in `p` -/
238248
def total_degree (p : mv_polynomial σ α) : ℕ := p.support.sup (λs, s.sum $ λn e, e)
239249

240250
end total_degree

algebra/linear_algebra/quotient_module.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ lemma quotient_rel_eq {b₁ b₂ : β} : (b₁ ≈ b₂) = (b₁ - b₂ ∈ s) :
3333

3434
section
3535
variable (β)
36+
/-- Quotient module. `quotient β s` is the quotient of the module `β` by the submodule `s`. -/
3637
def quotient : Type v := quotient (quotient_rel s)
3738
end
3839

algebra/module.lean

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@ variables {α : Type u} {β : Type v} {γ : Type w} {δ : Type x}
1515
lemma set.sInter_eq_Inter {s : set (set α)} : (⋂₀ s) = (⋂i ∈ s, i) :=
1616
set.ext $ by simp
1717

18+
/-- Typeclass for types with a scalar multiplication operation, denoted `•` (`\bu`) -/
1819
class has_scalar (α : out_param $ Type u) (γ : Type v) := (smul : α → γ → γ)
1920

2021
infixr ` • `:73 := has_scalar.smul
2122

23+
/-- A module is a generalization of vector spaces to a scalar ring.
24+
It consists of a scalar ring `α` and an additive group of "vectors" `β`,
25+
connected by a "scalar multiplication" operation `r • x : β`
26+
(where `r : α` and `x : β`) with some natural associativity and
27+
distributivity axioms similar to those on a ring. -/
2228
class module (α : out_param $ Type u) (β : Type v) [out_param $ ring α]
2329
extends has_scalar α β, add_comm_group β :=
2430
(smul_add : ∀r (x y : β), r • (x + y) = r • x + r • y)
@@ -143,6 +149,9 @@ by refine {..}; simp [hf.add, hf.smul, add_smul, smul_smul]
143149

144150
end is_linear_map
145151

152+
/-- A submodule of a module is one which is closed under vector operations.
153+
This is a sufficient condition for the subset of vectors in the submodule
154+
to themselves form a module. -/
146155
class is_submodule {α : Type u} {β : Type v} [ring α] [module α β] (p : set β) : Prop :=
147156
(zero_ : (0:β) ∈ p)
148157
(add_ : ∀ {x y}, x ∈ p → y ∈ p → x + y ∈ p)
@@ -221,8 +230,14 @@ end
221230

222231
end is_submodule
223232

233+
/-- A vector space is the same as a module, except the scalar ring is actually
234+
a field. (This adds commutativity of the multiplication and existence of inverses.)
235+
This is the traditional generalization of spaces like `ℝ^n`, which have a natural
236+
addition operation and a way to multiply them by real numbers, but no multiplication
237+
operation between vectors. -/
224238
class vector_space (α : out_param $ Type u) (β : Type v) [field α] extends module α β
225239

240+
/-- Subspace of a vector space. Defined to equal `is_submodule`. -/
226241
@[reducible] def subspace {α : Type u} {β : Type v} [field α] [vector_space α β] (p : set β) :
227242
Prop :=
228243
is_submodule p

algebra/order.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ le_antisymm ((H _).2 (le_refl _)) ((H _).1 (le_refl _))
7575

7676
namespace ordering
7777

78+
/-- `compares o a b` means that `a` and `b` have the ordering relation
79+
`o` between them, assuming that the relation `a < b` is defined -/
7880
@[simp] def compares [has_lt α] : ordering → α → α → Prop
7981
| lt a b := a < b
8082
| eq a b := a = b

algebra/ordered_group.lean

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@ section old_structure_cmd
1414

1515
set_option old_structure_cmd true
1616

17+
/-- An ordered (additive) commutative monoid is a commutative monoid
18+
with a partial order such that addition is an order embedding, i.e.
19+
`a + b ≤ a + c ↔ b ≤ c`. These monoids are automatically cancellative. -/
1720
class ordered_comm_monoid (α : Type*) extends add_comm_monoid α, partial_order α :=
1821
(add_le_add_left : ∀ a b : α, a ≤ b → ∀ c : α, c + a ≤ c + b)
1922
(lt_of_add_lt_add_left : ∀ a b c : α, a + b < a + c → b < c)
2023

24+
/-- A canonically ordered monoid is an ordered commutative monoid
25+
in which the ordering coincides with the divisibility relation,
26+
which is to say, `a ≤ b` iff there exists `c` with `b = a + c`.
27+
This is satisfied by the natural numbers, for example, but not
28+
the integers or other ordered groups. -/
2129
class canonically_ordered_monoid (α : Type*) extends ordered_comm_monoid α :=
2230
(le_iff_exists_add : ∀a b:α, a ≤ b ↔ ∃c, b = a + c)
2331

@@ -335,9 +343,9 @@ sub_left_lt_iff_lt_add.trans (lt_add_iff_pos_left _)
335343

336344
end ordered_comm_group
337345

338-
-- This is not so much a new structure as a construction mechanism
339-
-- for ordered groups
340346
set_option old_structure_cmd true
347+
/-- This is not so much a new structure as a construction mechanism
348+
for ordered groups, by specifying only the "positive cone" of the group. -/
341349
class nonneg_comm_group (α : Type*) extends add_comm_group α :=
342350
(nonneg : α → Prop)
343351
(pos : α → Prop := λ a, nonneg a ∧ ¬ nonneg (neg a))

0 commit comments

Comments
 (0)