summaryrefslogtreecommitdiff
path: root/src/proof/lfsc/lfsc_util.cpp
blob: 06bedb8952b01dae8be39b099a1244f0d6298002 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/******************************************************************************
 * Top contributors (to current version):
 *   Andrew Reynolds, Yoni Zohar
 *
 * This file is part of the cvc5 project.
 *
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
 * in the top-level source directory and their institutional affiliations.
 * All rights reserved.  See the file COPYING in the top-level source
 * directory for licensing information.
 * ****************************************************************************
 *
 * Utilities for LFSC proofs.
 */

#include "proof/lfsc/lfsc_util.h"

#include "proof/proof_checker.h"
#include "util/rational.h"

using namespace cvc5::kind;

namespace cvc5 {
namespace proof {

const char* toString(LfscRule id)
{
  switch (id)
  {
    case LfscRule::SCOPE: return "scope";
    case LfscRule::NEG_SYMM: return "neg_symm";
    case LfscRule::CONG: return "cong";
    case LfscRule::AND_INTRO1: return "and_intro1";
    case LfscRule::AND_INTRO2: return "and_intro2";
    case LfscRule::NOT_AND_REV: return "not_and_rev";
    case LfscRule::PROCESS_SCOPE: return "process_scope";
    case LfscRule::ARITH_SUM_UB: return "arith_sum_ub";
    case LfscRule::INSTANTIATE: return "instantiate";
    case LfscRule::SKOLEMIZE: return "skolemize";
    case LfscRule::LAMBDA: return "\\";
    case LfscRule::PLET: return "plet";
    default: return "?";
  }
}
std::ostream& operator<<(std::ostream& out, LfscRule id)
{
  out << toString(id);
  return out;
}

bool getLfscRule(Node n, LfscRule& lr)
{
  uint32_t id;
  if (ProofRuleChecker::getUInt32(n, id))
  {
    lr = static_cast<LfscRule>(id);
    return true;
  }
  return false;
}

LfscRule getLfscRule(Node n)
{
  LfscRule lr = LfscRule::UNKNOWN;
  getLfscRule(n, lr);
  return lr;
}

Node mkLfscRuleNode(LfscRule r)
{
  return NodeManager::currentNM()->mkConst(CONST_RATIONAL,
                                           Rational(static_cast<uint32_t>(r)));
}

bool LfscProofLetifyTraverseCallback::shouldTraverse(const ProofNode* pn)
{
  if (pn->getRule() == PfRule::SCOPE)
  {
    return false;
  }
  if (pn->getRule() != PfRule::LFSC_RULE)
  {
    return true;
  }
  // do not traverse under LFSC (lambda) scope
  LfscRule lr = getLfscRule(pn->getArguments()[0]);
  return lr != LfscRule::LAMBDA;
}

}  // namespace proof
}  // namespace cvc5
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback