@@ -117,53 +117,41 @@ open GenFFD.Header
117117open GenFFD.Body
118118open FFDState
119119
120- data SimpleFFD : FFDState → FFDAbstract.Input ffdAbstract → FFDAbstract.Output ffdAbstract → FFDState → Type where
121- SendIB : ∀ {s h b o} → SimpleFFD s (FFDAbstract.Send (ibHeader h) (just (ibBody b))) o (record s { outIBs = record {header = h; body = b} ∷ outIBs s})
122- SendEB : ∀ {s eb o} → SimpleFFD s (FFDAbstract.Send (ebHeader eb) nothing) o (record s { outEBs = eb ∷ outEBs s})
123- SendVS : ∀ {s vs o} → SimpleFFD s (FFDAbstract.Send (vHeader vs) nothing) o (record s { outVTs = vs ∷ outVTs s})
124-
125- BadSendIB : ∀ {s h o} → SimpleFFD s (FFDAbstract.Send (ibHeader h) nothing) o s
126- BadSendEB : ∀ {s h b o} → SimpleFFD s (FFDAbstract.Send (ebHeader h) (just b)) o s
127- BadSendVS : ∀ {s h b o} → SimpleFFD s (FFDAbstract.Send (vHeader h) (just b)) o s
128-
129- FetchIB : ∀ {s ib o} → SimpleFFD record s {inIBs = ib ∷ inIBs s} FFDAbstract.Fetch o s
130- EmptyIB : ∀ {s o} → SimpleFFD record s {inIBs = []} FFDAbstract.Fetch o s
131-
132- {-
133- FetchEB : ∀ {s eb o} → SimpleFFD record s {inEBs = eb ∷ inEBs s} FFDAbstract.Fetch o s
134- EmptyEB : ∀ {s o} → SimpleFFD record s {inEBs = []} FFDAbstract.Fetch o s
135-
136- FetchVT : ∀ {s x o} → SimpleFFD record s {inVTs = x ∷ inVTs s} FFDAbstract.Fetch o s
137- EmptyVT : ∀ {s o} → SimpleFFD record s {inVTs = []} FFDAbstract.Fetch o s
138- -}
120+ flushIns : FFDState → List (GenFFD.Header ⊎ GenFFD.Body)
121+ flushIns record { inIBs = ibs ; inEBs = ebs ; inVTs = vts } =
122+ flushIBs ibs ++ L.map (inj₁ ∘ ebHeader) ebs ++ L.map (inj₁ ∘ vHeader) vts
123+ where
124+ flushIBs : List InputBlock → List (GenFFD.Header ⊎ GenFFD.Body)
125+ flushIBs [] = []
126+ flushIBs (record {header = h; body = b} ∷ ibs) = inj₁ (ibHeader h) ∷ inj₂ (ibBody b) ∷ flushIBs ibs
139127
140- simple-total : ∀ {ffds i o} → ∃[ ffds' ] (SimpleFFD ffds i o ffds')
141- simple-total {ffd} { FFDAbstract.Send (ibHeader h) (just (ibBody b))} {o} = record ffd { outIBs = record {header = h; body = b} ∷ outIBs ffd} , SendIB
142- simple-total {ffd} { FFDAbstract.Send (ebHeader eb) nothing} {o} = record ffd { outEBs = eb ∷ outEBs ffd} , SendEB
143- simple-total {ffd} { FFDAbstract.Send (vHeader vs) nothing} {o} = record ffd { outVTs = vs ∷ outVTs ffd} , SendVS
128+ data SimpleFFD : FFDState → FFDAbstract.Input ffdAbstract → FFDAbstract.Output ffdAbstract → FFDState → Type where
129+ SendIB : ∀ {s h b} → SimpleFFD s ( FFDAbstract.Send (ibHeader h) (just (ibBody b))) FFDAbstract.SendRes ( record s { outIBs = record {header = h; body = b} ∷ outIBs s})
130+ SendEB : ∀ {s eb} → SimpleFFD s ( FFDAbstract.Send (ebHeader eb) nothing) FFDAbstract.SendRes ( record s { outEBs = eb ∷ outEBs s})
131+ SendVS : ∀ {s vs} → SimpleFFD s ( FFDAbstract.Send (vHeader vs) nothing) FFDAbstract.SendRes ( record s { outVTs = vs ∷ outVTs s})
144132
145- simple-total {ffd} { FFDAbstract.Send (ibHeader h) nothing} {o} = ffd , BadSendIB
146- simple-total {ffd} { FFDAbstract.Send (ebHeader eb ) (just b)} {o} = ffd , BadSendEB
147- simple-total {ffd} { FFDAbstract.Send (vHeader vs ) (just b)} {o} = ffd , BadSendVS
133+ BadSendIB : ∀ {s h} → SimpleFFD s ( FFDAbstract.Send (ibHeader h) nothing) FFDAbstract.SendRes s
134+ BadSendEB : ∀ {s h b} → SimpleFFD s ( FFDAbstract.Send (ebHeader h ) (just b)) FFDAbstract.SendRes s
135+ BadSendVS : ∀ {s h b} → SimpleFFD s ( FFDAbstract.Send (vHeader h ) (just b)) FFDAbstract.SendRes s
148136
149- simple-total {record {inIBs = record {header = h; body = b} ∷ i; inEBs = e; inVTs = v}} {FFDAbstract.Fetch} {o} = record {inIBs = i; inEBs = e; inVTs = v} , FetchIB
150- simple-total {record {inIBs = []; inEBs = e; inVTs = v}} {FFDAbstract.Fetch} {o} = record {inIBs = []; inEBs = e; inVTs = v} , EmptyIB
137+ Fetch : ∀ {s} → SimpleFFD s FFDAbstract.Fetch (FFDAbstract.FetchRes (flushIns s)) (record s { inIBs = [] ; inEBs = [] ; inVTs = [] })
151138
152- {-
153- simple-total {record {inIBs = i; inEBs = eb ∷ e; inVTs = v}} {FFDAbstract.Fetch} {o} = record {inIBs = i; inEBs = e; inVTs = v} , FetchEB
154- simple-total {record {inIBs = i; inEBs = []; inVTs = v}} {FFDAbstract.Fetch} {o} = record {inIBs = i; inEBs = []; inVTs = v} , EmptyEB
139+ simple-total : ∀ {s h b} → ∃[ s' ] (SimpleFFD s (FFDAbstract.Send h b) FFDAbstract.SendRes s')
140+ simple-total {s} {ibHeader h} {just (ibBody b)} = record s { outIBs = record {header = h; body = b} ∷ outIBs s} , SendIB
141+ simple-total {s} {ebHeader eb} {nothing} = record s { outEBs = eb ∷ outEBs s} , SendEB
142+ simple-total {s} {vHeader vs} {nothing} = record s { outVTs = vs ∷ outVTs s} , SendVS
155143
156- simple-total {record {inIBs = i; inEBs = e; inVTs = x ∷ v}} {FFDAbstract.Fetch} {o} = record {inIBs = i; inEBs = e; inVTs = v} , FetchVT
157- simple-total {record {inIBs = i; inEBs = e; inVTs = []}} {FFDAbstract.Fetch} {o } = record {inIBs = ; inEBs = e; inVTs = []} , EmptyVT
158- -}
144+ simple-total {s} {ibHeader h} {nothing} = s , BadSendIB
145+ simple-total {s} {ebHeader eb} {just _ } = s , BadSendEB
146+ simple-total {s} {vHeader vs} {just _} = s , BadSendVS
159147
160148d-FFDFunctionality : FFDAbstract.Functionality ffdAbstract
161149d-FFDFunctionality =
162150 record
163151 { State = FFDState
164152 ; initFFDState = record { inIBs = []; inEBs = []; inVTs = []; outIBs = []; outEBs = []; outVTs = [] }
165153 ; _-⟦_/_⟧⇀_ = SimpleFFD
166- ; FFD-total = simple-total
154+ ; FFD-Send- total = simple-total
167155 }
168156
169157open import Leios.Voting public
0 commit comments