0% found this document useful (0 votes)
13 views5 pages

Discretemath

The document provides an overview of discrete mathematics, focusing on logic, propositions, and set theory. It explains the use of truth tables, logical connectives, and operations on sets, including union, intersection, and difference. Additionally, it discusses algorithms, recursion, and pseudocode as essential components of programming in this mathematical context.

Uploaded by

KIM Tae HYUNG
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

Discretemath

The document provides an overview of discrete mathematics, focusing on logic, propositions, and set theory. It explains the use of truth tables, logical connectives, and operations on sets, including union, intersection, and difference. Additionally, it discusses algorithms, recursion, and pseudocode as essential components of programming in this mathematical context.

Uploaded by

KIM Tae HYUNG
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

DISCRETE MATHEMATICS • Truth tables are used to show how these

• It is a branch of mathematics that only operators can combine propositions to


accepts discrete values. compound propositions.
• Develops mathematical reasoning.
• Used for counting things, studying

(XOR)
p⊕q

F
T
T
F
interactions between finite sets, and
analyzing processes with a finite number of
steps.

(IF AND, ONLY IF)


LOGIC is the study of reasoning

p↔q
• It is concerned with the validity of arguments,

T
F
F
T
the truth of statements, and the relationship
between different propositions.

PROPOSITION is a declarative sentence that can

p→q
(IF)

T
F
T
T
be either true or false, but not both.

Ex.
PROPOSITION NOT PROPOSITION
The earth is flat. Questions(?) (OR)
pVq

Cats are mammals. Commands

T
T
T
F
It will rain tomorrow. Exclamation(!)

PROPOSITIONAL LOGIC (Sentential logic)


• branch of logic that deals with
(AND)
pꓥq

T
F
F
F
propositions—declarative statements that
can be classified as either true or false.
~q /¬q

• Propositions are often represented in small


(NOT)

F
T
F
T
letters.
• The value of a proposition (p) is called its
TRUTH VALUE.
p
T

F
q

T or 1
F or 0

COMPOUND PROPOSITIONS
• proposition constructed by combining one
T

F
p

(1) or more existing propositions.


• we can build compound propositions using
logical connectives.
In the last column, if the truth values are SETS - well-defined and un-ordered
All TRUE – the statement is a TAUTOLOGY collection or aggregate objects.
All FALSE – the statement is a CONTRADICTION
Mixed values – the statement is a CONTINGENCY Universal Set (U) - The set that contains all
elements relevant to a particular discussion or
LOGICAL EQUIVALENCE – 2 different compound problem.
propositions that have the SAME/IDENTICAL truth
values in every model. Represented with (≡) Venn Diagram - a way of visually representing sets
Ex. of items or numbers by using their logical
1. relationships to decide how they should be
𝑃: ¬(𝑝 ↔ 𝑞) CONTINGENCY grouped together.
p q (𝑝 ↔ 𝑞) ¬(𝑝 ↔ 𝑞)
T T T F
T F F T
F T F T
F F T F

Q: p ∧ ¬q CONTINGENCY
p q ¬q p ∧ ¬q
T T F F
T F T T
F T F F
F F T F • Invented by an English mathematician, John
Is P logically equivalent to Q? NO 𝑃 ≢ 𝑄 Venn (1834-1923) to illustrate ideas in his
2. If it is sunny or the temperature is above 20°C, text on symbolic logic, published 1881.
then Sarah will go to the park.
Propositions: Elements(Є)
p: it is sunny • It denotes “belongs to” or “is an element
q: the temperature is above 20°C of” a set.
r: Sarah will go to the park Ex. A = {4, 5, 6} then 4 ∈ A, 7 ∉ A
Symbol: (p ∨ q) → r
Truth table: Cardinal number – number of elements in a set.
p q r (p ∨ q) (p ∨ q) → r • Symbolized by n(A) or |A|.

T T T T T Infinite Set – sets that are not countable


T T F T F - can be denoted by {…}
T F T T T Ex. A = {x|x > 1}
T F F T F
F T T T T Finite Set – sets that are countable
Ex. A = {1,2,3}
F T F T F
F F T F T
Set Representation
F F F F T Roster Method – listing - A = {1,2,3,4,5}
Set Builder Notation – stating rules or condition. SET INTERSECTION
A = {x|x > 0, x <6} • Set made from common values of 2
different subsets of the universal set
Set Equality – 2 set with same values • Denoted by ∩
Ex. • Expressed as 𝐴 ∩ 𝐵 = {𝑥 ∈ 𝑈|𝑥 ∈ 𝐴 ∧
A={9,2,7,-3} B={7,9,-3,2} Equal x ∈ B}
A={1,2} B={1,1,1,2,2,2,2,2} Equal
A={1,2,3} B={1,3,5} Not Equal

Subset
- Set contained in a larger set or in an equal set.
- Denoted by ⊆
A={4,5,6} B={1,2,3,4,5,6,7,8,9} A⊆B SET UNION
A={...,-8, B={...,-8,-6,-4, A⊈B
• Set made of elements from the universal set
-4,0,4,8,...} -2,0,2,4,6,8}
where it is either from subset A or B or both
Proper Subset • Denoted by ∪
• It is a subset that is not equal to the set it • Expressed as 𝐴 ∪ 𝐵 = {𝑥 ∈ 𝑈|𝑥 ∈ 𝐴 ∨
belongs to. x ∈ B}
• Denoted with ⊂
A={4,5,6} B={1,2,3,4,5,6,7,8,9} A⊂B

Number of distinct subsets = 2n


Number of distinct proper subsets = 2n – 1

Note: List all distinct subsets when finding the no. SET DIFFERENCE
of subsets/proper subsets. • Set made by elements from a subset
without the common elements in another
Null Set – empty set/ set with no elements subset
• Denoted by {} or ∅ • Denoted by A-B
• Expressed as A-𝐵 = {𝑥 ∈ 𝑈|𝑥 ∈ 𝐴 ∧
SET OPERATIONS x ∉ B}
SET COMPLEMENT
• Set of all elements that are in the universal
set (U) that isn’t in a specific subset.
• Denoted by A’ or A ̅
• Expressed as A' = {x ∈ U | x ∉ A}

SYMMETRIC DIFFERENCE
• Set made from elements of both subsets
without the common elements of both
subsets
• Denoted as A ⊕ B, (A-B) ∪ (B-A)
If student's grade is greater than or equal to 60
Print "passed"
else
Print "failed"

Pseudocode

RECURSION
ALGORITHMS • technique in programming that calls itself
• Finite set of instructions that specify a • has the capability to save the condition it
sequence of operations to be carried out was in or the particular process it was
• All the tasks that can be carried out by a serving when calling itself
computer can be stated as algorithms • can be written using ASSIGNMENT
STATEMENT, IF-ELSE STATEMENT and WHILE
CRITERIA STATEMENT
1. INPUT TYPES
2. OUTPUT 1. DIRECT – the function calls itself directly
3. DEFINITENESS – clear within the body
4. FINITENESS – countable
5. EFFECTIVENESS – feasible Ex. Factorial Calculator

Ex. Design an algorithm to add two numbers and FUNCTION Factorial(n)


display the result IF n == 0 OR n == 1 THEN
RETURN 1
STEP 1 - START ELSE
STEP 2 - GET values a & b RETURN n * Factorial(n - 1) // Recursive call
STEP 3 - c←a+b ENDIF
STEP 4 - DISPLAY c END FUNCTION
STEP 5 - STOP
2. INDIRECT – 2 or more functions call within a
PSEUDOCODE loop
• Textual representation of a flowchart
• Could be translated into a program Ex. Even and Odd Number Checker

Ex. FUNCTION isEven(n)


Problem: Create a program that will display if the IF n == 0 THEN
grade is passed or failed. RETURN TRUE // Base case: 0 is even
ELSE
Purpose of the program RETURN isOdd(n - 1) // Calls isOdd function
This program will allow the user to ENDIF
determine if the student passed or failed based on END FUNCTION
the grade.
FUNCTION isOdd(n)
IF n == 0 THEN
RETURN FALSE // Base case: 0 is not odd
ELSE
RETURN isEven(n - 1) // Calls isEven function
ENDIF
END FUNCTION

STEPWISE REFINEMENT
• process by which a programmer refines an
initial idea to a problem’s solution into more
specific terms
• The last phase of refinement results in a
program ready to be coded for execution

ANALYSIS OF ALGORITHM
• Determining the number of resources such
as time and storage to execute a program
• Usually in terms of CPU time and memory

You might also like