Documentation

LeanUnits.Framework.Conversions.Basic

Affine conversion between units.

āš ļø Warning : Affine composition works when offset is zero or factor is 1 ie : abbrev Affinable (c1 c2 : Conversion) : Prop := (c1.factor = 1 ∧ c2.factor = 1) ∨ (c1.offset = 0 ∧ c2.offset = 0)

instance (c₁ cā‚‚ : Conversion) : Decidable (Affinable c₁ cā‚‚) := by infer_instance

But we can't eforce it in the instances below because there is no way to attach the proof to the standard typeclasses. We could attach it to Conversion but that would restrict it too much. Indeed, it would prevent converting from celsius to fahrenheit directly.

Instances For
    theorem Units.Conversion.ext {x y : Conversion} (factor : x.factor = y.factor) (offset : x.offset = y.offset) :
    x = y
    Equations
    • One or more equations did not get rendered due to their size.
    Instances For
      def Units.instDecidableEqConversion.decEq (xāœ xāœĀ¹ : Conversion) :
      Decidable (xāœ = xāœĀ¹)
      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        Equations
        Instances For
          class Units.HasConversion (μ : Type) :
          Instances
            Equations
            Instances For
              def Units.Conversion.scale (s : ā„š) (h : s ≠ 0 := by simp) :
              Equations
              Instances For
                Equations
                Instances For
                  Equations
                  Instances For
                    Equations
                    Instances For
                      Equations
                      Instances For
                        Equations
                        Instances For
                          theorem Units.Conversion.mul_def (c1 c2 : Conversion) :
                          c1 * c2 = c1.mul c2
                          theorem Units.Conversion.div_def (c1 c2 : Conversion) :
                          c1 / c2 = c1.mul c2.inv
                          def Units.Conversion.apply {α : Type u_1} [RatCast α] [Mul α] [Add α] (c : Conversion) (x : α) :
                          α

                          Apply the conversion to a value x

                          Equations
                          Instances For
                            def Units.Conversion.convert {α : Type u_1} [RatCast α] [Mul α] [Add α] (c1 c2 : Conversion) (x : α) :
                            α

                            Convert x from c1 to c2

                            Equations
                            Instances For
                              Equations
                              Instances For
                                Equations
                                Instances For
                                  Equations
                                  Instances For
                                    Equations
                                    Instances For
                                      Equations
                                      Instances For
                                        theorem Units.Conversion.add_comm' (c1 c2 : Conversion) :
                                        c1.add c2 = c2.add c1
                                        theorem Units.Conversion.add_comm (c1 c2 : Conversion) :
                                        c1 + c2 = c2 + c1
                                        theorem Units.Conversion.add_assoc' (c1 c2 c3 : Conversion) :
                                        (c1.add c2).add c3 = c1.add (c2.add c3)
                                        theorem Units.Conversion.add_assoc (c1 c2 c3 : Conversion) :
                                        c1 + c2 + c3 = c1 + (c2 + c3)
                                        theorem Units.Conversion.nsmul_succ (s : ā„•) (c : Conversion) :
                                        nsmul (s + 1) c = (nsmul s c).add c
                                        theorem Units.Conversion.sub_eq_add_neg (c1 c2 : Conversion) :
                                        c1 - c2 = c1 + c2.neg
                                        theorem Units.Conversion.zsmul_succ' (n : ā„•) (c : Conversion) :
                                        zsmul (↑n.succ) c = zsmul (↑n) c + c
                                        Equations
                                        • One or more equations did not get rendered due to their size.