File size: 3,193 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 | import OAI.NumberTheory.TwoPoint.Circuits.CircuitAssignmentUpdates
namespace OAI
/-! Complete query blocks along a canonical DNF path. A prefix of a path is
enough for the switching encoding; the final Boolean answer is irrelevant. -/
namespace TwoPointCorrelations
open Finset
open scoped Classical
structure DNFQueryBlock (n : β) where
term : CubeTerm n
queried : Finset (Fin n)
answer : BooleanCube n
namespace DNFQueryBlock
def support {n : β} : List (DNFQueryBlock n) β Finset (Fin n)
| [] => β
| b :: bs => b.queried βͺ support bs
def length {n : β} : List (DNFQueryBlock n) β β
| [] => 0
| b :: bs => b.queried.card + length bs
def image {n : β} : PartialAssignment n β List (DNFQueryBlock n) β PartialAssignment n
| Ο, [] => Ο
| Ο, b :: bs => image (Ο.assign b.queried b.term.value) bs
end DNFQueryBlock
inductive CanonicalDNFWalk {n : β} :
List (CubeTerm n) β PartialAssignment n β List (DNFQueryBlock n) β Prop
| nil (F Ο) : CanonicalDNFWalk F Ο []
| skip {C F Ο bs} (hC : Β¬ C.Compatible Ο) (h : CanonicalDNFWalk F Ο bs) :
CanonicalDNFWalk (C :: F) Ο bs
| step {C F Ο bs} (x : BooleanCube n) (hC : C.Compatible Ο)
(hne : (C.live Ο).Nonempty) (h : CanonicalDNFWalk F (Ο.assign (C.live Ο) x) bs) :
CanonicalDNFWalk (C :: F) Ο (β¨C, C.live Ο, xβ© :: bs)
namespace CanonicalDNFWalk
lemma support_subset_free {n : β} {F : List (CubeTerm n)} {Ο : PartialAssignment n}
{bs : List (DNFQueryBlock n)} (h : CanonicalDNFWalk F Ο bs) :
DNFQueryBlock.support bs β Ο.free := by
induction h with
| nil => simp [DNFQueryBlock.support]
| skip _ _ ih => exact ih
| @step C F Ο bs x _ _ _ ih =>
intro i hi
rcases mem_union.mp hi with hi | hi
Β· exact C.live_subset_free Ο hi
Β· have hh := ih hi
rw [PartialAssignment.free_assign] at hh
exact (mem_sdiff.mp hh).1
lemma head_disjoint_tail {n : β} {C : CubeTerm n} {F : List (CubeTerm n)}
{Ο : PartialAssignment n} {bs : List (DNFQueryBlock n)} (x : BooleanCube n)
(h : CanonicalDNFWalk F (Ο.assign (C.live Ο) x) bs) :
Disjoint (C.live Ο) (DNFQueryBlock.support bs) := by
apply Finset.disjoint_left.mpr
intro i hi htail
have hh := h.support_subset_free htail
rw [PartialAssignment.free_assign] at hh
exact (mem_sdiff.mp hh).2 hi
lemma length_eq_card_support {n : β} {F : List (CubeTerm n)}
{Ο : PartialAssignment n} {bs : List (DNFQueryBlock n)}
(h : CanonicalDNFWalk F Ο bs) :
DNFQueryBlock.length bs = (DNFQueryBlock.support bs).card := by
induction h with
| nil => simp [DNFQueryBlock.length, DNFQueryBlock.support]
| skip _ _ ih => exact ih
| @step C F Ο bs x _ _ h ih =>
simp only [DNFQueryBlock.length, DNFQueryBlock.support]
rw [card_union_of_disjoint (head_disjoint_tail x h), ih]
lemma length_le_dimension {n : β} {F : List (CubeTerm n)}
{Ο : PartialAssignment n} {bs : List (DNFQueryBlock n)}
(h : CanonicalDNFWalk F Ο bs) : DNFQueryBlock.length bs β€ n := by
rw [h.length_eq_card_support]
exact (card_le_card (subset_univ _)).trans_eq (by simp)
end CanonicalDNFWalk
end TwoPointCorrelations
end OAI
|