Turn definitions into rules

I know that this seems to be unnecessary, but here I have a bunch of assignments, like around 50, and I want to create rules for all these to have the freedom to apply these rules only on certain expressions. However I can’t find an efficient way to do this. Please help.

Clear is also not efficient because I have to put in all those names of the variables.

How to get synonyms from definitions using Bayes algorithm

I work on a project: an online dictionary where the user can find definitions of a word he’s looking for. My supervisor asked us to add synonyms using machine learning. He recommend us to use Bayes algorithm. but I don’t see how to do this, how to put every word in a category and make probabilities.

Please how can I use this algorithm? knowing that my project is in java.

Thanks, for any suggestions or opinions.

Foreign key references on column definitions are ignored. Feature, not a bug — why?

Good old references constrains. They work like a charm when defined at the table level.

create table foo (id int primary key);  create table bar (id int, foreign key(id) references foo(id)); insert into bar values (1); -- ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (...) 

But if you come from another ecosystem and are used to occasionally define foreign key constrains at the column level, this is what happens:

create table baz (id int references foo(id)); insert into baz values (1); -- happily takes a value that isn't there in foo select id from baz; -- 1 

What happens is that the references has been recognized, but ignored.

It turns out that this is not a bug. The MySQL documentation says they do it, and that’s all you need to know:

MySQL parses but ignores “inline REFERENCES specifications” (as defined in the SQL standard) where the references are defined as part of the column specification. MySQL accepts REFERENCES clauses only when specified as part of a separate FOREIGN KEY specification.

The MariaDB documentation is slightly more verbose on their rationale:

MariaDB accepts the REFERENCES clause in ALTER TABLE and CREATE TABLE statements, but that syntax does nothing. MariaDB simply parses it without returning any error or warning, for compatibility with other DBMS’s. However, only the syntax described below creates foreign keys.

Now what could be the use for this “feature” that helps “compatibility” with other DBMS — and the standard — by silently breaking the very purpose of the reference, while at the same time, correctly implementing it does not look like a big effort since foreign key constrains are indeed enforced when declared at the table level? And don’t tell me this cannot be fixed because people rely on the fact that foreign constrains can be broken when declared at the column level.

Please help me make sense out of this.

Equivalence of two definitions of mutual information

I am learning quantum computing and as a background study, I am currently learning fundamentals of classical information theory. I thought it best to ask my doubts here. In Nielsen and Chuang, it is stated that mutual information I(X:Y) of two random variables X and Y is the information they have in common while in some books, it is written that mutual information I(X:Y) is the information one variable(say X) has about the other(say Y). I can’t understand it intuitively how the two definitions are equivalent. Also, the symmetric property of mutual information,i.e., I(X:Y)=I(Y:X) is obvious to me from the first definition but not from the second one.

Definitions of and difference between adaptive online adversary and adaptive offline adversary?

I recently started learning about randomized online algorithms, and the Wikipedia definitions for the three adversary models are very unhelpful to put it mildly. From poking around I think I have a good understanding of what an oblivious adversary is. From my understanding, the oblivious adversary must determine the “worst possible input sequence” before we even start running our algorithm. Let $ I_w$ denote the worst possible input sequence this adversary comes up with. (I.e., the input sequence that produces the greatest gap between the best that can be done and what we expect our algorithm to do.)

We then say that our algorithm is $ c$ -competitive (for a minimization problem) under this adversary if $ $ E[Alg(I_w)] \le c \cdot Opt(I_w) + b$ $ where $ c,b$ are some constants, $ E[Alg(I_w)]$ is the expected value of our algorithm on the input, and $ Opt(I_w)$ is the cost if we had made perfect decisions. (I.e., if the problem went offline.)

My confusion concerns the adaptive online and adaptive offline adversaries. I neither fully understand their definitions nor the difference between them. I will list my confusions directly below.

  • As I understand it, both of these adversaries somehow build the input sequences as your online algorithm runs. This says before you create the input at time $ t$ , unlike in the case of the oblivious adversary, both the adaptive online and adaptive offline adversaries have access to the outcomes of your algorithm at time steps $ 1, \ldots , t-1$ . Then it says that in both cases the adversary “incurs the costs of serving the requests online.” The difference being that for the online adaptive adversary, it “will only receive the decision of the online algorithm after it decided its own response to the request.” Does this mean that the difference is that the offline adaptive adversary can see how your algorithm performs during future steps? Or just the present step? But then why is it still incurring the cost of serving requests online?
  • This source contradicts the source above. It says that the adaptive offline adversary “is charged the optimum offline cost for that sequence.” Like I said previously, the previously source says both incur “the cost of serving the requests online.” What does it even mean to incur the cost of serving requests online vs. offline? Which is correct?
  • This takes a completely different tack and talks about knowing randomness (online adaptive) vs. knowing “random bits” (offline adaptive). Is this equivalent somehow? How so?
  • How does the definition of the competitive ratio change for these two adversaries? Most sources I looked at just defined the competitive ratio for the oblivious adversary.

A simple example of each to illustrate the difference would be much appreciated. Thanks for the help!

Break down the CISecurity OVAL definitions file to smaller definition files

I am working on a project that uses OpenSCAP and the OVAL vulnerability definitions provided by CISecurity (Example definitions file Warning: link will auto-download the file).

This is a huge definitions file, containing over 3.6k definitions, which takes approximately 2 hours to complete on our desktops.

My plan was to break down the definitions file into 30 smaller files each containing just over 100 definitions, I have already scripted this and it effectively works.

I then intended to complete 30 smaller scans, each taking about 4 minutes to complete, whenever I detect the desktop user has been idle for 5 minutes. This would allow us to complete the scans during the working day when users are on breaks or in meetings (it’s a strange requirement, but the client is refusing WOL for overnight scans).

When I tested the first of the 30 smaller definition files, I received a lot of these errors:

File 'C:\Users\SomeUser\Desktop\testdefinition-1of30.xml' line 4803: Element '{http://oval.mitre.org/XMLSchema/oval-definitions-5}extend_definition': No match found for key-sequence ['oval:org.cisecurity:def:6326'] of keyref '{http://oval.mitre.org/XMLSchema/oval-definitions-5}extendKeyRef'. OpenSCAP Error: Invalid OVAL Definition (5.11.1) content in file [C:\projects\openscap\src\source\oscap_source.c:346] 

So it appears OVAL definitions are vitally linked with one another, something I hadn’t spotted in the standard myself.

Can anyone explain these links to me, or help me understand how I can break down the large definitions file into several smaller ones?

I can write the script myself, but I’m having difficulty understanding the logic.

Thanks!

Two definitions of oracle

There are two definitions of oracle

a) Oracle is a black box that “knows” (in an instant) the answer to a given decision problem, such as is this number (presented e.g. as a binary string) a prime number.

b) Oracle is a characteristic function of a set of all strings of a given alphabet such as {0,1}. (The characteristic function can even be completely random?)

My question is this. Is definition b) more general than definition a)? Can results obtained for b) be applied to the complexity of real computational problems? It seems that in the first case (a) there exists an algorithm that eventually can (however slowly) produce the answer, while in the second case (b) there is no algorithm and the answer is completely arbitrary.

Are the definitions of constructs in terms of lambda terms issues in implementation/design or uses of functional languages?

In Lambda Calculus, natural numbers, boolean values, list processing functions, recursion, if function are defined in terms of lambda terms. For example, natural numbers are defined as Church numerals, and recursion is defined in terms of a fixed point of a function.

Functional languages are said to be based on Lambda Calculus.

Who shall be concerned about the above concepts in terms of lambda terms: the implementer/designer of the languages, and/or programmers in the languages?

  • Do functional programming languages define/implement the above concepts in terms of lambda terms?

  • As programmers in regular functional programming languages (such as Haskell, Lisp, ML), is it correct that the above concepts are always given in the same way as in imperative languages, and we never have to understand or deal with their definitions in terms of lambda terms?

Thanks.