Running at the same time 2 algorithms that designed to solve the mutual-exclusion - mutual-exclusion

Question I saw on site that explains the issue of mutual-exclusion (http://www.faculty.idc.ac.il/gadi/PPTs/Chapter2-Mutex-BasicTopics.pptx - page 8). Unfortunately there is no answer. Also, the original question is only about C but I didn't understand If the order is changing how it affects the result, so I added D.
Let A and B be two algorithms designed to solve the mutual-exclusion problem. In other words, their structure consists of an entry-section, critical-section and exit-section (but you cannot assume they satisfy mutual-exclusion or deadlock-freedom unless written otherwise). Assume that algorithms A and B do not use the same variables. We construct a new mutual-excusion algorithm, C, as follows:
Algorithm C
entry code of A
entry code of B
Critical Section
exit code of B
exit code of A
For each of the following assertions, please prove or disprove its correctness.
If both A and B are deadlock-free, C is deadlock-free.
If both A and B are starvation-free, C is starvation-free.
If A or B satisfy mutual-exclusion, C satisfies mutual-exclusion.
If A is deadlock-free and B is starvation-free, C is starvation-free.
If A is starvation-free and B is deadlock-free, C is starvation-free.
Also that same questions, but this time on D instead of C, where D is:
Algorithm D
entry code of A
entry code of B
Critical Section
exit code of A
exit code of B
Thanks!

Related

cgal corefinement demo : cutting mesh A surface with mesh B, then remove A in B

I posted some time ago a CGAL question that was kindly answered by pointing to the Polyhedron demo and the corefinement plugin. The basic idea being that one open polyhedron A is cut by another open polyhedron B, and I need the list of intersection half edges owned by A, or better, A minus the part of A in B.
The co-refinement demo does this, but I want to select, as a result, all parts of A not in B. This does not match the available predicates in the demo (A - B (leaves parts of B inside A) , B - A (leaves parts of B outside A), A inter B, A union B). I tried combining/modifying them to get what I want but I must be missing something. The information on the 'darts' seem to be mutually exclusive.
The picture below illustrates this : A as been cut by B (I have a hole with the shape of B) but some parts of B are still in A (the facets on the hole border).
(edit : sorry : not enough reputation to post an image here :-()
Any advices on how to write a predicate that would select only A with a hole, and leave out any face coming from B?
Thank you!

Puzzle on Probability of 7 people being seen or ignored

I have a question.
Suppose i have 7 people sitting next to each other.
A B C D E F G
When i say "look", the people can either look towards their right or left.
The Question is :
- What is the probability that "A" and "G" could be ignored?
- What is the probability that each Person can be either ignored or looked.
I found it too confusing.
Can anyone help?
Thanks and Good day.
A is ignored if everyone looks to the right, so probability is 0.5^5, same answer for G...

Understanding Operational semantics

I have this derivation
(b,σ)→false (skip,σ)→σ
(if b then c;w else skip)→σ
(With the top line being the precondition and the bottom line the expression)
Does the expression mean:
If b is True, then do command c, else do w and skip,
or
If b is True, then do command c and command w, else skip.
The semi-colon in the middle is confusing me?!
Also, why don't I have to include c in the precondition?
Thanks.
Every operational semantics is different and the question specifies no context, so I can only guess at the answer.
I would parse if b then c; w else skip as if b then {c; w} else skip, that is, the second interpretation from the question. The derivation seems to be about the case that b is false, so c is not mentioned because if b is false, c is not executed. Instead, skip is mentioned because it's executed.
This just answers part of your question, heowever: c is not included in the precondition because it does not depend on the precondition. I somehow cannot make sense of the w in the second line either. Furthermore, the question might be off topic as it is more about computer science than actual programming.

What is the language of this deterministic finite automata?

Given:
I have no idea what the accepted language is.
From looking at it you can get several end results:
1.) bb
2.) ab(a,b)
3.) bbab(a, b)
4.) bbaaa
How to write regular expression for a DFA
In any automata, the purpose of state is like memory element. A state stores some information in automate like ON-OFF fan switch.
A Deterministic-Finite-Automata(DFA) called finite automata because finite amount of memory present in the form of states. For any Regular Language(RL) a DFA is always possible.
Let's see what information stored in the DFA (refer my colorful figure).
(note: In my explanation any number means zero or more times and Λ is null symbol)
State-1: is START state and information stored in it is even number of a has been come. And ZERO b.
Regular Expression(RE) for this state is = (aa)*.
State-4: Odd number of a has been come. And ZERO b.
Regular Expression for this state is = (aa)*a.
Figure: a BLUE states = EVEN number of a, and RED states = ODD number of a has been come.
NOTICE: Once first b has been come, move can't back to state-1 and state-4.
State-5: comes after Yellow b. Yellow b means b after odd numbers of a.
Once you gets b after odd numbers of a(at state-5) every thing is acceptable because there is self a loop for (b,a) at state-5.
You can write for state-5 : Yellow-b followed-by any string of a, b that is = Yellow-b (a + b)*
State-6: Just to differentiate whether odd a or even.
State-2: comes after even a then b then any number of b. = (aa)* bb*
State-3: comes after state-2 then first a then there is a loop via state-6.
We can write for state-3 comes = state-2 a (aa)* = (aa)*bb* a (aa)*
Because in our DFA, we have three final states so language accepted by DFA is union (+ in RE) of three RL (or three RE).
So the language accepted by the DFA is corresponding to three accepting states-2,3,5, And we can write like:
State-2 + state-3 + state-5
(aa)*bb* + (aa)*bb* a (aa)* + Yellow-b (a + b)*
I forgot to explain how Yellow-b comes?
ANSWER: Yellow-b is a b after state-4 or state-3. And we can write like:
Yellow-b = ( state-4 + state-3 ) b = ( (aa)*a + (aa)*bb* a (aa)* ) b
[ANSWER]
(aa)*bb* + (aa)*bb* a (aa)* + ( (aa)*a + (aa)*bb* a (aa)* ) b (a + b)*
English Description of Language: DFA accepts union of three languages
EVEN NUMBERs OF a's, FOLLOWED BY ONE OR MORE b's,
EVEN NUMBERs OF a's, FOLLOWED BY ONE OR MORE b's, FOLLOWED BY ODD NUMBERs OF a's.
A PREFIX STRING OF a AND b WITH ODD NUMBER OF a's, FOLLOWED BY b, FOLLOWED BY ANY STRING OF a AND b AND Λ.
English Description is complex but this the only way to describe the language. You can improve it by first convert given DFA into minimized DFA then write RE and description.
Also, there is a Derivative Method to find RE from a given Transition Graph using Arden's Theorem. I have explained here how to write a regular expression for a DFA using Arden's theorem. The transition graph must first be converted into a standard form without the null-move and single start state. But I prefer to learn Theory of computation by analysis instead of using the Mathematical derivation approach.
I guess this question isn't relevant anymore :) and it's probably better to guide you through it then just stating the answer, but I think I got a basic expression that covers it (it's probably minimizable), so i'll just write it down for future searchers
(aa)*b(b)* // for stoping at 2
U
(aa)*b(b)*a(aa)* // for stoping at 3
U
(aa)*b(b)*a(aa)*b((a)*(b)*)* // for stoping at 5 via 3
U
a(aa)*b((a)*(b)*)* // for stoping at 5 via 4
The examples (1 - 4) that you give there are not the language accepted by the DFA. They are merely strings that belong to the language that the DFA accepts. Therefore, they all fall in the same language.
If you want to figure out the regular expression that defines that DFA, you will need to do something called k-path induction, and you can read up on it here.

Boolean Search In Lucene

I have been trying to run the following boolean query in lucene but it seems to fail. Please help.
(a or b) and c -> works fine
(a AND b) or c -> gives result for a AND b OR c. So a becomes must and b and c becomes should, and the search result is wrong. Where it should work like a, b must be available or c may be available.
Another example:
If you search for "(a AND b)" it will return x results
If you search for "c" it will return y results
If you search for "(a and b) or c" the number of results cannot be less than the larger of x or y. But this is not happening. Please help how should I proceed to implement this?
(a AND b) or c gets converted to (+a +b) c. What you want is this without parentheses: +a +b c.
From a logical perspective, "A and B must occur, C might occur" is equivalent to "A and B must occur." (There is no way to say "might be true" in classical logic.) So you will have difficulty saying (+a +b) c in boolean terms. One way you could do it is "(a AND b AND c) or (a AND b)".