pub trait Representation:
Send
+ Sync
+ Debug {
// Required methods
fn init(name: &Name, symtab: &SymbolTable) -> Option<Self>
where Self: Sized;
fn variable_name(&self) -> &Name;
fn value_down(
&self,
value: Literal,
) -> Result<BTreeMap<Name, Literal>, ApplicationError>;
fn value_up(
&self,
values: &BTreeMap<Name, Literal>,
) -> Result<Literal, ApplicationError>;
fn expression_down(
&self,
symtab: &SymbolTable,
) -> Result<BTreeMap<Name, Expression>, ApplicationError>;
fn declaration_down(&self) -> Result<Vec<DeclarationPtr>, ApplicationError>;
fn repr_name(&self) -> &str;
fn box_clone(&self) -> Box<dyn Representation>;
}Expand description
Encodes the two-way relationship between a non-atomic variable and multiple auxiliary variables.
For example, a 2x2 matrix X might be represented by a variable for each element X1_1 X1_2 X2_1 X2_2.
The Representation for X then allows us to set the value of the matrix, and takes care of
assigning the individual variables accordingly. Conversly, we can set the values of the elements, and
the Representation will return an assignment for the matrix as a whole.
Required Methods§
Sourcefn init(name: &Name, symtab: &SymbolTable) -> Option<Self>where
Self: Sized,
fn init(name: &Name, symtab: &SymbolTable) -> Option<Self>where
Self: Sized,
Creates a representation object for the given name.
Sourcefn variable_name(&self) -> &Name
fn variable_name(&self) -> &Name
The variable being represented.
Sourcefn value_down(
&self,
value: Literal,
) -> Result<BTreeMap<Name, Literal>, ApplicationError>
fn value_down( &self, value: Literal, ) -> Result<BTreeMap<Name, Literal>, ApplicationError>
Given an assignment for self, creates assignments for its representation variables.
Sourcefn value_up(
&self,
values: &BTreeMap<Name, Literal>,
) -> Result<Literal, ApplicationError>
fn value_up( &self, values: &BTreeMap<Name, Literal>, ) -> Result<Literal, ApplicationError>
Given assignments for its representation variables, creates an assignment for self.
Sourcefn expression_down(
&self,
symtab: &SymbolTable,
) -> Result<BTreeMap<Name, Expression>, ApplicationError>
fn expression_down( &self, symtab: &SymbolTable, ) -> Result<BTreeMap<Name, Expression>, ApplicationError>
Returns Expressions representing each representation variable.
Sourcefn declaration_down(&self) -> Result<Vec<DeclarationPtr>, ApplicationError>
fn declaration_down(&self) -> Result<Vec<DeclarationPtr>, ApplicationError>
Creates declarations for the representation variables of self.
Sourcefn box_clone(&self) -> Box<dyn Representation>
fn box_clone(&self) -> Box<dyn Representation>
Makes a clone of self into a Representation trait object.