1 /********************* */
4 ** Top contributors (to current version):
5 ** Andrew Reynolds, Haniel Barbosa, Gereon Kremer
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2021 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 CVC5__EXPR__PROOF_RULE_H
18 #define CVC5__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(toOriginal(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 original form of F', meaning that
139 // this rule may conclude an F whose Skolem form is justified by the
140 // definition of its (fresh) Skolem variables. For example, this rule may
141 // justify the conclusion (= k t) where k is the purification Skolem for t,
142 // e.g. where the original form of k is t.
144 // Furthermore, notice that the rewriting and substitution is applied only
145 // within the side condition, meaning the rewritten form of the original 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(toOriginal(F')) == Rewriter::rewrite(toOriginal(G'))
180 // where F' and G' are the result of each side of the equation above. Here,
181 // original 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 equality of the form t = t' where t was replaced by t'
235 // based on theory expand definitions.
237 // where F is an existential (exists ((x T)) (P x)) used for introducing
238 // a witness term (witness ((x T)) (P x)).
240 // where F is an equality (= t t') that holds by a form of rewriting 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 replayed during proof postprocessing.
246 // where F is an equality (= t t') that holds by a form of substitution that
247 // could not be determined by the TrustSubstitutionMap.
250 //================================================= Boolean rules
251 // ======== Resolution
254 // Arguments: (pol, L)
255 // ---------------------
258 // - C1 and C2 are nodes viewed as clauses, i.e., either an OR node with
259 // each children viewed as a literal or a node viewed as a literal. Note
260 // that an OR node could also be a literal.
261 // - pol is either true or false, representing the polarity of the pivot on
263 // - L is the pivot of the resolution, which occurs as is (resp. under a
264 // NOT) in C1 and negatively (as is) in C2 if pol = true (pol = false).
265 // C is a clause resulting from collecting all the literals in C1, minus the
266 // first occurrence of the pivot or its negation, and C2, minus the first
267 // occurrence of the pivot or its negation, according to the policy above.
268 // If the resulting clause has a single literal, that literal itself is the
269 // result; if it has no literals, then the result is false; otherwise it's
270 // an OR node of the resulting literals.
272 // Note that it may be the case that the pivot does not occur in the
273 // clauses. In this case the rule is not unsound, but it does not correspond
274 // to resolution but rather to a weakening of the clause that did not have a
275 // literal eliminated.
277 // ======== N-ary Resolution
278 // Children: (P1:C_1, ..., Pm:C_n)
279 // Arguments: (pol_1, L_1, ..., pol_{n-1}, L_{n-1})
280 // ---------------------
283 // - let C_1 ... C_n be nodes viewed as clauses, as defined above
284 // - let "C_1 <>_{L,pol} C_2" represent the resolution of C_1 with C_2 with
285 // pivot L and polarity pol, as defined above
286 // - let C_1' = C_1 (from P1),
287 // - for each i > 1, let C_i' = C_{i-1} <>_{L_{i-1}, pol_{i-1}} C_i'
288 // The result of the chain resolution is C = C_n'
290 // ======== Factoring
293 // ---------------------
296 // Set representations of C1 and C2 is the same and the number of literals in
297 // C2 is smaller than that of C1
299 // ======== Reordering
302 // ---------------------
305 // Set representations of C1 and C2 are the same and the number of literals
306 // in C2 is the same of that of C1
308 // ======== N-ary Resolution + Factoring + Reordering
309 // Children: (P1:C_1, ..., Pm:C_n)
310 // Arguments: (C, pol_1, L_1, ..., pol_{n-1}, L_{n-1})
311 // ---------------------
314 // - let C_1 ... C_n be nodes viewed as clauses, as defined in RESOLUTION
315 // - let "C_1 <>_{L,pol} C_2" represent the resolution of C_1 with C_2 with
316 // pivot L and polarity pol, as defined in RESOLUTION
317 // - let C_1' be equal, in its set representation, to C_1 (from P1),
318 // - for each i > 1, let C_i' be equal, it its set representation, to
319 // C_{i-1} <>_{L_{i-1}, pol_{i-1}} C_i'
320 // The result of the chain resolution is C, which is equal, in its set
321 // representation, to C_n'
323 // As above but not checked
324 MACRO_RESOLUTION_TRUST
,
329 // ---------------------
330 // Conclusion: (or F (not F))
332 // ======== Equality resolution
333 // Children: (P1:F1, P2:(= F1 F2))
335 // ---------------------
337 // Note this can optionally be seen as a macro for EQUIV_ELIM1+RESOLUTION.
339 // ======== Modus ponens
340 // Children: (P1:F1, P2:(=> F1 F2))
342 // ---------------------
344 // Note this can optionally be seen as a macro for IMPLIES_ELIM+RESOLUTION.
346 // ======== Double negation elimination
347 // Children: (P:(not (not F)))
349 // ---------------------
352 // ======== Contradiction
353 // Children: (P1:F P2:(not F))
355 // ---------------------
358 // ======== And elimination
359 // Children: (P:(and F1 ... Fn))
361 // ---------------------
364 // ======== And introduction
365 // Children: (P1:F1 ... Pn:Fn))
367 // ---------------------
368 // Conclusion: (and P1 ... Pn)
370 // ======== Not Or elimination
371 // Children: (P:(not (or F1 ... Fn)))
373 // ---------------------
374 // Conclusion: (not Fi)
376 // ======== Implication elimination
377 // Children: (P:(=> F1 F2))
379 // ---------------------
380 // Conclusion: (or (not F1) F2)
382 // ======== Not Implication elimination version 1
383 // Children: (P:(not (=> F1 F2)))
385 // ---------------------
388 // ======== Not Implication elimination version 2
389 // Children: (P:(not (=> F1 F2)))
391 // ---------------------
392 // Conclusion: (not F2)
394 // ======== Equivalence elimination version 1
395 // Children: (P:(= F1 F2))
397 // ---------------------
398 // Conclusion: (or (not F1) F2)
400 // ======== Equivalence elimination version 2
401 // Children: (P:(= F1 F2))
403 // ---------------------
404 // Conclusion: (or F1 (not F2))
406 // ======== Not Equivalence elimination version 1
407 // Children: (P:(not (= F1 F2)))
409 // ---------------------
410 // Conclusion: (or F1 F2)
412 // ======== Not Equivalence elimination version 2
413 // Children: (P:(not (= F1 F2)))
415 // ---------------------
416 // Conclusion: (or (not F1) (not F2))
418 // ======== XOR elimination version 1
419 // Children: (P:(xor F1 F2)))
421 // ---------------------
422 // Conclusion: (or F1 F2)
424 // ======== XOR elimination version 2
425 // Children: (P:(xor F1 F2)))
427 // ---------------------
428 // Conclusion: (or (not F1) (not F2))
430 // ======== Not XOR elimination version 1
431 // Children: (P:(not (xor F1 F2)))
433 // ---------------------
434 // Conclusion: (or F1 (not F2))
436 // ======== Not XOR elimination version 2
437 // Children: (P:(not (xor F1 F2)))
439 // ---------------------
440 // Conclusion: (or (not F1) F2)
442 // ======== ITE elimination version 1
443 // Children: (P:(ite C F1 F2))
445 // ---------------------
446 // Conclusion: (or (not C) F1)
448 // ======== ITE elimination version 2
449 // Children: (P:(ite C F1 F2))
451 // ---------------------
452 // Conclusion: (or C F2)
454 // ======== Not ITE elimination version 1
455 // Children: (P:(not (ite C F1 F2)))
457 // ---------------------
458 // Conclusion: (or (not C) (not F1))
460 // ======== Not ITE elimination version 1
461 // Children: (P:(not (ite C F1 F2)))
463 // ---------------------
464 // Conclusion: (or C (not F2))
467 //================================================= De Morgan rules
469 // Children: (P:(not (and F1 ... Fn))
471 // ---------------------
472 // Conclusion: (or (not F1) ... (not Fn))
474 //================================================= CNF rules
475 // ======== CNF And Pos
477 // Arguments: ((and F1 ... Fn), i)
478 // ---------------------
479 // Conclusion: (or (not (and F1 ... Fn)) Fi)
481 // ======== CNF And Neg
483 // Arguments: ((and F1 ... Fn))
484 // ---------------------
485 // Conclusion: (or (and F1 ... Fn) (not F1) ... (not Fn))
487 // ======== CNF Or Pos
489 // Arguments: ((or F1 ... Fn))
490 // ---------------------
491 // Conclusion: (or (not (or F1 ... Fn)) F1 ... Fn)
493 // ======== CNF Or Neg
495 // Arguments: ((or F1 ... Fn), i)
496 // ---------------------
497 // Conclusion: (or (or F1 ... Fn) (not Fi))
499 // ======== CNF Implies Pos
501 // Arguments: ((implies F1 F2))
502 // ---------------------
503 // Conclusion: (or (not (implies F1 F2)) (not F1) F2)
505 // ======== CNF Implies Neg version 1
507 // Arguments: ((implies F1 F2))
508 // ---------------------
509 // Conclusion: (or (implies F1 F2) F1)
511 // ======== CNF Implies Neg version 2
513 // Arguments: ((implies F1 F2))
514 // ---------------------
515 // Conclusion: (or (implies F1 F2) (not F2))
517 // ======== CNF Equiv Pos version 1
519 // Arguments: ((= F1 F2))
520 // ---------------------
521 // Conclusion: (or (not (= F1 F2)) (not F1) F2)
523 // ======== CNF Equiv Pos version 2
525 // Arguments: ((= F1 F2))
526 // ---------------------
527 // Conclusion: (or (not (= F1 F2)) F1 (not F2))
529 // ======== CNF Equiv Neg version 1
531 // Arguments: ((= F1 F2))
532 // ---------------------
533 // Conclusion: (or (= F1 F2) F1 F2)
535 // ======== CNF Equiv Neg version 2
537 // Arguments: ((= F1 F2))
538 // ---------------------
539 // Conclusion: (or (= F1 F2) (not F1) (not F2))
541 // ======== CNF Xor Pos version 1
543 // Arguments: ((xor F1 F2))
544 // ---------------------
545 // Conclusion: (or (not (xor F1 F2)) F1 F2)
547 // ======== CNF Xor Pos version 2
549 // Arguments: ((xor F1 F2))
550 // ---------------------
551 // Conclusion: (or (not (xor F1 F2)) (not F1) (not F2))
553 // ======== CNF Xor Neg version 1
555 // Arguments: ((xor F1 F2))
556 // ---------------------
557 // Conclusion: (or (xor F1 F2) (not F1) F2)
559 // ======== CNF Xor Neg version 2
561 // Arguments: ((xor F1 F2))
562 // ---------------------
563 // Conclusion: (or (xor F1 F2) F1 (not F2))
565 // ======== CNF ITE Pos version 1
567 // Arguments: ((ite C F1 F2))
568 // ---------------------
569 // Conclusion: (or (not (ite C F1 F2)) (not C) F1)
571 // ======== CNF ITE Pos version 2
573 // Arguments: ((ite C F1 F2))
574 // ---------------------
575 // Conclusion: (or (not (ite C F1 F2)) C F2)
577 // ======== CNF ITE Pos version 3
579 // Arguments: ((ite C F1 F2))
580 // ---------------------
581 // Conclusion: (or (not (ite C F1 F2)) F1 F2)
583 // ======== CNF ITE Neg version 1
585 // Arguments: ((ite C F1 F2))
586 // ---------------------
587 // Conclusion: (or (ite C F1 F2) (not C) (not F1))
589 // ======== CNF ITE Neg version 2
591 // Arguments: ((ite C F1 F2))
592 // ---------------------
593 // Conclusion: (or (ite C F1 F2) C (not F2))
595 // ======== CNF ITE Neg version 3
597 // Arguments: ((ite C F1 F2))
598 // ---------------------
599 // Conclusion: (or (ite C F1 F2) (not F1) (not F2))
602 //================================================= Equality rules
603 // ======== Reflexive
606 // ---------------------
607 // Conclusion: (= t t)
609 // ======== Symmetric
610 // Children: (P:(= t1 t2)) or (P:(not (= t1 t2)))
612 // -----------------------
613 // Conclusion: (= t2 t1) or (not (= t2 t1))
615 // ======== Transitivity
616 // Children: (P1:(= t1 t2), ..., Pn:(= t{n-1} tn))
618 // -----------------------
619 // Conclusion: (= t1 tn)
621 // ======== Congruence
622 // Children: (P1:(= t1 s1), ..., Pn:(= tn sn))
623 // Arguments: (<kind> f?)
624 // ---------------------------------------------
625 // Conclusion: (= (<kind> f? t1 ... tn) (<kind> f? s1 ... sn))
626 // Notice that f must be provided iff <kind> is a parameterized kind, e.g.
627 // APPLY_UF. The actual node for <kind> is constructible via
628 // ProofRuleChecker::mkKindNode.
630 // ======== True intro
633 // ----------------------------------------
634 // Conclusion: (= F true)
636 // ======== True elim
637 // Children: (P:(= F true))
639 // ----------------------------------------
642 // ======== False intro
643 // Children: (P:(not F))
645 // ----------------------------------------
646 // Conclusion: (= F false)
648 // ======== False elim
649 // Children: (P:(= F false))
651 // ----------------------------------------
652 // Conclusion: (not F)
657 // ---------------------
658 // Conclusion: (= t TheoryUfRewriter::getHoApplyForApplyUf(t))
659 // For example, this rule concludes (f x y) = (HO_APPLY (HO_APPLY f x) y)
661 // ======== Congruence
662 // Children: (P1:(= f g), P2:(= t1 s1), ..., Pn+1:(= tn sn))
664 // ---------------------------------------------
665 // Conclusion: (= (f t1 ... tn) (g s1 ... sn))
666 // Notice that this rule is only used when the application kinds are APPLY_UF.
669 //================================================= Array rules
670 // ======== Read over write
671 // Children: (P:(not (= i1 i2)))
672 // Arguments: ((select (store a i2 e) i1))
673 // ----------------------------------------
674 // Conclusion: (= (select (store a i2 e) i1) (select a i1))
675 ARRAYS_READ_OVER_WRITE
,
676 // ======== Read over write, contrapositive
677 // Children: (P:(not (= (select (store a i2 e) i1) (select a i1)))
679 // ----------------------------------------
680 // Conclusion: (= i1 i2)
681 ARRAYS_READ_OVER_WRITE_CONTRA
,
682 // ======== Read over write 1
684 // Arguments: ((select (store a i e) i))
685 // ----------------------------------------
686 // Conclusion: (= (select (store a i e) i) e)
687 ARRAYS_READ_OVER_WRITE_1
,
688 // ======== Extensionality
689 // Children: (P:(not (= a b)))
691 // ----------------------------------------
692 // Conclusion: (not (= (select a k) (select b k)))
693 // where k is arrays::SkolemCache::getExtIndexSkolem((not (= a b))).
695 // ======== Array Trust
696 // Children: (P1 ... Pn)
698 // ---------------------
702 //================================================= Bit-Vector rules
706 // ---------------------
707 // Conclusion: (= t bitblast(t))
709 // ======== Eager Atom
712 // ---------------------
713 // Conclusion: (= F F[0])
714 // where F is of kind BITVECTOR_EAGER_ATOM
717 //================================================= Datatype rules
718 // ======== Unification
719 // Children: (P:(= (C t1 ... tn) (C s1 ... sn)))
721 // ----------------------------------------
722 // Conclusion: (= ti si)
723 // where C is a constructor.
725 // ======== Instantiate
728 // ----------------------------------------
729 // Conclusion: (= ((_ is C) t) (= t (C (sel_1 t) ... (sel_n t))))
730 // where C is the n^th constructor of the type of T, and (_ is C) is the
731 // discriminator (tester) for C.
735 // Arguments: ((sel_i (C_j t_1 ... t_n)))
736 // ----------------------------------------
737 // Conclusion: (= (sel_i (C_j t_1 ... t_n)) r)
738 // where C_j is a constructor, r is t_i if sel_i is a correctly applied
739 // selector, or TypeNode::mkGroundTerm() of the proper type otherwise. Notice
740 // that the use of mkGroundTerm differs from the rewriter which uses
741 // mkGroundValue in this case.
746 // ----------------------------------------
747 // Conclusion: (or ((_ is C1) t) ... ((_ is Cn) t))
750 // Children: (P1:((_ is Ci) t), P2: ((_ is Cj) t))
752 // ----------------------------------------
756 // ======== Datatype Trust
757 // Children: (P1 ... Pn)
759 // ---------------------
763 //================================================= Quantifiers rules
764 // ======== Skolem intro
767 // ----------------------------------------
768 // Conclusion: (= k t)
769 // where t is the original form of skolem k.
771 // ======== Exists intro
772 // Children: (P:F[t])
773 // Arguments: ((exists ((x T)) F[x]))
774 // ----------------------------------------
775 // Conclusion: (exists ((x T)) F[x])
776 // This rule verifies that F[x] indeed matches F[t] with a substitution
779 // ======== Skolemize
780 // Children: (P:(exists ((x1 T1) ... (xn Tn)) F))
782 // ----------------------------------------
783 // Conclusion: F*sigma
784 // sigma maps x1 ... xn to their representative skolems obtained by
785 // SkolemManager::mkSkolemize, returned in the skolems argument of that
786 // method. Alternatively, can use negated forall as a premise. The witness
787 // terms for the returned skolems can be obtained by
788 // SkolemManager::getWitnessForm.
790 // ======== Instantiate
791 // Children: (P:(forall ((x1 T1) ... (xn Tn)) F))
792 // Arguments: (t1 ... tn)
793 // ----------------------------------------
794 // Conclusion: F*sigma
795 // sigma maps x1 ... xn to t1 ... tn.
798 //================================================= String rules
799 //======================== Core solver
800 // ======== Concat eq
801 // Children: (P1:(= (str.++ t1 ... tn t) (str.++ t1 ... tn s)))
802 // Arguments: (b), indicating if reverse direction
803 // ---------------------
804 // Conclusion: (= t s)
806 // Notice that t or s may be empty, in which case they are implicit in the
807 // concatenation above. For example, if
808 // P1 concludes (= x (str.++ x z)), then
809 // (CONCAT_EQ P1 :args false) concludes (= "" z)
811 // Also note that constants are split, such that if
812 // P1 concludes (= (str.++ "abc" x) (str.++ "a" y)), then
813 // (CONCAT_EQ P1 :args false) concludes (= (str.++ "bc" x) y)
814 // This splitting is done only for constants such that Word::splitConstant
817 // ======== Concat unify
818 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 s2)),
819 // P2:(= (str.len t1) (str.len s1)))
820 // Arguments: (b), indicating if reverse direction
821 // ---------------------
822 // Conclusion: (= t1 s1)
824 // ======== Concat conflict
825 // Children: (P1:(= (str.++ c1 t) (str.++ c2 s)))
826 // Arguments: (b), indicating if reverse direction
827 // ---------------------
829 // Where c1, c2 are constants such that Word::splitConstant(c1,c2,index,b)
830 // is null, in other words, neither is a prefix of the other.
832 // ======== Concat split
833 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 s2)),
834 // P2:(not (= (str.len t1) (str.len s1))))
835 // Arguments: (false)
836 // ---------------------
837 // Conclusion: (or (= t1 (str.++ s1 r_t)) (= s1 (str.++ t1 r_s)))
839 // r_t = (witness ((z String)) (= z (suf t1 (str.len s1)))),
840 // r_s = (witness ((z String)) (= z (suf s1 (str.len t1)))).
842 // or the reverse form of the above:
844 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 s2)),
845 // P2:(not (= (str.len t2) (str.len s2))))
847 // ---------------------
848 // Conclusion: (or (= t2 (str.++ r_t s2)) (= s2 (str.++ r_s t2)))
850 // r_t = (witness ((z String)) (= z (pre t2 (- (str.len t2) (str.len
851 // s2))))), r_s = (witness ((z String)) (= z (pre s2 (- (str.len s2)
854 // Above, (suf x n) is shorthand for (str.substr x n (- (str.len x) n)) and
855 // (pre x n) is shorthand for (str.substr x 0 n).
857 // ======== Concat constant split
858 // Children: (P1:(= (str.++ t1 t2) (str.++ c s2)),
859 // P2:(not (= (str.len t1) 0)))
860 // Arguments: (false)
861 // ---------------------
862 // Conclusion: (= t1 (str.++ c r))
864 // r = (witness ((z String)) (= z (suf t1 1))).
866 // or the reverse form of the above:
868 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 c)),
869 // P2:(not (= (str.len t2) 0)))
871 // ---------------------
872 // Conclusion: (= t2 (str.++ r c))
874 // r = (witness ((z String)) (= z (pre t2 (- (str.len t2) 1)))).
876 // ======== Concat length propagate
877 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 s2)),
878 // P2:(> (str.len t1) (str.len s1)))
879 // Arguments: (false)
880 // ---------------------
881 // Conclusion: (= t1 (str.++ s1 r_t))
883 // r_t = (witness ((z String)) (= z (suf t1 (str.len s1))))
885 // or the reverse form of the above:
887 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 s2)),
888 // P2:(> (str.len t2) (str.len s2)))
889 // Arguments: (false)
890 // ---------------------
891 // Conclusion: (= t2 (str.++ r_t s2))
893 // r_t = (witness ((z String)) (= z (pre t2 (- (str.len t2) (str.len
896 // ======== Concat constant propagate
897 // Children: (P1:(= (str.++ t1 w1 t2) (str.++ w2 s)),
898 // P2:(not (= (str.len t1) 0)))
899 // Arguments: (false)
900 // ---------------------
901 // Conclusion: (= t1 (str.++ w3 r))
903 // w1, w2, w3, w4 are words,
906 // p = Word::overlap((suf w2 1), w1),
907 // r = (witness ((z String)) (= z (suf t1 (str.len w3)))).
908 // In other words, w4 is the largest suffix of (suf w2 1) that can contain a
909 // prefix of w1; since t1 is non-empty, w3 must therefore be contained in t1.
911 // or the reverse form of the above:
913 // Children: (P1:(= (str.++ t1 w1 t2) (str.++ s w2)),
914 // P2:(not (= (str.len t2) 0)))
916 // ---------------------
917 // Conclusion: (= t2 (str.++ r w3))
919 // w1, w2, w3, w4 are words,
920 // w3 is (suf w2 (- (str.len w2) p)),
921 // w4 is (pre w2 (- (str.len w2) p)),
922 // p = Word::roverlap((pre w2 (- (str.len w2) 1)), w1),
923 // r = (witness ((z String)) (= z (pre t2 (- (str.len t2) (str.len w3))))).
924 // In other words, w4 is the largest prefix of (pre w2 (- (str.len w2) 1))
925 // that can contain a suffix of w1; since t2 is non-empty, w3 must therefore
926 // be contained in t2.
928 // ======== String decompose
929 // Children: (P1: (>= (str.len t) n)
930 // Arguments: (false)
931 // ---------------------
932 // Conclusion: (and (= t (str.++ w1 w2)) (= (str.len w1) n))
934 // Children: (P1: (>= (str.len t) n)
936 // ---------------------
937 // Conclusion: (and (= t (str.++ w1 w2)) (= (str.len w2) n))
939 // w1 is (witness ((z String)) (= z (pre t n)))
940 // w2 is (witness ((z String)) (= z (suf t n)))
942 // ======== Length positive
945 // ---------------------
946 // Conclusion: (or (and (= (str.len t) 0) (= t "")) (> (str.len t 0)))
948 // ======== Length non-empty
949 // Children: (P1:(not (= t "")))
951 // ---------------------
952 // Conclusion: (not (= (str.len t) 0))
953 STRING_LENGTH_NON_EMPTY
,
954 //======================== Extended functions
955 // ======== Reduction
958 // ---------------------
959 // Conclusion: (and R (= t w))
960 // where w = strings::StringsPreprocess::reduce(t, R, ...).
961 // In other words, R is the reduction predicate for extended term t, and w is
962 // (witness ((z T)) (= z t))
963 // Notice that the free variables of R are w and the free variables of t.
965 // ======== Eager Reduction
967 // Arguments: (t, id?)
968 // ---------------------
970 // where R = strings::TermRegistry::eagerReduce(t, id).
971 STRING_EAGER_REDUCTION
,
972 //======================== Regular expressions
973 // ======== Regular expression intersection
974 // Children: (P:(str.in.re t R1), P:(str.in.re t R2))
976 // ---------------------
977 // Conclusion: (str.in.re t (re.inter R1 R2)).
979 // ======== Regular expression unfold positive
980 // Children: (P:(str.in.re t R))
982 // ---------------------
983 // Conclusion:(RegExpOpr::reduceRegExpPos((str.in.re t R))),
984 // corresponding to the one-step unfolding of the premise.
986 // ======== Regular expression unfold negative
987 // Children: (P:(not (str.in.re t R)))
989 // ---------------------
990 // Conclusion:(RegExpOpr::reduceRegExpNeg((not (str.in.re t R)))),
991 // corresponding to the one-step unfolding of the premise.
993 // ======== Regular expression unfold negative concat fixed
994 // Children: (P:(not (str.in.re t R)))
996 // ---------------------
997 // Conclusion:(RegExpOpr::reduceRegExpNegConcatFixed((not (str.in.re t
998 // R)),L,i)) where RegExpOpr::getRegExpConcatFixed((not (str.in.re t R)), i) =
999 // L. corresponding to the one-step unfolding of the premise, optimized for
1000 // fixed length of component i of the regular expression concatenation R.
1001 RE_UNFOLD_NEG_CONCAT_FIXED
,
1002 // ======== Regular expression elimination
1004 // Arguments: (F, b)
1005 // ---------------------
1006 // Conclusion: (= F strings::RegExpElimination::eliminate(F, b))
1007 // where b is a Boolean indicating whether we are using aggressive
1008 // eliminations. Notice this rule concludes (= F F) if no eliminations
1009 // are performed for F.
1011 //======================== Code points
1013 // Arguments: (t, s)
1014 // ---------------------
1015 // Conclusion:(or (= (str.code t) (- 1))
1016 // (not (= (str.code t) (str.code s)))
1019 //======================== Sequence unit
1020 // Children: (P:(= (seq.unit x) (seq.unit y)))
1022 // ---------------------
1023 // Conclusion:(= x y)
1024 // Also applies to the case where (seq.unit y) is a constant sequence
1026 STRING_SEQ_UNIT_INJ
,
1027 // ======== String Trust
1030 // ---------------------
1034 //================================================= Arithmetic rules
1035 // ======== Adding Inequalities
1036 // Note: an ArithLiteral is a term of the form (>< poly const)
1038 // >< is >=, >, ==, <, <=, or not(== ...).
1039 // poly is a polynomial
1040 // const is a rational constant
1042 // Children: (P1:l1, ..., Pn:ln)
1043 // where each li is an ArithLiteral
1044 // not(= ...) is dis-allowed!
1046 // Arguments: (k1, ..., kn), non-zero reals
1047 // ---------------------
1048 // Conclusion: (>< t1 t2)
1049 // where >< is the fusion of the combination of the ><i, (flipping each it
1050 // its ki is negative). >< is always one of <, <=
1051 // NB: this implies that lower bounds must have negative ki,
1052 // and upper bounds must have positive ki.
1053 // t1 is the sum of the scaled polynomials (k_1 * poly_1 + ... + k_n *
1054 // poly_n) t2 is the sum of the scaled constants (k_1 * const_1 + ... + k_n
1056 ARITH_SCALE_SUM_UPPER_BOUNDS
,
1058 // ======== Sum Upper Bounds
1059 // Children: (P1, ... , Pn)
1060 // where each Pi has form (><i, Li, Ri)
1061 // for ><i in {<, <=, ==}
1062 // Conclusion: (>< L R)
1063 // where >< is < if any ><i is <, and <= otherwise.
1064 // L is (+ L1 ... Ln)
1065 // R is (+ R1 ... Rn)
1067 // ======== Tightening Strict Integer Upper Bounds
1068 // Children: (P:(< i c))
1069 // where i has integer type.
1071 // ---------------------
1072 // Conclusion: (<= i greatestIntLessThan(c)})
1075 // ======== Tightening Strict Integer Lower Bounds
1076 // Children: (P:(> i c))
1077 // where i has integer type.
1079 // ---------------------
1080 // Conclusion: (>= i leastIntGreaterThan(c)})
1083 // ======== Trichotomy of the reals
1086 // ---------------------
1088 // where (not A) (not B) and C
1089 // are (> x c) (< x c) and (= x c)
1091 // note that "not" here denotes arithmetic negation, flipping
1095 // ======== Arithmetic operator elimination
1098 // ---------------------
1099 // Conclusion: arith::OperatorElim::getAxiomFor(t)
1100 ARITH_OP_ELIM_AXIOM
,
1102 // ======== Int Trust
1103 // Children: (P1 ... Pn)
1105 // ---------------------
1109 //======== Multiplication sign inference
1111 // Arguments: (f1, ..., fk, m)
1112 // ---------------------
1113 // Conclusion: (=> (and f1 ... fk) (~ m 0))
1114 // Where f1, ..., fk are variables compared to zero (less, greater or not
1115 // equal), m is a monomial from these variables, and ~ is the comparison (less
1116 // or greater) that results from the signs of the variables. All variables
1117 // with even exponent in m should be given as not equal to zero while all
1118 // variables with odd exponent in m should be given as less or greater than
1121 //======== Multiplication with positive factor
1123 // Arguments: (m, (rel lhs rhs))
1124 // ---------------------
1125 // Conclusion: (=> (and (> m 0) (rel lhs rhs)) (rel (* m lhs) (* m rhs)))
1126 // Where rel is a relation symbol.
1128 //======== Multiplication with negative factor
1130 // Arguments: (m, (rel lhs rhs))
1131 // ---------------------
1132 // Conclusion: (=> (and (< m 0) (rel lhs rhs)) (rel_inv (* m lhs) (* m rhs)))
1133 // Where rel is a relation symbol and rel_inv the inverted relation symbol.
1135 //======== Multiplication tangent plane
1137 // Arguments: (t, x, y, a, b, sgn)
1138 // ---------------------
1140 // sgn=-1: (= (<= t tplane) (or (and (<= x a) (>= y b)) (and (>= x a) (<= y
1141 // b))) sgn= 1: (= (>= t tplane) (or (and (<= x a) (<= y b)) (and (>= x a)
1143 // Where x,y are real terms (variables or extended terms), t = (* x y)
1144 // (possibly under rewriting), a,b are real constants, and sgn is either -1
1145 // or 1. tplane is the tangent plane of x*y at (a,b): b*x + a*y - a*b
1148 // ================ Lemmas for transcendentals
1149 //======== Assert bounds on PI
1151 // Arguments: (l, u)
1152 // ---------------------
1153 // Conclusion: (and (>= real.pi l) (<= real.pi u))
1154 // Where l (u) is a valid lower (upper) bound on pi.
1157 //======== Exp at negative values
1160 // ---------------------
1161 // Conclusion: (= (< t 0) (< (exp t) 1))
1162 ARITH_TRANS_EXP_NEG
,
1163 //======== Exp is always positive
1166 // ---------------------
1167 // Conclusion: (> (exp t) 0)
1168 ARITH_TRANS_EXP_POSITIVITY
,
1169 //======== Exp grows super-linearly for positive values
1172 // ---------------------
1173 // Conclusion: (or (<= t 0) (> exp(t) (+ t 1)))
1174 ARITH_TRANS_EXP_SUPER_LIN
,
1175 //======== Exp at zero
1178 // ---------------------
1179 // Conclusion: (= (= t 0) (= (exp t) 1))
1180 ARITH_TRANS_EXP_ZERO
,
1181 //======== Exp is approximated from above for negative values
1183 // Arguments: (d, t, l, u)
1184 // ---------------------
1185 // Conclusion: (=> (and (>= t l) (<= t u)) (<= (exp t) (secant exp l u t))
1186 // Where d is an even positive number, t an arithmetic term and l (u) a lower
1187 // (upper) bound on t. Let p be the d'th taylor polynomial at zero (also
1188 // called the Maclaurin series) of the exponential function. (secant exp l u
1189 // t) denotes the secant of p from (l, exp(l)) to (u, exp(u)) evaluated at t,
1190 // calculated as follows:
1191 // (p(l) - p(u)) / (l - u) * (t - l) + p(l)
1192 // The lemma states that if t is between l and u, then (exp t) is below the
1193 // secant of p from l to u.
1194 ARITH_TRANS_EXP_APPROX_ABOVE_NEG
,
1195 //======== Exp is approximated from above for positive values
1197 // Arguments: (d, t, l, u)
1198 // ---------------------
1199 // Conclusion: (=> (and (>= t l) (<= t u)) (<= (exp t) (secant-pos exp l u t))
1200 // Where d is an even positive number, t an arithmetic term and l (u) a lower
1201 // (upper) bound on t. Let p* be a modification of the d'th taylor polynomial
1202 // at zero (also called the Maclaurin series) of the exponential function as
1203 // follows where p(d-1) is the regular Maclaurin series of degree d-1:
1204 // p* = p(d-1) * (1 + t^n / n!)
1205 // (secant-pos exp l u t) denotes the secant of p from (l, exp(l)) to (u,
1206 // exp(u)) evaluated at t, calculated as follows:
1207 // (p(l) - p(u)) / (l - u) * (t - l) + p(l)
1208 // The lemma states that if t is between l and u, then (exp t) is below the
1209 // secant of p from l to u.
1210 ARITH_TRANS_EXP_APPROX_ABOVE_POS
,
1211 //======== Exp is approximated from below
1213 // Arguments: (d, t)
1214 // ---------------------
1215 // Conclusion: (>= (exp t) (maclaurin exp d t))
1216 // Where d is an odd positive number and (maclaurin exp d t) is the d'th
1217 // taylor polynomial at zero (also called the Maclaurin series) of the
1218 // exponential function evaluated at t. The Maclaurin series for the
1219 // exponential function is the following:
1220 // e^x = \sum_{n=0}^{\infty} x^n / n!
1221 ARITH_TRANS_EXP_APPROX_BELOW
,
1223 //======== Sine is always between -1 and 1
1226 // ---------------------
1227 // Conclusion: (and (<= (sin t) 1) (>= (sin t) (- 1)))
1228 ARITH_TRANS_SINE_BOUNDS
,
1229 //======== Sine arg shifted to -pi..pi
1231 // Arguments: (x, y, s)
1232 // ---------------------
1235 // (= (sin y) (sin x))
1236 // (ite (<= -pi x pi) (= x y) (= x (+ y (* 2 pi s))))
1238 // Where x is the argument to sine, y is a new real skolem that is x shifted
1239 // into -pi..pi and s is a new integer skolem that is the number of phases y
1241 ARITH_TRANS_SINE_SHIFT
,
1242 //======== Sine is symmetric with respect to negation of the argument
1245 // ---------------------
1246 // Conclusion: (= (- (sin t) (sin (- t))) 0)
1247 ARITH_TRANS_SINE_SYMMETRY
,
1248 //======== Sine is bounded by the tangent at zero
1251 // ---------------------
1253 // (=> (> t 0) (< (sin t) t))
1254 // (=> (< t 0) (> (sin t) t))
1256 ARITH_TRANS_SINE_TANGENT_ZERO
,
1257 //======== Sine is bounded by the tangents at -pi and pi
1260 // ---------------------
1262 // (=> (> t -pi) (> (sin t) (- -pi t)))
1263 // (=> (< t pi) (< (sin t) (- pi t)))
1265 ARITH_TRANS_SINE_TANGENT_PI
,
1266 //======== Sine is approximated from above for negative values
1268 // Arguments: (d, t, lb, ub, l, u)
1269 // ---------------------
1270 // Conclusion: (=> (and (>= t lb) (<= t ub)) (<= (sin t) (secant sin l u t))
1271 // Where d is an even positive number, t an arithmetic term, lb (ub) a
1272 // symbolic lower (upper) bound on t (possibly containing pi) and l (u) the
1273 // evaluated lower (upper) bound on t. Let p be the d'th taylor polynomial at
1274 // zero (also called the Maclaurin series) of the sine function. (secant sin l
1275 // u t) denotes the secant of p from (l, sin(l)) to (u, sin(u)) evaluated at
1276 // t, calculated as follows:
1277 // (p(l) - p(u)) / (l - u) * (t - l) + p(l)
1278 // The lemma states that if t is between l and u, then (sin t) is below the
1279 // secant of p from l to u.
1280 ARITH_TRANS_SINE_APPROX_ABOVE_NEG
,
1281 //======== Sine is approximated from above for positive values
1283 // Arguments: (d, t, c, lb, ub)
1284 // ---------------------
1285 // Conclusion: (=> (and (>= t lb) (<= t ub)) (<= (sin t) (upper sin c))
1286 // Where d is an even positive number, t an arithmetic term, c an arithmetic
1287 // constant, and lb (ub) a symbolic lower (upper) bound on t (possibly
1288 // containing pi). Let p be the d'th taylor polynomial at zero (also called
1289 // the Maclaurin series) of the sine function. (upper sin c) denotes the upper
1290 // bound on sin(c) given by p and lb,ub are such that sin(t) is the maximum of
1291 // the sine function on (lb,ub).
1292 ARITH_TRANS_SINE_APPROX_ABOVE_POS
,
1293 //======== Sine is approximated from below for negative values
1295 // Arguments: (d, t, c, lb, ub)
1296 // ---------------------
1297 // Conclusion: (=> (and (>= t lb) (<= t ub)) (>= (sin t) (lower sin c))
1298 // Where d is an even positive number, t an arithmetic term, c an arithmetic
1299 // constant, and lb (ub) a symbolic lower (upper) bound on t (possibly
1300 // containing pi). Let p be the d'th taylor polynomial at zero (also called
1301 // the Maclaurin series) of the sine function. (lower sin c) denotes the lower
1302 // bound on sin(c) given by p and lb,ub are such that sin(t) is the minimum of
1303 // the sine function on (lb,ub).
1304 ARITH_TRANS_SINE_APPROX_BELOW_NEG
,
1305 //======== Sine is approximated from below for positive values
1307 // Arguments: (d, t, lb, ub, l, u)
1308 // ---------------------
1309 // Conclusion: (=> (and (>= t lb) (<= t ub)) (>= (sin t) (secant sin l u t))
1310 // Where d is an even positive number, t an arithmetic term, lb (ub) a
1311 // symbolic lower (upper) bound on t (possibly containing pi) and l (u) the
1312 // evaluated lower (upper) bound on t. Let p be the d'th taylor polynomial at
1313 // zero (also called the Maclaurin series) of the sine function. (secant sin l
1314 // u t) denotes the secant of p from (l, sin(l)) to (u, sin(u)) evaluated at
1315 // t, calculated as follows:
1316 // (p(l) - p(u)) / (l - u) * (t - l) + p(l)
1317 // The lemma states that if t is between l and u, then (sin t) is above the
1318 // secant of p from l to u.
1319 ARITH_TRANS_SINE_APPROX_BELOW_POS
,
1321 // ================ CAD Lemmas
1322 // We use IRP for IndexedRootPredicate.
1324 // A formula "Interval" describes that a variable (xn is none is given) is
1325 // within a particular interval whose bounds are given as IRPs. It is either
1326 // an open interval or a point interval:
1327 // (IRP k poly) < xn < (IRP k poly)
1328 // xn == (IRP k poly)
1330 // A formula "Cell" describes a portion
1331 // of the real space in the following form:
1332 // Interval(x1) and Interval(x2) and ...
1333 // We implicitly assume a Cell to go up to n-1 (and can be empty).
1335 // A formula "Covering" is a set of Intervals, implying that xn can be in
1336 // neither of these intervals. To be a covering (of the real line), the union
1337 // of these intervals should be the real numbers.
1338 // ======== CAD direct conflict
1339 // Children (Cell, A)
1340 // ---------------------
1341 // Conclusion: (false)
1342 // A direct interval is generated from an assumption A (in variables x1...xn)
1343 // over a Cell (in variables x1...xn). It derives that A evaluates to false
1344 // over the Cell. In the actual algorithm, it means that xn can not be in the
1345 // topmost interval of the Cell.
1346 ARITH_NL_CAD_DIRECT
,
1347 // ======== CAD recursive interval
1348 // Children (Cell, Covering)
1349 // ---------------------
1350 // Conclusion: (false)
1351 // A recursive interval is generated from a Covering (for xn) over a Cell
1352 // (in variables x1...xn-1). It generates the conclusion that no xn exists
1353 // that extends the Cell and satisfies all assumptions.
1354 ARITH_NL_CAD_RECURSIVE
,
1356 //================================================= Unknown rule
1361 * Converts a proof rule to a string. Note: This function is also used in
1362 * `safe_print()`. Changing this function name or signature will result in
1363 * `safe_print()` printing "<unsupported>" instead of the proper strings for
1366 * @param id The proof rule
1367 * @return The name of the proof rule
1369 const char* toString(PfRule id
);
1372 * Writes a proof rule name to a stream.
1374 * @param out The stream to write to
1375 * @param id The proof rule to write to the stream
1376 * @return The stream
1378 std::ostream
& operator<<(std::ostream
& out
, PfRule id
);
1380 /** Hash function for proof rules */
1381 struct PfRuleHashFunction
1383 size_t operator()(PfRule id
) const;
1384 }; /* struct PfRuleHashFunction */
1388 #endif /* CVC5__EXPR__PROOF_RULE_H */