Struct biodivine_sketchbook::sketchbook::model::UninterpretedFn
source · pub struct UninterpretedFn {
name: String,
annotation: String,
arguments: Vec<FnArgument>,
tree: Option<FnTree>,
expression: String,
}
Expand description
An uninterpreted function of a partially specified model.
Field arguments
hold information regarding properties of the function
with respect to each of its arguments (in order). It also tracks the arity.
You can leave the function completely unspecified, or you can add an
“partial expression”. Field tree
holds the parsed version of that formula,
while expression
tracks the original formula.
Fields§
§name: String
§annotation: String
§arguments: Vec<FnArgument>
§tree: Option<FnTree>
§expression: String
Implementations§
source§impl UninterpretedFn
impl UninterpretedFn
Creating new UninterpretedFn
instances.
sourcepub fn new_without_constraints(
name: &str,
arity: usize,
) -> Result<UninterpretedFn, String>
pub fn new_without_constraints( name: &str, arity: usize, ) -> Result<UninterpretedFn, String>
Create new UninterpretedFn
object that has no constraints regarding monotonicity,
essentiality, or its expression. Annotation is empty.
sourcepub fn new(
name: &str,
annotation: &str,
expression: &str,
arguments: Vec<FnArgument>,
model: &ModelState,
own_id: &UninterpretedFnId,
) -> Result<UninterpretedFn, String>
pub fn new( name: &str, annotation: &str, expression: &str, arguments: Vec<FnArgument>, model: &ModelState, own_id: &UninterpretedFnId, ) -> Result<UninterpretedFn, String>
Create new UninterpretedFn
instance given all its raw components.
The model and function’s ID are used for validity check during argument parsing.
sourcepub fn with_new_expression(
original_fn: UninterpretedFn,
new_expression: &str,
context: &ModelState,
own_id: &UninterpretedFnId,
) -> Result<UninterpretedFn, String>
pub fn with_new_expression( original_fn: UninterpretedFn, new_expression: &str, context: &ModelState, own_id: &UninterpretedFnId, ) -> Result<UninterpretedFn, String>
Create uninterpreted function using another one as a template, but changing the expression. The provided original function object is consumed.
sourcepub fn with_substituted_fn_symbol(
original_fn: UninterpretedFn,
old_id: &UninterpretedFnId,
new_id: &UninterpretedFnId,
context: &ModelState,
) -> UninterpretedFn
pub fn with_substituted_fn_symbol( original_fn: UninterpretedFn, old_id: &UninterpretedFnId, new_id: &UninterpretedFnId, context: &ModelState, ) -> UninterpretedFn
Create uninterpreted function from another one, substituting all occurrences of a given function symbol in the syntactic tree. The provided original function object is consumed.
source§impl UninterpretedFn
impl UninterpretedFn
Editing UninterpretedFn
instances.
sourcepub fn set_annotation(&mut self, annotation: &str)
pub fn set_annotation(&mut self, annotation: &str)
Change annotation of this uninterpreted fn.
sourcepub fn set_arity(&mut self, new_arity: usize) -> Result<(), String>
pub fn set_arity(&mut self, new_arity: usize) -> Result<(), String>
Change arity of this uninterpreted fn.
If arity is made larger, default arguments (without monotonicity/essentiality constraints) are added. If arity is made smaller, last arguments are dropped. These must not be used in function’s expression.
sourcepub fn drop_last_argument(&mut self) -> Result<(), String>
pub fn drop_last_argument(&mut self) -> Result<(), String>
Drop the last argument of the function, essentially decrementing the arity of this uninterpreted fn. The last argument must not be used in function’s expression.
sourcepub fn add_argument(
&mut self,
monotonicity: Monotonicity,
essentiality: Essentiality,
)
pub fn add_argument( &mut self, monotonicity: Monotonicity, essentiality: Essentiality, )
Add an argument with specified monotonicity/essentiality. Argument is added at the end of the current argument list.
sourcepub fn add_default_argument(&mut self)
pub fn add_default_argument(&mut self)
Add default argument (with unknown monotonicity/essentiality) for this function. Argument is added at the end of the current argument list.
sourcepub fn set_fn_expression(
&mut self,
new_expression: &str,
model: &ModelState,
own_id: &UninterpretedFnId,
) -> Result<(), String>
pub fn set_fn_expression( &mut self, new_expression: &str, model: &ModelState, own_id: &UninterpretedFnId, ) -> Result<(), String>
Set the function’s expression to a given string.
model
is used to provide context regarding valid IDs.
We also need ID of this uninterpreted function to ensure that the expression is not defined
recursively, i.e., to check that expression of function f
does not contain f
inside.
sourcepub fn set_argument(
&mut self,
index: usize,
argument: FnArgument,
) -> Result<(), String>
pub fn set_argument( &mut self, index: usize, argument: FnArgument, ) -> Result<(), String>
Set properties of an argument with given index
(starting from 0).
sourcepub fn set_essential(
&mut self,
index: usize,
essential: Essentiality,
) -> Result<(), String>
pub fn set_essential( &mut self, index: usize, essential: Essentiality, ) -> Result<(), String>
Set Essentiality
of argument with given index
(starting from 0).
sourcepub fn set_monotonic(
&mut self,
index: usize,
monotone: Monotonicity,
) -> Result<(), String>
pub fn set_monotonic( &mut self, index: usize, monotone: Monotonicity, ) -> Result<(), String>
Set Monotonicity
of argument with given index
(starting from 0).
sourcepub fn set_all_arguments(
&mut self,
argument_list: Vec<FnArgument>,
) -> Result<(), String>
pub fn set_all_arguments( &mut self, argument_list: Vec<FnArgument>, ) -> Result<(), String>
Set the properties for all arguments (essentially replacing the current version). The number of arguments must stay the same, not changing arity.
sourcepub fn substitute_fn_symbol(
&mut self,
old_id: &UninterpretedFnId,
new_id: &UninterpretedFnId,
context: &ModelState,
)
pub fn substitute_fn_symbol( &mut self, old_id: &UninterpretedFnId, new_id: &UninterpretedFnId, context: &ModelState, )
Substitute all occurrences of a given function symbol in the syntactic tree.
source§impl UninterpretedFn
impl UninterpretedFn
Observing UninterpretedFn
instances.
sourcepub fn get_annotation(&self) -> &str
pub fn get_annotation(&self) -> &str
Annotation of this uninterpreted fn.
sourcefn get_highest_var_idx_in_expression(&self) -> Option<usize>
fn get_highest_var_idx_in_expression(&self) -> Option<usize>
Get highest index of a variable that is actually used in the function’s expression. This number might be lower than function’s actual arity.
sourcepub fn get_fn_expression(&self) -> &str
pub fn get_fn_expression(&self) -> &str
Get function’s expression.
sourcepub fn get_argument(&self, index: usize) -> &FnArgument
pub fn get_argument(&self, index: usize) -> &FnArgument
Get function’s argument (FnArgument
object) on given index
(starting from 0).
sourcepub fn get_essential(&self, index: usize) -> &Essentiality
pub fn get_essential(&self, index: usize) -> &Essentiality
Get Essentiality
of argument with given index
(starting from 0).
sourcepub fn get_monotonic(&self, index: usize) -> &Monotonicity
pub fn get_monotonic(&self, index: usize) -> &Monotonicity
Get Monotonicity
of argument with given index
(starting from 0).
sourcepub fn get_all_arguments(&self) -> &Vec<FnArgument>
pub fn get_all_arguments(&self) -> &Vec<FnArgument>
Get list of all ordered arguments (FnArgument
objects) of this function.
sourcepub fn collect_variables(&self) -> HashSet<VarId>
pub fn collect_variables(&self) -> HashSet<VarId>
Return a set of all variables that are actually used as inputs in this function.
sourcepub fn collect_fn_symbols(&self) -> HashSet<UninterpretedFnId>
pub fn collect_fn_symbols(&self) -> HashSet<UninterpretedFnId>
Return a set of all uninterpreted fns that are actually used in this function.
Trait Implementations§
source§impl Clone for UninterpretedFn
impl Clone for UninterpretedFn
source§fn clone(&self) -> UninterpretedFn
fn clone(&self) -> UninterpretedFn
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for UninterpretedFn
impl Debug for UninterpretedFn
source§impl<'de> Deserialize<'de> for UninterpretedFn
impl<'de> Deserialize<'de> for UninterpretedFn
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Display for UninterpretedFn
impl Display for UninterpretedFn
source§impl PartialEq for UninterpretedFn
impl PartialEq for UninterpretedFn
source§impl Serialize for UninterpretedFn
impl Serialize for UninterpretedFn
impl Eq for UninterpretedFn
impl StructuralPartialEq for UninterpretedFn
Auto Trait Implementations§
impl Freeze for UninterpretedFn
impl RefUnwindSafe for UninterpretedFn
impl Send for UninterpretedFn
impl Sync for UninterpretedFn
impl Unpin for UninterpretedFn
impl UnwindSafe for UninterpretedFn
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<'de, D, R> CommandArg<'de, R> for Dwhere
D: Deserialize<'de>,
R: Runtime,
impl<'de, D, R> CommandArg<'de, R> for Dwhere
D: Deserialize<'de>,
R: Runtime,
§fn from_command(command: CommandItem<'de, R>) -> Result<D, InvokeError>
fn from_command(command: CommandItem<'de, R>) -> Result<D, InvokeError>
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.