Struct z3::ast::Regexp

source ·
pub struct Regexp<'ctx> { /* private fields */ }
Expand description

Ast node representing a regular expression.

use z3::ast;
use z3::{Config, Context, Solver, SatResult};

let cfg = Config::new();
let ctx = &Context::new(&cfg);
let solver = Solver::new(&ctx);
let s = ast::String::new_const(ctx, "s");

// the regexp representing foo[a-c]*
let a = ast::Regexp::concat(ctx, &[
    &ast::Regexp::literal(ctx, "foo"),
    &ast::Regexp::range(ctx, &'a', &'c').star()
]);
// the regexp representing [a-z]+
let b = ast::Regexp::range(ctx, &'a', &'z').plus();
// intersection of a and b is non-empty
let intersect = ast::Regexp::intersect(ctx, &[&a, &b]);
solver.assert(&s.regex_matches(&intersect));
assert!(solver.check() == SatResult::Sat);

Implementations§

source§

impl<'ctx> Regexp<'ctx>

source

pub fn literal(ctx: &'ctx Context, s: &str) -> Self

Creates a regular expression that recognizes the string given as parameter

source

pub fn range(ctx: &'ctx Context, lo: &char, hi: &char) -> Self

Creates a regular expression that recognizes a character in the specificed range (e.g. [a-z])

source

pub fn loop(&self, lo: u32, hi: u32) -> Self

Creates a regular expression that recognizes this regular expression lo to hi times (e.g. a{2,3})

source

pub fn full(ctx: &'ctx Context) -> Self

Creates a regular expression that recognizes all sequences

source

pub fn empty(ctx: &'ctx Context) -> Self

Creates a regular expression that doesn’t recognize any sequences

source

pub fn plus(&self) -> Self

Creates a regular expression that recognizes this regular expression one or more times (e.g. a+)

source

pub fn star(&self) -> Self

Creates a regular expression that recognizes this regular expression any number of times (Kleene star, e.g. a*)

source

pub fn complement(&self) -> Self

Creates a regular expression that recognizes any sequence that this regular expression doesn’t

source

pub fn concat(ctx: &'ctx Context, values: &[&Self]) -> Self

Concatenates regular expressions

source

pub fn union(ctx: &'ctx Context, values: &[&Self]) -> Self

Creates a regular expression that recognizes sequences that any of the regular expressions given as parameters recognize

source

pub fn intersect(ctx: &'ctx Context, values: &[&Self]) -> Self

Creates a regular expression that only recognizes sequences that all of the parameters recognize

Trait Implementations§

source§

impl<'ctx> Ast<'ctx> for Regexp<'ctx>

source§

unsafe fn wrap(ctx: &'ctx Context, ast: Z3_ast) -> Self

Wrap a raw Z3_ast. Read more
source§

fn get_ctx(&self) -> &'ctx Context

source§

fn get_z3_ast(&self) -> Z3_ast

source§

fn _eq(&self, other: &Self) -> Bool<'ctx>where Self: Sized,

Compare this Ast with another Ast, and get a Bool representing the result. Read more
source§

fn _safe_eq(&self, other: &Self) -> Result<Bool<'ctx>, SortDiffers<'ctx>>where Self: Sized,

Compare this Ast with another Ast, and get a Result. Errors if the sort does not match for the two values.
source§

fn distinct(ctx: &'ctx Context, values: &[&Self]) -> Bool<'ctx>where Self: Sized,

Compare this Ast with a list of other Asts, and get a Bool which is true only if all arguments (including Self) are pairwise distinct. Read more
source§

fn get_sort(&self) -> Sort<'ctx>

Get the Sort of the Ast.
source§

fn simplify(&self) -> Selfwhere Self: Sized,

Simplify the Ast. Returns a new Ast which is equivalent, but simplified using algebraic simplification rules, such as constant propagation.
source§

fn substitute<T: Ast<'ctx>>(&self, substitutions: &[(&T, &T)]) -> Selfwhere Self: Sized,

Performs substitution on the Ast. The slice substitutions contains a list of pairs with a “from” Ast that will be substituted by a “to” Ast.
source§

fn num_children(&self) -> usize

Return the number of children of this Ast. Read more
source§

fn nth_child(&self, idx: usize) -> Option<Dynamic<'ctx>>

Return the nth child of this Ast. Read more
source§

fn children(&self) -> Vec<Dynamic<'ctx>>

Return the children of this node as a Vec<Dynamic>.
source§

fn kind(&self) -> AstKind

Return the AstKind for this Ast.
source§

fn is_app(&self) -> bool

Return true if this is a Z3 function application. Read more
source§

fn is_const(&self) -> bool

Return true if this is a Z3 constant. Read more
source§

fn decl(&self) -> FuncDecl<'ctx>

Return the FuncDecl of the Ast. Read more
source§

fn safe_decl(&self) -> Result<FuncDecl<'ctx>, IsNotApp>

source§

fn translate<'src_ctx>(&'src_ctx self, dest: &'ctx Context) -> Selfwhere Self: Sized,

source§

impl<'ctx> Clone for Regexp<'ctx>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'ctx> Debug for Regexp<'ctx>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<'ctx> Display for Regexp<'ctx>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<'ctx> Drop for Regexp<'ctx>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<'ctx> From<Regexp<'ctx>> for Z3_ast

source§

fn from(ast: Regexp<'ctx>) -> Self

Converts to this type from the input type.
source§

impl<'ctx> Hash for Regexp<'ctx>

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'ctx> PartialEq<Regexp<'ctx>> for Regexp<'ctx>

source§

fn eq(&self, other: &Regexp<'ctx>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'ctx> Eq for Regexp<'ctx>

Auto Trait Implementations§

§

impl<'ctx> RefUnwindSafe for Regexp<'ctx>

§

impl<'ctx> !Send for Regexp<'ctx>

§

impl<'ctx> !Sync for Regexp<'ctx>

§

impl<'ctx> Unpin for Regexp<'ctx>

§

impl<'ctx> UnwindSafe for Regexp<'ctx>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.