Counting weighted possible worlds #
DescriptiveComplexity.Counting.PossibleWorlds counts the possible worlds of
an instance with certain and uncertain facts, each uncertain fact being
present with probability 1/2. Here every uncertain fact carries its own
probability, as two natural weights: a for its being present and c for
its being absent, the probability being a / (a + c). The quantity counted is
the weighted number of worlds in which a sentence φ of the schema holds,
W(φ) = ∑ over the worlds satisfying φ of ∏ over the open facts of their weight,
and the probability of φ is W(φ) / W(⊤)
(DescriptiveComplexity.ProbAssignment.funcProb_ofWeights).
The instances #
DescriptiveComplexity.weightedLang L: for each symbol of the schema L, of
arity n, the certain facts and the uncertain ones, and two relations of
arity n + 1 holding the bits of the two weights of each fact; and one order
relation on the bit positions, which are all the elements. Weights are in
binary: the encoding in which a probability of a database is honestly
written, and the one for which membership is the stronger statement.
Why this is in #P #
A weight multiplies a count, and a count cannot be multiplied by a number of
the instance directly. The witness therefore carries, beside the world, one
number per open fact, below the weight that fact takes in the world: each
world is then counted once per unit of the product of its weights. “Below” is
first-order, by the highest position at which two binary numbers differ
(DescriptiveComplexity.numLtFormula, generic in the arity of the fact), and
the numbers below a weight are as many as the weight
(DescriptiveComplexity.card_binNum_lt).
DescriptiveComplexity.WeightedWorlds φis the witness count of that kernel, hence in#Pfor every first-orderφ(DescriptiveComplexity.weightedWorlds_mem_sharpP).DescriptiveComplexity.weightedWorlds_eq_weightSum: on an instance whose order is linear, it is the weighted number of worlds. The proof sorts the witnesses by world (DescriptiveComplexity.weightedWorlds_eq_sum), then counts the numbers allowed at each fact (DescriptiveComplexity.card_numCond).- On an instance whose order relation is not linear the count is zero
(
DescriptiveComplexity.weightedWorlds_of_not_isLinOrd): the kernel asks for linearity, such an instance carrying no number.
The probability #
The open facts of an instance are independent Boolean variables, and a world
is a valuation of them (DescriptiveComplexity.worldOfVal). So the count is a
weighted count in the sense of DescriptiveComplexity.Counting.Probability
(DescriptiveComplexity.weightedWorlds_eq_weightedCount), and
Pr(φ) = WeightedWorlds φ / WeightedWorlds ⊤
(DescriptiveComplexity.funcProb_holdsEvent_eq_ratio): the probability of
any first-order query over a tuple-independent database is a ratio of two
#P numbers.
The vocabulary #
The relation symbols of a weighted instance over the schema L: for each
symbol of the schema, the certain facts, the uncertain facts, and the bits of
the two weights of each fact; and one order, on the bit positions.
- cert
{L : FirstOrder.Language}
{n : ℕ}
(R : L.Relations n)
: WeightedRel L n
The certain facts.
- unc
{L : FirstOrder.Language}
{n : ℕ}
(R : L.Relations n)
: WeightedRel L n
The uncertain facts.
- pres
{L : FirstOrder.Language}
{n : ℕ}
(R : L.Relations n)
: WeightedRel L (n + 1)
pres R (x̄, i): the bit of positioniof the weight of the factR(x̄)being present. - abs
{L : FirstOrder.Language}
{n : ℕ}
(R : L.Relations n)
: WeightedRel L (n + 1)
abs R (x̄, i): the bit of positioniof the weight of the factR(x̄)being absent. - le
{L : FirstOrder.Language}
: WeightedRel L 2
The order of the bit positions.
Instances For
Dependency graph
The vocabulary of weighted instances over the schema L.
Equations
- DescriptiveComplexity.weightedLang L = { Functions := fun (x : ℕ) => Empty, Relations := DescriptiveComplexity.WeightedRel L }
Instances For
Dependency graph
Dependency graph
The block guessing a weighted world: a world, and for each fact a number, as the set of its bits.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The vocabulary of the kernel.
Equations
Instances For
Dependency graph
The certain facts of a symbol, in the kernel vocabulary.
Instances For
Dependency graph
The uncertain facts of a symbol, in the kernel vocabulary.
Equations
Instances For
Dependency graph
The bits of the weight of presence, in the kernel vocabulary.
Instances For
Dependency graph
The bits of the weight of absence, in the kernel vocabulary.
Equations
Instances For
Dependency graph
The guessed world, in the kernel vocabulary.
Instances For
Dependency graph
The guessed numbers, in the kernel vocabulary.
Instances For
Dependency graph
The order of the positions, in the kernel vocabulary.
Instances For
Dependency graph
Atoms about a fact and a position #
The atom S(x̄), the tuple being read off the free variables through
e.
Equations
- DescriptiveComplexity.factAtom S e = S.formula fun (m : Fin n) => FirstOrder.Language.var (e m)
Instances For
Dependency graph
The atom S(x̄, i): a fact and a position.
Equations
- DescriptiveComplexity.bitAtom S e i = S.formula (Fin.snoc (fun (m : Fin n) => FirstOrder.Language.var (e m)) (FirstOrder.Language.var i))
Instances For
Dependency graph
Comparing two numbers attached to a fact #
“The number N(x̄, ·) is below the number W(x̄, ·)”, by the highest
position at which they differ: some position carries 1 in W and 0 in
N, and the two agree strictly above it.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
“The relation Le is a linear order”, as a sentence.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
“The number N(x̄, ·) is zero”: it has no bit.
Equations
Instances For
Dependency graph
Dependency graph
The kernel #
The world of an assignment of the block.
Equations
- DescriptiveComplexity.worldOf σ p x = σ (Sum.inl p) x
Instances For
Dependency graph
The number an assignment of the block attaches to a fact, as its set of bits.
Equations
- DescriptiveComplexity.numOf σ p x i = σ (Sum.inr p) (Fin.snoc x i)
Instances For
Dependency graph
The bits of a weight of a fact, read through a symbol of arity one more than the fact's.
Equations
Instances For
Dependency graph
The order of the positions of a weighted instance.
Equations
Instances For
Dependency graph
One set of bits is below another, by the highest position at which they differ.
Equations
Instances For
Dependency graph
What the kernel asks of an assignment at one fact: the world keeps a certain fact and contains only certain or uncertain ones; at an open fact – uncertain and not certain – the number is below the weight of presence if the world keeps the fact, and below the weight of absence if not; at any other fact the number is zero.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The condition of the kernel at one fact, as a formula in the fact.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The sentence asking the condition of the kernel at every fact.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
Reading a sentence of the schema in the guessed world.
Equations
- DescriptiveComplexity.toWeightWorld L = { onFunction := fun {x : ℕ} (f : L.Functions x) => isEmptyElim f, onRelation := fun {n : ℕ} (R : L.Relations n) => DescriptiveComplexity.wkWorld ⟨n, R⟩ }
Instances For
Dependency graph
The kernel: the positions are linearly ordered, the condition holds at every fact, and the sentence holds in the world.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The counting problem #
Counting weighted possible worlds: the witnesses are the worlds in
which the sentence φ holds, each with one number per open fact below the
weight that fact takes in the world. On an instance whose positions are
linearly ordered this is the weighted count of the worlds satisfying φ, and
on any other instance it is zero.
Equations
Instances For
Dependency graph
Dependency graph
On an instance whose positions are not linearly ordered, the count is
zero: such an instance carries no number.
Registered in the Lax archive as
Lax794877.ProbabilityRatio.weightedWorlds_of_not_isLinOrd.
Dependency graph
Counting the weighted worlds of a first-order sentence is in #P,
whatever the sentence.
Registered in the Lax archive as
Lax794877.WorldsInSharpP.weightedWorlds_mem_sharpP.
Dependency graph
The count #
The facts over a universe: a symbol of the schema and a tuple.
Instances For
Dependency graph
The fact is open: uncertain and not certain.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The family of relations is a possible world of the weighted instance.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
What the kernel asks of the number attached to a fact, in a world.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
An assignment of the block is a world and a number per fact.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The witnesses, sorted by world: the count is the sum, over the worlds satisfying the sentence, of the product over the facts of the number of numbers the kernel allows there.
Dependency graph
The weight of a fact in a world: the weight of presence of an open fact
the world keeps, the weight of absence of an open fact it drops, and 1 for a
fact that is not open. Weights are read in binary on the order of the
instance.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The numbers the kernel allows at a fact are as many as its weight.
Dependency graph
The count is the weighted number of worlds: on an instance whose positions are linearly ordered, the count is the sum, over the possible worlds in which the sentence holds, of the product of the weights of the facts.
Dependency graph
Worlds as valuations of the open facts #
The open facts of a finite instance, as a finite type: the independent Boolean variables of the instance.
Dependency graph
The weight of presence of an open fact.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The weight of absence of an open fact.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The world of a valuation of the open facts: the certain facts, and the open facts the valuation makes true.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The event “the sentence holds in the world”, as a Boolean function of the valuation of the open facts.
Equations
- DescriptiveComplexity.holdsEvent φ v = decide (A ⊨ φ)
Instances For
Dependency graph
Dependency graph
The count is a weighted count of valuations: on an instance whose positions are linearly ordered, counting the weighted worlds of a sentence is the weighted count, over the valuations of the open facts, of the event that the sentence holds.
Dependency graph
The probability of a first-order sentence is a ratio of two #P
numbers. Over a weighted instance whose positions are linearly ordered, let
each open fact be present independently, with probability its weight of
presence over the sum of its two weights. Then the probability that φ holds
is the count of the weighted worlds of φ, divided by the count of all the
weighted worlds; and both counting problems are in #P
(DescriptiveComplexity.weightedWorlds_mem_sharpP).
Dependency graph
The probability of a sentence over a weighted instance: each open fact is present independently, with probability its weight of presence over the sum of its two weights, and the probability is that of the event that the sentence holds in the resulting world.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Dependency graph
The probability of a first-order sentence is a ratio of two #P numbers:
DescriptiveComplexity.funcProb_holdsEvent_eq_ratio, for the packaged
probability.
Registered in the Lax archive as
Lax794877.ProbabilityRatio.worldProb_eq_ratio.