graphlang / paper /figures.py
Jose-dev's picture
Upload folder using huggingface_hub
9b0c4ec verified
Raw
History Blame Contribute Delete
4.43 kB
#!/usr/bin/env python3
"""
Figure 1: Language Coverage Map (9 languages → 12 IR kinds)
Figure 2: Compression Stability (1.5K → 10M functions)
For: "GraphLang: A Semantic Compression Layer Achieving 22.5x Reduction
Across 9 Programming Languages" — ArXiv 2026
"""
import json
# ═══ FIGURE 1: Language Coverage ═══════════════════════════════════════
COVERAGE = {
"Python": {"cst": 238, "ir_pct": 100, "status": "Production"},
"Java": {"cst": 296, "ir_pct": 100, "status": "Production"},
"JavaScript": {"cst": 242, "ir_pct": 100, "status": "Production"},
"TypeScript": {"cst": 250, "ir_pct": 100, "status": "Production"},
"C#": {"cst": 220, "ir_pct": 100, "status": "Production"},
"Rust": {"cst": 290, "ir_pct": 100, "status": "Production"},
"Go": {"cst": 199, "ir_pct": 100, "status": "Production"},
"C": {"cst": 180, "ir_pct": 93, "status": "Stabilized"},
"C++": {"cst": 300, "ir_pct": 93, "status": "Stabilized"},
}
print("=" * 72)
print("FIGURE 1: Language Coverage Map")
print("=" * 72)
print()
print(f"{'Language':<14s} {'CST Types':>10s} {'IR Cov':>8s} {'Status':<14s}")
print("-" * 50)
total_cst = 0
for lang, data in COVERAGE.items():
total_cst += data["cst"]
bar = "█" * (data["ir_pct"] // 5) + ("░" if data["ir_pct"] < 100 else "")
print(f"{lang:<14s} {data['cst']:>8d} {data['ir_pct']:>3d}% {bar:20s} {data['status']:<14s}")
print("-" * 50)
avg_cov = sum(d["ir_pct"] for d in COVERAGE.values()) / len(COVERAGE)
print(f"{'TOTAL':<14s} {total_cst:>8d} {avg_cov:.0f}% avg → 12 IR kinds")
print()
# ═══ FIGURE 2: Compression Stability ══════════════════════════════════
BENCHMARKS = [
(1500, 33387, 1197, 27.9, 1.1),
(100000, 2172203, 96504, 22.5, 40.0),
(1000000, 21721250, 965048, 22.5, 20.0),
(10000000, 217210967, 9649257, 22.5, 203.0),
]
print("=" * 72)
print("FIGURE 2: Compression Stability Across Scale")
print("=" * 72)
print()
print(f"{'Functions':>12s} {'Nodes':>12s} {'Unique':>10s} {'Ratio':>8s} {'Time':>8s}")
print("-" * 55)
for funcs, nodes, unique, ratio, secs in BENCHMARKS:
print(f"{funcs:>10,d} {nodes:>10,d} {unique:>8,d} {ratio:>4.1f}x {secs:>5.0f}s")
print("-" * 55)
print(f"{'Converges at':>12s} {'22.5x from':>24s} {'100K to':>18s} {'10M':>8s}")
print()
# ═══ FIGURE 3: IR Kind Distribution (10M benchmark) ═══════════════════
KINDS_10M = {
"var": 62403662,
"const": 46315782,
"block": 27543852,
"return": 19999998,
"binop": 18947367,
"args": 10000002,
"function": 10000002,
"module": 10000002,
"if": 9824558,
"unary": 1578948,
}
print("=" * 72)
print("FIGURE 3: IR Kind Distribution (10M functions)")
print("=" * 72)
print()
max_count = max(KINDS_10M.values())
for kind, count in sorted(KINDS_10M.items(), key=lambda x: -x[1]):
bar_len = int(count / max_count * 50)
bar = "█" * bar_len
pct = count / sum(KINDS_10M.values()) * 100
print(f" {kind:12s} {count:>12,d} {bar} {pct:.0f}%")
print()
print(f" {'TOTAL':12s} {sum(KINDS_10M.values()):>12,d}")
print()
# ═══ PAPER METADATA ═══════════════════════════════════════════════════
print("=" * 72)
print("PAPER METADATA")
print("=" * 72)
print(f"""
Title: GraphLang: A Semantic Compression Layer Achieving 22.5x
Reduction Across 9 Programming Languages
Author: Josué Argaña
Date: July 2026
Repo: github.com/cripto-bot/graphlang
Key Claims:
1. 12 universal IR kinds capture complete computational intent
across 9 programming languages (7 at 100%, 2 at 93%).
2. Compression ratio of 22.5x is mathematically stable from
100K to 10M functions — converges, not degrades.
3. Cross-language equivalence of 97% is achievable through
CST normalization alone, without ML or heuristics.
4. The 12 IR kinds are finite and complete: only 16 structurally
unique ways to write an if statement exist across all languages.
Suggested Venues: ICSE 2027, OOPSLA 2027, PLDI 2027
Target: Tools & Demonstrations track (with live benchmark)
""")