15#include <unordered_map>
17#include <unordered_set>
30 return std::hash<int>{}(
static_cast<int>(s));
42 PropertyStore() =
default;
43 PropertyStore(
const PropertyStore&) =
default;
44 PropertyStore(PropertyStore&& other)
noexcept;
45 PropertyStore& operator=(
const PropertyStore& other);
46 PropertyStore& operator=(PropertyStore&& other)
noexcept;
49 std::uint64_t revision() const noexcept {
return revision_; }
71 std::optional<Interval> bounds = std::nullopt);
75 const std::string& symbol,
77 std::optional<Interval> bounds,
78 ComputationContext& context);
80 const std::string& symbol,
82 std::optional<Interval> bounds = std::nullopt);
85 Domain get_domain(
const std::string& symbol)
const;
88 std::unordered_set<Sign, SignHash> get_signs(
const std::string& symbol)
const;
91 Parity get_parity(
const std::string& symbol)
const;
94 Boundedness get_boundedness(
const std::string& symbol)
const;
97 std::optional<Interval> get_bounds(
const std::string& symbol)
const;
100 bool has_sign(
const std::string& symbol, Sign sign)
const;
103 bool has_domain(
const std::string& symbol, Domain domain)
const;
112 const std::string& symbol,
const Interval& interval);
115 const std::string& symbol,
116 const Interval& interval,
117 ComputationContext& context);
119 const std::string& symbol,
120 const Interval& interval);
133 const std::string& symbol,
const Interval& interval);
136 const std::string& symbol,
137 const Interval& interval,
138 ComputationContext& context);
140 const std::string& symbol,
141 const Interval& interval);
150 Result<bool> is_continuous(
const std::string& symbol,
const Interval& interval)
const;
152 Result<bool> is_continuous_checked(
153 const std::string& symbol,
154 const Interval& interval,
155 ComputationContext& context)
const;
156 Result<bool> is_continuous_checked(
157 const std::string& symbol,
158 const Interval& interval)
const;
167 Result<bool> is_differentiable(
const std::string& symbol,
const Interval& interval)
const;
169 Result<bool> is_differentiable_checked(
170 const std::string& symbol,
171 const Interval& interval,
172 ComputationContext& context)
const;
173 Result<bool> is_differentiable_checked(
174 const std::string& symbol,
175 const Interval& interval)
const;
196 bool is_transcendental(
const std::string& symbol)
const;
217 Finiteness get_finiteness(
const std::string& symbol)
const;
232 PropertyStoreResult declare_definiteness_checked(
const std::string& symbol, Definiteness d);
239 Definiteness get_definiteness(
const std::string& symbol)
const;
250 const std::string& symbol,
const std::string& variable,
251 const SymbolicExpr& period);
255 const std::string& symbol,
256 const std::string& variable,
257 const SymbolicExpr& period);
264 std::optional<SymbolicExpr> get_period(
265 const std::string& symbol,
const std::string& variable)
const;
268 bool is_periodic(
const std::string& symbol,
const std::string& variable)
const;
270 using PeriodDeclarations = std::map<std::string, SymbolicExpr>;
272 const PeriodDeclarations& get_period_decls(
const std::string& symbol)
const;
278 std::vector<std::string> get_all_symbols()
const;
281 struct ContinuityInfo {
283 bool is_differentiable;
287 struct MonotonicityInfo {
298 std::vector<ContinuityInfo> get_continuity_decls(
const std::string& symbol)
const;
305 std::vector<MonotonicityInfo> get_monotonicity_decls(
const std::string& symbol)
const;
320 const std::string& symbol,
const std::string& variable,
321 const Interval& interval, Monotonicity mono);
324 const std::string& symbol,
325 const std::string& variable,
326 const Interval& interval,
328 ComputationContext& context);
330 const std::string& symbol,
331 const std::string& variable,
332 const Interval& interval,
348 Result<Monotonicity> get_monotonicity(
349 const std::string& symbol,
const std::string& variable,
350 const Interval& interval)
const;
352 Result<Monotonicity> get_monotonicity_checked(
353 const std::string& symbol,
354 const std::string& variable,
355 const Interval& interval,
356 ComputationContext& context)
const;
357 Result<Monotonicity> get_monotonicity_checked(
358 const std::string& symbol,
359 const std::string& variable,
360 const Interval& interval)
const;
363 struct SymbolProperties {
364 Domain most_specific_domain = Domain::Complex;
365 std::unordered_set<Sign, SignHash> signs;
366 Parity parity = Parity::Unknown;
368 std::optional<Interval> bounds;
371 bool transcendental =
false;
380 PeriodDeclarations periods;
383 struct ContinuityDecl {
385 bool is_differentiable;
389 std::vector<ContinuityDecl> continuity_decls;
392 struct MonotonicityDecl {
399 std::vector<MonotonicityDecl> monotonicity_decls;
402 std::unordered_map<std::string, SymbolProperties> properties_;
403 std::uint64_t revision_ = 0;
405 static Result<bool> check_continuous_declarations(
406 const std::vector<SymbolProperties::ContinuityDecl>& declarations,
407 const std::string& symbol,
408 const Interval& interval,
409 ComputationContext& context);
410 static bool has_differentiable_declaration(
411 const std::vector<SymbolProperties::ContinuityDecl>& declarations,
412 const Interval& interval);
414 void declare_domain_unchecked(
const std::string& symbol, Domain domain);
415 void declare_sign_unchecked(
const std::string& symbol, Sign sign);
416 void declare_parity_unchecked(
const std::string& symbol, Parity parity);
417 void declare_bounded_unchecked(
const std::string& symbol,
419 std::optional<Interval> bounds);
420 void declare_transcendental_unchecked(
const std::string& symbol);
421 void declare_finiteness_unchecked(
const std::string& symbol, Finiteness f);
422 void declare_definiteness_unchecked(
const std::string& symbol, Definiteness d);
423 void declare_periodic_unchecked(
const std::string& symbol,
424 const std::string& variable,
425 const SymbolicExpr& period);
428 void check_domain_sign_consistency(
const std::string& symbol,
429 const SymbolProperties& props,
433 void check_sign_contradiction(
const std::string& symbol,
434 const std::unordered_set<Sign, SignHash>& existing,
438 std::unordered_set<Sign, SignHash> get_implied_signs(Sign sign)
const;
442 int domain_specificity(Domain domain)
const;
Core enumerations and forward declarations for the Assumption System.
区间与区间并集 IntervalUnion,用于不等式解集表示。
const std::string & variable
ExprResult interval(ExprPtr lower, ExprPtr upper, bool lower_closed, bool upper_closed)
Result< void > PropertyStoreResult
Domain
Mathematical domain hierarchy (least specific → most specific). Complex ⊃ Real ⊃ Algebraic ⊃ Rational...
Boundedness
Boundedness classification for symbols.
Monotonicity
Monotonicity classification for functions over intervals.
Definiteness
Matrix definiteness classification.
Finiteness
Finiteness classification for limits and sequences.
Parity
Integer parity classification.
Sign
Sign classification for symbols and expressions.
Hash functor for Sign enum to allow use in unordered_set.
std::size_t operator()(Sign s) const noexcept
符号表达式主类 SymbolicExpr 及其工厂方法,运算接口.