#!/usr/bin/env python3 """lit652.py -- job #652. Prior art for the central object of return #101 (Proposition 6 of research/fold-arithmetic-bridge.md: the all-depth sub-2 certificate). Fetches each source once, prints its sha256, and prints the short excerpt that carries each statement the certificate imports, with its locator. Stdout depends only on the bytes the served copies return, and every source is hashed, so a reviewer sees at once whether a copy moved. python lit652.py # ~40 s, one core, ~3 MB down; writes the fetched copies, executes nothing Requires pdftotext (poppler). Nothing fetched here is executed. Excerpts are short attributed quotations, printed as the locator of a statement, not reproduced in bulk. """ import hashlib import io import re import subprocess import urllib.parse import urllib.request UA = {'User-Agent': 'buffy-agent (freebuff)'} SOURCES = { 'wu-0705.1652v1.pdf': 'https://arxiv.org/pdf/0705.1652v1', 'motohashi-lectures.pdf': ('https://www.math.utoledo.edu/~codenth/Spring_13/3200/NT-books/' 'Lectures_on_Sieve_Methods_and_Prime_Number_Theory-Motohashi.pdf'), 'franze-1012.3809v1.html': 'https://arxiv.org/html/1012.3809v1', } def fetch(name, url): d = urllib.request.urlopen(urllib.request.Request(url, headers=UA), timeout=180).read() io.open(name, 'wb').write(d) print('%-28s %9d bytes sha256 %s' % (name, len(d), hashlib.sha256(d).hexdigest())) return d def pages_of(pdf): out = subprocess.run(['pdftotext', '-layout', pdf, '-'], capture_output=True).stdout return out.decode('utf-8', 'replace').split('\f') def show(pages, page_no, pattern, label, clip=170): """Print the first line of that PDF page matching the pattern -- the locator, not the payload.""" if page_no > len(pages): print(' %-34s page %d beyond the file' % (label, page_no)) return for i, line in enumerate(pages[page_no - 1].split('\n')): if re.search(pattern, line): s = re.sub(r'\s+', ' ', line.strip()).encode('ascii', 'replace').decode() print(' %-34s pdf p.%d L%-4d %s' % (label, page_no, i + 1, s[:clip])) return print(' %-34s pdf p.%d NOT MATCHED' % (label, page_no)) print("== 1. Wu, Acta Arith. 114 (2004) 215-273 = arXiv:0705.1652v1, the record's own carrier ==") fetch('wu-0705.1652v1.pdf', SOURCES['wu-0705.1652v1.pdf']) wu = pages_of('wu-0705.1652v1.pdf') print(' pdf pages %d' % len(wu)) show(wu, 6, r'F \(u\) = 2e/u', 'the delay equations (2.6)', 120) show(wu, 6, r'\(uF \(u\)\) = f \(u - 1\)', ' their second line', 120) show(wu, 6, r'\bF, f are defined\b', ' the sentence introducing them', 120) print() print('== 2. Motohashi, Lectures on Sieve Methods and Prime Number Theory (free PDF) ==') fetch('motohashi-lectures.pdf', SOURCES['motohashi-lectures.pdf']) mo = pages_of('motohashi-lectures.pdf') print(' pdf pages %d' % len(mo)) show(mo, 83, r'0\(s\) = 0 for 0 < s', '(3.2.10), printed p. 85', 150) show(mo, 159, r'1\(s\) = 2e/s for s', 'the (6.1.21) region', 150) print() print('== 3. Franze, Sifting Limits for the Lambda^2Lambda^- Sieve (arXiv:1012.3809v1) ==') d = fetch('franze-1012.3809v1.html', SOURCES['franze-1012.3809v1.html']) h = d.decode('utf-8', 'replace') t = re.sub(r'|', ' ', h, flags=re.S) t = re.sub(r'<[^>]+>', ' ', t) t = re.sub(r' ?', ' ', t) t = re.sub(r'\s+', ' ', t) def quote(pattern, label, clip=210): m = re.search(pattern, t) s = (m.group(0) if m else 'NOT MATCHED').encode('ascii', 'replace').decode() print(' %-26s %s' % (label, s[:clip])) quote(r'An important parameter in a sieve is the[^.]*\.', 'sifting limit, defined') quote(r'The calculations in Chapter 17 of[^.]*\.', 'DHR sifting limit') quote(r'DHR[^0-9]{0,24}4\.266', 'DHR beta_2 in Table 1', 120) quote(r'4\.516', 'Selberg beta_2', 90) quote(r'Recently, Sara Blight[^.]*\.', 'Blight, better at kappa=2?', 200) print() print('== 4. MathSciNet mrlookup (free bibliographic channel; fields only, no review text) ==') for q in ({'ti': "Rosser's sieve", 'au': 'Iwaniec'}, {'ti': 'sifting limits'}, {'au': 'Jurkat', 'ti': 'selberg'}, {'ti': 'Rosser sieve', 'au': 'Coleman'}): data = urllib.parse.urlencode(dict(q, format='bibtex')).encode() hh = urllib.request.urlopen(urllib.request.Request( 'https://mathscinet.ams.org/mrlookup', data=data, headers={ 'User-Agent': 'Mozilla/5.0 (compatible; buffy-agent)', 'Content-Type': 'application/x-www-form-urlencoded'}), timeout=120).read().decode('utf-8', 'replace') txt = re.sub(r'<[^>]+>', ' ', hh) txt = re.sub(r'\s+', ' ', txt) got = re.search(r'Retrieved (?:first \d+ documents out of |all documents out of )?(\d+|all documents)', txt) ids = re.findall(r'MRNUMBER = \{(\d+)\}', txt) titles = re.findall(r'TITLE = \{(.*?)\},', txt) print(' %-40s -> %-4s MR %s' % (str(q), got.group(1) if got else '?', ids[:4])) for x in titles[:3]: print(' %s' % x.encode('ascii', 'replace').decode()[:110])