Physlib

Physlib.Units.ParametricDimensionExamples

Examples: parametric dimensions and comparing dimensioned quantities

`Dimension B` is parameterised by a basis `B` of base dimensions. This module illustrates two consequences.

Comparing a length with a velocity times a time

A recurring question is how to compare a quantity of dimension `length` with a product of a quantity of dimension `length / time` and a quantity of dimension `time`. The two dimensions are *equal*, but this equality is a **group cancellation law** on the rational exponents — it holds *propositionally*, never *definitionally*:

* `(L𝓭 / T𝓭) * T𝓭 = L𝓭` cannot be closed by `rfl`: cancellation is not a reduction rule. * nor by `decide`: the exponents are rational, so the kernel has nothing to evaluate.

Consequently `WithDim ((L𝓭 / T𝓭) * T𝓭) ℝ` and `WithDim L𝓭 ℝ` are genuinely different types, and a bare `x = v * t` is a type error. The bridge is `WithDim.cast`, whose default argument discharges the propositional dimension equality automatically, so the comparison is a one-liner. This is not a limitation of the representation: no representation of `Dimension` makes the equality definitional, so a cast on a proven equality is the correct idiom.

A non-standard basis

Because `Dimension` is parametric, the same dimensional algebra and the same `cast`-based comparison are available over *any* basis — not just the physical `LTMCTDimensionBase`. The unit-scaling layer (`LTMCTUnitChoices`, `dimScale`) is not needed for either the algebra or the comparison, so neither is referenced here.

This module is illustrative and should not be imported by other modules.

The same comparison over a non-standard basis

A basis with two base dimensions of its own — `bit` and `symbol` — that `LTMCTDimensionBase` does not have. Nothing in the standard units system is involved.

4 declarations

inductive

Information-theoretic base dimensions Info\text{Info}

The inductive type `Info` defines a basis for information-theoretic dimensions. It serves as a set of base dimensions for a dimensional analysis system, specifically containing constructors for the base dimensions of a "bit" and a "symbol".

definition

The bit dimension in the Info\text{Info} basis

The dimension bitDim\text{bitDim} is an element of the dimension space over the information-theoretic basis Info={bit,symbol}\text{Info} = \{\text{bit}, \text{symbol}\}. It is defined by assigning an exponent of 11 to the "bit" base dimension and an exponent of 00 to the "symbol" base dimension.

definition

Base dimension of a symbol\text{symbol} in Info\text{Info}

The dimension representing a symbol\text{symbol} within the information-theoretic basis Info\text{Info}. It is defined by assigning an exponent of 11 to the symbol\text{symbol} base dimension and an exponent of 00 to the bit\text{bit} base dimension.

instance

Dimension basis for information-theoretic dimensions Info\text{Info}

The instance `instDimensionBasisInfo` establishes the type `Info` as a valid basis for a system of dimensions. This allows for the construction of dimensions based on the information-theoretic base units of a "bit" and a "symbol".