You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wirelog currently behaves like a weighted logic engine where ordinary inserted facts have weight +1, retractions contribute -1, duplicate derivations are consolidated by signed multiplicity, and joins multiply multiplicities. In that sense, the current system already has a weight algebra: signed integer Z-set multiplicity.
Probabilistic logic can be understood as the next generalization: allow facts, derivations, and rule results to carry weights other than 1, and define how those weights combine across joins, unions, recursion, negation, aggregation, and retraction.
This issue should evaluate whether Wirelog can expose a weighted/semiring evaluation addon point so probabilistic logic can be implemented outside the core builtin function set, while preserving the core's deterministic Datalog and differential/retraction guarantees.
This is related to #912, but it is a deeper layer. #912 covers row-local scalar functions. Probabilistic logic requires changing the evaluation algebra, not just adding scalar callbacks.
Current Mental Model
The current execution model can be described as a fixed weight algebra:
inserted EDB fact: weight +1
retracted EDB fact: weight -1
duplicate derivations of the same tuple: weights are added during consolidation
join: weights are multiplied
antijoin/negation: handled through stratified relational semantics, not probabilistic complement
result existence: a tuple with non-zero signed multiplicity is present
incremental update: deltas propagate signed weight changes
This is effectively a signed-integer semiring/group-like model specialized for Z-set differential evaluation.
The probabilistic logic question is therefore not merely “can we call probability helper functions?” The deeper question is:
Can the weight algebra itself be made pluggable or extensible?
Motivation
For many reasoning workloads, facts are not simply true or false. They may have confidence, probability, cost, trust, provenance, risk, or score.
Examples:
edge(a, b, 0.7).
edge(b, c, 0.4).
path(x, y, p) :- edge(x, y, p).
path(x, z, p3) :- path(x, y, p1), edge(y, z, p2), combine(p1, p2, p3).
The user can encode probabilities as ordinary columns today, but then the user must manually define and maintain derivation-combination semantics. That becomes error-prone for recursion, multiple proofs, negation, aggregation, and retraction.
A weighted/semiring addon point could let Wirelog keep its core engine small while allowing higher layers to supply alternate weight semantics.
Key Distinction From Scalar Addons
Scalar addons from #912 are row-local expression functions. They are enough for probability arithmetic utilities such as:
prob.mul(p1, p2)
prob.noisy_or(p1, p2)
prob.threshold(p, cutoff)
prob.log_sum_exp(a, b)
They are not enough to define probabilistic logic semantics because they do not control:
how duplicate derivations combine
how join weights are produced
how recursive fixpoints converge
how retractions undo or recompute marginal probabilities
how negation behaves under uncertainty
how aggregation interacts with weights
how provenance is retained or discarded
Weighted/probabilistic logic needs an evaluation-level addon point, not just an expression-level addon point.
The design identifies whether the next step is a generic weight algebra addon point, a separate weighted backend, or an external higher-layer inference engine.
Any proposed public ABI defines weight representation, add/combine, multiply/extend, zero/one, retraction, equality/zero-test, serialization, and lifecycle rules.
Any probabilistic semantics proposal defines multiple derivation combination, independence/provenance assumptions, recursion, negation, aggregation, and retraction behavior before implementation.
Core builtin probability semantics are not added until these questions are resolved.
Follow-Up Issues
Potential follow-ups:
Document current signed multiplicity/Z-set algebra as Wirelog's baseline weight model.
Research semiring/provenance requirements for weighted Datalog in Wirelog.
Prototype an experimental weighted backend or alternate algebra path.
Summary
Wirelog currently behaves like a weighted logic engine where ordinary inserted facts have weight
+1, retractions contribute-1, duplicate derivations are consolidated by signed multiplicity, and joins multiply multiplicities. In that sense, the current system already has a weight algebra: signed integer Z-set multiplicity.Probabilistic logic can be understood as the next generalization: allow facts, derivations, and rule results to carry weights other than
1, and define how those weights combine across joins, unions, recursion, negation, aggregation, and retraction.This issue should evaluate whether Wirelog can expose a weighted/semiring evaluation addon point so probabilistic logic can be implemented outside the core builtin function set, while preserving the core's deterministic Datalog and differential/retraction guarantees.
This is related to #912, but it is a deeper layer. #912 covers row-local scalar functions. Probabilistic logic requires changing the evaluation algebra, not just adding scalar callbacks.
Current Mental Model
The current execution model can be described as a fixed weight algebra:
+1-1This is effectively a signed-integer semiring/group-like model specialized for Z-set differential evaluation.
The probabilistic logic question is therefore not merely “can we call probability helper functions?” The deeper question is:
Motivation
For many reasoning workloads, facts are not simply true or false. They may have confidence, probability, cost, trust, provenance, risk, or score.
Examples:
The user can encode probabilities as ordinary columns today, but then the user must manually define and maintain derivation-combination semantics. That becomes error-prone for recursion, multiple proofs, negation, aggregation, and retraction.
A weighted/semiring addon point could let Wirelog keep its core engine small while allowing higher layers to supply alternate weight semantics.
Key Distinction From Scalar Addons
Scalar addons from #912 are row-local expression functions. They are enough for probability arithmetic utilities such as:
prob.mul(p1, p2)prob.noisy_or(p1, p2)prob.threshold(p, cutoff)prob.log_sum_exp(a, b)They are not enough to define probabilistic logic semantics because they do not control:
Weighted/probabilistic logic needs an evaluation-level addon point, not just an expression-level addon point.
Candidate Abstraction: Weight Algebra / Semiring Addon
A possible addon point would describe the algebra used for tuple weights.
Potential descriptor fields:
zset.signed_i64,prob.independent,provenance.boolean_formulaConceptual callbacks:
This is only a sketch. The design must account for memory ownership, inline vs heap weights, ABI stability, vectorized execution, and backend storage.
Probabilistic Algebra Examples
Independent proof probability
For independent alternative derivations of the same tuple:
For joins of independent events:
This works only under independence assumptions. If derivations share facts, naive noisy-or can overcount unless provenance is tracked.
Log-space probability
Weights can be stored in log-space to reduce underflow:
This raises representation questions because Wirelog's current hot paths are
int64_t-centric.Provenance semiring
Instead of immediately computing probabilities, weights can store symbolic provenance:
Marginal probabilities can be computed later from the provenance expression. This avoids some overcounting but can explode in size.
Major Semantic Questions
Before implementation, the design must answer:
1-p?Interaction With Current Wirelog Architecture
This is a deep architectural change because current execution assumes signed multiplicity in many places.
Likely affected areas:
A weighted addon point must not silently reuse signed-multiplicity assumptions where the selected algebra has different laws.
Architecture Options
Option 1: Keep weights as ordinary columns
No new evaluation addon point. Users encode probabilities manually and use #912 scalar functions for arithmetic.
Pros:
Cons:
Option 2: Add a weight algebra addon point
Expose a pluggable algebra for tuple weights while keeping relational structure in core.
Pros:
+1/-1multiplicity is one weight algebra.Cons:
int64_tweights.Option 3: Add a separate weighted backend/evaluation mode
Keep the existing Z-set engine unchanged. Add a new backend or evaluation mode that explicitly supports weighted/semiring logic.
Pros:
Cons:
Option 4: Keep probabilistic inference outside Wirelog
Use Wirelog for deterministic candidate/proof generation and run probabilistic inference in a higher-layer engine.
Pros:
Cons:
Recommended Direction
Do not treat probabilistic logic as a scalar addon problem.
Short term:
Medium term:
Long term:
Possible Minimal Prototype
A prototype should not start with full probabilistic Datalog syntax. Instead:
Only after this should a public ABI be considered.
Test Requirements
Any weighted/probabilistic evaluation design needs tests for:
Acceptance Criteria
+1/-1signed multiplicity model is documented as the baseline weight algebra.Follow-Up Issues
Potential follow-ups: