inductive S :: "alpha list ⇒ bool" where
empty : "S []" |
step1 : "S w ⟹ S (a # w @ [b])" |
step2 : "⟦S w1; S w2⟧ ⟹ S (w1 @ w2)"
inductive T :: "alpha list ⇒ bool" where
empty : "T []" |
step : "⟦T w1; T w2⟧ ⟹ T (w1 @ [a] @ w2 @ [b])"
fun balanced :: "nat ⇒ alpha list ⇒ bool" where
"balanced 0 w = S w" |
"balanced (Suc 0) w = S (a # w)" |
"(balanced n w = S (a # m @ w)) ⟹ (balanced (Suc n) w = S (a # a # m @ w))"
I am trying to write a function balanced
so that balanced n w
is true if and only if S (an @ w)
where an is list that contains n
number of the same alphalist. For the third equation of the function"(balanced n w = S (a # m @ w)) ⟹ (balanced (Suc n) w = S (a # a # m @ w))"
I get the error "Variable "m" occurs on right hand side only:" even though there is m
in the left side.
The only solution that I can think of is write the function in another way but cannot think of how at the moment.