File size: 2,522 Bytes
0dd3af4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import Mathlib
import OAI.Computability.FiniteCompiler.Effectivity
import OAI.Computability.FiniteCompiler.Selectors
import OAI.GroupTheory.BooneHigman.Basic
import OAI.GroupTheory.SimpleOvergroups.ArrayNames
import OAI.GroupTheory.SimpleOvergroups.CanonicalNames

namespace OAI


namespace SimpleFInftyOvergroups.EffectiveNames.Array
open FiniteAlgebraicEnvelopes
noncomputable section
open scoped Classical
variable {A X J D : Type*} [AddCommMonoid D] [Primcodable A] [Primcodable X] [Primcodable J]
  (coeff : A → D)

def collect (f : X → Part J) (p : Name A X) : Part (Name A J) :=
  Effect.traverse (fun a => (f a.2).map (fun k => (a.1,k))) p

def collectedKey (f : X → Part J) (p : Name A X) : Part ℕ :=
  (collect f p).map (key (value coeff id))

omit [Primcodable A] [Primcodable X] [Primcodable J] in
theorem collect_full (f : X → Part J) (g : X → J) (p : Name A X)
    (h : ∀ a ∈ p, g a.2 ∈ f a.2) :
    p.map (fun a => (a.1,g a.2)) ∈ collect f p := by
  apply FiniteAlgebraicEnvelopes.Bootstrap.Search.traverse_map
  intro a ha
  exact Part.mem_map _ (h a ha)

omit [Primcodable X] in
theorem collectedKey_full (hc : Function.Surjective coeff) (f : X → Part J)
    {K : Type*} (index : X → K) (g : K → J) (p : Name A X)
    (h : ∀ a ∈ p, g (index a.2) ∈ f a.2) :
    semanticKey (value coeff id) (value_surjective coeff id hc Function.surjective_id)
      (Finsupp.mapDomain g (value coeff index p)) ∈ collectedKey coeff f p := by
  rw [← value_map_index coeff index (g ∘ index) id g (fun _ => rfl) p,
    semanticKey_value]
  exact Part.mem_map _ (collect_full f (g ∘ index) p h)

variable {P : Type*} [Primcodable P] {f : P → X → Part J}

theorem partrec_collect (hf : Partrec₂ f) :
    Partrec₂ (fun p : P => (collect (f p) : Name A X → Part (Name A J))) := by
  have hc : Partrec₂ (fun (p : P) (a : A × X) =>
      (f p a.2).map (fun k => (a.1,k))) := by
    exact ((hf.comp Computable.fst (Computable.snd.comp Computable.snd)).map
      ((Computable.fst.comp (Computable.snd.comp Computable.fst)).pair Computable.snd).to₂).to₂
  exact Effect.partrec_traverse_parameter hc

theorem partrec_collectedKey (heq : ComputablePred
    (fun p : Name A J × Name A J => value coeff id p.1 = value coeff id p.2))
    (hf : Partrec₂ f) : Partrec₂ (fun p : P => collectedKey coeff (f p)) := by
  exact (partrec_collect hf).map (((computable_key (value coeff id) heq).comp Computable.snd).to₂)

end
end SimpleFInftyOvergroups.EffectiveNames.Array

end OAI