diff --git a/src/analyze/annot.rs b/src/analyze/annot.rs
index b246df43..7a0342dd 100644
--- a/src/analyze/annot.rs
+++ b/src/analyze/annot.rs
@@ -177,6 +177,14 @@ pub fn seq_push_path() -> [Symbol; 3] {
]
}
+pub fn seq_subsequence_path() -> [Symbol; 3] {
+ [
+ Symbol::intern("thrust"),
+ Symbol::intern("def"),
+ Symbol::intern("seq_subsequence"),
+ ]
+}
+
pub fn seq_concat_path() -> [Symbol; 3] {
[
Symbol::intern("thrust"),
diff --git a/src/analyze/annot_fn.rs b/src/analyze/annot_fn.rs
index f817712c..4769a91f 100644
--- a/src/analyze/annot_fn.rs
+++ b/src/analyze/annot_fn.rs
@@ -717,6 +717,21 @@ impl<'a, 'tcx> AnnotFnTranslator<'a, 'tcx> {
new_arr, offset, new_len,
]));
}
+ if Some(def_id) == self.def_ids.seq_subsequence() {
+ assert_eq!(args.len(), 2, "Seq::subsequence takes exactly 2 arguments");
+ let t = self.to_term(receiver);
+ let start = self.to_term(&args[0]);
+ let end = self.to_term(&args[1]);
+ let arr = t.clone().tuple_proj(0);
+ let offset = t.tuple_proj(1);
+ // A subsequence shares the underlying array, advances the offset by
+ // `start`, and sets the length to `end - start`.
+ return FormulaOrTerm::Term(chc::Term::tuple(vec![
+ arr,
+ offset.add(start.clone()),
+ end.sub(start),
+ ]));
+ }
if Some(def_id) == self.def_ids.seq_concat() {
assert_eq!(args.len(), 1, "Seq::concat takes exactly 1 argument");
let elem_sort = self.adt_arg_type_at(receiver, 0).to_sort();
diff --git a/src/analyze/did_cache.rs b/src/analyze/did_cache.rs
index 4dbcf110..78b35fb5 100644
--- a/src/analyze/did_cache.rs
+++ b/src/analyze/did_cache.rs
@@ -29,6 +29,7 @@ struct DefIds {
seq_singleton: OnceCell