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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
//! Canonical symbols for the number-domain family.
//!
//! Concrete number crates should import these helpers instead of spelling
//! `Symbol::qualified("numbers", "...")` locally. Keeping the symbols in one
//! place makes promotion edges auditable: a typo cannot silently create an
//! unreachable domain.
//!
//! # Promotion lattice
//!
//! The default number prelude installs a directed promotion graph. Literal
//! promotion rules are a fast path; every edge that participates in dispatch
//! also has a value-promotion rule so opaque number values can move through the
//! same lattice.
//!
//! Intended scalar reachability:
//!
//! - `bool -> u8 -> ...`, plus direct `bool -> i64` and `bool -> f64` edges.
//! - Signed fixed-width integers widen through `i8 -> i16 -> i32 -> i64 ->
//! i128`; unsigned fixed-width integers widen through `u8 -> u16 -> u32 ->
//! u64 -> u128` and can cross to the next wider signed domain.
//! - Fixed-width integers reach `f32`, `f64`, and `rational`; `i64` also
//! provides direct `i64 -> f64` and `i64 -> rational` edges.
//! - `bigint` is the arbitrary-precision integer domain and reaches
//! `rational`.
//! - `f32 -> f64`; `f64 <-> rational` when decimal rationalization succeeds.
//! - `i64`, `f64`, and `rational` reach `complex`; `complex` is the scalar
//! numeric sink before symbolic, function, or tensor lifting.
//! - `cas` absorbs scalar domains through value promotion so symbolic
//! arithmetic can mix CAS values with installed numeric domains.
//! - `tensor` is value-only; tensor broadcast and typed tensor fast paths use
//! explicit value descriptors rather than scalar promotion.
use Symbol;
/// Build a symbol in the canonical `numbers` namespace.
/// The `numbers/arith` symbol: the cross-domain arithmetic op namespace.
/// The `numbers/bool` domain symbol.
/// The `numbers/i8` domain symbol.
/// The `numbers/u8` domain symbol.
/// The `numbers/i16` domain symbol.
/// The `numbers/u16` domain symbol.
/// The `numbers/i32` domain symbol.
/// The `numbers/u32` domain symbol.
/// The `numbers/i64` domain symbol.
/// The `numbers/u64` domain symbol.
/// The `numbers/i128` domain symbol.
/// The `numbers/u128` domain symbol.
/// The `numbers/isize` domain symbol.
/// The `numbers/usize` domain symbol.
/// The `numbers/f32` domain symbol.
/// The `numbers/f64` domain symbol.
/// The `numbers/fixed` fixed-point domain symbol.
/// The `numbers/bigint` arbitrary-precision integer domain symbol.
/// The `numbers/rational` domain symbol.
/// The `numbers/complex` domain symbol (the scalar numeric sink).
/// The `numbers/cf` continued-fraction domain symbol.
/// The `numbers/cas` symbolic (computer-algebra) domain symbol.
/// The `numbers/cas-diff` symbolic-differentiation domain symbol.
/// The `numbers/cas-eval` symbolic-evaluation domain symbol.
/// The `numbers/func` function-value domain symbol.
/// The `numbers/tensor` domain symbol (value-only lift over scalar domains).
/// The `numbers/tensor-bcast` broadcasting tensor domain symbol.
/// The `numbers/tensor-linalg` linear-algebra tensor domain symbol.
/// The `numbers/numeric` namespace symbol for numeric utilities.
/// The `numbers/quad` quadrature (numeric integration) domain symbol.
/// The `numbers/rk` Runge-Kutta (numeric ODE) domain symbol.
/// The literal-class symbol for a domain, e.g. `numbers/i64-literal`.
///
/// # Examples
///
/// ```
/// use sim_lib_numbers_core::domains;
///
/// assert_eq!(
/// domains::literal_class("i64"),
/// domains::domain("i64-literal"),
/// );
/// ```
/// The value-shape symbol for `domain`, e.g. `numbers/i64/value-shape`.
/// The `numbers/Rational` value-class symbol.
/// The `numbers/Complex` value-class symbol.
/// The `numbers/Cas` value-class symbol.
/// The `numbers/Tensor` value-class symbol.
/// All fixed-width integer domain symbols (`i8`..`usize`), in lattice order.
/// All integer domain symbols: the fixed-width set plus `numbers/bigint`.
///
/// # Examples
///
/// ```
/// use sim_lib_numbers_core::domains;
///
/// let ints = domains::integer_domains();
/// assert_eq!(ints.len(), domains::fixed_integer_domains().len() + 1);
/// assert!(ints.contains(&domains::bigint()));
/// ```