(proof-new) Add datatypes proof checker (#5340)
[cvc5.git] / src / expr / proof_rule.h
1 /********************* */
2 /*! \file proof_rule.h
3 ** \verbatim
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
11 **
12 ** \brief Proof rule enumeration
13 **/
14
15 #include "cvc4_private.h"
16
17 #ifndef CVC4__EXPR__PROOF_RULE_H
18 #define CVC4__EXPR__PROOF_RULE_H
19
20 #include <iosfwd>
21
22 namespace CVC4 {
23
24 /**
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
27 * proves formula F.
28 *
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.
34 *
35 * The following PfRule values include core rules and those categorized by
36 * theory, including the theory of equality.
37 *
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.
43 */
44 enum class PfRule : uint32_t
45 {
46 //================================================= Core rules
47 //======================== Assume and Scope
48 // ======== Assumption (a leaf)
49 // Children: none
50 // Arguments: (F)
51 // --------------
52 // Conclusion: F
53 //
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).
59 ASSUME,
60 // ======== Scope (a binder for assumptions)
61 // Children: (P:F)
62 // Arguments: (F1, ..., Fn)
63 // --------------
64 // Conclusion: (=> (and F1 ... Fn) F) or (not (and F1 ... Fn)) if F is false
65 //
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.
73 SCOPE,
74
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
82 // reverse order.
83 // Notice that ids is a MethodId identifier, which determines how to convert
84 // the formulas F1, ..., Fn into substitutions.
85 SUBS,
86 // ======== Rewrite
87 // Children: none
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.
93 REWRITE,
94 // ======== Evaluate
95 // Children: none
96 // Arguments: (t)
97 // ----------------------------------------
98 // Conclusion: (= t Evaluator::evaluate(t))
99 // Note this is equivalent to:
100 // (REWRITE t MethodId::RW_EVALUATE)
101 EVALUATE,
102 // ======== Substitution + Rewriting equality introduction
103 //
104 // In this rule, we provide a term t and conclude that it is equal to its
105 // rewritten form under a (proven) substitution.
106 //
107 // Children: (P1:F1, ..., Pn:Fn)
108 // Arguments: (t, (ids (idr)?)?)
109 // ---------------------------------------------------------------
110 // Conclusion: (= t t')
111 // where
112 // t' is
113 // Rewriter{idr}(t*sigma{ids}(Fn)*...*sigma{ids}(F1))
114 //
115 // In other words, from the point of view of Skolem forms, this rule
116 // transforms t to t' by standard substitution + rewriting.
117 //
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.
121 MACRO_SR_EQ_INTRO,
122 // ======== Substitution + Rewriting predicate introduction
123 //
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.
126 //
127 // Children: (P1:F1, ..., Pn:Fn)
128 // Arguments: (F, (ids (idr)?)?)
129 // ---------------------------------------------------------------
130 // Conclusion: F
131 // where
132 // Rewriter{idr}(F*sigma{ids}(Fn)*...*sigma{ids}(F1)) == true
133 // where ids and idr are method identifiers.
134 //
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)).
143 //
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.
147 MACRO_SR_PRED_INTRO,
148 // ======== Substitution + Rewriting predicate elimination
149 //
150 // In this rule, if we have proven a formula F, then we may conclude its
151 // rewritten form under a proven substitution.
152 //
153 // Children: (P1:F, P2:F1, ..., P_{n+1}:Fn)
154 // Arguments: ((ids (idr)?)?)
155 // ----------------------------------------
156 // Conclusion: F'
157 // where
158 // F' is
159 // Rewriter{idr}(F*sigma{ids}(Fn)*...*sigma{ids}(F1)).
160 // where ids and idr are method identifiers.
161 //
162 // We rewrite only on the Skolem form of F, similar to MACRO_SR_EQ_INTRO.
163 MACRO_SR_PRED_ELIM,
164 // ======== Substitution + Rewriting predicate transform
165 //
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
168 // substitution.
169 //
170 // Children: (P1:F, P2:F1, ..., P_{n+1}:Fn)
171 // Arguments: (G, (ids (idr)?)?)
172 // ----------------------------------------
173 // Conclusion: G
174 // where
175 // Rewriter{idr}(F*sigma{ids}(Fn)*...*sigma{ids}(F1)) ==
176 // Rewriter{idr}(G*sigma{ids}(Fn)*...*sigma{ids}(F1))
177 //
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,
183
184 //================================================= Processing rules
185 // ======== Remove Term Formulas Axiom
186 // Children: none
187 // Arguments: (t)
188 // ---------------------------------------------------------------
189 // Conclusion: RemoveTermFormulas::getAxiomFor(t).
190 REMOVE_TERM_FORMULA_AXIOM,
191
192 //================================================= Trusted rules
193 // ======== Theory lemma
194 // Children: none
195 // Arguments: (F, tid)
196 // ---------------------------------------------------------------
197 // Conclusion: F
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.
201 THEORY_LEMMA,
202 // ======== Theory Rewrite
203 // Children: none
204 // Arguments: (F, tid, rid)
205 // ----------------------------------------
206 // Conclusion: F
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
209 // is one of:
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.
215 THEORY_REWRITE,
216 // The rules in this section have the signature of a "trusted rule":
217 //
218 // Children: none
219 // Arguments: (F)
220 // ---------------------------------------------------------------
221 // Conclusion: F
222 //
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.
226 PREPROCESS,
227 // where F was added as a new assertion by some preprocessing pass.
228 PREPROCESS_LEMMA,
229 // where F is an equality of the form t = Theory::ppRewrite(t) for some
230 // theory. Notice this is a "trusted" rule.
231 THEORY_PREPROCESS,
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)).
236 WITNESS_AXIOM,
237 // where F is an equality (= t t') that holds by a form of rewriting that
238 // could not be replayed during proof postprocessing.
239 TRUST_REWRITE,
240 // where F is an equality (= t t') that holds by a form of substitution that
241 // could not be replayed during proof postprocessing.
242 TRUST_SUBS,
243 // where F is an equality (= t t') that holds by a form of substitution that
244 // could not be determined by the TrustSubstitutionMap.
245 TRUST_SUBS_MAP,
246
247 //================================================= Boolean rules
248 // ======== Resolution
249 // Children:
250 // (P1:C1, P2:C2)
251 // Arguments: (id, L)
252 // ---------------------
253 // Conclusion: C
254 // where
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.
267 //
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.
272 RESOLUTION,
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 // ---------------------
277 // Conclusion: C_m'
278 // where
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}'
282 CHAIN_RESOLUTION,
283 // ======== Factoring
284 // Children: (P:C1)
285 // Arguments: ()
286 // ---------------------
287 // Conclusion: C2
288 // where
289 // Set representations of C1 and C2 is the same and the number of literals in
290 // C2 is smaller than that of C1
291 FACTORING,
292 // ======== Reordering
293 // Children: (P:C1)
294 // Arguments: (C2)
295 // ---------------------
296 // Conclusion: C2
297 // where
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
300 REORDERING,
301
302 // ======== Split
303 // Children: none
304 // Arguments: (F)
305 // ---------------------
306 // Conclusion: (or F (not F))
307 SPLIT,
308 // ======== Equality resolution
309 // Children: (P1:F1, P2:(= F1 F2))
310 // Arguments: none
311 // ---------------------
312 // Conclusion: (F2)
313 // Note this can optionally be seen as a macro for EQUIV_ELIM1+RESOLUTION.
314 EQ_RESOLVE,
315 // ======== Modus ponens
316 // Children: (P1:F1, P2:(=> F1 F2))
317 // Arguments: none
318 // ---------------------
319 // Conclusion: (F2)
320 // Note this can optionally be seen as a macro for IMPLIES_ELIM+RESOLUTION.
321 MODUS_PONENS,
322 // ======== Double negation elimination
323 // Children: (P:(not (not F)))
324 // Arguments: none
325 // ---------------------
326 // Conclusion: (F)
327 NOT_NOT_ELIM,
328 // ======== Contradiction
329 // Children: (P1:F P2:(not F))
330 // Arguments: ()
331 // ---------------------
332 // Conclusion: false
333 CONTRA,
334 // ======== And elimination
335 // Children: (P:(and F1 ... Fn))
336 // Arguments: (i)
337 // ---------------------
338 // Conclusion: (Fi)
339 AND_ELIM,
340 // ======== And introduction
341 // Children: (P1:F1 ... Pn:Fn))
342 // Arguments: ()
343 // ---------------------
344 // Conclusion: (and P1 ... Pn)
345 AND_INTRO,
346 // ======== Not Or elimination
347 // Children: (P:(not (or F1 ... Fn)))
348 // Arguments: (i)
349 // ---------------------
350 // Conclusion: (not Fi)
351 NOT_OR_ELIM,
352 // ======== Implication elimination
353 // Children: (P:(=> F1 F2))
354 // Arguments: ()
355 // ---------------------
356 // Conclusion: (or (not F1) F2)
357 IMPLIES_ELIM,
358 // ======== Not Implication elimination version 1
359 // Children: (P:(not (=> F1 F2)))
360 // Arguments: ()
361 // ---------------------
362 // Conclusion: (F1)
363 NOT_IMPLIES_ELIM1,
364 // ======== Not Implication elimination version 2
365 // Children: (P:(not (=> F1 F2)))
366 // Arguments: ()
367 // ---------------------
368 // Conclusion: (not F2)
369 NOT_IMPLIES_ELIM2,
370 // ======== Equivalence elimination version 1
371 // Children: (P:(= F1 F2))
372 // Arguments: ()
373 // ---------------------
374 // Conclusion: (or (not F1) F2)
375 EQUIV_ELIM1,
376 // ======== Equivalence elimination version 2
377 // Children: (P:(= F1 F2))
378 // Arguments: ()
379 // ---------------------
380 // Conclusion: (or F1 (not F2))
381 EQUIV_ELIM2,
382 // ======== Not Equivalence elimination version 1
383 // Children: (P:(not (= F1 F2)))
384 // Arguments: ()
385 // ---------------------
386 // Conclusion: (or F1 F2)
387 NOT_EQUIV_ELIM1,
388 // ======== Not Equivalence elimination version 2
389 // Children: (P:(not (= F1 F2)))
390 // Arguments: ()
391 // ---------------------
392 // Conclusion: (or (not F1) (not F2))
393 NOT_EQUIV_ELIM2,
394 // ======== XOR elimination version 1
395 // Children: (P:(xor F1 F2)))
396 // Arguments: ()
397 // ---------------------
398 // Conclusion: (or F1 F2)
399 XOR_ELIM1,
400 // ======== XOR elimination version 2
401 // Children: (P:(xor F1 F2)))
402 // Arguments: ()
403 // ---------------------
404 // Conclusion: (or (not F1) (not F2))
405 XOR_ELIM2,
406 // ======== Not XOR elimination version 1
407 // Children: (P:(not (xor F1 F2)))
408 // Arguments: ()
409 // ---------------------
410 // Conclusion: (or F1 (not F2))
411 NOT_XOR_ELIM1,
412 // ======== Not XOR elimination version 2
413 // Children: (P:(not (xor F1 F2)))
414 // Arguments: ()
415 // ---------------------
416 // Conclusion: (or (not F1) F2)
417 NOT_XOR_ELIM2,
418 // ======== ITE elimination version 1
419 // Children: (P:(ite C F1 F2))
420 // Arguments: ()
421 // ---------------------
422 // Conclusion: (or (not C) F1)
423 ITE_ELIM1,
424 // ======== ITE elimination version 2
425 // Children: (P:(ite C F1 F2))
426 // Arguments: ()
427 // ---------------------
428 // Conclusion: (or C F2)
429 ITE_ELIM2,
430 // ======== Not ITE elimination version 1
431 // Children: (P:(not (ite C F1 F2)))
432 // Arguments: ()
433 // ---------------------
434 // Conclusion: (or (not C) (not F1))
435 NOT_ITE_ELIM1,
436 // ======== Not ITE elimination version 1
437 // Children: (P:(not (ite C F1 F2)))
438 // Arguments: ()
439 // ---------------------
440 // Conclusion: (or C (not F2))
441 NOT_ITE_ELIM2,
442
443 //================================================= De Morgan rules
444 // ======== Not And
445 // Children: (P:(not (and F1 ... Fn))
446 // Arguments: ()
447 // ---------------------
448 // Conclusion: (or (not F1) ... (not Fn))
449 NOT_AND,
450 //================================================= CNF rules
451 // ======== CNF And Pos
452 // Children: ()
453 // Arguments: ((and F1 ... Fn), i)
454 // ---------------------
455 // Conclusion: (or (not (and F1 ... Fn)) Fi)
456 CNF_AND_POS,
457 // ======== CNF And Neg
458 // Children: ()
459 // Arguments: ((and F1 ... Fn))
460 // ---------------------
461 // Conclusion: (or (and F1 ... Fn) (not F1) ... (not Fn))
462 CNF_AND_NEG,
463 // ======== CNF Or Pos
464 // Children: ()
465 // Arguments: ((or F1 ... Fn))
466 // ---------------------
467 // Conclusion: (or (not (or F1 ... Fn)) F1 ... Fn)
468 CNF_OR_POS,
469 // ======== CNF Or Neg
470 // Children: ()
471 // Arguments: ((or F1 ... Fn), i)
472 // ---------------------
473 // Conclusion: (or (or F1 ... Fn) (not Fi))
474 CNF_OR_NEG,
475 // ======== CNF Implies Pos
476 // Children: ()
477 // Arguments: ((implies F1 F2))
478 // ---------------------
479 // Conclusion: (or (not (implies F1 F2)) (not F1) F2)
480 CNF_IMPLIES_POS,
481 // ======== CNF Implies Neg version 1
482 // Children: ()
483 // Arguments: ((implies F1 F2))
484 // ---------------------
485 // Conclusion: (or (implies F1 F2) F1)
486 CNF_IMPLIES_NEG1,
487 // ======== CNF Implies Neg version 2
488 // Children: ()
489 // Arguments: ((implies F1 F2))
490 // ---------------------
491 // Conclusion: (or (implies F1 F2) (not F2))
492 CNF_IMPLIES_NEG2,
493 // ======== CNF Equiv Pos version 1
494 // Children: ()
495 // Arguments: ((= F1 F2))
496 // ---------------------
497 // Conclusion: (or (not (= F1 F2)) (not F1) F2)
498 CNF_EQUIV_POS1,
499 // ======== CNF Equiv Pos version 2
500 // Children: ()
501 // Arguments: ((= F1 F2))
502 // ---------------------
503 // Conclusion: (or (not (= F1 F2)) F1 (not F2))
504 CNF_EQUIV_POS2,
505 // ======== CNF Equiv Neg version 1
506 // Children: ()
507 // Arguments: ((= F1 F2))
508 // ---------------------
509 // Conclusion: (or (= F1 F2) F1 F2)
510 CNF_EQUIV_NEG1,
511 // ======== CNF Equiv Neg version 2
512 // Children: ()
513 // Arguments: ((= F1 F2))
514 // ---------------------
515 // Conclusion: (or (= F1 F2) (not F1) (not F2))
516 CNF_EQUIV_NEG2,
517 // ======== CNF Xor Pos version 1
518 // Children: ()
519 // Arguments: ((xor F1 F2))
520 // ---------------------
521 // Conclusion: (or (not (xor F1 F2)) F1 F2)
522 CNF_XOR_POS1,
523 // ======== CNF Xor Pos version 2
524 // Children: ()
525 // Arguments: ((xor F1 F2))
526 // ---------------------
527 // Conclusion: (or (not (xor F1 F2)) (not F1) (not F2))
528 CNF_XOR_POS2,
529 // ======== CNF Xor Neg version 1
530 // Children: ()
531 // Arguments: ((xor F1 F2))
532 // ---------------------
533 // Conclusion: (or (xor F1 F2) (not F1) F2)
534 CNF_XOR_NEG1,
535 // ======== CNF Xor Neg version 2
536 // Children: ()
537 // Arguments: ((xor F1 F2))
538 // ---------------------
539 // Conclusion: (or (xor F1 F2) F1 (not F2))
540 CNF_XOR_NEG2,
541 // ======== CNF ITE Pos version 1
542 // Children: ()
543 // Arguments: ((ite C F1 F2))
544 // ---------------------
545 // Conclusion: (or (not (ite C F1 F2)) (not C) F1)
546 CNF_ITE_POS1,
547 // ======== CNF ITE Pos version 2
548 // Children: ()
549 // Arguments: ((ite C F1 F2))
550 // ---------------------
551 // Conclusion: (or (not (ite C F1 F2)) C F2)
552 CNF_ITE_POS2,
553 // ======== CNF ITE Pos version 3
554 // Children: ()
555 // Arguments: ((ite C F1 F2))
556 // ---------------------
557 // Conclusion: (or (not (ite C F1 F2)) F1 F2)
558 CNF_ITE_POS3,
559 // ======== CNF ITE Neg version 1
560 // Children: ()
561 // Arguments: ((ite C F1 F2))
562 // ---------------------
563 // Conclusion: (or (ite C F1 F2) (not C) (not F1))
564 CNF_ITE_NEG1,
565 // ======== CNF ITE Neg version 2
566 // Children: ()
567 // Arguments: ((ite C F1 F2))
568 // ---------------------
569 // Conclusion: (or (ite C F1 F2) C (not F2))
570 CNF_ITE_NEG2,
571 // ======== CNF ITE Neg version 3
572 // Children: ()
573 // Arguments: ((ite C F1 F2))
574 // ---------------------
575 // Conclusion: (or (ite C F1 F2) (not F1) (not F2))
576 CNF_ITE_NEG3,
577
578 //================================================= Equality rules
579 // ======== Reflexive
580 // Children: none
581 // Arguments: (t)
582 // ---------------------
583 // Conclusion: (= t t)
584 REFL,
585 // ======== Symmetric
586 // Children: (P:(= t1 t2)) or (P:(not (= t1 t2)))
587 // Arguments: none
588 // -----------------------
589 // Conclusion: (= t2 t1) or (not (= t2 t1))
590 SYMM,
591 // ======== Transitivity
592 // Children: (P1:(= t1 t2), ..., Pn:(= t{n-1} tn))
593 // Arguments: none
594 // -----------------------
595 // Conclusion: (= t1 tn)
596 TRANS,
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.
605 CONG,
606 // ======== True intro
607 // Children: (P:F)
608 // Arguments: none
609 // ----------------------------------------
610 // Conclusion: (= F true)
611 TRUE_INTRO,
612 // ======== True elim
613 // Children: (P:(= F true))
614 // Arguments: none
615 // ----------------------------------------
616 // Conclusion: F
617 TRUE_ELIM,
618 // ======== False intro
619 // Children: (P:(not F))
620 // Arguments: none
621 // ----------------------------------------
622 // Conclusion: (= F false)
623 FALSE_INTRO,
624 // ======== False elim
625 // Children: (P:(= F false))
626 // Arguments: none
627 // ----------------------------------------
628 // Conclusion: (not F)
629 FALSE_ELIM,
630 // ======== HO trust
631 // Children: none
632 // Arguments: (t)
633 // ---------------------
634 // Conclusion: (= t TheoryUfRewriter::getHoApplyForApplyUf(t))
635 // For example, this rule concludes (f x y) = (HO_APPLY (HO_APPLY f x) y)
636 HO_APP_ENCODE,
637 // ======== Congruence
638 // Children: (P1:(= f g), P2:(= t1 s1), ..., Pn+1:(= tn sn))
639 // Arguments: ()
640 // ---------------------------------------------
641 // Conclusion: (= (f t1 ... tn) (g s1 ... sn))
642 // Notice that this rule is only used when the application kinds are APPLY_UF.
643 HO_CONG,
644
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)))
654 // Arguments: none
655 // ----------------------------------------
656 // Conclusion: (= i1 i2)
657 ARRAYS_READ_OVER_WRITE_CONTRA,
658 // ======== Read over write 1
659 // Children: none
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)))
666 // Arguments: none
667 // ----------------------------------------
668 // Conclusion: (not (= (select a k) (select b k)))
669 // where k is arrays::SkolemCache::getExtIndexSkolem((not (= a b))).
670 ARRAYS_EXT,
671 // ======== Array Trust
672 // Children: (P1 ... Pn)
673 // Arguments: (F)
674 // ---------------------
675 // Conclusion: F
676 ARRAYS_TRUST,
677
678 //================================================= Datatype rules
679 // ======== Unification
680 // Children: (P:(= (C t1 ... tn) (C s1 ... sn)))
681 // Arguments: (i)
682 // ----------------------------------------
683 // Conclusion: (= ti si)
684 // where C is a constructor.
685 DT_UNIF,
686 // ======== Instantiate
687 // Children: none
688 // Arguments: (t, n)
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.
693 DT_INST,
694 // ======== Collapse
695 // Children: none
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.
703 DT_COLLAPSE,
704 // ======== Split
705 // Children: none
706 // Arguments: (t)
707 // ----------------------------------------
708 // Conclusion: (or ((_ is C1) t) ... ((_ is Cn) t))
709 DT_SPLIT,
710 // ======== Clash
711 // Children: (P1:((_ is Ci) t), P2: ((_ is Cj) t))
712 // Arguments: none
713 // ----------------------------------------
714 // Conclusion: false
715 // for i != j.
716 DT_CLASH,
717 // ======== Datatype Trust
718 // Children: (P1 ... Pn)
719 // Arguments: (F)
720 // ---------------------
721 // Conclusion: F
722 DT_TRUST,
723
724 //================================================= Quantifiers rules
725 // ======== Witness intro
726 // Children: (P:(exists ((x T)) F[x]))
727 // Arguments: none
728 // ----------------------------------------
729 // Conclusion: (= k (witness ((x T)) F[x]))
730 // where k is the Skolem form of (witness ((x T)) F[x]).
731 WITNESS_INTRO,
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
738 // over x.
739 EXISTS_INTRO,
740 // ======== Skolemize
741 // Children: (P:(exists ((x1 T1) ... (xn Tn)) F))
742 // Arguments: none
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.
748 SKOLEMIZE,
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.
755 INSTANTIATE,
756
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)
764 //
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)
769 //
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
774 // returns non-null.
775 CONCAT_EQ,
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)
782 CONCAT_UNIFY,
783 // ======== Concat conflict
784 // Children: (P1:(= (str.++ c1 t) (str.++ c2 s)))
785 // Arguments: (b), indicating if reverse direction
786 // ---------------------
787 // Conclusion: false
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.
790 CONCAT_CONFLICT,
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)))
797 // where
798 // r_t = (witness ((z String)) (= z (suf t1 (str.len s1)))),
799 // r_s = (witness ((z String)) (= z (suf s1 (str.len t1)))).
800 //
801 // or the reverse form of the above:
802 //
803 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 s2)),
804 // P2:(not (= (str.len t2) (str.len s2))))
805 // Arguments: (true)
806 // ---------------------
807 // Conclusion: (or (= t2 (str.++ r_t s2)) (= s2 (str.++ r_s t2)))
808 // where
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)
811 // (str.len t2))))).
812 //
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).
815 CONCAT_SPLIT,
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))
822 // where
823 // r = (witness ((z String)) (= z (suf t1 1))).
824 //
825 // or the reverse form of the above:
826 //
827 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 c)),
828 // P2:(not (= (str.len t2) 0)))
829 // Arguments: (true)
830 // ---------------------
831 // Conclusion: (= t2 (str.++ r c))
832 // where
833 // r = (witness ((z String)) (= z (pre t2 (- (str.len t2) 1)))).
834 CONCAT_CSPLIT,
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))
841 // where
842 // r_t = (witness ((z String)) (= z (suf t1 (str.len s1))))
843 //
844 // or the reverse form of the above:
845 //
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))
851 // where
852 // r_t = (witness ((z String)) (= z (pre t2 (- (str.len t2) (str.len
853 // s2))))).
854 CONCAT_LPROP,
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))
861 // where
862 // w1, w2, w3, w4 are words,
863 // w3 is (pre w2 p),
864 // w4 is (suf w2 p),
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.
869 //
870 // or the reverse form of the above:
871 //
872 // Children: (P1:(= (str.++ t1 w1 t2) (str.++ s w2)),
873 // P2:(not (= (str.len t2) 0)))
874 // Arguments: (true)
875 // ---------------------
876 // Conclusion: (= t2 (str.++ r w3))
877 // where
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.
886 CONCAT_CPROP,
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))
892 // or
893 // Children: (P1: (>= (str.len t) n)
894 // Arguments: (true)
895 // ---------------------
896 // Conclusion: (and (= t (str.++ w1 w2)) (= (str.len w2) n))
897 // where
898 // w1 is (witness ((z String)) (= z (pre t n)))
899 // w2 is (witness ((z String)) (= z (suf t n)))
900 STRING_DECOMPOSE,
901 // ======== Length positive
902 // Children: none
903 // Arguments: (t)
904 // ---------------------
905 // Conclusion: (or (and (= (str.len t) 0) (= t "")) (> (str.len t 0)))
906 STRING_LENGTH_POS,
907 // ======== Length non-empty
908 // Children: (P1:(not (= t "")))
909 // Arguments: none
910 // ---------------------
911 // Conclusion: (not (= (str.len t) 0))
912 STRING_LENGTH_NON_EMPTY,
913 //======================== Extended functions
914 // ======== Reduction
915 // Children: none
916 // Arguments: (t)
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.
923 STRING_REDUCTION,
924 // ======== Eager Reduction
925 // Children: none
926 // Arguments: (t, id?)
927 // ---------------------
928 // Conclusion: R
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))
934 // Arguments: none
935 // ---------------------
936 // Conclusion: (str.in.re t (re.inter R1 R2)).
937 RE_INTER,
938 // ======== Regular expression unfold positive
939 // Children: (P:(str.in.re t R))
940 // Arguments: none
941 // ---------------------
942 // Conclusion:(RegExpOpr::reduceRegExpPos((str.in.re t R))),
943 // corresponding to the one-step unfolding of the premise.
944 RE_UNFOLD_POS,
945 // ======== Regular expression unfold negative
946 // Children: (P:(not (str.in.re t R)))
947 // Arguments: none
948 // ---------------------
949 // Conclusion:(RegExpOpr::reduceRegExpNeg((not (str.in.re t R)))),
950 // corresponding to the one-step unfolding of the premise.
951 RE_UNFOLD_NEG,
952 // ======== Regular expression unfold negative concat fixed
953 // Children: (P:(not (str.in.re t R)))
954 // Arguments: none
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
962 // Children: (P:F)
963 // Arguments: none
964 // ---------------------
965 // Conclusion: R
966 // where R = strings::RegExpElimination::eliminate(F).
967 RE_ELIM,
968 //======================== Code points
969 // Children: none
970 // Arguments: (t, s)
971 // ---------------------
972 // Conclusion:(or (= (str.code t) (- 1))
973 // (not (= (str.code t) (str.code s)))
974 // (not (= t s)))
975 STRING_CODE_INJ,
976 //======================== Sequence unit
977 // Children: (P:(= (seq.unit x) (seq.unit y)))
978 // Arguments: none
979 // ---------------------
980 // Conclusion:(= x y)
981 // Also applies to the case where (seq.unit y) is a constant sequence
982 // of length one.
983 STRING_SEQ_UNIT_INJ,
984 // ======== String Trust
985 // Children: none
986 // Arguments: (Q)
987 // ---------------------
988 // Conclusion: (Q)
989 STRING_TRUST,
990
991 //================================================= Arithmetic rules
992 // ======== Adding Inequalities
993 // Note: an ArithLiteral is a term of the form (>< poly const)
994 // where
995 // >< is >=, >, ==, <, <=, or not(== ...).
996 // poly is a polynomial
997 // const is a rational constant
998
999 // Children: (P1:l1, ..., Pn:ln)
1000 // where each li is an ArithLiteral
1001 // not(= ...) is dis-allowed!
1002 //
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,
1013
1014 // ======== Tightening Strict Integer Upper Bounds
1015 // Children: (P:(< i c))
1016 // where i has integer type.
1017 // Arguments: none
1018 // ---------------------
1019 // Conclusion: (<= i greatestIntLessThan(c)})
1020 INT_TIGHT_UB,
1021
1022 // ======== Tightening Strict Integer Lower Bounds
1023 // Children: (P:(> i c))
1024 // where i has integer type.
1025 // Arguments: none
1026 // ---------------------
1027 // Conclusion: (>= i leastIntGreaterThan(c)})
1028 INT_TIGHT_LB,
1029
1030 // ======== Trichotomy of the reals
1031 // Children: (A B)
1032 // Arguments: (C)
1033 // ---------------------
1034 // Conclusion: (C),
1035 // where (not A) (not B) and C
1036 // are (> x c) (< x c) and (= x c)
1037 // in some order
1038 // note that "not" here denotes arithmetic negation, flipping
1039 // >= to <, etc.
1040 ARITH_TRICHOTOMY,
1041
1042 // ======== Arithmetic operator elimination
1043 // Children: none
1044 // Arguments: (t)
1045 // ---------------------
1046 // Conclusion: arith::OperatorElim::getAxiomFor(t)
1047 ARITH_OP_ELIM_AXIOM,
1048
1049 // ======== Int Trust
1050 // Children: (P1 ... Pn)
1051 // Arguments: (Q)
1052 // ---------------------
1053 // Conclusion: (Q)
1054 INT_TRUST,
1055
1056 //================================================= Unknown rule
1057 UNKNOWN,
1058 };
1059
1060 /**
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
1064 * the enum values.
1065 *
1066 * @param id The proof rule
1067 * @return The name of the proof rule
1068 */
1069 const char* toString(PfRule id);
1070
1071 /**
1072 * Writes a proof rule name to a stream.
1073 *
1074 * @param out The stream to write to
1075 * @param id The proof rule to write to the stream
1076 * @return The stream
1077 */
1078 std::ostream& operator<<(std::ostream& out, PfRule id);
1079
1080 /** Hash function for proof rules */
1081 struct PfRuleHashFunction
1082 {
1083 size_t operator()(PfRule id) const;
1084 }; /* struct PfRuleHashFunction */
1085
1086 } // namespace CVC4
1087
1088 #endif /* CVC4__EXPR__PROOF_RULE_H */