Struct term_rewriting::Signature
[−]
[src]
pub struct Signature { /* fields omitted */ }
Records a universe of symbols.
Use Signature::default
for a blank signature, or Signature::new
to initialize a
signature with given operators.
Methods
impl Signature
[src]
pub fn new(
operator_spec: Vec<(u32, Option<String>)>
) -> (Signature, Vec<Operator>)
[src]
operator_spec: Vec<(u32, Option<String>)>
) -> (Signature, Vec<Operator>)
Construct a signature with the given operators.
Each operator is specified in the form of (arity, Some(name))
or
(arity, None)
, where arity
is the number of arguments a term takes
(for example, an arity
of 0 gives a "constant" operator). A name
for
the operator is unnecessary, but may be supplied for more readable
formatting.
The returned vector of Operator
s corresponds to the supplied spec.
pub fn operators(&self) -> Vec<Operator>
[src]
Returns every Operator
known to the signature, in the order they were created.
pub fn variables(&self) -> Vec<Variable>
[src]
Returns every Variable
known to the signature, in the order they were created.
pub fn new_op(&mut self, arity: u32, name: Option<String>) -> Operator
[src]
Create a new Operator
distinct from all existing operators.
pub fn new_var(&mut self, name: Option<String>) -> Variable
[src]
Create a new Variable
distinct from all existing variables.
pub fn merge(
&mut self,
other: Signature,
strategy: MergeStrategy
) -> SignatureChange
[src]
&mut self,
other: Signature,
strategy: MergeStrategy
) -> SignatureChange
Merge two signatures. All terms, contexts, rules, and TRSs associated
with the other
signature should be reified
using methods provided
by the returned SignatureChange
.
Examples
let (mut sig1, _ops) = Signature::new(vec![ (2, Some(".".to_string())), (0, Some("S".to_string())), (0, Some("K".to_string())), ]); let mut sig2 = sig1.clone(); let s1 = "S K K"; let term = parse_term(&mut sig1, s1).unwrap(); let s2 = "S x_ y_ z_ = (x_ z_) (y_ z_);"; let trs = parse_trs(&mut sig2, s2).unwrap(); let sigchange = sig1.merge(sig2, MergeStrategy::SameOperators); // we only reify terms/rules/TRSs associated with sig2 let trs = sigchange.reify_trs(trs); // now term and rule both exist with symbols according to sig1.
Trait Implementations
impl Clone for Signature
[src]
fn clone(&self) -> Signature
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Signature
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more