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 builtinsmath.pi,math.e,math.tau→ exact-repr numeric literals**(power),+,-,*,/, unary-→ EML operatorsdef f(x: float, ...) -> float→fn f(x: Real, ...) -> Realletbindings via localname = exprlines, thenreturn expr- Top-level
MODULE_NAME = "..."overrides the inferred module name
E2 — Loops, conditionals, NumPy, C
- Fixed-iteration loop unrolling —
for i in range(N):with literal N (≤ 64) expands to a flat let-chain - Augmented assigns —
x *= y,x += yetc. lower tolet x = x * y; - Conditional flattening —
if cond: A else Band ternaryA if cond else Bbecomelerp(B, A, step01(cond)). Since EML has no native conditional, eFrog emits astep01shim into the module preamble (clamp(x * 1e30, 0, 1)). Boolean composition:and→ product of selectors,or→ 1 − product of complements,not→1 - sel. - NumPy element-wise —
np.exp/sin/...map to the same EML builtins asmath.*; aliases likenp.maximum/minimum/arcsin/...resolve tomax/min/asin/...;np.pi/np.e/np.tauinlined - C decompiler —
double f(double x) { ... }style;math.hcalls;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 / TypeScript —
function f(x) { ... }and arrow formsconst f = (x) => ….Math.exp/sin/...calls strip theMath.namespace;Math.PI/E/SQRT2/... inlined; ternaries flatten branch-free. Pure-Python esprima parser, no native deps. - Rust —
fn f(x: f64) -> f64 { … }with explicitreturnor 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 / Octave —
function y = f(x) ... end; output-var binding becomes the function's tail expression;pi/einlined;.*/.^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 fordiv/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 Nrandom 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 asys.modules['numpy']shim.--lean— emits a Lean 4 module per source: adeftranslating the EML body intoReal.exp/sin/...calls (Mathlib-style), plus twotheoremskeletons per function (<name>_chain_order,<name>_eml_consistent). Bodies are deliberatelysorry/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--verifyto confirm the rewrite preserved every value.
E4 scaffolding — The math microphone
--mic— captures--mic-durationseconds from the default input device, runs an FFT, picks the dominant non-DC bin, and emits a single-sine EML fitmic_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 innumpy+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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0746a1ec4d27faf4f25722501613f4cb32b8fbe3d0c4a48c8ee7c6f76e355d68
|
|
| MD5 |
ab1fbc0180c036e552fab3605c056c08
|
|
| BLAKE2b-256 |
b3a37ac0def475e21443b78b69a6aae1f60f6e4bbdea630f37da84991c001865
|
Provenance
The following attestation bundles were made for efrog-0.4.0.tar.gz:
Publisher:
release.yml on agent-maestro/efrog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
efrog-0.4.0.tar.gz -
Subject digest:
0746a1ec4d27faf4f25722501613f4cb32b8fbe3d0c4a48c8ee7c6f76e355d68 - Sigstore transparency entry: 1438975574
- Sigstore integration time:
-
Permalink:
agent-maestro/efrog@15c2f493fa52d126aae5f44485d4709bde14669a -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/agent-maestro
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@15c2f493fa52d126aae5f44485d4709bde14669a -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e78ba524a150c48501c0dd254e3e077b73b7bc366de52c1d76155790ebde548
|
|
| MD5 |
7891e990c2384e22cb103fd76d3c2e8a
|
|
| BLAKE2b-256 |
0f9659a9d910f4ad23cca254b6f381653eab2b211b64bc32a85c5ff7b2d4852f
|
Provenance
The following attestation bundles were made for efrog-0.4.0-py3-none-any.whl:
Publisher:
release.yml on agent-maestro/efrog
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
efrog-0.4.0-py3-none-any.whl -
Subject digest:
6e78ba524a150c48501c0dd254e3e077b73b7bc366de52c1d76155790ebde548 - Sigstore transparency entry: 1438975592
- Sigstore integration time:
-
Permalink:
agent-maestro/efrog@15c2f493fa52d126aae5f44485d4709bde14669a -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/agent-maestro
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@15c2f493fa52d126aae5f44485d4709bde14669a -
Trigger Event:
push
-
Statement type: