I have the following isabelle code snippet:
type_synonym vname = string
datatype aexp = N int | V vname | Plus aexp aexp
fun full_plus :: "aexp ⇒ aexp ⇒ aexp" where
"full_plus (N n⇩1) (N n⇩2) = N (n⇩1+n⇩2)" |
"full_plus (N n⇩1) (Plus (N n⇩2) a) = (Plus (N (n⇩1+n⇩2)) a)" |
"full_plus (N n⇩1) (Plus a (N n⇩2)) = (Plus (N (n⇩1+n⇩2)) a)" |
"full_plus (Plus (N n⇩1) a) (N n⇩2) = (Plus (N (n⇩1+n⇩2)) a)" |
"full_plus (Plus a (N n⇩1)) (N n⇩2) = (Plus (N (n⇩1+n⇩2)) a)" |
"full_plus (Plus a⇩1 (N n⇩1)) (Plus a⇩2 (N n⇩2)) = (Plus (N (n⇩1+n⇩2)) (Plus a⇩1 a⇩2))" |
"full_plus (Plus a⇩1 (N n⇩1)) (Plus (N n⇩2) a⇩2) = (Plus (N (n⇩1+n⇩2)) (Plus a⇩1 a⇩2))" |
"full_plus (Plus (N n⇩1) a⇩1) (Plus a⇩2 (N n⇩2)) = (Plus (N (n⇩1+n⇩2)) (Plus a⇩1 a⇩2))" |
"full_plus (Plus (N n⇩1) a⇩1) (Plus (N n⇩2) a⇩2) = (Plus (N (n⇩1+n⇩2)) (Plus a⇩1 a⇩2))" |
"full_plus a⇩1 a⇩2 = Plus a⇩1 a⇩2"
However, the function definition turns purple in jEdit. I've seen this happen when I mark a recursive lemma as [simp]
so I'm assuming this means the backend freezes or falls into an infinite loop, but never with functions. To me it seems that full_plus
does not recurse...? I've added declare [[simp_trace]]
to the program, but that just produces a long and (to me, a beginner) unintelligeble trace. I can post it here if someone wants to see it, but it's quite long.
For reference, this is for exercise 3.2 from the free online concrete semantics book. Hope someone can help me out!