cfahlgren1/math / lean /OAI /Algebra /DepthFive /CoefficientDescent.lean
cfahlgren1's picture
download
raw
7.03 kB
import OAI.Algebra.DepthFive.CoefficientSupport
namespace OAI
noncomputable section
universe u v
namespace Problem335
variable {K : Type u} [Field K] {n : ℕ}
def restrictLeaf (c : Depth5Circuit K n) (i : Fin c.leafCount) :
D5Leaf (circuitCoefficientField c) n :=
match h : c.leaves i with
| .scalar a => .scalar ⟨a, leaf_scalar_mem c i a h⟩
| .variable x => .variable x
@[simp] theorem restrictLeaf_degree (c : Depth5Circuit K n) (i : Fin c.leafCount) :
d5LeafDegree (restrictLeaf c i) = d5LeafDegree (c.leaves i) := by
unfold restrictLeaf
split <;> simp_all [d5LeafDegree]
def restrictWeightedInputs {ι : Type v} (S : Subfield K) (l : List (K × ι))
(h : ∀ e ∈ l, e.1 ∈ S) : List (S × ι) :=
l.attach.map fun e => (⟨e.val.1, h e.val e.property⟩, e.val.2)
@[simp] theorem restrictWeightedInputs_eq_nil_iff {ι : Type v} (S : Subfield K)
(l : List (K × ι)) (h : ∀ e ∈ l, e.1 ∈ S) :
restrictWeightedInputs S l h = [] ↔ l = [] := by
simp [restrictWeightedInputs]
@[simp] theorem restrictWeightedInputs_map_coe {ι : Type v} (S : Subfield K)
(l : List (K × ι)) (h : ∀ e ∈ l, e.1 ∈ S) :
(restrictWeightedInputs S l h).map (fun e => ((e.1 : K), e.2)) = l := by
simp [restrictWeightedInputs, List.map_map, Function.comp_def, List.attach_map_subtype_val]
/-- Restrict a circuit to the subfield generated by its occurring coefficients. -/
def restrictCircuit (c : Depth5Circuit K n) : Depth5Circuit (circuitCoefficientField c) n where
leafCount := c.leafCount
leaves := restrictLeaf c
bottomCount := c.bottomCount
bottomInputs i := restrictWeightedInputs _ (c.bottomInputs i) (bottom_coeff_mem c i)
bottomDegree := c.bottomDegree
bottomHomogeneous := by
intro i e he
rcases List.mem_map.mp he with ⟨a, ha, rfl⟩
simpa using c.bottomHomogeneous i a.val a.property
bottomEmpty := by
intro i h
exact c.bottomEmpty i ((restrictWeightedInputs_eq_nil_iff _ _ _).mp h)
lowerCount := c.lowerCount
lowerInputs := c.lowerInputs
middleCount := c.middleCount
middleInputs i := restrictWeightedInputs _ (c.middleInputs i) (middle_coeff_mem c i)
middleDegree := c.middleDegree
middleHomogeneous := by
intro i e he
rcases List.mem_map.mp he with ⟨a, ha, rfl⟩
exact c.middleHomogeneous i a.val a.property
middleEmpty := by
intro i h
exact c.middleEmpty i ((restrictWeightedInputs_eq_nil_iff _ _ _).mp h)
upperCount := c.upperCount
upperInputs := c.upperInputs
outputInputs := restrictWeightedInputs _ c.outputInputs (output_coeff_mem c)
outputDegree := c.outputDegree
outputHomogeneous := by
intro e he
rcases List.mem_map.mp he with ⟨a, ha, rfl⟩
exact c.outputHomogeneous a.val a.property
outputEmpty := by
intro h
exact c.outputEmpty ((restrictWeightedInputs_eq_nil_iff _ _ _).mp h)
@[simp] theorem circuitSize_restrictCircuit (c : Depth5Circuit K n) :
circuitSize (restrictCircuit c) = circuitSize c := rfl
@[simp] theorem map_restrictLeaf_value (c : Depth5Circuit K n) (i : Fin c.leafCount) :
MvPolynomial.map (circuitCoefficientField c).subtype (d5LeafValue (restrictLeaf c i)) =
d5LeafValue (c.leaves i) := by
unfold restrictLeaf
split <;> simp_all [d5LeafValue]
theorem restrictWeightedInputs_map_eval {ι : Type v} {β : Type*} (S : Subfield K)
(l : List (K × ι)) (h : ∀ e ∈ l, e.1 ∈ S) (f : K × ι → β) :
(restrictWeightedInputs S l h).map (fun e => f ((e.1 : K), e.2)) = l.map f := by
simpa only [List.map_map, Function.comp_def] using
congrArg (List.map f) (restrictWeightedInputs_map_coe S l h)
@[simp] theorem map_bottomValue_restrictCircuit (c : Depth5Circuit K n)
(i : Fin c.bottomCount) :
MvPolynomial.map (circuitCoefficientField c).subtype
(bottomValue (restrictCircuit c) i) = bottomValue c i := by
simp only [bottomValue, map_list_sum, List.map_map, Function.comp_def, map_mul,
MvPolynomial.map_C]
change (List.map (fun e => MvPolynomial.C (e.1 : K) *
MvPolynomial.map (circuitCoefficientField c).subtype
(d5LeafValue (restrictLeaf c e.2)))
(restrictWeightedInputs _ (c.bottomInputs i) (bottom_coeff_mem c i))).sum = _
simp only [map_restrictLeaf_value]
exact congrArg List.sum (restrictWeightedInputs_map_eval _ _ _
(fun e : K × Fin c.leafCount => MvPolynomial.C e.1 * d5LeafValue (c.leaves e.2)))
@[simp] theorem map_lowerValue_restrictCircuit (c : Depth5Circuit K n)
(i : Fin c.lowerCount) :
MvPolynomial.map (circuitCoefficientField c).subtype
(lowerValue (restrictCircuit c) i) = lowerValue c i := by
simp only [lowerValue, map_list_prod, List.map_map, Function.comp_def]
change (List.map (fun j => MvPolynomial.map (circuitCoefficientField c).subtype
(bottomValue (restrictCircuit c) j)) (c.lowerInputs i)).prod = _
exact congrArg List.prod (List.map_congr_left
(fun index _ => map_bottomValue_restrictCircuit c index))
@[simp] theorem map_middleValue_restrictCircuit (c : Depth5Circuit K n)
(i : Fin c.middleCount) :
MvPolynomial.map (circuitCoefficientField c).subtype
(middleValue (restrictCircuit c) i) = middleValue c i := by
simp only [middleValue, map_list_sum, List.map_map, Function.comp_def, map_mul,
MvPolynomial.map_C]
change (List.map (fun e => MvPolynomial.C (e.1 : K) *
MvPolynomial.map (circuitCoefficientField c).subtype
(lowerValue (restrictCircuit c) e.2))
(restrictWeightedInputs _ (c.middleInputs i) (middle_coeff_mem c i))).sum = _
simp only [map_lowerValue_restrictCircuit]
exact congrArg List.sum (restrictWeightedInputs_map_eval _ _ _
(fun e : K × Fin c.lowerCount => MvPolynomial.C e.1 * lowerValue c e.2))
@[simp] theorem map_upperValue_restrictCircuit (c : Depth5Circuit K n)
(i : Fin c.upperCount) :
MvPolynomial.map (circuitCoefficientField c).subtype
(upperValue (restrictCircuit c) i) = upperValue c i := by
simp only [upperValue, map_list_prod, List.map_map, Function.comp_def]
change (List.map (fun j => MvPolynomial.map (circuitCoefficientField c).subtype
(middleValue (restrictCircuit c) j)) (c.upperInputs i)).prod = _
exact congrArg List.prod (List.map_congr_left
(fun index _ => map_middleValue_restrictCircuit c index))
@[simp] theorem map_circuitValue_restrictCircuit (c : Depth5Circuit K n) :
MvPolynomial.map (circuitCoefficientField c).subtype
(circuitValue (restrictCircuit c)) = circuitValue c := by
simp only [circuitValue, map_list_sum, List.map_map, Function.comp_def, map_mul,
MvPolynomial.map_C]
change (List.map (fun e => MvPolynomial.C (e.1 : K) *
MvPolynomial.map (circuitCoefficientField c).subtype
(upperValue (restrictCircuit c) e.2))
(restrictWeightedInputs _ c.outputInputs (output_coeff_mem c))).sum = _
simp only [map_upperValue_restrictCircuit]
exact congrArg List.sum (restrictWeightedInputs_map_eval _ _ _
(fun e : K × Fin c.upperCount => MvPolynomial.C e.1 * upperValue c e.2))
end Problem335
end
end OAI

Xet Storage Details

Size:
7.03 kB
·
Xet hash:
d7fd7e520d7e67ec47549df2750fa5bb876f494c3a38039234fa91abc5010579

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.