*To*: Eddy Westbrook <westbrook at kestrel.edu>, USR Isabelle Mailinglist <isabelle-users at cl.cam.ac.uk>*Subject*: Re: [isabelle] Termination for ordinal-like datatypes*From*: Dmitriy Traytel <traytel at in.tum.de>*Date*: Tue, 15 Jul 2014 09:16:04 +0200*In-reply-to*: <8C5FE629-350B-4522-ADB4-623352324731@kestrel.edu>*References*: <8C5FE629-350B-4522-ADB4-623352324731@kestrel.edu>*User-agent*: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

Hi Eddy,

definition "sub ≡ {(x, Succ x) | x. True} ∪ {(f n, Limit f) | n f. True}" lemma subI[intro]: "(x, Succ x) ∈ sub" "(f n, Limit f) ∈ sub" unfolding sub_def by blast+ lemma wf_sub[simp]: "wf sub" proof (rule wfUNIVI) fix P x assume "∀x. (∀y. (y, x) ∈ sub ⟶ P y) ⟶ P x" then show "P x" unfolding sub_def by (induct x) blast+ qed Both of your functions can be then proved terminating via termination by (relation "sub <*lex*> sub") auto Dmitriy On 15.07.2014 03:08, Eddy Westbrook wrote:

Hi, I was wondering if someone could help me figure out an easy way to prove termination for functions over ordinal-like datatypes. What I mean by this is datatypes T where one of the constructors for T takes a function that returns type T. The classic one is the ordinals: datatype ord = Zero | Succ ord | Limit "(nat => ord)” My question is, what is the easiest and best way to write termination proofs for recursive functions over the type ord? Are there some mechanisms already available, or do I have to define my own inductive proposition or something similar? It looks like all the default mechanisms for proving termination rely on types that satisfy “size”, which ord does not because of the Limit constructor. For example, I want to define functions like these, which should be terminating: function ord_plus :: "ord => ord => ord" where "ord_plus x Zero = x" | "ord_plus x (Succ y) = Succ (ord_plus x y)" | "ord_plus x (Limit f) = Limit (\<lambda> n . ord_plus x (f n))" by pat_completeness auto function ord_leq :: "ord ⇒ ord ⇒ bool" where "ord_leq Zero x = True" | "ord_leq (Succ x) Zero = False" | "ord_leq (Succ x) (Succ y) = ord_leq x y" | "ord_leq (Succ x) (Limit f) = (\<exists> n. ord_leq (Succ x) (f n))" | "ord_leq (Limit f) y = (\<forall>n . ord_leq (f n) y)" by pat_completeness auto Thanks very much for any help or suggestions. -Eddy

**Follow-Ups**:**Re: [isabelle] Termination for ordinal-like datatypes***From:*Eddy Westbrook

**References**:**[isabelle] Termination for ordinal-like datatypes***From:*Eddy Westbrook

- Previous by Date: Re: [isabelle] Termination for ordinal-like datatypes
- Next by Date: [isabelle] newbie questions: theory for sums and Isar syntax
- Previous by Thread: Re: [isabelle] Termination for ordinal-like datatypes
- Next by Thread: Re: [isabelle] Termination for ordinal-like datatypes
- Cl-isabelle-users July 2014 archives indexes sorted by: [ thread ] [ subject ] [ author ] [ date ]
- Cl-isabelle-users list archive Table of Contents
- More information about the Cl-isabelle-users mailing list