File size: 3,376 Bytes
2c7d975 | 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 | import OAI.Algebra.DepthFive.IndexedCircuit
import OAI.Algebra.DepthFive.UpperBlockData
namespace OAI
noncomputable section
namespace Problem335.BlockData
variable {n : ℕ}
theorem middleInputs_empty_degree (K : Type*) [One K]
(blocks : List (List (Fin n))) (m : Middle blocks)
(h : middleInputs K blocks m = []) : middleDegree blocks m = 0 := by
by_cases hb : blocks.get m.1 = []
· change (blocks.get m.1).length = 0
rw [hb]
rfl
· have hc := congrArg List.length h
simp only [middleInputs, List.length_ofFn, List.length_nil] at hc
have hp := matrixEntryPaths_length (blocks.get m.1) hb m.2.1 m.2.2
have hn : 0 < n := Nat.zero_lt_of_lt m.2.1.isLt
have hpos : 0 < (paths blocks m).length := by
rw [paths, hp, Fintype.card_fin]
exact Nat.pow_pos hn
omega
theorem outputInputs_empty_degree (K : Type*) [One K]
(blocks : List (List (Fin n))) (z : Fin n)
(h : outputInputs K blocks z = []) : (blocks.map List.length).sum = 0 := by
by_cases hb : blocks = []
· simp [hb]
· have hc := congrArg List.length h
simp only [outputInputs, List.length_ofFn, List.length_nil] at hc
have hp := matrixEntryPaths_length (List.finRange blocks.length)
(by simpa using hb) z z
have hn : 0 < n := Nat.zero_lt_of_lt z.isLt
have hpos : 0 < (upperPaths blocks z).length := by
rw [upperPaths, hp, Fintype.card_fin]
exact Nat.pow_pos hn
omega
/-- The actual homogeneous five-layer block-expansion circuit, before finite reindexing. -/
def indexedCircuit (K : Type*) [CommSemiring K]
(blocks : List (List (Fin n))) (z : Fin n) :
IndexedDepth5Circuit K n
(Fin n × Fin n × Fin n) (Fin n × Fin n × Fin n)
(Lower blocks) (Middle blocks) (Upper blocks z) where
leaves := D5Leaf.variable
bottomInputs v := [(1, v)]
bottomDegree _ := 1
bottomHomogeneous := by
intro i entry h
simp only [List.mem_singleton] at h
subst entry
rfl
bottomEmpty := by simp
lowerInputs := lowerInputs blocks
middleInputs := middleInputs K blocks
middleDegree := middleDegree blocks
middleHomogeneous := by
intro m entry h
simpa using middleInputs_homogeneous K blocks m entry h
middleEmpty := middleInputs_empty_degree K blocks
upperInputs := upperInputs blocks z
outputInputs := outputInputs K blocks z
outputDegree := (blocks.map List.length).sum
outputHomogeneous := by
intro entry _
exact upperInputs_degree blocks z entry.2
outputEmpty := outputInputs_empty_degree K blocks z
/-- The qualified `Fin`-indexed circuit produced by block expansion. -/
def circuit (K : Type*) [CommSemiring K]
(blocks : List (List (Fin n))) (z : Fin n) : Depth5Circuit K n :=
(indexedCircuit K blocks z).toDepth5Circuit
@[simp] theorem circuit_outputDegree (K : Type*) [CommSemiring K]
(blocks : List (List (Fin n))) (z : Fin n) :
(circuit K blocks z).outputDegree = (blocks.map List.length).sum := rfl
theorem circuit_size (K : Type*) [CommSemiring K]
(blocks : List (List (Fin n))) (z : Fin n) :
circuitSize (circuit K blocks z) = 2 * n ^ 3 +
Fintype.card (Lower blocks) + Fintype.card (Middle blocks) +
Fintype.card (Upper blocks z) + 1 := by
rw [circuit, IndexedDepth5Circuit.circuitSize_toDepth5Circuit]
simp only [Fintype.card_prod, Fintype.card_fin]
ring
end Problem335.BlockData
end
end OAI
|