theory TypesInductifs imports Main begin datatype nat = Z | S nat datatype 'a list = nil | cons 'a "'a list" datatype 'a tree = leaf | node 'a "'a tree" "'a tree" datatype ('a,'b) itree = ileaf | inode 'a "'b => ('a,'b) itree" (* datatype E = C E *) (* TypesInductifs.nat.induct: ?P Z \ (\x. ?P x \ ?P (S x)) \ ?P ?nat TypesInductifs.list.induct: ?P nil \ (\x1 x2. ?P x2 \ ?P (cons x1 x2)) \ ?P ?list TypesInductifs.tree.induct: ?P leaf \ (\x1 x2 x3. ?P x2 \ ?P x3 \ ?P (node x1 x2 x3)) \ ?P ?tree TypesInductifs.itree.induct: ?P ileaf \ (\x1 x2. (\x2a. x2a \ range x2 \ ?P x2a) \ ?P (inode x1 x2 x3)) \ ?P ?itree *) fun natR (* :: "'x \ (nat \ 'x \ 'x) \ nat \ 'x" *) where "natR f g Z = f" | "natR f g (S p) = g p (natR f g p)" fun listR where "listR f g nil = f" | "listR f g (cons a p) = g a p (listR f g p)" fun treeR where "treeR f g leaf = f" | "treeR f g (node a l r) = g a l r (treeR f g l) (treeR f g r)" (* pas accepté avec fun *) primrec itreeR where "itreeR f g ileaf = f" | "itreeR f g (inode a F) = g a F (\ x. itreeR f g (F x))" term itreeR end