isabelle - "invalid map function" when defining a corecursive tree -



isabelle - "invalid map function" when defining a corecursive tree -

i’m doing first experiments codatatype, i’m stuck rather early. started definition of branching, perchance infinite tree:

codatatype (lset: 'a) ltree = node (lnext : "'a ⇒ 'a ltree option")

and definitions work fine:

primcorec lempty :: "'a ltree" "lnext lempty = (λ _ . none)" primcorec single :: "'a ⇒ 'a ltree" "lnext (single x) = (λ _ . none)(x := lempty)"

but not work:

primcorec many :: "'a ⇒ 'a ltree" "lnext (many x) = (λ _ . none)(x := (many x))"

as error message

primcorec error: invalid map function in "[x ↦ many x]"

i work around writing

primcorec many :: "'a ⇒ 'a ltree" "lnext (many x) = (λ x'. if x' = x (many x) else none)"

which makes believe primcorec needs “know about” function update operator, similar how fun needs fundef_cong lemmas , inductive needs mono lemmas. exactly?

if codatatype recurses through other type constructors, primcorec expects recursive calls nested in map functions of these type constructors. in example, recursion goes through function type , alternative type, map functions op o , map_option. consequently, recursive phone call many should have form op o (map_option many). hence, next definition works:

primcorec many :: "'a ⇒ 'a ltree" "lnext (many x) = map_option many ∘ [x ↦ x]"

for convenience, primcorec supports few more syntactic input formats. in particular, map function function type can written using lambda abstractions. additionally, supports case distinctions , ifs. why sec version accepted. however, when @ generated definition many_def, see more complicated explicit map functions.

primcorec not suport registration of arbitrary functions, cannot utilize fun_upd in original form. primitive corecursion syntactical. maybe in future there corecursive counterpart function.

the map functions explained in tutorial on datatypes , in this paper.

isabelle corecursion

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -