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
//! # symcas - Fast, deterministic computer algebra system in Rust
//!
//! Core features: canonical expression representation (arena + hash-consing),
//! deterministic total order, plain / LaTeX formatting, and roundtrip parsing.
//! Polynomial kernel, differentiation, series expansion, and simplification.
//!
//! # Example 1: Construction and Canonical Form
//!
//! ```
//! use symcas::prelude::*;
//!
//! let ctx = Context::new();
//! let x = ctx.sym("x");
//! let y = ctx.sym("y");
//!
//! // Operator overloading constructs canonical forms: flattening, ordering,
//! // exact arithmetic folding, and term combination happen immediately.
//! let e = (x.clone() + y.clone()).pow(3) - x.clone().pow(3) - y.clone().pow(3);
//! assert_eq!(symcas::plain(&ctx, &e), "(x + y)^3 - x^3 - y^3");
//!
//! // 同一数学内容的两条构造路径落在同一节点(hash-consing)
//! let a = x.clone() + x.clone();
//! let b = ctx.int(2) * x.clone();
//! assert!(a == b);
//! ```
//!
//! # 例 2:解析与往返
//!
//! ```
//! use symcas::prelude::*;
//!
//! let ctx = Context::new();
//! let x = ctx.sym("x");
//!
//! let e = symcas::parse(&ctx, "x + x + 1/2*x").unwrap();
//! assert_eq!(symcas::plain(&ctx, &e), "5/2*x");
//!
//! // Plain output parses back to the exact same expression node (roundtrip guarantee)
//! let back = symcas::parse(&ctx, "5/2*x").unwrap();
//! assert!(back == e);
//!
//! // sym! 宏批量声明符号
//! let (u, v) = sym!(&ctx, u, v);
//! let _ = u + v;
//! ```
pub use ;
pub use ParseError;
/// 解析 plain 文法(见 `cas-parse` 文档)。
/// plain 输出:往返格式,字节由确定性全序决定。
/// LaTeX 输出:面向阅读,无往返承诺。