Professional Documents
Culture Documents
1 - Introduction - Fundamentos Teoria
1 - Introduction - Fundamentos Teoria
1 - Introduction - Fundamentos Teoria
Unit 1
Introduction
University of Oviedo
University of Oviedo Computer Science Fundamentals
Table of contents
Unit 1: Introduction 2
University of Oviedo Computer Science Fundamentals
Unit 1: Introduction 3
University of Oviedo Computer Science Fundamentals
• What is a computer?
It is a machine that collects data,
processes them, and produces
an output.
It processes information much
Data bus
quicker than the human brain.
Address bus
It is programmable.
Control bus
• How are these actions carried
Given a second order polynomial p(x)=a·x2+b·x+c,
out? evaluate p(x) for all numbers x other than zero
o Architecture and block provided by the user.
diagram Algorithm:
print("Evaluating polynomials")
print("p(x)=a*x*x+b*x+c")
a = float(input("Type a: "))
§ Unique address space Ask for the coefficients b = float(input("Type b: "))
Ask for x c = float(input("Type c: "))
Unit 1: Introduction 4
University of Oviedo Computer Science Fundamentals
• Information on a computer
o Electrical signals are exchanged
through the buses
o Electrical signals are discrete (ALL /
NOTHING)!
o One example: the old Motorola 68000
Memory
Buses
CPU
Unit 1: Introduction 5
University of Oviedo Computer Science Fundamentals
• Hexadecimal system 10 0x 2 10 0x 2
o Base 16 0 0 0000 8 8 1000
§ Digits {0, 1, 2, 3, 4, 5, 6, 7, 8, 1 1 0001 9 9 1001
9, A, B, C, D, E, F} 2 2 0010 10 A 1010
o Possible values: integers in the 3 3 0011 11 B 1011
range [0, 15]
4 4 0100 12 C 1100
o Direct match between
5 5 0101 13 D 1101
hexadecimal and binary:
§ 16=24 à all the hex digits can 6 6 0110 14 E 1110
be represented with 4 bits 7 7 0111 15 F 1111
o Conversion between Use this table to easily convert
hexadecimal and decimal from binary to hexadecimal.
§ The same as in the binary case
Unit 1: Introduction 7
University of Oviedo Computer Science Fundamentals
Unit 1: Introduction 8
University of Oviedo Computer Science Fundamentals
Unit 1: Introduction 9
University of Oviedo Computer Science Fundamentals
Unit 1: Introduction 10
University of Oviedo Computer Science Fundamentals
Unit 1: Introduction 11
University of Oviedo Computer Science Fundamentals
Unit 1: Introduction 12
University of Oviedo Computer Science Fundamentals
Unit 1: Introduction 13
University of Oviedo Computer Science Fundamentals
Unit 1: Introduction 14
University of Oviedo Computer Science Fundamentals
Semantic rules
P1 P2 P1 Ú P2 P1 ¬ P1
T T T T T T T F
T F F T F T F T
F T T NOT
F T F
F F F F F F
AND OR
Unit 1: Introduction 15
University of Oviedo Computer Science Fundamentals
Unit 1: Introduction 16
University of Oviedo Computer Science Fundamentals
Logical laws
Logical laws are very important equivalences between propositions; i.e.,
propositions with an identical truth table. Being P, Q and R propositions:
• Associative • Complements
(P Ú Q) Ú R = P Ú (Q Ú R) P Ú ¬ P = T,
(P Ù Q) Ù R = P Ù (Q Ù R) P Ù¬P =F
• Commutative
PÚQ=QÚP • T and F
PÙQ=QÙP TÚP=T TÙP=P
FÚP=P FÙP=F
• Distributive
(P Ú Q) Ù R = (P Ù R) Ú (Q Ù R)
• De Morgan
(P Ù Q) Ú R = (P Ú R) Ù (Q Ú R)
¬(P Ú Q) = ¬ P Ù ¬Q
• Idempotent ¬(P Ù Q) = ¬ P Ú ¬Q
¬ ¬P = P
Unit 1: Introduction 17
University of Oviedo Computer Science Fundamentals
Syntactic simplifications
Unit 1: Introduction 18
University of Oviedo Computer Science Fundamentals
Translations
Unit 1: Introduction 19
University of Oviedo Computer Science Fundamentals
• Consider the expression “either the number x is odd, or even and greater or equal
to 10”. Write a Boolean expression in Python using a variable x with the same
meaning as in the previous sentence.
(Note that the expression a%b in Python returns the remainder when a is divided by b)
• Negate the previous expression and then apply the De Morgan’s laws, writing the
result without any negations. What would be the result for x=6?