Documentation

LambdaS.LogFactor

Exact logarithms of positive rationals #

Eliminating declaration equations combines the logarithms of declared factors with rational coefficients, producing values such as (log 2)/2 - log 3. This module represents such values exactly and decides their equality without evaluating a logarithm or a root.

An Expr is a finite list of pairs (c, q) of a rational coefficient and a positive rational, denoting ∑ c * log q (eval). radical clears denominators, returning a positive rational q and a positive natural N with log q = N * eval xs (radical_log). So an expression denotes zero exactly when q = 1 (isZero_iff), a test carried out in ℚ.

LogFactor is the quotient of Expr by equality of denotation. It is a ℚ-module with decidable equality, so RationalSolver can eliminate over it. Its real interpretation interpret is an injective ℚ-linear map (interpret_injective), which lets DeclSolver.solve_isSome_iff transfer solvability to real valuations. The same radical gives the radicand and root degree of DeclSolver.ExactFactor (radical_exp). No real arithmetic is executed.

@[reducible, inline]

Positive rationals: the declared factors whose logarithms an Expr combines.

Equations
Instances For
    @[reducible, inline]

    A formal rational combination of logarithms: [(c₁, q₁), …, (cₙ, qₙ)] denotes c₁ log q₁ + … + cₙ log qₙ.

    Equations
    Instances For
      noncomputable def LambdaS.LogFactor.eval :
      Expr → ℝ

      The real number an expression denotes. Noncomputable; used only in statements and proofs.

      Equations
      Instances For
        theorem LambdaS.LogFactor.eval_ofFn {n : ℕ} (c : Fin n → ℚ) (q : Fin n → PositiveRat) :
        eval (List.ofFn fun (i : Fin n) => (c i, q i)) = ∑ i : Fin n, ↑(c i) * Real.log ↑↑(q i)

        Evaluate an explicitly indexed finite family of logarithm coefficients.

        Return (q, N), with q a positive rational and N a positive natural, such that the expression denotes log q / N (radical_log, radical_pos). The integer powers clear denominators without factoring any integer.

        Equations
        Instances For
          theorem LambdaS.LogFactor.radical_pos (xs : Expr) :
          0 < (radical xs).1 ∧ 0 < (radical xs).2
          theorem LambdaS.LogFactor.radical_log (xs : Expr) :
          Real.log ↑(radical xs).1 = ↑(radical xs).2 * eval xs

          The defining property of radical: for (q, N) = radical xs, log q = N * eval xs.

          theorem LambdaS.LogFactor.radical_exp (xs : Expr) :
          Real.exp (eval xs) ^ (radical xs).2 = ↑(radical xs).1

          The returned rational and positive degree specify the positive real factor without evaluating a logarithm or a root in the executable representation.

          The executable zero test; its decision takes place entirely in ℚ.

          Equations
          Instances For

            Exact zero test. An expression denotes zero exactly when its cleared radicand is 1.

            theorem LambdaS.LogFactor.eval_append (xs ys : Expr) :
            eval (xs ++ ys) = eval xs + eval ys
            Equations
            Instances For
              theorem LambdaS.LogFactor.eval_scaleExpr (c : ℚ) (xs : Expr) :
              eval (scaleExpr c xs) = ↑c * eval xs
              @[instance_reducible]

              Two expressions are equivalent when they denote the same real number; exprRelDecidable decides this with isZero on their difference.

              Equations

              Exact logarithms of positive rational numbers, closed under rational linear combinations.

              Equations
              Instances For
                @[instance_reducible]
                Equations
                • One or more equations did not get rendered due to their size.
                @[instance_reducible]
                Equations
                • One or more equations did not get rendered due to their size.
                @[instance_reducible]
                Equations
                @[instance_reducible]
                Equations
                @[instance_reducible]
                Equations
                @[instance_reducible]
                Equations
                @[simp]
                @[simp]
                theorem LambdaS.LogFactor.value_smul (c : ℚ) (x : LogFactor) :
                (c • x).value = c • x.value
                @[simp]
                @[simp]
                @[simp]
                @[instance_reducible]
                Equations
                • One or more equations did not get rendered due to their size.
                @[instance_reducible]
                Equations
                • One or more equations did not get rendered due to their size.

                The real interpretation is noncomputable; all operations on its domain are executable.

                Equations
                Instances For

                  Distinct LogFactors denote distinct reals, so exact equality agrees with real equality.

                  def LambdaS.LogFactor.ofRat (q : ℚ) (hq : 0 < q) :

                  Construct the exact logarithm of a declared positive rational factor.

                  Equations
                  Instances For
                    @[simp]
                    theorem LambdaS.LogFactor.interpret_ofRat (q : ℚ) (hq : 0 < q) :