LMCAS
Lamina Computer Algebra System
载入中...
搜索中...
未找到
LMCAS::assumption_detail::AssumptionParser类 参考

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

LMCAS::assumption_detail::AssumptionParser 的协作图:

Public 成员函数

 AssumptionParser (ComputationContext &context)
AssumptionContext parse (const std::string &data)

Private 成员函数

void parse_bounded (std::istringstream &ls, const std::string &keyword)
void parse_conditional (std::istringstream &ls, const std::string &keyword)
void parse_continuity (std::istringstream &ls, const std::string &keyword)
void parse_definiteness (std::istringstream &ls, const std::string &keyword)
void parse_domain (std::istringstream &ls, const std::string &keyword)
void parse_finiteness (std::istringstream &ls, const std::string &keyword)
void parse_monotonicity (std::istringstream &ls, const std::string &keyword)
void parse_parity (std::istringstream &ls, const std::string &keyword)
void parse_periodic (std::istringstream &ls, const std::string &keyword)
void parse_record (const std::string &line)
void parse_relation (std::istringstream &ls, const std::string &keyword)
void parse_scope (std::istringstream &ls, const std::string &keyword)
void parse_sign (std::istringstream &ls, const std::string &keyword)
void parse_transcendental (std::istringstream &ls, const std::string &keyword)

Private 属性

ComputationContext & computation
AssumptionContext ctx
int current_scope = -1
bool ended = false
int line_num = 0

详细描述

在文件 assumption_parser.hpp 第 34 行定义.

构造及析构函数说明

◆ AssumptionParser()

LMCAS::assumption_detail::AssumptionParser::AssumptionParser ( ComputationContext & context)
inlineexplicit

在文件 assumption_parser.hpp 第 36 行定义.

const std::vector< Polynomial< BigInt > > const BigInt ComputationContext & context

引用了 computation , 以及 LMCAS::context.

被这些函数引用 parse_record().

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

成员函数说明

◆ parse()

AssumptionContext LMCAS::assumption_detail::AssumptionParser::parse ( const std::string & data)

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

5 {
6 std::istringstream input(data);
7 std::string line;
8 while (std::getline(input, line)) {
9 ++line_num;
10 if (line.empty()) continue;
11 if (line.back() == '\r') line.pop_back();
12 if (line.empty()) continue;
13 if (ended) {
14 throw std::invalid_argument(
15 "Line " + std::to_string(line_num) + ": data after END");
16 }
17 if (line == "END") {
18 ended = true;
19 continue;
20 }
21 parse_record(line);
22 }
23 if (!ended) {
24 throw std::invalid_argument(
25 "Line " + std::to_string(line_num) + ": unexpected end of input (missing END)");
26 }
27 return std::move(ctx);
28}

引用了 ctx, ended, line_num , 以及 parse_record().

函数调用图:

◆ parse_bounded()

void LMCAS::assumption_detail::AssumptionParser::parse_bounded ( std::istringstream & ls,
const std::string & keyword )
private

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

48 {
49 std::string symbol;
50 std::string boundedness_text;
51 if (!(ls >> symbol >> boundedness_text)) {
52 throw std::invalid_argument(
53 "Line " + std::to_string(line_num) +
54 ": BOUNDED requires symbol and boundedness");
55 }
56 const Boundedness bounded =
57 parse_boundedness(boundedness_text, line_num);
58
59 std::string payload;
60 std::getline(ls, payload);
61 const auto bounds_text = trim_ascii_whitespace(payload);
62 std::optional<Interval> bounds;
63 if (!bounds_text.empty()) {
64 if (bounded != Boundedness::Bounded) {
65 throw std::invalid_argument(
66 "Line " + std::to_string(line_num) +
67 ": only Bounded declarations may carry an interval");
68 }
69 bounds = parse_interval(
70 std::string(bounds_text), line_num, computation);
71 }
73 ctx.current_properties().declare_bounded_checked(
74 symbol, bounded, std::move(bounds), computation),
75 line_num, keyword);
76}
std::string_view trim_ascii_whitespace(std::string_view text) noexcept
void require_deserialization_update(const Result< void > &result, int line, const std::string &keyword)
Boundedness parse_boundedness(const std::string &s, int line_num)
Interval parse_interval(const std::string &text, int line_num, ComputationContext &context)
Boundedness
Boundedness classification for symbols.
@ Bounded
Symbol has finite bounds

引用了 LMCAS::Bounded, computation, ctx, line_num, LMCAS::assumption_detail::parse_boundedness(), LMCAS::assumption_detail::parse_interval(), LMCAS::assumption_detail::require_deserialization_update() , 以及 LMCAS::assumption_detail::trim_ascii_whitespace().

被这些函数引用 parse_record().

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

◆ parse_conditional()

void LMCAS::assumption_detail::AssumptionParser::parse_conditional ( std::istringstream & ls,
const std::string & keyword )
private

在文件 assumption_parse_relations.cpp 第 175 行定义.

176 {
177 std::string text;
178 std::getline(input, text);
179 const auto trimmed = trim_ascii_whitespace(text);
180 if (trimmed.empty()) {
181 throw std::invalid_argument(
182 "Line " + std::to_string(line_num) +
183 ": CONDITIONAL requires condition and conclusion");
184 }
185 text = trimmed;
186 const auto arrows =
187 find_top_level_tokens(text, {"=>"}, line_num);
188 if (arrows.size() != 1) {
189 throw std::invalid_argument(
190 "Line " + std::to_string(line_num) +
191 ": CONDITIONAL requires one top-level '=>'");
192 }
193
194 const auto arrow = arrows.front();
195 const std::string condition_text = unwrap_parenthesized(
196 text.substr(0, arrow.position), line_num, "condition");
197 const std::string conclusion_text = unwrap_parenthesized(
198 text.substr(arrow.position + arrow.token.size()),
199 line_num, "conclusion");
200 SymbolicExpr condition = parse_conditional_relation(
201 condition_text, line_num, computation);
202 SymbolicExpr conclusion = parse_conditional_relation(
203 conclusion_text, line_num, computation);
205 ctx.assume_conditional_checked(condition, conclusion),
206 line_num, keyword);
207}
SymbolicExpr parse_conditional_relation(const std::string &text, int line_num, ComputationContext &context)
std::vector< TopLevelToken > find_top_level_tokens(const std::string &text, const std::vector< std::string_view > &tokens, int line_num)
std::string unwrap_parenthesized(const std::string &text, int line_num, const char *role)

引用了 computation, ctx, line_num, LMCAS::assumption_detail::require_deserialization_update() , 以及 LMCAS::assumption_detail::trim_ascii_whitespace().

被这些函数引用 parse_record().

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

◆ parse_continuity()

void LMCAS::assumption_detail::AssumptionParser::parse_continuity ( std::istringstream & ls,
const std::string & keyword )
private

在文件 assumption_parse_intervals.cpp 第 27 行定义.

28 {
29 std::string sym;
30 if (!(ls >> sym)) {
31 throw std::invalid_argument(
32 "Line " + std::to_string(line_num) + ": " + keyword + " requires symbol");
33 }
34 std::string iv_str;
35 std::getline(ls, iv_str);
36 const auto interval_text = trim_ascii_whitespace(iv_str);
37 if (interval_text.empty()) {
38 throw std::invalid_argument(
39 "Line " + std::to_string(line_num) + ": " + keyword + " requires interval");
40 }
41 Interval iv = parse_interval(
42 std::string(interval_text), line_num, computation);
43 auto declared = keyword == "DIFFERENTIABLE"
44 ? ctx.current_properties().declare_differentiable_checked(
45 sym, iv, computation)
46 : ctx.current_properties().declare_continuous_checked(
47 sym, iv, computation);
48 require_deserialization_update(declared, line_num, keyword);
49}
ExprResult sym(const std::string &name)

引用了 computation, ctx, line_num, LMCAS::assumption_detail::parse_interval(), LMCAS::assumption_detail::require_deserialization_update(), LMCAS::sym() , 以及 LMCAS::assumption_detail::trim_ascii_whitespace().

被这些函数引用 parse_record().

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

◆ parse_definiteness()

void LMCAS::assumption_detail::AssumptionParser::parse_definiteness ( std::istringstream & ls,
const std::string & keyword )
private

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

106 {
107
108 std::string sym, def_str;
109 if (!(ls >> sym >> def_str)) {
110 throw std::invalid_argument(
111 "Line " + std::to_string(line_num) + ": DEFINITENESS requires symbol and value");
112 }
114 require_line_end(ls, line_num, keyword);
116 ctx.current_properties().declare_definiteness_checked(sym, d), line_num, keyword);
117}
void require_line_end(std::istringstream &input, int line_num, const std::string &keyword)
Definiteness parse_definiteness(const std::string &s, int line_num)
Definiteness
Matrix definiteness classification.

引用了 ctx, line_num, LMCAS::assumption_detail::parse_definiteness(), LMCAS::assumption_detail::require_deserialization_update(), LMCAS::assumption_detail::require_line_end() , 以及 LMCAS::sym().

被这些函数引用 parse_record().

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

◆ parse_domain()

void LMCAS::assumption_detail::AssumptionParser::parse_domain ( std::istringstream & ls,
const std::string & keyword )
private

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

6 {
7
8 std::string sym, dom_str;
9 if (!(ls >> sym >> dom_str)) {
10 throw std::invalid_argument(
11 "Line " + std::to_string(line_num) + ": DOMAIN requires symbol and domain");
12 }
13 require_line_end(ls, line_num, keyword);
16 ctx.current_properties().declare_domain_checked(sym, dom), line_num, keyword);
17}
Domain parse_domain(const std::string &s, int line_num)
Domain
Mathematical domain hierarchy (least specific → most specific). Complex ⊃ Real ⊃ Algebraic ⊃ Rational...

引用了 ctx, line_num, LMCAS::assumption_detail::parse_domain(), LMCAS::assumption_detail::require_deserialization_update(), LMCAS::assumption_detail::require_line_end() , 以及 LMCAS::sym().

被这些函数引用 parse_record().

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

◆ parse_finiteness()

void LMCAS::assumption_detail::AssumptionParser::parse_finiteness ( std::istringstream & ls,
const std::string & keyword )
private

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

92 {
93
94 std::string sym, fin_str;
95 if (!(ls >> sym >> fin_str)) {
96 throw std::invalid_argument(
97 "Line " + std::to_string(line_num) + ": FINITENESS requires symbol and value");
98 }
100 require_line_end(ls, line_num, keyword);
102 ctx.current_properties().declare_finiteness_checked(sym, f), line_num, keyword);
103}
Finiteness parse_finiteness(const std::string &s, int line_num)
Finiteness
Finiteness classification for limits and sequences.

引用了 ctx, line_num, LMCAS::assumption_detail::parse_finiteness(), LMCAS::assumption_detail::require_deserialization_update(), LMCAS::assumption_detail::require_line_end() , 以及 LMCAS::sym().

被这些函数引用 parse_record().

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

◆ parse_monotonicity()

void LMCAS::assumption_detail::AssumptionParser::parse_monotonicity ( std::istringstream & ls,
const std::string & keyword )
private

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

53 {
54
55 std::string sym, var;
56 if (!(ls >> sym >> var)) {
57 throw std::invalid_argument(
58 "Line " + std::to_string(line_num) +
59 ": MONOTONICITY requires symbol and variable");
60 }
61 std::string rest_line;
62 std::getline(ls, rest_line);
63 const auto monotonicity_text = trim_ascii_whitespace(rest_line);
64 if (monotonicity_text.empty()) {
65 throw std::invalid_argument(
66 "Line " + std::to_string(line_num) +
67 ": MONOTONICITY requires interval and type");
68 }
69 rest_line = monotonicity_text;
70 size_t bracket_end = std::string::npos;
71 if (rest_line.front() == '[' || rest_line.front() == '(') {
72 size_t depth = 0;
73 for (size_t i = 1; i < rest_line.size(); ++i) {
74 const char c = rest_line[i];
75 if (c == '(' || c == '[') {
76 ++depth;
77 } else if (c == ')' || c == ']') {
78 if (depth == 0) {
79 bracket_end = i;
80 break;
81 }
82 --depth;
83 }
84 }
85 }
86 if (bracket_end == std::string::npos) {
87 throw std::invalid_argument(
88 "Line " + std::to_string(line_num) +
89 ": MONOTONICITY malformed interval");
90 }
91 std::string mono_iv_str = rest_line.substr(0, bracket_end + 1);
92 Interval iv = parse_interval(mono_iv_str, line_num, computation);
93
94 std::string mono_str = rest_line.substr(bracket_end + 1);
95 const auto type_text = trim_ascii_whitespace(mono_str);
96 if (type_text.empty()) {
97 throw std::invalid_argument(
98 "Line " + std::to_string(line_num) +
99 ": MONOTONICITY requires type after interval");
100 }
101 mono_str = type_text;
102
105 ctx.current_properties().declare_monotonicity_checked(
106 sym, var, iv, m, computation),
107 line_num, keyword);
108}
Monotonicity parse_monotonicity(const std::string &s, int line_num)
const VectorField const VectorField & c
Monotonicity
Monotonicity classification for functions over intervals.
std::size_t std::size_t depth

引用了 LMCAS::c, computation, ctx, LMCAS::depth, line_num, LMCAS::assumption_detail::parse_interval(), LMCAS::assumption_detail::parse_monotonicity(), LMCAS::assumption_detail::require_deserialization_update(), LMCAS::sym() , 以及 LMCAS::assumption_detail::trim_ascii_whitespace().

被这些函数引用 parse_record().

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

◆ parse_parity()

void LMCAS::assumption_detail::AssumptionParser::parse_parity ( std::istringstream & ls,
const std::string & keyword )
private

在文件 assumption_parse_properties.cpp 第 33 行定义.

34 {
35
36 std::string sym, par_str;
37 if (!(ls >> sym >> par_str)) {
38 throw std::invalid_argument(
39 "Line " + std::to_string(line_num) + ": PARITY requires symbol and parity");
40 }
41 require_line_end(ls, line_num, keyword);
44 ctx.current_properties().declare_parity_checked(sym, p), line_num, keyword);
45}
Parity parse_parity(const std::string &s, int line_num)
Parity
Integer parity classification.

引用了 ctx, line_num, LMCAS::assumption_detail::parse_parity(), LMCAS::assumption_detail::require_deserialization_update(), LMCAS::assumption_detail::require_line_end() , 以及 LMCAS::sym().

被这些函数引用 parse_record().

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

◆ parse_periodic()

void LMCAS::assumption_detail::AssumptionParser::parse_periodic ( std::istringstream & ls,
const std::string & keyword )
private

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

6 {
7 std::string sym, variable;
8 if (!(ls >> sym >> variable)) {
9 throw std::invalid_argument(
10 "Line " + std::to_string(line_num) + ": PERIODIC requires symbol and variable");
11 }
12 std::string period_str;
13 std::getline(ls, period_str);
14 const auto period_text = trim_ascii_whitespace(period_str);
15 if (period_text.empty()) {
16 throw std::invalid_argument(
17 "Line " + std::to_string(line_num) + ": PERIODIC requires period value");
18 }
19 auto period = parse_serialized_expression(
20 std::string(period_text), line_num, computation);
22 ctx.current_properties().declare_periodic_checked(
23 sym, variable, period),
24 line_num, keyword);
25}
SymbolicExpr parse_serialized_expression(const std::string &text, int line_num, ComputationContext &context)
const std::string & variable

引用了 computation, ctx, line_num, LMCAS::assumption_detail::parse_serialized_expression(), LMCAS::assumption_detail::require_deserialization_update(), LMCAS::sym(), LMCAS::assumption_detail::trim_ascii_whitespace() , 以及 LMCAS::variable.

被这些函数引用 parse_record().

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

◆ parse_record()

void LMCAS::assumption_detail::AssumptionParser::parse_record ( const std::string & line)
private

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

30 {
31 std::istringstream ls(line);
32 std::string keyword;
33 ls >> keyword;
34 using Handler = void (AssumptionParser::*)(std::istringstream&, const std::string&);
35 struct Command {
36 const char* name;
37 Handler handler;
38 };
39 static const Command commands[] = {
45 {"TRANSCENDENTAL", &AssumptionParser::parse_transcendental},
47 {"DEFINITENESS", &AssumptionParser::parse_definiteness},
52 {"DIFFERENTIABLE", &AssumptionParser::parse_continuity},
53 {"MONOTONICITY", &AssumptionParser::parse_monotonicity},
54 };
55 for (const auto& command : commands) {
56 if (keyword == command.name) {
57 if (command.handler != &AssumptionParser::parse_scope && current_scope < 0) {
58 throw std::invalid_argument(
59 "Line " + std::to_string(line_num) + ": " + keyword + " before SCOPE");
60 }
61 (this->*command.handler)(ls, keyword);
62 return;
63 }
64 }
65 if (keyword == "END") {
66 throw std::invalid_argument(
67 "Line " + std::to_string(line_num) + ": malformed END record");
68 }
69 throw std::invalid_argument(
70 "Line " + std::to_string(line_num) + ": unknown keyword '" + keyword + "'");
71}
void parse_relation(std::istringstream &ls, const std::string &keyword)
void parse_periodic(std::istringstream &ls, const std::string &keyword)
void parse_bounded(std::istringstream &ls, const std::string &keyword)
void parse_transcendental(std::istringstream &ls, const std::string &keyword)
void parse_parity(std::istringstream &ls, const std::string &keyword)
void parse_domain(std::istringstream &ls, const std::string &keyword)
void parse_conditional(std::istringstream &ls, const std::string &keyword)
void parse_continuity(std::istringstream &ls, const std::string &keyword)
void parse_sign(std::istringstream &ls, const std::string &keyword)
void parse_finiteness(std::istringstream &ls, const std::string &keyword)
void parse_definiteness(std::istringstream &ls, const std::string &keyword)
void parse_scope(std::istringstream &ls, const std::string &keyword)
void parse_monotonicity(std::istringstream &ls, const std::string &keyword)
__attribute__((visibility("default"))) Result< EqvProfile > eqv_profile_from_name(const std const std::string & name

引用了 AssumptionParser(), current_scope, line_num, LMCAS::name, parse_bounded(), parse_conditional(), parse_continuity(), parse_definiteness(), parse_domain(), parse_finiteness(), parse_monotonicity(), parse_parity(), parse_periodic(), parse_relation(), parse_scope(), parse_sign() , 以及 parse_transcendental().

被这些函数引用 parse().

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

◆ parse_relation()

void LMCAS::assumption_detail::AssumptionParser::parse_relation ( std::istringstream & ls,
const std::string & keyword )
private

在文件 assumption_parse_relations.cpp 第 156 行定义.

157 {
158 std::string text;
159 std::getline(input, text);
160 const auto trimmed = trim_ascii_whitespace(text);
161 if (trimmed.empty()) {
162 throw std::invalid_argument(
163 "Line " + std::to_string(line_num) +
164 ": RELATION requires lhs, op, and rhs");
165 }
167 std::string(trimmed), line_num, false, computation);
169 ctx.current_relations().add_relation_checked(
170 relation.lhs, relation.rhs, relation.op,
171 ctx.current_properties()),
172 line_num, keyword);
173}
Relation parse_relation(const std::string &text, int line_num, bool conditional, ComputationContext &context)
ExprResult relation(const ExprPtr &lhs, const ExprPtr &rhs, RelationOp op)

引用了 computation, ctx, line_num, LMCAS::assumption_detail::parse_relation(), LMCAS::relation(), LMCAS::assumption_detail::require_deserialization_update() , 以及 LMCAS::assumption_detail::trim_ascii_whitespace().

被这些函数引用 parse_record().

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

◆ parse_scope()

void LMCAS::assumption_detail::AssumptionParser::parse_scope ( std::istringstream & ls,
const std::string & keyword )
private

在文件 assumption_deserialization.cpp 第 73 行定义.

74 {
75 int idx;
76 if (!(ls >> idx)) {
77 throw std::invalid_argument(
78 "Line " + std::to_string(line_num) + ": SCOPE missing index");
79 }
80 require_line_end(ls, line_num, keyword);
81 if (idx != current_scope + 1) {
82 throw std::invalid_argument(
83 "Line " + std::to_string(line_num) +
84 ": SCOPE indices must be sequential from zero");
85 }
86 if (idx > 0) {
87 ctx.push();
88 }
89 current_scope = idx;
90}

引用了 ctx, current_scope, line_num , 以及 LMCAS::assumption_detail::require_line_end().

被这些函数引用 parse_record().

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

◆ parse_sign()

void LMCAS::assumption_detail::AssumptionParser::parse_sign ( std::istringstream & ls,
const std::string & keyword )
private

在文件 assumption_parse_properties.cpp 第 19 行定义.

20 {
21
22 std::string sym, sign_str;
23 if (!(ls >> sym >> sign_str)) {
24 throw std::invalid_argument(
25 "Line " + std::to_string(line_num) + ": SIGN requires symbol and sign");
26 }
27 require_line_end(ls, line_num, keyword);
30 ctx.current_properties().declare_sign_checked(sym, s), line_num, keyword);
31}
Sign parse_sign(const std::string &s, int line_num)
Sign
Sign classification for symbols and expressions.

引用了 ctx, line_num, LMCAS::assumption_detail::parse_sign(), LMCAS::assumption_detail::require_deserialization_update(), LMCAS::assumption_detail::require_line_end() , 以及 LMCAS::sym().

被这些函数引用 parse_record().

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

◆ parse_transcendental()

void LMCAS::assumption_detail::AssumptionParser::parse_transcendental ( std::istringstream & ls,
const std::string & keyword )
private

在文件 assumption_parse_properties.cpp 第 78 行定义.

79 {
80
81 std::string sym;
82 if (!(ls >> sym)) {
83 throw std::invalid_argument(
84 "Line " + std::to_string(line_num) + ": TRANSCENDENTAL requires symbol");
85 }
86 require_line_end(ls, line_num, keyword);
88 ctx.current_properties().declare_transcendental_checked(sym), line_num, keyword);
89}

引用了 ctx, line_num, LMCAS::assumption_detail::require_deserialization_update(), LMCAS::assumption_detail::require_line_end() , 以及 LMCAS::sym().

被这些函数引用 parse_record().

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

类成员变量说明

◆ computation

ComputationContext& LMCAS::assumption_detail::AssumptionParser::computation
private

◆ ctx

◆ current_scope

int LMCAS::assumption_detail::AssumptionParser::current_scope = -1
private

在文件 assumption_parser.hpp 第 43 行定义.

被这些函数引用 parse_record() , 以及 parse_scope().

◆ ended

bool LMCAS::assumption_detail::AssumptionParser::ended = false
private

在文件 assumption_parser.hpp 第 44 行定义.

被这些函数引用 parse().

◆ line_num


该类的文档由以下文件生成: