Complexity, Autometa can anyone please explain this? - complexity-theory

Let L1 ⊆ {0, 1}∗ and L2 ⊆ {0, 1}∗ be RE (recursively enumer-
able) languages such that L1 ∪ L2 = {0, 1}∗ and L1 ∩ L2 6= ∅. Prove that L1
is algorithmically reducible to L1 ∩ L2, that is, there is an algorithm which,
for every w ∈ {0, 1}∗, constructs a suitable v ∈ {0, 1}∗ such that w ∈ L1 if
and only if v ∈ L1 ∩ L2.

Related

ZDD with Quantification in Prolog

What would be the ZDD approach in Prolog that also provides quantifiers.
Notation for existential quantifier would be as follows:
X^F
where X is the bound variable and F is the formula. It corresponds
to the following formula:
F[X/0] v F[X/1]
How would one go about and write a Prolog routine that takes a ZDD
for F and a variable X and produces the ZDD for X^F ?
Daniel Pehoushek posted some interesting C-code, which I translated to Prolog. Its not directly working with ZDD, but rather with sets of sets of variables, which is also explained here. But I guess the algorithm can be translated from sets of sets of variables to ZDD.
It only needs two new operations, the rest works with the operations from library(lists). One operation is split/4 which gives the left and right branch for a tree root. And the other operation is join/4 which does the inverse. The main routine is bob/3:
bob(_, [], []) :- !.
bob([], A, A).
bob([V|W], A, T) :-
split(A, V, L, R),
intersection(L, R, H),
bob(W, H, P),
union(L, R, J),
bob(W, J, Q),
join(V, P, Q, T).
What does bob do? It transforms a formula P into a formula Q. The original formula P has propositional variables x1,..,xn. The resulting formulas has propositional variables x1',..,xn' which act as switches, where xi'=0 means ∀xi and xi'=1 means ∃xi. So the desired quantification result can be read off in the corresponding truth table row of Q.
Lets make an example:
P = (- A v B) & (-B v C)
Q = (A' v B') & (B' v C') & (A' v C')
A'B'C' Q
000 0
001 0
010 0
011 1 eg: (All A)(Exists B)(Exists C) P
100 0
101 1
110 1
111 1
Or as a Prolog call, computing Q from P for the above example:
?- bob([c,b,a], [[],[c],[b,c],[a,b,c]], A).
A = [[b, a], [c, a], [c, b], [c, b, a]]
Open source:
Some curious transformation by Daniel Pehoushek
https://gist.github.com/jburse/928f060331ed7d5307a0d3fcd6d4aae9#file-bob-pl

How to get predicates by specifying the number of arguments it should have?

Suppose I have these relations:
d(m, n).
d(x, y).
d(a, b, c).
d(i, j, k).
d(1, 2, 3, 4).
How can I write a predicate mypred(Pred, NumArgs, Rel)?
Examples:
mypred(d, 2, Rel): Rel would be d(m, n), d(x, y), false.
mypred(d, 3, Rel): Rel would be d(a, b, c), d(i, j, k), false.
mypred(d, 4, Rel): Rel would be d(1, 2, 3, 4), false.
mypred(F, A, Rel_0) :-
functor(Rel_0, F, A),
call(Rel_0).
However, rather don't use such a definition. Instead try to use call/N with N > 1.
Definitions as mypred/3, are very difficult to analyze. Cross-referencing is practically impossible. On the other hand, with call/N, N > 1 quite similar functionality is possible, cross-referencing stays intact. See meta-predicate for many uses.

Formal Linux Kernel Memory Model

images and citations comes from:
Frightening Small Children and Disconcerting Grown-ups: Concurrency in the Linux Kernel
Let's consider a simple program:
cumul-fence is defined as:
cumul-fence := A-cumul(strong-fence ∪ po-rel) ∪ wmb
A-cumul(r) := rfe';r
In the linked publication in 3.2.3 it is written that (b, e) ∈ prop. From that we can conclude that (c, d) ∈ cumul-fence.
So, let's see:
po-rel = {(c,d)}
strong-fence = {(a,b),(e,f)}
wmb = {}
rfe = {(d,e)}
rfe' = {(d,d), (d,e), (e,e)} <- reflexive closure of rfe.
A-cumul({(a,b),(e,f),(c,d)}) = {(d,d), (d,e), (e,e)};{(a,b),(e,f),(c,d)} = {(d,f), (e,f)}
cumul-fence = {(d,f), (e,f)}
so, as we can see (c,d) is not in cumul-fence. Can someone explain me where my reasoning is incorrect?
rfe', the reflexive closure of rfe, is
{(d,e), (a, a), (b, b), (c, c), (d, d), (e, e), (f, f), (k, k), (r, r)}
since the set of nodes is {a, b, c, d, e, f, k, r}.
From there, cumul-fence is {(d, f), (a, b), (c, d), (e, f)}.

R o R (Discrete Mathematics - Relations on Sets)

The following is given
Let A = {1, 2, 3, 4}
Let R = the relation on the set A, or:
R = {(1,1), (1,2), (1,3), (2,1), (3,2), (3,3), (4,4)}
Find R o R as a set of tuples.
I am not certain how to approach this problem.
My best guess is
R o R = {((1,1),(1,1)), ((1,1),(1,2), ..., ((4,4),(4,4))}
but that does not seem right to me. I'm looking for how to solve this type of problem, not just a solution to this problem.
Any help would be appreciated!
According to Definition 6 from Chapter 8:Relations and Thier Properties :
S ○ R
Composite relation of R and S where
R from A to B
S from B to C
is the ordered pairs:
(a, c), where a ∈ A and c ∈ C
for which b ∈ B such that
(a, b) ∈ R ^ (b, c) ∈ S
(a, c) ∈ S ○ R if (a, b) ∈ R ^ (b, c) ∈ S
and using example that follows it, one can get
So the final answer is
R ○ R = {(1,1), (1,2), (1,3), (2,1), (2,2), (2,3), (3,1), (3,2), (3,3), (4,4)}

Is there a built-in Mathematica function to find operators rather than numbers in equations?

How can the following be best accomplished in Mathematica?
In[1] := Solve[f[2,3]==5,f ∈ {Plus,Minus,Divide}]
Out[1] := Plus
The desired expression syntax can be transformed into a set of Solve expressions:
fSolve[expr_, f_ ∈ functions_List] :=
Map[Solve[(expr /. f -> #) && f == #, f] &, functions] // Flatten
Sample use:
In[6]:= fSolve[f[2,3] == 5, f ∈ {Plus, Subtract, Divide}]
Out[6]= {f -> Plus}
In[7]:= fSolve[f[4,2] == 2, f ∈ {Plus, Subtract, Divide}]
Out[7]= {f -> Subtract, f -> Divide}
The advantage of this approach is that the full power of Solve remains available for more complex expressions, e.g.
In[8]:= fSolve[D[f[x], x] < f[x], f ∈ {Log, Exp}]
Out[8]= {f -> ConditionalExpression[Log, x Log[x]∈Reals && x>E^ProductLog[1]]}
In[9]:= fSolve[D[f[x], x] <= f[x], f ∈ {Log, Exp}]
Out[9]= {f -> ConditionalExpression[Log, x Log[x]∈Reals && x>=E^ProductLog[1]],
f -> ConditionalExpression[Exp, E^x ∈ Reals]}
Please tell me if this does what you want:
findFunction[expr_, head_ ∈ {ops__}] :=
Quiet#Pick[{ops}, expr /. head -> # & /# {ops}]
findFunction[f[2, 3] == 5, f ∈ {Plus, Minus, Divide}]
(* Out[]= {Plus} *)
I'm not aware of a built-in function, but it's not hard to write one yourself. Here is one approach that you can use:
Clear#correctOperatorQ;
correctOperatorQ[expr_, value_,
operators_] := (expr == value) /. Head[expr] -> # & /# operators
By the way, the correct operator for 2-3 is Subtract, not Minus. The result for your example:
correctOperatorQ[f[2, 3], 5, {Plus,Subtract,Divide}]
Out[1]={True, False, False}

Resources