pub enum FnTree {
Const(bool),
Var(VarId),
PlaceholderVar(VarId),
UninterpretedFn(UninterpretedFnId, Vec<FnTree>),
Not(Box<FnTree>),
Binary(BinaryOp, Box<FnTree>, Box<FnTree>),
}
Expand description
Syntactic tree of a partially defined Boolean function. This might specify an update function, or a partially defined uninterpreted fn.
Variants§
Const(bool)
A true/false constant.
Var(VarId)
References a network variable.
PlaceholderVar(VarId)
References a “placeholder network variable” that corresponds to an argument of an uninterpreted fn.
UninterpretedFn(UninterpretedFnId, Vec<FnTree>)
References a network parameter (uninterpreted function). The variable list are the arguments of the function invocation.
Not(Box<FnTree>)
Negation.
Binary(BinaryOp, Box<FnTree>, Box<FnTree>)
Binary Boolean operation.
Implementations§
source§impl FnTree
impl FnTree
sourcepub fn try_from_str(
expression: &str,
model: &ModelState,
is_uninterpreted: Option<(&UninterpretedFnId, &UninterpretedFn)>,
) -> Result<FnTree, String>
pub fn try_from_str( expression: &str, model: &ModelState, is_uninterpreted: Option<(&UninterpretedFnId, &UninterpretedFn)>, ) -> Result<FnTree, String>
Try to parse an update function from a string, taking IDs from the provided ModelState
.
is_uninterpreted
specifies whether the expression represents an uninterpreted function,
or an update function. This must be distinguished as update functions can contain network
variables, but uninterpreted functions only utilize “unnamed” variables var0
, var1
, …
sourcepub fn to_string(
&self,
model: &ModelState,
is_uninterpreted: Option<usize>,
) -> String
pub fn to_string( &self, model: &ModelState, is_uninterpreted: Option<usize>, ) -> String
Convert this update function to a string.
Currently, the transformation utilizes intermediate structs from [biodivine_lib_param_bn]
library, and thus model
is needed to provide context (regarding IDs).
sourcefn from_fn_update(
fn_update: FnUpdate,
model: &ModelState,
is_uninterpreted: Option<(&UninterpretedFnId, &UninterpretedFn)>,
) -> Result<FnTree, String>
fn from_fn_update( fn_update: FnUpdate, model: &ModelState, is_uninterpreted: Option<(&UninterpretedFnId, &UninterpretedFn)>, ) -> Result<FnTree, String>
Obtain the FnTree
from a similar FnUpdate
object of the [biodivine_lib_param_bn] library.
The provided model gives context for variable and parameter IDs.
sourcefn from_fn_update_recursive(
fn_update: FnUpdate,
model: &ModelState,
bn_context: &BooleanNetwork,
is_uninterpreted: Option<&UninterpretedFnId>,
) -> Result<FnTree, String>
fn from_fn_update_recursive( fn_update: FnUpdate, model: &ModelState, bn_context: &BooleanNetwork, is_uninterpreted: Option<&UninterpretedFnId>, ) -> Result<FnTree, String>
Recursively obtain the FnTree
from a similar FnUpdate
object of the [biodivine_lib_param_bn] library.
The provided model and BN give context for variable and parameter IDs.
sourcepub(crate) fn to_fn_update_recursive(
&self,
bn_context: &BooleanNetwork,
) -> FnUpdate
pub(crate) fn to_fn_update_recursive( &self, bn_context: &BooleanNetwork, ) -> FnUpdate
Recursively transform the FnTree
to a similar FnUpdate
object of the [biodivine_lib_param_bn] library.
The provided BN gives context for variable and parameter IDs.
sourcepub fn collect_variables(&self) -> HashSet<VarId>
pub fn collect_variables(&self) -> HashSet<VarId>
Return a set of all variables that are actually used in this function as arguments.
Both valid network variables
and placeholder variables
are collected (note that
these two variants can never happen to be in the same tree at the same time).
sourcepub fn collect_fn_symbols(&self) -> HashSet<UninterpretedFnId>
pub fn collect_fn_symbols(&self) -> HashSet<UninterpretedFnId>
Return a set of all uninterpreted functions (parameters) that are used in this function.
sourcepub fn substitute_var(&self, old_id: &VarId, new_id: &VarId) -> FnTree
pub fn substitute_var(&self, old_id: &VarId, new_id: &VarId) -> FnTree
Use this function as a template to create a new one, but substitute a given network variable’s ID with a new one.
This can only be used to substitute network variables
(that appear in update functions),
not placeholder variables (that appear in uninterpreted functions), since modifying the
latter does not make that much sense.
sourcepub fn substitute_fn_symbol(
&self,
old_id: &UninterpretedFnId,
new_id: &UninterpretedFnId,
) -> FnTree
pub fn substitute_fn_symbol( &self, old_id: &UninterpretedFnId, new_id: &UninterpretedFnId, ) -> FnTree
Use this function as a template to create a new one, but substitute a given uninterpreted function’s ID with a new one.
Trait Implementations§
source§impl<'de> Deserialize<'de> for FnTree
impl<'de> Deserialize<'de> for FnTree
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>,
impl Eq for FnTree
impl StructuralPartialEq for FnTree
Auto Trait Implementations§
impl Freeze for FnTree
impl RefUnwindSafe for FnTree
impl Send for FnTree
impl Sync for FnTree
impl Unpin for FnTree
impl UnwindSafe for FnTree
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.