Defining an Algorithm for finding all alignments between two sequences


Let S and T be two sequences of length n and m, respectively. When calculating the dynamic programming table to find the optimal global alignments between the two sequences S and T, we can keep pointers to find the optimal alignments by following these pointers from cell (n, m) to cell (0,0). Each of the paths represents a different optimal alignment for the two sequences.

To illustrate, we have an example of a table between the sequences ACGTTA and AACTA. By following the arrows from the cell (6,5) to (0,0) we get a possible optimal alignment. There are many ways to get to (0,0). Each of those ways is a distinct possible optimal alignment.

enter image description here

The challenge is to find a dynamic programming algorithm that will give me the number of the possible paths from this first table probably by looking at pointers.

Because dynamic programming involves having a programming table I’m not sure how it should look like. What would be the appropriate policy that determines which cells to look at to find the result in the next cell.

I notice that each possible alignment is a path from (n,m) to (0,0). This implies that each different path is a divergence from a common path.

enter image description here

You will notice that the red path and the blue path have some parts in common. This seems to justify a dynamic programming solution because we have certain solutions in common that we can use to find the next solution.

My whole problem with this is how do I formalize this thinking into a policy that looks like: enter image description here

The left part is the intial conditions. It basically tells how to find the solution for the next cells based on previous cells. This is not specific to this problem it’s just an example of what I’m looking for.

Defining a regular grammar but without $Q \rightarrow \varepsilon $

I defined a regular grammar (FSM), which starts with $ ab$ and ends with $ ba$ the following way:

  1. $ S \rightarrow aS$
  2. $ S \rightarrow bS$
  3. $ S \rightarrow aT$
  4. $ T \rightarrow bR$
  5. $ R \rightarrow aQ$
  6. $ Q \rightarrow aQ$
  7. $ Q \rightarrow bQ$
  8. $ Q \rightarrow \epsilon$

, where $ S$ is the starting element, $ \epsilon$ is the empty (null) element and the rest are just variables.

The rules 6, 7 and 8 are there, so we can end a word. However, I am trying to rewrite my grammer but without the $ Q \rightarrow \epsilon$ . I can’t use the empty element.

Can it be done? I’m not sure how.

Thanks

Defining “a particular kind” in the Locate Object spell

In our latest session a question came up. The initial statement [PHB pg 256] says to;

“Describe an object that is familiar to you.”

The spell description goes on to state that known to you (not familiar to you) is defined as seen within 30 feet.

The discrepancy comes up in the phrase;

“Alternatively, the spell can locate the nearest object of a particular kind, such as a certain kind of apparel, jewelry, furniture, tool, or weapon.”

We are trying to decide if an item that we have never seen, but is described to us (it is a gem that does X and has been in X location for a couple of hundred years) is enough to qualify as a “particular kind” of if that is too vague?

Throttling – difficulty in defining the description

WE have a problem with the spell form the lore of Shadow, named Throttling. (warhammer 2ed).

Spell description: You send ropes of inky darkness to throttle any one target within 12 yards (6 squares), cutting of his ability to breath entirely and forcing him to make a Thoughness Test to resist the effect the spell. You can maintain this spell with half action on each subsequent round, but you may cast no futher spells while doing so. If u maintain the spell, the Thoughness Test is modified a cumulative -10% penalty each round until it is failed, at which point the target begins to take damage. The first round of failure causes a Mamage 1 hit that ignores Armour, and each subsequent round the Damage of the hit increases by 1. No additional Toughness Test are allowed to resist damage after the first has been failed; the damage simply continues to compund until you stop, or are forced to stop, concentrating on the spell. The rules for concentration (see WFRP, Spellcasting Limits, page 144) apply.

And you see. 1. One of my friends is saying that: In first round, after the target make successful Toughness Test, wizard has to cast the spell (if want to maintain it) again and (if successful) target (again) has to pass Toughness Test (-10) if successful, then again wizard has to cast a spell… and the cycle repeats until the test fails

2. When the other is saying that: In first round, after the target make successful Toughness Test, wizard can maintain the spell with half action, and in the next round target (yet again) has to pass Toughness Test (-10) if successful, then again wizard sacrifice half action to maintain the spell… and the cycle repeats until the test fails.

Which one is correct? And if there was any mistakes, then sorry for my bad English

Defining $a^n b^{n^2}$ with one existential SO binary relation


Is it possible to define the language:

$ $ L = \{ a^n \; b^{n^2} \}$ $

using an existential second order sentence over strings (ordered structures with unary predicates $ U_a(x), U_b(x)$ ) using only one binary relation?

( $ \exists M \varphi$ where $ M$ is a binary relation, $ \varphi$ is first order)

If not, how to prove it? (or cite a textbook in which I can find similar exercises)

Defining $a^n b^{n^2}$ with one existential SO binary relation


Is it possible to define the language:

$ $ L = \{ a^n \; b^{n^2} \}$ $

using an existential second order sentence over strings (ordered structures with unary predicates $ U_a(x), U_b(x)$ ) using only one binary relation?

( $ \exists M \varphi$ where $ M$ is a binary relation, $ \varphi$ is first order)

If not, how to prove it? (or cite a textbook in which I can find similar exercises)

Defining $a^n b^{n^2}$ with one existential SO binary relation


Is it possible to define the language:

$ $ L = \{ a^n \; b^{n^2} \}$ $

using an existential second order sentence over strings (ordered structures with unary predicates $ U_a(x), U_b(x)$ ) using only one binary relation?

( $ \exists M \varphi$ where $ M$ is a binary relation, $ \varphi$ is first order)

If not, how to prove it? (or cite a textbook in which I can find similar exercises)

Defining one variable function on specific interval and taking supremum of it

I got a course in my undergraduate education 4 years ago. So actually I can’t remember the details about mathematica. I’m trying to solve one thing about 1 week. Here is my question:

f is a continuos and bounded function on [a,b]. Define

blank”>{x,t\in[a,b]&space;and&space;|t-x|<\delta}|f(x)-f(t)|” title=”w(f,\delta)=sup_{x,t\in[a,b] and |t-x|<\delta}|f(x)-f(t)|” />

I want to write this function on mathematica and checking while delta going zero, is w will be going with it. I replaced supremum with MaxValue function. But I didn’t write when x,t in [a,b] take f(x)-f(t). Because f is a single variable and I dont know how can I put condition when t-x < delta.

These are my problems. After defining this function I want to see on graph how it changes with different delta’s

motivation and idea of defining non-deterministic Turing machine

This is a very basic question but I spent some time reading and find no answer. I am not computer science majored but have read some basic algorithm stuff, for example, some basic sorting algorithms and I also have some basic knowledge of how computers operate. However, I am really interested in the idea of a Turing machine, especially the non-deterministic one.

I have read Wiki about the definitions of a Turing machine (and watched some youtube videos) and I sort of accept that, although I really feel that this is a huge jump from an algorithm to an abstract machine. From my understanding (you are more than welcome to correct me):

  1. A Turing machine is a machine performing works specified on a cookery book (algorithm).
  2. The pages of the cookery book represent the “states” of your machine and each page contains a table saying that which state and which cell your machine will move to given the alphabet the machine read and your current state. (NB. This is not a function but a partial function because it is possible that the machine stops.)
  3. So, to guess the idea and motivation of defining an abstract Turing machine, I imagine that the algorithm corresponds to the partial map, the memory of the computer corresponds to the (infinitely long) tape and what’s finally on the tape is the answer to the question you wanna solve.

So, Turing machine looks like a machine to realize any algorithm to solve problems. One just “translates” any algorithm to a set of mysterious simple rules (i.e. the partial function) and let the machine do the laboring job and then we get the solution.

In this respect, Turing machine is always deterministic, because algorithms are deterministic. It tells you what to do next precisely. This is no uncertainty. Turing machine is just a machine to realize any algorithm.


OK, This is very abstract and I sort of accept it. However, then I read something called non-deterministic Turing machine (NTM) and then I was knocked down. A NTM is pretty much similar to a Turing machine except that the partial function is now replaced by a “relation”. That is, it is a one-to-multiple map and it is no longer a (partial) function.

Could someone explain to me why we need such multiple options? I would never expect to encounter something uncertainty in the implementation of an algorithm. It is like telling the machine: you first do A, then if you find yourself in a state B and find the data is now B’ then you choose for yourself one of the 10 allowed next steps?

Are NTM’s corresponding to a set of algorithms that need uncertainty? for example the generation of random numbers? If no, why do we need to allow multiple choices for a Turing machine?

Any help will be appreciated!