Reflection of CSC165 Lec1 2014.Sep.9th.
1.1 Introduction
Since its the first lecture, plenty of time is spent on emphasizing rules and requirements of the course. Its not necessary to spend time describing that in the blog, but the part after becomes really hard to understand.(1.2 of the lecture)
1.2 Precision
1.2.1 Four paragraphs of codes
Four paragraphs of codes are showed and compared in section 1.2. As I did not use any Python and my first CSC108 course started one day after this CSC165, I am so confused of these codes during the lecture. I cannot figure out the difference between 1&3, 2&4 (Figure 1.1) as I think they just change the order of expression as the picture shows in my note (Figure 1.2).Figure 1.1
Figure 1.2
After reviewing the slides, I found professor's comment for Q1 is:
"whether every element of S1 is not in S2".
while for Q3 is:
"Whether there exists an element in S1 which is not in S2".
These notes make me understand the difference between Q1 and Q3. Basically it implies how we understand the words after "if". Moreover, it really matters about what we defined directly and indirectly. So we can paraphrase the Q1 and Q3 like this:
Q1:"(all) x is in S1, if (all) x is in S2 ==>false
(all) x is in S1, if (any) x is not in S2 ==>true"
Q3:"(all) x is in S1, if (all) x is not in S2 ==>true
(all) x is in S1, if (any) x is in S2 ==>false"
In Q1 we directly define what is false. The negation of false is true then. This is why we have "any" but not "all" before the X in the negation part. This idea makes sense to me after the MAT137 course which we review the concept negation and how it works in different cases.
Now it becomes clear, if we want to prove "all X is in S2" is not false, only one case that "X is in S2" is enough.
By concluding this, we say there is a implied "all" before the X which's condition is directly mentioned.
1.2.2 Python syntactic sugar
There are two main symbols all(L) and any(L). Understanding them could to summarize the content in 1.2.1 better."all(L): whether all elements in L are True.
➔ all([True, True, True])
◆ TRUE
➔ all([True, False, True])
◆ FALSE
any(L): whether any element in L is True
➔ any([False, False, False])
◆ FALSE
➔ any([False, False, True])
◆ TRUE"
So Q1 in 1.2.1 could also be written like
Q1: return all([X not in S2 for X in S1]) which is the same as
return any([X in S2 for X in S1])
As mentioned in the powerpoint, it is an cooler way to code as it saves space.
1.3 Problem Solving and Quantifiers
1.3.1 Problem Solving
The
section of problem solving provides us a general pattern we might follow when
facing all problems. Basically these steps are recommended:
- Understand the problem
- Plan a solution
- Carry out your plan
- Review any solution you achieve
In
CSC108, we learnt about how to define a function. It also follow these steps
and lead to the program.
1.3.2 Quantifiers
The conception of quantifiers are mentioned in both this
course and MAT137. In MAT137 we have studied the symbol of there exists (∃) and for all (∀)
and used them in certain questions. In this course ∃ is called existential
quantification while ∀
is called universal quantification.
To prove universal quantification, we need verify every elements as
"all" of them must satisfy. To disprove universal quantification, we
just need to give a single counterexample which does not meet the requirement. To prove existential quantification, give single example. To
disprove existential quantification, verify all elements that does not meet the
quantification. They are vice versa basically.

没有评论:
发表评论