@@ -364,42 +364,52 @@ sequence_matchest instantiate_sequence(
364
364
365
365
return result;
366
366
}
367
- else if (expr.id () == ID_sva_sequence_consecutive_repetition ) // [*...]
367
+ else if (expr.id () == ID_sva_sequence_repetition_star ) // [*...]
368
368
{
369
- // x[*n] is syntactic sugar for x ##1 ... ##1 x, with n repetitions
370
- auto &repetition = to_sva_sequence_consecutive_repetition_expr (expr);
371
- return instantiate_sequence (
372
- repetition.lower (), semantics, t, no_timeframes);
373
- }
374
- else if (
375
- expr.id () == ID_sva_sequence_repetition_plus ||
376
- expr.id () == ID_sva_sequence_repetition_star)
377
- {
378
- // x[+] and x[*]
379
- auto &op = to_unary_expr (expr).op ();
369
+ auto &repetition = to_sva_sequence_repetition_star_expr (expr);
370
+ if (repetition.is_unbounded () && repetition.repetitions_given ())
371
+ {
372
+ // [*x:$]
373
+ auto from = numeric_cast_v<mp_integer>(repetition.from ());
374
+ auto &op = repetition.op ();
380
375
381
- // Is x a sequence or a state predicate?
382
- if (is_SVA_sequence_operator (op))
383
- PRECONDITION (false ); // no support
376
+ // Is op a sequence or a state predicate?
377
+ if (is_SVA_sequence_operator (op))
378
+ PRECONDITION (false ); // no support
384
379
385
- sequence_matchest result;
380
+ sequence_matchest result;
386
381
387
- // we incrementally add conjuncts to the condition
388
- exprt::operandst conjuncts;
382
+ // we incrementally add conjuncts to the condition
383
+ exprt::operandst conjuncts;
389
384
390
- for (mp_integer u = t; u < no_timeframes; ++u)
391
- {
392
- // does x hold in state u?
393
- auto cond_u = instantiate (op, u, no_timeframes);
394
- conjuncts.push_back (cond_u);
395
- result.push_back ({u, conjunction (conjuncts)});
396
- }
385
+ for (mp_integer u = t; u < no_timeframes; ++u)
386
+ {
387
+ // does op hold in timeframe u?
388
+ auto cond_u = instantiate (op, u, no_timeframes);
389
+ conjuncts.push_back (cond_u);
397
390
398
- // In addition to the above, x[*] allows an empty match.
399
- if (expr. id () == ID_sva_sequence_repetition_star)
400
- result. push_back ({t, true_exprt{}});
391
+ if (conjuncts. size () >= from)
392
+ result. push_back ({u, conjunction (conjuncts)});
393
+ }
401
394
402
- return result;
395
+ // Empty match allowed?
396
+ if (from == 0 )
397
+ result.push_back ({t, true_exprt{}});
398
+
399
+ return result;
400
+ }
401
+ else
402
+ {
403
+ // [*], [*n], [*x:y]
404
+ return instantiate_sequence (
405
+ repetition.lower (), semantics, t, no_timeframes);
406
+ }
407
+ }
408
+ else if (expr.id () == ID_sva_sequence_repetition_plus) // [+]
409
+ {
410
+ auto &repetition = to_sva_sequence_repetition_plus_expr (expr);
411
+ return instantiate_sequence (
412
+ repetition.lower (), semantics, t, no_timeframes);
403
413
}
404
414
else if (expr.id () == ID_sva_sequence_goto_repetition) // [->...]
405
415
{
0 commit comments