Let K be a field, in SageMath - symbolic-math

How can I construct something that's analogous to the beginning of a proposition with "Let K be a field" -- some kind of field that isn't defined, but does have an arbitrary field's properties.
I've seen this symbolic ring documents page, but I am not sure if I can construct a symbolic ring that has .is_field() == True.
Can somebody help? I'd also be interested in doing the same for Let G be a group, or how one would go about more complicated symbolic algebraic objects, like let P be a PID.
Thanks.

In SageMath, a generic field is represented by sage.rings.ring.Field (source/docs). Similarly, PIDs are represented in sage.rings.ring.PrincipalIdealDomain, and groups in sage.groups.group.Group.

Related

Venn diagram notation for all other sets except one

I'm trying to find a Venn diagram notation that can illustrate data that is only in a single set.
If I can select data from all the other sets, without knowing how many there are, then I can find the intersection of their complement, to select data only in the targeting set.
My current solution looks like this, but it assumes the existance of sets B and C.
The eventual diagram expecting to look like this:
One way to do it would be by using a system based on regions rather than sets. In your case, it would be the region that belongs to set A but does not belong to any other set. You can find the rationale to do that here. The idea is to express the region as a binary chain where 1 means "belongs to set n" and 0 means "does not belong to set n", where n is determined by the ordering of the sets.
In your example, you might define A as the last set, and therefore as the last bit. With three sets CBA, your region would be 001. The nice thing about this is that the leading zeroes can be naturally disregarded. Your region would be 1b, not matter how many sets there are (the b is for "binary").
You might even extend the idea by translating the number to another base. For instance, say that you want to express the region of elements belonging to set B only. With the same ordering as before, it would be 010 or 10b. But you can also express it as a decimal number and say "region 2". This expression would be valid if sets A and B exist, independently of the presence of any other set.

Definition of functional dependency, ambigiuous "for all pairs"

for all pairs of tuples t1 and t2 such that
t1[A] = t2[A] then t1[B] = t2[B]
Can "a pair" also be a pair of the same tuple, meaning t1 = t2, or does it mean only two distinct tuples?
TL;DR The "pairs of" is redundant informal language. The informal language is trying to say that they have 2 names--a pair/paring/duo/couple/twosome/dyad of names--and a value is sought for each one. The value associated with one can be the value associated with the other--they can name the same value.
You are to twice find a value for a name: a value to call by "t1" then a value to call by "t2". The formal notation is "EXISTS t1, t2 (...)" or "EXISTS t1 EXISTS t2 (...)".
So for each name you might or might not find a value; so you might get zero, one or both names naming values; and if both, the names might or might not end up with the same value; and if they do, you might or might not have got the value from the same tuple-valued element of the set that is the relation body.
From my answer at Determining if this data is really in 4th normal form? re MVDs (mulitvalued dependencies):
"There exist" says some values exist, and they don't have to be different. EXISTS followed by some name(s) says that there exist(s) some value(s) referred to by the name(s), for which a condition holds. Multiple names can refer to the same value. (FOR ALL can be expressed in terms of EXISTS.)
When such statements are given formally we say, "for all X" (universal quantification) or "there exists X" (existential quantification) where "X" is a name and we mean that "for all values" or "there exists a value" that you could use that name for in what follows. This is basic logic as used in mathematics, science and engineering.
They say "for all pairs of tuples", but they mean for all sequences that are a tuple-valued value followed by a tuple-valued value. "The first value" and "the second value" might be equal, ie be "the same value" even though there are two "values". The natural language is not clear, you have to learn what certain phrasings mean.
A free resource https://www.fecundity.com/logic/ :
forall x is an Open Education Resource (OER) introductory textbook in formal logic. It covers translation, proofs, and formal semantics for sentential and predicate logic.
A variant at https://open.umn.edu/opentextbooks/textbooks/1139 is forall x: Calgary.

Maximum of 2 INTEGERS?

What's the syntax for the maximum of 2 INTEGERS?
Eiffel documentation is so bad, literally could not find the answer to this simple question anywhere!
Or does it not exist and I have to use if-statements?
In most cases in Eiffel, the source is all the documentation you need. By right-clicking on a class' name in EiffelStudio, you can see its ancestor tree. You can also use the flat view feature to see all the inherited features of a class within the same editor.
Typically, INTEGER is an alias for INTEGER_32. INTEGER_32 inherits from COMPARABLE (through INTEGER_32_REF). COMPARABLE provides the max and min features. Their signature is
max (other: like Current): like Current
meaning all descendants of COMPARABLE take and return another value of the same type as themselves.
Therefore:
local
a, b, maximum: INTEGER
do
a := <some value>
b := <some value>
maximum := a.max(b) -- or b.max(a)
end
Eiffel has a unified type system, which means every type is defined as a class, even 'primitive' types that get special treatments in most other languages. INTEGER, CHARACTER, BOOLEAN, ARRAY and other such basic types thus come with a rich set of features you can consult in their own class files like you would with any other type. Since operators are defined as regular features too, this is also the way to figure out exactly what operators exist for any given class.

VDM-SL notation for a single, finite subset

Not sure if this is within the realm of SO but:
Using VDM-SL, I have been looking around for the 'best' way of describing a single, finite subset of ℕ. In my travels I have found several ways that people are conveying this but I wonder which is the most accepted.
I initially thought that F(ℕ) would do but I believe that this is the set of finite subsets of ℕ, rather than a single subset.
Would it be enough to say, "Let S be finite: S ⊂ ℕ?"
Or does such a notation exist?
All sets in VDM language are finite by definition, so I believe there is no need to explicitly specify that part. As defined here http://wiki.overturetool.org/images/c/cb/VDM10_lang_manV2.pdf section 3.2.1
Now, to model a type which is a subset of a set s2 , one of the ways is to use an invariant on that type. such as "inv t == s1 subset s2".

What's the order of parameters in vl_ubcmatch?

I am using VLFEAT implementation of SIFT to compute SIFT descriptors on two set of images: queries and database images. Given a set of queries, I'd like to obtain the closest descriptors from a big database of descriptors, for which I use vl_ubcmatch.
Having vl_ubcmatch syntax as MATCHES = vl_ubcmatch(DESCR1, DESCR2) I obtain different results if I input the query descriptors first and the database descriptors as a second parameter or the other way around.
Which is the correct syntax?
1) MATCHES = vl_ubcmatch(QUERY_DESCR,DATABASE_DESCR)
or
2) MATCHES = vl_ubcmatch(DATABASE_DESCR,QUERY_DESCR)
I obtain different results if I input the query descriptors first and the database descriptors as a second parameter or the other way around.
This is because this method uses the ratio test[1] algorithm behind the scenes, i.e comparing the distance of the closest neighbor to that of the second-closest neighbor.
vl_feat implementation uses by default a threshold of 1.5 as follow:
if(thresh * (float) best < (float) second_best) {
/* accept the match */
}
This ratio test is not symmetric, that's why you could obtain differences between the set of matches when you swap the inputs.
If you are not comfortable with it, you can refer to Computer Vision Programming using the OpenCV Library Chapter 9 which suggests a pragmatic way to symmetrize the matching as follow:
From these [matching] sets, we will now extract the matches that are in agreement
with both sets. This is the symmetrical matching scheme imposing that,
for a match pair to be accepted, both points must be the best matching
feature of the other.
[1] see 7.1 Keypoint Matching from D. Lowe's paper.
MATCHES = vl_ubcmatch(DESCR1, DESCR2) for each descriptor in DESCR1 searches for the closest descriptor in DESCR2 and adds it to the output if the match passes the test (for more details see deltheil's answer).
So I believe MATCHES = vl_ubcmatch(QUERY_DESCR,DATABASE_DESCR) is the variant you want.

Resources