0

I'm trying to prove this lema

reverse-++ : ∀{ℓ}{A : Set ℓ}(l1 l2 :  A) → reverse (l1 ++ l2) ≡ (reverse l2) ++ (reverse l1)     
reverse-++ [] [] = refl
reverse-++ l1  [] rewrite ++[] l1 = refl
reverse-++ l1 (x :: xs) =  {!!}

But another function, reverse-helper keeps coming up into my goal and I have no idea how I get rid of it. Any guidance or suggestions?

JrPtn
  • 83
  • 2
  • 8
  • 1
    We'll need to see the definition of `reverse`, since it seems you implemented it with helper function. – Vitus Feb 19 '14 at 23:05

2 Answers2

1

I'm assuming that in the implementation of reverse, you call reverse-helper. In that case, you probably want to prove a lemma about reverse-helper that you can call in the lemma about reverse. This is a general thing: If you are proving something about a function with a helper function, you usually need a proof with a helper proof, because the induction structure of the proof usually matches the recursion structure of the function.

Toxaris
  • 7,156
  • 1
  • 21
  • 37
0

I think you should start with the different argument.

Since ++ is probably defined with [] ++ a = a, and reverse (x :: xs) = (reverse xs) ++ (x :: nil) it will be better to prove reverse-++ (x :: xs) ys = cong (\xs -> xs ++ (x :: nil)) (reverse-++ xs ys)

Sassa NF
  • 5,306
  • 15
  • 22
  • Well, it looks like it's the usual reverse with accumulator. You need far more involved proof for that, such as https://gist.github.com/vituscze/9116356 – Vitus Feb 20 '14 at 15:32
  • @Vitus It seemed to me that I proved something similar to reverse (xs++ys) = (reverse xs)++(reverse ys) in only a few lines. Maybe my memory fails me. – Sassa NF Feb 20 '14 at 16:45
  • You might want something slightly more general like https://github.com/copumpkin/containers/blob/master/Semigroup.agda#L29. – Mysterious Dan Feb 21 '14 at 18:52