Skip to content

Commit 0697253

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 0bb7c82 + 24b2d5a commit 0697253

File tree

10 files changed

+112
-41
lines changed

10 files changed

+112
-41
lines changed

include/cvc5/cvc5_proof_rule.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,16 @@ enum ENUM(ProofRule)
16851685
* \endverbatim
16861686
*/
16871687
EVALUE(RE_INTER),
1688+
/**
1689+
* \verbatim embed:rst:leading-asterisk
1690+
* **Strings -- Regular expressions -- Concatenation**
1691+
*
1692+
* .. math::
1693+
*
1694+
* \inferrule{t_1\in R_1,\,\ldots,\,t_n\in R_n\mid -}{\text{str.++}(t_1, \ldots, t_n)\in \text{re.++}(R_1, \ldots, R_n)}
1695+
* \endverbatim
1696+
*/
1697+
EVALUE(RE_CONCAT),
16881698
/**
16891699
* \verbatim embed:rst:leading-asterisk
16901700
* **Strings -- Regular expressions -- Positive Unfold**

proofs/eo/cpc/rules/Strings.eo

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@
311311

312312
;;-------------------- Regular expressions
313313

314+
;;;;; ProofRule::RE_INTER
315+
314316
; rule: re_inter
315317
; implements: ProofRule::RE_INTER
316318
; premises:
@@ -324,6 +326,38 @@
324326
:conclusion (str.in_re x (re.inter s t))
325327
)
326328

329+
;;;;; ProofRule::RE_CONCAT
330+
331+
; program: $mk_re_concat
332+
; args:
333+
; - E: A conjunction of regular expression memberships.
334+
; return: >
335+
; The concatenation of the strings in E is in the concatenation of the regular
336+
; expressions in E.
337+
(program $mk_re_concat ((Es Bool :list) (s String) (r RegLan))
338+
(Bool) Bool
339+
(
340+
(($mk_re_concat (and (str.in_re s r) Es)) (eo::match ((s1 String) (r1 RegLan))
341+
($mk_re_concat Es)
342+
(((str.in_re s1 r1) (str.in_re (eo::cons str.++ s s1) (eo::cons re.++ r r1))))))
343+
(($mk_re_concat true) (str.in_re "" @re.empty))
344+
)
345+
)
346+
347+
; rule: re_concat
348+
; implements: ProofRule::RE_CONCAT
349+
; premises:
350+
; - E [:list]: A conjunction of regular expression memberships.
351+
; conclusion: >
352+
; The concatenation of the strings in E is in the concatenation of the regular
353+
; expressions in E.
354+
(declare-rule re_concat ((E Bool))
355+
:premise-list E and
356+
:conclusion ($mk_re_concat E)
357+
)
358+
359+
;;;;; ProofRule::RE_UNFOLD_POS
360+
327361
; rule: re_unfold_pos
328362
; implements: ProofRule::RE_UNFOLD_POS
329363
; premises:
@@ -357,6 +391,8 @@
357391
))
358392
)
359393

394+
;;;;; ProofRule::RE_UNFOLD_NEG_CONCAT_FIXED
395+
360396
; rule: re_unfold_neg_concat_fixed
361397
; implements: ProofRule::RE_UNFOLD_NEG_CONCAT_FIXED
362398
; premises:
@@ -384,6 +420,8 @@
384420
))
385421
)
386422

423+
;;;;; ProofRule::RE_UNFOLD_NEG
424+
387425
; rule: re_unfold_neg
388426
; implements: ProofRule::RE_UNFOLD_NEG
389427
; premises:

src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,10 @@ set(REWRITES_FILES
14411441
${PROJECT_SOURCE_DIR}/src/theory/strings/rewrites
14421442
${PROJECT_SOURCE_DIR}/src/theory/strings/rewrites-regexp-membership
14431443
${PROJECT_SOURCE_DIR}/src/theory/uf/rewrites
1444+
# these files should only be enabled in expert builds and should
1445+
# be partitioned into their own proof signature
1446+
${PROJECT_SOURCE_DIR}/src/theory/arith/rewrites-transcendentals
1447+
${PROJECT_SOURCE_DIR}/src/theory/sets/rewrites-card
14441448
)
14451449

14461450
#-----------------------------------------------------------------------------#

src/api/cpp/cvc5_proof_rule_template.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ const char* toString(ProofRule rule)
148148
case ProofRule::STRING_REDUCTION: return "STRING_REDUCTION";
149149
case ProofRule::STRING_EAGER_REDUCTION: return "STRING_EAGER_REDUCTION";
150150
case ProofRule::RE_INTER: return "RE_INTER";
151+
case ProofRule::RE_CONCAT: return "RE_CONCAT";
151152
case ProofRule::RE_UNFOLD_POS: return "RE_UNFOLD_POS";
152153
case ProofRule::RE_UNFOLD_NEG: return "RE_UNFOLD_NEG";
153154
case ProofRule::RE_UNFOLD_NEG_CONCAT_FIXED:

src/proof/alf/alf_printer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ bool AlfPrinter::isHandled(const Options& opts, const ProofNode* pfn)
167167
case ProofRule::STRING_LENGTH_POS:
168168
case ProofRule::STRING_LENGTH_NON_EMPTY:
169169
case ProofRule::RE_INTER:
170+
case ProofRule::RE_CONCAT:
170171
case ProofRule::RE_UNFOLD_POS:
171172
case ProofRule::RE_UNFOLD_NEG_CONCAT_FIXED:
172173
case ProofRule::RE_UNFOLD_NEG:

src/theory/arith/rewrites

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,6 @@
7777
(>= (to_real t) c)
7878
(>= t cc))
7979

80-
; trancendentals
81-
82-
(define-rule arith-sine-zero () (sin 0/1) 0/1)
83-
(define-rule arith-sine-pi2 () (sin (* 1/2 real.pi)) 1/1)
84-
(define-rule arith-cosine-elim ((x Real)) (cos x) (sin (- (* 1/2 real.pi) x)))
85-
(define-rule arith-tangent-elim ((x Real)) (tan x) (/ (sin x) (cos x)))
86-
(define-rule arith-secent-elim ((x Real)) (sec x) (/ 1/1 (sin x)))
87-
(define-rule arith-cosecent-elim ((x Real)) (csc x) (/ 1/1 (cos x)))
88-
(define-rule arith-cotangent-elim ((x Real)) (cot x) (/ (cos x) (sin x)))
89-
90-
(define-rule arith-pi-not-int () (is_int real.pi) false)
91-
9280
; absolute value comparisons
9381

9482
(define-rule arith-abs-eq ((x ?) (y ?))
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; trancendentals
2+
3+
(define-rule arith-sine-zero () (sin 0/1) 0/1)
4+
(define-rule arith-sine-pi2 () (sin (* 1/2 real.pi)) 1/1)
5+
(define-rule arith-cosine-elim ((x Real)) (cos x) (sin (- (* 1/2 real.pi) x)))
6+
(define-rule arith-tangent-elim ((x Real)) (tan x) (/ (sin x) (cos x)))
7+
(define-rule arith-secent-elim ((x Real)) (sec x) (/ 1/1 (sin x)))
8+
(define-rule arith-cosecent-elim ((x Real)) (csc x) (/ 1/1 (cos x)))
9+
(define-rule arith-cotangent-elim ((x Real)) (cot x) (/ (cos x) (sin x)))
10+
11+
(define-rule arith-pi-not-int () (is_int real.pi) false)
12+

src/theory/sets/rewrites

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; Equality
1+
; Theory of sets
22

33
(define-cond-rule sets-eq-singleton-emp ((x ?Set) (y ?))
44
(= x (@set.empty_of_type (@type_of x)))
@@ -64,29 +64,10 @@
6464
(set.choose (set.singleton x))
6565
x)
6666

67-
(define-rule sets-card-singleton ((x ?))
68-
(set.card (set.singleton x))
69-
1)
70-
71-
(define-rule sets-card-union ((s ?Set) (t ?Set))
72-
(set.card (set.union s t))
73-
(- (+ (set.card s) (set.card t)) (set.card (set.inter s t))))
74-
75-
(define-rule sets-card-minus ((s ?Set) (t ?Set))
76-
(set.card (set.minus s t))
77-
(- (set.card s) (set.card (set.inter s t))))
78-
79-
(define-cond-rule sets-card-emp ((x ?Set))
80-
(= x (@set.empty_of_type (@type_of x)))
81-
(set.card x)
82-
0)
83-
8467
(define-rule sets-minus-self ((x ?Set))
8568
(set.minus x x)
8669
(@set.empty_of_type (@type_of x)))
8770

88-
; (set.complement S) ---> (set.minus (as set.universe (Set Int)) S)
89-
9071
(define-rule sets-is-empty-elim ((x ?Set))
9172
(set.is_empty x)
9273
(= x (@set.empty_of_type (@type_of x))))

src/theory/sets/rewrites-card

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
; Theory of sets with cardinality
2+
3+
(define-rule sets-card-singleton ((x ?))
4+
(set.card (set.singleton x))
5+
1)
6+
7+
(define-rule sets-card-union ((s ?Set) (t ?Set))
8+
(set.card (set.union s t))
9+
(- (+ (set.card s) (set.card t)) (set.card (set.inter s t))))
10+
11+
(define-rule sets-card-minus ((s ?Set) (t ?Set))
12+
(set.card (set.minus s t))
13+
(- (set.card s) (set.card (set.inter s t))))
14+
15+
(define-cond-rule sets-card-emp ((x ?Set))
16+
(= x (@set.empty_of_type (@type_of x)))
17+
(set.card x)
18+
0)
19+
20+
; (set.complement S) ---> (set.minus (as set.universe (Set Int)) S)

src/theory/strings/proof_checker.cpp

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ void StringProofRuleChecker::registerTo(ProofChecker* pc)
5555
pc->registerChecker(ProofRule::STRING_REDUCTION, this);
5656
pc->registerChecker(ProofRule::STRING_EAGER_REDUCTION, this);
5757
pc->registerChecker(ProofRule::RE_INTER, this);
58+
pc->registerChecker(ProofRule::RE_CONCAT, this);
5859
pc->registerChecker(ProofRule::RE_UNFOLD_POS, this);
5960
pc->registerChecker(ProofRule::RE_UNFOLD_NEG, this);
6061
pc->registerChecker(ProofRule::RE_UNFOLD_NEG_CONCAT_FIXED, this);
@@ -395,30 +396,45 @@ Node StringProofRuleChecker::checkInternal(ProofRule id,
395396
// memberships in the explanation
396397
for (const Node& c : children)
397398
{
398-
bool polarity = c.getKind() != Kind::NOT;
399-
Node catom = polarity ? c : c[0];
400-
if (catom.getKind() != Kind::STRING_IN_REGEXP)
399+
if (c.getKind() != Kind::STRING_IN_REGEXP)
401400
{
402401
return Node::null();
403402
}
404403
if (x.isNull())
405404
{
406-
x = catom[0];
405+
x = c[0];
407406
}
408-
else if (x != catom[0])
407+
else if (x != c[0])
409408
{
410409
// different LHS
411410
return Node::null();
412411
}
413-
Node xcurr = catom[0];
414-
Node rcurr =
415-
polarity ? catom[1] : nm->mkNode(Kind::REGEXP_COMPLEMENT, catom[1]);
416-
reis.push_back(rcurr);
412+
reis.push_back(c[1]);
417413
}
418414
Node rei =
419415
reis.size() == 1 ? reis[0] : nm->mkNode(Kind::REGEXP_INTER, reis);
420416
return nm->mkNode(Kind::STRING_IN_REGEXP, x, rei);
421417
}
418+
else if (id == ProofRule::RE_CONCAT)
419+
{
420+
Assert(children.size() >= 2);
421+
Assert(args.empty());
422+
std::vector<Node> ts;
423+
std::vector<Node> rs;
424+
// make the regular expression concatenation
425+
for (const Node& c : children)
426+
{
427+
if (c.getKind() != Kind::STRING_IN_REGEXP)
428+
{
429+
return Node::null();
430+
}
431+
ts.push_back(c[0]);
432+
rs.push_back(c[1]);
433+
}
434+
Node tc = nm->mkNode(Kind::STRING_CONCAT, ts);
435+
Node rc = nm->mkNode(Kind::REGEXP_CONCAT, rs);
436+
return nm->mkNode(Kind::STRING_IN_REGEXP, tc, rc);
437+
}
422438
else if (id == ProofRule::RE_UNFOLD_POS || id == ProofRule::RE_UNFOLD_NEG
423439
|| id == ProofRule::RE_UNFOLD_NEG_CONCAT_FIXED)
424440
{

0 commit comments

Comments
 (0)