Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Default owner for everything
* @djdarcy

# Python source
*.py @djdarcy

# Lean proofs
proofs/ @djdarcy

# Documentation
docs/ @djdarcy
*.md @djdarcy

# GitHub configuration
/.github/ @djdarcy
15 changes: 15 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# These are supported funding model platforms

github: djdarcy # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
ko_fi: djdarcy # Replace with a single Ko-fi username
buy_me_a_coffee: djdarcy
#patreon: dustinjd # Replace with a single Patreon username

open_collective: # Replace with a single Open Collective username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
#custom: ['https://buymeacoffee.com/djdarcy'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Bug report
about: Create a report to help improve Prime-Square-Sum
title: "[BUG] "
labels: bug
assignees: ''
---

**Describe the bug**
A clear and concise description of what the bug is.

**Command used**
```bash
python prime-square-sum.py --expr "..."
```

**Expected behavior**
A clear and concise description of what you expected to happen.

**Actual behavior**
What actually happened, including any error messages.

**Environment:**
- OS: [e.g., Windows 11, Ubuntu 22.04]
- Python version: [e.g., 3.12]
- Prime-Square-Sum version: [e.g., 0.8.2]
- Installation method: [conda / pip / manual]

**Additional context**
Add any other context about the problem here.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Documentation
url: https://github.com/djdarcy/Prime-Square-Sum/tree/main/docs
about: Browse the expression syntax, equations, and function reference docs
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Feature request
about: Suggest an idea for Prime-Square-Sum
title: ''
labels: enhancement
assignees: ''
---

**Is your feature request related to a problem?**
A clear and concise description of what the problem is. E.g., "I'm frustrated when..."

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context about the feature request here.
21 changes: 21 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 2
updates:
# Python dependencies (requirements.txt)
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 10
labels:
- "dependencies"
versioning-strategy: increase-if-necessary

# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
open-pull-requests-limit: 5
labels:
- "dependencies"
- "github-actions"
31 changes: 31 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## Description
<!-- Provide a brief summary of the changes in this PR -->

## Type of change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
- [ ] Code refactoring (no functional changes)
- [ ] Performance improvement
- [ ] Lean proof addition/modification

## Components affected
- [ ] CLI / Expression engine
- [ ] Number theory utilities
- [ ] Lean 4 proofs
- [ ] Documentation
- [ ] Tests
- [ ] Infrastructure (scripts, CI, etc.)

## How Has This Been Tested?
<!-- Describe the tests you ran to verify your changes -->
<!-- e.g., python -m pytest tests/ -v -->

## Checklist:
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] New and existing tests pass (`python -m pytest tests/ -v`)
- [ ] I have updated the CHANGELOG (for user-facing changes)
34 changes: 34 additions & 0 deletions .github/release-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Release v$NEXT_VERSION

## What's Changed

### New Features
-

### Bug Fixes
-

### Lean Proofs
-

### Documentation
-

### Maintenance
-

### Breaking Changes
-

## Installation

```bash
git clone https://github.com/djdarcy/Prime-Square-Sum.git
cd Prime-Square-Sum
conda create -n prime-square-sum python=3.12
conda activate prime-square-sum
conda install -c conda-forge numpy primesieve
```

## Full Changelog
$CHANGES
37 changes: 37 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Configuration for probot-stale - https://github.com/probot/stale

# Number of days of inactivity before an Issue or Pull Request becomes stale
daysUntilStale: 90

# Number of days of inactivity before a stale Issue or Pull Request is closed
daysUntilClose: 14

# Issues or Pull Requests with these labels will never be considered stale
exemptLabels:
- pinned
- security
- enhancement
- bug
- "in progress"
- "help wanted"
- "lean-proofs"

# Label to use when marking as stale
staleLabel: stale

# Comment to post when marking as stale
markComment: >
This issue/PR has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs within 14 days.
Thank you for your contributions.

# Comment to post when closing a stale Issue or Pull Request
closeComment: >
This issue/PR has been automatically closed due to inactivity.
Please feel free to reopen if this is still relevant.

# Limit the number of actions per hour, from 1-30. Default is 30
limitPerRun: 30

# Set to true to ignore issues with an assignee
exemptAssignees: true
65 changes: 65 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CI

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

jobs:
# Primary test: conda with primesieve (the recommended install path)
test-conda:
name: conda (Python 3.10, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
defaults:
run:
shell: bash -el {0}

steps:
- uses: actions/checkout@v6

- name: Set up Miniconda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: prime-square-sum
environment-file: environment.yml
auto-activate-base: false

- name: Verify primesieve available
run: |
python -c "import primesieve; print(f'primesieve {primesieve.primesieve_version()} available')"

- name: Run tests
run: |
python -m pytest tests/ -v --tb=short

# Compatibility test: pip-only, newer Python (no primesieve, tests fallback sieve)
test-pip:
name: pip (Python ${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ['3.12']

steps:
- uses: actions/checkout@v6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install numpy pytest lark

- name: Run tests
run: |
python -m pytest tests/ -v --tb=short
42 changes: 33 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

📓 **[View the Mathematica Notebook](https://github.com/djdarcy/Prime-Square-Sum/blob/main/paper%20and%20notes/2010%20-%20Recurrence%20relation%20between%20triangular%20numbers%20and%20squared%20primes%20-%20D.%20Darcy.nb)** *(Requires [Mathematica](https://www.wolfram.com/mathematica/) or [Wolfram Player](https://www.wolfram.com/player/))*

The python program is a computational platform for validating mathematical relationships. It checks LHS expressions against RHS targets and stores sequences for future analysis. The main focus of `prime-square-sum` is on summing triangular row values together (where `stf()` is an acronym for sum triangular factors) to determine if:
The python program is a computational platform for validating mathematical relationships. It checks LHS expressions against RHS targets and stores sequences for future analysis. The main focus of `prime-square-sum` is on summing triangular row values together (where `stf()` below is an acronym for "sum triangular factors") to determine if:

![stf(b) = sum_(z=1)^qg(b) tf(b,z);](<paper and notes/function-stf-defined.png> "stf defined")

Expand All @@ -18,7 +18,7 @@ r = qg(b) = size of the base row of the triangular number; //qg(b) = 1/2(-1+sqrt
z = row in the triangular number; //ex. tf(10,4)=0123; tf(10,3)=456; tf(10,2)=78, etc.)
```

Where `tf()`, the individual triangular row factors, are defined to be:
Where `tf()`, the individual "triangular row factors", are defined to be:

![tf(b,z) = (-2 + 2b - 2b^2 + z - bz - z^2 + bz^2 + b^z(2 + 2b^2 + z + z^2 - b(2 + z + z^2))) / (2(-1 + b)^2)](<paper and notes/function-tf-defined.png> "tf defined")

Expand All @@ -41,19 +41,43 @@ Due to the huge size of the 98-digits I've further adapted `prime-square-sum` to
## Usage

```bash
# Find n where sum of first n squared primes equals 666
# Find n where sum of first n squared primes equals 666 (this is the known result: stf(10))
python prime-square-sum.py --expr "does_exist primesum(n,2) == 666"
# Output: Found: n=7 (because 2² + 3² + 5² + 7² + 11² + 13² + 17² = 666)

# Shorthand using default expression
python prime-square-sum.py --target 666
```

### The Open Question

The core investigation: does the sum of triangular row factors as `stf(666)`, the 98-digit number, equal a sum of squared, cubed, or some p-th power primes?

```bash
# The main search — does stf(666) = primesum(n, 2) for some n?
python prime-square-sum.py --expr "does_exist primesum(n,2) == trisum(666)" \
--algorithm sieve:primesieve --max n:1000000000

# The pattern may continue at a higher power — search p = 3, 4, 5
python prime-square-sum.py --expr "does_exist primesum(n,3) == trisum(666)" \
--algorithm sieve:primesieve --max n:50000000
python prime-square-sum.py --expr "does_exist primesum(n,4) == trisum(666)" \
--algorithm sieve:primesieve --max n:10000000
python prime-square-sum.py --expr "does_exist primesum(n,5) == trisum(666)" \
--algorithm sieve:primesieve --max n:5000000

# Skip early values that are too small to match a 98-digit target
python prime-square-sum.py --expr "does_exist primesum(n,p) == trisum(666)" \
--algorithm sieve:primesieve -min n:50000000 -max n:1000000000 --max p:5
```

This search requires billions of prime sums and benefits from `--algorithm sieve:primesieve` (C++ [primesieve](https://github.com/kimwalisch/primesieve) library via conda). See [Installation](#recommended-conda) for setup. The answer to this question would establish whether the chain `primesum(3,1) → stf(10) → primesum(7,2) → stf(666) → primesum(?,?)` continues — and whether it may continues indefinitely. The formal [proofs](proofs/README.md) provide the algebraic framework (closed-form `stf(b)`, verified in Lean 4), while the numerical search here would supply the concrete witness needed for induction.

The `--target` flag searches against the **default expression** `primesum(n,2)` (sum of squared primes). This default is defined in `equations.json` and can be customized via `config.json`. See [docs/equations.md](docs/equations.md) for details.

```bash
# Find matches between prime sums and triangular numbers
python prime-square-sum.py --expr "for_any primesum(n,2) == tri(m)" --max-n 100 --max-m 50
python prime-square-sum.py --expr "for_any primesum(n,2) == tri(m)" --max n:100 --max m:50

# List available functions
python prime-square-sum.py --list functions
Expand All @@ -66,7 +90,7 @@ Use standard arithmetic operators directly in expressions:
```bash
# Arithmetic in expressions
python prime-square-sum.py --expr "does_exist n**2 == 25" # n=5
python prime-square-sum.py --expr "does_exist tri(n) + 1 == 11" --max-n 10 # n=4
python prime-square-sum.py --expr "does_exist tri(n) + 1 == 11" --max n:10 # n=4
python prime-square-sum.py --expr "verify (2 + 3) * 4 == 20" # true

# Operators: + - * / // % ** ^ (unary: -x, +x)
Expand All @@ -77,14 +101,14 @@ python prime-square-sum.py --expr "verify (2 + 3) * 4 == 20" #

```bash
# Boolean logic with short-circuit evaluation
python prime-square-sum.py --expr "does_exist n > 0 and n < 10 and tri(n) == 28" --max-n 20
python prime-square-sum.py --expr "does_exist n > 0 and n < 10 and tri(n) == 28" --max n:20

# Bitwise operations via keyword operators
python prime-square-sum.py --expr "verify 5 xor 3 == 6"
python prime-square-sum.py --expr "verify 5 band 3 == 1"

# Chained comparisons
python prime-square-sum.py --expr "does_exist 1 < n < 10 and tri(n) == 28" --max-n 20
python prime-square-sum.py --expr "does_exist 1 < n < 10 and tri(n) == 28" --max n:20

# Context blocks for operator disambiguation
python prime-square-sum.py --expr "verify bit[2^3] == 1" # ^ is XOR in bit context
Expand All @@ -103,8 +127,8 @@ python prime-square-sum.py --expr "solve tri(36)" # 666
python prime-square-sum.py --expr "tri(36)" # 666 (implicit)

# Enumerate sequence values
python prime-square-sum.py --expr "solve tri(n)" --max-n 10 # n=1: 1, n=2: 3, ...
python prime-square-sum.py --expr "for_any primesum(n,2)" --max-n 7 # tabulate squared prime sums
python prime-square-sum.py --expr "solve tri(n)" --max n:10 # n=1: 1, n=2: 3, ...
python prime-square-sum.py --expr "for_any primesum(n,2)" --max n:7 # tabulate squared prime sums
```

### Verify Mode (v0.7.6+)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.1
0.8.2
2 changes: 1 addition & 1 deletion docs/equations.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Set default variable bounds in the equation:

CLI flags override equation bounds:
```bash
python prime-square-sum.py --equation tri-match --max-n 500
python prime-square-sum.py --equation tri-match --max n:500
```

## Built-in Equations
Expand Down
Loading
Loading