GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/quantifiers/ematching/trigger_term_info.cpp Lines: 42 42 100.0 %
Date: 2021-09-16 Branches: 101 132 76.5 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Morgan Deters, Yoni Zohar
4
 *
5
 * This file is part of the cvc5 project.
6
 *
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.
11
 * ****************************************************************************
12
 *
13
 * Implementation of trigger term info class.
14
 */
15
16
#include "theory/quantifiers/ematching/trigger_term_info.h"
17
18
#include "theory/quantifiers/term_util.h"
19
20
using namespace cvc5::kind;
21
22
namespace cvc5 {
23
namespace theory {
24
namespace quantifiers {
25
namespace inst {
26
27
91596
void TriggerTermInfo::init(Node q, Node n, int reqPol, Node reqPolEq)
28
{
29
91596
  if (d_fv.empty())
30
  {
31
91110
    quantifiers::TermUtil::computeInstConstContainsForQuant(q, n, d_fv);
32
  }
33
91596
  if (d_reqPol == 0)
34
  {
35
91478
    d_reqPol = reqPol;
36
91478
    d_reqPolEq = reqPolEq;
37
  }
38
  else
39
  {
40
    // determined a ground (dis)equality must hold or else q is a tautology?
41
  }
42
91596
  d_weight = getTriggerWeight(n);
43
91596
}
44
45
3415041
bool TriggerTermInfo::isAtomicTrigger(Node n)
46
{
47
3415041
  return isAtomicTriggerKind(n.getKind());
48
}
49
50
9583776
bool TriggerTermInfo::isAtomicTriggerKind(Kind k)
51
{
52
  // we use both APPLY_SELECTOR and APPLY_SELECTOR_TOTAL since this
53
  // method is used both for trigger selection and for ground term registration,
54
  // where these two things require those kinds respectively.
55
3741171
  return k == APPLY_UF || k == SELECT || k == STORE || k == APPLY_CONSTRUCTOR
56
2207143
         || k == APPLY_SELECTOR || k == APPLY_SELECTOR_TOTAL
57
2139684
         || k == APPLY_TESTER || k == UNION || k == INTERSECTION || k == SUBSET
58
2075171
         || k == SETMINUS || k == MEMBER || k == SINGLETON || k == SEP_PTO
59
2040094
         || k == BITVECTOR_TO_NAT || k == INT_TO_BITVECTOR || k == HO_APPLY
60
11603579
         || k == STRING_LENGTH || k == SEQ_NTH;
61
}
62
63
354798
bool TriggerTermInfo::isRelationalTrigger(Node n)
64
{
65
354798
  return isRelationalTriggerKind(n.getKind());
66
}
67
68
354798
bool TriggerTermInfo::isRelationalTriggerKind(Kind k)
69
{
70
354798
  return k == EQUAL || k == GEQ;
71
}
72
73
23444
bool TriggerTermInfo::isSimpleTrigger(Node n)
74
{
75
46888
  Node t = n.getKind() == NOT ? n[0] : n;
76
23444
  if (t.getKind() == EQUAL)
77
  {
78
2982
    if (!quantifiers::TermUtil::hasInstConstAttr(t[1]))
79
    {
80
2964
      t = t[0];
81
    }
82
  }
83
23444
  if (!isAtomicTrigger(t))
84
  {
85
82
    return false;
86
  }
87
59451
  for (const Node& tc : t)
88
  {
89
88002
    if (tc.getKind() != INST_CONSTANT
90
88002
        && quantifiers::TermUtil::hasInstConstAttr(tc))
91
    {
92
7912
      return false;
93
    }
94
  }
95
15450
  if (t.getKind() == HO_APPLY && t[0].getKind() == INST_CONSTANT)
96
  {
97
12
    return false;
98
  }
99
15438
  return true;
100
}
101
102
166999
int32_t TriggerTermInfo::getTriggerWeight(Node n)
103
{
104
166999
  if (n.getKind() == APPLY_UF)
105
  {
106
131265
    return 0;
107
  }
108
35734
  if (isAtomicTrigger(n))
109
  {
110
13139
    return 1;
111
  }
112
22595
  return 2;
113
}
114
115
}  // namespace inst
116
}  // namespace quantifiers
117
}  // namespace theory
118
29577
}  // namespace cvc5