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.
A formal rational combination of logarithms: [(c₁, q₁), …, (cₙ, qₙ)] denotes
c₁ log q₁ + … + cₙ log qₙ.
Equations
Instances For
The real number an expression denotes. Noncomputable; used only in statements and proofs.
Equations
- LambdaS.LogFactor.eval [] = 0
- LambdaS.LogFactor.eval ((c, q) :: xs) = ↑c * Real.log ↑↑q + LambdaS.LogFactor.eval xs
Instances For
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
The executable zero test; its decision takes place entirely in ℚ.
Equations
- LambdaS.LogFactor.isZero xs = ((LambdaS.LogFactor.radical xs).1 == 1)
Instances For
Equations
- LambdaS.LogFactor.scaleExpr c xs = List.map (fun (a : ℚ × LambdaS.LogFactor.PositiveRat) => (c * a.1, a.2)) xs
Instances For
Two expressions are equivalent when they denote the same real number;
exprRelDecidable decides this with isZero on their difference.
Equations
- LambdaS.LogFactor.exprSetoid = { r := fun (xs ys : LambdaS.LogFactor.Expr) => LambdaS.LogFactor.eval xs = LambdaS.LogFactor.eval ys, iseqv := LambdaS.LogFactor.exprSetoid._proof_1 }
Equations
- LambdaS.LogFactor.exprRelDecidable xs ys = decidable_of_iff (LambdaS.LogFactor.isZero (xs ++ LambdaS.LogFactor.scaleExpr (-1) ys) = true) ⋯
Exact logarithms of positive rational numbers, closed under rational linear combinations.
Instances For
Equations
- LambdaS.LogFactor.ofExpr xs = ⟦xs⟧
Instances For
Instances For
Equations
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- LambdaS.LogFactor.instNeg = { neg := fun (x : LambdaS.LogFactor) => -1 • x }
Equations
- LambdaS.LogFactor.instSub = { sub := fun (x y : LambdaS.LogFactor) => x + -y }
Equations
- LambdaS.LogFactor.instSMulNat = { smul := fun (n : ℕ) (x : LambdaS.LogFactor) => ↑n • x }
Equations
- LambdaS.LogFactor.instSMulInt = { smul := fun (n : ℤ) (x : LambdaS.LogFactor) => ↑n • x }
Equations
- One or more equations did not get rendered due to their size.
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
- LambdaS.LogFactor.interpret = { toFun := LambdaS.LogFactor.value, map_add' := LambdaS.LogFactor.value_add, map_smul' := LambdaS.LogFactor.value_smul }
Instances For
Distinct LogFactors denote distinct reals, so exact equality agrees with
real equality.
Construct the exact logarithm of a declared positive rational factor.
Equations
- LambdaS.LogFactor.ofRat q hq = LambdaS.LogFactor.ofExpr [(1, ⟨q, hq⟩)]