pith. sign in

arxiv: 2604.16799 · v1 · submitted 2026-04-18 · 🧮 math.AG · math.NT

Implementing p-adic numbers in Macaulay2 using its foreign function interface and FLINT

Pith reviewed 2026-05-10 07:30 UTC · model grok-4.3

classification 🧮 math.AG math.NT
keywords p-adic numbersMacaulay2FLINTforeign function interfacealgebraic geometrycomputer algebranumber theorysoftware package
0
0 comments X

The pith

Macaulay2 supports p-adic numbers through a new package interfacing with FLINT.

A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.

The paper presents a Macaulay2 package for p-adic numbers built on top of the FLINT library using the ForeignFunctions interface. This brings p-adic arithmetic to a tool widely used in algebraic geometry and commutative algebra. Implementation focuses on memory allocation, garbage collector compatibility, and object design similar to reals and complexes. Sympathetic readers would value this for enabling seamless p-adic work within Macaulay2 scripts. The approach illustrates how external libraries can extend the system's capabilities.

Core claim

By using the ForeignFunctions package, the authors implement p-adic numbers in Macaulay2 by calling into FLINT, handling memory to avoid leaks with the garbage collector, and designing classes that match the style of built-in number fields.

What carries the argument

FLINT's p-adic types accessed via Macaulay2's ForeignFunctions package, with custom object wrappers for integration.

If this is right

  • P-adic computations become possible natively in Macaulay2.
  • The interface method can extend to other FLINT features or libraries.
  • Design patterns for number fields are reusable for future additions.
  • Algebraic geometry research gains direct p-adic support.

Where Pith is reading between the lines

These are editorial extensions of the paper, not claims the author makes directly.

  • This could lead to more library integrations in Macaulay2 for specialized computations.
  • Researchers might test the package on known p-adic problems to check accuracy.
  • It opens the door to combining p-adics with Macaulay2's strong polynomial algebra tools.

Load-bearing premise

That the foreign function calls to FLINT work correctly and that p-adic objects are properly managed by Macaulay2's memory system without errors.

What would settle it

A Macaulay2 session that allocates many p-adic numbers and performs operations on them; if it crashes or leaks memory, the implementation fails.

Figures

Figures reproduced from arXiv: 2604.16799 by Douglas A. Torrance.

Figure 1
Figure 1. Figure 1: Class diagram for number types Instances of QQ_p are hash tables containing pointers to the corresponding padic_t and padic_ctx_t objects. The latter are memoized to avoid duplica￾tion. Then methods are installed on PadicNumber wrapping each of the foreign functions from FLINT, e.g., PadicNumber + PadicNumber calls padic_add. 6 Example: Hensel’s lemma We close with an example, showing how to use our Macaul… view at source ↗
Figure 2
Figure 2. Figure 2: Class diagram for number objects We would like to use Macaulay2 to compute the cube root of 2 in Z5 by finding a root of x 3 − 2 ∈ Z5[x]. Since 3 3 − 2 = 25 ≡ 0 (mod 5) and 3 · 3 2 = 27 ̸≡ 0 (mod 5), we begin with α1 = 3. We then iterate Newton’s method until it converges (up to the 5 19 term, as FLINT’s default precision for p-adics is N = 20). See Listing 2. Disclosure of Interests. The author has no com… view at source ↗
read the original abstract

Macaulay2 is a computer algebra platform widely used by researchers in algebraic geometry and commutative algebra. Using the ForeignFunctions package, it is possible to make calls from Macaulay2 to dynamic libraries such as FLINT. We demonstrate this by introducing a new Macaulay2 package implementing p-adic numbers using FLINT via this interface. We discuss implementation details such as memory allocation, interaction with Macaulay2's garbage collector, and object-oriented design decisions that mirror the existing implementations of the real and complex number fields in Macaulay2.

Editorial analysis

A structured set of objections, weighed in public.

Desk editor's note, referee report, simulated authors' rebuttal, and a circularity audit. Tearing a paper down is the easy half of reading it; the pith above is the substance, this is the friction.

Referee Report

0 major / 2 minor

Summary. The manuscript presents the development of a new Macaulay2 package implementing p-adic numbers via the ForeignFunctions interface to the FLINT library. It covers implementation details such as memory allocation, interaction with Macaulay2's garbage collector, and object-oriented design choices that parallel the existing real and complex number field implementations.

Significance. If the integration functions as described, this provides a practical and valuable extension to Macaulay2 for p-adic computations in algebraic geometry and commutative algebra. The approach of building directly on the reliable FLINT library through the ForeignFunctions package is a strength, offering a concrete software contribution that enables new workflows without reinventing core arithmetic.

minor comments (2)
  1. [Abstract] The abstract would be strengthened by briefly noting any included examples or usage demonstrations of the package.
  2. Add explicit references to the documentation or source of the ForeignFunctions package and the relevant FLINT p-adic modules to aid readers in reproducing the interface.

Simulated Author's Rebuttal

0 responses · 0 unresolved

We thank the referee for their positive assessment of the manuscript and their recommendation to accept.

Circularity Check

0 steps flagged

No circularity: pure implementation report with no derivations

full rationale

This paper is a software implementation report describing the creation of a Macaulay2 package for p-adic numbers using FLINT via the ForeignFunctions interface. It contains no mathematical derivations, predictions, fitted parameters, uniqueness theorems, or first-principles results that could reduce to their inputs by construction. The central claim is the existence and functionality of the implemented package, which is verified directly by its successful creation, memory management details, and usability rather than any self-referential logic or self-citation chains. No load-bearing steps match the enumerated circularity patterns.

Axiom & Free-Parameter Ledger

0 free parameters · 0 axioms · 0 invented entities

This is a software implementation paper. It relies on the pre-existing FLINT library for p-adic arithmetic, Macaulay2's ForeignFunctions package, and standard practices for memory management and garbage collector interaction. No new mathematical free parameters, axioms, or invented entities are introduced.

pith-pipeline@v0.9.0 · 5385 in / 1057 out tokens · 62412 ms · 2026-05-10T07:30:41.026339+00:00 · methodology

discussion (0)

Sign in with ORCID, Apple, or X to comment. Anyone can read and Pith papers without signing in.

Reference graph

Works this paper leans on

6 extracted references · 6 canonical work pages

  1. [1]

    Soft- ware: Practice and Experience18(9), 807–820 (1988)

    Boehm, H.J., Weiser, M.: Garbage collection in an uncooperative environment. Soft- ware: Practice and Experience18(9), 807–820 (1988)

  2. [2]

    Universitext, Springer-Verlag, Berlin, second edn

    Gouvêa, F.Q.: p-adic Numbers, An Introduction. Universitext, Springer-Verlag, Berlin, second edn. (1997), https://doi.org/10.1007/978-3-642-59058-0

  3. [3]

    Available at https://macaulay2.com/

    Grayson, D.R., Stillman, M.E.: Macaulay2, a software system for research in alge- braic geometry. Available at https://macaulay2.com/

  4. [4]

    Hensel, K.: Neue Grundlagen der Arithmetik. J. Reine Angew. Math.127, 51–84 (1904), https://doi.org/10.1515/crll.1904.127.51

  5. [5]

    The FLINT team: FLINT: Fast Library for Number Theory (2025), version 3.4.0, https://flintlib.org

  6. [6]

    Torrance, D.A.: ForeignFunctions package for Macaulay2. J. Softw. Algebra Geom. 15(1), 1–9 (2025), https://doi.org/10.2140/jsag.2025.15.1 Implementing p-adic numbers in Macaulay2 using its FFI and FLINT 7 i1 : needsPackage "Padic"; i2 : newton = x -> x - (x^3 - 2)/(3*x^2); i3 : alpha = QQ_5 3 o3 = 3 o3 : QQ (of precision 20) 5 i4 : while alpha != (alpha =...