Skip to Content
AxiomsAxioms
  • Article
  • Open Access

24 November 2026

20 Pages

Learning Twin Primality from Pairs of Modular-Inverse Graphs

Ramat Gan Academic College, Ramat Gan 52275, Israel
This article belongs to the Section Algebra and Number Theory

Abstract

This work investigates whether twin-prime pairs can be identified from graph representations derived solely from modular-inverse relations. Each integer is represented as a graph in which vertices correspond to residues modulo that integer and edges encode multiplicative-inverse relations. We provide mathematical justification for two classification approaches: a Siamese Graph Isomorphism Network (SiameseGIN) and logistic regression. We identify the sum of the isolated-vertex proportions of the two graphs as a common structural quantity underlying both approaches and establish conditions under which it separates twin-prime pairs from non-twin pairs. For the SiameseGIN, we analyze the message-passing and pooling operations and show that the resulting graph representations encode the isolated-vertex proportions, allowing its decision score to depend on the same structural quantity. For logistic regression, we show that the decision score can be expressed as an affine function of this quantity and therefore admits perfect separation under these conditions. We further establish conditions under which the validation and test ranges admit a common separating threshold, providing a theoretical explanation for the empirical observation that the validation-selected threshold also achieves perfect separation on the test set. We evaluate both approaches experimentally using disjoint training, validation, and test ranges. A threshold selected exclusively on the validation set is applied unchanged to the test set, where both logistic regression and the SiameseGIN achieve a balanced accuracy of 1.000, with no false-positive or false-negative classifications. Additional experiments demonstrate perfect classification across extended numerical ranges, including integers near 106, without retraining or threshold adjustment. The principal contribution is a mathematical characterization of how the SiameseGIN architecture processes modular-inverse graphs for integers below 104, while the experimental results demonstrate agreement with the theoretical analysis.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.