Generate code from automata

I am trying to figure out the process of generating code (set of instructions, implementation language specifics dont matter at this time) from an automata.

The description of my intent is vague because although I am an electrical engineer, with extensive coding experience, I have no theoretical CS background and I am struggling to even articulate what I mean. The issue at hand is related to a digital circuit that I am working with. At this point I am not even aware of what I need to start looking into. Another way of describing my intent is, say I got a transition model of a process with the data requirements that are associated with the states. Knowing that, can I generate a program that will implement that model? Is there a field of study that deals with problems like this? Or should I just develop some logic to solve a limited interpretation of the model?

I believe I am using incorrect or misleading terms from a CS standpoint but I will appreciate if I can get some guidance on how to formulate my intent and then try to understand the possible solutions, if any.


Theoretically, If you know the hash of a program one intends to install and you generate another file that hashes to that value what could you do?

If I know the hash of a program you intend to install is d306c9f6c5…, if I generate some other file that hashes to that value, I could wreak all sorts of havoc. – from

Theoretically, If you know the hash of a program one intends to install and you generate another file that hashes to that value what could you do?

Generate certificate v3 instead of v1

Trying to get certificate v3, but getting v1. I’m using following commands:

openssl req -out server.csr -newkey rsa:2048 -nodes -keyout server.key -config san_server.cnf openssl ca -config san_server.cnf -create_serial -batch -in server.csr -out server.crt 

Configuration file san_server.cnf content:

[ca] default_ca=CA_default  [CA_default] dir=./ca database=$  dir/index.txt new_certs_dir=$  dir/newcerts serial=$  dir/serial private_key=./ca.key certificate=./ca.crt default_days=3650 default_md=sha256 policy=policy_anything copy_extensions=copyall  [policy_anything] countryName=optional stateOrProvinceName=optional localityName=optional organizationName=optional organizationalUnitName=optional commonName=optional emailAddress=optional  [req] prompt=no distinguished_name=req_distinguished_name req_extensions=v3_req x509_extensions=v3_ca  [req_distinguished_name] countryName=EN stateOrProvinceName=Some-State localityName=London organizationName=Internet Widgits Pty Ltd commonName=  [v3_req] subjectAltName=@alt_names  [v3_ca] subjectAltName=@alt_names  [alt_names] IP.1= IP.2= DNS.1=localhost 

Why LL(1) grammar generate all regular languages?

I came across following:

Every regular language has right linear grammar and this is LL(1). Thus, LL(1) grammar generates all regular languages.

I tried to get that.

Definition: Right linear grammar (RLG)
In right linear grammar, all productions are of one of the following forms: $ A\rightarrow t^*V$ or $ A\rightarrow t^*$ , where $ A$ and $ V$ are non terminals and $ t$ is terminal.

Definition: LL(1) grammar

A grammar $ G$ is $ LL(1)$ grammar if and only if whenever $ A→α|β$ are two distinct productions of $ G$ , the following conditions hold:

  1. For no terminal $ a$ do both $ α$ and $ β$ derive strings beginning with $ a$ .
  2. At most one of $ α$ and $ β$ can derive the empty string.
  3. If $ β⇒^*ϵ$ , then $ α$ does not derive any string beginning with a terminal FOLLOW(A). Likewise, if $ α⇒^*ϵ$ , then $ β$ does not derive any string beginning with a terminal in FOLLOW(A). ($ β⇒^*ϵ$ means $ B$ derives $ \epsilon$ )

(Q1.) How definition of RLG ensures condition 1 in the definition of LL(1) grammar.

This answer says:

All regular languages have LL(1) grammars. To obtain such a grammar, take any DFA for the regular language (perhaps by doing the subset construction on the NFA obtained from the regular expression), then convert it to a right-recursive regular grammar. This grammar is then LL(1), because any pair of productions for the same nonterminal either start with different symbols, or one produces ε and has $ as a lookahead token.

(Q2.) I read somewhere “eliminating left recursion from given grammar does not necessarily make it LL(1)”. Then how turning grammar to right recursive will ensure its LL(1) (as stated in above quoted answer)?

(Q3). I didnt get the significance of “one produces ε and has $ as a lookahead token” in above quoted answer.

(Q4.) First quote in this question says right linear grammar is LL(1). How is it so?

(Q5.) This answer says “all regular languages have a LR(0) grammar”, I guess its incorrect as LR(0) are DCFLs with prefix property which are not superset of regular languages. Am I right with this?

(Leetcode) Combinatorial Sum – How to generate solution set from number of solution sets?

The following question is taken from Leetcode entitled ‘Combination Sum’

Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.

The same repeated number may be chosen from candidates unlimited number of times.


  1. All numbers (including target) will be positive integers.
  2. The solution set must not contain duplicate combinations.

Example 1:

Input: candidates = [2,3,6,7], target = 7, A solution set is: [ [7], [2,2,3] ]

Example 2:

Input: candidates = [2,3,5], target = 8, A solution set is: [ [2,2,2,2], [2,3,3], [3,5] ]

To solve this problem, I applied dynamic programming, particularly bottom up 2D tabulation approach. The method is quite similar to 0/1 knapsack problem, that is, whether we want to use an element in candidates or not.

The following is my code:

class Solution:     def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]:         if not len(candidates):             return 0         dp = [ [1] + [0]*target for _ in range(len(candidates) + 1)]         for row in range(1, len(candidates) + 1):             for col in range(1, target+1):                 dp[row][col] += dp[row - 1][col]                 if col - candidates[row-1] >= 0:                     dp[row][col] += dp[row][col - candidates[row-1]]         print(dp[-1][-1]) 

However, my codes above do not give solution set. Instead, it gives the number of elements in solution set.

I attempted to generate solution set from my codes above but to no avail. Can anyone help me?

How can I securely generate secret-sharing/multisig keys on a p2p network?

I am trying to create a peer-to-peer escrow system. I need to encrypt the private key of a wallet with a 2-of-3 secret-sharing function – the buyer, seller, and arbitrator will each have have one key.

The problem lies in the generation of secret keys on a p2p network, as there is no trusted server. What can I do to prevent a maliciously modified client from making a copy of the keys before distributing them to their rightful owners?

Thanks in advance!

Is checking if the length of a C program that can generate a string is less than a given number decidable?

I was given this question:

Komplexity(S) is the length of the smallest C program that generates the string S as an output. Is the question “Komplexity(S) < K” decidable?

With respect to decidability, I only know about the Halting Problem and just learned about Rice’s Theorem while searching online (though I don’t think it can be applied here?). I couldn’t reduce the problem to any undecidable problem I know about. Thanks in advance for any help

How to code an algorithm to generate a random but valid train track layout?

I am wondering if I have quantity C of curved tracks and quantity S of straight tracks, how I could write a computer program to design a “random” layout using all of those tracks, such that the following rules are satisfied:

1) The tracks, when all connected, form a closed (continuous) loop for the train to go around.

2) Ramps, bending of tracks, bumping of tracks, crossing of tracks are all not allowed.

So would the computer program have to create a geometric model and remember the exact positions of each track or is there some simpler way to code this? I want to be able to “push a button” and the computer “spits out” a valid “new” layout for me.

Do I need to give the exact measurements of the 2 types of tracks? If so, I can provide those.

I have some coding skills but I need to know an algorithm first before I can code something meaningful (other than just testing a few parts of a candidate algorithm)

Snort Doesn’t Generate Default Rules

I am new to information security, and am trying to set-up Snort

It seems like on Windows and Linux, that Snort doesn’t generate any default rules at installation. It doesn’t even generate default files, causing the .conf file to be mostly commented out, or having to generate the .rules myself. ./rules, and ./etc/rules are empty.

Why no default .rules? Is this intended? Is there a repository of rules that I can reference for my own learning?