@@ -221,11 +221,9 @@ mrProvable bool_tm =
221
221
(closedOpenTerm a)
222
222
ec <- instUVar nm ec_tp
223
223
liftSC4 genBVVecTerm n len a ec
224
- -- For pairs, recurse on both sides and combine the result as a pair
225
- (asPairType -> Just (tp1, tp2)) -> do
226
- e1 <- instUVar nm tp1
227
- e2 <- instUVar nm tp2
228
- liftSC2 scPairValue e1 e2
224
+ -- For tuples, recurse on all components and combine the result as a tuple
225
+ (asTupleType -> Just tps) ->
226
+ liftSC1 scTuple =<< traverse (instUVar nm) tps
229
227
-- Otherwise, create a global variable with the given name and type
230
228
tp' -> liftSC2 scFreshEC nm tp' >>= liftSC1 scExtCns
231
229
@@ -268,6 +266,12 @@ andTermInCtx (TermInCtx ctx1 t1) (TermInCtx ctx2 t2) =
268
266
t2' <- liftTermLike (length ctx2) (length ctx1) t2
269
267
TermInCtx (ctx1++ ctx2) <$> liftSC2 scAnd t1' t2'
270
268
269
+ -- | Conjoin a list of 'TermInCtx's, assuming they all have Boolean type.
270
+ allTermInCtx :: [TermInCtx ] -> MRM TermInCtx
271
+ allTermInCtx [] = TermInCtx [] <$> liftSC1 scBool True
272
+ allTermInCtx [x] = pure x
273
+ allTermInCtx (x : xs) = andTermInCtx x =<< allTermInCtx xs
274
+
271
275
-- | Extend the context of a 'TermInCtx' with additional universal variables
272
276
-- bound "outside" the 'TermInCtx'
273
277
extTermInCtx :: [(LocalName ,Term )] -> TermInCtx -> TermInCtx
@@ -358,15 +362,13 @@ mrProveEqH _ (asBoolType -> Just _) t1 t2 =
358
362
mrProveEqH _ (asIntegerType -> Just _) t1 t2 =
359
363
mrProveEqSimple (liftSC2 scIntEq) t1 t2
360
364
361
- -- For pair types, prove both the left and right projections are equal
362
- mrProveEqH var_map (asPairType -> Just (tpL, tpR)) t1 t2 =
363
- do t1L <- liftSC1 scPairLeft t1
364
- t2L <- liftSC1 scPairLeft t2
365
- t1R <- liftSC1 scPairRight t1
366
- t2R <- liftSC1 scPairRight t2
367
- condL <- mrProveEqH var_map tpL t1L t2L
368
- condR <- mrProveEqH var_map tpR t1R t2R
369
- andTermInCtx condL condR
365
+ -- For tuple types, prove all of the projections are equal
366
+ mrProveEqH var_map (asTupleType -> Just tps) t1 t2 =
367
+ do let idxs = [0 .. length tps - 1 ]
368
+ ts1 <- liftSC1 (\ sc t -> traverse (scTupleSelector sc t) idxs) t1
369
+ ts2 <- liftSC1 (\ sc t -> traverse (scTupleSelector sc t) idxs) t2
370
+ conds <- sequence $ zipWith3 (mrProveEqH var_map) tps ts1 ts2
371
+ allTermInCtx conds
370
372
371
373
-- For non-bitvector vector types, prove all projections are equal by
372
374
-- quantifying over a universal index variable and proving equality at that
0 commit comments