eml_core/lib.rs
1//! EML (exp-ln) universal function approximation.
2//!
3//! This crate provides the EML operator and learning machinery for
4//! O(1) learned functions from data. Based on Odrzywolel 2026,
5//! "All elementary functions from a single operator".
6//!
7//! # Core Idea
8//!
9//! The EML operator `eml(x, y) = exp(x) - ln(y)` is the continuous-
10//! mathematics analog of the NAND gate: combined with the constant 1,
11//! it can reconstruct all elementary functions.
12//!
13//! # Components
14//!
15//! - [`eml`] / [`eml_safe`] / [`softmax3`] — primitive operators
16//! - [`EmlTree`] — depth-configurable evaluation tree
17//! - [`EmlModel`] — multi-head model with training
18//! - [`FeatureVector`] — trait for types that produce `&[f64]` inputs
19//!
20//! # Example
21//!
22//! ```
23//! use eml_core::EmlModel;
24//!
25//! // Create a depth-4 model with 3 inputs and 1 output head
26//! let mut model = EmlModel::new(4, 3, 1);
27//!
28//! // Record training data (y = x0 + x1 + x2)
29//! for i in 0..100 {
30//! let x = [i as f64 / 100.0, i as f64 / 50.0, i as f64 / 200.0];
31//! let y = x[0] + x[1] + x[2];
32//! model.record(&x, &[Some(y)]);
33//! }
34//!
35//! // Train
36//! let _converged = model.train();
37//!
38//! // Predict
39//! let prediction = model.predict_primary(&[0.5, 1.0, 0.25]);
40//! assert!(prediction.is_finite());
41//! ```
42
43pub mod events;
44pub mod features;
45pub mod model;
46pub mod operator;
47pub mod tree;
48
49#[cfg(feature = "experimental-attention")]
50pub mod attention;
51#[cfg(feature = "experimental-attention")]
52pub mod baseline_attention;
53
54// Re-export public API
55pub use events::{EmlEvent, EmlEventLog};
56pub use features::FeatureVector;
57pub use model::EmlModel;
58pub use operator::{eml, eml_safe, softmax3};
59pub use tree::EmlTree;
60
61#[cfg(feature = "experimental-attention")]
62pub use attention::{
63 run_benchmark, run_benchmark_with_trials, AttentionBenchmark, AttentionError,
64 EndToEndTrainConfig, SafeTree, ScalingPoint, ToyEmlAttention, MAX_TOY_D_MODEL,
65 MAX_TOY_SEQ_LEN,
66};
67#[cfg(feature = "experimental-attention")]
68pub use baseline_attention::{
69 compare_eml_vs_baseline, AttentionComparison, BaselineAttention,
70};