theory FunTerm imports Main begin function tst1 :: "nat \ nat" and tst2 :: "nat \ nat" where "tst1 n = (tst2 n) + 1" | "tst2 n = n + 1" by pat_completeness auto fun tstMeasure :: "nat + nat => nat" where "tstMeasure n = (case n of Inl n1 \ 1 | Inr n2 \ 0 )" termination tst1 apply(relation "measure tstMeasure") apply(auto) done function tst1' :: "nat \ nat" and tst2' :: "nat \ nat" and tst3' :: "nat \ nat" where "tst1' n = (tst2' n) + 1" | "tst2' n = (tst3' n) + 1" | "tst3' n = n + 1" by pat_completeness auto fun tstMeasure' :: "nat + nat + nat => nat" where "tstMeasure' n = (case n of Inl n1 \ 2 | Inr n1 \ (case n1 of Inl n2 \ 1 | Inr n2 \ 0 ) )" termination tst1' apply(relation "measure tstMeasure'") apply(auto) done function t1 :: "nat \ nat" and t2 :: "nat \ nat" and t3 :: "nat \ nat" and t4 :: "nat \ nat" where "t1 n = (t2 n) + 1" | "t2 n = (t3 n) + 1" | "t3 n = (t4 n) + 1" | "t4 n = n + 1" by pat_completeness auto fun tMeasure :: "nat + nat + nat + nat \ nat" where "tMeasure v = (case v of Inl x \ 3 | Inr x \ (case x of Inl y \ 2 | Inr y \ (case y of Inl z \ 1 | Inr z \ 0 ) ) )" termination t1 apply(relation "measure tMeasure") end