$A \subset \{1,2,3,...,40\} : \forall a,b\in A,\space |a-b|\ne4,\space|a-b|\ne9$. Prove $n(A)<20$ 
Question:
$A \subset \{1,2,3,...,40\}$ such that
  \begin{align}
&\forall a,b\in A\\
&|a-b|\ne4,\quad|a-b|\ne9
\end{align}
  Prove that $n(A)<20$.

I found a case of $n(A)=19$ that is $A=\{13m+n|m=0,1,2,\space n=1,3,4,6,9,11\}\cup\{40\}$, but couldn't prove that $19$ is the maximum. Thanks.
 A: Lemma : Given $13$ consecutive numbers $a+1,...,a+13$ and a $7$ element subset $A$ of this set,  there exist two elements in $A$ that differ by either $4$ or $9$.
Proof: Let $A$ be a subset such that no two elements in $A$ differ by either four or nine. If $a+m \in A$, then we want to see how many elements' membership this rules out in $A$. If $m=1, ..., 4$, this rules out $2$ elements, namely $a+m+4,a+m+9$. If $m = 10,...,13$, this rules out two elements, namely $a+m-4,a+m-9$. If $m = 5,...,9$, this rules out two numbers : $a+m-4,a+m+4$. Thus, the membership of $a+m$ always rules out two other numbers from the list.
Let us call $B = \{a+1,a+2,a+3,a+4\}$, $C = \{a+5,a+6,a+7,a+8,a+9\}$ and $D = \{a+10,a+11,a+12,a+13\}$.  
Note that $A$ shares at least three of it's elements with one of these subsets. If it shares three elements with $B$, then these  eliminate exactly three elements each from $C$ and $D$, so that leaves only two in $C$ and one in $D$, so that $A$ can have only six elements.
Similarly, if it shares three elements with $D$, then these eliminate exactly three elements in $B$ and $C$, so that leaves only two in $C$ and one in $B$, so that $A$ can have only six elements.
If it shares three elements with $C$,  then we have three cases:
1 : If neither $a+5$ nor $a+9$ is a member of $A$, then this eliminates three members of $B$ and $D$. That leaves four elements in total, but note that  both $a+5,a+9$ cannot both be in $A$ as their difference is $4$. Hence, $A$ can have only six elements.
2: If $a+5$ is a member of $A$, then this eliminates three choices from $B$, and two choices from $D$. Hence, we have two choices left in $D$ and one in $B$, so $A$ can have at most six elements.
3 : A similar thing to above, for $a+9$ being a member of $A$.
Finally, the lemma is proved. With this, let $A$ be a subset of $\{1,...,40\}$ that has $20$ elements. Then, $A$ shares $19$ elements with $\{1,...,39\}$, so that one of the subsets $\{1,...,13\},\{14,...,26\},\{27,...,39\}$  shares at least seven elements with $A$. From here, use the lemma to get a contradiction.
Hence, $A$ must have less than nineteen elements. You have provided a $19$ element subset, congratulations. Furthermore, note that any nineteen element subset satisfying the above property must contain $40$.
EDIT: I have not checked what happens if $B,C,D$ ends up sharing four elements with $A$, but you can check even this does not work. But I prefer the proof below, by Muralidharan.
Can you generalize this result?
Lemma : Let $k$ be odd, and $c,d$ be two numbers such that $c + d=k$. Then, any subset of $\{a+1,...,a+k\}$ of size at least $\frac {k+1}2$ contains two elements that either differ by $c$ or $d$. 
A: Another proof of the Lemma in the above solution:
Put thirteen points $1,2,\ldots, 13$ on a circle and connect two of those with edges if they differ by 4 or 9. We get a graph of degree 2 (that is each vertex has two incident edges). Now if it is possible to choose 7 vertices such that no two are connected by an edge, then removing these vertices and the edges incident on them will remove 14 edges from the original graph but that graph has only 13 edges.

