1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// Allow field reassignment with default in test code - common pattern for config building
//! # RIES-RS: Find algebraic equations given their solution
//!
//! A Rust implementation of Robert Munafo's RIES (RILYBOT Inverse Equation Solver).
//!
//! Given a numeric target value, RIES searches for algebraic equations
//! that have the target as a solution. For example, given π, it finds
//! equations like `x = π`, `x² = 10`, `sin(πx) = 0`, etc.
//!
//! ## Features
//!
//! - **Parallel search** using Rayon for multi-core speedup
//! - **Automatic differentiation** for Newton-Raphson refinement
//! - **User-defined constants and functions** via profiles
//! - **Multiple output formats**: default, pretty (Unicode), Mathematica, SymPy
//! - **Complexity scoring** to find simplest equations first
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use ries_rs::{search, GenConfig};
//!
//! let config = GenConfig::default();
//! let matches = search(2.5, &config, 10);
//!
//! // Should find equations like x = 5/2, x-2 = 1/2, etc.
//! assert!(!matches.is_empty());
//! ```
//!
//! ## Command-Line Usage
//!
//! ```bash
//! # Find equations for π
//! ries-rs 3.141592653589793
//!
//! # Higher search level (more results)
//! ries-rs 2.5 -l 5
//!
//! # Restrict to algebraic solutions
//! ries-rs 1.41421356 -a
//! ```
//!
//! ## API Levels
//!
//! The library provides three API levels:
//!
//! ### High-Level API
//!
//! Simple functions for common use cases:
//! - [`search()`] - Find equations for a target value
//!
//! ### Mid-Level API
//!
//! Configuration and control structures:
//! - [`GenConfig`](gen::GenConfig) - Configure expression generation
//! - [`SearchConfig`](search::SearchConfig) - Configure search behavior
//! - [`Match`](search::Match) - A matched equation
//!
//! ### Low-Level API
//!
//! Building blocks for custom implementations:
//! - [`Expression`](expr::Expression) - Symbolic expression representation
//! - [`Symbol`](symbol::Symbol) - Individual symbols (constants, operators)
//! - [`evaluate()`](eval::evaluate) - Evaluate expressions with derivatives
//!
//! ## Modules
//!
//! - [`eval`] - Expression evaluation with automatic differentiation
//! - [`expr`] - Expression representation and manipulation
//! - [`gen`] - Expression generation
//! - [`metrics`] - Match scoring and categorization
//! - [`pool`] - Bounded priority pool for match collection
//! - [`precision`] - Precision abstraction for numeric types
//! - [`profile`] - Profile file support for configuration
//! - [`report`] - Categorized match output
//! - [`search`] - Search algorithms and matching
//! - [`symbol`] - Symbol definitions and type system
//! - [`thresholds`] - Named threshold constants
//! - [`udf`] - User-defined functions
// WASM re-exports (when feature is enabled)
pub use ;
// =============================================================================
// Type Aliases
// =============================================================================
/// Type alias for complexity scores
///
/// Complexity scores measure how "simple" an expression is.
/// Lower values indicate simpler expressions that will be shown first.
///
/// Uses `u32` to allow for very long expressions without overflow risk,
/// though practical expressions typically have complexity < 500.
pub type Complexity = u32;
// =============================================================================
// Re-exports for convenience
// =============================================================================
// High-level API
pub use search;
pub use ;
// Fast exact match detection
pub use ;
// Common types
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use SymbolTable;
pub use UserFunction;
// Threshold constants
pub use ;
// High-precision types (when feature is enabled)
pub use ;
// Manifest types for reproducibility
pub use ;
// Structured reporting and analysis
pub use ;
pub use MatchMetrics;
pub use ;
pub use ;
pub use ;
pub use ;