File size: 3,909 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | import OAI.LinearAlgebra.MatrixMultiplication.Recovery.Staggering
import Mathlib.Algebra.BigOperators.Group.Finset.Basic
import Mathlib.Data.Fintype.Perm
namespace OAI
/-! Finite orbit symmetries, masks and exact recovery operations. -/
open scoped BigOperators
noncomputable section
namespace MatrixMultiplication.PhysicalOrders
open Staggering
abbrev PhysicalOrder := Equiv.Perm (Fin 3)
theorem card_physical_orders : Fintype.card PhysicalOrder = 6 := by
norm_num [PhysicalOrder, Fintype.card_perm, Nat.factorial_succ]
def placementAmount (amount : β) (_phi : PhysicalOrder) : β := amount / 6
theorem placementAmount_eq (amount : β) (phi psi : PhysicalOrder) :
placementAmount amount phi = placementAmount amount psi := rfl
theorem sum_placementAmount (amount : β) :
β phi : PhysicalOrder, placementAmount amount phi = amount := by
simp only [placementAmount, Finset.sum_const, Finset.card_univ,
card_physical_orders, nsmul_eq_mul]
norm_num
ring
theorem placement_has_unique_order (rho phi : PhysicalOrder) :
β! sigma : PhysicalOrder, rho.trans phi = sigma := by
refine β¨rho.trans phi, rfl, ?_β©
intro sigma hsigma
exact hsigma.symm
theorem sum_selected_placement (rho sigma : PhysicalOrder) (value : β) :
(β phi : PhysicalOrder, if rho.trans phi = sigma then value else 0) = value := by
classical
obtain β¨phi, hphi, huniqueβ© := physical_order_unique rho sigma
calc
_ = β psi : PhysicalOrder, if psi = phi then value else 0 := by
apply Finset.sum_congr rfl
intro psi _
have hiff : rho.trans psi = sigma β psi = phi := by
constructor
Β· exact hunique psi
Β· rintro rfl
exact hphi
simp only [hiff]
_ = value := by simp
variable {History : Type*} [Fintype History]
def aggregateCapacity (amount : History β β) (capacity : History β Capacity) : Capacity :=
fun i => β h, amount h * capacity h i
def perPhysicalOrderCapacity (amount : History β β) (capacity : History β Capacity)
(priority : History β PhysicalOrder) (sigma : PhysicalOrder) : Capacity := by
classical
exact fun i => β h, β phi : PhysicalOrder,
if (priority h).trans phi = sigma then amount h / 6 * capacity h i else 0
theorem perPhysicalOrderCapacity_apply (amount : History β β)
(capacity : History β Capacity) (priority : History β PhysicalOrder)
(sigma : PhysicalOrder) (i : Fin 3) :
perPhysicalOrderCapacity amount capacity priority sigma i =
(1 / 6 : β) * aggregateCapacity amount capacity i := by
classical
unfold perPhysicalOrderCapacity aggregateCapacity
simp only [sum_selected_placement]
rw [Finset.mul_sum]
apply Finset.sum_congr rfl
intro h _
ring
theorem perPhysicalOrderCapacity_eq (amount : History β β)
(capacity : History β Capacity) (priority : History β PhysicalOrder)
(sigma : PhysicalOrder) :
perPhysicalOrderCapacity amount capacity priority sigma =
fun i => (1 / 6 : β) * aggregateCapacity amount capacity i := by
funext i
exact perPhysicalOrderCapacity_apply amount capacity priority sigma i
theorem minCapacity_mul (a : Capacity) (r : β) (hr : 0 β€ r) :
minCapacity (fun i => r * a i) = r * minCapacity a := by
unfold minCapacity
rw [mul_min_of_nonneg _ _ hr, mul_min_of_nonneg _ _ hr]
theorem sum_physical_order_minima (amount : History β β)
(capacity : History β Capacity) (priority : History β PhysicalOrder) :
(β sigma : PhysicalOrder,
minCapacity (perPhysicalOrderCapacity amount capacity priority sigma)) =
minCapacity (aggregateCapacity amount capacity) := by
simp_rw [perPhysicalOrderCapacity_eq,
minCapacity_mul _ (1 / 6 : β) (by norm_num)]
simp only [Finset.sum_const, Finset.card_univ, card_physical_orders, nsmul_eq_mul]
norm_num
ring
end MatrixMultiplication.PhysicalOrders
end
end OAI
|