Research-Stack/.github/workflows/wolfram-verification.yml
Devin AI 0c9efac330 chore(consolidation): integrate E8Sidon stack (PRs #79 #80 #81 #89) into one PR
Squash the four overlapping feature branches into a single change set against
main, eliminating cross-PR merge conflicts and the duplicated CI-fix scripts.

What this brings in (merge order #79 -> #80 -> #81 -> #89):
- #79 refactor(infra): shared utilities (4-Infrastructure/lib/*: q16, hashing,
  jsonl, fraction_utils) + the scripts/math-first/* validators that the
  math-check CI requires.
- #80 feat(lean): Semantics.E8Sidon (1025 lines) -- Eisenstein coefficient
  identity E4^2 = E8 and the Sidon framework. E4_sq_eq_E8_coeff is fully proved
  (all Fourier-coefficient extraction machine-checked); the single residual gap
  is pinned to E4_sq_eq_E8_qExpansion (Mathlib lacks the valence formula /
  dim M8 = 1). 4 sorries + 1 axiom (e8_additive_completeness), all TODO(lean-port).
- #81 refactor(lean): Float-free FixedPoint core (integer-only sqrt/log2/expNeg).
  E8Sidon.lean kept at #80's final 1025-line version (the #81 intermediate
  438-line copy was overridden by merge order).
- #89 feat(lean): Semantics.RRC.PolyFactorIdentity -- short-sleeve polynomial
  detection at the zerocopy limb boundary; now imports Semantics.E8Sidon for
  sigma3/sigma7/convolutionLHS (single source of truth) instead of inlining them.

Conflict resolution:
- flake.nix -> canonical rs-surface removal (Garnix shutdown).
- scripts/math-first/* -> byte-identical across branches, clean.
- .cursorrules / AGENTS.md -> unified; baselines + sorry inventory refreshed.

Verification:
- lake build (default aggregator): 3573 jobs, 0 errors.
- lake build Semantics.RRC.PolyFactorIdentity (E8Sidon + FixedPoint + PolyFactor):
  3655 jobs, 0 errors. Witnesses verified (sigma7 4 = 16513, convolutionLHS 6 = 2350).
- Python tests: 68/68 pass.

Note: the "Workers Builds: researchstack" check is a preexisting external
Cloudflare build unrelated to this change (no branch touches 4-Infrastructure/cloudflare/).

Build: 3573 jobs (default), 3655 jobs (narrow), 0 errors
Co-Authored-By: Allaun Silverfox <bigdataiscoming+9i37y6j2@protonmail.com>
2026-06-16 02:01:31 +00:00

143 lines
5.5 KiB
YAML

name: Wolfram Alpha Verification Check
on:
pull_request:
paths:
- '0-Core-Formalism/lean/Semantics/**/*.lean'
- '0-Core-Formalism/lean/Semantics/AGENTS.md'
- '6-Documentation/docs/AGENTS.md'
push:
paths:
- '0-Core-Formalism/lean/Semantics/**/*.lean'
- '0-Core-Formalism/lean/Semantics/AGENTS.md'
- '6-Documentation/docs/AGENTS.md'
permissions:
contents: read
pull-requests: write
jobs:
wolfram-verification:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Find changed Lean files
id: changed-files
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
git diff --name-only origin/${{ github.base_ref }}...HEAD > /tmp/changed_files.txt
else
git diff --name-only HEAD~1 HEAD > /tmp/changed_files.txt
fi
# Filter for Lean files in Semantics
grep '^0-Core-Formalism/lean/Semantics/.*\.lean$' /tmp/changed_files.txt > /tmp/lean_files.txt || true
if [ -s /tmp/lean_files.txt ]; then
echo "changed=true" >> $GITHUB_OUTPUT
{
echo "files<<EOF"
cat /tmp/lean_files.txt
echo "EOF"
} >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Check for mathematical formulas needing verification
if: steps.changed-files.outputs.changed == 'true'
run: |
python3 << 'EOF'
import re
import sys
# Read changed files
with open('/tmp/lean_files.txt', 'r') as f:
files = [line.strip() for line in f if line.strip()]
# Patterns that indicate mathematical formulas
math_patterns = [
r'Q16_16\.pow', # Power operations
r'Q16_16\.sqrt', # Square root
r'Q16_16\.sin', # Trigonometric
r'Q16_16\.ln', # Logarithm
r'Q16_16\.log2', # Logarithm
r'Q16_16\.expNeg', # Exponential
r'cross\s*\(', # Cross product
r'dot\s*\(', # Dot product
r'magnitude', # Magnitude calculations
r'normalize', # Normalization
r'exp\s*\(', # Exponential
r'log\s*\(', # Logarithm
r'sin\s*\(', # Trigonometric
r'cos\s*\(', # Trigonometric
r'tan\s*\(', # Trigonometric
]
# Check each file
violations = []
for file_path in files:
with open(file_path, 'r') as f:
content = f.read()
lines = content.split('\n')
# Find functions with mathematical operations
for i, line in enumerate(lines, 1):
for pattern in math_patterns:
if re.search(pattern, line):
# Check if Wolfram Alpha verification comment exists nearby
# Look in the current line and next 3 lines
verification_found = False
for j in range(max(0, i-2), min(len(lines), i+3)):
if 'Verified with Wolfram Alpha' in lines[j] or 'wolfram-verify' in lines[j]:
verification_found = True
break
if not verification_found:
violations.append(f"{file_path}:{i}")
break
if violations:
print("❌ Wolfram Alpha verification missing for mathematical formulas:")
for v in violations:
print(f" - {v}")
print("\nPlease add verification comments like:")
print(" -- Verified with Wolfram Alpha: formula matches standard quaternion multiplication")
print("Or mark with TODO if verification is deferred:")
print(" -- TODO(wolfram-verify): domain-specific operation")
sys.exit(1)
else:
print("✅ All mathematical formulas have Wolfram Alpha verification")
EOF
- name: Comment on PR if violations found
if: failure() && github.event_name == 'pull_request'
uses: actions/github-script@v9
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## ⚠️ Wolfram Alpha Verification Missing
This PR introduces mathematical formulas without Wolfram Alpha verification.
Please add verification comments to your code:
\`\`\`lean
-- Verified with Wolfram Alpha: formula matches standard quaternion multiplication
def myFormula (x : Q16_16) : Q16_16 := ...
\`\`\`
Or mark with TODO if verification is deferred:
\`\`\`lean
-- TODO(wolfram-verify): domain-specific operation
def customOp (x : Q16_16) : Q16_16 := ...
\`\`\`
See [AGENTS.md Section 5.1](6-Documentation/docs/AGENTS.md) for details.`
})