roseking's picture
Add lean source and binary files (part 85)
f18e7de verified
Raw History Blame Contribute Delete
3.82 kB
import OAI.LinearAlgebra.MatrixMultiplication.JointExtraction.CanonicalMixed
namespace OAI
/-! Joint tensor extraction, compatibility and entropy estimates. -/
noncomputable section
namespace MatrixMultiplication.JointPopulationMixedNonzero
open MatrixMultiplication.Foundation JointPopulation JointCanonicalization JointCanonicalCW
open JointCanonicalMixed CWStrands InheritedMasks
open scoped BigOperators
attribute [local instance] Classical.propDecidable
variable {H F : Type*} [Fintype H] [DecidableEq H] [Field F]
omit [DecidableEq H] in
theorem class_half_products_nonzero
(counts : H → Shape → ℕ) (leftLength rightLength : H → ℕ)
(parentShape : H → Fin 3 → ℕ) (sharing : H → Bool)
(hleft : ∀ h, leftLength h ≤ 8)
(hsupp : ∀ h u, 0 < counts h u → sharing h = true →
∀ s, shapeNat u s ≤ parentShape h s)
(e : Target counts)
(x y z : RawPairs counts (Left leftLength) (Right rightLength))
(hsource : sourceTensor counts (Left leftLength) (Right rightLength)
(inputTensor (F := F) leftLength rightLength parentShape sharing) x y z ≠ 0)
(hx : coarseMask counts (Left leftLength) (Right rightLength)
(coarse leftLength rightLength hleft) 0 e x)
(hy : coarseMask counts (Left leftLength) (Right rightLength)
(coarse leftLength rightLength hleft) 1 e y)
(hz : coarseMask counts (Left leftLength) (Right rightLength)
(coarse leftLength rightLength hleft) 2 e z)
(h : H) (u : Shape) (hn : 0 < counts h u) (hh : sharing h = true) :
(∏ i : Class counts e h u,
shapeTensor (F := F) (Fin (leftLength h)) (shapeNat u)
(x h i.val).1 (y h i.val).1 (z h i.val).1) ≠ 0 ∧
(∏ i : Class counts e h u,
shapeTensor (F := F) (Fin (rightLength h)) (parentShape h - shapeNat u)
(x h i.val).2 (y h i.val).2 (z h i.val).2) ≠ 0 := by
change (∏ h' : H, ∏ i : Positions counts h',
inputTensor (F := F) leftLength rightLength parentShape sharing h'
(x h' i) (y h' i) (z h' i)) ≠ 0 at hsource
have hparent (i : Positions counts h) :
inputTensor (F := F) leftLength rightLength parentShape sharing h
(x h i) (y h i) (z h i) ≠ 0 :=
Finset.prod_ne_zero_iff.mp
(Finset.prod_ne_zero_iff.mp hsource h (Finset.mem_univ h)) i (Finset.mem_univ i)
have hhalves (i : Class counts e h u) :
shapeTensor (F := F) (Fin (leftLength h)) (shapeNat u)
(x h i.val).1 (y h i.val).1 (z h i.val).1 *
shapeTensor (F := F) (Fin (rightLength h)) (parentShape h - shapeNat u)
(x h i.val).2 (y h i.val).2 (z h i.val).2 ≠ 0 := by
have hx' : coarse leftLength rightLength hleft 0 h (x h i.val) = u.1 := by
simpa [shapeSide, i.property] using hx h i.val
have hy' : coarse leftLength rightLength hleft 1 h (y h i.val) = u.2.1 := by
simpa [shapeSide, i.property] using hy h i.val
have hz' : coarse leftLength rightLength hleft 2 h (z h i.val) = u.2.2 := by
simpa [shapeSide, i.property] using hz h i.val
have hblock : block (Left leftLength) (Right rightLength)
(inputTensor (F := F) leftLength rightLength parentShape sharing)
(coarse leftLength rightLength hleft) (h, u)
(x h i.val) (y h i.val) (z h i.val) ≠ 0 := by
simpa [block, hx', hy', hz'] using hparent i.val
rw [block_eq_children leftLength rightLength parentShape sharing hleft h u
(hsupp h u hn)] at hblock
simpa only [Tensor.product, leftTensor, childRight, hh, ↓reduceIte, rightTensor]
using hblock
constructor
· apply Finset.prod_ne_zero_iff.mpr
intro i _
exact (mul_ne_zero_iff.mp (hhalves i)).1
· apply Finset.prod_ne_zero_iff.mpr
intro i _
exact (mul_ne_zero_iff.mp (hhalves i)).2
end MatrixMultiplication.JointPopulationMixedNonzero
end
end OAI