LMCAS
Lamina Computer Algebra System
载入中...
搜索中...
未找到
LMCAS::InferenceEngine::Impl结构体 参考

#include </home/runner/work/docs/docs/LMCAS/src/internal/inference_engine_impl.hpp>

LMCAS::InferenceEngine::Impl 的协作图:

Public 成员函数

 Impl (const AssumptionContext &context)
InferenceTriboolResult absolute_domain (const InferenceEngine &engine, const SymbolicExpr &arg_expr, Domain target, ComputationContext &context) const
InferenceTriboolResult absolute_sign (const InferenceEngine &engine, const SymbolicExpr &arg_expr, Sign target, ComputationContext &context) const
InferenceTriboolResult accumulate_product_sign (const InferenceEngine &engine, const std::shared_ptr< const SymbolicNode > &operand, std::uint8_t &possible, ComputationContext &context) const
Result< void > accumulate_sum_relation_sign (const std::shared_ptr< const SymbolicNode > &operand, const SymbolicExpr &zero_expr, bool &all_gt_zero, bool &all_geq_zero, ComputationContext &context) const
Result< void > add_deduced (InferenceEngine &engine, const SymbolicExpr &new_lhs, const SymbolicExpr &new_rhs, RelationStore &store, PropertyStore &prop_store, int depth) const
InferenceTriboolResult arctangent_domain (const InferenceEngine &engine, const SymbolicExpr &arg_expr, Domain target, ComputationContext &context) const
InferenceTriboolResult composite_integer (const InferenceEngine &engine, const SymbolicExpr &expr, ComputationContext &context) const
InferenceTriboolResult composite_negative (const InferenceEngine &engine, const SymbolicExpr &expr, ComputationContext &context) const
InferenceTriboolResult composite_nonnegative (const InferenceEngine &engine, const SymbolicExpr &expr, ComputationContext &context) const
InferenceTriboolResult composite_nonpositive (const InferenceEngine &engine, const SymbolicExpr &expr, ComputationContext &context) const
InferenceTriboolResult composite_nonzero (const InferenceEngine &engine, const SymbolicExpr &expr, ComputationContext &context) const
InferenceTriboolResult composite_positive (const InferenceEngine &engine, const SymbolicExpr &expr, ComputationContext &context) const
InferenceTriboolResult composite_real (const InferenceEngine &engine, const SymbolicExpr &expr, ComputationContext &context) const
Result< void > deduce_function_relation (InferenceEngine &engine, const VariableNode &lhs, const VariableNode &rhs, FunctionNode::FuncType type, RelationStore &store, PropertyStore &prop_store, int depth) const
Result< void > deduce_power_relations (InferenceEngine &engine, const VariableNode &lhs, const VariableNode &rhs, RelationStore &store, PropertyStore &prop_store, int depth) const
InferenceTriboolResult even_power_sign (const InferenceEngine &engine, const SymbolicExpr &base_expr, const NumberNode &exponent, Sign target, ComputationContext &context) const
InferenceTriboolResult exponential_domain (const InferenceEngine &engine, const SymbolicExpr &arg_expr, Domain target, ComputationContext &context) const
InferenceTriboolResult exponential_sign (const InferenceEngine &engine, const SymbolicExpr &arg_expr, Sign target, ComputationContext &context) const
InferenceTriboolResult function_domain (const InferenceEngine &engine, FunctionNode::FuncType type, const SymbolicExpr &argument, Domain target, ComputationContext &context) const
InferenceTriboolResult function_sign (const InferenceEngine &engine, FunctionNode::FuncType type, const SymbolicExpr &argument, Sign target, ComputationContext &context) const
InferenceTriboolResult integer_power_sign (const InferenceEngine &engine, const SymbolicExpr &base_expr, const NumberNode &exponent, Sign target, ComputationContext &context) const
InferenceTriboolResult logarithm_domain (const InferenceEngine &engine, const SymbolicExpr &arg_expr, Domain target, ComputationContext &context) const
InferenceTriboolResult logarithm_sign (const InferenceEngine &engine, const SymbolicExpr &arg_expr, Sign target, ComputationContext &context) const
InferenceTriboolResult multiply_domain (const InferenceEngine &engine, const MultiplyNode &node, Domain target, ComputationContext &context) const
InferenceTriboolResult nonzero_power_sign (const InferenceEngine &engine, const SymbolicExpr &base_expr, const NumberNode &exponent, Sign target, ComputationContext &context) const
bool operand_sign (const std::shared_ptr< const SymbolicNode > &operand, Sign target, ComputationContext &context) const
InferenceTriboolResult positive_integer_power_sign (const InferenceEngine &engine, const SymbolicExpr &base_expr, const NumberNode &exponent, Sign target, ComputationContext &context) const
InferenceTriboolResult positive_power_sign (const InferenceEngine &engine, const SymbolicExpr &base_expr, const SymbolicExpr &exp_expr, Sign target, ComputationContext &context) const
InferenceTriboolResult positive_relation_chain (const SymbolicExpr &expr, const SymbolicExpr &zero_expr, ComputationContext &context) const
InferenceTriboolResult product_relation_sign (const MultiplyNode &mul, const SymbolicExpr &zero_expr, Sign target, ComputationContext &context) const
InferenceTriboolResult product_sign (const InferenceEngine &engine, const MultiplyNode &node, Sign target, ComputationContext &context) const
InferenceTriboolResult query_natural (const SymbolicExpr &expr, ComputationContext &context) const
InferenceTriboolResult query_rational (const InferenceEngine &engine, const SymbolicExpr &expr, ComputationContext &context) const
InferenceTriboolResult query_zero (const InferenceEngine &engine, const SymbolicExpr &expr, ComputationContext &context) const
InferenceTriboolResult quotient_sign (const InferenceEngine &engine, const SymbolicExpr &num_expr, const SymbolicExpr &den_expr, Sign target, ComputationContext &context) const
InferenceTriboolResult real_or_integer (const InferenceEngine &engine, const SymbolicExpr &arg_expr, ComputationContext &context) const
Result< bool > relation_rhs_nonnegative (const Relation &rel, const SymbolicExpr &zero_expr, ComputationContext &context) const
InferenceTriboolResult square_root_domain (const InferenceEngine &engine, const SymbolicExpr &arg_expr, Domain target, ComputationContext &context) const
InferenceTriboolResult square_root_sign (const InferenceEngine &engine, const SymbolicExpr &arg_expr, Sign target, ComputationContext &context) const
InferenceTriboolResult subtraction_sign (const InferenceEngine &engine, const SymbolicExpr &minuend_expr, const SymbolicExpr &subtrahend_expr, Sign target, ComputationContext &context) const
InferenceTriboolResult sum_nonzero (const InferenceEngine &engine, const AddNode &add, ComputationContext &context) const
InferenceTriboolResult sum_relation_sign (const AddNode &add, const SymbolicExpr &zero_expr, Sign target, ComputationContext &context) const
InferenceTriboolResult sum_sign (const InferenceEngine &engine, const AddNode &node, Sign target, ComputationContext &context) const
InferenceTriboolResult trigonometric_sign (const InferenceEngine &engine, const SymbolicExpr &arg_expr, ComputationContext &context) const
InferenceTriboolResult weak_subtraction_sign (const InferenceEngine &engine, const SymbolicExpr &minuend_expr, const SymbolicExpr &subtrahend_expr, Sign target, ComputationContext &context) const
InferenceTriboolResult zero_power_sign (const InferenceEngine &engine, const SymbolicExpr &base_expr, const NumberNode *exp_num, Sign target, ComputationContext &context) const

静态 Public 成员函数

static void collect_node_exponent (const std::shared_ptr< const SymbolicNode > &node, const std::string &lhs_name, const std::string &rhs_name, std::unordered_set< int > &exponents)
static std::vector< int > collect_power_exponents (const RelationStore &store, const std::string &lhs_name, const std::string &rhs_name)
static Monotonicity function_monotonicity (const FunctionNode &func, const std::string &var, const Interval &interval)
static bool has_negated_operand (const AddNode &node, ComputationContext &context)
static InferenceTriboolResult integral_power_domain (const InferenceEngine &engine, const SymbolicExpr &base, const NumberNode &exponent, Domain target, ComputationContext &context)
static Tribool known_sign (int value, Sign target)
static Monotonicity logarithm_monotonicity (const Interval &interval)
static Tribool natural_number (const NumberNode &num)
static Tribool nonnegative_sign (Sign target)
static Tribool number_integer (const NumberNode &num)
static Tribool number_negative (const NumberNode &num)
static Tribool number_nonnegative (const NumberNode &num)
static Tribool number_nonpositive (const NumberNode &num)
static Tribool number_nonzero (const NumberNode &num)
static Tribool number_positive (const NumberNode &num)
static InferenceTriboolResult product_parity_sign (std::uint8_t possible, Sign target)
static InferenceTriboolResult real_definedness (const InferenceEngine &engine, const SymbolicNode &node, ComputationContext &context)
static std::optional< int > small_positive_exponent (const std::shared_ptr< const NumberNode > &number)
static std::shared_ptr< const SymbolicNode > subtrahend (const std::shared_ptr< const SymbolicNode > &operand, ComputationContext &context)

Public 属性

const AssumptionContext & ctx
int current_depth = 0
int max_depth
std::unordered_set< const SymbolicNode * > visited

详细描述

在文件 inference_engine_impl.hpp 第 93 行定义.

构造及析构函数说明

◆ Impl()

LMCAS::InferenceEngine::Impl::Impl ( const AssumptionContext & context)
inlineexplicit

在文件 inference_engine_impl.hpp 第 94 行定义.

95 : ctx(context), max_depth(context.get_max_query_depth()) {}
const std::vector< Polynomial< BigInt > > const BigInt ComputationContext & context

引用了 LMCAS::context, ctx , 以及 max_depth.

成员函数说明

◆ absolute_domain()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::absolute_domain ( const InferenceEngine & engine,
const SymbolicExpr & arg_expr,
Domain target,
ComputationContext & context ) const

在文件 inference_engine_functions.cpp 第 187 行定义.

190 {
191 if (target == Domain::Real) {
192 return real_or_integer(engine, arg_expr, context);
193 }
194 if (target == Domain::Integer) {
195 auto integer = engine.query_integer_checked(arg_expr, context);
196 if (!integer) {
197 return integer;
198 }
199 if (integer.value() == Tribool::True) {
200 return Tribool::True;
201 }
202 }
203 return Tribool::Unknown;
204}
ExprResult integer(Integer)=delete
@ Real
Real numbers
@ Unknown
Property cannot be determined
@ True
Property definitely holds
const ExprPtr & target
InferenceTriboolResult real_or_integer(const InferenceEngine &engine, const SymbolicExpr &arg_expr, ComputationContext &context) const

引用了 LMCAS::context, LMCAS::Integer, LMCAS::integer, LMCAS::Real, real_or_integer(), LMCAS::target, LMCAS::True, LMCAS::Unknown , 以及 LMCAS::Result< T >::value().

被这些函数引用 function_domain().

函数调用图:
这是这个函数的调用关系图:

◆ absolute_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::absolute_sign ( const InferenceEngine & engine,
const SymbolicExpr & arg_expr,
Sign target,
ComputationContext & context ) const

在文件 inference_engine_functions.cpp 第 59 行定义.

62 {
63 auto arg_real_result = engine.query_domain_of_checked(arg_expr, Domain::Real, context);
64 if (!arg_real_result) {
65 return arg_real_result;
66 }
67 const Tribool arg_real = arg_real_result.value();
68 if (arg_real != Tribool::True) {
70 }
71
72 auto arg_pos_result = engine.query_sign_of_checked(arg_expr, Sign::Positive, context);
73 if (!arg_pos_result) {
74 return arg_pos_result;
75 }
76 const Tribool arg_pos = arg_pos_result.value();
77 auto arg_neg_result = engine.query_sign_of_checked(arg_expr, Sign::Negative, context);
78 if (!arg_neg_result) {
79 return arg_neg_result;
80 }
81 const Tribool arg_neg = arg_neg_result.value();
82 auto arg_nz_result = engine.query_sign_of_checked(arg_expr, Sign::NonZero, context);
83 if (!arg_nz_result) {
84 return arg_nz_result;
85 }
86 const Tribool arg_nz = arg_nz_result.value();
87 bool abs_is_positive = (arg_pos == Tribool::True) ||
88 (arg_neg == Tribool::True) ||
89 (arg_nz == Tribool::True);
90
91 if (abs_is_positive) {
92 return known_sign(1, target);
93 }
95}
static Result success(Tribool value)
Tribool
Tri-state logic value for property queries.
static Tribool known_sign(int value, Sign target)

引用了 LMCAS::context, known_sign(), LMCAS::Negative, nonnegative_sign(), LMCAS::NonZero, LMCAS::Positive, LMCAS::Real, LMCAS::Result< Tribool >::success(), LMCAS::target, LMCAS::True , 以及 LMCAS::Unknown.

被这些函数引用 function_sign().

函数调用图:
这是这个函数的调用关系图:

◆ accumulate_product_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::accumulate_product_sign ( const InferenceEngine & engine,
const std::shared_ptr< const SymbolicNode > & operand,
std::uint8_t & possible,
ComputationContext & context ) const

在文件 inference_engine_product.cpp 第 38 行定义.

41 {
42 const auto expression = detail::expression_from_node(operand);
43 std::uint8_t operand_signs = all_signs;
46 auto fact = engine.query_sign_of_checked(expression, sign, context);
47 if (!fact) return fact;
48 if (fact.value() == Tribool::True) operand_signs &= sign_set(sign);
49 }
50 possible = multiply_sign_sets(possible, operand_signs);
51 return Tribool::True;
52}
std::uint8_t multiply_sign_sets(std::uint8_t left, std::uint8_t right)
inline ::LMCAS::SymbolicExpr expression_from_node(SymbolicNodePtr root)
Sign
Sign classification for symbols and expressions.

引用了 LMCAS::context, LMCAS::detail::expression_from_node(), LMCAS::Negative, LMCAS::NonNegative, LMCAS::NonPositive, LMCAS::NonZero, LMCAS::Positive, LMCAS::True , 以及 LMCAS::Zero.

被这些函数引用 product_sign() , 以及 quotient_sign().

函数调用图:
这是这个函数的调用关系图:

◆ accumulate_sum_relation_sign()

Result< void > LMCAS::InferenceEngine::Impl::accumulate_sum_relation_sign ( const std::shared_ptr< const SymbolicNode > & operand,
const SymbolicExpr & zero_expr,
bool & all_gt_zero,
bool & all_geq_zero,
ComputationContext & context ) const

在文件 inference_engine_relations.cpp 第 25 行定义.

27 {
28 auto step = context.consume_steps(1, "inference.relations");
29 if (!step) {
30 throw step.error();
31 }
32 auto op_expr = detail::expression_from_node(operand);
33 auto gt = ctx.has_relation_checked(
34 op_expr, zero_expr, RelationalNode::Op::GT, context);
35 if (!gt) {
37 }
38 auto geq = ctx.has_relation_checked(
39 op_expr, zero_expr, RelationalNode::Op::GEQ, context);
40 if (!geq) {
41 return Result<void>::failure(geq.error());
42 }
43 bool op_gt = gt.value();
44 bool op_geq = geq.value();
45 if (!op_gt) {
46 op_gt = operand_sign(operand, Sign::Positive, context);
47 }
48 if (!op_geq && !op_gt) {
49 op_geq = operand_sign(operand, Sign::NonNegative, context);
50 }
51 if (!op_gt) {
52 all_gt_zero = false;
53 }
54 if (!op_gt && !op_geq) {
55 all_geq_zero = false;
56 }
57 return Result<void>::success();
58}
CasError & error()
static Result failure(CasErrc code, std::string message, std::string operation={})
ExprResult gt(const ExprPtr &lhs, const ExprPtr &rhs)
bool operand_sign(const std::shared_ptr< const SymbolicNode > &operand, Sign target, ComputationContext &context) const

引用了 LMCAS::context, ctx, LMCAS::Result< T >::error(), LMCAS::detail::expression_from_node(), LMCAS::Result< T >::failure(), LMCAS::gt(), LMCAS::NonNegative, operand_sign(), LMCAS::Positive, LMCAS::Result< T >::success() , 以及 LMCAS::Result< T >::value().

被这些函数引用 sum_relation_sign().

函数调用图:
这是这个函数的调用关系图:

◆ add_deduced()

Result< void > LMCAS::InferenceEngine::Impl::add_deduced ( InferenceEngine & engine,
const SymbolicExpr & new_lhs,
const SymbolicExpr & new_rhs,
RelationStore & store,
PropertyStore & prop_store,
int depth ) const

在文件 inference_engine_monotonicity.cpp 第 105 行定义.

111 {
112 if (store.has_relation(new_lhs, new_rhs, RelationalNode::Op::GT)) {
113 return Result<void>::success();
114 }
115
116 auto inserted = store.add_relation_checked(
117 new_lhs, new_rhs, RelationalNode::Op::GT, prop_store);
118 if (!inserted.has_value()) {
119 return Result<void>::failure(inserted.error());
120 }
121
122 Relation new_rel{new_lhs, new_rhs, RelationalNode::Op::GT};
123 return engine.apply_monotonicity_rules_checked(new_rel, store, prop_store, depth + 1);
124}
std::size_t std::size_t depth

引用了 LMCAS::depth, LMCAS::Result< T >::failure() , 以及 LMCAS::Result< T >::success().

被这些函数引用 deduce_function_relation() , 以及 deduce_power_relations().

函数调用图:
这是这个函数的调用关系图:

◆ arctangent_domain()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::arctangent_domain ( const InferenceEngine & engine,
const SymbolicExpr & arg_expr,
Domain target,
ComputationContext & context ) const

在文件 inference_engine_functions.cpp 第 234 行定义.

237 {
238 if (target == Domain::Real) {
239 auto arg_real_result = engine.query_real_checked(arg_expr, context);
240 if (!arg_real_result) {
241 return arg_real_result;
242 }
243 const Tribool arg_real = arg_real_result.value();
244 if (arg_real == Tribool::True) {
246 }
247 }
249}

引用了 LMCAS::context, LMCAS::Real, LMCAS::Result< Tribool >::success(), LMCAS::target, LMCAS::True , 以及 LMCAS::Unknown.

被这些函数引用 function_domain().

函数调用图:
这是这个函数的调用关系图:

◆ collect_node_exponent()

void LMCAS::InferenceEngine::Impl::collect_node_exponent ( const std::shared_ptr< const SymbolicNode > & node,
const std::string & lhs_name,
const std::string & rhs_name,
std::unordered_set< int > & exponents )
static

在文件 inference_engine_monotonicity.cpp 第 62 行定义.

66 {
67 if (!node) {
68 return;
69 }
70 auto pow_node = std::dynamic_pointer_cast<const PowerNode>(node);
71 if (!pow_node) {
72 return;
73 }
74
75 auto base_var = std::dynamic_pointer_cast<const VariableNode>(pow_node->base());
76 if (!base_var || base_var->is_constant()) {
77 return;
78 }
79 if (base_var->name() != lhs_name && base_var->name() != rhs_name) {
80 return;
81 }
82
83 auto exp_num = std::dynamic_pointer_cast<const NumberNode>(pow_node->exponent());
84 if (!exp_num) {
85 return;
86 }
87 const auto exponent = small_positive_exponent(exp_num);
88 if (exponent) {
89 exponents.insert(*exponent);
90 }
91}
const ExprPtr & exponent
static std::optional< int > small_positive_exponent(const std::shared_ptr< const NumberNode > &number)

引用了 LMCAS::exponent , 以及 small_positive_exponent().

被这些函数引用 collect_power_exponents().

函数调用图:
这是这个函数的调用关系图:

◆ collect_power_exponents()

std::vector< int > LMCAS::InferenceEngine::Impl::collect_power_exponents ( const RelationStore & store,
const std::string & lhs_name,
const std::string & rhs_name )
static

在文件 inference_engine_monotonicity.cpp 第 93 行定义.

96 {
97 std::unordered_set<int> exponents;
98 for (const auto& rel : store.get_relations()) {
99 collect_node_exponent(detail::node(rel.lhs), lhs_name, rhs_name, exponents);
100 collect_node_exponent(detail::node(rel.rhs), lhs_name, rhs_name, exponents);
101 }
102 return std::vector<int>(exponents.begin(), exponents.end());
103}
const SymbolicNodePtr & node(const ::LMCAS::SymbolicExpr &expression) noexcept
static void collect_node_exponent(const std::shared_ptr< const SymbolicNode > &node, const std::string &lhs_name, const std::string &rhs_name, std::unordered_set< int > &exponents)

引用了 collect_node_exponent() , 以及 LMCAS::detail::node().

被这些函数引用 deduce_power_relations().

函数调用图:
这是这个函数的调用关系图:

◆ composite_integer()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::composite_integer ( const InferenceEngine & engine,
const SymbolicExpr & expr,
ComputationContext & context ) const

在文件 inference_engine_core.cpp 第 197 行定义.

199 {
200 if (auto add = std::dynamic_pointer_cast<const AddNode>(LMCAS::detail::node(expr))) {
201 return engine.infer_add_domain_checked(*add, Domain::Integer, context);
202 }
203 if (auto mul = std::dynamic_pointer_cast<const MultiplyNode>(LMCAS::detail::node(expr))) {
204 return engine.infer_multiply_domain_checked(*mul, Domain::Integer, context);
205 }
206 if (auto pow = std::dynamic_pointer_cast<const PowerNode>(LMCAS::detail::node(expr))) {
207 return engine.infer_power_domain_checked(*pow, Domain::Integer, context);
208 }
209 if (auto func = std::dynamic_pointer_cast<const FunctionNode>(LMCAS::detail::node(expr))) {
210 return engine.infer_function_domain_checked(*func, Domain::Integer, context);
211 }
212 return Tribool::Unknown;
213}
ExprResult pow(const ExprPtr &base, const ExprPtr &exponent, ComputationContext &context)
ExprResult mul(const ExprPtr &lhs, const ExprPtr &rhs, ComputationContext &context)
ExprResult add(const ExprPtr &lhs, const ExprPtr &rhs, ComputationContext &context)

引用了 LMCAS::add(), LMCAS::context, LMCAS::Integer, LMCAS::mul(), LMCAS::detail::node(), LMCAS::pow() , 以及 LMCAS::Unknown.

函数调用图:

◆ composite_negative()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::composite_negative ( const InferenceEngine & engine,
const SymbolicExpr & expr,
ComputationContext & context ) const

在文件 inference_engine_core.cpp 第 109 行定义.

111 {
112 if (auto add = std::dynamic_pointer_cast<const AddNode>(LMCAS::detail::node(expr))) {
113 return engine.infer_add_sign_checked(*add, Sign::Negative, context);
114 }
115 if (auto mul = std::dynamic_pointer_cast<const MultiplyNode>(LMCAS::detail::node(expr))) {
116 return engine.infer_multiply_sign_checked(*mul, Sign::Negative, context);
117 }
118 if (auto pow = std::dynamic_pointer_cast<const PowerNode>(LMCAS::detail::node(expr))) {
119 return engine.infer_power_property_checked(*pow, Sign::Negative, context);
120 }
121 if (auto func = std::dynamic_pointer_cast<const FunctionNode>(LMCAS::detail::node(expr))) {
122 return engine.infer_function_property_checked(*func, Sign::Negative, context);
123 }
124 return Tribool::Unknown;
125}

引用了 LMCAS::add(), LMCAS::context, LMCAS::mul(), LMCAS::Negative, LMCAS::detail::node(), LMCAS::pow() , 以及 LMCAS::Unknown.

函数调用图:

◆ composite_nonnegative()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::composite_nonnegative ( const InferenceEngine & engine,
const SymbolicExpr & expr,
ComputationContext & context ) const

在文件 inference_engine_core.cpp 第 127 行定义.

129 {
130 if (auto add = std::dynamic_pointer_cast<const AddNode>(LMCAS::detail::node(expr))) {
131 auto result =
132 engine.infer_add_sign_checked(*add, Sign::NonNegative, context);
133 if (!result) {
134 return result;
135 }
136 if (result.value() != Tribool::Unknown) {
137 return result;
138 }
139 return engine.infer_sign_from_relations_checked(expr, Sign::NonNegative, context);
140 }
141 if (auto mul = std::dynamic_pointer_cast<const MultiplyNode>(LMCAS::detail::node(expr))) {
142 auto result =
143 engine.infer_multiply_sign_checked(*mul, Sign::NonNegative, context);
144 if (!result) {
145 return result;
146 }
147 if (result.value() != Tribool::Unknown) {
148 return result;
149 }
150 return engine.infer_sign_from_relations_checked(expr, Sign::NonNegative, context);
151 }
152 if (auto pow = std::dynamic_pointer_cast<const PowerNode>(LMCAS::detail::node(expr))) {
153 return engine.infer_power_property_checked(*pow, Sign::NonNegative, context);
154 }
155 if (auto func = std::dynamic_pointer_cast<const FunctionNode>(LMCAS::detail::node(expr))) {
156 return engine.infer_function_property_checked(*func, Sign::NonNegative, context);
157 }
158 return Tribool::Unknown;
159}

引用了 LMCAS::add(), LMCAS::context, LMCAS::mul(), LMCAS::detail::node(), LMCAS::NonNegative, LMCAS::pow() , 以及 LMCAS::Unknown.

函数调用图:

◆ composite_nonpositive()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::composite_nonpositive ( const InferenceEngine & engine,
const SymbolicExpr & expr,
ComputationContext & context ) const

在文件 inference_engine_core.cpp 第 161 行定义.

163 {
164 if (auto add = std::dynamic_pointer_cast<const AddNode>(LMCAS::detail::node(expr))) {
165 return engine.infer_add_sign_checked(*add, Sign::NonPositive, context);
166 }
167 if (auto mul = std::dynamic_pointer_cast<const MultiplyNode>(LMCAS::detail::node(expr))) {
168 return engine.infer_multiply_sign_checked(*mul, Sign::NonPositive, context);
169 }
170 if (auto pow = std::dynamic_pointer_cast<const PowerNode>(LMCAS::detail::node(expr))) {
171 return engine.infer_power_property_checked(*pow, Sign::NonPositive, context);
172 }
173 if (auto func = std::dynamic_pointer_cast<const FunctionNode>(LMCAS::detail::node(expr))) {
174 return engine.infer_function_property_checked(*func, Sign::NonPositive, context);
175 }
176 return Tribool::Unknown;
177}

引用了 LMCAS::add(), LMCAS::context, LMCAS::mul(), LMCAS::detail::node(), LMCAS::NonPositive, LMCAS::pow() , 以及 LMCAS::Unknown.

函数调用图:

◆ composite_nonzero()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::composite_nonzero ( const InferenceEngine & engine,
const SymbolicExpr & expr,
ComputationContext & context ) const

在文件 inference_engine_core.cpp 第 237 行定义.

239 {
240 if (auto mul = std::dynamic_pointer_cast<const MultiplyNode>(LMCAS::detail::node(expr))) {
241 return engine.infer_multiply_sign_checked(*mul, Sign::NonZero, context);
242 }
243 if (auto pow = std::dynamic_pointer_cast<const PowerNode>(LMCAS::detail::node(expr))) {
244 return engine.infer_power_property_checked(*pow, Sign::NonZero, context);
245 }
246 if (auto func = std::dynamic_pointer_cast<const FunctionNode>(LMCAS::detail::node(expr))) {
247 return engine.infer_function_property_checked(*func, Sign::NonZero, context);
248 }
249 if (auto add = std::dynamic_pointer_cast<const AddNode>(LMCAS::detail::node(expr))) {
250 return sum_nonzero(engine, *add, context);
251 }
252 return Tribool::Unknown;
253}
InferenceTriboolResult sum_nonzero(const InferenceEngine &engine, const AddNode &add, ComputationContext &context) const

引用了 LMCAS::add(), LMCAS::context, LMCAS::mul(), LMCAS::detail::node(), LMCAS::NonZero, LMCAS::pow(), sum_nonzero() , 以及 LMCAS::Unknown.

函数调用图:

◆ composite_positive()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::composite_positive ( const InferenceEngine & engine,
const SymbolicExpr & expr,
ComputationContext & context ) const

在文件 inference_engine_core.cpp 第 75 行定义.

77 {
78 if (auto add = std::dynamic_pointer_cast<const AddNode>(LMCAS::detail::node(expr))) {
79 auto result =
80 engine.infer_add_sign_checked(*add, Sign::Positive, context);
81 if (!result) {
82 return result;
83 }
84 if (result.value() != Tribool::Unknown) {
85 return result;
86 }
87 return engine.infer_sign_from_relations_checked(expr, Sign::Positive, context);
88 }
89 if (auto mul = std::dynamic_pointer_cast<const MultiplyNode>(LMCAS::detail::node(expr))) {
90 auto result =
91 engine.infer_multiply_sign_checked(*mul, Sign::Positive, context);
92 if (!result) {
93 return result;
94 }
95 if (result.value() != Tribool::Unknown) {
96 return result;
97 }
98 return engine.infer_sign_from_relations_checked(expr, Sign::Positive, context);
99 }
100 if (auto pow = std::dynamic_pointer_cast<const PowerNode>(LMCAS::detail::node(expr))) {
101 return engine.infer_power_property_checked(*pow, Sign::Positive, context);
102 }
103 if (auto func = std::dynamic_pointer_cast<const FunctionNode>(LMCAS::detail::node(expr))) {
104 return engine.infer_function_property_checked(*func, Sign::Positive, context);
105 }
106 return engine.infer_sign_from_relations_checked(expr, Sign::Positive, context);
107}

引用了 LMCAS::add(), LMCAS::context, LMCAS::mul(), LMCAS::detail::node(), LMCAS::Positive, LMCAS::pow() , 以及 LMCAS::Unknown.

函数调用图:

◆ composite_real()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::composite_real ( const InferenceEngine & engine,
const SymbolicExpr & expr,
ComputationContext & context ) const

在文件 inference_engine_core.cpp 第 179 行定义.

181 {
182 if (auto add = std::dynamic_pointer_cast<const AddNode>(LMCAS::detail::node(expr))) {
183 return engine.infer_add_domain_checked(*add, Domain::Real, context);
184 }
185 if (auto mul = std::dynamic_pointer_cast<const MultiplyNode>(LMCAS::detail::node(expr))) {
186 return engine.infer_multiply_domain_checked(*mul, Domain::Real, context);
187 }
188 if (auto pow = std::dynamic_pointer_cast<const PowerNode>(LMCAS::detail::node(expr))) {
189 return engine.infer_power_domain_checked(*pow, Domain::Real, context);
190 }
191 if (auto func = std::dynamic_pointer_cast<const FunctionNode>(LMCAS::detail::node(expr))) {
192 return engine.infer_function_domain_checked(*func, Domain::Real, context);
193 }
194 return Tribool::Unknown;
195}

引用了 LMCAS::add(), LMCAS::context, LMCAS::mul(), LMCAS::detail::node(), LMCAS::pow(), LMCAS::Real , 以及 LMCAS::Unknown.

函数调用图:

◆ deduce_function_relation()

Result< void > LMCAS::InferenceEngine::Impl::deduce_function_relation ( InferenceEngine & engine,
const VariableNode & lhs,
const VariableNode & rhs,
FunctionNode::FuncType type,
RelationStore & store,
PropertyStore & prop_store,
int depth ) const

在文件 inference_engine_monotonicity.cpp 第 126 行定义.

133 {
134 auto lhs_node = detail::make_node<FunctionNode>(
135 type, std::vector<std::shared_ptr<const SymbolicNode>>{lhs.clone()});
136 auto rhs_node = detail::make_node<FunctionNode>(
137 type, std::vector<std::shared_ptr<const SymbolicNode>>{rhs.clone()});
138 auto lhs_expr = detail::expression_from_node(lhs_node);
139 auto rhs_expr = detail::expression_from_node(rhs_node);
140 return add_deduced(engine, lhs_expr, rhs_expr, store, prop_store, depth);
141}
std::shared_ptr< const Node > make_node(Args &&... args)
const ExprPtr & rhs
Result< void > add_deduced(InferenceEngine &engine, const SymbolicExpr &new_lhs, const SymbolicExpr &new_rhs, RelationStore &store, PropertyStore &prop_store, int depth) const

引用了 add_deduced(), LMCAS::VariableNode::clone(), LMCAS::depth, LMCAS::detail::expression_from_node(), LMCAS::detail::make_node() , 以及 LMCAS::rhs.

函数调用图:

◆ deduce_power_relations()

Result< void > LMCAS::InferenceEngine::Impl::deduce_power_relations ( InferenceEngine & engine,
const VariableNode & lhs,
const VariableNode & rhs,
RelationStore & store,
PropertyStore & prop_store,
int depth ) const

在文件 inference_engine_monotonicity.cpp 第 143 行定义.

149 {
150 std::vector<int> exponents = collect_power_exponents(store, lhs.name(), rhs.name());
151
152 for (int n : exponents) {
153 auto exp_node = LMCAS::detail::make_node<NumberNode>(BigInt(n));
154 auto pow_x_node = LMCAS::detail::make_node<PowerNode>(lhs.clone(), exp_node->clone());
155 auto pow_y_node = LMCAS::detail::make_node<PowerNode>(rhs.clone(), exp_node->clone());
156
157 auto pow_x = LMCAS::detail::expression_from_node(pow_x_node);
158 auto pow_y = LMCAS::detail::expression_from_node(pow_y_node);
159 auto deduced = add_deduced(engine, pow_x, pow_y, store, prop_store, depth);
160 if (!deduced.has_value()) {
161 return deduced;
162 }
163 }
164 return Result<void>::success();
165}
static std::vector< int > collect_power_exponents(const RelationStore &store, const std::string &lhs_name, const std::string &rhs_name)

引用了 add_deduced(), LMCAS::VariableNode::clone(), collect_power_exponents(), LMCAS::depth, LMCAS::detail::expression_from_node(), LMCAS::detail::make_node(), LMCAS::VariableNode::name(), LMCAS::rhs , 以及 LMCAS::Result< T >::success().

函数调用图:

◆ even_power_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::even_power_sign ( const InferenceEngine & engine,
const SymbolicExpr & base_expr,
const NumberNode & exponent,
Sign target,
ComputationContext & context ) const

在文件 inference_engine_power.cpp 第 47 行定义.

51 {
53 return Tribool::Unknown;
54 }
55 const detail::AssumptionFacts facts(engine);
56 auto base = detail::query_real_value(detail::node(base_expr), facts, context);
57 if (!base) {
58 return base;
59 }
60 if (base.value() == Tribool::True) {
61 auto nonzero = detail::query_nonzero_value(detail::node(base_expr), facts, Domain::Real, context);
62 if (!nonzero) return nonzero;
63 if (nonzero.value() == Tribool::True) return known_sign(1, target);
64 if (nonzero.value() == Tribool::False) return known_sign(0, target);
66 }
67 return Tribool::Unknown;
68}
Result< Tribool > query_nonzero_value(const Node &node, const FactsQuery &facts, Domain domain, ComputationContext &context)
RewriteBudget const FactsQuery & facts
Result< Tribool > query_real_value(const Node &node, const FactsQuery &facts, ComputationContext &context)
bool is_even_integer_number(const NumberNode &num)
@ False
Property definitely does not hold

引用了 LMCAS::context, LMCAS::exponent, LMCAS::False, LMCAS::is_even_integer_number(), known_sign(), LMCAS::detail::node(), nonnegative_sign(), LMCAS::detail::query_nonzero_value(), LMCAS::detail::query_real_value(), LMCAS::Real, LMCAS::target, LMCAS::True , 以及 LMCAS::Unknown.

被这些函数引用 integer_power_sign().

函数调用图:
这是这个函数的调用关系图:

◆ exponential_domain()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::exponential_domain ( const InferenceEngine & engine,
const SymbolicExpr & arg_expr,
Domain target,
ComputationContext & context ) const

在文件 inference_engine_functions.cpp 第 174 行定义.

177 {
178 if (target != Domain::Real) {
179 return Tribool::Unknown;
180 }
181 const detail::AssumptionFacts facts(engine);
182 auto real = detail::query_real_value(detail::node(arg_expr), facts, context);
183 if (!real) return real;
185}
ExprResult real(const ExprPtr &expression, ComputationContext &context)

引用了 LMCAS::context, LMCAS::detail::node(), LMCAS::detail::query_real_value(), LMCAS::Real, LMCAS::real(), LMCAS::target, LMCAS::True, LMCAS::Unknown , 以及 LMCAS::Result< T >::value().

被这些函数引用 function_domain().

函数调用图:
这是这个函数的调用关系图:

◆ exponential_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::exponential_sign ( const InferenceEngine & engine,
const SymbolicExpr & arg_expr,
Sign target,
ComputationContext & context ) const

在文件 inference_engine_functions.cpp 第 34 行定义.

37 {
38 const detail::AssumptionFacts facts(engine);
39 auto real = detail::query_real_value(detail::node(arg_expr), facts, context);
40 if (!real) {
41 return real;
42 }
43 if (real.value() == Tribool::True) {
44 return known_sign(1, target);
45 }
46 return Tribool::Unknown;
47}

引用了 LMCAS::context, known_sign(), LMCAS::detail::node(), LMCAS::detail::query_real_value(), LMCAS::real(), LMCAS::target, LMCAS::True, LMCAS::Unknown , 以及 LMCAS::Result< T >::value().

被这些函数引用 function_sign().

函数调用图:
这是这个函数的调用关系图:

◆ function_domain()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::function_domain ( const InferenceEngine & engine,
FunctionNode::FuncType type,
const SymbolicExpr & argument,
Domain target,
ComputationContext & context ) const

在文件 inference_engine_functions.cpp 第 338 行定义.

340 {
341 switch (type) {
343 return exponential_domain(engine, arg_expr, target, context);
344 }
348 if (target == Domain::Real) {
349 return real_or_integer(engine, arg_expr, context);
350 }
352 }
354 return absolute_domain(engine, arg_expr, target, context);
355 }
357 return logarithm_domain(engine, arg_expr, target, context);
358 }
360 return square_root_domain(engine, arg_expr, target, context);
361 }
363 return arctangent_domain(engine, arg_expr, target, context);
364 }
365 default:
367 }
368}
@ Sqrt
对数、绝对值、平方根。
InferenceTriboolResult exponential_domain(const InferenceEngine &engine, const SymbolicExpr &arg_expr, Domain target, ComputationContext &context) const
InferenceTriboolResult arctangent_domain(const InferenceEngine &engine, const SymbolicExpr &arg_expr, Domain target, ComputationContext &context) const
InferenceTriboolResult square_root_domain(const InferenceEngine &engine, const SymbolicExpr &arg_expr, Domain target, ComputationContext &context) const
InferenceTriboolResult absolute_domain(const InferenceEngine &engine, const SymbolicExpr &arg_expr, Domain target, ComputationContext &context) const
InferenceTriboolResult logarithm_domain(const InferenceEngine &engine, const SymbolicExpr &arg_expr, Domain target, ComputationContext &context) const

引用了 LMCAS::FunctionNode::Abs, absolute_domain(), LMCAS::FunctionNode::ArcTan, arctangent_domain(), LMCAS::context, LMCAS::FunctionNode::Cos, LMCAS::FunctionNode::Exp, exponential_domain(), LMCAS::FunctionNode::Ln, logarithm_domain(), LMCAS::Real, real_or_integer(), LMCAS::FunctionNode::Sin, LMCAS::FunctionNode::Sqrt, square_root_domain(), LMCAS::Result< Tribool >::success(), LMCAS::FunctionNode::Tan, LMCAS::target , 以及 LMCAS::Unknown.

函数调用图:

◆ function_monotonicity()

Monotonicity LMCAS::InferenceEngine::Impl::function_monotonicity ( const FunctionNode & func,
const std::string & var,
const Interval & interval )
static

在文件 inference_engine_monotonicity.cpp 第 23 行定义.

26 {
27 if (func.arguments().empty()) {
29 }
30 auto arg_var = std::dynamic_pointer_cast<const VariableNode>(func.arguments()[0]);
31 if (!arg_var || arg_var->is_constant() || arg_var->name() != var) {
33 }
34
35 switch (func.type()) {
38
41
44 }
45
46 default:
47 break;
48 }
50}
ExprResult interval(ExprPtr lower, ExprPtr upper, bool lower_closed, bool upper_closed)
@ Unknown
Monotonicity not determined
@ Increasing
Strictly increasing
static Monotonicity logarithm_monotonicity(const Interval &interval)

引用了 LMCAS::FunctionNode::ArcTan, LMCAS::FunctionNode::arguments(), LMCAS::FunctionNode::Exp, LMCAS::Increasing, LMCAS::interval(), LMCAS::FunctionNode::Ln, logarithm_monotonicity(), LMCAS::FunctionNode::type() , 以及 LMCAS::Unknown.

函数调用图:

◆ function_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::function_sign ( const InferenceEngine & engine,
FunctionNode::FuncType type,
const SymbolicExpr & argument,
Sign target,
ComputationContext & context ) const

在文件 inference_engine_functions.cpp 第 280 行定义.

282 {
283 switch (type) {
285 return exponential_sign(engine, arg_expr, target, context);
286 }
290 return trigonometric_sign(engine, arg_expr, context);
291 }
293 return absolute_sign(engine, arg_expr, target, context);
294 }
296 return logarithm_sign(engine, arg_expr, target, context);
297 }
299 return square_root_sign(engine, arg_expr, target, context);
300 }
302 return engine.query_sign_of_checked(arg_expr, target, context);
303 }
304 default:
306 }
307}
InferenceTriboolResult trigonometric_sign(const InferenceEngine &engine, const SymbolicExpr &arg_expr, ComputationContext &context) const
InferenceTriboolResult square_root_sign(const InferenceEngine &engine, const SymbolicExpr &arg_expr, Sign target, ComputationContext &context) const
InferenceTriboolResult exponential_sign(const InferenceEngine &engine, const SymbolicExpr &arg_expr, Sign target, ComputationContext &context) const
InferenceTriboolResult absolute_sign(const InferenceEngine &engine, const SymbolicExpr &arg_expr, Sign target, ComputationContext &context) const
InferenceTriboolResult logarithm_sign(const InferenceEngine &engine, const SymbolicExpr &arg_expr, Sign target, ComputationContext &context) const

引用了 LMCAS::FunctionNode::Abs, absolute_sign(), LMCAS::FunctionNode::ArcTan, LMCAS::context, LMCAS::FunctionNode::Cos, LMCAS::FunctionNode::Exp, exponential_sign(), LMCAS::FunctionNode::Ln, logarithm_sign(), LMCAS::FunctionNode::Sin, LMCAS::FunctionNode::Sqrt, square_root_sign(), LMCAS::Result< Tribool >::success(), LMCAS::FunctionNode::Tan, LMCAS::target, trigonometric_sign() , 以及 LMCAS::Unknown.

函数调用图:

◆ has_negated_operand()

bool LMCAS::InferenceEngine::Impl::has_negated_operand ( const AddNode & node,
ComputationContext & context )
static

在文件 inference_engine_arithmetic.cpp 第 62 行定义.

62 {
63 if (node.operands().size() != 2) {
64 return false;
65 }
66 for (const auto& operand : node.operands()) {
67 auto step = context.consume_steps(1, "inference.arithmetic");
68 if (!step) throw step.error();
69 auto mul = std::dynamic_pointer_cast<const MultiplyNode>(operand);
70 if (!mul || mul->operands().size() != 2) {
71 continue;
72 }
73 for (const auto& factor : mul->operands()) {
74 auto step = context.consume_steps(1, "inference.arithmetic");
75 if (!step) throw step.error();
76 const auto number =
77 std::dynamic_pointer_cast<const NumberNode>(factor);
78 if (number && number->is_negative_one()) {
79 return true;
80 }
81 }
82 }
83 return false;
84}

引用了 LMCAS::context , 以及 LMCAS::mul().

函数调用图:

◆ integer_power_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::integer_power_sign ( const InferenceEngine & engine,
const SymbolicExpr & base_expr,
const NumberNode & exponent,
Sign target,
ComputationContext & context ) const

在文件 inference_engine_power.cpp 第 106 行定义.

110 {
112 const detail::AssumptionFacts facts(engine);
113 auto real = detail::query_real_value(detail::node(base_expr), facts, context);
114 if (!real) return real;
115 if (real.value() != Tribool::True)
116 return nonzero_power_sign(engine, base_expr, exponent, target, context);
117 return engine.query_sign_of_checked(base_expr, target, context);
118 }
119 auto even = even_power_sign(engine, base_expr, exponent, target, context);
120 if (!even) {
121 return even;
122 }
123 if (even.value() != Tribool::Unknown) {
124 return even;
125 }
126 auto positive = positive_integer_power_sign(engine, base_expr, exponent, target, context);
127 if (!positive) {
128 return positive;
129 }
130 if (positive.value() != Tribool::Unknown) {
131 return positive;
132 }
133 return nonzero_power_sign(engine, base_expr, exponent, target, context);
134}
bool is_integer_number(const NumberNode &num)
InferenceTriboolResult even_power_sign(const InferenceEngine &engine, const SymbolicExpr &base_expr, const NumberNode &exponent, Sign target, ComputationContext &context) const
InferenceTriboolResult nonzero_power_sign(const InferenceEngine &engine, const SymbolicExpr &base_expr, const NumberNode &exponent, Sign target, ComputationContext &context) const
InferenceTriboolResult positive_integer_power_sign(const InferenceEngine &engine, const SymbolicExpr &base_expr, const NumberNode &exponent, Sign target, ComputationContext &context) const

引用了 LMCAS::context, even_power_sign(), LMCAS::exponent, LMCAS::is_even_integer_number(), LMCAS::is_integer_number(), LMCAS::detail::node(), nonzero_power_sign(), positive_integer_power_sign(), LMCAS::detail::query_real_value(), LMCAS::real(), LMCAS::target, LMCAS::True, LMCAS::Unknown , 以及 LMCAS::Result< T >::value().

函数调用图:

◆ integral_power_domain()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::integral_power_domain ( const InferenceEngine & engine,
const SymbolicExpr & base,
const NumberNode & exponent,
Domain target,
ComputationContext & context )
static

在文件 inference_engine_domains.cpp 第 143 行定义.

145 {
146 if (target == Domain::Integer) {
147 auto base_int_result = engine.query_integer_checked(base, context);
148 if (!base_int_result) {
149 return base_int_result;
150 }
151 const Tribool base_int = base_int_result.value();
154 }
155 if (base_int == Tribool::True && is_zero_number(exponent)) {
157 }
158 }
159 return Tribool::Unknown;
160}
bool is_positive_integer_number(const NumberNode &num)
bool is_zero_number(const NumberNode &num)

引用了 LMCAS::context, LMCAS::exponent, LMCAS::Integer, LMCAS::is_positive_integer_number(), LMCAS::is_zero_number(), LMCAS::Result< Tribool >::success(), LMCAS::target, LMCAS::True , 以及 LMCAS::Unknown.

函数调用图:

◆ known_sign()

Tribool LMCAS::InferenceEngine::Impl::known_sign ( int value,
Sign target )
static

在文件 inference_engine_arithmetic.cpp 第 6 行定义.

6 {
7 switch (target) {
8 case Sign::Positive: {
10 }
11 case Sign::Negative: {
12 return value < 0 ? Tribool::True : Tribool::False;
13 }
14 case Sign::NonNegative: {
15 return value >= 0 ? Tribool::True : Tribool::False;
16 }
17 case Sign::NonPositive: {
18 return value <= 0 ? Tribool::True : Tribool::False;
19 }
20 case Sign::Zero: {
21 return value == 0 ? Tribool::True : Tribool::False;
22 }
23 case Sign::NonZero: {
24 return value != 0 ? Tribool::True : Tribool::False;
25 }
26 }
27 return Tribool::Unknown;
28}
const std::string const ExprPtr & value

引用了 LMCAS::False, LMCAS::Negative, LMCAS::NonNegative, LMCAS::NonPositive, LMCAS::NonZero, LMCAS::Positive, LMCAS::target, LMCAS::True, LMCAS::Unknown, LMCAS::value , 以及 LMCAS::Zero.

被这些函数引用 absolute_sign(), even_power_sign(), exponential_sign(), logarithm_sign(), positive_power_sign(), subtraction_sign() , 以及 zero_power_sign().

这是这个函数的调用关系图:

◆ logarithm_domain()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::logarithm_domain ( const InferenceEngine & engine,
const SymbolicExpr & arg_expr,
Domain target,
ComputationContext & context ) const

在文件 inference_engine_functions.cpp 第 206 行定义.

209 {
210 if (target != Domain::Real) return Tribool::Unknown;
211 const detail::AssumptionFacts facts(engine);
212 auto positive = detail::query_positive_value(detail::node(arg_expr), facts, context);
213 if (!positive) return positive;
214 return positive.value() == Tribool::True ? Tribool::True : Tribool::Unknown;
215}
Result< Tribool > query_positive_value(const Node &node, const FactsQuery &facts, ComputationContext &context)

引用了 LMCAS::context, LMCAS::detail::node(), LMCAS::detail::query_positive_value(), LMCAS::Real, LMCAS::target, LMCAS::True , 以及 LMCAS::Unknown.

被这些函数引用 function_domain().

函数调用图:
这是这个函数的调用关系图:

◆ logarithm_monotonicity()

Monotonicity LMCAS::InferenceEngine::Impl::logarithm_monotonicity ( const Interval & interval)
static

在文件 inference_engine_monotonicity.cpp 第 8 行定义.

8 {
9 ComputationContext context;
11 interval.lower, context, "inference.logarithm_monotonicity");
12 if (!lower) return Monotonicity::Unknown;
13 auto comparison = detail::compare_comparable(
14 lower.value(), detail::ComparableEndpoint{}, context);
15 if (!comparison) return Monotonicity::Unknown;
16 if (comparison.value() > 0 ||
17 (comparison.value() == 0 && interval.lower.is_open)) {
19 }
21}
Result< ComparableEndpoint > comparable_endpoint(const Endpoint &endpoint, ComputationContext &context, const std::string &operation)
Result< int > compare_comparable(const ComparableEndpoint &left, const ComparableEndpoint &right, ComputationContext &context)
const ExprPtr & lower

引用了 LMCAS::detail::comparable_endpoint(), LMCAS::detail::compare_comparable(), LMCAS::context, LMCAS::Increasing, LMCAS::interval(), LMCAS::lower , 以及 LMCAS::Unknown.

被这些函数引用 function_monotonicity().

函数调用图:
这是这个函数的调用关系图:

◆ logarithm_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::logarithm_sign ( const InferenceEngine & engine,
const SymbolicExpr & arg_expr,
Sign target,
ComputationContext & context ) const

在文件 inference_engine_functions.cpp 第 97 行定义.

100 {
101 if (const auto* number = dynamic_cast<const NumberNode*>(detail::node(arg_expr).get())) {
102 const int sign = std::visit([](const auto& value) {
103 using T = std::decay_t<decltype(value)>;
104 return value > T(1) ? 1 : value < T(1) ? -1 : 0;
105 }, number->value());
106 return known_sign(sign, target);
107 }
108 auto step = context.consume_steps(1, "inference.logarithm");
109 if (!step) {
110 return InferenceTriboolResult::failure(step.error());
111 }
113 auto greater = ctx.has_relation_checked(arg_expr, one, RelationOp::GT, context);
114 if (!greater) {
115 return InferenceTriboolResult::failure(greater.error());
116 }
117 if (greater.value()) {
118 return known_sign(1, target);
119 }
120 auto equal = ctx.has_relation_checked(arg_expr, one, RelationOp::EQ, context);
121 if (!equal) {
122 return InferenceTriboolResult::failure(equal.error());
123 }
124 if (equal.value()) {
125 return known_sign(0, target);
126 }
127 auto less = ctx.has_relation_checked(arg_expr, one, RelationOp::LT, context);
128 if (!less) {
129 return InferenceTriboolResult::failure(less.error());
130 }
131 if (less.value()) {
132 return known_sign(-1, target);
133 }
134 return Tribool::Unknown;
135}

引用了 LMCAS::context, ctx, LMCAS::EQ, LMCAS::detail::expression_from_node(), LMCAS::Result< Tribool >::failure(), LMCAS::GT, known_sign(), LMCAS::LT, LMCAS::detail::make_node(), LMCAS::detail::node(), LMCAS::target, LMCAS::Unknown , 以及 LMCAS::value.

被这些函数引用 function_sign().

函数调用图:
这是这个函数的调用关系图:

◆ multiply_domain()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::multiply_domain ( const InferenceEngine & engine,
const MultiplyNode & node,
Domain target,
ComputationContext & context ) const

在文件 inference_engine_domains.cpp 第 95 行定义.

96 {
98 for (const auto& operand : node.operands()) {
99 const auto expression = detail::expression_from_node(operand);
100 auto result = target == Domain::Integer ? engine.query_integer_checked(expression, context)
101 : real_or_integer(engine, expression, context);
102 if (!result) { return result; }
103 if (result.value() != Tribool::True) { return Tribool::Unknown; }
104 }
105 return Tribool::True;
106}

引用了 LMCAS::context, LMCAS::detail::expression_from_node(), LMCAS::Integer, LMCAS::Real, real_or_integer(), LMCAS::target, LMCAS::True , 以及 LMCAS::Unknown.

函数调用图:

◆ natural_number()

Tribool LMCAS::InferenceEngine::Impl::natural_number ( const NumberNode & num)
static

在文件 inference_engine_facts.cpp 第 91 行定义.

91 {
92 return is_integer_number(num) && (num.is_positive() || num.is_zero())
94}
std::shared_ptr< SymbolicExpr > num(int value)

引用了 LMCAS::False, LMCAS::is_integer_number(), LMCAS::polynomial_solver_detail::num() , 以及 LMCAS::True.

被这些函数引用 query_natural().

函数调用图:
这是这个函数的调用关系图:

◆ nonnegative_sign()

Tribool LMCAS::InferenceEngine::Impl::nonnegative_sign ( Sign target)
static

在文件 inference_engine_arithmetic.cpp 第 30 行定义.

30 {
32 return Tribool::True;
33 }
34 if (target == Sign::Negative) {
35 return Tribool::False;
36 }
37 return Tribool::Unknown;
38}

引用了 LMCAS::False, LMCAS::Negative, LMCAS::NonNegative, LMCAS::target, LMCAS::True , 以及 LMCAS::Unknown.

被这些函数引用 absolute_sign(), even_power_sign(), positive_integer_power_sign() , 以及 square_root_sign().

这是这个函数的调用关系图:

◆ nonzero_power_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::nonzero_power_sign ( const InferenceEngine & engine,
const SymbolicExpr & base_expr,
const NumberNode & exponent,
Sign target,
ComputationContext & context ) const

在文件 inference_engine_power.cpp 第 88 行定义.

92 {
94 return Tribool::Unknown;
95 }
96 auto base = engine.query_sign_of_checked(base_expr, Sign::NonZero, context);
97 if (!base) {
98 return base;
99 }
100 if (base.value() == Tribool::True) {
102 }
103 return Tribool::Unknown;
104}

引用了 LMCAS::context, LMCAS::exponent, LMCAS::False, LMCAS::is_integer_number(), LMCAS::NonZero, LMCAS::target, LMCAS::True, LMCAS::Unknown , 以及 LMCAS::Zero.

被这些函数引用 integer_power_sign().

函数调用图:
这是这个函数的调用关系图:

◆ number_integer()

Tribool LMCAS::InferenceEngine::Impl::number_integer ( const NumberNode & num)
static

在文件 inference_engine_facts.cpp 第 21 行定义.

引用了 LMCAS::False, LMCAS::is_integer_number(), LMCAS::polynomial_solver_detail::num() , 以及 LMCAS::True.

函数调用图:

◆ number_negative()

Tribool LMCAS::InferenceEngine::Impl::number_negative ( const NumberNode & num)
static

在文件 inference_engine_facts.cpp 第 9 行定义.

9 {
10 return !num.is_positive() && !num.is_zero() ? Tribool::True : Tribool::False;
11}

引用了 LMCAS::False, LMCAS::polynomial_solver_detail::num() , 以及 LMCAS::True.

函数调用图:

◆ number_nonnegative()

Tribool LMCAS::InferenceEngine::Impl::number_nonnegative ( const NumberNode & num)
static

在文件 inference_engine_facts.cpp 第 13 行定义.

13 {
14 return num.is_positive() || num.is_zero() ? Tribool::True : Tribool::False;
15}

引用了 LMCAS::False, LMCAS::polynomial_solver_detail::num() , 以及 LMCAS::True.

函数调用图:

◆ number_nonpositive()

Tribool LMCAS::InferenceEngine::Impl::number_nonpositive ( const NumberNode & num)
static

在文件 inference_engine_facts.cpp 第 17 行定义.

17 {
18 return num.is_positive() ? Tribool::False : Tribool::True;
19}

引用了 LMCAS::False, LMCAS::polynomial_solver_detail::num() , 以及 LMCAS::True.

函数调用图:

◆ number_nonzero()

Tribool LMCAS::InferenceEngine::Impl::number_nonzero ( const NumberNode & num)
static

在文件 inference_engine_facts.cpp 第 25 行定义.

25 {
26 return num.is_zero() ? Tribool::False : Tribool::True;
27}

引用了 LMCAS::False, LMCAS::polynomial_solver_detail::num() , 以及 LMCAS::True.

函数调用图:

◆ number_positive()

Tribool LMCAS::InferenceEngine::Impl::number_positive ( const NumberNode & num)
static

在文件 inference_engine_facts.cpp 第 5 行定义.

5 {
6 return num.is_positive() ? Tribool::True : Tribool::False;
7}

引用了 LMCAS::False, LMCAS::polynomial_solver_detail::num() , 以及 LMCAS::True.

函数调用图:

◆ operand_sign()

bool LMCAS::InferenceEngine::Impl::operand_sign ( const std::shared_ptr< const SymbolicNode > & operand,
Sign target,
ComputationContext & context ) const

在文件 inference_engine_relations.cpp 第 8 行定义.

8 {
9 auto step = context.consume_steps(0, "inference.relations");
10 if (!step) throw step.error();
11 if (auto var = std::dynamic_pointer_cast<const VariableNode>(operand)) {
12 return var->is_constant()
14 : ctx.has_sign(var->name(), target);
15 }
16 if (auto num = std::dynamic_pointer_cast<const NumberNode>(operand)) {
17 if (target == Sign::Positive) {
18 return num->is_positive();
19 }
20 return num->is_zero() || num->is_positive();
21 }
22 return false;
23}
__attribute__((visibility("default"))) Result< EqvProfile > eqv_profile_from_name(const std const std::string & name

引用了 LMCAS::context, ctx, LMCAS::NonNegative, LMCAS::polynomial_solver_detail::num(), LMCAS::Positive , 以及 LMCAS::target.

被这些函数引用 accumulate_sum_relation_sign() , 以及 product_relation_sign().

函数调用图:
这是这个函数的调用关系图:

◆ positive_integer_power_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::positive_integer_power_sign ( const InferenceEngine & engine,
const SymbolicExpr & base_expr,
const NumberNode & exponent,
Sign target,
ComputationContext & context ) const

在文件 inference_engine_power.cpp 第 70 行定义.

74 {
76 return Tribool::Unknown;
77 }
78 auto base = engine.query_sign_of_checked(base_expr, Sign::NonNegative, context);
79 if (!base) {
80 return base;
81 }
82 if (base.value() == Tribool::True) {
84 }
85 return Tribool::Unknown;
86}

引用了 LMCAS::context, LMCAS::exponent, LMCAS::is_positive_integer_number(), LMCAS::NonNegative, nonnegative_sign(), LMCAS::target, LMCAS::True , 以及 LMCAS::Unknown.

被这些函数引用 integer_power_sign().

函数调用图:
这是这个函数的调用关系图:

◆ positive_power_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::positive_power_sign ( const InferenceEngine & engine,
const SymbolicExpr & base_expr,
const SymbolicExpr & exp_expr,
Sign target,
ComputationContext & context ) const

在文件 inference_engine_power.cpp 第 24 行定义.

28 {
29 const detail::AssumptionFacts facts(engine);
30 auto base_pos = detail::query_positive_value(detail::node(base_expr), facts, context);
31 if (!base_pos) {
32 return base_pos;
33 }
34 if (base_pos.value() != Tribool::True) {
35 return Tribool::Unknown;
36 }
37 auto exp_real = detail::query_real_value(detail::node(exp_expr), facts, context);
38 if (!exp_real) {
39 return exp_real;
40 }
41 if (exp_real.value() == Tribool::True) {
42 return known_sign(1, target);
43 }
44 return Tribool::Unknown;
45}

引用了 LMCAS::context, known_sign(), LMCAS::detail::node(), LMCAS::detail::query_positive_value(), LMCAS::detail::query_real_value(), LMCAS::target, LMCAS::True , 以及 LMCAS::Unknown.

函数调用图:

◆ positive_relation_chain()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::positive_relation_chain ( const SymbolicExpr & expr,
const SymbolicExpr & zero_expr,
ComputationContext & context ) const

在文件 inference_engine_relations.cpp 第 150 行定义.

152 {
153 auto relations = ctx.get_visible_relations_checked(context);
154 if (!relations) return InferenceTriboolResult::failure(relations.error());
155 detail::RewriteBudget budget(context, context.limits().max_recursion_depth,
156 std::numeric_limits<std::size_t>::max(), "inference.relations");
158 for (const auto& rel : relations.value()) {
159 auto step = context.consume_steps(1, "inference.relations");
160 if (!step) throw step.error();
161 if (rel.op != RelationalNode::Op::GT) {
162 continue;
163 }
164
165 if (!LMCAS::detail::node(rel.lhs) || !LMCAS::detail::node(expr)) {
166 continue;
167 }
168 budget.measure(detail::node(rel.lhs));
169 if (!LMCAS::detail::node(rel.lhs)->equals(*LMCAS::detail::node(expr))) {
170 continue;
171 }
172 if (!LMCAS::detail::node(rel.rhs)) {
173 continue;
174 }
175
176 auto nonnegative = relation_rhs_nonnegative(rel, zero_expr, context);
177 if (!nonnegative) return InferenceTriboolResult::failure(nonnegative.error());
178 if (nonnegative.value()) {
180 }
181 }
183}
std::size_t measure(const std::shared_ptr< const SymbolicNode > &node)
Result< bool > relation_rhs_nonnegative(const Relation &rel, const SymbolicExpr &zero_expr, ComputationContext &context) const

引用了 LMCAS::context, ctx, LMCAS::Result< Tribool >::failure(), LMCAS::detail::RewriteBudget::measure(), LMCAS::detail::node(), relation_rhs_nonnegative(), LMCAS::Result< Tribool >::success(), LMCAS::True , 以及 LMCAS::Unknown.

函数调用图:

◆ product_parity_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::product_parity_sign ( std::uint8_t possible,
Sign target )
static

在文件 inference_engine_product.cpp 第 54 行定义.

55 {
56 if (!possible) return Tribool::Unknown;
57 const auto wanted = sign_set(target);
58 if ((possible & wanted) == possible) return Tribool::True;
59 if (!(possible & wanted)) return Tribool::False;
60 return Tribool::Unknown;
61}

引用了 LMCAS::False, LMCAS::target, LMCAS::True , 以及 LMCAS::Unknown.

被这些函数引用 product_sign() , 以及 quotient_sign().

这是这个函数的调用关系图:

◆ product_relation_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::product_relation_sign ( const MultiplyNode & mul,
const SymbolicExpr & zero_expr,
Sign target,
ComputationContext & context ) const

在文件 inference_engine_relations.cpp 第 88 行定义.

91 {
92 const auto& rel_store = ctx;
93 if (mul.operands().empty()) {
95 }
96
97 if (target == Sign::Positive) {
98 bool all_gt_zero = true;
99
100 for (const auto& operand : mul.operands()) {
101 auto step = context.consume_steps(1, "inference.relations");
102 if (!step) throw step.error();
103 auto op_expr = LMCAS::detail::expression_from_node(operand);
104 auto gt = rel_store.has_relation_checked(
105 op_expr, zero_expr, RelationalNode::Op::GT, context);
107 bool op_gt = gt.value();
108
109 if (!op_gt) {
110 op_gt = operand_sign(operand, Sign::Positive, context);
111 }
112
113 if (!op_gt) {
114 all_gt_zero = false;
115 break;
116 }
117 }
118
119 if (all_gt_zero) {
121 }
122 }
124}

引用了 LMCAS::context, ctx, LMCAS::Result< T >::error(), LMCAS::detail::expression_from_node(), LMCAS::Result< Tribool >::failure(), LMCAS::gt(), LMCAS::mul(), operand_sign(), LMCAS::Positive, LMCAS::Result< Tribool >::success(), LMCAS::target, LMCAS::True, LMCAS::Unknown , 以及 LMCAS::Result< T >::value().

函数调用图:

◆ product_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::product_sign ( const InferenceEngine & engine,
const MultiplyNode & node,
Sign target,
ComputationContext & context ) const

在文件 inference_engine_product.cpp 第 63 行定义.

64 {
65 auto defined = real_definedness(engine, node, context);
66 if (!defined || defined.value() != Tribool::True) { return defined; }
67 const detail::AssumptionFacts facts(engine);
68 bool all_real = true;
69 for (const auto& operand : node.operands()) {
70 auto real = detail::query_real_value(operand, facts, context);
71 if (!real) { return real; }
72 all_real = all_real && real.value() == Tribool::True;
73 }
74 if (!all_real) { return Tribool::Unknown; }
75 std::uint8_t possible = positive_sign;
76 for (const auto& operand : node.operands()) {
77 auto result = accumulate_product_sign(engine, operand, possible, context);
78 if (!result) { return result; }
79 }
80 return product_parity_sign(possible, target);
81}
static InferenceTriboolResult product_parity_sign(std::uint8_t possible, Sign target)
static InferenceTriboolResult real_definedness(const InferenceEngine &engine, const SymbolicNode &node, ComputationContext &context)
InferenceTriboolResult accumulate_product_sign(const InferenceEngine &engine, const std::shared_ptr< const SymbolicNode > &operand, std::uint8_t &possible, ComputationContext &context) const

引用了 accumulate_product_sign(), LMCAS::context, product_parity_sign(), LMCAS::detail::query_real_value(), LMCAS::real(), real_definedness(), LMCAS::target, LMCAS::True, LMCAS::Unknown , 以及 LMCAS::Result< T >::value().

函数调用图:

◆ query_natural()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::query_natural ( const SymbolicExpr & expr,
ComputationContext & context ) const

在文件 inference_engine_facts.cpp 第 74 行定义.

74 {
75 return checked_inference_result<Tribool>(expr, "query_domain_of_checked", context,
76 [&]() -> InferenceTriboolResult {
77 if (auto num = std::dynamic_pointer_cast<const NumberNode>(LMCAS::detail::node(expr))) {
78 return natural_number(*num);
79 }
80 if (auto var = std::dynamic_pointer_cast<const VariableNode>(LMCAS::detail::node(expr))) {
81 if (var->is_constant()) return Tribool::False;
82 const auto& props = ctx;
83 if (props.has_domain(var->name(), Domain::Natural)) {
84 return Tribool::True;
85 }
86 }
87 return Tribool::Unknown;
88 });
89}
Result< T > checked_inference_result(const SymbolicExpr &expr, const std::string &operation, ComputationContext &context, const std::function< Result< T >()> &query)
@ Natural
Non-negative integers (0, 1, 2, ...)
Result< Tribool > InferenceTriboolResult
static Tribool natural_number(const NumberNode &num)

引用了 LMCAS::checked_inference_result(), LMCAS::context, ctx, LMCAS::False, LMCAS::Natural, natural_number(), LMCAS::detail::node(), LMCAS::polynomial_solver_detail::num(), LMCAS::True , 以及 LMCAS::Unknown.

函数调用图:

◆ query_rational()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::query_rational ( const InferenceEngine & engine,
const SymbolicExpr & expr,
ComputationContext & context ) const

在文件 inference_engine_facts.cpp 第 29 行定义.

31 {
32 if (!LMCAS::detail::node(expr)) {
35 "inference expression must not be null",
36 "query_domain_of_checked");
37 }
38 try {
39 auto integer = engine.query_integer_checked(expr, context);
40 if (!integer) {
42 }
43 if (integer.value() == Tribool::True) {
45 }
46 if (auto num = std::dynamic_pointer_cast<const NumberNode>(LMCAS::detail::node(expr))) {
47 if (std::holds_alternative<Rational>(num->value())) {
49 }
50 }
51 if (auto var = std::dynamic_pointer_cast<const VariableNode>(LMCAS::detail::node(expr))) {
52 if (var->is_constant()) return InferenceTriboolResult::success(Tribool::False);
53 const auto& props = ctx;
54 if (props.has_domain(var->name(), Domain::Rational)) {
56 }
57 }
59 } catch (const CasError& error) {
61 } catch (const std::bad_alloc&) {
64 "inference query allocation failed",
65 "query_domain_of_checked");
66 } catch (const std::exception& ex) {
69 ex.what(),
70 "query_domain_of_checked");
71 }
72}
@ Rational
Rational numbers

引用了 LMCAS::context, ctx, LMCAS::Result< T >::error(), LMCAS::Result< Tribool >::failure(), LMCAS::False, LMCAS::integer, LMCAS::InternalInvariant, LMCAS::InvalidArgument, LMCAS::detail::node(), LMCAS::polynomial_solver_detail::num(), LMCAS::Rational, LMCAS::ResourceLimit, LMCAS::Result< Tribool >::success(), LMCAS::True, LMCAS::Unknown , 以及 LMCAS::Result< T >::value().

函数调用图:

◆ query_zero()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::query_zero ( const InferenceEngine & engine,
const SymbolicExpr & expr,
ComputationContext & context ) const

在文件 inference_engine_core.cpp 第 255 行定义.

257 {
258 auto nn = engine.query_nonnegative_checked(expr, context);
259 if (!nn) {
260 return nn;
261 }
262 auto np = engine.query_nonpositive_checked(expr, context);
263 if (!np) {
264 return np;
265 }
266 if (nn.value() == Tribool::True && np.value() == Tribool::True) {
268 }
269 if (nn.value() == Tribool::False || np.value() == Tribool::False) {
271 }
272 auto nonzero = engine.query_nonzero_checked(expr, context);
273 if (!nonzero) return nonzero;
274 if (nonzero.value() == Tribool::True) return Tribool::False;
276}

引用了 LMCAS::context, LMCAS::False, LMCAS::Result< Tribool >::success(), LMCAS::True , 以及 LMCAS::Unknown.

函数调用图:

◆ quotient_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::quotient_sign ( const InferenceEngine & engine,
const SymbolicExpr & num_expr,
const SymbolicExpr & den_expr,
Sign target,
ComputationContext & context ) const

在文件 inference_engine_product.cpp 第 83 行定义.

85 {
86 const detail::AssumptionFacts facts(engine);
87 bool all_defined = true;
88 bool all_real = true;
89 for (const auto* expression : {&numerator, &denominator}) {
90 auto defined = real_definedness(engine, *detail::node(*expression), context);
91 if (!defined) { return defined; }
92 all_defined = all_defined && defined.value() == Tribool::True;
93 auto real = detail::query_real_value(detail::node(*expression), facts, context);
94 if (!real) { return real; }
95 all_real = all_real && real.value() == Tribool::True;
96 }
98 if (!nonzero) { return nonzero; }
99 if (nonzero.value() == Tribool::False) {
101 CasErrc::DomainError, "division denominator is zero", "inference.division");
102 }
103 if (!all_defined || !all_real || nonzero.value() != Tribool::True)
104 { return Tribool::Unknown; }
105 std::uint8_t possible = positive_sign;
106 auto first = accumulate_product_sign(engine, detail::node(numerator), possible, context);
107 if (!first) { return first; }
108 auto second = accumulate_product_sign(engine, detail::node(denominator), possible, context);
109 if (!second) { return second; }
110 return product_parity_sign(possible, target);
111}
const ExprPtr & denominator

引用了 accumulate_product_sign(), LMCAS::context, LMCAS::denominator, LMCAS::DomainError, LMCAS::Result< Tribool >::failure(), LMCAS::False, LMCAS::detail::node(), product_parity_sign(), LMCAS::detail::query_nonzero_value(), LMCAS::detail::query_real_value(), LMCAS::Real, LMCAS::real(), real_definedness(), LMCAS::target, LMCAS::True, LMCAS::Unknown , 以及 LMCAS::Result< T >::value().

函数调用图:

◆ real_definedness()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::real_definedness ( const InferenceEngine & engine,
const SymbolicNode & node,
ComputationContext & context )
static

在文件 inference_engine_functions.cpp 第 8 行定义.

9 {
10 const detail::AssumptionFacts facts(engine);
11 const std::shared_ptr<const SymbolicNode> borrowed(
12 std::shared_ptr<const SymbolicNode>{}, &node);
13 bool violated_real_restriction = false;
14 auto defined = detail::query_definedness(
15 borrowed, facts, Domain::Real, context, &violated_real_restriction);
16 if (defined && defined.value() == Tribool::False) {
17 if (!violated_real_restriction) {
18 auto complex_defined =
20 if (!complex_defined) return InferenceTriboolResult::failure(complex_defined.error());
21 if (complex_defined.value() != Tribool::False) {
22 auto real_value = detail::query_real_value(borrowed, facts, context);
23 if (!real_value) return InferenceTriboolResult::failure(real_value.error());
24 if (real_value.value() == Tribool::Unknown) return Tribool::Unknown;
25 }
26 }
28 CasErrc::DomainError, "expression is undefined in the real domain",
29 "inference.definedness");
30 }
31 return defined;
32}
Result< Tribool > query_definedness(const Node &node, const FactsQuery &facts, Domain domain, ComputationContext &context, bool *violated_real_restriction)
@ Complex
Complex numbers (default, least specific)

引用了 LMCAS::Complex, LMCAS::context, LMCAS::DomainError, LMCAS::Result< Tribool >::failure(), LMCAS::False, LMCAS::detail::query_definedness(), LMCAS::detail::query_real_value(), LMCAS::Real , 以及 LMCAS::Unknown.

被这些函数引用 product_sign() , 以及 quotient_sign().

函数调用图:
这是这个函数的调用关系图:

◆ real_or_integer()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::real_or_integer ( const InferenceEngine & engine,
const SymbolicExpr & arg_expr,
ComputationContext & context ) const

在文件 inference_engine_functions.cpp 第 151 行定义.

153 {
154 auto arg_real_result = engine.query_real_checked(arg_expr, context);
155 if (!arg_real_result) {
156 return arg_real_result;
157 }
158 const Tribool arg_real = arg_real_result.value();
159 if (arg_real == Tribool::True) {
161 }
162
163 auto arg_int_result = engine.query_integer_checked(arg_expr, context);
164 if (!arg_int_result) {
165 return arg_int_result;
166 }
167 const Tribool arg_int = arg_int_result.value();
168 if (arg_int == Tribool::True) {
170 }
172}

引用了 LMCAS::context, LMCAS::Result< Tribool >::success(), LMCAS::True , 以及 LMCAS::Unknown.

被这些函数引用 absolute_domain(), function_domain() , 以及 multiply_domain().

函数调用图:
这是这个函数的调用关系图:

◆ relation_rhs_nonnegative()

Result< bool > LMCAS::InferenceEngine::Impl::relation_rhs_nonnegative ( const Relation & rel,
const SymbolicExpr & zero_expr,
ComputationContext & context ) const

在文件 inference_engine_relations.cpp 第 126 行定义.

126 {
127 auto step = context.consume_steps(1, "inference.relations");
128 if (!step) return Result<bool>::failure(step.error());
129 const auto& rel_store = ctx;
130 if (auto rhs_num = std::dynamic_pointer_cast<const NumberNode>(LMCAS::detail::node(rel.rhs))) {
131 if (rhs_num->is_zero() || rhs_num->is_positive()) {
132 return true;
133 }
134 }
135
136 if (auto rhs_var = std::dynamic_pointer_cast<const VariableNode>(LMCAS::detail::node(rel.rhs))) {
137 if (rhs_var->is_constant() ||
138 ctx.has_sign(rhs_var->name(), Sign::NonNegative)) {
139 return true;
140 }
141 }
142
143 auto geq = rel_store.has_relation_checked(
144 rel.rhs, zero_expr, RelationalNode::Op::GEQ, context);
145 if (!geq || geq.value()) return geq;
146 return rel_store.has_relation_checked(
147 rel.rhs, zero_expr, RelationalNode::Op::GT, context);
148}

引用了 LMCAS::context, ctx, LMCAS::Result< T >::failure(), LMCAS::detail::node(), LMCAS::NonNegative , 以及 LMCAS::Relation::rhs.

被这些函数引用 positive_relation_chain().

函数调用图:
这是这个函数的调用关系图:

◆ small_positive_exponent()

std::optional< int > LMCAS::InferenceEngine::Impl::small_positive_exponent ( const std::shared_ptr< const NumberNode > & number)
static

在文件 inference_engine_monotonicity.cpp 第 52 行定义.

53 {
54 BigInt exponent;
55 if (!try_get_integer_value(number, exponent) ||
56 exponent <= BigInt(0) || exponent > BigInt(100)) {
57 return std::nullopt;
58 }
59 return static_cast<int>(*exponent.try_to_int64());
60}
bool try_get_integer_value(const std::shared_ptr< const NumberNode > &node, BigInt &value)

引用了 LMCAS::exponent , 以及 LMCAS::try_get_integer_value().

被这些函数引用 collect_node_exponent().

函数调用图:
这是这个函数的调用关系图:

◆ square_root_domain()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::square_root_domain ( const InferenceEngine & engine,
const SymbolicExpr & arg_expr,
Domain target,
ComputationContext & context ) const

在文件 inference_engine_functions.cpp 第 217 行定义.

220 {
221 if (target == Domain::Real) {
222 auto arg_nonneg_result = engine.query_sign_of_checked(arg_expr, Sign::NonNegative, context);
223 if (!arg_nonneg_result) {
224 return arg_nonneg_result;
225 }
226 const Tribool arg_nonneg = arg_nonneg_result.value();
227 if (arg_nonneg == Tribool::True) {
229 }
230 }
232}

引用了 LMCAS::context, LMCAS::NonNegative, LMCAS::Real, LMCAS::Result< Tribool >::success(), LMCAS::target, LMCAS::True , 以及 LMCAS::Unknown.

被这些函数引用 function_domain().

函数调用图:
这是这个函数的调用关系图:

◆ square_root_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::square_root_sign ( const InferenceEngine & engine,
const SymbolicExpr & arg_expr,
Sign target,
ComputationContext & context ) const

在文件 inference_engine_functions.cpp 第 137 行定义.

140 {
141 auto nonnegative = engine.query_sign_of_checked(arg_expr, Sign::NonNegative, context);
142 if (!nonnegative) {
143 return nonnegative;
144 }
145 if (nonnegative.value() == Tribool::True) {
146 return nonnegative_sign(target);
147 }
148 return Tribool::Unknown;
149}

引用了 LMCAS::context, LMCAS::NonNegative, nonnegative_sign(), LMCAS::target, LMCAS::True , 以及 LMCAS::Unknown.

被这些函数引用 function_sign().

函数调用图:
这是这个函数的调用关系图:

◆ subtraction_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::subtraction_sign ( const InferenceEngine & engine,
const SymbolicExpr & minuend_expr,
const SymbolicExpr & subtrahend_expr,
Sign target,
ComputationContext & context ) const

在文件 inference_engine_arithmetic.cpp 第 122 行定义.

126 {
127 auto min_pos_result =
128 engine.query_sign_of_checked(minuend_expr, Sign::Positive, context);
129 if (!min_pos_result) {
130 return min_pos_result;
131 }
132 const Tribool min_pos = min_pos_result.value();
133 auto min_neg_result =
134 engine.query_sign_of_checked(minuend_expr, Sign::Negative, context);
135 if (!min_neg_result) {
136 return min_neg_result;
137 }
138 const Tribool min_neg = min_neg_result.value();
139 auto sub_pos_result =
140 engine.query_sign_of_checked(subtrahend_expr, Sign::Positive, context);
141 if (!sub_pos_result) {
142 return sub_pos_result;
143 }
144 const Tribool sub_pos = sub_pos_result.value();
145 auto sub_neg_result =
146 engine.query_sign_of_checked(subtrahend_expr, Sign::Negative, context);
147 if (!sub_neg_result) {
148 return sub_neg_result;
149 }
150 const Tribool sub_neg = sub_neg_result.value();
151
152 if (min_pos == Tribool::True && sub_neg == Tribool::True) {
153 return known_sign(1, target);
154 }
155
156 if (min_neg == Tribool::True && sub_pos == Tribool::True) {
157 return known_sign(-1, target);
158 }
159
160 return weak_subtraction_sign(engine, minuend_expr, subtrahend_expr, target, context);
161}
InferenceTriboolResult weak_subtraction_sign(const InferenceEngine &engine, const SymbolicExpr &minuend_expr, const SymbolicExpr &subtrahend_expr, Sign target, ComputationContext &context) const

引用了 LMCAS::context, known_sign(), LMCAS::Negative, LMCAS::Positive, LMCAS::target, LMCAS::True , 以及 weak_subtraction_sign().

函数调用图:

◆ subtrahend()

std::shared_ptr< const SymbolicNode > LMCAS::InferenceEngine::Impl::subtrahend ( const std::shared_ptr< const SymbolicNode > & operand,
ComputationContext & context )
static

在文件 inference_engine_arithmetic.cpp 第 40 行定义.

41 {
42 auto mul = std::dynamic_pointer_cast<const MultiplyNode>(operand);
43 if (!mul || mul->operands().size() != 2) {
44 return nullptr;
45 }
46 bool found_neg_one = false;
47 std::shared_ptr<const SymbolicNode> other_operand;
48 for (const auto& mul_op : mul->operands()) {
49 auto step = context.consume_steps(1, "inference.arithmetic");
50 if (!step) throw step.error();
51 const auto number =
52 std::dynamic_pointer_cast<const NumberNode>(mul_op);
53 if (number && number->is_negative_one()) {
54 found_neg_one = true;
55 continue;
56 }
57 other_operand = mul_op;
58 }
59 return found_neg_one ? other_operand : nullptr;
60}

引用了 LMCAS::context , 以及 LMCAS::mul().

函数调用图:

◆ sum_nonzero()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::sum_nonzero ( const InferenceEngine & engine,
const AddNode & add,
ComputationContext & context ) const

在文件 inference_engine_core.cpp 第 215 行定义.

217 {
218 auto positive =
219 engine.infer_add_sign_checked(add, Sign::Positive, context);
220 if (!positive) {
221 return positive;
222 }
223 if (positive.value() == Tribool::True) {
224 return Tribool::True;
225 }
226 auto negative =
227 engine.infer_add_sign_checked(add, Sign::Negative, context);
228 if (!negative) {
229 return negative;
230 }
231 if (negative.value() == Tribool::True) {
232 return Tribool::True;
233 }
234 return Tribool::Unknown;
235}

引用了 LMCAS::add(), LMCAS::context, LMCAS::Negative, LMCAS::Positive, LMCAS::True , 以及 LMCAS::Unknown.

被这些函数引用 composite_nonzero().

函数调用图:
这是这个函数的调用关系图:

◆ sum_relation_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::sum_relation_sign ( const AddNode & add,
const SymbolicExpr & zero_expr,
Sign target,
ComputationContext & context ) const

在文件 inference_engine_relations.cpp 第 60 行定义.

63 {
64 if (add.operands().empty()) {
66 }
67
68 bool all_gt_zero = true;
69 bool all_geq_zero = true;
70
71 for (const auto& operand : add.operands()) {
72 auto result = accumulate_sum_relation_sign(
73 operand, zero_expr, all_gt_zero, all_geq_zero, context);
74 if (!result) {
75 return InferenceTriboolResult::failure(result.error());
76 }
77 }
78
79 if (target == Sign::Positive && all_gt_zero) {
81 }
82 if (target == Sign::NonNegative && all_geq_zero) {
84 }
86}
Result< void > accumulate_sum_relation_sign(const std::shared_ptr< const SymbolicNode > &operand, const SymbolicExpr &zero_expr, bool &all_gt_zero, bool &all_geq_zero, ComputationContext &context) const

引用了 accumulate_sum_relation_sign(), LMCAS::add(), LMCAS::context, LMCAS::Result< Tribool >::failure(), LMCAS::NonNegative, LMCAS::Positive, LMCAS::Result< Tribool >::success(), LMCAS::target, LMCAS::True , 以及 LMCAS::Unknown.

函数调用图:

◆ sum_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::sum_sign ( const InferenceEngine & engine,
const AddNode & node,
Sign target,
ComputationContext & context ) const

在文件 inference_engine_arithmetic.cpp 第 86 行定义.

89 {
90 bool all_have_property = true;
91
92 for (const auto& operand : node.operands()) {
93 auto step = context.consume_steps(1, "inference.arithmetic");
94 if (!step) throw step.error();
95 auto op_expr = LMCAS::detail::expression_from_node(operand);
96 Tribool op_result = Tribool::Unknown;
100 }
101 auto queried = engine.query_sign_of_checked(op_expr, target, context);
102 if (!queried) {
103 return queried;
104 }
105 op_result = queried.value();
106
107 if (op_result == Tribool::Unknown) {
109 }
110 if (op_result == Tribool::False) {
111 all_have_property = false;
112 }
113 }
114
115 if (all_have_property) {
117 }
118
120}

引用了 LMCAS::context, LMCAS::detail::expression_from_node(), LMCAS::False, LMCAS::Negative, LMCAS::NonNegative, LMCAS::NonPositive, LMCAS::Positive, LMCAS::Result< Tribool >::success(), LMCAS::target, LMCAS::True , 以及 LMCAS::Unknown.

函数调用图:

◆ trigonometric_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::trigonometric_sign ( const InferenceEngine & engine,
const SymbolicExpr & arg_expr,
ComputationContext & context ) const

在文件 inference_engine_functions.cpp 第 49 行定义.

51 {
52 auto real = engine.query_domain_of_checked(arg_expr, Domain::Real, context);
53 if (!real) {
54 return real;
55 }
56 return Tribool::Unknown;
57}

引用了 LMCAS::context, LMCAS::Real, LMCAS::real() , 以及 LMCAS::Unknown.

被这些函数引用 function_sign().

函数调用图:
这是这个函数的调用关系图:

◆ weak_subtraction_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::weak_subtraction_sign ( const InferenceEngine & engine,
const SymbolicExpr & minuend_expr,
const SymbolicExpr & subtrahend_expr,
Sign target,
ComputationContext & context ) const

在文件 inference_engine_arithmetic.cpp 第 163 行定义.

167 {
168 auto min_nn_result =
169 engine.query_sign_of_checked(minuend_expr, Sign::NonNegative, context);
170 if (!min_nn_result) {
171 return min_nn_result;
172 }
173 const Tribool min_nn = min_nn_result.value();
174 auto sub_np_result =
175 engine.query_sign_of_checked(subtrahend_expr, Sign::NonPositive, context);
176 if (!sub_np_result) {
177 return sub_np_result;
178 }
179 const Tribool sub_np = sub_np_result.value();
180 if (min_nn == Tribool::True && sub_np == Tribool::True) {
181 switch (target) {
184 default: break;
185 }
186 }
187
188 auto min_np_result =
189 engine.query_sign_of_checked(minuend_expr, Sign::NonPositive, context);
190 if (!min_np_result) {
191 return min_np_result;
192 }
193 const Tribool min_np = min_np_result.value();
194 auto sub_nn_result =
195 engine.query_sign_of_checked(subtrahend_expr, Sign::NonNegative, context);
196 if (!sub_nn_result) {
197 return sub_nn_result;
198 }
199 const Tribool sub_nn = sub_nn_result.value();
200 if (min_np == Tribool::True && sub_nn == Tribool::True) {
201 switch (target) {
204 default: break;
205 }
206 }
207
209}

引用了 LMCAS::context, LMCAS::False, LMCAS::Negative, LMCAS::NonNegative, LMCAS::NonPositive, LMCAS::Positive, LMCAS::Result< Tribool >::success(), LMCAS::target, LMCAS::True , 以及 LMCAS::Unknown.

被这些函数引用 subtraction_sign().

函数调用图:
这是这个函数的调用关系图:

◆ zero_power_sign()

InferenceTriboolResult LMCAS::InferenceEngine::Impl::zero_power_sign ( const InferenceEngine & engine,
const SymbolicExpr & base_expr,
const NumberNode * exp_num,
Sign target,
ComputationContext & context ) const

在文件 inference_engine_power.cpp 第 7 行定义.

11 {
12 if (!exp_num || !is_zero_number(*exp_num)) {
13 return Tribool::Unknown;
14 }
15 const detail::AssumptionFacts facts(engine);
16 auto base_nonzero = detail::query_nonzero_value(detail::node(base_expr), facts, Domain::Real, context);
17 if (!base_nonzero) return base_nonzero;
18 if (base_nonzero.value() == Tribool::True) {
19 return known_sign(1, target);
20 }
21 return Tribool::Unknown;
22}

引用了 LMCAS::context, LMCAS::is_zero_number(), known_sign(), LMCAS::detail::node(), LMCAS::detail::query_nonzero_value(), LMCAS::Real, LMCAS::target, LMCAS::True , 以及 LMCAS::Unknown.

函数调用图:

类成员变量说明

◆ ctx

const AssumptionContext& LMCAS::InferenceEngine::Impl::ctx

◆ current_depth

int LMCAS::InferenceEngine::Impl::current_depth = 0
mutable

在文件 inference_engine_impl.hpp 第 242 行定义.

◆ max_depth

int LMCAS::InferenceEngine::Impl::max_depth

在文件 inference_engine_impl.hpp 第 240 行定义.

被这些函数引用 Impl().

◆ visited

std::unordered_set<const SymbolicNode*> LMCAS::InferenceEngine::Impl::visited
mutable

在文件 inference_engine_impl.hpp 第 241 行定义.


该结构体的文档由以下文件生成: