This is a repost of [this question][1].

Can you provide proof or counterexample for the claim given below?

Inspired by [Lucas-Lehmer primality test][2] I have formulated the following claim:
 
>Let $P_m(x)=2^{-m}\cdot((x-\sqrt{x^2-4})^m+(x+\sqrt{x^2-4})^m)$ . Let $N= 4 \cdot 3^{n}-1 $ where $n\ge3$ . Let $S_i=S_{i-1}^3-3  S_{i-1}$ with $S_0=P_9(6)$ . Then $N$ is prime if and only if $S_{n-2} \equiv 0 \pmod{N}$ .

You can run this test [here][3] .

Numbers $n$ such that $4 \cdot 3^n-1$ is prime can be found [here][4] . 

I was searching for counterexample using the following PARI/GP code:

    CE431(n1,n2)=
    {
    for(n=n1,n2,
    N=4*3^n-1;
    S=2*polchebyshev(9,1,3);
    ctr=1;
    while(ctr<=n-2,
    S=Mod(2*polchebyshev(3,1,S/2),N);
    ctr+=1);
    if(S==0 && !ispseudoprime(N),print("n="n)))
    }

P.S.

Partial answer can be found [here][5].

**EDIT**
After few years I finally found correct formulation of criterion. I have a proof but it is too long. Here is criterion:
>Let $N= 4 \cdot 3^{n}-1 $ where $n\ge 0$ . Let $S_i=S_{i-1}^3-3  S_{i-1}$ with $S_0=6$ . Then $N$ is prime if and only if $S_{n} \equiv 0 \pmod{N}$ .

  [1]: https://math.stackexchange.com/q/3205287/15660
  [2]: https://en.wikipedia.org/wiki/Lucas%E2%80%93Lehmer_primality_test
  [3]: https://sagecell.sagemath.org/?z=eJxdi7EOwiAURXc-oxOvvkYBF0PfJ9iF3UHEQNICaYmmf9-3uDjdnHvvyWSsmOjam0celBWOdF_L7GN47lsMH3lDhQas8G0l3r8xzUEyjJQHjY7u5SX_FMOKO2vACSw_T6TYT2_piC5Y15Sb7DiW0MEPfVlq2VLjCuwBm0wsfQ==&lang=gp&interacts=eJyLjgUAARUAuQ==
  [4]: https://oeis.org/A005540
  [5]: https://math.stackexchange.com/a/3208094/15660