Struct 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 specified 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 power(&self, n: u32) -> Self

Creates a regular expression that recognizes this regular expression n number of times Requires Z3 4.8.15 or later.

Source

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

Creates a regular expression that recognizes all sequences

Source

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

Creates a regular expression that accepts all singleton sequences of the characters Requires Z3 4.8.13 or later.

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 option(&self) -> Self

Creates a regular expression that optionally accepts this regular expression (e.g. a?)

Source

pub fn diff(&self, other: &Self) -> Self

Creates a difference regular expression Requires Z3 4.8.14 or later.

Source

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

Concatenates regular expressions

Source

pub fn union(ctx: &'ctx Context, values: &[impl Borrow<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: &[impl Borrow<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: &[impl Borrow<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) -> Self
where 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)]) -> Self
where 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) -> Self
where Self: Sized,

Source§

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

Source§

fn clone(&self) -> Self

Returns a duplicate 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 for Regexp<'ctx>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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> Freeze for Regexp<'ctx>

§

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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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 T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

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

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.