Enum term_rewriting::Context[][src]

pub enum Context {
    Hole,
    Variable(Variable),
    Application {
        op: Operator,
        args: Vec<Context>,
    },
}

A first-order context: a Term that may have Holes; a sort of Term template.

Variants

An empty place in the Context.

Examples

// How to construct a hole manually
let h = Context::Hole;

A concrete but unspecified Context (e.g. x, y)

Examples

let mut sig = Signature::default();

// How to construct a Context Variable manually
let v = sig.new_var(Some("x_".to_string()));
let var = Context::Variable(v);

An Operator applied to zero or more Contexts (e.g. (f(x, y), g())

Examples

let mut sig = Signature::default();
// How to construct a Context Application manually
let a = sig.new_op(0, Some("A".to_string()));
let app = Context::Application{ op: a, args: vec![] };

Fields of Application

Methods

impl Context
[src]

A serialized representation of the Context.

Examples


let mut sig = Signature::default();

let h = Context::Hole;
assert_eq!(h.display(&sig), "[!]".to_string());

let var = sig.new_var(Some("y".to_string()));
let context_var = Context::Variable(var);
assert_eq!(context_var.display(&sig), "y_".to_string());

let op = sig.new_op(0,Some("S".to_string()));
let args = vec![];
let context_app = Context::Application {op, args};
assert_eq!(context_app.display(&sig), "S".to_string());

let var = sig.new_var(Some("x".to_string()));
let a = sig.new_op(2, Some("A".to_string()));
let example_context = Context::Application {
    op: a,
    args: vec![Context::Hole, Context::Variable(var)],
};
assert_eq!(example_context.display(&sig), "A([!] x_)".to_string());

A human-readable serialization of the Context.

Every Atom used in self.

Every Variable used in self.

Every Operator used in self.

A list of the Places in self that are holes.

The head of the Context.

The args of the Context.

Every subcontext and its place, starting with the original context itself.

The number of distinct Places in self.

Get the subcontext at the given Place, or None if the place does not exist.

Create a copy of self where the Context at the given Place has been replaced with subcontext.

Translate self into a Term, if possible.

Trait Implementations

impl Debug for Context
[src]

Formats the value using the given formatter. Read more

impl PartialEq for Context
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for Context
[src]

impl Hash for Context
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl Clone for Context
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl From<Term> for Context
[src]

Performs the conversion.

Auto Trait Implementations

impl Send for Context

impl Sync for Context