1 /********************* */
2 /*! \file trust_node.cpp
4 ** Top contributors (to current version):
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS
8 ** in the top-level source directory) and their institutional affiliations.
9 ** All rights reserved. See the file COPYING in the top-level source
10 ** directory for licensing information.\endverbatim
12 ** \brief Implementation of the trust node utility
15 #include "theory/trust_node.h"
17 #include "expr/proof_generator.h"
22 const char* toString(TrustNodeKind tnk
)
26 case TrustNodeKind::CONFLICT
: return "CONFLICT";
27 case TrustNodeKind::LEMMA
: return "LEMMA";
28 case TrustNodeKind::PROP_EXP
: return "PROP_EXP";
33 std::ostream
& operator<<(std::ostream
& out
, TrustNodeKind tnk
)
39 TrustNode
TrustNode::mkTrustConflict(Node conf
, ProofGenerator
* g
)
41 Node ckey
= getConflictProven(conf
);
42 // if a generator is provided, should confirm that it can prove it
43 Assert(g
== nullptr || g
->hasProofFor(ckey
));
44 return TrustNode(TrustNodeKind::CONFLICT
, ckey
, g
);
47 TrustNode
TrustNode::mkTrustLemma(Node lem
, ProofGenerator
* g
)
49 Node lkey
= getLemmaProven(lem
);
50 // if a generator is provided, should confirm that it can prove it
51 Assert(g
== nullptr || g
->hasProofFor(lkey
));
52 return TrustNode(TrustNodeKind::LEMMA
, lkey
, g
);
55 TrustNode
TrustNode::mkTrustPropExp(TNode lit
, Node exp
, ProofGenerator
* g
)
57 Node pekey
= getPropExpProven(lit
, exp
);
58 Assert(g
== nullptr || g
->hasProofFor(pekey
));
59 return TrustNode(TrustNodeKind::PROP_EXP
, pekey
, g
);
62 TrustNode
TrustNode::null()
64 return TrustNode(TrustNodeKind::INVALID
, Node::null());
67 TrustNode::TrustNode(TrustNodeKind tnk
, Node p
, ProofGenerator
* g
)
68 : d_tnk(tnk
), d_proven(p
), d_gen(g
)
70 // does not make sense to provide null node with generator
71 Assert(!d_proven
.isNull() || d_gen
== nullptr);
74 TrustNodeKind
TrustNode::getKind() const { return d_tnk
; }
76 Node
TrustNode::getNode() const
78 return d_tnk
== TrustNodeKind::LEMMA
? d_proven
: d_proven
[0];
81 Node
TrustNode::getProven() const { return d_proven
; }
82 ProofGenerator
* TrustNode::getGenerator() const { return d_gen
; }
84 bool TrustNode::isNull() const { return d_proven
.isNull(); }
86 Node
TrustNode::getConflictProven(Node conf
) { return conf
.notNode(); }
88 Node
TrustNode::getLemmaProven(Node lem
) { return lem
; }
90 Node
TrustNode::getPropExpProven(TNode lit
, Node exp
)
92 return NodeManager::currentNM()->mkNode(kind::IMPLIES
, exp
, lit
);
95 std::ostream
& operator<<(std::ostream
& out
, TrustNode n
)
97 out
<< "(trust " << n
.getNode() << ")";
101 } // namespace theory