Skip to main content

Module asp

Module asp 

Source

Structs§

AspRule
A normal ASP rule head :- pos.., not neg... head == 0 encodes an integrity constraint :- pos.., not neg.. (admits no atom; prunes models satisfying the body).
WeakConstraint
A weak constraint :~ pos.., not neg.. [weight] — incurs weight when its body holds in a model. Optimal answer sets MINIMISE total incurred weight.

Enums§

AspOutcome
Outcome of an answer-set computation — distinguishes “no model” (an over-constrained / inconsistent program) from genuine results, so the caller can route the former to paraconsistent reasoning instead of treating absence-of-model as plain falsity.

Constants§

ASP_MAX_ATOMS
ASP_MAX_BODY
MAX_STABLE_MODELS

Functions§

answer_sets_or_paraconsistent
Compute answer sets; if NONE exist, return AspOutcome::NoStableModel so the caller routes the (inconsistent) program to modalities::paraconsistent::route_paraconsistent rather than silently concluding falsity. This is the tight integration with paraconsistent routing.
atom_index
Index of atom a in atoms (bit position), if present.
brave_consequences
Brave (credulous) consequences: the atoms in SOME answer set (bit-OR of all models).
cautious_consequences
Cautious (skeptical) consequences: the atoms in EVERY answer set (bit-AND of all models). 0 if there are no models.
compute_answer_sets
Compute the stable models (answer sets) of rules over atoms. Each answer set is written to out as a bitmask over atom indices (bit i ⇔ atoms[i] is in the set). Returns the number found. Zero-heap; bounded to ASP_MAX_ATOMS atoms.
enumerate_stable_models
Returns number of stable models found (max MAX_STABLE_MODELS = 8) Worlds are encoded as context-hash variants: world_i_context = base_context ^ (i as u64)
ground_rule
Ground a rule TEMPLATE by substituting variable var with each element of domain, writing the ground instances into out. Returns the count. Apply repeatedly (over the partially-ground output) for multiple variables. Zero-heap — bounded by out.len() (the “millions of constraints” ceiling is the caller’s buffer, not a heap allocation here).
model_penalty
Total penalty of model under weak: the sum of weights of the weak constraints whose body holds in the model.
optimal_answer_set
The optimal answer set: the stable model minimising total weak-constraint penalty. Returns (model_bitmask, penalty), or None if the program has no stable model. buf is scratch for the enumerated answer sets.