I suspect that if such a program could be written, it would be done using 'LISP'.
LISP is (or has been) much used for 'Expert Systems'. I had a look at it years ago, but left it feeling that it could push a person to the edge of insanity - with just one more pair of square brackets needed to push them over the edge!
Jim