[isabelle] Common monadic programming idioms and termination

Hi all,

I have a problem with a development that I am working on (in Isabelle
2015).  A slimmed down and simplified version of the problematic code
has been attached in a dedicated theory file to this e-mail with the
problem annotated with an (* XXX *) comment.

The problem arises when trying to prove termination of recursive
functions that follow a fairly natural monadic programming style,
namely recursively calling your function on a decreasing argument that
is produced by earlier monadic code, hence lambda-bound following a
bind.  Here, the termination machinery seems to generate proof
obligations that are not solveable, demanding one prove that an
arbitrary list is shorter (according to the measure) than a non-empty
list, like so:

âxs xa. xs â [] â length xa < length xs

Interestingly, HOL4's termination machinery also seems to behave
similarly, and with the help of Anthony Fox the issue has been
reported to Konrad Slind.

Does anybody have any suggestions on how to proceed other than
completely rewriting all of my monadic code?  The problematic code is
automatically generated, and comes from a rather large model, so I'd
rather not have to rewrite everything.

Many thanks for any help proffered,

Attachment: Strange_Termination.thy
Description: Binary data

This archive was generated by a fusion of Pipermail (Mailman edition) and MHonArc.