lemma case_maybe_case: "(case (case L of lnil → Nothing | x :@ xs → Just⋅(h⋅x⋅xs)) of Nothing → f | Just⋅(a, b) → g⋅a⋅b) = (case L of lnil → f | x :@ xs → g⋅(fst (h⋅x⋅xs))⋅(snd (h⋅x⋅xs)))" apply (cases L, simp_all) apply (case_tac "h⋅a⋅llist") apply simp done
lemma case_a2c_case_caseR: "(case a2c⋅w of lnil → f | x :@ xs → g⋅x⋅xs) = (case nextR⋅w of Nothing → f | Just⋅(x, r) → g⋅x⋅(a2c⋅r))" (is"?lhs = ?rhs") proof - have"?rhs = (case (case ldropWhile⋅(Λ x. SetMem⋅x⋅(exceptR⋅w))⋅(resultR⋅w) of lnil → Nothing | x :@ xs → Just⋅(x, R⋅xs⋅(exceptR⋅w))) of Nothing → f | Just⋅(x, r) → g⋅x⋅(a2c⋅r))" by (simp add: nextR_def) alsohave"… = (case ldropWhile⋅(Λ x. SetMem⋅x⋅(exceptR⋅w))⋅(resultR⋅w) of lnil → f | x :@ xs → g⋅x⋅(a2c⋅(R⋅xs⋅(exceptR⋅w))))" using case_maybe_case[where L="ldropWhile⋅(Λ x. SetMem⋅x⋅(exceptR⋅w))⋅(resultR⋅w)" and f=f and g="Λ x r. g⋅x⋅(a2c⋅r)"and h="Λ x xs. (x, R⋅xs⋅(exceptR⋅w))"] by simp alsohave"… = ?lhs" apply (simp add: a2c_def) apply (cases "resultR⋅w") apply simp_all apply (rule_tac p="SetMem⋅a⋅(exceptR⋅w)"in trE) apply simp_all apply (induct_tac llist) apply simp_all apply (rule_tac p="SetMem⋅aa⋅(exceptR⋅w)"in trE) apply simp_all done finallyshow"?lhs = ?rhs"by simp qed
lemma filter_filterR: "lfilter⋅(neg oo (Λ y. x =B y))⋅(a2c⋅r) = a2c⋅(filterR⋅x⋅r)" using filter_filter[where p="Tr.neg oo (Λ y. x =B y)"and q="Λ v. Tr.neg⋅(SetMem⋅v⋅(exceptR⋅r))"] unfolding a2c_def filterR_def by (cases r, simp_all add: SetMem_SetInsert TR_deMorgan)
text‹Apply worker/wrapper. Unlike Gill/Hutton, we manipulate the body of
worker into the right form then apply the lemma.›
definition
nub_body' :: "(R → Nat llist) → R → Nat llist"where "nub_body' ≡ Λ f r. case a2c⋅r of lnil → lnil | x :@ xs → x :@ f⋅(c2a⋅(lfilter⋅(neg oo (Λ y. x =B y))⋅xs))"
definition
nub_body'' :: "(R → Nat llist) → R → Nat llist"where "nub_body'' ≡ Λ f r. case nextR⋅r of Nothing → lnil | Just⋅(x, xs) → x :@ f⋅(c2a⋅(lfilter⋅(neg oo (Λ y. x =B y))⋅(a2c⋅xs)))"
lemma nub_body'_nub_body''_eq: "nub_body' = nub_body''" proof(rule cfun_eqI)+ fix f r show"nub_body'⋅f⋅r = nub_body''⋅f⋅r" unfolding nub_body'_def nub_body''_def using case_a2c_case_caseR[where f="lnil"and g="Λ x xs. x :@ f⋅(c2a⋅(lfilter⋅(Tr.neg oo (Λ y. x =B y))⋅xs))"and w="r"] by simp qed
definition
nub_body''' :: "(R → Nat llist) → R → Nat llist"where "nub_body''' ≡ (Λ f r. case nextR⋅r of Nothing → lnil | Just⋅(x, xs) → x :@ f⋅(filterR⋅x⋅xs))"
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.