Examples of units in PhysLean #
In this module we give some examples of how to use the units system in PhysLean. This module should not be imported into any other module, and the results here should not be used in the proofs of any other results other then those in this file.
Defining a length dependent on units #
The length corresponding to 400 meters.
Equations
- UnitExamples.meters400 = (CarriesDimension.toDimensionful UnitChoices.SI) { val := 400 }
Instances For
Proving propositions are dimensionally correct #
Cases with only WithDim #
An example of dimensions corresponding to E = m c^2
using WithDim
.
Equations
- UnitExamples.EnergyMassWithDim' m E c = (E = (m * c * c).cast UnitExamples.EnergyMassWithDim'._proof_1)
Instances For
An example of dimensions corresponding to F = m a
using WithDim
.
Equations
- UnitExamples.NewtonsSecondWithDim' m F a = (F = (m * a).cast UnitExamples.NewtonsSecondWithDim'._proof_1)
Instances For
An example of dimensions corresponding to s = d/t
using WithDim
.
Equations
- UnitExamples.SpeedEq s d t = (s = (d / t).cast UnitExamples.SpeedEq._proof_1)
Instances For
An example with complicated dimensions.
Equations
Instances For
An example of dimensions corresponding to E = m c^2
using WithDim
with .val
.
Instances For
An example of dimensions corresponding to F = m a
using WithDim
with .val
.
Instances For
An example of dimensions corresponding to E = m c
using WithDim
with .val
,
which is not dimensionally correct.
Instances For
Cases with Dimensionful #
The equation E = m c^2
, in this equation we E
and m
are implicitly in the
units u
, while the speed of light is explicitly written in those units.
Equations
- UnitExamples.EnergyMass m E u = (E.val = m.val * (↑DimSpeed.speedOfLight u).val ^ 2)
Instances For
The equation E = m c^2
, in this version everything is written explicitly in
terms of a choice of units.
Equations
- UnitExamples.EnergyMass' m E u = ((↑E u).val = (↑m u).val * (↑DimSpeed.speedOfLight u).val ^ 2)
Instances For
The lemma that the proposition EnergyMass
is dimensionally correct
Examples of using isDimensionallyCorrect
#
We now explore the consequences of energyMass_isDimensionallyCorrect
and how we can use it.
## Examples with other functions
An example of a dimensionafully correct result using functions.
Instances For
## An example involving derivatives