pub fn new(spec: &RewriteSpecification, annotate: impl Fn(&Rule) -> M, apma: bool) -> SetAutomaton<M> {
// The initial state has a match goals for each pattern. For each pattern l there is a match goal
/// Derive transitions from a state given a head symbol. The resulting transition is returned as a tuple
/// The tuple consists of a vector of outputs and a set of destinations (which are sets of match goals).
/// We don't use the struct Transition as it requires that the destination is a full state, with name.
/// Since we don't yet know whether the state already exists we just return a set of match goals as 'state'.
// Computes the derivative containing the goals that are completed, unchanged and reduced
// If we are building an APMA we do not deepen the position or create a hypertransitions
destinations.push((ExplicitPosition::empty_pos(), GoalsOrInitial::Goals(new_match_goals)));
.any(|mo| mo.position == self.label && mo.pattern.data_function_symbol() != symbol.copy())
new_obligations.sort_unstable_by(|mo1, mo2| mo1.position.len().cmp(&mo2.position.len()));
fn add_symbol(function_symbol: DataFunctionSymbol, arity: usize, symbols: &mut HashMap<DataFunctionSymbol, usize>) {
/// Returns false iff this is a higher order term, of the shape t(t_0, ..., t_n), or an unknown term.
fn find_symbols(t: &DataExpressionRef<'_>, symbols: &mut HashMap<DataFunctionSymbol, usize>) {