View on GitHub

Exact p-Adics

A Magma package for exact p-adic computation

Precision strategies

All intrinsics in ExactpAdics either return the correct value or raise an error if this is not possible. In particular, some p-adic computations are not possible unless the inputs are known to sufficient precision, and if this occurs then we raise a precision error. Precision strategies are how we tell these computation how much we are willing to increase certain precisions before giving up.

Contents

Motivation

Consider we have a value x which is known to be 0 modulo 2:

> K := ExactpAdicField(2);
> x := K!(2^19+1) - K!1;
> print x;
O(2)

Suppose we want its valuation. All we know at the moment is that it is at least 1. We could try increasing the precision of x to 10 and find:

> IncreaseAbsolutePrecision(x, 10);
> print x;
O(2^10)

So its valuation is at least 10. Now try increasing its precision to 20:

> IncreaseAbsolutePrecision(x, 20);
> print x;
2^19 + O(2^20)

And now we know the valuation is 19. But it was possible that the valuation was 100 or 1000 or Inifinity, so how often should we try increasing the precision, and by how much, before giving up? This decision is left to the user, and this information is encapsulated in a precision strategy which is essentially an ascending sequence of numbers. Most functions which use such strategies do so by increasing their inputs to each number in the sequence in turn until the computation can succeed.

> K := ExactpAdicField(2);
> x := K!(2^19+1) - K!1;
> print x;
O(2)
> Valuation(x : Strategy := [1,5,10]);
Runtime error: weakly zero
> print x;
O(2^10)
> Valuation(x : Strategy := [1,5,10,20]);
19
> print x;
2^19 + O(2^20)
> Valuation(x : Stragegy := [1,5,10]);
19
> print x;
2^19 + O(2^10)

This example shows that asking for the valuation of something with a strategy which doesn’t go high enough will result in a precision error. And once the valuation is known, it remains known, even if we ask for it with a strategy which appears too small later.

Conventions

In this package we obey the convention that any intrinsic which accepts precision strategies will:

For example, this is a valid intrinsic:

intrinsic Foo(x : Strategy:="default", OtherStrategy:=Strategy) -> .

Functions which accept strategies should be careful to propagate these out to any function calls which accept strategies.

Format of a strategy

A strategy is a strictly increasing sequence of integers, and is represented by one of the following:

Execution

ExactpAdics_StartPrecisionStrategy (strategy)

-> Any

An object representing the initial state of the strategy.

Parameters

ExactpAdics_StepPrecisionStrategy (~ok, ~pr, ~state)

If the strategy can be stepped further, sets ok to true, sets pr to the next precision and sets state to the next state. Otherwise sets ok to false, pr is unchanged and state may change but can still not be stepped further.

ExactpAdics_ExecutePrecisionStrategy (cb :: UserProgram, strategy)

-> BoolElt, RngIntElt, Any

Executes the given precision strategy: calls cb(pr) for each pr in the strategy; if it ever returns (true,value) then this returns (true,pr,value), otherwise it returns (false,pr,_) where pr is the last precision used in the strategy.

Parameters

ExactpAdics_ExecutePrecisionStrategy_Lazy (strategy, getDeps :: UserProgram, getValue :: UserProgram)

-> ExactpAdics_Gettr

The (general) getter which, for each pr in the strategy calls getDeps(pr, ~getter) to get a dependent getter, which evaluates to gval, then calls getValue(gval, ~val) to get the value.

Global strategies

For user convenience, there is a table of globally defined strategies which may be referred to by name. There are 3 strategies provided by default, which may all be overridden:

The string "default" is used as the default Strategy parameter by most instrinsics in this package, so for most users it suffices to simply set this global strategy to their preferred one and then use the intrinsics without any explicit Strategy parameters.

ExactpAdics_IsGlobalPrecisionStrategyDefined (name :: MonStgElt)

-> BoolElt, Any

Returns true if there is a global strategy with the given name, and if so, returns the strategy itself.

ExactpAdics_SetGlobalPrecisionStrategy (name :: MonStgElt, strat)

Defines the global strategy with the given name to the given strategy.

ExactpAdics_GetGlobalPrecisionStrategy (name :: MonStgElt)

-> Any

Returns the global strategy with the given name.