Skip to main content

QueryHeap

Struct QueryHeap 

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

Working heap for proof search.

Wraps a shared read-only program heap (Arc<Vec<Cell>>) and an owned mutable cell buffer for query-time allocations. Supports branching via an optional parent pointer for backtracking.

Implementations§

Source§

impl QueryHeap

Source

pub fn new( prog_cells: Arc<Vec<Cell>>, root: Option<*const QueryHeap>, ) -> QueryHeap

Source

pub fn branch(&self, count: usize) -> Vec<QueryHeap>

Trait Implementations§

Source§

impl Heap for QueryHeap

Source§

fn term_string(&self, addr: usize) -> String

Create String to represent cell, can be recursively used to format complex structures or list

Source§

fn heap_push(&mut self, cell: Cell) -> usize

Source§

fn heap_len(&self) -> usize

Source§

fn get_id(&self) -> usize

Source§

fn truncate(&mut self, len: usize)

Source§

fn _set_arg(&mut self, value: usize) -> usize

Source§

fn set_const(&mut self, id: usize) -> usize

Source§

fn set_ref(&mut self, ref_addr: Option<usize>) -> usize

Source§

fn deref_addr(&self, addr: usize) -> usize

Source§

fn bind(&mut self, binding: &[(usize, usize)])

Update address value of ref cells affected by binding @binding: List of (usize, usize) tuples representing heap indexes, left -> right
Source§

fn unbind(&mut self, binding: &[(usize, usize)])

Reset Ref cells affected by binding to self references @binding: List of (usize, usize) tuples representing heap indexes, left -> right
Source§

fn str_symbol_arity(&self, addr: usize) -> (usize, usize)

Get the symbol id and arity of functor structure
Source§

fn term_vars(&self, addr: usize, args: bool) -> Vec<usize>

Collect all REF, cells in structure or referenced by structure If cell at addr is a reference return that cell
Source§

fn str_iterator(&self, addr: usize) -> RangeInclusive<usize>

Given address to a str cell create an operator over the sub terms addresses, including functor/predicate
Source§

fn _normalise_args(&mut self, addr: usize, args: &[usize])

Source§

fn _copy_complex( &mut self, other: &impl Heap, addr: usize, update_addr: &mut usize, )

Source§

fn _copy_simple(&mut self, other: &impl Heap, addr: usize, update_addr: &usize)

Source§

fn _copy_term(&mut self, other: &impl Heap, addr: usize) -> usize

Source§

fn copy_term_with_ref_map( &mut self, other: &impl Heap, addr: usize, ref_map: &mut HashMap<usize, usize>, ) -> usize

Copy a term from other heap into self, tracking variable identity via ref_map. Unbound Ref cells in other are mapped to fresh Ref cells in self; the same source Ref always maps to the same target Ref. Call with a shared ref_map across multiple terms to preserve variable sharing (e.g. across literals in a clause).
Source§

fn _copy_ref_map_complex( &mut self, other: &impl Heap, addr: usize, ref_map: &mut HashMap<usize, usize>, ) -> Option<Cell>

Pre-pass helper for copy_term_with_ref_map: recursively copy complex sub-terms and return the Cell to later insert, or None for simple cells.
Source§

fn _copy_ref_map_simple( &mut self, other: &impl Heap, addr: usize, ref_map: &mut HashMap<usize, usize>, )

Post-pass helper for copy_term_with_ref_map: push a simple cell, handling Ref identity via ref_map.
Source§

fn _term_equal(&self, addr1: usize, addr2: usize) -> bool

Source§

fn contains_args(&self, addr: usize) -> bool

Source§

fn _print_heap(&self)

Debug function for printing formatted string of current heap state
Source§

fn list_string(&self, addr: usize) -> String

Create a string from a list
Source§

fn func_string(&self, addr: usize) -> String

Create a string for a functor structure
Source§

fn tuple_string(&self, addr: usize) -> String

Create a string for a tuple
Source§

fn set_string(&self, addr: usize) -> String

Create a string for a set
Source§

impl Index<Range<usize>> for QueryHeap

Source§

type Output = [(Tag, usize)]

The returned type after indexing.
Source§

fn index(&self, index: Range<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<usize> for QueryHeap

Source§

type Output = (Tag, usize)

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<usize> for QueryHeap

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

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, 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, 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.