Nguyễn Quốc An (BKC18348) - Assignemt 1 Set theory and functions

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

PROGRAM TITLE: ……Discrete Math………………………………………

UNIT TITLE: ……………1……………………………………….

ASSIGNMENT NUMBER: ……1……………………………

ASSIGNMENT NAME: …Set Theory and functions………………………………….

SUBMISSION DATE: …October 17 2021…………………………………….

DATE RECEIVED: ……October 14 2021……………………………………….

TUTORIAL LECTURER: …Luu Thi Huong Giang…………………………………

WORD COUNT: ……………………………………………..

STUDENT NAME: ……Nguyễn Quốc An…………………………………………

STUDENT ID: ……BKC18348……………………………………………….

MOBILE NUMBER: …0795179677…………………………………………


Summative Feedback:

Internal verification:
Part 1:

1, Let A and B be two non-empty finite sets. If cardinalities of the sets A, B, and A ∩ B are 72, 28
and 13 respectively, find the cardinality of the set A ∪ B.

=> n(A ∪ B) = n(A) + n(B) - n(A ∩ B)

n(A ∪ B) = 72 + 28 –13 = 87

2, Let A={n∈N:20≤n<50} and B={n∈N:10<n≤30}. Suppose C is a set such that C ⊆ A and C ⊆ B.


What is the largest possible cardinality of C?

=>A = {20;21;22;23;…;49} and B = {11;12;13;14;…;30}. If C ⊆ A and C ⊆ B so C ⊆ A ∩ B, and


A ∩ B = { n ∈ N:20 ≤ n < 30 } => C ⊆ A ∩ B = { n ∈ N:20 ≤ n < 30 }.

Finally, the largest possible cardinality of C is 11.

3, Consider the sets A and B, where A = {3, |B|} and B = {1, |A|, |B|}. What are the sets?

=> |A| = {2, |B| ≠ 3 and 1, |B| = 3}. Imagine that |A| = 1, then B = {1,1, |B|} = {1, |B|}, and a
contradiction with |B| = 3. However, |A| = 2, and |B| ≠ 3. Consider to that B = {1, |A|, |B|} = {1,2, |B|} and
|B| < 3, can lead to conclude that |B| = 2. Finally, A = {3, 2} and B = {1, 2}

Part 2:

1, Write the multi-sets of prime factors of given numbers. a, 150; b, 450; c, 1250

A, 150 => 1, 2, 3, 5, 6, 10, 15, 25, 30, 50, 75, and 150

B, 450 => 1, 2, 3, 5, 6, 9, 10, 15, 18, 25, 30, 45, 50, 75, 90, 150, 225, and 450

C, 1250 => 1, 2, 5, 10, 25, 50, 125, 250, 625 and 1250

2, Find the cardinalities of each multiset in part 2-1.

A, 150 = {2, 3, 5, 5}. 2 has multiplicity 1, 3 has multiplicity 1 and 5 has multiplicity 2

=> 1 + 1 + 2 = 4.

B, 450 = {2, 3, 3, 5, 5}. 2 has multiplicity 1, 3 has multiplicity 2 and 5 has multiplicity 2
=> 1 + 2 + 2 = 5.

C, 1250 = {2, 5, 5, 5, 5}. 2 has multiplicity 1, 5 has multiplicity 4 => 1 + 4 = 5.


3, Present the application of set and multiset in software engineering? Give specific programming
example

Set: A set is an abstract data type in computer science that may store unique elements in any order. It's a
computerized version of the mathematics concept of a finite set. Unlike most other collection types,
instead of getting a specific element from a set, a value is normally tested for set membership. Some set
data structures are intended for static or frozen sets, which do not change after they are created. Static sets
only provide query operations on their elements, such as determining whether a given value is in the set
or enumerating the values in any order. Other forms, known as dynamic or mutable sets, allow for the
insertion and deletion of set elements.

Type theory: Sets are often recognized in type theory by their indicator function (characteristic
function): thus, a set of values of type A may be denoted by 2A or P(A) .(Refinement types can be used to
simulate subtypes and subsets, and setoids can be used to substitute quotient sets.). A set S characteristic
function F is defined as follows:

Implementations: Sets can be implemented using a variety of data structures, each with its own set of
performance and space trade-offs for various operations. Some solutions are intended to boost the
efficiency of highly specialized operations like nearest or union. The element of, add, and remove
procedures are often optimized in "general usage" implementations. A list can be used as a rudimentary
implementation, ignoring the order of the members and taking care to avoid repeated values. This is
straightforward yet inefficient, because operations like set membership or element deletion are O(n)
because they involve reading the full list. Sets are frequently implemented using more efficient data
structures, such as various varieties of trees, attempts, or hash tables.

Because sets can be interpreted as a type of map (via the indicator function), they are commonly
implemented in the same way as (partial) maps (associative arrays) – in this case, where the value of each
key-value pair has the unit type or a sentinel value – namely, a self-balancing binary search tree for sorted
sets (which has O(log n) for most operations) or a hash table for unsorted sets (which has O(1) average
To offer deterministically ordered sets, a sorted linear hash table can be employed.

Furthermore, sets can be implemented in terms of maps in languages that support maps but not sets. A
typical programming idiom in Perl, for example, that turns an array to a hash whose elements are the
sentinel value 1, for usage as a set, is:

my %elements = map { $_ => 1 } @elements;


Arrays are another popular way. A subset of the integers 1..n, in particular, can be easily represented as
an n-bit bit array, which also supports very efficient union and intersection operations. A Bloom map
based on probabilities implements a set, employing a relatively compact representation while risking a
tiny number of false positives on queries.

Although the Boolean set operations can be done using simpler operations (pop, clear, and add),
specialized techniques may offer lower asymptotic time limitations. If sets are implemented as sorted
lists, the naive algorithm for union(S,T) will take time proportional to the length m of S times the length n
of T, whereas a variant of the list merging technique will take time proportional to m + n. Furthermore,
there exist specific set data structures (such as the union-find data structure) that are optimized for one or
more of these operations while sacrificing others.

Multiset: A multiset (or bag, or mset) in mathematics is a variation of the concept of a set that, unlike a
set, allows for many instances of each of its items. The multiplicity of an element in a multiset is the
number of instances given for that element. As a result, there are an endless number of multisets that
include only components a and b but differ in the multiplicities of their elements:

 When a, b is viewed as a multiset, it comprises just elements a and b, each with multiplicity 1.
 The element a has multiplicity 2 in the multiset a, a, b, and b has multiplicity 1.
 The multiset {a, a, a, b, b, b} so a and b both have multiplicity 3.

When regarded as multisets, these items are all distinct, even though they are all part of the same set
because they all contain the same components. Order does not matter in discriminating multisets, as it
does in sets, and unlike tuples, therefore {a, a, b} and {a, b, a} denote the same multiset. A notation with
square brackets is often used to distinguish between sets and multisets: the multiset {a, a, b} might be
represented as [a, a, b].

A multiset's cardinality is calculated by adding the multiplicities of all its elements. For example, in the
multiset {a, a, b, b, c} the multiplicities of the members {a, b, c} are 2, 3, and 1, respectively, and so the
cardinality of this multiset is 6.
Definition: A multiset is formally defined as a 2-tuple (A, m), where A is the underlying set of the
multiset, constructed from its distinct members, and m: A -> Z+ is a function from A to the set of positive
integers, giving the multiplicity, or number of occurrences, of the element an in the multiset as the
number m. (a). Representing the function m by its graph (the set of ordered pairings (a, m (a)): a ∈ A
allows for the multiset {a, a, b} to be written as (a, b, (a, 2), (b, 1)), and the multiset {a, b} to be written
as (a, b, (a, 1), (b, 1)). This notation is not widely used, and instead, more compact notations are utilized.

If A = {a1, ..., an} is a finite set, the multiset (A, m) is frequently denoted as

{am(a1), … , am(an)}, sometimes reduced to am(a1) … am(an) (Note I can not write a1) , where upper indices of
1 are excluded. For instance, the multiset a, a, b can be expressed as {a2, b} or a2 b. If the elements of the
multiset are numbers, basic arithmetic operations may cause confusion; these are generally excluded from
the context. The latter notation, on the other hand, is consistent with the fact that, according to the
fundamental theorem of arithmetic, the prime factorization of a positive integer is a uniquely defined
multiset. A monomial is also a multiset of indeterminates; for example, x3 y2 corresponds to the multiset
{x, x, x, y, y}.

If the multiplicity of each element is one, a multiset corresponds to an ordinary set (as opposed to some
larger positive integer). An indexed family, (ai)I ∈ I, where i varies over an index-set i, can define a
multiset, which is frequently represented as ai. The image of the family provides the underlying set of the
multiset in this perspective, and the multiplicity of any member x is the number of index values i such
that an ai = x. The multiplicities are considered finite in this article, which means that no element occurs
infinitely many times in the family: even in an infinite multiset, the multiplicities are finite numbers.

It is possible to generalize the definition of a multiset by allowing multiplicities of individual items to be


infinite cardinals rather than positive integers, however not all features are preserved.

Applications: Multisets have a variety of uses. They are becoming increasingly important in
combinatorics. Multisets have become a significant tool in relational database theory, which frequently
use the synonym bag. Multisets, for example, are frequently used to implement relations in database
systems. Because it can contain numerous identical records, a table (without a primary key) functions as a
multiset. SQL, on the other hand, operates on multisets and returns identical records. Consider the
statement "SELECT name from Student." If there are numerous rows in the student table with the name
"sara," they are all displayed. That is, the SQL result set is a multiset. If it was a set, the result set's
repeating records were removed. Multiset is also used in the modeling of multigraphs. Multiple edges can
exist between any two vertices in a multigraph. As a result, the entity that displays edges is a multiset
rather than a set.
There are further applications. Richard Rado, for example, used multisets as a tool to examine the
features of set families. "The notion of a set takes no account of many occurrences of any one of its
members," he argued, "and yet it is precisely this type of information that is frequently of relevance."
Consider the set of roots of a polynomial, f(x), or the spectrum of a linear operator.

Part 3:

1, Determine whether the following functions are invertible or not. If it is invertible, then find the
rule of the inverse f-1 (x)

I, f : R -> R+ , f(x) = x2

=> f(x) = x2
f(x) = 2x
f (-3) = 2*(-3) = (-6) →f2 * (-6) = (-12)
f (-2) = 2*(-2) = (-4) → f2 * (-4) = (-8)
f (-1) = 2*(-1) = (-2) → f2 * (-2) = (-4)
f (0) = 2*(0) = (0) → f2 * (0) = (0)
f (1) = 2*(1) = (2) → f2 * (2) = (4)
f (2) = 2*(2) = (4) → f2 * (4) = (8)
f (3) = 2*(3) = (6) → f2 * (6) = (12)

II, f : R+ -> R+ , f(x) = 1/x

=> f(x) = 1/x, f(1) = 1/1 = 1, f(2) = ½, f(1/2) = 1/1/2 = 2, f(3) = 1/3, f(1/3) = 1/1/3 = 3

X1 , x2 are two different numbers from domain

F(x1) = 1/x1 (1) f(x2) = 1/x2 (2)

(1) - (2) => f(x1) = f(x2) = 1/x1 = 1/x2 = x1 = x2

1 – 1 function f(x) = 1/x

-1
F(x) = y, Y = 1/x , X = 1/y, X -> y -> x, Y = 1/x (inverse function) => f (x) = 1/x
III, f : R+ -> R+ , f(x) = x2

X
X2 F(X) = X2
1 1 F(1) = 12 = 1
2 4 F(2) = 22 = 4
4 16 F(4) = 42 = 16
5 25 F(5) = 52 = 25
25 625 F(25) = 252 = 625
0.1 0.01 F(0.1) = 0.12 = 0.01
0.01 0.0001 F(0.01) = 0.012 = 0.0001
X1, x2 are two different numbers from domain

F(x1) = x12 (1), f(x2) = x22 (2)

(1) = (2) => x12 = x22. Take the square root x1 = +x2 then 1- 1 function inverse exit.

F(x) = (1/x)2 , f(x) = y, y = x2 . Take the square root √y = √x2 , √y = x, x= y and y = x

√x = y (inverse) => f-1 (x) = √x

IV, f : [-π/2, π/2] -> [-1, 1], f(x) = sin x

F(-π/2) = sin(-π/2) = -sin(π/2) = -1 f(π/2) = sin(π/2) = 1

X1, x2 are two different numbers

F(X1) = sin(X1) (1) f(x2) = sin(x2) (2)

(1) = (2)

Sin(x1) = sin(x2) [-π/2, π/2]

F(x) = sin(x), y = f(x), y = sin(x), sin-1 (y) = x

X -> y and y -> x, y = sin-1 (x) => f-1 (x) = sin-1 (x).

2, Function f(x) = 5/9 (x-32) converts Fahrenheit temperatures into Celsius. What is the function
for opposite conversion?

Assume f(x) = y => y = 5/9 (x-32) => 9y = 5x -160 => 9y +160 = 5x => x = 1/5 (9y + 160) = 9/5y +
32. As a result, the opposite function which convert Celsius to Fahrenheit is 9/5y + 32, which y is the
temperature in Celsius. For example: x0 C, ( 9/5y + 32)0 F
3, Present the application of function in software engineering? Give specific programming example

Functional programming is a programming paradigm in computer science in which programs are built by
applying and composing functions. It is a declarative programming paradigm in which function
definitions are trees of expressions that map values to other values, rather than a series of imperative
statements that update the program's running state.

Functions are viewed as first-class citizens in functional programming, which means they can be bound to
names (including local identifiers), supplied as arguments, and returned from other functions just like any
other data type. This enables programs to be written in a declarative and composable form, with simple
functions being joined in a modular fashion.

Functional programming is sometimes confused with purely functional programming, a subset of


functional programming in which all functions are treated as deterministic mathematical functions, or
pure functions. When a pure function is invoked with some arguments, it always returns the same result
and is unaffected by mutable states or other side effects. This is in contrast to impure procedures, which
are popular in imperative programming and can have side effects (such as changing the program's state or
taking user input). Purists of purely functional programming argue that by limiting side effects, programs
can have fewer flaws, be easier to debug and test, and be more amenable to formal verification.

Functional programming has its origins in academia, where it evolved from the lambda calculus, a formal
computation system based solely on functions. Functional programming has historically been less popular
than imperative programming, however numerous functional languages, such as Common Lisp, Scheme,
Clojure, Wolfram Language, Racket, Erlang Elixir, OCaml, Haskell, and F#, are now being used in
industry and education. Functional programming is also important in other cases JavaScript for the Web,
R for statistics, J, K, and Q for financial analysis, and XQuery/XSLT for XML are examples of languages
that have achieved success in certain domains. Some characteristics of functional programming are used
in domain-specific declarative languages such as SQL and Lex/Yacc, such as the prohibition on
changeable values. Furthermore, many other programming languages, such as C++11, C#, Kotlin, Perl,
PHP, Python, Go, Rust, Raku, Scala, and Java, support or have implemented functional programming
concepts (since Java 8).

Applications:

Spreadsheets: Spreadsheets are a type of zeroth-order, strict-evaluation functional programming system.


Spreadsheets, on the other hand, often lack higher-order functions, as well as code reuse, and in some
implementations, recursion. Several extensions for spreadsheet systems have been developed to enable
higher-order and reusable functions, but they are mostly academic in nature.

Academia: In the realm of programming language theory, functional programming is an active topic of
research. The International Conference on Functional Programming, the Journal of Functional
Programming, and the Symposium on Trends in Functional Programming are three peer-reviewed
publication venues devoted to functional programming.
Industry: Functional programming has found application in a wide range of industrial applications.
Erlang, for example, was developed in the late 1980s by the Swedish company Ericsson and was initially
used to implement fault-tolerant telecommunications systems, but has since become popular for building
a variety of applications at companies such as Nortel, Facebook, Électricité de France, and WhatsApp.
Scheme, a Lisp dialect, was utilized as the foundation for various applications on early Apple Macintosh
computers, and has been used to challenges as diverse as training simulation software and telescope
control. Since its introduction in the mid-1990s, OCaml has found commercial application in areas such
as financial analysis, driver verification, industrial robot programming, and static analysis of embedded
software. Although Haskell was designed as a research language, it has been used by a variety of
industries in areas such as aerospace systems, hardware design, and web development.

Scala, F#, Wolfram Language, Lisp, Standard ML, and Clojure are some more functional programming
languages that have found employment in industry.

For risk analytics, functional "platforms" have become prominent in finance (particularly with the larger
investment banks). Lifestyle factors are represented as functions that build interdependence hierarchies
(categories) to measure correlations in market shifts, similar to Gröbner basis improvements, as well as
for regulatory compliance purposes, such as Comprehensive Capital Analysis and Review. Because of the
employment of OCAML or CAML variants in finance, these systems are sometimes thought to be related
to a categorical abstract machine, or CAM. Indeed, category theory has had a significant impact on
functional programming.

Education: Functional programming is taught or has been taught in many universities as part of their
undergraduate Computer Science degrees. Some people teach it as an introduction to programming, while
others teach it after imperative programming. Functional programming is being utilized outside of
computer science to teach problem solving, algebra, and geometric principles.

It has also been utilized as a teaching aid in Structure and Interpretation of Classical Mechanics.

Part 4:

1, Formulate corresponding proof principles to prove the following properties about defined sets

A = B <=> A ⊆ B and B ⊆ A

=> Answer: Assume we want to demonstrate that A = B. If we demonstrate A ⊆ B, then every element of
A is already in B, but there is still a chance that B contains elements which aren't in A, so we cannot
assume A = B. However, if we also display B ⊆ A, then B can't contain anything not in A, so A = B.
2, De Morgan's Law by mathematical induction.

=> Answer: De Morgan’s Law #1:

Occupancy P = (A U B)' and Q = A' ∩ B’. Let x be a subjective element of P then

x ∈ P ⇒ x ∈ (A U B)' ⇒ x ∉ (A U B) ⇒ x ∉ A and x ∉ B ⇒ x ∈ A' and

x ∈ B' ⇒ x ∈ A' ∩ B' ⇒ x ∈ Q

De Morgan’s Law #2:

Agreement P = (A ∩ B)' and Q = A' U B’. Let x be a random element of P then

x ∈ P ⇒ x ∈ (A ∩ B)' ⇒ x ∉ (A ∩ B) ⇒ x ∉ A or x ∉ B ⇒ x ∈ A' or

x ∈ B' ⇒ x ∈ A' U B' ⇒ x ∈ Q

3, Distributive Laws for three non-empty finite sets A, B, and C.

=> Answer: Using the indirect method:

Assume A, B, C be sets. If A ⊆ B and B ∩ C = ∅, then A ∩ C = ∅. Let A, B, C besets. If A ⊆ B and B ∩


C = ∅, then A ∩ C= ∅.

If we suppose the outcome is false and get a conflict, the theorem must be true.

Assume A ⊆ B and B ∩ C = ∅, and A ∩ C ≠ ∅. Let x ∈ A ∩ C be the proof that this cannot happen.

x ∈ A ∩ C ⇒x ∈ A and x ∈ C ⇒ x ∈ B and x ∈ C ⇒ x ∈ B ∩ C. This, however, contradicts the second


premise. As a result, the theorem is proven.

References:

1, Wikipedia contributors (2021) Functional programming, Wikipedia, The Free Encyclopedia. Available
at: https://en.wikipedia.org/w/index.php?title=Functional_programming&oldid=1059406385.

2, Wikipedia contributors (2021b) Multiset, Wikipedia, The Free Encyclopedia. Available at:
https://en.wikipedia.org/w/index.php?title=Multiset&oldid=1060422728.

3, Wikipedia contributors (2021c) Set (abstract data type), Wikipedia, The Free Encyclopedia. Available
at: https://en.wikipedia.org/w/index.php?title=Set_(abstract_data_type)&oldid=1047224096.

You might also like