Skip to main content

CompiledLogicProgram

Struct CompiledLogicProgram 

Source
pub struct CompiledLogicProgram { /* private fields */ }

Implementations§

Source§

impl CompiledLogicProgram

Source

pub fn prepare_conditioned( &self, py: Python<'_>, prob_source: &str, memory_mb: Option<u64>, ) -> PyResult<CompiledConditionedProgram>

Compile this program’s accepted epistemic evidence and prob_source once.

The returned handle can be evaluated repeatedly while independent probabilistic fact priors are changed atomically. It does not accept caller-supplied input relations, matching evaluate_conditioned.

Source

pub fn evaluate_conditioned( &self, py: Python<'_>, prob_source: &str, memory_mb: Option<u64>, ) -> PyResult<EpistemicEvalResult>

Run this epistemic program on the GPU and condition prob_source on what it knows.

The compiled program must contain epistemic operators (know, possible, …) AND lower to a single-component epistemic plan: ordinary Datalog programs are rejected, because there is no accepted world view to condition on. Only facts declared in the epistemic program’s own source are used to build that world view.

Both epistemic modes are reachable here. FAEEL programs and non-recursive G91-compatibility programs (#pragma epistemic_mode = g91) both lower to a single-component epistemic plan and condition normally; epistemic_evidence().epistemic_mode names the mode, and the trace’s accepted_faeel_world_view_evidence_consumed / accepted_g91_world_view_evidence_consumed pair says which one actually supplied the evidence. Only the recursive G91 shapes (positive possible cycles that need tuple-level compatibility) compile to a dedicated G91-compatibility plan and are rejected at plan level, alongside split, stratified and WFS plans.

LIMITATION: unlike evaluate, this method does not accept dlpack_inputs. Caller-supplied input relations are NOT consulted — if the epistemic program depends on a relation that is normally supplied at call time via evaluate(dlpack_inputs=...), that relation is empty here and no world view is accepted. This method then RAISES RuntimeError (“Unsupported epistemic construct: accepted GPU world-view evidence … probabilistic evidence requires non-empty accepted GPU final output”); it does NOT fall back to the unconditioned prior. That is fail-closed by design: a conditioned query that silently became unconditioned would be indistinguishable from a successful one, which is exactly the failure the trace counters exist to make visible. To test for the case without catching an exception, call epistemic_evidence() first — it reports accepted_world_views == 0 without raising.

The returned trace must show a non-zero gpu_conditioned_evidence_facts — otherwise the conditioning did not reach the GPU exact path. gpu_conditioned_evidence_facts is the total the engine itself validates; the per-class counters (gpu_conditioned_know_evidence_facts, gpu_conditioned_possible_evidence_facts, gpu_conditioned_not_known_evidence_facts, gpu_conditioned_not_possible_evidence_facts) break it down. A possible-only or negated-evidence program conditions correctly with the know counter at 0, so check the total, not the know class alone.

Source

pub fn epistemic_evidence(&self, py: Python<'_>) -> PyResult<EpistemicEvidence>

Run this epistemic program on the GPU and report what it accepted.

Diagnostic counterpart of evaluate_conditioned: it answers whether the know-broadcast happened at all, without involving the probabilistic tier.

LIMITATION: like evaluate_conditioned, this only ever sees facts declared in the epistemic program’s own source; it does not accept caller-supplied input relations. A program that depends on such a relation reports accepted_world_views == 0, accepted_candidates == 0 and final_output_rows == 0 here — without raising. The operator censuses (know_operator_count, possible_operator_count) are read off the plan, not the execution, so they stay non-zero: it is the accepted/consumed family that goes to zero, not “every counter”. Calling evaluate_conditioned() on that same program RAISES rather than returning an unconditioned result, so this method is the non-raising way to probe for the case first.

Source§

impl CompiledLogicProgram

Source

pub fn evaluate( &self, py: Python<'_>, dlpack_inputs: Option<&Bound<'_, PyDict>>, memory_mb: Option<u64>, ) -> PyResult<LogicEvalResult>

Source

pub fn session(&self) -> PyResult<LogicRelationSession>

Source

pub fn memory_stats(&self, py: Python<'_>) -> PyResult<Py<PyAny>>

Return memory diagnostics including allocated_bytes and memory_limit_bytes.

Source

pub fn rule_provenance(&self, py: Python<'_>) -> PyResult<Py<PyAny>>

Source

pub fn proof_traces(&self, py: Python<'_>) -> PyResult<Py<PyAny>>

Trait Implementations§

Source§

impl DerefToPyAny for CompiledLogicProgram

Source§

impl ExtractPyClassWithClone for CompiledLogicProgram

Source§

impl<'py> IntoPyObject<'py> for CompiledLogicProgram

Source§

type Target = CompiledLogicProgram

The Python output type
Source§

type Output = Bound<'py, <CompiledLogicProgram as IntoPyObject<'py>>::Target>

The smart pointer type to use. Read more
Source§

type Error = PyErr

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

fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>

Performs the conversion.
Source§

impl PyClass for CompiledLogicProgram

Source§

const NAME: &str = "CompiledLogicProgram"

Name of the class. Read more
Source§

type Frozen = False

Whether the pyclass is frozen. Read more
Source§

impl PyClassImpl for CompiledLogicProgram

Source§

const MODULE: Option<&str> = ::core::option::Option::None

Module which the class will be associated with. Read more
Source§

const IS_BASETYPE: bool = false

#[pyclass(subclass)]
Source§

const IS_SUBCLASS: bool = false

#[pyclass(extends=…)]
Source§

const IS_MAPPING: bool = false

#[pyclass(mapping)]
Source§

const IS_SEQUENCE: bool = false

#[pyclass(sequence)]
Source§

const IS_IMMUTABLE_TYPE: bool = false

#[pyclass(immutable_type)]
Source§

const RAW_DOC: &'static CStr = c"\x00"

Docstring for the class provided on the struct or enum. Read more
Source§

const DOC: &'static CStr

Fully rendered class doc, including the text_signature if a constructor is defined. Read more
Source§

type Layout = <<CompiledLogicProgram as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<CompiledLogicProgram>

Description of how this class is laid out in memory
Source§

type BaseType = PyAny

Base class
Source§

type ThreadChecker = NoopThreadChecker

This handles following two situations: Read more
Source§

type Inventory = Pyo3MethodsInventoryForCompiledLogicProgram

Source§

type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild

Immutable or mutable
Source§

type Dict = PyClassDummySlot

Specify this class has #[pyclass(dict)] or not.
Source§

type WeakRef = PyClassDummySlot

Specify this class has #[pyclass(weakref)] or not.
Source§

type BaseNativeType = PyAny

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
Source§

fn items_iter() -> PyClassItemsIter

Source§

fn lazy_type_object() -> &'static LazyTypeObject<Self>

§

fn dict_offset() -> Option<PyObjectOffset>

Used to provide the dictoffset slot (equivalent to tp_dictoffset)
§

fn weaklist_offset() -> Option<PyObjectOffset>

Used to provide the weaklistoffset slot (equivalent to tp_weaklistoffset
Source§

impl PyTypeInfo for CompiledLogicProgram

Source§

const NAME: &str = <Self as ::pyo3::PyClass>::NAME

👎Deprecated since 0.28.0:

prefer using ::type_object(py).name() to get the correct runtime value

Class name.
Source§

const MODULE: Option<&str> = <Self as ::pyo3::impl_::pyclass::PyClassImpl>::MODULE

👎Deprecated since 0.28.0:

prefer using ::type_object(py).module() to get the correct runtime value

Module name, if any.
Source§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.
§

fn type_object(py: Python<'_>) -> Bound<'_, PyType>

Returns the safe abstraction over the type object.
§

fn is_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type or a subclass of this type.
§

fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type.

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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.

§

impl<'py, T> IntoPyObjectExt<'py> for T
where T: IntoPyObject<'py>,

§

fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>

Converts self into an owned Python object, dropping type information.
§

fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>

Converts self into an owned Python object, dropping type information and unbinding it from the 'py lifetime.
§

fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>

Converts self into a Python object. Read more
§

impl<T> PyErrArguments for T
where T: for<'py> IntoPyObject<'py> + Send + Sync,

§

fn arguments(self, py: Python<'_>) -> Py<PyAny>

Arguments for exception
§

impl<T> PyTypeCheck for T
where T: PyTypeInfo,

§

fn type_check(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of Self, which may include a subtype. Read more
§

fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>

Returns the expected type as a possible argument for the isinstance and issubclass function. 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.
§

impl<T> Ungil for T
where T: Send,

§

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

§

fn vzip(self) -> V