(proof-new) Add the strings proof checker (#4858)
[cvc5.git] / src / expr / proof_rule.h
1 /********************* */
2 /*! \file proof_rule.h
3 ** \verbatim
4 ** Top contributors (to current version):
5 ** Haniel Barbosa, Andrew Reynolds
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 // ======== Substitution + Rewriting equality introduction
95 //
96 // In this rule, we provide a term t and conclude that it is equal to its
97 // rewritten form under a (proven) substitution.
98 //
99 // Children: (P1:F1, ..., Pn:Fn)
100 // Arguments: (t, (ids (idr)?)?)
101 // ---------------------------------------------------------------
102 // Conclusion: (= t t')
103 // where
104 // t' is
105 // Rewriter{idr}(t*sigma{ids}(Fn)*...*sigma{ids}(F1))
106 //
107 // In other words, from the point of view of Skolem forms, this rule
108 // transforms t to t' by standard substitution + rewriting.
109 //
110 // The argument ids and idr is optional and specify the identifier of the
111 // substitution and rewriter respectively to be used. For details, see
112 // theory/builtin/proof_checker.h.
113 MACRO_SR_EQ_INTRO,
114 // ======== Substitution + Rewriting predicate introduction
115 //
116 // In this rule, we provide a formula F and conclude it, under the condition
117 // that it rewrites to true under a proven substitution.
118 //
119 // Children: (P1:F1, ..., Pn:Fn)
120 // Arguments: (F, (ids (idr)?)?)
121 // ---------------------------------------------------------------
122 // Conclusion: F
123 // where
124 // Rewriter{idr}(toWitness(F)*sigma{ids}(Fn)*...*sigma{ids}(F1)) == true
125 // where ids and idr are method identifiers.
126 //
127 // Notice that we apply rewriting on the witness form of F, meaning that this
128 // rule may conclude an F whose Skolem form is justified by the definition of
129 // its (fresh) Skolem variables. Furthermore, notice that the rewriting and
130 // substitution is applied only within the side condition, meaning the
131 // rewritten form of the witness form of F does not escape this rule.
132 MACRO_SR_PRED_INTRO,
133 // ======== Substitution + Rewriting predicate elimination
134 //
135 // In this rule, if we have proven a formula F, then we may conclude its
136 // rewritten form under a proven substitution.
137 //
138 // Children: (P1:F, P2:F1, ..., P_{n+1}:Fn)
139 // Arguments: ((ids (idr)?)?)
140 // ----------------------------------------
141 // Conclusion: F'
142 // where
143 // F' is
144 // Rewriter{idr}(F*sigma{ids}(Fn)*...*sigma{ids}(F1)).
145 // where ids and idr are method identifiers.
146 //
147 // We rewrite only on the Skolem form of F, similar to MACRO_SR_EQ_INTRO.
148 MACRO_SR_PRED_ELIM,
149 // ======== Substitution + Rewriting predicate transform
150 //
151 // In this rule, if we have proven a formula F, then we may provide a formula
152 // G and conclude it if F and G are equivalent after rewriting under a proven
153 // substitution.
154 //
155 // Children: (P1:F, P2:F1, ..., P_{n+1}:Fn)
156 // Arguments: (G, (ids (idr)?)?)
157 // ----------------------------------------
158 // Conclusion: G
159 // where
160 // Rewriter{idr}(toWitness(F)*sigma{ids}(Fn)*...*sigma{ids}(F1)) ==
161 // Rewriter{idr}(toWitness(G)*sigma{ids}(Fn)*...*sigma{ids}(F1))
162 //
163 // Notice that we apply rewriting on the witness form of F and G, similar to
164 // MACRO_SR_PRED_INTRO.
165 MACRO_SR_PRED_TRANSFORM,
166 // ======== Theory Rewrite
167 // Children: none
168 // Arguments: (t, preRewrite?)
169 // ----------------------------------------
170 // Conclusion: (= t t')
171 // where
172 // t' is the result of applying either a pre-rewrite or a post-rewrite step
173 // to t (depending on the second argument).
174 THEORY_REWRITE,
175
176 //================================================= Processing rules
177 // ======== Preprocess (trusted)
178 // Children: none
179 // Arguments: (F)
180 // ---------------------------------------------------------------
181 // Conclusion: F
182 // where F is an equality of the form t = t' where t was replaced by t'
183 // based on some preprocessing pass, or otherwise F was added as a new
184 // assertion by some preprocessing pass.
185 PREPROCESS,
186 // ======== Witness axiom (trusted)
187 // Children: none
188 // Arguments: (F)
189 // ---------------------------------------------------------------
190 // Conclusion: F
191 // where F is an existential (exists ((x T)) (P x)) used for introducing
192 // a witness term (witness ((x T)) (P x)).
193 WITNESS_AXIOM,
194 // ======== Remove Term Formulas Axiom
195 // Children: none
196 // Arguments: (t)
197 // ---------------------------------------------------------------
198 // Conclusion: RemoveTermFormulas::getAxiomFor(t).
199 REMOVE_TERM_FORMULA_AXIOM,
200
201 //================================================= Boolean rules
202 // ======== Split
203 // Children: none
204 // Arguments: (F)
205 // ---------------------
206 // Conclusion: (or F (not F))
207 SPLIT,
208 // ======== Equality resolution
209 // Children: (P1:F1, P2:(= F1 F2))
210 // Arguments: none
211 // ---------------------
212 // Conclusion: (F2)
213 // Note this can optionally be seen as a macro for EQUIV_ELIM1+RESOLUTION.
214 EQ_RESOLVE,
215 // ======== And elimination
216 // Children: (P:(and F1 ... Fn))
217 // Arguments: (i)
218 // ---------------------
219 // Conclusion: (Fi)
220 AND_ELIM,
221 // ======== And introduction
222 // Children: (P1:F1 ... Pn:Fn))
223 // Arguments: ()
224 // ---------------------
225 // Conclusion: (and P1 ... Pn)
226 AND_INTRO,
227 // ======== Not Or elimination
228 // Children: (P:(not (or F1 ... Fn)))
229 // Arguments: (i)
230 // ---------------------
231 // Conclusion: (not Fi)
232 NOT_OR_ELIM,
233 // ======== Implication elimination
234 // Children: (P:(=> F1 F2))
235 // Arguments: ()
236 // ---------------------
237 // Conclusion: (or (not F1) F2)
238 IMPLIES_ELIM,
239 // ======== Not Implication elimination version 1
240 // Children: (P:(not (=> F1 F2)))
241 // Arguments: ()
242 // ---------------------
243 // Conclusion: (F1)
244 NOT_IMPLIES_ELIM1,
245 // ======== Not Implication elimination version 2
246 // Children: (P:(not (=> F1 F2)))
247 // Arguments: ()
248 // ---------------------
249 // Conclusion: (not F2)
250 NOT_IMPLIES_ELIM2,
251 // ======== Equivalence elimination version 1
252 // Children: (P:(= F1 F2))
253 // Arguments: ()
254 // ---------------------
255 // Conclusion: (or (not F1) F2)
256 EQUIV_ELIM1,
257 // ======== Equivalence elimination version 2
258 // Children: (P:(= F1 F2))
259 // Arguments: ()
260 // ---------------------
261 // Conclusion: (or F1 (not F2))
262 EQUIV_ELIM2,
263 // ======== Not Equivalence elimination version 1
264 // Children: (P:(not (= F1 F2)))
265 // Arguments: ()
266 // ---------------------
267 // Conclusion: (or F1 F2)
268 NOT_EQUIV_ELIM1,
269 // ======== Not Equivalence elimination version 2
270 // Children: (P:(not (= F1 F2)))
271 // Arguments: ()
272 // ---------------------
273 // Conclusion: (or (not F1) (not F2))
274 NOT_EQUIV_ELIM2,
275 // ======== XOR elimination version 1
276 // Children: (P:(xor F1 F2)))
277 // Arguments: ()
278 // ---------------------
279 // Conclusion: (or F1 F2)
280 XOR_ELIM1,
281 // ======== XOR elimination version 2
282 // Children: (P:(xor F1 F2)))
283 // Arguments: ()
284 // ---------------------
285 // Conclusion: (or (not F1) (not F2))
286 XOR_ELIM2,
287 // ======== Not XOR elimination version 1
288 // Children: (P:(not (xor F1 F2)))
289 // Arguments: ()
290 // ---------------------
291 // Conclusion: (or F1 (not F2))
292 NOT_XOR_ELIM1,
293 // ======== Not XOR elimination version 2
294 // Children: (P:(not (xor F1 F2)))
295 // Arguments: ()
296 // ---------------------
297 // Conclusion: (or (not F1) F2)
298 NOT_XOR_ELIM2,
299 // ======== ITE elimination version 1
300 // Children: (P:(ite C F1 F2))
301 // Arguments: ()
302 // ---------------------
303 // Conclusion: (or (not C) F1)
304 ITE_ELIM1,
305 // ======== ITE elimination version 2
306 // Children: (P:(ite C F1 F2))
307 // Arguments: ()
308 // ---------------------
309 // Conclusion: (or C F2)
310 ITE_ELIM2,
311 // ======== Not ITE elimination version 1
312 // Children: (P:(not (ite C F1 F2)))
313 // Arguments: ()
314 // ---------------------
315 // Conclusion: (or (not C) (not F1))
316 NOT_ITE_ELIM1,
317 // ======== Not ITE elimination version 1
318 // Children: (P:(not (ite C F1 F2)))
319 // Arguments: ()
320 // ---------------------
321 // Conclusion: (or C (not F2))
322 NOT_ITE_ELIM2,
323 // ======== Not ITE elimination version 1
324 // Children: (P1:P P2:(not P))
325 // Arguments: ()
326 // ---------------------
327 // Conclusion: (false)
328 CONTRA,
329
330 //================================================= De Morgan rules
331 // ======== Not And
332 // Children: (P:(not (and F1 ... Fn))
333 // Arguments: ()
334 // ---------------------
335 // Conclusion: (or (not F1) ... (not Fn))
336 NOT_AND,
337 //================================================= CNF rules
338 // ======== CNF And Pos
339 // Children: ()
340 // Arguments: ((and F1 ... Fn), i)
341 // ---------------------
342 // Conclusion: (or (not (and F1 ... Fn)) Fi)
343 CNF_AND_POS,
344 // ======== CNF And Neg
345 // Children: ()
346 // Arguments: ((and F1 ... Fn))
347 // ---------------------
348 // Conclusion: (or (and F1 ... Fn) (not F1) ... (not Fn))
349 CNF_AND_NEG,
350 // ======== CNF Or Pos
351 // Children: ()
352 // Arguments: ((or F1 ... Fn))
353 // ---------------------
354 // Conclusion: (or (not (or F1 ... Fn)) F1 ... Fn)
355 CNF_OR_POS,
356 // ======== CNF Or Neg
357 // Children: ()
358 // Arguments: ((or F1 ... Fn), i)
359 // ---------------------
360 // Conclusion: (or (or F1 ... Fn) (not Fi))
361 CNF_OR_NEG,
362 // ======== CNF Implies Pos
363 // Children: ()
364 // Arguments: ((implies F1 F2))
365 // ---------------------
366 // Conclusion: (or (not (implies F1 F2)) (not F1) F2)
367 CNF_IMPLIES_POS,
368 // ======== CNF Implies Neg version 1
369 // Children: ()
370 // Arguments: ((implies F1 F2))
371 // ---------------------
372 // Conclusion: (or (implies F1 F2) F1)
373 CNF_IMPLIES_NEG1,
374 // ======== CNF Implies Neg version 2
375 // Children: ()
376 // Arguments: ((implies F1 F2))
377 // ---------------------
378 // Conclusion: (or (implies F1 F2) (not F2))
379 CNF_IMPLIES_NEG2,
380 // ======== CNF Equiv Pos version 1
381 // Children: ()
382 // Arguments: ((= F1 F2))
383 // ---------------------
384 // Conclusion: (or (not (= F1 F2)) (not F1) F2)
385 CNF_EQUIV_POS1,
386 // ======== CNF Equiv Pos version 2
387 // Children: ()
388 // Arguments: ((= F1 F2))
389 // ---------------------
390 // Conclusion: (or (not (= F1 F2)) F1 (not F2))
391 CNF_EQUIV_POS2,
392 // ======== CNF Equiv Neg version 1
393 // Children: ()
394 // Arguments: ((= F1 F2))
395 // ---------------------
396 // Conclusion: (or (= F1 F2) F1 F2)
397 CNF_EQUIV_NEG1,
398 // ======== CNF Equiv Neg version 2
399 // Children: ()
400 // Arguments: ((= F1 F2))
401 // ---------------------
402 // Conclusion: (or (= F1 F2) (not F1) (not F2))
403 CNF_EQUIV_NEG2,
404 // ======== CNF Xor Pos version 1
405 // Children: ()
406 // Arguments: ((xor F1 F2))
407 // ---------------------
408 // Conclusion: (or (not (xor F1 F2)) F1 F2)
409 CNF_XOR_POS1,
410 // ======== CNF Xor Pos version 2
411 // Children: ()
412 // Arguments: ((xor F1 F2))
413 // ---------------------
414 // Conclusion: (or (not (xor F1 F2)) (not F1) (not F2))
415 CNF_XOR_POS2,
416 // ======== CNF Xor Neg version 1
417 // Children: ()
418 // Arguments: ((xor F1 F2))
419 // ---------------------
420 // Conclusion: (or (xor F1 F2) (not F1) F2)
421 CNF_XOR_NEG1,
422 // ======== CNF Xor Neg version 2
423 // Children: ()
424 // Arguments: ((xor F1 F2))
425 // ---------------------
426 // Conclusion: (or (xor F1 F2) F1 (not F2))
427 CNF_XOR_NEG2,
428 // ======== CNF ITE Pos version 1
429 // Children: ()
430 // Arguments: ((ite C F1 F2))
431 // ---------------------
432 // Conclusion: (or (not (ite C F1 F2)) (not C) F1)
433 CNF_ITE_POS1,
434 // ======== CNF ITE Pos version 2
435 // Children: ()
436 // Arguments: ((ite C F1 F2))
437 // ---------------------
438 // Conclusion: (or (not (ite C F1 F2)) C F2)
439 CNF_ITE_POS2,
440 // ======== CNF ITE Pos version 3
441 // Children: ()
442 // Arguments: ((ite C F1 F2))
443 // ---------------------
444 // Conclusion: (or (not (ite C F1 F2)) F1 F2)
445 CNF_ITE_POS3,
446 // ======== CNF ITE Neg version 1
447 // Children: ()
448 // Arguments: ((ite C F1 F2))
449 // ---------------------
450 // Conclusion: (or (ite C F1 F2) (not C) (not F1))
451 CNF_ITE_NEG1,
452 // ======== CNF ITE Neg version 2
453 // Children: ()
454 // Arguments: ((ite C F1 F2))
455 // ---------------------
456 // Conclusion: (or (ite C F1 F2) C (not F2))
457 CNF_ITE_NEG2,
458 // ======== CNF ITE Neg version 3
459 // Children: ()
460 // Arguments: ((ite C F1 F2))
461 // ---------------------
462 // Conclusion: (or (ite C F1 F2) (not F1) (not F2))
463 CNF_ITE_NEG3,
464
465 //================================================= Equality rules
466 // ======== Reflexive
467 // Children: none
468 // Arguments: (t)
469 // ---------------------
470 // Conclusion: (= t t)
471 REFL,
472 // ======== Symmetric
473 // Children: (P:(= t1 t2)) or (P:(not (= t1 t2)))
474 // Arguments: none
475 // -----------------------
476 // Conclusion: (= t2 t1) or (not (= t2 t1))
477 SYMM,
478 // ======== Transitivity
479 // Children: (P1:(= t1 t2), ..., Pn:(= t{n-1} tn))
480 // Arguments: none
481 // -----------------------
482 // Conclusion: (= t1 tn)
483 TRANS,
484 // ======== Congruence
485 // Children: (P1:(= t1 s1), ..., Pn:(= tn sn))
486 // Arguments: (<kind> f?)
487 // ---------------------------------------------
488 // Conclusion: (= (<kind> f? t1 ... tn) (<kind> f? s1 ... sn))
489 // Notice that f must be provided iff <kind> is a parameterized kind, e.g.
490 // APPLY_UF. The actual node for <kind> is constructible via
491 // ProofRuleChecker::mkKindNode.
492 CONG,
493 // ======== True intro
494 // Children: (P:F)
495 // Arguments: none
496 // ----------------------------------------
497 // Conclusion: (= F true)
498 TRUE_INTRO,
499 // ======== True elim
500 // Children: (P:(= F true)
501 // Arguments: none
502 // ----------------------------------------
503 // Conclusion: F
504 TRUE_ELIM,
505 // ======== False intro
506 // Children: (P:(not F))
507 // Arguments: none
508 // ----------------------------------------
509 // Conclusion: (= F false)
510 FALSE_INTRO,
511 // ======== False elim
512 // Children: (P:(= F false)
513 // Arguments: none
514 // ----------------------------------------
515 // Conclusion: (not F)
516 FALSE_ELIM,
517
518 //================================================= Quantifiers rules
519 // ======== Witness intro
520 // Children: (P:F[t])
521 // Arguments: (t)
522 // ----------------------------------------
523 // Conclusion: (= t (witness ((x T)) F[x]))
524 // where x is a BOUND_VARIABLE unique to the pair F,t.
525 WITNESS_INTRO,
526 // ======== Exists intro
527 // Children: (P:F[t])
528 // Arguments: (t)
529 // ----------------------------------------
530 // Conclusion: (exists ((x T)) F[x])
531 // where x is a BOUND_VARIABLE unique to the pair F,t.
532 EXISTS_INTRO,
533 // ======== Skolemize
534 // Children: (P:(exists ((x1 T1) ... (xn Tn)) F))
535 // Arguments: none
536 // ----------------------------------------
537 // Conclusion: F*sigma
538 // sigma maps x1 ... xn to their representative skolems obtained by
539 // SkolemManager::mkSkolemize, returned in the skolems argument of that
540 // method.
541 SKOLEMIZE,
542 // ======== Instantiate
543 // Children: (P:(forall ((x1 T1) ... (xn Tn)) F))
544 // Arguments: (t1 ... tn)
545 // ----------------------------------------
546 // Conclusion: F*sigma
547 // sigma maps x1 ... xn to t1 ... tn.
548 INSTANTIATE,
549
550 //================================================= String rules
551 //======================== Core solver
552 // ======== Concat eq
553 // Children: (P1:(= (str.++ t1 ... tn t) (str.++ t1 ... tn s)))
554 // Arguments: (b), indicating if reverse direction
555 // ---------------------
556 // Conclusion: (= t s)
557 //
558 // Notice that t or s may be empty, in which case they are implicit in the
559 // concatenation above. For example, if
560 // P1 concludes (= x (str.++ x z)), then
561 // (CONCAT_EQ P1 :args false) concludes (= "" z)
562 //
563 // Also note that constants are split, such that if
564 // P1 concludes (= (str.++ "abc" x) (str.++ "a" y)), then
565 // (CONCAT_EQ P1 :args false) concludes (= (str.++ "bc" x) y)
566 // This splitting is done only for constants such that Word::splitConstant
567 // returns non-null.
568 CONCAT_EQ,
569 // ======== Concat unify
570 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 s2)),
571 // P2:(= (str.len t1) (str.len s1)))
572 // Arguments: (b), indicating if reverse direction
573 // ---------------------
574 // Conclusion: (= t1 s1)
575 CONCAT_UNIFY,
576 // ======== Concat conflict
577 // Children: (P1:(= (str.++ c1 t) (str.++ c2 s)))
578 // Arguments: (b), indicating if reverse direction
579 // ---------------------
580 // Conclusion: false
581 // Where c1, c2 are constants such that Word::splitConstant(c1,c2,index,b)
582 // is null, in other words, neither is a prefix of the other.
583 CONCAT_CONFLICT,
584 // ======== Concat split
585 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 s2)),
586 // P2:(not (= (str.len t1) (str.len s1))))
587 // Arguments: (false)
588 // ---------------------
589 // Conclusion: (or (= t1 (str.++ s1 r_t)) (= s1 (str.++ t1 r_s)))
590 // where
591 // r_t = (witness ((z String)) (= z (suf t1 (str.len s1)))),
592 // r_s = (witness ((z String)) (= z (suf s1 (str.len t1)))).
593 //
594 // or the reverse form of the above:
595 //
596 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 s2)),
597 // P2:(not (= (str.len t2) (str.len s2))))
598 // Arguments: (true)
599 // ---------------------
600 // Conclusion: (or (= t2 (str.++ r_t s2)) (= s2 (str.++ r_s t2)))
601 // where
602 // r_t = (witness ((z String)) (= z (pre t2 (- (str.len t2) (str.len
603 // s2))))), r_s = (witness ((z String)) (= z (pre s2 (- (str.len s2)
604 // (str.len t2))))).
605 //
606 // Above, (suf x n) is shorthand for (str.substr x n (- (str.len x) n)) and
607 // (pre x n) is shorthand for (str.substr x 0 n).
608 CONCAT_SPLIT,
609 // ======== Concat constant split
610 // Children: (P1:(= (str.++ t1 t2) (str.++ c s2)),
611 // P2:(not (= (str.len t1) 0)))
612 // Arguments: (false)
613 // ---------------------
614 // Conclusion: (= t1 (str.++ c r))
615 // where
616 // r = (witness ((z String)) (= z (suf t1 1))).
617 //
618 // or the reverse form of the above:
619 //
620 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 c)),
621 // P2:(not (= (str.len t2) 0)))
622 // Arguments: (true)
623 // ---------------------
624 // Conclusion: (= t2 (str.++ r c))
625 // where
626 // r = (witness ((z String)) (= z (pre t2 (- (str.len t2) 1)))).
627 CONCAT_CSPLIT,
628 // ======== Concat length propagate
629 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 s2)),
630 // P2:(> (str.len t1) (str.len s1)))
631 // Arguments: (false)
632 // ---------------------
633 // Conclusion: (= t1 (str.++ s1 r_t))
634 // where
635 // r_t = (witness ((z String)) (= z (suf t1 (str.len s1))))
636 //
637 // or the reverse form of the above:
638 //
639 // Children: (P1:(= (str.++ t1 t2) (str.++ s1 s2)),
640 // P2:(> (str.len t2) (str.len s2)))
641 // Arguments: (false)
642 // ---------------------
643 // Conclusion: (= t2 (str.++ r_t s2))
644 // where
645 // r_t = (witness ((z String)) (= z (pre t2 (- (str.len t2) (str.len
646 // s2))))).
647 CONCAT_LPROP,
648 // ======== Concat constant propagate
649 // Children: (P1:(= (str.++ t1 w1 t2) (str.++ w2 s)),
650 // P2:(not (= (str.len t1) 0)))
651 // Arguments: (false)
652 // ---------------------
653 // Conclusion: (= t1 (str.++ w3 r))
654 // where
655 // w1, w2, w3, w4 are words,
656 // w3 is (pre w2 p),
657 // w4 is (suf w2 p),
658 // p = Word::overlap((suf w2 1), w1),
659 // r = (witness ((z String)) (= z (suf t1 (str.len w3)))).
660 // In other words, w4 is the largest suffix of (suf w2 1) that can contain a
661 // prefix of w1; since t1 is non-empty, w3 must therefore be contained in t1.
662 //
663 // or the reverse form of the above:
664 //
665 // Children: (P1:(= (str.++ t1 w1 t2) (str.++ s w2)),
666 // P2:(not (= (str.len t2) 0)))
667 // Arguments: (true)
668 // ---------------------
669 // Conclusion: (= t2 (str.++ r w3))
670 // where
671 // w1, w2, w3, w4 are words,
672 // w3 is (suf w2 (- (str.len w2) p)),
673 // w4 is (pre w2 (- (str.len w2) p)),
674 // p = Word::roverlap((pre w2 (- (str.len w2) 1)), w1),
675 // r = (witness ((z String)) (= z (pre t2 (- (str.len t2) (str.len w3))))).
676 // In other words, w4 is the largest prefix of (pre w2 (- (str.len w2) 1))
677 // that can contain a suffix of w1; since t2 is non-empty, w3 must therefore
678 // be contained in t2.
679 CONCAT_CPROP,
680 // ======== String decompose
681 // Children: (P1: (>= (str.len t) n)
682 // Arguments: (false)
683 // ---------------------
684 // Conclusion: (and (= t (str.++ w1 w2)) (= (str.len w1) n))
685 // or
686 // Children: (P1: (>= (str.len t) n)
687 // Arguments: (true)
688 // ---------------------
689 // Conclusion: (and (= t (str.++ w1 w2)) (= (str.len w2) n))
690 // where
691 // w1 is (witness ((z String)) (= z (pre t n)))
692 // w2 is (witness ((z String)) (= z (suf t n)))
693 STRING_DECOMPOSE,
694 // ======== Length positive
695 // Children: none
696 // Arguments: (t)
697 // ---------------------
698 // Conclusion: (or (and (= (str.len t) 0) (= t "")) (> (str.len t 0)))
699 STRING_LENGTH_POS,
700 // ======== Length non-empty
701 // Children: (P1:(not (= t "")))
702 // Arguments: none
703 // ---------------------
704 // Conclusion: (not (= (str.len t) 0))
705 STRING_LENGTH_NON_EMPTY,
706 //======================== Extended functions
707 // ======== Reduction
708 // Children: none
709 // Arguments: (t)
710 // ---------------------
711 // Conclusion: (and R (= t w))
712 // where w = strings::StringsPreprocess::reduce(t, R, ...).
713 // In other words, R is the reduction predicate for extended term t, and w is
714 // (witness ((z T)) (= z t))
715 // Notice that the free variables of R are w and the free variables of t.
716 STRING_REDUCTION,
717 // ======== Eager Reduction
718 // Children: none
719 // Arguments: (t, id?)
720 // ---------------------
721 // Conclusion: R
722 // where R = strings::TermRegistry::eagerReduce(t, id).
723 STRING_EAGER_REDUCTION,
724 //======================== Regular expressions
725 // ======== Regular expression intersection
726 // Children: (P:(str.in.re t R1), P:(str.in.re t R2))
727 // Arguments: none
728 // ---------------------
729 // Conclusion: (str.in.re t (re.inter R1 R2)).
730 RE_INTER,
731 // ======== Regular expression unfold positive
732 // Children: (P:(str.in.re t R))
733 // Arguments: none
734 // ---------------------
735 // Conclusion:(RegExpOpr::reduceRegExpPos((str.in.re t R))),
736 // corresponding to the one-step unfolding of the premise.
737 RE_UNFOLD_POS,
738 // ======== Regular expression unfold negative
739 // Children: (P:(not (str.in.re t R)))
740 // Arguments: none
741 // ---------------------
742 // Conclusion:(RegExpOpr::reduceRegExpNeg((not (str.in.re t R)))),
743 // corresponding to the one-step unfolding of the premise.
744 RE_UNFOLD_NEG,
745 // ======== Regular expression unfold negative concat fixed
746 // Children: (P:(not (str.in.re t R)))
747 // Arguments: none
748 // ---------------------
749 // Conclusion:(RegExpOpr::reduceRegExpNegConcatFixed((not (str.in.re t
750 // R)),L,i)) where RegExpOpr::getRegExpConcatFixed((not (str.in.re t R)), i) =
751 // L. corresponding to the one-step unfolding of the premise, optimized for
752 // fixed length of component i of the regular expression concatenation R.
753 RE_UNFOLD_NEG_CONCAT_FIXED,
754 // ======== Regular expression elimination
755 // Children: (P:F)
756 // Arguments: none
757 // ---------------------
758 // Conclusion: R
759 // where R = strings::RegExpElimination::eliminate(F).
760 RE_ELIM,
761 //======================== Code points
762 // Children: none
763 // Arguments: (t, s)
764 // ---------------------
765 // Conclusion:(or (= (str.code t) (- 1))
766 // (not (= (str.code t) (str.code s)))
767 // (not (= t s)))
768 STRING_CODE_INJ,
769 //======================== Sequence unit
770 // Children: (P:(= (seq.unit x) (seq.unit y)))
771 // Arguments: none
772 // ---------------------
773 // Conclusion:(= x y)
774 // Also applies to the case where (seq.unit y) is a constant sequence
775 // of length one.
776 STRING_SEQ_UNIT_INJ,
777 // ======== String Trust
778 // Children: none
779 // Arguments: (Q)
780 // ---------------------
781 // Conclusion: (Q)
782 STRING_TRUST,
783
784 //================================================= Arithmetic rules
785 // ======== Adding Inequalities
786 // Note: an ArithLiteral is a term of the form (>< poly const)
787 // where
788 // >< is >=, >, ==, <, <=, or not(== ...).
789 // poly is a polynomial
790 // const is a rational constant
791
792 // Children: (P1:l1, ..., Pn:ln)
793 // where each li is an ArithLiteral
794 // not(= ...) is dis-allowed!
795 //
796 // Arguments: (k1, ..., kn), non-zero reals
797 // ---------------------
798 // Conclusion: (>< (* k t1) (* k t2))
799 // where >< is the fusion of the combination of the ><i, (flipping each it
800 // its ki is negative). >< is always one of <, <=
801 // NB: this implies that lower bounds must have negative ki,
802 // and upper bounds must have positive ki.
803 // t1 is the sum of the polynomials.
804 // t2 is the sum of the constants.
805 ARITH_SCALE_SUM_UPPER_BOUNDS,
806
807 // ======== Tightening Strict Integer Upper Bounds
808 // Children: (P:(< i c))
809 // where i has integer type.
810 // Arguments: none
811 // ---------------------
812 // Conclusion: (<= i greatestIntLessThan(c)})
813 INT_TIGHT_UB,
814
815 // ======== Tightening Strict Integer Lower Bounds
816 // Children: (P:(> i c))
817 // where i has integer type.
818 // Arguments: none
819 // ---------------------
820 // Conclusion: (>= i leastIntGreaterThan(c)})
821 INT_TIGHT_LB,
822
823 // ======== Trichotomy of the reals
824 // Children: (A B)
825 // Arguments: (C)
826 // ---------------------
827 // Conclusion: (C),
828 // where (not A) (not B) and C
829 // are (> x c) (< x c) and (= x c)
830 // in some order
831 // note that "not" here denotes arithmetic negation, flipping
832 // >= to <, etc.
833 ARITH_TRICHOTOMY,
834
835 // ======== Arithmetic operator elimination
836 // Children: none
837 // Arguments: (t)
838 // ---------------------
839 // Conclusion: arith::OperatorElim::getAxiomFor(t)
840 ARITH_OP_ELIM_AXIOM,
841
842 // ======== Int Trust
843 // Children: (P1 ... Pn)
844 // Arguments: (Q)
845 // ---------------------
846 // Conclusion: (Q)
847 INT_TRUST,
848
849 //================================================= Unknown rule
850 UNKNOWN,
851 };
852
853 /**
854 * Converts a proof rule to a string. Note: This function is also used in
855 * `safe_print()`. Changing this function name or signature will result in
856 * `safe_print()` printing "<unsupported>" instead of the proper strings for
857 * the enum values.
858 *
859 * @param id The proof rule
860 * @return The name of the proof rule
861 */
862 const char* toString(PfRule id);
863
864 /**
865 * Writes a proof rule name to a stream.
866 *
867 * @param out The stream to write to
868 * @param id The proof rule to write to the stream
869 * @return The stream
870 */
871 std::ostream& operator<<(std::ostream& out, PfRule id);
872
873 /** Hash function for proof rules */
874 struct PfRuleHashFunction
875 {
876 size_t operator()(PfRule id) const;
877 }; /* struct PfRuleHashFunction */
878
879 } // namespace CVC4
880
881 #endif /* CVC4__EXPR__PROOF_RULE_H */