Enum biodivine_lib_param_bn::FnUpdate
source · [−]pub enum FnUpdate {
Const(bool),
Var(VariableId),
Param(ParameterId, Vec<VariableId>),
Not(Box<FnUpdate>),
Binary(BinaryOp, Box<FnUpdate>, Box<FnUpdate>),
}
Expand description
A Boolean update function formula which references
Variables
and Parameters
of a BooleanNetwork
.
An update function specifies the evolution rules for one specific Variable
of a
BooleanNetwork
. The arguments used in the function must be the same as specified
by the RegulatoryGraph
of the network.
Variants
Const(bool)
A true/false constant.
Var(VariableId)
References a network variable.
Param(ParameterId, Vec<VariableId>)
References a network parameter (uninterpreted function).
The variable list are the arguments of the function invocation.
Not(Box<FnUpdate>)
Negation.
Binary(BinaryOp, Box<FnUpdate>, Box<FnUpdate>)
Binary boolean operation.
Implementations
sourceimpl FnUpdate
impl FnUpdate
sourcepub(crate) fn symbolic_eval_true(
&self,
state: IdState,
encoder: &BddParameterEncoder
) -> BddParams
pub(crate) fn symbolic_eval_true(
&self,
state: IdState,
encoder: &BddParameterEncoder
) -> BddParams
(internal) Evaluate this FnUpdate
into symbolic BddParams
that represent all parameter
valuations for which this function evaluates to true
.
pub(super) fn _symbolic_eval(
&self,
state: IdState,
encoder: &BddParameterEncoder
) -> Bdd
sourceimpl FnUpdate
impl FnUpdate
sourcepub fn try_from_expression(
expression: BooleanExpression,
graph: &RegulatoryGraph
) -> Option<FnUpdate>
pub fn try_from_expression(
expression: BooleanExpression,
graph: &RegulatoryGraph
) -> Option<FnUpdate>
Convert a BooleanExpression
to a FnUpdate
, using RegulatoryGraph
to resolve variable
names.
sourceimpl FnUpdate
impl FnUpdate
Constructor and destructor utility methods. These mainly avoid unnecessary boxing and exhaustive pattern matching when not necessary.
sourcepub fn mk_var(id: VariableId) -> FnUpdate
pub fn mk_var(id: VariableId) -> FnUpdate
Create an x
formula where x
is a Boolean variable.
sourcepub fn mk_param(id: ParameterId, args: &[VariableId]) -> FnUpdate
pub fn mk_param(id: ParameterId, args: &[VariableId]) -> FnUpdate
Create a p(x_1, ..., x_k)
formula where p
is a parameter function and x_1
through
x_k
are its arguments.
sourcepub fn mk_not(inner: FnUpdate) -> FnUpdate
pub fn mk_not(inner: FnUpdate) -> FnUpdate
Create a !phi
formula, where phi
is an inner FnUpdate
.
sourcepub fn mk_binary(op: BinaryOp, left: FnUpdate, right: FnUpdate) -> FnUpdate
pub fn mk_binary(op: BinaryOp, left: FnUpdate, right: FnUpdate) -> FnUpdate
Create a phi 'op' psi
where phi
and psi
are arguments of op
operator.
sourcepub fn as_var(&self) -> Option<VariableId>
pub fn as_var(&self) -> Option<VariableId>
If Var
, return the id, otherwise return None
.
sourcepub fn as_param(&self) -> Option<(ParameterId, &[VariableId])>
pub fn as_param(&self) -> Option<(ParameterId, &[VariableId])>
If Param
, return the id and args, otherwise return None
.
sourceimpl FnUpdate
impl FnUpdate
Other utility methods.
sourcepub fn collect_arguments(&self) -> Vec<VariableId>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn collect_arguments(&self) -> Vec<VariableId>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Return a sorted vector of all variables that are actually used as inputs in this function.
sourcepub fn collect_parameters(&self) -> Vec<ParameterId>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn collect_parameters(&self) -> Vec<ParameterId>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Return a sorted vector of all parameters (i.e. uninterpreted functions) that are used in this update function.
sourcepub fn to_string(&self, context: &BooleanNetwork) -> String
pub fn to_string(&self, context: &BooleanNetwork) -> String
Convert this update function to a string, taking names from the provided BooleanNetwork
.
sourcepub fn evaluate(&self, values: &HashMap<VariableId, bool>) -> Option<bool>
pub fn evaluate(&self, values: &HashMap<VariableId, bool>) -> Option<bool>
If possible, evaluate this function using the given network variable valuation.
Note that this only works when the function output does not depend on parameters, and
all necessary variable values are part of the valuation. Otherwise, the function
returns None
, as the value cannot be determined.
However, note that in some cases, even a partially specified function can be evaluated.
For example, A & f(X, Y)
is false whenever A = false
, regardless of uninterpreted
function f
. In such cases, this method may still output the correct result.
In other words, the meaning of this method should be interpreted as “if it is possible
to unambiguously evaluate this function using the provided valuation, do it; otherwise
return None
”.
sourcepub fn is_specialisation_of(&self, other: &FnUpdate) -> bool
pub fn is_specialisation_of(&self, other: &FnUpdate) -> bool
Test that this update function is a syntactic specialisation of the provided FnUpdate
.
Syntactic specialisation is a function that has the same abstract syntax tree, except that some occurrences of parameters can be substituted for more concrete Boolean functions.
Note that this is not entirely bulletproof, as it does not check for usage of multiple parameters within the same function, which could influence the semantics of the main function, but does not influence the specialisation.
sourcepub fn walk_postorder<F>(&self, action: &mut F) where
F: FnMut(&FnUpdate),
pub fn walk_postorder<F>(&self, action: &mut F) where
F: FnMut(&FnUpdate),
Allows us to iterate through all nodes of the abstract syntax tree of this function in post-order.
Note that this is a preliminary version of the API. A more robust implementation should provide a standard iterator interface.
sourcepub fn substitute(
&self,
vars: &[VariableId],
params: &[ParameterId]
) -> FnUpdate
pub fn substitute(
&self,
vars: &[VariableId],
params: &[ParameterId]
) -> FnUpdate
Create a copy of this function which replaces every occurrence of every
VariableId
with a new one supplied by the provided vector (original VariableId
is the index into the vector). Similarly replaces every ParameterId
.
Trait Implementations
impl Eq for FnUpdate
impl StructuralEq for FnUpdate
impl StructuralPartialEq for FnUpdate
Auto Trait Implementations
impl RefUnwindSafe for FnUpdate
impl Send for FnUpdate
impl Sync for FnUpdate
impl Unpin for FnUpdate
impl UnwindSafe for FnUpdate
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more