14.1. Functions on quantities
-
PropertyKindCalculus.MathCarrier[complete]
\mathrm{MathCarrier}\ R is the function operation surface a kind-indexed magnitude
needs — \exp, \log, \sin, \cos, the hyperbolic functions, \sqrt{\,},
|\cdot|, and the constant \pi — supplied once per representation type R. It is the
function-layer analogue of the numeric carrier Carrier, and is by construction the
same surface as the underlying tensor toolchain's elementary functions, so every carrier
that supports them — \mathbb{R}, Float, the binary32 carriers — is a clean
\mathrm{MathCarrier}.
Lean code for Definition14.1.1●1 definition
Associated Lean declarations
-
PropertyKindCalculus.MathCarrier[complete]
-
PropertyKindCalculus.MathCarrier[complete]
-
classdefined in PropertyKindCalculus/QuantityFunction.leancomplete
class PropertyKindCalculus.MathCarrier (R : Type) : Type
class PropertyKindCalculus.MathCarrier (R : Type) : Type
**The function operation surface.** The transcendental and root operations a kind-indexed magnitude needs, supplied once per representation type `R`. This is the function-layer analogue of `Carrier`, and is deliberately the *same* surface as TorchLean's `MathFunctions α`, so any carrier supporting `MathFunctions` (`ℝ`, `Float`, binary32) instantiates it cleanly.
Methods
exp : R → R
Natural exponential.
log : R → R
Natural logarithm.
sin : R → R
Sine.
cos : R → R
Cosine.
sinh : R → R
Hyperbolic sine.
cosh : R → R
Hyperbolic cosine.
tanh : R → R
Hyperbolic tangent.
sqrt : R → R
Square root.
abs : R → R
Absolute value.
pi : R
The constant `π`.
Realized as the MathCarrier class. The richer surface (\tan, the inverse trig,
\operatorname{atan2}, cube root, rounding, rational power) is split off into
MathCarrierExt, so the executable binary32 carrier — whose function vocabulary is
deliberately smaller — is a MathCarrier without being a MathCarrierExt. The algebraic
identities (\sin^2+\cos^2=1, \exp(a+b)=\exp a\cdot\exp b) live in
LawfulMathCarrier, which holds at \mathbb{R} and fails in floating point — the same
exec/spec gap the lawful numeric carrier draws for +. The Float
instance is computable (the run carrier); the \mathbb{R} instance is the noncomputable
proof carrier in the PhysLib-backed Dimension layer.
-
PropertyKindCalculus.PowerKind[complete]
\mathrm{PowerKind}\ p\ k_1\ k records that raising a k_1-quantity to the rational
power p yields a k-quantity (k = k_1^{\,p}). In the core it carries only the
ratio-scale gate (Dybkær §13.3.5 — only ratio quantities have powers); the
dimension layer strengthens it to the exponent-scaling certificate
\dim k = (\dim k_1)^{p}. This is the one function family that is not
dimension-one-in-out — the dimension-scaling extension of multiplication and division.
Lean code for Definition14.1.2●1 definition
Associated Lean declarations
-
PropertyKindCalculus.PowerKind[complete]
-
PropertyKindCalculus.PowerKind[complete]
-
structuredefined in PropertyKindCalculus/QuantityFunction.leancomplete
structure PropertyKindCalculus.PowerKind (p : ℚ) (k₁ k : PropertyKindCalculus.KindOfProperty) : Prop
structure PropertyKindCalculus.PowerKind (p : ℚ) (k₁ k : PropertyKindCalculus.KindOfProperty) : Prop
**A kind-level power law.** `k` is the `p`-th power kind of `k₁` (`k = k₁^p`): both ratio-scale. The `Dimension` layer strengthens this with `k.dim = (k₁.dim)^p`.
Fields
ratio₁ : k₁.IsRational
The base is ratio-scale.
ratioPow : k.IsRational
The power is ratio-scale.
Realized as the PowerKind structure (two ratio-scale fields), with the smart constructors
Quantity.sqrt (the half-power), Quantity.cbrt, and
Quantity.rpow. The exponent-scaling refinement is DimPowerKind, well-defined because
PhysLib's Dimension carries \mathbb{Q} exponents (Pow Dimension ℚ), making a
half-power a genuine group element.
-
PropertyKindCalculus.Quantity.sqrt[complete]
\mathrm{Quantity.sqrt} is the verified half-power, the canonical
PowerKind (1/2) smart constructor: \sqrt{\,} of a k_1
yields a k, its magnitude \sqrt{a} taken in the carrier. It rides on the base
MathCarrier (not the extended surface), so it runs even on the
binary32 executable carrier.
Lean code for Definition14.1.3●1 definition
Associated Lean declarations
-
PropertyKindCalculus.Quantity.sqrt[complete]
-
PropertyKindCalculus.Quantity.sqrt[complete]
-
defdefined in PropertyKindCalculus/QuantityFunction.leancomplete
def PropertyKindCalculus.Quantity.sqrt {k₁ k : PropertyKindCalculus.KindOfProperty} {R : Type} [PropertyKindCalculus.MathCarrier R] (_h : PropertyKindCalculus.PowerKind (1 / 2) k₁ k) (a : PropertyKindCalculus.Quantity k₁ R) : PropertyKindCalculus.Quantity k R
def PropertyKindCalculus.Quantity.sqrt {k₁ k : PropertyKindCalculus.KindOfProperty} {R : Type} [PropertyKindCalculus.MathCarrier R] (_h : PropertyKindCalculus.PowerKind (1 / 2) k₁ k) (a : PropertyKindCalculus.Quantity k₁ R) : PropertyKindCalculus.Quantity k R
**Square root** — the half-power, available from the base `MathCarrier` (so it runs even on the binary32 exec carrier). `sqrt` of an area is a length.
Realized as Quantity.sqrt, taking a PowerKind (1/2) k₁ k and returning
⟨\mathrm{MathCarrier.sqrt}\ a.\mathrm{magnitude}⟩; the projection
sqrt_magnitude is rfl, so an erased computation is exactly the carrier's
\sqrt{\,}.
-
PropertyKindCalculus.sqrt_area_coherent[complete]
The square root of an area is a length — checked, not annotated. The half-power of the
area dimension \mathrm{L}^2 is the length dimension \mathrm{L}:
\dim(\sqrt{\mathrm{area}}) = (\dim \mathrm{area})^{1/2} = \mathrm{L}.
The certificate Quantity.sqrt carries, here discharged in the
PhysLib Dimension group. Builds on the power law.
Lean code for Theorem14.1.4●1 theorem
Associated Lean declarations
-
PropertyKindCalculus.sqrt_area_coherent[complete]
-
PropertyKindCalculus.sqrt_area_coherent[complete]
-
theoremdefined in PropertyKindCalculus/Function.leancomplete
theorem PropertyKindCalculus.sqrt_area_coherent : PropertyKindCalculus.DimPowerKind (1 / 2) PropertyKindCalculus.areaK PropertyKindCalculus.lengthKind
theorem PropertyKindCalculus.sqrt_area_coherent : PropertyKindCalculus.DimPowerKind (1 / 2) PropertyKindCalculus.areaK PropertyKindCalculus.lengthKind
**`sqrt` of an area is a length — checked, not annotated.** The half-power of the area dimension `L²` is the length dimension `L`: `dim(√area) = (dim area)^(1/2) = L`. This is the certificate the core `Quantity.sqrt` carries, here discharged in the `Dimension` group.
Proved in the Function module: areaK is declared with dimension \mathrm{L}^2 and the
goal lengthKind.dim = areaK.dim ^ (1/2 : ℚ) is closed component-wise by norm_num over
the rational exponents of the Dimension group.
-
PropertyKindCalculus.TranscendentalKind[complete]
\mathrm{TranscendentalKind}\ k_1\ k licenses the smart constructors
for \exp, \log, the hyperbolic and trigonometric
functions. The core records the ratio-scale gate; the dimension layer
strengthens it to "argument and result are dimension one" (Families C), and — for the
trigonometric functions — to a curated algebra (the unary analogue of
the interaction algebra) that keeps \sin on plane angles only. That a
plane angle is dimension one yet a distinct kind is exactly why \sin of an angle is
fine while \sin of a reflectivity is the category error a dimension-only system cannot
forbid.
Lean code for Definition14.1.5●1 definition
Associated Lean declarations
-
PropertyKindCalculus.TranscendentalKind[complete]
-
PropertyKindCalculus.TranscendentalKind[complete]
-
structuredefined in PropertyKindCalculus/QuantityFunction.leancomplete
structure PropertyKindCalculus.TranscendentalKind (k₁ k : PropertyKindCalculus.KindOfProperty) : Prop
structure PropertyKindCalculus.TranscendentalKind (k₁ k : PropertyKindCalculus.KindOfProperty) : Prop
**A kind-level transcendental law.** Applying a transcendental to `k₁` yields `k`; both ratio-scale. The `Dimension` layer strengthens this to `dim k₁ = dim k = 1` and, for the trigonometric functions, curates exactly which `(k₁, k)` edges are sanctioned.
Fields
ratio₁ : k₁.IsRational
The argument kind is ratio-scale.
ratioResult : k.IsRational
The result kind is ratio-scale.
Realized as TranscendentalKind with the constructors Quantity.exp / log / sin /
cos / tanh (base surface) and tan / asin / acos / atan / atan2 (extended
surface). The dimensional strengthening is DimTranscendental (tanh_lossTangent_coherent
is the worked edge: the conductive-loss \tanh argument is dimensionless and so is its
value), and the trigonometric curation is the Dimension-layer trig algebra.