1 /********************* */
4 ** Top contributors (to current version):
5 ** Andrew Reynolds, Haniel Barbosa, Alex Ozdemir
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS
8 ** in the top-level source directory and their institutional affiliations.
9 ** All rights reserved. See the file COPYING in the top-level source
10 ** directory for licensing information.\endverbatim
12 ** \brief Proof rule enumeration
15 #include "cvc4_private.h"
17 #ifndef CVC4__EXPR__PROOF_RULE_H
18 #define CVC4__EXPR__PROOF_RULE_H
25 * An enumeration for proof rules. This enumeration is analogous to Kind for
26 * Node objects. In the documentation below, P:F denotes a ProofNode that
29 * Conceptually, the following proof rules form a calculus whose target
30 * user is the Node-level theory solvers. This means that the rules below
31 * are designed to reason about, among other things, common operations on Node
32 * objects like Rewriter::rewrite or Node::substitute. It is intended to be
33 * translated or printed in other formats.
35 * The following PfRule values include core rules and those categorized by
36 * theory, including the theory of equality.
38 * The "core rules" include two distinguished rules which have special status:
39 * (1) ASSUME, which represents an open leaf in a proof.
40 * (2) SCOPE, which closes the scope of assumptions.
41 * The core rules additionally correspond to generic operations that are done
42 * internally on nodes, e.g. calling Rewriter::rewrite.
44 enum class PfRule
: uint32_t
46 //================================================= Core rules
47 //======================== Assume and Scope
48 // ======== Assumption (a leaf)
54 // This rule has special status, in that an application of assume is an
55 // open leaf in a proof that is not (yet) justified. An assume leaf is
56 // analogous to a free variable in a term, where we say "F is a free
57 // assumption in proof P" if it contains an application of F that is not
58 // bound by SCOPE (see below).
60 // ======== Scope (a binder for assumptions)
62 // Arguments: (F1, ..., Fn)
64 // Conclusion: (=> (and F1 ... Fn) F) or (not (and F1 ... Fn)) if F is false
66 // This rule has a dual purpose with ASSUME. It is a way to close
67 // assumptions in a proof. We require that F1 ... Fn are free assumptions in
68 // P and say that F1, ..., Fn are not free in (SCOPE P). In other words, they
69 // are bound by this application. For example, the proof node:
70 // (SCOPE (ASSUME F) :args F)
71 // has the conclusion (=> F F) and has no free assumptions. More generally, a
72 // proof with no free assumptions always concludes a valid formula.
75 //======================== Builtin theory (common node operations)
76 // ======== Substitution
77 // Children: (P1:F1, ..., Pn:Fn)
78 // Arguments: (t, (ids)?)
79 // ---------------------------------------------------------------
80 // Conclusion: (= t t*sigma{ids}(Fn)*...*sigma{ids}(F1))
81 // where sigma{ids}(Fi) are substitutions, which notice are applied in
83 // Notice that ids is a MethodId identifier, which determines how to convert
84 // the formulas F1, ..., Fn into substitutions.
88 // Arguments: (t, (idr)?)
89 // ----------------------------------------
90 // Conclusion: (= t Rewriter{idr}(t))
91 // where idr is a MethodId identifier, which determines the kind of rewriter
92 // to apply, e.g. Rewriter::rewrite.
97 // ----------------------------------------
98 // Conclusion: (= t Evaluator::evaluate(t))
99 // Note this is equivalent to:
100 // (REWRITE t MethodId::RW_EVALUATE)
102 // ======== Substitution + Rewriting equality introduction
104 // In this rule, we provide a term t and conclude that it is equal to its
105 // rewritten form under a (proven) substitution.
107 // Children: (P1:F1, ..., Pn:Fn)
108 // Arguments: (t, (ids (idr)?)?)
109 // ---------------------------------------------------------------
110 // Conclusion: (= t t')
113 // Rewriter{idr}(t*sigma{ids}(Fn)*...*sigma{ids}(F1))
115 // In other words, from the point of view of Skolem forms, this rule
116 // transforms t to t' by standard substitution + rewriting.
118 // The argument ids and idr is optional and specify the identifier of the
119 // substitution and rewriter respectively to be used. For details, see
120 // theory/builtin/proof_checker.h.
122 // ======== Substitution + Rewriting predicate introduction
124 // In this rule, we provide a formula F and conclude it, under the condition
125 // that it rewrites to true under a proven substitution.
127 // Children: (P1:F1, ..., Pn:Fn)
128 // Arguments: (F, (ids (idr)?)?)
129 // ---------------------------------------------------------------
132 // Rewriter{idr}(F*sigma{ids}(Fn)*...*sigma{ids}(F1)) == true
133 // where ids and idr are method identifiers.
135 // More generally, this rule also holds when:
136 // Rewriter::rewrite(toWitness(F')) == true
137 // where F' is the result of the left hand side of the equality above. Here,
138 // notice that we apply rewriting on the witness form of F', meaning that this
139 // rule may conclude an F whose Skolem form is justified by the definition of
140 // its (fresh) Skolem variables. For example, this rule may justify the
141 // conclusion (= k t) where k is the purification Skolem for t, whose
142 // witness form is (witness ((x T)) (= x t)).
144 // Furthermore, notice that the rewriting and substitution is applied only
145 // within the side condition, meaning the rewritten form of the witness form
146 // of F does not escape this rule.
148 // ======== Substitution + Rewriting predicate elimination
150 // In this rule, if we have proven a formula F, then we may conclude its
151 // rewritten form under a proven substitution.
153 // Children: (P1:F, P2:F1, ..., P_{n+1}:Fn)
154 // Arguments: ((ids (idr)?)?)
155 // ----------------------------------------
159 // Rewriter{idr}(F*sigma{ids}(Fn)*...*sigma{ids}(F1)).
160 // where ids and idr are method identifiers.
162 // We rewrite only on the Skolem form of F, similar to MACRO_SR_EQ_INTRO.
164 // ======== Substitution + Rewriting predicate transform
166 // In this rule, if we have proven a formula F, then we may provide a formula
167 // G and conclude it if F and G are equivalent after rewriting under a proven
170 // Children: (P1:F, P2:F1, ..., P_{n+1}:Fn)
171 // Arguments: (G, (ids (idr)?)?)
172 // ----------------------------------------
175 // Rewriter{idr}(F*sigma{ids}(Fn)*...*sigma{ids}(F1)) ==
176 // Rewriter{idr}(G*sigma{ids}(Fn)*...*sigma{ids}(F1))
178 // More generally, this rule also holds when:
179 // Rewriter::rewrite(toWitness(F')) == Rewriter::rewrite(toWitness(G'))
180 // where F' and G' are the result of each side of the equation above. Here,
181 // witness forms are used in a similar manner to MACRO_SR_PRED_INTRO above.
182 MACRO_SR_PRED_TRANSFORM
,
184 //================================================= Processing rules
185 // ======== Remove Term Formulas Axiom
188 // ---------------------------------------------------------------
189 // Conclusion: RemoveTermFormulas::getAxiomFor(t).
190 REMOVE_TERM_FORMULA_AXIOM
,
192 //================================================= Trusted rules
193 // ======== Theory lemma
195 // Arguments: (F, tid)
196 // ---------------------------------------------------------------
198 // where F is a (T-valid) theory lemma generated by theory with TheoryId tid.
199 // This is a "coarse-grained" rule that is used as a placeholder if a theory
200 // did not provide a proof for a lemma or conflict.
202 // ======== Theory Rewrite
204 // Arguments: (F, tid, rid)
205 // ----------------------------------------
207 // where F is an equality of the form (= t t') where t' is obtained by
208 // applying the kind of rewriting given by the method identifier rid, which
210 // { RW_REWRITE_THEORY_PRE, RW_REWRITE_THEORY_POST, RW_REWRITE_EQ_EXT }
211 // Notice that the checker for this rule does not replay the rewrite to ensure
212 // correctness, since theory rewriter methods are not static. For example,
213 // the quantifiers rewriter involves constructing new bound variables that are
214 // not guaranteed to be consistent on each call.
216 // The rules in this section have the signature of a "trusted rule":
220 // ---------------------------------------------------------------
223 // where F is an equality of the form t = t' where t was replaced by t'
224 // based on some preprocessing pass, or otherwise F was added as a new
225 // assertion by some preprocessing pass.
227 // where F was added as a new assertion by some preprocessing pass.
229 // where F is an equality of the form t = Theory::ppRewrite(t) for some
230 // theory. Notice this is a "trusted" rule.
232 // where F was added as a new assertion by theory preprocessing.
233 THEORY_PREPROCESS_LEMMA
,
234 // where F is an existential (exists ((x T)) (P x)) used for introducing
235 // a witness term (witness ((x T)) (P x)).
237 // where F is an equality (= t t') that holds by a form of rewriting that
238 // could not be replayed during proof postprocessing.
240 // where F is an equality (= t t') that holds by a form of substitution that
241 // could not be replayed during proof postprocessing.
243 // where F is an equality (= t t') that holds by a form of substitution that
244 // could not be determined by the TrustSubstitutionMap.
247 //================================================= Boolean rules
248 // ======== Resolution
251 // Arguments: (id, L)
252 // ---------------------
255 // - C1 and C2 are nodes viewed as clauses, i.e., either an OR node with
256 // each children viewed as a literal or a node viewed as a literal. Note
257 // that an OR node could also be a literal.
258 // - id is either true or false
259 // - L is the pivot of the resolution, which occurs as is (resp. under a
260 // NOT) in C1 and negatively (as is) in C2 if id = true (id = false).
261 // C is a clause resulting from collecting all the literals in C1, minus the
262 // first occurrence of the pivot or its negation, and C2, minus the first
263 // occurrence of the pivot or its negation, according to the policy above.
264 // If the resulting clause has a single literal, that literal itself is the
265 // result; if it has no literals, then the result is false; otherwise it's
266 // an OR node of the resulting literals.
268 // Note that it may be the case that the pivot does not occur in the
269 // clauses. In this case the rule is not unsound, but it does not correspond
270 // to resolution but rather to a weakening of the clause that did not have a
271 // literal eliminated.
273 // ======== Chain Resolution
274 // Children: (P1:(or F_{1,1} ... F_{1,n1}), ..., Pm:(or F_{m,1} ... F_{m,nm}))
275 // Arguments: (L_1, ..., L_{m-1})
276 // ---------------------
279 // let "C_1 <>_l C_2" represent the resolution of C_1 with C_2 with pivot l,
280 // let C_1' = C_1 (from P_1),
281 // for each i > 1, C_i' = C_i <>_L_i C_{i-1}'
283 // ======== Factoring
286 // ---------------------
289 // Set representations of C1 and C2 is the same and the number of literals in
290 // C2 is smaller than that of C1
292 // ======== Reordering
295 // ---------------------
298 // Set representations of C1 and C2 is the same but the number of literals in
299 // C2 is the same of that of C1
305 // ---------------------
306 // Conclusion: (or F (not F))
308 // ======== Equality resolution
309 // Children: (P1:F1, P2:(= F1 F2))
311 // ---------------------
313 // Note this can optionally be seen as a macro for EQUIV_ELIM1+RESOLUTION.
315 // ======== Modus ponens
316 // Children: (P1:F1, P2:(=> F1 F2))
318 // ---------------------
320 // Note this can optionally be seen as a macro for IMPLIES_ELIM+RESOLUTION.
322 // ======== Double negation elimination
323 // Children: (P:(not (not F)))
325 // ---------------------
328 // ======== Contradiction
329 // Children: (P1:F P2:(not F))
331 // ---------------------
334 // ======== And elimination
335 // Children: (P:(and F1 ... Fn))
337 // ---------------------
340 // ======== And introduction
341 // Children: (P1:F1 ... Pn:Fn))
343 // ---------------------
344 // Conclusion: (and P1 ... Pn)
346 // ======== Not Or elimination
347 // Children: (P:(not (or F1 ... Fn)))
349 // ---------------------
350 // Conclusion: (not Fi)
352 // ======== Implication elimination
353 // Children: (P:(=> F1 F2))
355 // ---------------------
356 // Conclusion: (or (not F1) F2)
358 // ======== Not Implication elimination version 1
359 // Children: (P:(not (=> F1 F2)))
361 // ---------------------
364 // ======== Not Implication elimination version 2
365 // Children: (P:(not (=> F1 F2)))
367 // ---------------------
368 // Conclusion: (not F2)
370 // ======== Equivalence elimination version 1
371 // Children: (P:(= F1 F2))
373 // ---------------------
374 // Conclusion: (or (not F1) F2)
376 // ======== Equivalence elimination version 2
377 // Children: (P:(= F1 F2))
379 // ---------------------
380 // Conclusion: (or F1 (not F2))
382 // ======== Not Equivalence elimination version 1
383 // Children: (P:(not (= F1 F2)))
385 // ---------------------
386 // Conclusion: (or F1 F2)
388 // ======== Not Equivalence elimination version 2
389 // Children: (P:(not (= F1 F2)))
391 // ---------------------
392 // Conclusion: (or (not F1) (not F2))
394 // ======== XOR elimination version 1
395 // Children: (P:(xor F1 F2)))
397 // ---------------------
398 // Conclusion: (or F1 F2)
400 // ======== XOR elimination version 2
401 // Children: (P:(xor F1 F2)))
403 // ---------------------
404 // Conclusion: (or (not F1) (not F2))
406 // ======== Not XOR elimination version 1
407 // Children: (P:(not (xor F1 F2)))
409 // ---------------------
410 // Conclusion: (or F1 (not F2))
412 // ======== Not XOR elimination version 2
413 // Children: (P:(not (xor F1 F2)))
415 // ---------------------
416 // Conclusion: (or (not F1) F2)
418 // ======== ITE elimination version 1
419 // Children: (P:(ite C F1 F2))
421 // ---------------------
422 // Conclusion: (or (not C) F1)
424 // ======== ITE elimination version 2
425 // Children: (P:(ite C F1 F2))
427 // ---------------------
428 // Conclusion: (or C F2)
430 // ======== Not ITE elimination version 1
431 // Children: (P:(not (ite C F1 F2)))
433 // ---------------------
434 // Conclusion: (or (not C) (not F1))
436 // ======== Not ITE elimination version 1
437 // Children: (P:(not (ite C F1 F2)))
439 // ---------------------
440 // Conclusion: (or C (not F2))
443 //================================================= De Morgan rules
445 // Children: (P:(not (and F1 ... Fn))
447 // ---------------------
448 // Conclusion: (or (not F1) ... (not Fn))
450 //================================================= CNF rules
451 // ======== CNF And Pos
453 // Arguments: ((and F1 ... Fn), i)
454 // ---------------------
455 // Conclusion: (or (not (and F1 ... Fn)) Fi)
457 // ======== CNF And Neg
459 // Arguments: ((and F1 ... Fn))
460 // ---------------------
461 // Conclusion: (or (and F1 ... Fn) (not F1) ... (not Fn))
463 // ======== CNF Or Pos
465 // Arguments: ((or F1 ... Fn))
466 // ---------------------
467 // Conclusion: (or (not (or F1 ... Fn)) F1 ... Fn)
469 // ======== CNF Or Neg
471 // Arguments: ((or F1 ... Fn), i)
472 // ---------------------
473 // Conclusion: (or (or F1 ... Fn) (not Fi))
475 // ======== CNF Implies Pos
477 // Arguments: ((implies F1 F2))
478 // ---------------------
479 // Conclusion: (or (not (implies F1 F2)) (not F1) F2)
481 // ======== CNF Implies Neg version 1
483 // Arguments: ((implies F1 F2))
484 // ---------------------
485 // Conclusion: (or (implies F1 F2) F1)
487 // ======== CNF Implies Neg version 2
489 // Arguments: ((implies F1 F2))
490 // ---------------------
491 // Conclusion: (or (implies F1 F2) (not F2))
493 // ======== CNF Equiv Pos version 1
495 // Arguments: ((= F1 F2))
496 // ---------------------
497 // Conclusion: (or (not (= F1 F2)) (not F1) F2)
499 // ======== CNF Equiv Pos version 2
501 // Arguments: ((= F1 F2))
502 // ---------------------
503 // Conclusion: (or (not (= F1 F2)) F1 (not F2))
505 // ======== CNF Equiv Neg version 1
507 // Arguments: ((= F1 F2))
508 // ---------------------
509 // Conclusion: (or (= F1 F2) F1 F2)
511 // ======== CNF Equiv Neg version 2
513 // Arguments: ((= F1 F2))
514 // ---------------------
515 // Conclusion: (or (= F1 F2) (not F1) (not F2))
517 // ======== CNF Xor Pos version 1
519 // Arguments: ((xor F1 F2))
520 // ---------------------
521 // Conclusion: (or (not (xor F1 F2)) F1 F2)
523 // ======== CNF Xor Pos version 2
525 // Arguments: ((xor F1 F2))
526 // ---------------------
527 // Conclusion: (or (not (xor F1 F2)) (not F1) (not F2))
529 // ======== CNF Xor Neg version 1
531 // Arguments: ((xor F1 F2))
532 // ---------------------
533 // Conclusion: (or (xor F1 F2) (not F1) F2)
535 // ======== CNF Xor Neg version 2
537 // Arguments: ((xor F1 F2))
538 // ---------------------
539 // Conclusion: (or (xor F1 F2) F1 (not F2))
541 // ======== CNF ITE Pos version 1
543 // Arguments: ((ite C F1 F2))
544 // ---------------------
545 // Conclusion: (or (not (ite C F1 F2)) (not C) F1)
547 // ======== CNF ITE Pos version 2
549 // Arguments: ((ite C F1 F2))
550 // ---------------------
551 // Conclusion: (or (not (ite C F1 F2)) C F2)
553 // ======== CNF ITE Pos version 3
555 // Arguments: ((ite C F1 F2))
556 // ---------------------
557 // Conclusion: (or (not (ite C F1 F2)) F1 F2)
559 // ======== CNF ITE Neg version 1
561 // Arguments: ((ite C F1 F2))
562 // ---------------------
563 // Conclusion: (or (ite C F1 F2) (not C) (not F1))
565 // ======== CNF ITE Neg version 2
567 // Arguments: ((ite C F1 F2))
568 // ---------------------
569 // Conclusion: (or (ite C F1 F2) C (not F2))
571 // ======== CNF ITE Neg version 3
573 // Arguments: ((ite C F1 F2))
574 // ---------------------
575 // Conclusion: (or (ite C F1 F2) (not F1) (not F2))
578 //================================================= Equality rules
579 // ======== Reflexive
582 // ---------------------
583 // Conclusion: (= t t)
585 // ======== Symmetric
586 // Children: (P:(= t1 t2)) or (P:(not (= t1 t2)))
588 // -----------------------
589 // Conclusion: (= t2 t1) or (not (= t2 t1))
591 // ======== Transitivity
592 // Children: (P1:(= t1 t2), ..., Pn:(= t{n-1} tn))
594 // -----------------------
595 // Conclusion: (= t1 tn)
597 // ======== Congruence
598 // Children: (P1:(= t1 s1), ..., Pn:(= tn sn))
599 // Arguments: (<kind> f?)
600 // ---------------------------------------------
601 // Conclusion: (= (<kind> f? t1 ... tn) (<kind> f? s1 ... sn))
602 // Notice that f must be provided iff <kind> is a parameterized kind, e.g.
603 // APPLY_UF. The actual node for <kind> is constructible via
604 // ProofRuleChecker::mkKindNode.
606 // ======== True intro
609 // ----------------------------------------
610 // Conclusion: (= F true)
612 // ======== True elim
613 // Children: (P:(= F true))
615 // ----------------------------------------
618 // ======== False intro
619 // Children: (P:(not F))
621 // ----------------------------------------
622 // Conclusion: (= F false)
624 // ======== False elim
625 // Children: (P:(= F false))
627 // ----------------------------------------
628 // Conclusion: (not F)
633 // ---------------------
634 // Conclusion: (= t TheoryUfRewriter::getHoApplyForApplyUf(t))
635 // For example, this rule concludes (f x y) = (HO_APPLY (HO_APPLY f x) y)
637 // ======== Congruence
638 // Children: (P1:(= f g), P2:(= t1 s1), ..., Pn+1:(= tn sn))
640 // ---------------------------------------------
641 // Conclusion: (= (f t1 ... tn) (g s1 ... sn))
642 // Notice that this rule is only used when the application kinds are APPLY_UF.
645 //================================================= Array rules
646 // ======== Read over write
647 // Children: (P:(not (= i1 i2)))
648 // Arguments: ((select (store a i2 e) i1))
649 // ----------------------------------------
650 // Conclusion: (= (select (store a i2 e) i1) (select a i1))
651 ARRAYS_READ_OVER_WRITE
,
652 // ======== Read over write, contrapositive
653 // Children: (P:(not (= (select (store a i2 e) i1) (select a i1)))
655 // ----------------------------------------
656 // Conclusion: (= i1 i2)
657 ARRAYS_READ_OVER_WRITE_CONTRA
,
658 // ======== Read over write 1
660 // Arguments: ((select (store a i e) i))
661 // ----------------------------------------
662 // Conclusion: (= (select (store a i e) i) e)
663 ARRAYS_READ_OVER_WRITE_1
,
664 // ======== Extensionality
665 // Children: (P:(not (= a b)))
667 // ----------------------------------------
668 // Conclusion: (not (= (select a k) (select b k)))
669 // where k is arrays::SkolemCache::getExtIndexSkolem((not (= a b))).
671 // ======== Array Trust
672 // Children: (P1 ... Pn)
674 // ---------------------
678 //================================================= Datatype rules
679 // ======== Unification
680 // Children: (P:(= (C t1 ... tn) (C s1 ... sn)))
682 // ----------------------------------------
683 // Conclusion: (= ti si)
684 // where C is a constructor.
686 // ======== Instantiate
689 // ----------------------------------------
690 // Conclusion: (= ((_ is C) t) (= t (C (sel_1 t) ... (sel_n t))))
691 // where C is the n^th constructor of the type of T, and (_ is C) is the
692 // discriminator (tester) for C.
696 // Arguments: ((sel_i (C_j t_1 ... t_n)))
697 // ----------------------------------------
698 // Conclusion: (= (sel_i (C_j t_1 ... t_n)) r)
699 // where C_j is a constructor, r is t_i if sel_i is a correctly applied
700 // selector, or TypeNode::mkGroundTerm() of the proper type otherwise. Notice
701 // that the use of mkGroundTerm differs from the rewriter which uses
702 // mkGroundValue in this case.
707 // ----------------------------------------
708 // Conclusion: (or ((_ is C1) t) ... ((_ is Cn) t))
711 // Children: (P1:((_ is Ci) t), P2: ((_ is Cj) t))
713 // ----------------------------------------
717 // ======== Datatype Trust
718 // Children: (P1 ... Pn)
720 // ---------------------
724 //================================================= Quantifiers rules
725 // ======== Witness intro
726 // Children: (P:(exists ((x T)) F[x]))
728 // ----------------------------------------
729 // Conclusion: (= k (witness ((x T)) F[x]))
730 // where k is the Skolem form of (witness ((x T)) F[x]).
732 // ======== Exists intro
733 // Children: (P:F[t])
734 // Arguments: ((exists ((x T)) F[x]))
735 // ----------------------------------------
736 // Conclusion: (exists ((x T)) F[x])
737 // This rule verifies that F[x] indeed matches F[t] with a substitution
740 // ======== Skolemize
741 // Children: (P:(exists ((x1 T1) ... (xn Tn)) F))
743 // ----------------------------------------
744 // Conclusion: F*sigma
745 // sigma maps x1 ... xn to their representative skolems obtained by
746 // SkolemManager::mkSkolemize, returned in the skolems argument of that
747 // method. Alternatively, can use negated forall as a premise.
749 // ======== Instantiate
750 // Children: (P:(forall ((x1 T1) ... (xn Tn)) F))
751 // Arguments: (t1 ... tn)
752 // ----------------------------------------
753 // Conclusion: F*sigma
754 // sigma maps x1 ... xn to t1 ... tn.
757 //================================================= String rules
758 //======================== Core solver
759 // ======== Concat eq
760 // Children: (P1:(= (str.++ t1 ... tn t) (str.++ t1 ... tn s)))
761 // Arguments: (b), indicating if reverse direction
762 // ---------------------
763 // Conclusion: (= t s)
765 // Notice that t or s may be empty, in which case they are implicit in the
766 // concatenation above. For example, if
767 // P1 concludes (= x (str.++ x z)), then
768 // (CONCAT_EQ P1 :args false) concludes (= "" z)
770 // Also note that constants are split, such that if
771 // P1 concludes (= (str.++ "abc" x) (str.++ "a" y)), then
772 // (CONCAT_EQ P1 :args false) concludes (= (str.++ "bc" x) y)
773 // This splitting is done only for constants such that Word::splitConstant
776 // ======== Concat unify
777 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 s2)),
778 // P2:(= (str.len t1) (str.len s1)))
779 // Arguments: (b), indicating if reverse direction
780 // ---------------------
781 // Conclusion: (= t1 s1)
783 // ======== Concat conflict
784 // Children: (P1:(= (str.++ c1 t) (str.++ c2 s)))
785 // Arguments: (b), indicating if reverse direction
786 // ---------------------
788 // Where c1, c2 are constants such that Word::splitConstant(c1,c2,index,b)
789 // is null, in other words, neither is a prefix of the other.
791 // ======== Concat split
792 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 s2)),
793 // P2:(not (= (str.len t1) (str.len s1))))
794 // Arguments: (false)
795 // ---------------------
796 // Conclusion: (or (= t1 (str.++ s1 r_t)) (= s1 (str.++ t1 r_s)))
798 // r_t = (witness ((z String)) (= z (suf t1 (str.len s1)))),
799 // r_s = (witness ((z String)) (= z (suf s1 (str.len t1)))).
801 // or the reverse form of the above:
803 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 s2)),
804 // P2:(not (= (str.len t2) (str.len s2))))
806 // ---------------------
807 // Conclusion: (or (= t2 (str.++ r_t s2)) (= s2 (str.++ r_s t2)))
809 // r_t = (witness ((z String)) (= z (pre t2 (- (str.len t2) (str.len
810 // s2))))), r_s = (witness ((z String)) (= z (pre s2 (- (str.len s2)
813 // Above, (suf x n) is shorthand for (str.substr x n (- (str.len x) n)) and
814 // (pre x n) is shorthand for (str.substr x 0 n).
816 // ======== Concat constant split
817 // Children: (P1:(= (str.++ t1 t2) (str.++ c s2)),
818 // P2:(not (= (str.len t1) 0)))
819 // Arguments: (false)
820 // ---------------------
821 // Conclusion: (= t1 (str.++ c r))
823 // r = (witness ((z String)) (= z (suf t1 1))).
825 // or the reverse form of the above:
827 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 c)),
828 // P2:(not (= (str.len t2) 0)))
830 // ---------------------
831 // Conclusion: (= t2 (str.++ r c))
833 // r = (witness ((z String)) (= z (pre t2 (- (str.len t2) 1)))).
835 // ======== Concat length propagate
836 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 s2)),
837 // P2:(> (str.len t1) (str.len s1)))
838 // Arguments: (false)
839 // ---------------------
840 // Conclusion: (= t1 (str.++ s1 r_t))
842 // r_t = (witness ((z String)) (= z (suf t1 (str.len s1))))
844 // or the reverse form of the above:
846 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 s2)),
847 // P2:(> (str.len t2) (str.len s2)))
848 // Arguments: (false)
849 // ---------------------
850 // Conclusion: (= t2 (str.++ r_t s2))
852 // r_t = (witness ((z String)) (= z (pre t2 (- (str.len t2) (str.len
855 // ======== Concat constant propagate
856 // Children: (P1:(= (str.++ t1 w1 t2) (str.++ w2 s)),
857 // P2:(not (= (str.len t1) 0)))
858 // Arguments: (false)
859 // ---------------------
860 // Conclusion: (= t1 (str.++ w3 r))
862 // w1, w2, w3, w4 are words,
865 // p = Word::overlap((suf w2 1), w1),
866 // r = (witness ((z String)) (= z (suf t1 (str.len w3)))).
867 // In other words, w4 is the largest suffix of (suf w2 1) that can contain a
868 // prefix of w1; since t1 is non-empty, w3 must therefore be contained in t1.
870 // or the reverse form of the above:
872 // Children: (P1:(= (str.++ t1 w1 t2) (str.++ s w2)),
873 // P2:(not (= (str.len t2) 0)))
875 // ---------------------
876 // Conclusion: (= t2 (str.++ r w3))
878 // w1, w2, w3, w4 are words,
879 // w3 is (suf w2 (- (str.len w2) p)),
880 // w4 is (pre w2 (- (str.len w2) p)),
881 // p = Word::roverlap((pre w2 (- (str.len w2) 1)), w1),
882 // r = (witness ((z String)) (= z (pre t2 (- (str.len t2) (str.len w3))))).
883 // In other words, w4 is the largest prefix of (pre w2 (- (str.len w2) 1))
884 // that can contain a suffix of w1; since t2 is non-empty, w3 must therefore
885 // be contained in t2.
887 // ======== String decompose
888 // Children: (P1: (>= (str.len t) n)
889 // Arguments: (false)
890 // ---------------------
891 // Conclusion: (and (= t (str.++ w1 w2)) (= (str.len w1) n))
893 // Children: (P1: (>= (str.len t) n)
895 // ---------------------
896 // Conclusion: (and (= t (str.++ w1 w2)) (= (str.len w2) n))
898 // w1 is (witness ((z String)) (= z (pre t n)))
899 // w2 is (witness ((z String)) (= z (suf t n)))
901 // ======== Length positive
904 // ---------------------
905 // Conclusion: (or (and (= (str.len t) 0) (= t "")) (> (str.len t 0)))
907 // ======== Length non-empty
908 // Children: (P1:(not (= t "")))
910 // ---------------------
911 // Conclusion: (not (= (str.len t) 0))
912 STRING_LENGTH_NON_EMPTY
,
913 //======================== Extended functions
914 // ======== Reduction
917 // ---------------------
918 // Conclusion: (and R (= t w))
919 // where w = strings::StringsPreprocess::reduce(t, R, ...).
920 // In other words, R is the reduction predicate for extended term t, and w is
921 // (witness ((z T)) (= z t))
922 // Notice that the free variables of R are w and the free variables of t.
924 // ======== Eager Reduction
926 // Arguments: (t, id?)
927 // ---------------------
929 // where R = strings::TermRegistry::eagerReduce(t, id).
930 STRING_EAGER_REDUCTION
,
931 //======================== Regular expressions
932 // ======== Regular expression intersection
933 // Children: (P:(str.in.re t R1), P:(str.in.re t R2))
935 // ---------------------
936 // Conclusion: (str.in.re t (re.inter R1 R2)).
938 // ======== Regular expression unfold positive
939 // Children: (P:(str.in.re t R))
941 // ---------------------
942 // Conclusion:(RegExpOpr::reduceRegExpPos((str.in.re t R))),
943 // corresponding to the one-step unfolding of the premise.
945 // ======== Regular expression unfold negative
946 // Children: (P:(not (str.in.re t R)))
948 // ---------------------
949 // Conclusion:(RegExpOpr::reduceRegExpNeg((not (str.in.re t R)))),
950 // corresponding to the one-step unfolding of the premise.
952 // ======== Regular expression unfold negative concat fixed
953 // Children: (P:(not (str.in.re t R)))
955 // ---------------------
956 // Conclusion:(RegExpOpr::reduceRegExpNegConcatFixed((not (str.in.re t
957 // R)),L,i)) where RegExpOpr::getRegExpConcatFixed((not (str.in.re t R)), i) =
958 // L. corresponding to the one-step unfolding of the premise, optimized for
959 // fixed length of component i of the regular expression concatenation R.
960 RE_UNFOLD_NEG_CONCAT_FIXED
,
961 // ======== Regular expression elimination
964 // ---------------------
966 // where R = strings::RegExpElimination::eliminate(F).
968 //======================== Code points
971 // ---------------------
972 // Conclusion:(or (= (str.code t) (- 1))
973 // (not (= (str.code t) (str.code s)))
976 //======================== Sequence unit
977 // Children: (P:(= (seq.unit x) (seq.unit y)))
979 // ---------------------
980 // Conclusion:(= x y)
981 // Also applies to the case where (seq.unit y) is a constant sequence
984 // ======== String Trust
987 // ---------------------
991 //================================================= Arithmetic rules
992 // ======== Adding Inequalities
993 // Note: an ArithLiteral is a term of the form (>< poly const)
995 // >< is >=, >, ==, <, <=, or not(== ...).
996 // poly is a polynomial
997 // const is a rational constant
999 // Children: (P1:l1, ..., Pn:ln)
1000 // where each li is an ArithLiteral
1001 // not(= ...) is dis-allowed!
1003 // Arguments: (k1, ..., kn), non-zero reals
1004 // ---------------------
1005 // Conclusion: (>< (* k t1) (* k t2))
1006 // where >< is the fusion of the combination of the ><i, (flipping each it
1007 // its ki is negative). >< is always one of <, <=
1008 // NB: this implies that lower bounds must have negative ki,
1009 // and upper bounds must have positive ki.
1010 // t1 is the sum of the polynomials.
1011 // t2 is the sum of the constants.
1012 ARITH_SCALE_SUM_UPPER_BOUNDS
,
1014 // ======== Tightening Strict Integer Upper Bounds
1015 // Children: (P:(< i c))
1016 // where i has integer type.
1018 // ---------------------
1019 // Conclusion: (<= i greatestIntLessThan(c)})
1022 // ======== Tightening Strict Integer Lower Bounds
1023 // Children: (P:(> i c))
1024 // where i has integer type.
1026 // ---------------------
1027 // Conclusion: (>= i leastIntGreaterThan(c)})
1030 // ======== Trichotomy of the reals
1033 // ---------------------
1035 // where (not A) (not B) and C
1036 // are (> x c) (< x c) and (= x c)
1038 // note that "not" here denotes arithmetic negation, flipping
1042 // ======== Arithmetic operator elimination
1045 // ---------------------
1046 // Conclusion: arith::OperatorElim::getAxiomFor(t)
1047 ARITH_OP_ELIM_AXIOM
,
1049 // ======== Int Trust
1050 // Children: (P1 ... Pn)
1052 // ---------------------
1056 //================================================= Unknown rule
1061 * Converts a proof rule to a string. Note: This function is also used in
1062 * `safe_print()`. Changing this function name or signature will result in
1063 * `safe_print()` printing "<unsupported>" instead of the proper strings for
1066 * @param id The proof rule
1067 * @return The name of the proof rule
1069 const char* toString(PfRule id
);
1072 * Writes a proof rule name to a stream.
1074 * @param out The stream to write to
1075 * @param id The proof rule to write to the stream
1076 * @return The stream
1078 std::ostream
& operator<<(std::ostream
& out
, PfRule id
);
1080 /** Hash function for proof rules */
1081 struct PfRuleHashFunction
1083 size_t operator()(PfRule id
) const;
1084 }; /* struct PfRuleHashFunction */
1088 #endif /* CVC4__EXPR__PROOF_RULE_H */