If a program could program itself?.... (AI)

The one thing about this that I've always wondered I know certain virus's have the ability to morph into completely new version of a virus to trick antivirus scanners so wouldn't this sort of be considered as AI technology by some form because the programmer is giving the virus the ability to compile itself into something new? I mean types of virus's like this apply self modifying code and alter there own instructions after execution. I know that using virus as a topic for discussion isn't the best example but I've always wondered if a virus can modify itself to morph wouldn't it be possible in normal programming if it was programmed to change its instructions on its own causing it to be self sustaining basically to do a task?