File size: 3,915 Bytes
97c3405 | 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 | import OAI.Combinatorics.ContingencyTables.Machines.CanonicalInitialEncoding
import OAI.Combinatorics.ContingencyTables.Counting.CompanionInitialDraw
import OAI.Combinatorics.ContingencyTables.Counting.CompanionOrderedProposal
namespace OAI
/-! # A common explicit encoding for initialization and proposals
Cells follow `cellEnum`, their copies follow increasing finite indices,
and each copy contributes its false and true coordinates consecutively.
The polynomial initializer computes exactly this encoding of the actual
initial draw. The same order may therefore be used by the proposal scan.
-/
namespace ContingencyTables.CompanionCanonicalEncoding
open CommonBasesFPRAS TwoLiftStates CompanionFactorialApplication
open InitialTransversals InitialFactorialBits CompanionInitialDraw
open CompanionArithmeticProposal CompanionOrderedProposal
open scoped BigOperators Classical
noncomputable section
variable {I J : Type} [Fintype I] [Fintype J]
def copyEquiv (A : Instance I J) : Labels A ≃ Copy (cellCapacity A) :=
Equiv.sigmaCongrLeft' (cellEnum A)
def pairEquiv (A : Instance I J) : (Labels A×Bool) ≃ (Copy (cellCapacity A)×Bool) :=
Equiv.prodCongr (copyEquiv A) (Equiv.refl Bool)
def coordinateOrder (A : Instance I J) : (Labels A×Bool) ≃
Fin (CanonicalInitialEncoding.pairOrder (cellCapacity A)).length :=
(pairEquiv A).trans (CanonicalInitialEncoding.coordinateEquiv (cellCapacity A))
lemma encodeSet_reindex (A : Instance I J) (S : Set (Labels A×Bool)) :
encodeSet (coordinateOrder A) S=
encodeSet (CanonicalInitialEncoding.coordinateEquiv (cellCapacity A))
((pairEquiv A).symm ⁻¹' S) := rfl
/-- Reindexing the physical initial draw gives the independent cell
choices used by the actual list initializer. -/
lemma initial_preimage (A : Instance I J) (B : ℕ)
(bits : Fin (initialBits A B) → Bool) :
(pairEquiv A).symm ⁻¹' (draw A B bits).val.val=
encode (cellCapacity A) (drawChoices (cellCapacity A) B bits) := by
ext p
rcases p with ⟨⟨i,k⟩,side⟩
have hc := Equiv.piCongrLeft'_symm_apply_apply
(fun s : SmallCell A => Finset (Fin (A.b s.val.1 s.val.2)))
(cellEnum A) (drawChoices (cellCapacity A) B bits) i
cases side
· change k∈(choiceEquiv (fun s : SmallCell A => A.b s.val.1 s.val.2)
(cellEnum A) (drawChoices (cellCapacity A) B bits)) ((cellEnum A).symm i) ↔
k∈drawChoices (cellCapacity A) B bits i
exact Iff.of_eq (congrArg (fun S => k∈S) hc)
· change k∉(choiceEquiv (fun s : SmallCell A => A.b s.val.1 s.val.2)
(cellEnum A) (drawChoices (cellCapacity A) B bits)) ((cellEnum A).symm i) ↔
k∉drawChoices (cellCapacity A) B bits i
exact Iff.of_eq (congrArg (fun S => k∉S) hc)
/-- The polynomial binary initializer emits precisely the code of the
literal `PlainIndex` output with its distributional error bound. -/
theorem initialCode_eq (A : Instance I J) (B : ℕ) (hB : 0<B)
(bits : Fin (initialBits A B) → Bool) :
CanonicalInitialEncoding.initialCode ((List.ofFn (cellCapacity A),B),List.ofFn bits)=
encodeSet (coordinateOrder A) (draw A B bits).val.val := by
rw [encodeSet_reindex,initial_preimage]
exact CanonicalInitialEncoding.initialCode_ofFn (cellCapacity A) B hB bits
/-- The canonical initializer encoding can be fed directly to an
arithmetic proposal with the same dyadic transition law. -/
theorem canonicalProposal_law (A : Instance I J) (S : CompanionBooleanPhase.State A) :
FirstSuccess.mapLaw
(FirstSuccess.uniformLaw (α := Fin (CompanionBooleanPhase.proposalBits A) → Bool))
(orderedProposal A (coordinateOrder A) S)=
FirstSuccess.mapLaw
(FirstSuccess.uniformLaw (α := Fin (CompanionBooleanPhase.proposalBits A) → Bool))
(CompanionBooleanPhase.proposal A S) :=
orderedProposal_law A (coordinateOrder A) S
end
end ContingencyTables.CompanionCanonicalEncoding
end OAI
|