TRƯỜNG ĐH CH KHOA ĐHQG-HCM
KHOA KH&KT Y TÍNH
BÀI KT GIỮA KỲ Học kỳ/Năm học 1 2020-2021
Ngày KT 04-11-2020
Môn học hình hóa Toán học
môn học CO2011
Thời lượng 70 phút đề 7121
Ghi chú: - SV được phép sử dụng 01 tờ giấy A4 viết tay chứa ghi chép cần thiết.
-SV phải ghi MSSV, họ và tên vào cuối trang y và nộp lại đề thi cùng với bài làm.
- Tô đậm phương án trả lời đúng vào phiếu làm bài trắc nghiệm.
- Bài thi 20 câu hỏi trắc nghiệm, mỗi câu điểm số 0.5.
Câu 1. (L.O.1.2)
Given the following program. With {a2}is a
precondition, which of the following is the post
condition?
A{ais prime}.
B{z= (ais prime)}.
C{true = (ais prime)}.
D{z(ais prime)}.
Câu 2. (L.O.1.2)
With a precondition, the program and the postcondition given in Question 3. In order to prove
the partial correctness of the corresponding Hoare triple, which of the following is an invariant
form we should use?
A(0 x2< a)y= (x+ 1)2.
B(0 < x2a)y= (x+ 1)2.
C(0 x2a)y= (x+ 1)2.
D(0 < x2< a)y= (x+ 1)2.
Câu 3. (L.O.1.2)
Given the following program. With
{a0}
is a precondition, which of the following is the
post condition?
A{0x2< a (x+ 1)2}.
B{0< x2< a (x+ 1)2}.
C{0x2a < (x+ 1)2}.
D{0< x2a < (x+ 1)2}.
Câu 4. (L.O.1.2)
With notions and terminology defined as in Question 7. Which of the following is incorrect?
A|=¬wp(P, ¬φ)wp(P, φ).
BIf |=φψthen |=wp(P, φ)wp(P, ψ).
C|=par (|φ|)P(|ψ|)if and only if |=φwp(P, ψ)
DIf |=wp(P, φ)wp(P, ψ)then |=φψ.
MSSV: . . . . . . . . . . . . . . . . . Họ và tên SV: . . . . . . . . . . . . . . . . . Trang 1/4
Câu 5. (L.O.1.2)
Given the following program, where we use ÷
to denote integer division, which always rounds
down, i.e.
n÷m=bn
mc.
With >is a precondition, determine the post-
condition yourself. In order to prove the partial
correctness of the corresponding Hoare triple,
which of the following is an invariant form we
should use?
Ar=XN.
Br=XNn.
Crxn=XN.
Dr=xn.
Câu 6. (L.O.1.2)
Given the following program. With
{a > 0b > 0}
is a precondition, which of the following is the
post condition?
A{y= gcd(a, b)}.
B{x= gcd(a, b)y=gcd(a, b)}.
C{x= gcd(a, b)}.
D{x=y= gcd(a, b)}.
Câu 7. (L.O.1.2)
A formula φis weaker than formula ψif ψφ. Given a set of formulas {φ1, φ2, ...}, φiis
the weakest formula in the set if φjφifor all j. Given a program Pand a formula ψ,
denote wp(P, ψ)the weakest precondition φsuch that |=par (|φ|)P(|ψ|). Moreover, we define
wp(P S, ψ) = wp(P, wp(S, ψ)). Which of the following is correct?
Awp(x:= x+y;y:= xy, x < y)((y < x < y)(y < 1)).
Bwp(x:= x+y;y:= xy, x < y)((y < x < y)(y > 1)).
Cwp(x:= x+y;y:= xy, x < y)((x > y)(y > 1)) ((x < y)(y < 1)).
Dwp(x:= x+y;y:= xy, x < y)((x > y)(y < 1)) ((x < y)(y > 1)).
Câu 8. (L.O.1.2)
With a precondition, the program and the postcondition given in Question 6. In order to prove
the partial correctness of the corresponding Hoare triple, which of the following is an invariant
form we should use?
Axy= gcd(a, b).
Byx= gcd(a, b).
Cgcd(x, y) = gcd(a, b).
Dgcd(x, y).
Câu 9. (L.O.1.2)
Given the following program. With
{a > 0b > 0}
is a precondition, which of the following is the
post condition?
A{z=ba}.
B{z=ab}.
C{z=ab}.
D{z=a+b}.
MSSV: . . . . . . . . . . . . . . . . . Họ và tên SV: . . . . . . . . . . . . . . . . . Trang 2/4
Câu 10. (L.O.1.2)
With a precondition, the program and the postcondition given in Question 9. In order to prove
the partial correctness of the corresponding Hoare triple, which of the following is an invariant
form we should use?
Az=xy.
Bz=xy.
Czxy=ab.
Dz=yx.
MSSV: . . . . . . . . . . . . . . . . . Họ và tên SV: . . . . . . . . . . . . . . . . . Trang 3/4