|
| 1 | +import Mathlib.LinearAlgebra.BilinearForm.Basic |
| 2 | +import Mathlib.Algebra.BigOperators.Group.Finset.Basic |
| 3 | +import Mathlib.Algebra.Order.Ring.Defs |
| 4 | + |
| 5 | +/-! |
| 6 | +# Bilinear forms β algebraic core (field-generic) |
| 7 | +
|
| 8 | +A field-generic, fully computable algebraic core for symmetric |
| 9 | +positive-definite bilinear forms. This is the foundation upon which |
| 10 | +the Riemannian metric API (`Riemannian/Metric/`) is built when the |
| 11 | +field happens to be `β` and smoothness is required; on a computable |
| 12 | +field like `β`, the same operations evaluate to actual numbers. |
| 13 | +
|
| 14 | +## Design |
| 15 | +
|
| 16 | +This file deliberately avoids: |
| 17 | +- Continuous linear maps (which require topology + `RCLike`) |
| 18 | +- Smoothness / `ContMDiff` (which require `β` or `β`) |
| 19 | +- Any non-computable Mathlib infrastructure |
| 20 | +
|
| 21 | +What remains is pure linear algebra: a bilinear form is a |
| 22 | +`B : V ββ[π] V ββ[π] π`, with computable `inner`, `IsSymm`, and |
| 23 | +`IsPosDef` predicates. |
| 24 | +
|
| 25 | +## Reusability |
| 26 | +
|
| 27 | +The bilinear-form algebra layer is reusable across: |
| 28 | +- Riemannian metrics (when π = β, with smoothness added) |
| 29 | +- Hermitian forms (when π = β) |
| 30 | +- Quadratic forms in algebra |
| 31 | +- Positive-definite forms in optimization |
| 32 | +- Matrix calculus over arbitrary fields |
| 33 | +
|
| 34 | +**Ground truth**: standard linear algebra of bilinear forms. |
| 35 | +-/ |
| 36 | + |
| 37 | +namespace OpenGALib.BilinearForm |
| 38 | + |
| 39 | +/-- A bilinear form on `V` over field `π`: a linear map |
| 40 | +`V ββ[π] V ββ[π] π`. -/ |
| 41 | +abbrev Form (π : Type*) [Field π] |
| 42 | + (V : Type*) [AddCommGroup V] [Module π V] := |
| 43 | + V ββ[π] V ββ[π] π |
| 44 | + |
| 45 | +section Algebra |
| 46 | + |
| 47 | +variable {π : Type*} [Field π] |
| 48 | + {V : Type*} [AddCommGroup V] [Module π V] |
| 49 | + |
| 50 | +/-- The bilinear form is symmetric. -/ |
| 51 | +def IsSymm (B : Form π V) : Prop := |
| 52 | + β v w, B v w = B w v |
| 53 | + |
| 54 | +/-- The **inner product** $\langle v, w \rangle_B$ via a bilinear form. -/ |
| 55 | +def inner (B : Form π V) (v w : V) : π := |
| 56 | + B v w |
| 57 | + |
| 58 | +/-- Inner product unfolds to bilinear-form application. -/ |
| 59 | +@[simp] |
| 60 | +theorem inner_def (B : Form π V) (v w : V) : |
| 61 | + inner B v w = B v w := rfl |
| 62 | + |
| 63 | +/-! ## Algebra lemmas |
| 64 | +
|
| 65 | +These follow directly from `LinearMap` algebra. They form the field- |
| 66 | +generic version of the framework's `metricInner_*` lemmas. -/ |
| 67 | + |
| 68 | +/-- **Symmetry** (when the form is symmetric). -/ |
| 69 | +theorem inner_comm {B : Form π V} (hB : IsSymm B) (v w : V) : |
| 70 | + inner B v w = inner B w v := |
| 71 | + hB v w |
| 72 | + |
| 73 | +/-- **Additivity in left argument**. -/ |
| 74 | +theorem inner_add_left (B : Form π V) (vβ vβ w : V) : |
| 75 | + inner B (vβ + vβ) w = inner B vβ w + inner B vβ w := by |
| 76 | + simp [inner_def, map_add, LinearMap.add_apply] |
| 77 | + |
| 78 | +/-- **Additivity in right argument**. -/ |
| 79 | +theorem inner_add_right (B : Form π V) (v wβ wβ : V) : |
| 80 | + inner B v (wβ + wβ) = inner B v wβ + inner B v wβ := by |
| 81 | + simp [inner_def, map_add] |
| 82 | + |
| 83 | +/-- **Scalar mult in left argument**. -/ |
| 84 | +theorem inner_smul_left (B : Form π V) (c : π) (v w : V) : |
| 85 | + inner B (c β’ v) w = c * inner B v w := by |
| 86 | + simp [inner_def, LinearMap.smul_apply, smul_eq_mul] |
| 87 | + |
| 88 | +/-- **Scalar mult in right argument**. -/ |
| 89 | +theorem inner_smul_right (B : Form π V) (c : π) (v w : V) : |
| 90 | + inner B v (c β’ w) = c * inner B v w := by |
| 91 | + simp [inner_def, smul_eq_mul] |
| 92 | + |
| 93 | +/-- **Zero in left argument**. -/ |
| 94 | +@[simp] |
| 95 | +theorem inner_zero_left (B : Form π V) (w : V) : |
| 96 | + inner B 0 w = 0 := by |
| 97 | + simp [inner_def] |
| 98 | + |
| 99 | +/-- **Zero in right argument**. -/ |
| 100 | +@[simp] |
| 101 | +theorem inner_zero_right (B : Form π V) (v : V) : |
| 102 | + inner B v 0 = 0 := by |
| 103 | + simp [inner_def] |
| 104 | + |
| 105 | +/-- **Negation in left argument**. -/ |
| 106 | +@[simp] |
| 107 | +theorem inner_neg_left (B : Form π V) (v w : V) : |
| 108 | + inner B (-v) w = -inner B v w := by |
| 109 | + simp [inner_def, map_neg, LinearMap.neg_apply] |
| 110 | + |
| 111 | +/-- **Negation in right argument**. -/ |
| 112 | +@[simp] |
| 113 | +theorem inner_neg_right (B : Form π V) (v w : V) : |
| 114 | + inner B v (-w) = -inner B v w := by |
| 115 | + simp [inner_def, map_neg] |
| 116 | + |
| 117 | +/-- **Subtraction in left argument**. -/ |
| 118 | +@[simp] |
| 119 | +theorem inner_sub_left (B : Form π V) (vβ vβ w : V) : |
| 120 | + inner B (vβ - vβ) w = inner B vβ w - inner B vβ w := by |
| 121 | + rw [sub_eq_add_neg, inner_add_left, inner_neg_left, sub_eq_add_neg] |
| 122 | + |
| 123 | +/-- **Subtraction in right argument**. -/ |
| 124 | +@[simp] |
| 125 | +theorem inner_sub_right (B : Form π V) (v wβ wβ : V) : |
| 126 | + inner B v (wβ - wβ) = inner B v wβ - inner B v wβ := by |
| 127 | + rw [sub_eq_add_neg, inner_add_right, inner_neg_right, sub_eq_add_neg] |
| 128 | + |
| 129 | +end Algebra |
| 130 | + |
| 131 | +section Order |
| 132 | + |
| 133 | +variable {π : Type*} [Field π] [LinearOrder π] [IsStrictOrderedRing π] |
| 134 | + {V : Type*} [AddCommGroup V] [Module π V] |
| 135 | + |
| 136 | +/-- The bilinear form is positive-definite. -/ |
| 137 | +def IsPosDef (B : Form π V) : Prop := |
| 138 | + β v β 0, 0 < B v v |
| 139 | + |
| 140 | +omit [IsStrictOrderedRing π] in |
| 141 | +/-- **Positive-definite** (when the form is positive-definite). -/ |
| 142 | +theorem inner_self_pos {B : Form π V} (hB : IsPosDef B) (v : V) (hv : v β 0) : |
| 143 | + 0 < inner B v v := |
| 144 | + hB v hv |
| 145 | + |
| 146 | +omit [IsStrictOrderedRing π] in |
| 147 | +/-- **Self-inner non-negativity** (when positive-definite). -/ |
| 148 | +theorem inner_self_nonneg {B : Form π V} (hB : IsPosDef B) (v : V) : |
| 149 | + 0 β€ inner B v v := by |
| 150 | + rcases eq_or_ne v 0 with hv | hv |
| 151 | + Β· rw [hv, inner_zero_left] |
| 152 | + Β· exact le_of_lt (inner_self_pos hB v hv) |
| 153 | + |
| 154 | +end Order |
| 155 | + |
| 156 | +end OpenGALib.BilinearForm |
0 commit comments