Counting m-semiring #
This file shows that ℕ (with standard addition and multiplication) is a commutative
m-semiring. The monus is truncated subtraction (Nat.sub). Unlike most provenance
semirings, ℕ is neither idempotent nor absorptive.
The natural order is the usual order on natural numbers, and monus coincides with
Mathlib's Nat.sub.
ℕ is a commutative m-semiring. The natural order is the usual order on
natural numbers, and the monus is truncated subtraction. The δ operator matches
ProvSQL's Counting::delta: the support indicator (0 ↦ 0, positive ↦ 1).
Equations
- One or more equations did not get rendered due to their size.
Equations
- instCommSemiringWithMonusNat = { toSemiringWithMonus := instSemiringWithMonusNat, mul_comm := instCommSemiringWithMonusNat._proof_1 }
Equations
- instHasAltLinearOrderNat = { altOrder := inferInstance }
ℕ has characteristic 0: it satisfies CharZero, hence CharP ℕ 0 via
CharP.ofCharZero.
There is no semiring homomorphism from BoolFunc X to ℕ sending the
variables to arbitrary values: ℕ is not absorptive (1 + 1 = 2 ≠ 1),
which contradicts var i + 1 = 1 in BoolFunc X.
Over ℕ, the two natural expansions of HAVING (count = 2) for a
three-tuple group, (t₁ ⊗ t₂) ⊗ (𝟙 ⊖ t₃) ⊕ (t₁ ⊗ t₃) ⊗ (𝟙 ⊖ t₂) ⊕ (t₂ ⊗ t₃) ⊗ (𝟙 ⊖ t₁) and (t₁ ⊗ t₂) ⊕ (t₁ ⊗ t₃) ⊕ (t₂ ⊗ t₃), differ.
With t₁ = t₂ = t₃ = 1, the first expression evaluates to 0 while the
second evaluates to 3.