Expand description
The exact real types in a program’s value model: real algebraic numbers, computable reals, the program’s infinitesimal and the hyperreals it generates, infinite integers, ordinals, and the values a supertask leaves.
Each type lives in its own module of this crate; this module decides how they mix with the
numeric tower and with each other, once, for every value model that holds them. A value model
(the interpreter’s runtime value, a compiled program’s value) implements TowerValue: how to
see one of its values as an exact type or a standard number, and how to build one. Everything
here is generic over it, so every tier computes, compares and prints these values identically.
- an integer, rational or float operand is lifted exactly (a float is the dyadic rational it denotes, never a rounding of the other side) into the exact type it meets;
- real algebraic numbers sit below computable reals; the hyperreals are generated by the
infinitesimal over the algebraic numbers, exactly as rational functions of
dt; a value a flow leaves, or a computable transcendental meeting the infinitesimal, is a germ — known by its series indtwith exact coefficients, compared by the sign of its first nonzero one; - an infinite integer meets a standard integer as an infinite integer (
+ − ×, floor division and remainder keep integer meaning) and anything fractional as a hyperreal; - a value that depends on the residue of
1/dtlifts every operation branch by branch, and a comparison of infinite integers can itself depend on that residue; - an ordinal meets only ordinals and naturals.
Every result is held in its smallest exact form — a hyperreal with no infinitesimal part is
its standard value, a hyperreal that is an integer for every admitted ⌈1/dt⌉ is that infinite
integer, an algebraic number that is rational is a rational — so a value has one representation
whatever route produced it, exactly as the tower downsizes BigInt to Int.
Structs§
- Branch
- One branch of a residue-dependent value, compared by value.
- Depends
Value - A value that depends on the residue of
⌈1/dt⌉. - Hyper
Value - A hyperreal value with the infinitesimal it is written in.
- Natural
Value - An infinite integer with the infinitesimal whose reciprocal generates it.
- Scale
- An infinitesimal of the program: the name it was declared under, what is known about the
residues of its reciprocal, the infinite natural
⌈1/dt⌉, and where it stands among the others.
Enums§
- Exact
Ref - A value of a value model seen as one of the types this module governs.
- Hyper
Form - A hyperreal’s representations: an exact rational function of
dt; a real algebraic Puiseux series that is none, a root of one (crate::puiseux); the germ a flow leaves, known by its series indt; or a value of several ordered infinitesimals (Multi). A Puiseux series compares and hashes by its value, a germ by its canonical encoding. - Op
- The arithmetic operators the exact types take.
- RealFn
- A function of the reals the exact types take: the square root, the exponential, the natural logarithm.
- Rel
- The relational operators the exact types answer.
- Rounding
- How an integer part rounds: down, up, or to the nearest integer with ties away from zero (the
tower’s
round). - Shape
- A value’s structure, as far as the supertask runtime reads it: the scalar kinds it treats apart, and the items of a list or a tuple.
Traits§
- Tower
Value - A value model that holds the exact types: how to see a value as one of them or as a standard number, and how to build one. The interpreter’s runtime value and a compiled program’s value each implement it; every operation in this module is generic over it.
- Value
Algebra - A value model’s whole arithmetic and its lists: what the supertask runtime computes with. Each operation is the language’s own on that model, exact types and standard numbers alike.
Functions§
- apply_
limit - Resolve a residue-dependent value under a limit rule; a value that does not depend on the residue is its own limit under every rule. A value that depends on the residues of several generators resolves each branch’s finer dependence first: the residues of different generators are independent, so the rule over every pair of classes is the rule over the coarser generator’s classes of the rule over the finer one’s.
- arith
- Apply
opwhen either operand is an exact type;Nonewhen neither is (the tower handles it), and for+with aTextoperand, which joins the other value as it prints by the value model’s own rule for every value.recurseis the value model’s full arithmetic, used to lift an operation over residue branches and through provisional values. - carry_
evidence vcarrying the evidence a provisional or settled answerccarries. An answer never holds another: whenvcarries evidence of its own, the two join into one (Converging::joined).- depends_
from_ parts - A residue-dependent value rebuilt from its scale, modulus and per-class values.
- display
- How an exact value prints;
Nonefor any other value. - euler
- e, exactly.
- exact_
bytes - An algebraic number (
0), computable real (1) or ordinal (2) as its canonical bytes;Nonefor any other value, and for a real built from a function a program defines, which stays with the program. - exact_
power base ** exponentfor an exponent that is an exact number — what**andpoware when their exponent is one: a fractionp/qtakes the realq-th root and raises it top(2 ** (1/2)is√2,dt ** (1/2)is√dt, an even root of a negative number refused), and any other exponent is the language’s own**, a float on either side the float power. A residue-dependent or provisional operand is followed branch by branch.- from_
algebraic - The canonical value of an algebraic number: a rational is an
Int/BigInt/Rational. - from_
closed - The canonical value of a value of the real closure: a rational function of
dtis that hyperreal, in its own smallest form. - from_
depends - The canonical value of a residue-dependent value: a branch that itself depends on the residue
is read on its own class, a single branch is that value, and a dependence whose every branch is
an integer polynomial in
1/dton its class is that infinite integer. - from_
exact_ bytes - The value
exact_byteswrote;Nonefor a forged or non-canonical encoding. - from_
exact_ real - The canonical value of a computable real: an algebraic one is an algebraic number.
- from_
germ - The canonical value of a germ: one built as a rational function of
dtis that hyperreal. - from_
hyper - The canonical value of a hyperreal: a standard value is its standard part, and a polynomial in
1/dtthat is an integer for every admitted⌈1/dt⌉is that infinite integer. - from_
multi - The canonical value of a value of several infinitesimals: a standard number is that number, and a value of one infinitesimal is that infinitesimal’s own.
- from_
natural - The canonical value of an infinite integer: a standard one is an
Int/BigInt, and one whose branches are standard but differ is a residue-dependent integer. - from_
ordinal - A finite ordinal is a natural number.
- from_
scaled_ bytes - The value
scaled_byteswrote;Nonefor a forged or non-canonical encoding. - generator_
of - The infinite natural
⌈1/dt⌉generated by an infinitesimal value. - germ_of
- A number as a germ: a standard number as a constant, a hyperreal by its series or as the germ
it is, an infinite integer that does not depend on the residue by its series;
Noneotherwise. - integer_
part - The integer part of an exact value under
mode;Nonewhenvis not one (the tower handles it).recurseis the builtin itself, for the standard values inside a dependence or a provisional answer. - is_
exact_ value - True for a value of one of the types this module governs.
- is_
infinitesimal x ≈ 0: zero or an infinitesimal.- is_
infinitesimal_ relative - Zero, or smaller than every positive value of
atand of the infinitesimals larger than it. - is_
limited - Bounded by a standard number.
- is_
limited_ relative - Bounded by a value of
atand of the infinitesimals larger than it. - limit_
rule - A limit rule by its English name.
- map_
depends fon every branch of a residue-dependent value, or the first error a branch raises.- new_
infinitesimal - The program’s infinitesimal:
Let <name> be an infinitesimal …, its reciprocal’s residues modulomoduluslimited toallowed(the parser has already intersected the stated facts), or the contradiction refused when nothing is allowed. - new_
ordered_ infinitesimal Let <name> be an infinitesimal much smaller than <larger> [and much larger than <smaller>] …: an infinitesimal belowlargerand abovesmaller, each an infinitesimal itself or nothing, with its reciprocal’s residues asnew_infinitesimalreads them. Refused when a bound is no infinitesimal, when the two bounds are not already ordered, and when the name is one an infinitesimal it would be ordered with already has.- not
notlifted over residue branches and through provisional values;Nonefor any other value.- omega
- ω, the first infinite ordinal.
- pi
- π, exactly.
- provisional
- A provisional answer: the current guess after
stepscases withrevisionschanges. A guess that is already an answer joins this evidence to its own. - real_fn
fofv, exactly. A standard number goes in as the rational it denotes (a float as its dyadic rational), an algebraic number or a computable real as itself, and the answer is held in its smallest exact form:sqrt(4)is2,sqrt(2)is√2,exp(0)is1,ln(e)is1. The square root of a hyperreal or an infinite integer is its root in the real closure (crate::puiseux):sqrt(dt)is√dt. Every other function of a value of the infinitesimal is the germ of it (Germ):exp(dt)is1 + dt + O(dt^2),ln(1 + dt)isdt - (1/2)·dt^2 + O(dt^3), and the root of a germ is a germ. What is no germ is refused by name: the exponential of an infinite value, beyond every power ofdt, and the logarithm of a positive infinitesimal or an infinite value, which carriesln(dt). A residue-dependent value is mapped branch by branch and a provisional one keeps its evidence; a function of an ordinal has no exact form.- relation
- Apply
relwhen either operand is an exact type;Nonewhen neither is. The answer is aBool, or a residue-dependentBoolwhen it depends on⌈1/dt⌉; a comparison no theorem decides within the budget is a loud error. - scale_
from_ parts - The scale
scale_partswrote. - scale_
parts - The infinitesimal’s name and its declaration’s bytes (
Scale::to_bytes): its reciprocal’s residue facts, and where it stands among the others. - scaled_
bytes - A hyperreal (
0), infinite integer (1), germ (2), root of a hyperreal (3), exact value of several infinitesimals (4), germ of several (5) or infinite integer of several (6) as its scale and canonical bytes — the scale of a value of several its smallest infinitesimal, the bytes naming every one it involves;Nonefor any other value, and for a germ holding a real built from a function a program defines. - standard_
part - The standard part: a hyperreal’s standard value, branch by branch for a residue-dependent value; a standard value is its own. An infinite value has none.
- standard_
part_ relative - The standard part relative to the infinitesimal
at: whatvis infinitely close to among the values ofatand the infinitesimals larger than it, every smaller infinitesimal read at zero — the inner limit withatheld fixed.the standard part of dt + dx relative to dtisdt. - structurally_
equal - Structural equality for collections and hashing: exact forms by value, a general computable
real by the formula that built it;
Nonewhen neither value is an exact type. - transmissible
- Whether a value of the exact types can travel as data — to a task, through a channel, over the wire: every value but one holding a real built from a function a program defines, in itself, in a germ, in a branch of a residue-dependent value or as a provisional answer. A value model’s own lists are its own to walk.
- undecided_
branch - Why a value cannot decide a branch — a residue-dependent answer, or a provisional one no proof
settled — or
Nonefor any other value. Every tier refuses such a branch with this sentence.