Skip to main content

QueryRewriter

Struct QueryRewriter 

Source
pub struct QueryRewriter { /* private fields */ }
Expand description

The PerfectRef query rewriter for OWL 2 QL

Extended to handle union query rewriting (ObjectUnionOf on RHS of SubClassOf).

Implementations§

Source§

impl QueryRewriter

Source

pub fn new(tbox: Owl2QLTBox) -> Self

Create a new rewriter with a classified TBox

Source

pub fn with_limit(tbox: Owl2QLTBox, max_rewrites: usize) -> Self

Create with a custom rewriting limit

Source

pub fn tbox(&self) -> &Owl2QLTBox

Access the underlying TBox

Source

pub fn rewrite_query( &self, query: &ConjunctiveQuery, ) -> Result<RewrittenQuery, QlError>

Main entry point: rewrite a conjunctive query using PerfectRef algorithm.

Returns a RewrittenQuery (UCQ) that is equivalent to the original CQ over any ABox consistent with the TBox.

This extended version handles:

  • Standard subclass/subproperty/domain/range unfolding
  • Union axiom branching: C ⊑ A ⊔ B causes the type atom ?x:A to gain an additional CQ branch where ?x:C replaces the atom (since C individuals that are A will satisfy the query).
Source

pub fn unfold_atom(&self, atom: &QueryAtom) -> Vec<QueryAtom>

Unfold a single query atom using TBox axioms. Returns all possible alternative atoms (including the original).

Source

pub fn unfold_type_atom_union_branches( &self, individual: &QueryTerm, class: &str, ) -> Vec<QueryAtom>

Compute additional type atom alternatives arising from union axioms.

For a type atom ?x:A, if there is a union axiom C ⊑ A ⊔ B, then C individuals that happen to be A will satisfy the query. We cannot replace ?x:A with ?x:C (since not all C are A), but we can add a branch that queries ?x:C with the understanding that a C that is not B must be A (by the closed-world assumption on the union).

In the PerfectRef framework for OWL 2 QL, union rewriting produces new CQ branches where the type atom is replaced by the sub-concept C (the class that is subsumed by the union). This is correct because:

  • If ?x is a C individual and C ⊑ A ⊔ B, then ?x satisfies A or B.
  • The query ?x:A is satisfied if we can certify ?x is a C that is an A.

Returns a list of replacement atoms (one per union branch sub-concept).

Source

pub fn is_satisfiable(&self, class: &str) -> bool

Check if a class assertion is trivially satisfiable given the TBox

Source

pub fn rewrite_query_union_aware( &self, query: &ConjunctiveQuery, ) -> Result<RewrittenQuery, QlError>

Compute union-aware query rewriting for a conjunctive query where union axioms guide query branching.

This method extends rewrite_query by explicitly computing all union disjunct branches for each type atom and emitting separate CQs for each possible branch derivation path.

For example, given: TBox: Dog ⊑ Animal ⊔ Pet Query: ?x:Animal

The rewriting includes: ?x:Animal (original) ?x:Dog (from union: Dog may be an Animal)

Source

pub fn union_siblings_for(&self, class: &str) -> Vec<Vec<String>>

Compute all union disjunct branches for a named class.

Returns a list of lists — each inner list is a set of class names that are sibling disjuncts in some union axiom where class participates.

Example: if TBox contains C ⊑ A ⊔ B, then: union_siblings_for(“A”) → [[“A”, “B”]]

Source

pub fn are_union_siblings(&self, class_a: &str, class_b: &str) -> bool

Check if class A and class B are in a union axiom together (sibling disjuncts)

Source

pub fn conjunction_satisfiable(&self, classes: &[&str]) -> bool

Compute satisfiability of a concept conjunction {C₁, C₂, …} w.r.t. the TBox.

Returns false if the conjunction is definitely unsatisfiable based on:

  • Direct disjointness between any two members
  • Union axiom exhaustion: C ⊑ A ⊔ B and neither A nor B is compatible

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,