codatatype tree = Node (val: nat) (sub: "tree list")
corec (friend) tplus :: "tree \ tree \ tree" where"tplus t u = Node (val t + val u) (map (\(t', u'). tplus t' u') (zip (sub t) (sub u)))"
corec (friend) ttimes :: "tree \ tree \ tree" where"ttimes t u = Node (val t * val u)
(map (\<lambda>(t, u). tplus (ttimes t u) (ttimes t u)) (zip (sub t) (sub u)))"
corecursive primes :: "nat \ nat \ nat stream" where"primes m n =
(if (m = 0 \<and> n > 1) \<or> coprime m n then n \<lhd> primes (m * n) (n + 1) else primes m (n + 1))" apply (relation "measure (\(m, n). if n = 0 then 1 else if coprime m n then 0 else m - n mod m)") apply (auto simp: mod_Suc diff_less_mono2 intro: Suc_lessI elim!: not_coprimeE) apply (metis dvd_1_iff_1 dvd_eq_mod_eq_0 mod_0 mod_Suc mod_Suc_eq mod_mod_cancel) done
corec facC :: "nat \ nat \ nat \ nat stream" where"facC n a i = (if i = 0 then a \ facC (n + 1) 1 (n + 1) else facC n (a * i) (i - 1))"
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 ist noch experimentell.