File size: 2,422 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 | import Mathlib
import OAI.Combinatorics.MatchingCount.Machines.TreeReach
import OAI.Combinatorics.MatchingCount.Machines.TreeStateTable
namespace OAI
namespace MatchingFPRAS.ExecutableLadder
open TreeTyped Polynomial
variable {I E : Type} [Codec I] [Codec E] [DecidableEq I] [Inhabited I] [LinearOrder E]
abbrev StateEnvelope (I E : Type) := List IΓFinset E
def normalizeState (x : StateEnvelope I EΓStateTable I (Finset E)) : StateTable I (Finset E) :=
x.1.1.map (fun i=>(i,lookup β
(x.2,i)β©x.1.2))
def normalizeStateRealizer (Eq : Realizer (fun x : IΓI=>decide (x.1=x.2)))
(EqE : Realizer (fun x : EΓE=>decide (x.1=x.2))) : Realizer (normalizeState (I:=I) (E:=E)) :=
(composition (pair identity first.fst) (mapWith (pair second
(composition (pair (composition (pair first.snd second) (lookupRealizer β
Eq)) first.fst.snd)
(finsetInter EqE))))).congr (fun _=>rfl)
lemma polynomial_normalizeState {Eq : Realizer (fun x : IΓI=>decide (x.1=x.2))}
{EqE : Realizer (fun x : EΓE=>decide (x.1=x.2))}
(hEq : PolynomialTime Eq) (hE : PolynomialTime EqE) : PolynomialTime (normalizeStateRealizer Eq EqE) := by
unfold normalizeStateRealizer Realizer.fst Realizer.snd
apply polynomial_congr
have := polynomial_lookup (β
: Finset E) hEq
tree_cost
omit [Inhabited I] in
lemma normalizeState_weight (keys : List I) (univ : Finset E) (s : StateTable I (Finset E)) :
weight (normalizeState ((keys,univ),s))β€(weight keys+1)*(weight univ+3) := by
induction keys with
| nil=>simp only [normalizeState,List.map_nil,weight_nil]; omega
| cons i keys ih=>
have hu : weight (lookup β
(s,i)β©univ)β€weight univ := weight_finset_subset Finset.inter_subset_right
change weight ((i,lookup β
(s,i)β©univ)::normalizeState ((keys,univ),s))β€_
rw [weight_cons,weight_prod,weight_cons]
nlinarith
omit [Codec I] [Codec E] [Inhabited I] in
lemma normalizeState_rep {Ξ© : Type} (keys : List I) (univ : Finset E) (e : Ξ©βFinset E)
(he : β a,e aβuniv) (s : IβΞ©) :
normalizeState ((keys,univ),stateRep keys (e β s))=stateRep keys (e β s) := by
unfold normalizeState stateRep
apply List.map_congr_left
intro i hi
change (i,lookup β
(stateRep keys (e β s),i)β©univ)=(i,e (s i))
rw [lookup_stateRep β
keys (e β s) i hi]
simp only [Function.comp_apply,Finset.inter_eq_left.mpr (he (s i))]
end MatchingFPRAS.ExecutableLadder
end OAI
|