1
1
use super :: {
2
- assert_clause_len, assert_eq, assert_num_premises, assert_polyeq , get_premise_term ,
3
- CheckerError , RuleArgs , RuleResult ,
2
+ assert_clause_len, assert_eq, assert_num_premises, get_premise_term , CheckerError , RuleArgs ,
3
+ RuleResult ,
4
4
} ;
5
5
use crate :: { ast:: * , checker:: rules:: assert_operation_len} ;
6
6
@@ -258,7 +258,22 @@ pub fn not_ite2(RuleArgs { conclusion, premises, .. }: RuleArgs) -> RuleResult {
258
258
assert_eq ( phi_2, conclusion[ 1 ] . remove_negation_err ( ) ?)
259
259
}
260
260
261
- pub fn ite_intro ( RuleArgs { conclusion, polyeq_time, .. } : RuleArgs ) -> RuleResult {
261
+ pub fn ite_intro (
262
+ RuleArgs {
263
+ conclusion,
264
+ polyeq_time,
265
+ allow_polyeq,
266
+ ..
267
+ } : RuleArgs ,
268
+ ) -> RuleResult {
269
+ let mut compare = |a, b| -> bool {
270
+ if allow_polyeq {
271
+ polyeq ( a, b, polyeq_time)
272
+ } else {
273
+ a == b
274
+ }
275
+ } ;
276
+
262
277
assert_clause_len ( conclusion, 1 ) ?;
263
278
264
279
let ( root_term, right_side) = match_term_err ! ( ( = t u) = & conclusion[ 0 ] ) ?;
@@ -278,25 +293,25 @@ pub fn ite_intro(RuleArgs { conclusion, polyeq_time, .. }: RuleArgs) -> RuleResu
278
293
// ```
279
294
// For cases like this, we first check if `t` equals the right side term modulo reordering of
280
295
// equalities. If not, we unwrap the conjunction and continue checking the rule normally.
281
- if polyeq ( root_term, right_side, polyeq_time ) {
296
+ if compare ( root_term, right_side) {
282
297
return Ok ( ( ) ) ;
283
298
}
284
299
let us = match_term_err ! ( ( and ...) = right_side) ?;
285
300
286
301
// `us` must be a conjunction where the first term is the root term
287
- assert_polyeq ( & us[ 0 ] , root_term, polyeq_time) ?;
302
+ if !allow_polyeq || !compare ( & us[ 0 ] , root_term) {
303
+ assert_eq ( & us[ 0 ] , root_term) ?;
304
+ }
288
305
289
306
// The remaining terms in `us` should be of the correct form
290
307
for u_i in & us[ 1 ..] {
291
308
let ( cond, ( a, b) , ( c, d) ) = match_term_err ! ( ( ite cond ( = a b) ( = c d) ) = u_i) ?;
292
309
293
310
let mut is_valid = |r_1, s_1, r_2, s_2| {
294
311
// s_1 == s_2 == (ite cond r_1 r_2)
295
- if polyeq ( s_1, s_2, polyeq_time ) {
312
+ if compare ( s_1, s_2) {
296
313
if let Some ( ( a, b, c) ) = match_term ! ( ( ite a b c) = s_1) {
297
- return polyeq ( a, cond, polyeq_time)
298
- && polyeq ( b, r_1, polyeq_time)
299
- && polyeq ( c, r_2, polyeq_time) ;
314
+ return compare ( a, cond) && compare ( b, r_1) && compare ( c, r_2) ;
300
315
}
301
316
}
302
317
false
0 commit comments