#!/usr/bin/env python3
"""Job #1500 prior-art channel probe (read-only, no credentials).
Channels reachable from this computer, each with a calibration query whose
known positive must come back in the same run:
* arXiv API (metadata only: title/abstract/authors, conjunctive)
* zbMATH API (bibliographic + review text; HTTP 404 = a NEGATIVE on this
API, per research/SEARCH-CONVENTIONS.md section 5)
Every raw reply is written to work/job1500-searches/ and hashed; the summary
prints one line per query with the number of hits and the first few titles.
Nothing is interpreted here: the report does the reading.
"""
import hashlib
import json
import os
import re
import time
import urllib.error
import urllib.parse
import urllib.request
HERE = os.path.dirname(os.path.abspath(__file__))
OUT = os.path.join(HERE, 'job1500-searches')
os.makedirs(OUT, exist_ok=True)
UA = 'solveathome-prior-art/1.0 (research; contact: department agent)'
ARXIV = [
# calibration
('CAL arxiv: ti:"Jacobsthal function"', 'ti:"Jacobsthal function"'),
# object: BV for the Mobius function at level 1/2
('arxiv: all:"Bombieri-Vinogradov" AND all:"Mobius function"',
'all:"Bombieri-Vinogradov" AND all:"Mobius function"'),
('arxiv: all:"level of distribution" AND all:"Mobius function"',
'all:"level of distribution" AND all:"Mobius function"'),
('arxiv: abs:"Mobius function" AND abs:"arithmetic progressions"',
'abs:"Mobius function" AND abs:"arithmetic progressions"'),
('arxiv: ti:"Bombieri-Vinogradov" AND all:"multiplicative functions"',
'ti:"Bombieri-Vinogradov" AND all:"multiplicative functions"'),
('arxiv: all:"Motohashi" AND all:"induction principle"',
'all:"Motohashi" AND all:"induction principle"'),
('arxiv: all:"prefix" AND all:"Bombieri-Vinogradov"',
'all:"prefix" AND all:"Bombieri-Vinogradov"'),
('arxiv: all:"Granville" AND all:"Shao" AND all:"Bombieri"',
'all:"Granville" AND all:"Shao" AND all:"Bombieri"'),
]
ZBMATH = [
('CAL zbmath: Jacobsthal function', 'Jacobsthal function'),
('zbmath: Moebius function arithmetic progressions Bombieri',
'Moebius function arithmetic progressions Bombieri'),
('zbmath: level of distribution Moebius function',
'level of distribution Moebius function'),
('zbmath: Bombieri-Vinogradov multiplicative functions',
'Bombieri-Vinogradov multiplicative functions'),
('zbmath: Motohashi induction principle Bombieri',
'Motohashi induction principle Bombieri'),
]
def fetch(url, tries=2, timeout=45):
last = None
for _ in range(tries):
try:
req = urllib.request.Request(url, headers={'User-Agent': UA})
with urllib.request.urlopen(req, timeout=timeout) as r:
return r.status, r.read()
except urllib.error.HTTPError as e:
return e.code, e.read()
except Exception as e: # network hiccup
last = repr(e)
time.sleep(3)
return None, last.encode()
def sha256(b):
return hashlib.sha256(b).hexdigest()
def titles(xml):
out = []
for entry in re.findall(r'