Demonstration of a simple optical finite state machine and restoring all-optical digital logic