Skip to content

Commit

Permalink
Add rare-list operator
Browse files Browse the repository at this point in the history
  • Loading branch information
bpandreotti committed Jan 23, 2024
1 parent edcba8c commit c9cc746
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions carcara/src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ pub enum Operator {
BvSGt,
BvSGe,
BvBbTerm,

// Misc.
/// The `rare-list` operator, used to represent RARE lists.
RareList,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
Expand Down Expand Up @@ -528,6 +532,8 @@ impl_str_conversion_traits!(Operator {
BvSGt: "bvsgt",
BvSGe: "bvsge",
BvBbTerm: "bbterm",

RareList: "rare-list",
});

/// A variable and an associated sort.
Expand Down Expand Up @@ -571,6 +577,9 @@ pub enum Sort {
///
/// The associated term is the BV width of this sort.
BitVec(Integer),

/// The sort of RARE lists.
RareList,
}

/// A quantifier, either `forall` or `exists`.
Expand Down
1 change: 1 addition & 0 deletions carcara/src/ast/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ impl PrimitivePool {
| Operator::ReKleeneCross
| Operator::ReOption
| Operator::ReRange => Sort::RegLan,
Operator::RareList => Sort::RareList,
},
Term::App(f, _) => {
match self.compute_sort(f).as_sort().unwrap() {
Expand Down
1 change: 1 addition & 0 deletions carcara/src/ast/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ impl fmt::Display for Sort {
Sort::RegLan => write!(f, "RegLan"),
Sort::Array(x, y) => write_s_expr(f, "Array", &[x, y]),
Sort::BitVec(w) => write!(f, "(_ BitVec {})", w),
Sort::RareList => unreachable!("RARE list sort should never be displayed"),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions carcara/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ impl<'a, R: BufRead> Parser<'a, R> {
}
SortError::assert_all_eq(&sorts)?;
}
Operator::RareList => SortError::assert_all_eq(&sorts)?,
}
Ok(self.pool.add(Term::Op(op, args)))
}
Expand Down

0 comments on commit c9cc746

Please sign in to comment.