pub enum RefinementPredicate {
Show 18 variants
Equal(f64),
NotEqual(f64),
GreaterThan(f64),
GreaterThanOrEqual(f64),
LessThan(f64),
LessThanOrEqual(f64),
Range {
min: f64,
max: f64,
},
RangeExclusive {
min: f64,
max: f64,
},
Modulo {
divisor: i64,
remainder: i64,
},
InSet(Vec<f64>),
NotInSet(Vec<f64>),
And(Vec<RefinementPredicate>),
Or(Vec<RefinementPredicate>),
Not(Box<RefinementPredicate>),
Custom {
name: String,
description: String,
checker: Arc<dyn Fn(f64) -> bool + Send + Sync>,
},
Dependent {
variable: String,
relation: DependentRelation,
},
StringLength {
min: Option<usize>,
max: Option<usize>,
},
Pattern(String),
}Expand description
A refinement predicate that constrains values.
Variants§
Equal(f64)
Value must equal a constant
NotEqual(f64)
Value must not equal a constant
GreaterThan(f64)
Value must be greater than a constant
GreaterThanOrEqual(f64)
Value must be greater than or equal to a constant
LessThan(f64)
Value must be less than a constant
LessThanOrEqual(f64)
Value must be less than or equal to a constant
Range
Value must be in a range [min, max]
RangeExclusive
Value must be in a half-open range [min, max)
Modulo
Value must satisfy a modulo constraint (value % divisor == remainder)
InSet(Vec<f64>)
Value must be in a set of allowed values
NotInSet(Vec<f64>)
Value must not be in a set of disallowed values
And(Vec<RefinementPredicate>)
Conjunction of predicates (all must be satisfied)
Or(Vec<RefinementPredicate>)
Disjunction of predicates (at least one must be satisfied)
Not(Box<RefinementPredicate>)
Negation of a predicate
Custom
Custom predicate with a name (for symbolic reasoning)
Dependent
Dependent predicate referencing another variable
StringLength
String length constraint
Pattern(String)
Pattern match constraint (for strings)
Implementations§
Source§impl RefinementPredicate
impl RefinementPredicate
Sourcepub fn greater_than(value: f64) -> Self
pub fn greater_than(value: f64) -> Self
Create a “greater than” predicate.
Sourcepub fn greater_than_or_equal(value: f64) -> Self
pub fn greater_than_or_equal(value: f64) -> Self
Create a “greater than or equal” predicate.
Sourcepub fn less_than_or_equal(value: f64) -> Self
pub fn less_than_or_equal(value: f64) -> Self
Create a “less than or equal” predicate.
Sourcepub fn and(predicates: Vec<RefinementPredicate>) -> Self
pub fn and(predicates: Vec<RefinementPredicate>) -> Self
Create a conjunction of predicates.
Sourcepub fn or(predicates: Vec<RefinementPredicate>) -> Self
pub fn or(predicates: Vec<RefinementPredicate>) -> Self
Create a disjunction of predicates.
Sourcepub fn not(predicate: RefinementPredicate) -> Self
pub fn not(predicate: RefinementPredicate) -> Self
Create a negation of a predicate.
Sourcepub fn custom<F>(
name: impl Into<String>,
description: impl Into<String>,
checker: F,
) -> Self
pub fn custom<F>( name: impl Into<String>, description: impl Into<String>, checker: F, ) -> Self
Create a custom predicate with a checker function.
Sourcepub fn dependent(
variable: impl Into<String>,
relation: DependentRelation,
) -> Self
pub fn dependent( variable: impl Into<String>, relation: DependentRelation, ) -> Self
Create a dependent predicate.
Sourcepub fn check(&self, value: f64) -> bool
pub fn check(&self, value: f64) -> bool
Check if a value satisfies this predicate.
Note: For dependent predicates, this returns true (use check_with_context instead).
Sourcepub fn check_with_context(
&self,
value: f64,
context: &RefinementContext,
) -> bool
pub fn check_with_context( &self, value: f64, context: &RefinementContext, ) -> bool
Check if a value satisfies this predicate with a context for dependent predicates.
Sourcepub fn free_variables(&self) -> Vec<String>
pub fn free_variables(&self) -> Vec<String>
Get the free variables referenced by this predicate.
Sourcepub fn simplify(&self) -> RefinementPredicate
pub fn simplify(&self) -> RefinementPredicate
Simplify the predicate by removing redundant constraints.
Sourcepub fn to_string_repr(&self) -> String
pub fn to_string_repr(&self) -> String
Convert to a human-readable string.
Trait Implementations§
Source§impl Clone for RefinementPredicate
impl Clone for RefinementPredicate
Source§fn clone(&self) -> RefinementPredicate
fn clone(&self) -> RefinementPredicate
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more