Skip to main content

Universal decompiler for the EML substrate — Forge spelled backwards. Anything → EML.

Project description

eFrog — universal decompiler for the EML substrate

Forge compiles math into everything. eFrog compiles everything into math.

pip install efrog (pre-release)

eFrog reads source files (and eventually sound, sensors, and shaders) and extracts the underlying mathematical structure as EML — the same intermediate language Monogate Forge emits into. eFrog is the reverse direction: every input becomes an EML tree you can profile, classify against a corpus of canonical math patterns, optimize, and re-compile to any of Forge's targets.

What's shipped (E1 + E2 + E2.5 + early E3 + E4 scaffolding)

efrog gaussian.py              # Python AST → EML
efrog gaussian.c               # C (math.h) → EML, via pycparser
efrog gaussian.js              # JavaScript / TypeScript → EML, via esprima
efrog gaussian.rs              # Rust → EML, hand-rolled parser
efrog gaussian.m               # MATLAB / Octave → EML, hand-rolled parser

efrog --profile  gaussian.py   # per-fn chain order, drift risk, node count
efrog --verify   gaussian.py   # round-trip the EML, sample N inputs, prove
                               # bit-exact agreement with the original
efrog --genome   gaussian.py   # classify each fn against a small corpus
                               # (gaussian / sigmoid / softplus / polynomial …)
efrog --lean     gaussian.py   # emit Lean 4 theorem skeletons
efrog --optimize gaussian.py   # conservative algebraic simplifier
                               # (x+0, x*1, exp(0), x**2 → x*x, …)
efrog --mic                    # capture audio, FFT, emit single-sine EML

A typical extraction looks like this:

module gaussian;

fn gaussian(mu: Real, sigma: Real, x: Real) -> Real
    where chain_order <= 1
{
    let dx = x - mu;
    exp(-dx * dx / (2.0 * sigma * sigma)) / sigma
}

E1 — Python pure math

  • math.exp/log/sqrt/sin/cos/tan/asin/acos/atan/sinh/cosh/tanh/pow/fabs → EML builtins
  • math.pi, math.e, math.tau → exact-repr numeric literals
  • ** (power), +, -, *, /, unary - → EML operators
  • def f(x: float, ...) -> floatfn f(x: Real, ...) -> Real
  • let bindings via local name = expr lines, then return expr
  • Top-level MODULE_NAME = "..." overrides the inferred module name

E2 — Loops, conditionals, NumPy, C

  • Fixed-iteration loop unrollingfor i in range(N): with literal N (≤ 64) expands to a flat let-chain
  • Augmented assignsx *= y, x += y etc. lower to let x = x * y;
  • Conditional flatteningif cond: A else B and ternary A if cond else B become lerp(B, A, step01(cond)). Since EML has no native conditional, eFrog emits a step01 shim into the module preamble (clamp(x * 1e30, 0, 1)). Boolean composition: and → product of selectors, or → 1 − product of complements, not1 - sel.
  • NumPy element-wisenp.exp/sin/... map to the same EML builtins as math.*; aliases like np.maximum/minimum/arcsin/... resolve to max/min/asin/...; np.pi/np.e/np.tau inlined
  • C decompilerdouble f(double x) { ... } style; math.h calls; M_PI/M_E/M_SQRT2/etc. constants; compound assigns (y *= x); cast strip ((double) n); f(void) parameter lists. Uses pycparser; no preprocessor required (we strip #-lines and comments)

E2.5 — JavaScript, Rust, MATLAB

  • JavaScript / TypeScriptfunction f(x) { ... } and arrow forms const f = (x) => …. Math.exp/sin/... calls strip the Math. namespace; Math.PI/E/SQRT2/... inlined; ternaries flatten branch-free. Pure-Python esprima parser, no native deps.
  • Rustfn f(x: f64) -> f64 { … } with explicit return or trailing tail expression; let (incl. let mut) bindings; compound assigns; method-call lowering (x.exp()exp(x), x.powf(2.0)pow(x, 2.0)); associated-function form (f64::sqrt(x)); path constants (std::f64::consts::PI).
  • MATLAB / Octavefunction y = f(x) ... end; output-var binding becomes the function's tail expression; pi/e inlined; .*/.^ treated as scalar; % and # comments; ... line continuation.

E3 partial — Numerical round-trip + Lean scaffolding + per-fn profile

  • --profile — per-fn chain order, transcendental count, node count, drift-risk hint (low/medium/high), and flags for div/sub (the two ops most commonly responsible for fp64 cancellation).
  • --verify — re-emits the decompiled EML as runnable Python via a self-contained primitive shim (no Forge install needed), samples --samples N random inputs per parameter using sane per-name domains (sigma → positive, omega → [0, 2π], ...), runs both the original and the round-trip on every sample, and reports max relative error. PASS if every sample agrees to within 1e-9 relative. The NumPy-using examples work without numpy installed thanks to a sys.modules['numpy'] shim.
  • --lean — emits a Lean 4 module per source: a def translating the EML body into Real.exp/sin/... calls (Mathlib-style), plus two theorem skeletons per function (<name>_chain_order, <name>_eml_consistent). Bodies are deliberately sorry / trivial — these are the scaffolds the MonogateEML proof sprint discharges.
  • --genome — classifies every decompiled function against a small curated corpus of canonical math landmarks (gaussian, sigmoid, softplus, ReLU, sinusoid, polynomial, …) with a structural similarity score (Jaccard over transcendentals + helpers + binops, weighted with a chain-order penalty). The full SuperBEST corpus ships separately.

E5 partial — Algebraic simplifier

  • --optimize — conservative bottom-up rewriter with fixed-point iteration. Safe identities only: x + 0 → x, x * 1 → x, x * 0 → 0, -(-x) → x, x + x → 2*x, pow(x, 2) → x*x, exp(0) → 1, log(1) → 0, sin(0) → 0, cos(0) → 1, sqrt(0/1) → 0/1, plus constant folding for two-literal binops. Pair with --verify to confirm the rewrite preserved every value.

E4 scaffolding — The math microphone

  • --mic — captures --mic-duration seconds from the default input device, runs an FFT, picks the dominant non-DC bin, and emits a single-sine EML fit mic_signal(t) = A * sin(2π f t + φ) plus amplitude / phase / SNR diagnostics. Multi-tone, harmonic, and envelope decomposition land in full E4. pip install efrog[mic] pulls in numpy + sounddevice.

Coming

Phase What When
E3-full Lean theorem generation (BFS proof attacks) month 4–6
E4-full Multi-tone / harmonic / envelope decomposition month 6–8
E5-full Universal optimizer pipe (CSE, trig identities) month 6–8
E6 Sensor expansion (camera / stethoscope / ...) month 8+

Full roadmap: monogate-research/products/software/efrog/ROADMAP.md.

Status

174 tests green. Five source languages (Python, C, JavaScript, Rust, MATLAB). Loops, ternaries, branch-free conditionals, NumPy aliases, per-function profiling, bit-exact numerical round-trip, Lean 4 scaffolding, genome classification, algebraic simplification, and single-sine audio fit all working. while loops, comprehensions, classes, real vector operations, pointers, arrays, structs, and multi-output MATLAB functions still raise honest "not supported, see ROADMAP.md" errors.

License

Apache 2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

efrog-0.4.0.tar.gz (60.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

efrog-0.4.0-py3-none-any.whl (56.2 kB view details)

Uploaded Python 3

File details

Details for the file efrog-0.4.0.tar.gz.

File metadata

  • Download URL: efrog-0.4.0.tar.gz
  • Upload date:
  • Size: 60.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for efrog-0.4.0.tar.gz
Algorithm Hash digest
SHA256 0746a1ec4d27faf4f25722501613f4cb32b8fbe3d0c4a48c8ee7c6f76e355d68
MD5 ab1fbc0180c036e552fab3605c056c08
BLAKE2b-256 b3a37ac0def475e21443b78b69a6aae1f60f6e4bbdea630f37da84991c001865

See more details on using hashes here.

Provenance

The following attestation bundles were made for efrog-0.4.0.tar.gz:

Publisher: release.yml on agent-maestro/efrog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file efrog-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: efrog-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 56.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for efrog-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6e78ba524a150c48501c0dd254e3e077b73b7bc366de52c1d76155790ebde548
MD5 7891e990c2384e22cb103fd76d3c2e8a
BLAKE2b-256 0f9659a9d910f4ad23cca254b6f381653eab2b211b64bc32a85c5ff7b2d4852f

See more details on using hashes here.

Provenance

The following attestation bundles were made for efrog-0.4.0-py3-none-any.whl:

Publisher: release.yml on agent-maestro/efrog

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page