Expand description
DSLCompile
: Mathematical Expression Compilation
DSLCompile
provides a three-layer optimization strategy for mathematical expressions:
- Final Tagless Approach: Type-safe expression building with multiple interpreters
- Symbolic Optimization: Algebraic simplification using egglog
- Compilation Backends: Rust hot-loading (primary) and optional Cranelift JIT
§Typed Variable System
The library includes a type-safe variable system that provides compile-time type checking with operator overloading syntax and full backward compatibility.
§Quick Start with Typed Variables
use dslcompile::prelude::*;
// Create a typed math builder
let math = MathBuilder::new();
// Create typed variables
let x: TypedVar<f64> = math.typed_var();
let y: TypedVar<f32> = math.typed_var();
// Build expressions with syntax and type safety
let x_expr = math.expr_from(x);
let y_expr = math.expr_from(y);
let expr = &x_expr * &x_expr + y_expr; // f32 auto-promotes to f64
// Backward compatible API still works
let old_style = math.var(); // Defaults to f64
§Architecture
┌─────────────────────────────────────────────────────────────┐
│ Final Tagless Layer │
│ (Expression Building & Type Safety) │
└─────────────────────┬───────────────────────────────────────┘
│
┌─────────────────────▼───────────────────────────────────────┐
│ Symbolic Optimization │
│ (Algebraic Simplification & Rewrite Rules) │
└─────────────────────┬───────────────────────────────────────┘
│
┌─────────────────────▼───────────────────────────────────────┐
│ Compilation Backends │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ Rust │ │ Cranelift │ │ Future Backends │ │
│ │ Hot-Loading │ │ JIT │ │ (LLVM, etc.) │ │
│ │ (Primary) │ │ (Optional) │ │ │ │
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
Re-exports§
pub use error::DSLCompileError;
pub use error::Result;
pub use expr::Expr;
pub use final_tagless::ASTEval;
pub use final_tagless::ASTMathExpr;
pub use final_tagless::ASTRepr;
pub use final_tagless::DirectEval;
pub use final_tagless::MathBuilder;
pub use final_tagless::MathExpr;
pub use final_tagless::NumericType;
pub use final_tagless::PrettyPrint;
pub use final_tagless::StatisticalExpr;
pub use final_tagless::TypeCategory;
pub use final_tagless::TypedBuilderExpr;
pub use final_tagless::TypedVar;
pub use final_tagless::VariableRegistry;
pub use symbolic::symbolic::CompilationApproach;
pub use symbolic::symbolic::CompilationStrategy;
pub use symbolic::symbolic::OptimizationConfig;
pub use symbolic::symbolic::SymbolicOptimizer;
pub use symbolic::anf;
pub use backends::CompiledRustFunction;
pub use backends::RustCodeGenerator;
pub use backends::RustCompiler;
pub use backends::RustOptLevel;
pub use symbolic::summation::SumResult;
pub use symbolic::summation::SummationConfig;
pub use symbolic::summation::SummationPattern;
pub use symbolic::summation::SummationSimplifier;
pub use symbolic::anf::ANFAtom;
pub use symbolic::anf::ANFCodeGen;
pub use symbolic::anf::ANFComputation;
pub use symbolic::anf::ANFConverter;
pub use symbolic::anf::ANFExpr;
pub use symbolic::anf::ANFVarGen;
pub use symbolic::anf::DomainAwareANFConverter;
pub use symbolic::anf::DomainAwareOptimizationStats;
pub use symbolic::anf::VarRef;
pub use symbolic::anf::convert_to_anf;
pub use symbolic::anf::generate_rust_code;
Modules§
- ast
- AST (Abstract Syntax Tree) Module
- backends
- Compilation Backends for
DSLCompile
- compile_
time - Compile-Time Mathematical Expression System
- error
- Error types for
DSLCompile
- expr
- Ergonomic wrapper for final tagless expressions with operator overloading
- final_
tagless - Final Tagless Mathematical Interpreter System
- interval_
domain - Interval-based domain analysis with endpoint specification Interval-Based Domain Analysis
- polynomial
- prelude
- Prelude module for imports
- symbolic
Constants§
- VERSION
- Version information for the
DSLCompile
library