Represent the English statement into Quantifiers - predicate

Here is a statement
C(x): x has a cat D(x): x has a dog F(x): x has a Ferret
represent using quantifiers and logical connectives. Under the domain "all students in your class"
1) No student in your class has a cat, a dog or a ferret.
2) For each of the three animals, there is a student in your class who has one of these animals as a pet.
Can someone provide an answer for this. Thanks in advance.

1) ∀x (~C(x) ^ ~D(x) ^ ~F(x))
2) (∃xC(x)) ^ (∃xD(x)) ^ (∃xF(x))

Related

UML class diagram association properties {subsets < Association end > } | {union} | {redefines}

I don't quite understand what {subset} stands for when it comes to the association between class diagrams in UML. I've found this PDF that talks about it on page 4: https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.138.5537&rep=rep1&type=pdf.
Here is the diagram & text that you can also find on page 4:
I read this and I'm not 100% about what {subsets < class > } is about.
It says that "The slot representing d will be a subset of the slot representing b. Elements of type B can be inserted into slot b and elements of type D can be inserted into slots b and d."
So, is {subset} some kind of polymorphism ? I think that thorugh "slot" they mean like the argument of a method that is of type B. And because D subsets b that means that D is like the sub-class of b so it can be passed down as "b" in arguments because of Polymorphism.
So the question is :
What is {subsets < class > } exactly, is it representing a sub class ?
On top of that I have other questions:
What are {union}, {redefines < class > }, {nonunique} & {sequence}. What do does stand for ?
Some examples in code would make it easier to understand.
So the question is : What is {subsets < class > } exactly, is it representing a sub class ?
It is not {subsets < class >} but {subsets < property name >}
In the given diagram D is the only visible class specializing B, and if they are no other classes specializing B then all the instances of B are instances of D and then {subset b} is equal to b.
But having at least :
all the instances of B are not necessary instances of D (including of classes specializing D), this is why d only concerns a subset of the instances of B concerned by b.
In your diagram and mine the subsets are not really useful, but there are for instance in case of redefinition e.g. {subsets a, redefines a} {subsets b, redefines b}
What are {union}, {redefines < class > }, {nonunique} & {sequence}
referring to formal/2017-12-05 §9.5.4 page 113 and 114 :
union means that the property is a derived union of its subsets.
nonunique: means that there may be duplicates in a multi-valued property. This is the opposite of unique meaning there is no possible duplicates. For instance supposing b is {nonunique} then some instances of B can be present several times in b. If the property is implemented in C++ by a std::set it is {unique}.
sequence means that the property represents an ordered bag, this is a shortcut of {nonunique, ordered}. This is the case of std::vector and std::list in C++.
{redefines < property-name > } (not {redefines < class >}) means that the property redefines an inherited property identified by < property-name >. If in your diagram the {subsets b} is replaced by {redefines b} then the classes C only has the slot (e.g. attribute in C++ etc) d. This is not like having b private so not accessible from C, that really means d is a redefinition of b.

Regular Expressions and languages of alphabets with substring

Right now I'm learning for a test in cs and I have my problems with regular expressions. Here is example of a question I don’t understand.
We have a given alphabet Σ = {0, 1} and L1. L1 represent any word with odd number of 0(zeros) and exactly twice 1 (ones).
The prof. showed us an example how the solution should look like:
Σ = {a, b} with L1.
L1 represents any Word in which the sub-words aa or bb occurs.
L1 = (a ∪ b)* (aa ∪ bb)* (a ∪ b)*
thank you for your help
Try this:
(?mx)
^
(?=0*10*10*$) # check if the word consists of only 0s and exactly two 1s
(?:..){1,}. # check if the word length is odd
$
Demo on RegEx101. There you can find an exhaustive explanation of this regular expression.

Understanding trains with literal values in J

I'm sure this is obvious but I'm a little unclear about it. Suppose I wanted to make a function do something like f(x) = 3x+1. Knowing the rule for forks, I expect to see something like this: [: 1&+ 3&* which is not that beautiful to me, but I guess is nicer looking that (1&+) #: (3&*) with the extra parentheses. Instead, if I query with 13: I get this:
13 : '1+3*y'
1 + 3 * ]
Way more beautiful, but I don't understand how it is possible. ] is the identity function, * and + are doing their usual thing, but how are the literals working here? Why is J not attempting to "call" 1 and 3 with arguments as if they are functions? I notice that this continues to do the right thing if I replace any of the constants with [ or ], so I think it is interpreting this as a train of some kind, but I'm not sure.
When J was first described, forks were all verbs (V V V), but then it was decided to let nouns be in the left tine position and return their face value. So (N V V) is seen as a fork as well. In some older code you can see the left tine of the fork show up as a 'verbified' noun such as 1: or 'a'"_ which act as verbs that return their face value when given any argument.
(N V V) configuration is described in the dictionary as "The train N g h (a noun followed by two verbs) is equivalent to N"_ g h ." http://www.jsoftware.com/help/dictionary/dictf.htm

Polymorphic empty relation in Alloy?

I run an Alloy command that involves finding witnesses for some existentials, like this one:
pred foo {
some x, y : E -> E |
baz[x,y] || qux[x,y]
}
Alloy comes up with a model where foo is true. I look at the model in the Visualizer, and find that y happens to be the empty relation. I want to dig deeper into the model and see whether baz or qux is true. So I fire up the Evaluator window and type baz[$foo_x, ???]. But what can I type for ???? Since y is empty, there is no variable with the name $foo_y. And typing none or {} gives a type-checking error.
Does Alloy provide an empty relation that can be used at any type? Or is there any way to get at the y witness even though it's empty?
I belive baz[$foo_x, none->none] should work. The relation none has arity 1, and by using cross product you can get empty relations of the desired arity. The explanation for this can be found in the paper "A Type System for Object Models" by Jonathan Edwards, Daniel Jackson and Emina Torlak.

Inductively Defining Sets of Strings

CS student slogging through a logic class. This question has me befuddled
Inductively Defining Sets of Strings
Find an inductive definition for the following set of strings:
S = {apbcr | p is a natural number, and r is a natural number greater than 0} *the p and r are superscripts*
I'd suggest the following definition:

Resources