theory Simple_Nesting imports"HOL-Library.BNF_Corec" begin
subsection‹Corecursion via Map Functions›
consts
g :: 'a
g' :: 'a
g'' :: 'a
h :: 'a
h' :: 'a
q :: 'a
q' :: 'a
codatatype tree =
Node nat "tree list"
(* a direct, intuitive way to define a function *)
corec k0 where "k0 x = Node (g x) (map (\y. if q y then g' y else k0 (h' y :: 'a)) (h (x :: 'a) :: nat list))"
(* another way -- this one is perhaps less intuitive but more systematic *)
corec k0' where "k0' x = Node (g x) (map (\z. case z of Inl t \ t | Inr (x' :: 'a) \ k0' x')
(map (λy. if q y then Inl (g' y) else Inr (h' y)) (h (x :: 'a) :: nat list)))"
corec k1' :: "nat \ tree" where "k1' x = Node (g x) (map (\z. case z of Inl t \ t | Inr x' \ k1' x')
(map (λy. Inr (h' y)) (h x :: nat list)))"
corec k2 :: "nat \ tree"where "k2 x = Node (g x) (map g' (h x :: nat list))"
corec k2' :: "nat \ tree" where "k2' x = Node (g x) (map (\z. case z of Inl t \ t | Inr (x' :: nat) \ k2' x')
(map (λy. Inl (g' y)) (h x :: nat list)))"
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.