Is the languague L={, M accepts a finite amount of words} decdidable?

Is $ L=\{<M> | L(M) \ is \ finite\} $ decidable ? M is a TM.

I think its relative simple to proof with the theorem of rice. But I am interested in a solution which does not use the Rice theorem.

This my try : Let f(<m,w>) be a function which works in the following way :

  1. Run w on M
  2. If M accepts Construct a TM Mwhich accepts only the word w and return M
  3. If M rejects Construct a TM Mwhich accepts everything. Return M

So if m is in $ A_{TM}= \{<M,w>|M \ accepts \ w\}$ we know that f(<m,w>) is in L. If m is not in A then we know that f(<m,w>) does accept every word and therefore infinity words. So f(<m,w>) not in L.

Is this a correct mapping reduction ?

Why there is no Turing Machine that accepts the Diagonal Language?

Given the diagonal language

$ $ L_d = {i: \sigma_i \notin L(M_i)}$ $

Where $ M_i$ are all Turing Machines and $ \sigma_i$ are all the words, if you put in in a Matrix like this:

$ $ \begin{array} {|c|c|c|c|c|c|c|} \hline & \sigma_1 & \sigma_2 & \sigma_3 & \sigma_4 & \sigma_5 & …\ \hline M_1 & 1 & 0 & 1 & \dotsb & \dotsb & \dotsb \ \hline M_2 & 0 & 0 & 1 & \dotsb & \dotsb & \dotsb \ \hline M_3 & 1 & 0 & 1 & \dotsb & \dotsb & \dotsb \ \hline M_4 & \vdots & \vdots & \vdots & 1 & \dotsb & \dotsb \ \hline M_5 & \vdots & \vdots & \vdots & \vdots & \ddots & \dotsb \ \hline \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \ddots \ \hline \end{array}$ $

Then $ L_d$ is represented by the numbers in the diagonal of the matrix. In class I was told that there is no TM that accept $ L_d$ , but I do not quite understand why is that, could somebody help?

PS: The above explanation was included because I did not know if this is called Diagonal Language in English, Spanish is my mother tongue.

Why, if a function accepts arguments, it fails on ajax calls?

I am trying to write a WP function to work with both ajax and direct calls, something like this:

PHP

function some_function($  var){     $  var = !empty($  var) ? $  var : $  _POST['var'];     echo $  var;          //or even      $  var = null;     echo 'something';      if(!empty($  _POST['action'])) wp_die(); } 

AJAX CALL

let ajaxurl = '███'; let data = {'action': 'somefunction','var':'foo')}; $  .post(ajaxurl, data, function(response) {console.log(response);}); 

WP use

add_action( 'wp_ajax_somefunction', 'some_function',10,1); add_action( 'wp_ajax_nopriv_somefunction', 'some_function',10,1); 

Another WP use

some_function('bar'); 

However, any time I place $ var as an accepted function argument, some_function($ var), my ajax calls start returning a 500 error. So, something like this

function some_function(){     $  var = !empty($  var) ? $  var : $  _POST['var'];     echo $  var; } 

works for ajax.

I tried looking up wp ajax & arguments, but the search results are always about the variables we pass through ajax, not the callback function arguments. The only thing I learned is that we have to add a number of accepted arguments into add_action()

What am I doing wrong?

Thank you.

…P.S. I found a funny workaround:

function some_function_ajax(){     $  var = $  _POST['var'];     some_function($  var); } function some_function($  var){     echo $  var; } // =) 

but still, what is the right way?

Write a program that accepts the radius of a circle in the client side of a program and compute the area and perimeter in the server side program

Write a program that accepts the radius of a circle in the client side of a program and compute the area and perimeter in the server side program and return the values to the client program.

// Client   import java.io.*; import java.net.*;  public class Client {             public static void main(String[] args) throws IOException{                 Socket s = new Socket("localhost",1234);                 BufferedReader br;                 PrintStream ps;   String str;                System.out.println("Enter Radius  :");                 br=new BufferedReader(new InputStreamReader(System.in));    ps=new PrintStream(s.getOutputStream());                ps.println(br.readLine());    br=new BufferedReader(new InputStreamReader(s.getInputStream()));                str=br.readLine();                System.out.println("Area of the circle is : "+str);                 br.close();                 ps.close();            } } 
// Server  import java.io.*; import java.net.*;  class Server {       public static void main(String[] args){           try {           ServerSocket ss = new ServerSocket(1234);                  System.out.println("Waiting for Client Request");                   Socket s=ss.accept();                   BufferedReader br;                   PrintStream ps;                   String str;                   br=new BufferedReader(new InputStreamReader(s.getInputStream()));                   str=br.readLine();                   double r=Double.parseDouble(str);                   double area=3.14*r*r;                   ps=new PrintStream(s.getOutputStream());                   ps.println(String.valueOf(area));                   br.close();                   ps.close();                   s.close();                   ss.close();        }           catch(Exception e)           {                       System.out.println(e);           }  } }  

how to add perimeter of a circle

Finding a finite automata that accepts a language that is the combination of two other languages with their own automata

I’m told that we have two DFA one A and one B both on alphabet $ \sum$ .

I’m then told to define a DFA (5-tuple representation) with this condition {w | w = $ a_i b_i$ $ a_k b_k$ and all the $ a \in A$ and all the $ b \in B$ }

Also 1 $ \leq$ i $ \leq$ k and $ a_i \in \sum$ and $ b_i \in \sum$ .

However I simply do not understand how I’m supposed to do this. Simply put my confusion is what $ w = a_i b_i$ mean. Is it concatenation? Does it mean that the word $ w$ is the concatenation of a with b?

All problems about Turing machines that involve only the language that the TM accepts are undecidable

I came across the below statement in the classic text “Introduction to Automata Theory, Languages, and Computation” by Hopcroft, Ullman, Motwani.

All problems about Turing machines that involve only the language that the TM accepts are undecidable

They say that the above theorem is per Rice theorem which states that:

“Every nontrivial property of the RE languages is undecidable.”

How are these two statements equivalent? The former deals only problems while the later deals with non trivial property.

Show that the language L = { | M1 is a Turing machine that accepts 0} is Turing recognizable

Show that the language L = {< M1 > | M1 is a Turing machine that accepts 0} is Turing recognizable. I was told by my professor to go about this proof by giving an informal description of a Turing Machine ‘V’ that would accept ‘M1’ if and only if ‘M1’ was a Turing Machine that accepts 0.

Below I have the informal description I gave for the Turing Machine ‘V’. I wanted to know if my description accurately depicts the Turing Machine ‘V’ and therefore proves that the language ‘L’ is Turing recognizable. Any feedback would be appreciated.

“V On input M1 where M1 is a Turing Machine

i = 1, stop = false;

While (stop==false){

Simulate i steps of M1 on 0

If the simulation enters an accepting state, stop = true. else i=i+1

}

accept.”