I know the language L2 = {a^m; m >=0} is a regular language, and that L3 = {a^p; p is a prime number} is recursively enumerable.
Would L2-L3=L1 also be recursively enumerable and not context free or regular?
I know the language L2 = {a^m; m >=0} is a regular language, and that L3 = {a^p; p is a prime number} is recursively enumerable.
Would L2-L3=L1 also be recursively enumerable and not context free or regular?
Not only is L3 = {a^p; p is a prime number} recursively enumerable, it is recursive. Here is a sketch of the proof:
Imagine a multi-tape Turing machine with the following tapes:
For simplicity, assume unary representation. These tapes can be used as follows:
Because we can decided non-primeness for any input using this TM, we can also enumerate the strings in the language simply by giving each string to this TM and listing it if we determine it's not prime.
Example of the TM running on the number 5 (prime):
s = 0 s = 1 s = 2 s = 3 s = 4
|||||#### |||||#### |||||#### |||||#### |||||####
######### ||####### ||####### ||####### ||#######
######### ######### |||||#### |||###### |########
s = 5 s = 6 s = 7 s = 8
|||||#### |||||#### |||||#### |||||#### HALT
|||###### |||###### ||||##### ||||##### REJECT
|||||#### ||####### |||||#### |########
Example of the TM running on 9 (non-prime):
s = 0 s = 1 s = 2 s = 3 s = 4
||||||||| ||||||||| ||||||||| ||||||||| |||||||||
######### ||####### ||####### ||####### ||#######
######### ######### ||||||||| |||||||## |||||####
s = 5 s = 6 s = 7 s = 8 s = 9
||||||||| ||||||||| ||||||||| ||||||||| |||||||||
||####### ||####### |||###### |||###### |||######
|||###### |######## ||||||||| ||||||### |||######
s = 10
||||||||| HALT
|||###### ACCEPT
#########