Internals
In this section, we document the generic internal structure common to all p-adic objects.
Contents
Overview
All p-adic objects are a subtype of AnyPadExact, which has attributes including:
id: A global id, a unique integer assigned in dependency order.approximation: A list of approximations of the object, thenth entry being the approximation at thenth “epoch”.dependencies: A list of the other p-adic object on which this depends.get_approximation: A function taking a positive integern(an epoch) and the list of approximations of the dependencies at this epoch, and returning an approximation at this epoch.min_epoch: The lowest epoch for whichget_approximationshould be called. For lower epochs, interpolation is used (seeInterpolateEpochs).max_epoch: The highest epoch for whichget_approximationshould be called. For higher epochs, a precision error is raised.internal_data: Some state which may be freely modified byget_approximation.
There are two direct subtypes of AnyPadExact: StrPadExact representing a structure (or set), and PadExactElt representing an element of such a structure. For example, FldPadExact represents a p-adic field and is a subtype of StrPadExact, and its elements have type FldPadExactElt which is a subtype of PadExactElt. PadExactElt has an additional parent attribute, which must be the parent structure to which the element belongs.
Generic intrinsics
BringToEpoch (x :: AnyPadExact, n :: RngIntElt)
Brings x to epoch n.
BringToEpoch (xs :: [AnyPadExact], n :: RngIntElt)
Brings each x in xs to epoch n.
CanBringToEpoch (x :: AnyPadExact, n :: RngIntElt)
-> BoolElt
Tries to bring x to epoch n. Returns true if successful, or false if the max_epoch of something is exceeded.
CanBringToEpoch (xs :: [AnyPadExact], n :: RngIntElt)
-> BoolElt
Tries to bring each x in xs to epoch n. Returns true if successful, or false if the max_epoch of something is exceeded.
EpochApproximation (xs :: [AnyPadExact], n :: RngIntElt)
-> []
Returns sequence of approximations of xs at epoch n.
EpochApproximation (x :: AnyPadExact, n :: RngIntElt)
-> Any
The approximation of x at epoch n.
Init_AnyPadExact (x :: AnyPadExact)
Init_PadExactElt (x :: PadExactElt)
Init (x :: AnyPadExact)
Init (x :: PadExactElt)
Initializes x.
Parent (x :: PadExactElt)
-> StrPadExact
The parent of x.
BestApproximation (x :: AnyPadExact)
-> Any
The best approximation to x.
ExistsEpochWith (x :: AnyPadExact, pred)
-> BoolElt, RngIntElt
True if there is an epoch of x such that pred(x) is true. If so, returns it.
ExistsEpochWithApproximation (x :: AnyPadExact, pred)
-> BoolElt, RngIntElt
True if there is an epoch of x such that pred(xx) is true, where xx is the corresponding approximation. If so, returns it. False if max_epoch is ever exceeded.
Parameters
FromTopMinimize
FirstEpochWithApproximation (x :: AnyPadExact, pred)
-> RngIntElt
The first epoch whose approximation satisfies the predicate.
Parameters
FromTop
IncreaseEpochUntil (x :: AnyPadExact, pred)
Increases the epoch of x until pred(x) is true.
IncreaseAbsolutePrecision (x :: PadExactElt, apr)
Increases the absolute precision of x to at least apr.
Approximation (x :: PadExactElt, apr)
-> Any
An approximation of x with absolute precision at least apr.
InterpolateUpTo (x :: AnyPadExact, n :: RngIntElt)
Replaces the approximations of x below n with their interpolations.
InterpolateUpToFirstEpochWithApproximation (x :: AnyPadExact, pred)
-> RngIntElt, RngIntElt
Replaces the approximations of x below n with their interpolations, where n is the first epoch whose approximation satisfies the predicate. Returns the new and old values of n.
Parameters
FromTop
SetApproximation (x :: AnyPadExact, n :: RngIntElt, xx)
Sets the approximation of x at epoch n to xx.
This is called by BringToEpoch and InterpolateUpTo.
It checks the new approximation is valid by calling IsValidApproximation, then calls SetApproximationHook, then calls InterpolateEpochs if necessary to get missing approximations below n, and then finally updates the list of approximations.
WithDependencies (x :: AnyPadExact, ds :: List)
-> AnyPadExact
A copy of x with the direct dependencies ds.
This is useful if x is some complex expression in ds and you don’t care about the intermediate expressions. It can provide a small speed-up in computing approximations for x.
Parameters
Fast := false: When true, this in effect eliminates the intermediate variables entirely, often resulting in a large speed-up in computing approximations for x. It should not be used when there is an intermediate variable which may alter its cached approximation, since this cache is not considered. This includes operations such as division and polynomial discriminant; many such operations have aSafeparameter which makes them safe to use in this context. Note that themin_epochof the copy of x will be the maximum of themin_epochof the intermediate variables; similarly themax_epochwill be the minimum over intermediate variables.
Overloadable intrinsics
The following intrinsics are expected to be overloaded for type-specific behaviour.
InterpolateEpochs (x :: AnyPadExact, n1 :: RngIntElt, n2 :: RngIntElt, xx2)
-> List
Assuming we have an approximation for x at epoch n1, and xx2 is the approximation at epoch n2, returns approximations for the intermediate epochs [n1+1..n2-1]. Usually this will do something simple such as just lowering the precision of xx2 to match each intermediate epoch.
GetApproximation (get, n :: RngIntElt, xds :: List)
-> Any
Given a get_approximation value get, an epoch n and a list of approximations of dependencies at epoch n, returns an approximation at epoch n.
GetApproximation (get :: UserProgram, n :: RngIntElt, xds :: List)
-> Any
Currently, get_approximation is always just a function, and so this just calls it.
SetApproximationHook (x :: AnyPadExact, n :: RngIntElt, ~xx)
Overload this to perform some action when we are about to set the approximation of x at epoch n to xx.
For example, this is used by RngUPol_FldPadExact to ensure all its approximations have the same variable name.
IsValidApproximation (x :: AnyPadExact, n :: RngIntElt, xx)
-> BoolElt, MonStgElt
True if xx is a valid approximation of x at epoch n. If not, also returns an error message.
IsValidApproximation (x :: PadExactElt, n :: RngIntElt, xx)
-> BoolElt, MonStgElt
For p-adic elements, this checks that the approximation is an element of the approximation of the parent, and that it is weakly equal to the current best approximation for x.
UninitializedCopy (x :: AnyPadExact)
-> AnyPadExact
An uninitialized copy of x.
UninitializedCopy (x :: StrPadExact)
-> StrPadExact
For structures, we raise a “cannot copy p-adic structures” error, since equality of structures is defined by equality of id, and this would break it.
UninitializedCopy (x :: PadExactElt)
-> PadExactElt
For elements, we just need to copy the parent.
Version
ExactpAdics_Version ()
-> RngIntElt, RngIntElt, RngIntElt
The version of the ExactpAdics package, as major, minor and patch numbers.
ExactpAdics_Implementation ()
-> RngIntElt
This returns 2, to distinguish this package from ExactpAdics, for which this returns 1.
Global ID
Each p-adic object (AnyPadExact) has a unique id attribute, which is ordered according to dependency.
ExactpAdics_NextId ()
-> RngIntElt
The next global id.
Warnings
For controlling the extent to which errors and warning occur in the package.
ExactpAdics_SetWarningAction (name :: MonStgElt, action :: MonStgElt)
Sets how the warning name is displayed. action is one of:
"Ignore": ignores the warning and does nothing"Warn": prints the warning to the screen"WarnOnce": prints the warning to the screen the first time it occurs"Error": raises an error
ExactpAdics_WarningActionIsDefined (name :: MonStgElt)
-> BoolElt, MonStgElt
True if there is a warning action defined for warning name. If so, also returns the action.
ExactpAdics_GetWarningAction (name :: MonStgElt, dflt :: MonStgElt)
-> MonStgElt
The warning action set for warning name, if set, or else dflt.
ExactpAdics_Warn (name :: MonStgElt, msg)
Raises the warning name with message msg.
Parameters
DefaultActionAction