0

I was trying to prove that replicate1 works correctly by showing that all elements of replicate1 n x are x:

all1 : (p : a -> Bool) -> List a -> Bool
all1 p [] = True
all1 p (x :: xs) = p x && all1 p xs

replicate1 : (n: Nat) -> a -> List a
replicate1 Z x = [x]
replicate1 (S k) x = x :: replicate1 k x

all_replicate_is_x : Eq a => {x: a} -> all1 (== x) (replicate1 n x) = True
all_replicate_is_x {n = Z} = ?hole
all_replicate_is_x {n = (S k)} = ?all_replicate_is_x_rhs_2

The base case hole is

Test.hole [P]
 `--           a : Type
      constraint : Eq a
               x : a
     -----------------------------------------
      Test.hole : x == x && Delay True = True

How to prove this?

Andrey
  • 712
  • 6
  • 16
  • The `Delay` comes from [`&&` being defined to be lazy in its second argument](https://github.com/idris-lang/Idris-dev/blob/fc3492474b8d348eddd87f5daaad03e1ebf6f116/libs/prelude/Prelude/Bool.idr#L29). – Cactus Sep 07 '18 at 07:08
  • I don't think the `Eq` interface prescribes reflexivity, so would `x == x` even be provable if just `Eq a`? – Cactus Sep 07 '18 at 07:10
  • good question, I will take a look on it, tnx. and the link, tnx – Andrey Sep 07 '18 at 10:14

0 Answers0