Isabelle Real Datatype - Malformed definition: Non-constructor pattern not allowed in sequential mode

社会主义新天地 提交于 2019-12-24 05:59:36

问题


I am creating a function of the form

y(t+h) = y(t) + h/y(t)

where y(0) = 1

fun y :: "real ⇒ real" where "y 0 = Suc(0)"| "y(t+h) = y(t) + h*(1/y(t))"

Unfortunately, I am getting an error

Malformed definition: Non-constructor pattern not allowed in sequential mode.

y 0 = real (Suc 0)

Googling showed me that I am not adhering to some constructor pattern of real datatype but I am not able to find what the pattern is and how I should change my function.


回答1:


Real numbers are not an algebraic datatype, so you can't pattern match on them with fun. You have to use either ‘normal’ equational definitions or some of the more advanced features of the function package, but that also makes things more difficult since you have to prove some well-definedness properties yourself.

Also, the Suc 0 on the right-hand side is a natural number, not a real number. (just write 1 instead)

However, the biggest problem with your definition is that the way you have written it down is too informal. I don't understand what it means even informally.

  • What assumptions do you have about h?
  • For what t should that second equation be valid?
  • What happens when you put in a negative value for t? (the way you've written it: non-termination)
  • What happens when 0 < t < h?

Once you have a mathematically precise specification for the function you want to define, you can probably write it down without too much of a headache with the function command



来源:https://stackoverflow.com/questions/44238481/isabelle-real-datatype-malformed-definition-non-constructor-pattern-not-allow

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!