@@ -42,13 +42,14 @@ class Rule final {
42
42
Term LHS;
43
43
Term RHS;
44
44
45
- // / Associated type introduction rules are 'permanent', meaning they cannot
46
- // / be deleted by homotopy reduction. This is because they do not correspond
47
- // / to generic requirements and are re-added when the rewrite system is
48
- // / built, so by leaving them in place we can find other redundancies
49
- // / instead.
45
+ // / A 'permanent' rule cannot be deleted by homotopy reduction. These
46
+ // / do not correspond to generic requirements and are re-added when the
47
+ // / rewrite system is built.
50
48
unsigned Permanent : 1 ;
51
49
50
+ // / An 'explicit' rule is a generic requirement written by the user.
51
+ unsigned Explicit : 1 ;
52
+
52
53
// / A 'simplified' rule was eliminated by simplifyRewriteSystem() if one of two
53
54
// / things happen:
54
55
// / - The rule's left hand side can be reduced via some other rule, in which
@@ -69,6 +70,7 @@ class Rule final {
69
70
Rule (Term lhs, Term rhs)
70
71
: LHS(lhs), RHS(rhs) {
71
72
Permanent = false ;
73
+ Explicit = false ;
72
74
Simplified = false ;
73
75
Redundant = false ;
74
76
}
@@ -84,36 +86,40 @@ class Rule final {
84
86
85
87
bool isProtocolRefinementRule () const ;
86
88
87
- // / See above for an explanation.
89
+ // / See above for an explanation of these predicates .
88
90
bool isPermanent () const {
89
91
return Permanent;
90
92
}
91
93
92
- // / See above for an explanation.
94
+ bool isExplicit () const {
95
+ return Explicit;
96
+ }
97
+
93
98
bool isSimplified () const {
94
99
return Simplified;
95
100
}
96
101
97
- // / See above for an explanation.
98
102
bool isRedundant () const {
99
103
return Redundant;
100
104
}
101
105
102
- // / Deletes the rule, which removes it from consideration in term
103
- // / simplification and completion. Deleted rules are simply marked as
104
- // / such instead of being physically removed from the rules vector
105
- // / in the rewrite system, to ensure that indices remain valid across
106
- // / deletion.
107
106
void markSimplified () {
108
107
assert (!Simplified);
109
108
Simplified = true ;
110
109
}
111
110
112
111
void markPermanent () {
113
- assert (!Permanent);
112
+ assert (!Explicit && !Permanent &&
113
+ " Permanent and explicit are mutually exclusive" );
114
114
Permanent = true ;
115
115
}
116
116
117
+ void markExplicit () {
118
+ assert (!Explicit && !Permanent &&
119
+ " Permanent and explicit are mutually exclusive" );
120
+ Explicit = true ;
121
+ }
122
+
117
123
void markRedundant () {
118
124
assert (!Redundant);
119
125
Redundant = true ;
@@ -255,6 +261,8 @@ class RewriteSystem final {
255
261
256
262
bool addPermanentRule (MutableTerm lhs, MutableTerm rhs);
257
263
264
+ bool addExplicitRule (MutableTerm lhs, MutableTerm rhs);
265
+
258
266
bool simplify (MutableTerm &term, RewritePath *path=nullptr ) const ;
259
267
260
268
void simplifySubstitutions (MutableTerm &term, RewritePath &path) const ;
0 commit comments