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]
impl Signature
pub fn new(
operator_spec: Vec<(u32, Option<String>)>
) -> (Signature, Vec<Operator>)
[src]
pub fn new(
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.
Examples
// Constructs a new signature with the operators ".","S","K' from the vector let (mut sig,ops) = Signature:: new(vec![ (2, Some(".".to_string())), (0, Some("S".to_string())), (0, Some("K".to_string())), ]); let (mut sig2,ops2) = Signature:: new(vec![ (2, Some(".".to_string())), (0, Some("S".to_string())), (0, Some("K".to_string())), ]); let (mut sig3,ops3) = Signature:: new(vec![ (2, Some(".".to_string())), (0, Some("S".to_string())), ]); assert_eq!(sig,sig2); assert_ne!(sig,sig3);
pub fn operators(&self) -> Vec<Operator>
[src]
pub fn operators(&self) -> Vec<Operator>
Returns every Operator
known to the signature, in the order they were created.
Examples
// Constructs a new signature with the operators ".","S","K' from the vector let (mut sig,ops) = Signature:: new(vec![ (2, Some(".".to_string())), (0, Some("S".to_string())), (0, Some("K".to_string())), ]); // Returns the operators in the signature above let example_ops = sig.operators(); assert_eq!(ops,example_ops);
pub fn variables(&self) -> Vec<Variable>
[src]
pub fn variables(&self) -> Vec<Variable>
Returns every Variable
known to the signature, in the order they were created.
Examples
// Constructs a new signature with the variables ".","S","K' from the vector let (mut sig,ops) = Signature:: new(vec![ (2, Some(".".to_string())), (0, Some("S".to_string())), (0, Some("K".to_string())), ]); // Returns the variables in the signature above let vars = sig.variables(); let vars2 = sig.variables(); let newVar = sig.new_var(Some("A".to_string())); let vars3 = sig.variables(); assert_eq!(vars,vars2); assert_ne!(vars,vars3);
pub fn atoms(&self) -> Vec<Atom>
[src]
pub fn atoms(&self) -> Vec<Atom>
Returns every Atom
known to the signature.
pub fn new_op(&mut self, arity: u32, name: Option<String>) -> Operator
[src]
pub fn new_op(&mut self, arity: u32, name: Option<String>) -> Operator
Create a new Operator
distinct from all existing operators.
Examples
let mut sig = Signature::default(); let a = sig.new_op(1, Some(".".to_string())); let s = sig.new_op(2, Some("S".to_string())); let s2 = sig.new_op(2, Some("S".to_string())); assert_ne!(a,s); assert_ne!(a,s2); assert_ne!(s,s2);
pub fn new_var(&mut self, name: Option<String>) -> Variable
[src]
pub fn new_var(&mut self, name: Option<String>) -> Variable
Create a new Variable
distinct from all existing variables.
Examples
let mut sig = Signature::default(); let z = sig.new_var(Some("Z".to_string())); let z2 = sig.new_var(Some("Z".to_string())); assert_ne!(z,z2);
pub fn merge(
&mut self,
other: Signature,
strategy: MergeStrategy
) -> SignatureChange
[src]
pub fn merge(
&mut self,
other: Signature,
strategy: MergeStrategy
) -> SignatureChange
Merge two Signature
s. 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]
impl Clone for Signature
fn clone(&self) -> Signature
[src]
fn clone(&self) -> Signature
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for Signature
[src]
impl Debug for Signature
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Default for Signature
[src]
impl Default for Signature
Creates a new Signature without any Operators or Variables
Usage
let mut sig = Signature::default(); let (mut sig2,ops) = Signature::new(vec![]); let (mut sig3,ops) = Signature::new(vec![ (2, Some(".".to_string())), (0, Some("S".to_string())), (0, Some("K".to_string())), ]); assert_eq!(sig,sig2); assert_ne!(sig,sig3);
impl PartialEq for Signature
[src]
impl PartialEq for Signature
Compares two Signatures to test if they should be considered equal
Examples
let mut sig = Signature::default(); let mut sig2 = Signature::default(); assert!(sig.eq(&sig2));