Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Discrete math with computers_3

.pdf
Скачиваний:
87
Добавлен:
16.03.2016
Размер:
2.29 Mб
Скачать

C.6. PROPOSITIONAL LOGIC

401

Since P Q and P R are WFFs, (P Q) (P R) is a WFF.

Since (P Q) (P R) and P (Q R) are WFFs, (P Q) (P R) ↔ P (Q R) is a WFF.

P

Q

R

P Q

P R

 

Q R

(P Q) (P R)

 

True

True

True

True

True

 

True

True

 

True

True

False

True

True

 

True

True

 

True

False

True

True

True

 

True

True

 

True

False

False

True

True

 

False

True

 

False

True

True

True

True

 

True

True

 

False

False

True

False

True

 

True

False

 

False

False

False

False

False

 

False

False

 

 

 

 

 

 

P

Q

R

P (Q R)

(P Q) (P R) ↔ P (Q R)

True

True

True

True

 

 

True

 

 

True

True

False

True

 

 

True

 

 

True

False

True

True

 

 

True

 

 

True

False

False

False

 

 

False

 

 

False

True

True

False

 

 

False

 

 

False

False

True

False

 

 

True

 

 

False

False

False

False

 

 

True

 

 

 

 

 

 

 

 

 

 

 

 

The proposition is satisfiable but not a tautology.

6.

P and Q are WFFs.

Since P and Q are WFFs, ¬P and ¬Q are WFFs.

Since P , Q, ¬P and ¬Q are WFFs, P ¬Q and Q ¬P are WFFs.

Since P and Q are WFFs, P ↔ Q is a WFF.

Since P ↔ Q is a WFF, ¬(P ↔ Q) is a WFF.

Since P ¬Q and Q ¬P are WFFs, (P ¬Q) (Q ¬P ) is a WFF.

Since (P ¬Q) (Q ¬P ) and ¬(P ↔ Q) are WFFs, ((P ¬Q) (Q ¬P )) → ¬(P ↔ Q) is a WFF.

P

Q

¬P

¬Q

P ¬Q

Q ¬P

True

True

False

False

False

False

True

False

False

True

True

False

False

True

True

False

False

True

False

False

True

True

False

False

 

 

 

 

 

 

402

 

 

APPENDIX C. SOLUTIONS TO SELECTED EXERCISES

 

 

 

 

 

 

 

 

 

 

P

Q

 

(P ¬Q) (Q ¬P )

P ↔ Q

¬(P ↔ Q)

 

True

True

 

False

True

False

 

 

True

False

 

True

False

True

 

 

False

True

 

True

False

True

 

 

False

False

 

False

True

False

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

P

Q

 

((P ¬Q) (Q ¬P )) → ¬(P ↔ Q)

 

True

True

 

True

 

 

 

 

 

True

False

 

True

 

 

 

 

 

False

True

 

True

 

 

 

 

 

False

False

 

True

 

 

 

 

 

 

 

 

 

 

 

 

 

The proposition is a tautology.

7.(P → Q) (P → ¬Q)

P and Q are WFFs.

Since Q is a WFF, ¬Q is a WFF.

Since P , Q, and ¬Q are WFFs, P → Q and P → ¬Q are WFFs.

Since P → Q and P → ¬Q are WFFs, (P → Q) (P → ¬Q) is a WFF.

P

Q

¬Q

P → Q

P → ¬Q

(P → Q) (P → ¬Q)

True

True

False

True

False

False

True

False

True

False

True

False

False

True

False

True

True

True

False

False

True

True

True

True

 

 

 

 

 

 

The proposition is satisfiable but not a tautology.

8.(P → Q) (¬P → Q)

P and Q are WFFs.

Since P is a WFF, ¬P is a WFF.

Since P , Q, and ¬P are WFFs, P → Q and ¬P → Q are WFFs.

Since P → Q and ¬P → Q are WFFs, (P → Q) (¬P → Q) is a WFF.

P

Q

¬P

P → Q

(¬P ) → Q

(P → Q) (¬P → Q)

True

True

False

True

True

True

True

False

False

False

True

False

False

True

True

True

True

True

False

False

True

True

False

False

The proposition is satisfiable but not a tautology.

C.6. PROPOSITIONAL LOGIC

403

9.(P → Q) (¬Q → ¬P )

P and Q are WFFs.

Since P and Q are WFFs, ¬P and ¬Q are WFFs.

Since P , Q, ¬Q, and ¬P are WFFs, P → Q and ¬Q → ¬P are WFFs.

Since P → Q and ¬Q → ¬P are WFFs, (P → Q) (¬Q → ¬P ) is a WFF.

P

Q

¬P

¬Q

P → Q

¬Q → ¬P

(P → Q) (¬Q → ¬P )

True

True

False

False

True

True

True

True

False

False

True

False

False

True

False

True

True

False

True

True

True

False

False

True

True

True

True

True

 

 

 

 

 

 

 

The proposition is a tautology.

10.

QR

{ I}

RQ R

{ I}

P(Q R)

11.The proof of y will have a symmetrical shape, but the proof of x will appear triangular, with more inference on the right side than on the left. In the general case, the proof of x with 2n variables will have height 2n, because every extra variable will require one extra inference above everything else. In contrast, the proof of y with 2n variables will have height n.

12.

 

(P Q) R

 

 

 

(P Q) R

{ EL}

 

 

 

 

 

P Q

 

 

 

{ EL}

 

{ ER}

 

(P Q) R

{ ER}

 

 

P Q

 

 

 

 

 

{ EL}

 

 

Q

 

R

{ I}

 

 

 

 

 

 

Q R

 

P

 

 

 

 

{ I}

P (Q R)

13.

P P → Q

{→E}

PQ

 

 

 

{ I}

 

 

 

P Q

 

 

 

 

 

P Q → R S

E

 

 

 

 

 

{→

 

}

 

 

R S

 

 

{ ER}

S

404

APPENDIX C. SOLUTIONS TO SELECTED EXERCISES

15.

PQ

{ I}

QP Q

{→I}

Q → P Q

18.

PQ

{ I}

P Q

{ IL}

(P Q) (Q R)

19. We prove that True True True and then that True True True, without translating True into False False.

True True

{ ER}

True

{→I}

True True True

True True

{ I}

True True

{→I}

True True True

20. We prove that True False True and then that True False True.

 

True

False

 

 

 

 

{ID}

 

{CTR}

 

 

True False True

True

E

 

 

 

 

 

 

{

 

}

True

{→I}

True False True

True

{ IL}

True False

{→I}

True True False

23.

P is represented by P

Q FALSE is represented by Or Q FALSE

C.6. PROPOSITIONAL LOGIC

405

• Q → (P → (P Q)) is represented by Imp Q (Imp P (And P Q))

25. Proof by equational reasonong.

(P False) (Q True)

{ null}

= False (Q True)

= False Q

{ identity}

= Q False

{commutativity}

= Q

{ identity}

27. Proof by equational reasoning.

 

(P ((Q R) Q)) S

{ commutative}

= S (P ((Q R) Q))

= S (((Q R) Q) P )

{ commutative}

= S ((Q (R Q)) P )

{ associative}

= S ((Q (Q R)) P )

{ commutative}

= S (((Q Q) R) P )

{ associative}

= S ((Q R) P )

{ idempotent}

= S ((R Q) P )

{ commutative}

30. Proof by equational reasoning.

 

(A B) B

 

= { identity}

 

(A B) (B False)

 

= { comm}

 

(B A) (B False)

 

= { over }

 

B (A False)

 

= { null }

 

B False

 

= { identity}

 

B

 

31. Solution by equational reasoning.

406 APPENDIX C. SOLUTIONS TO SELECTED EXERCISES

(¬A B) (A ¬B) = { over }

((¬A B) A) ((¬A B) ¬B) = { comm}

(A (¬A B)) (¬B (¬A B)) = { over }

((A ¬A) (A B)) ((¬B ¬A) (¬B B)) = { comm}

((A ¬A) (A B)) ((¬B ¬A) (B ¬B)) = { compl }

(True (A B)) ((¬B ¬A) True) = { comm}

((A B) True) ((¬B ¬A) True)

={ identityappliedtwice}

(A B) (¬B ¬A)

={DM }

(A B) ¬(B A) = { comm}

(A B) ¬(A B)

32. The problem is solved by equational reasoning:

¬(A B)

={double negationappliedtwice} ¬(¬¬A ¬¬B)

={DM }

¬(¬(¬A ¬B))

= {double negation} ¬A ¬B

33. Solution by equational reasoning.

(A B) (¬A C) (B C) = { identity}

(A B) (¬A C) ((B C) False) = { compl }

(A B) (¬A C) ((B C) (A ¬A))

= { over }

(A B) (¬A C) ((B C A) (B C ¬A)) = { comm}

(A B) (¬A C) ((A B C) (¬A B C))

= { comm}

(¬A C) (A B) ((A B C) (¬A B C)) = { assoc}

(¬A C) ((A B) (A B C)) (¬A B C)

C.6. PROPOSITIONAL LOGIC

407

= { comm}

((A B) (A B C)) (¬A C) (¬A B C) = { assoc}

((A B) (A B C)) ((¬A C) (¬A B C)) = { over }

((A (B (B C))) (¬A (C (B C)))

= { comm}

(A ((B C) B)) (¬A ((B C) C)) = { comm}

(A ((C B) B)) (¬A ((B C) C)) = {absorbtion, appliedtwice}

(A B) (¬A C)

34. A solution in natural deduction style:

 

 

A ¬A

{ EL}

 

A ¬A

{ ER}

 

 

 

 

 

 

 

 

 

 

A

 

 

¬A

E

 

 

 

 

 

 

 

 

 

 

{→

 

}

 

 

 

 

False

 

 

 

 

A solution in the proof-checker notation:

hwThm1 = Theorem [A ‘And‘ (Not A)] (FALSE)

proof_hwThm1 =

 

 

 

 

 

 

 

 

(Assume(A ‘And‘ (Not A))

 

 

{----------------------------

 

 

 

 

 

 

 

} ‘AndEL‘

 

 

 

 

A,

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Assume(A ‘And‘ (Not A))

{---------------------------------

 

 

 

 

 

 

} ‘AndER‘

 

 

 

 

 

 

 

(Not A))

 

 

{------------------------------------------------------

 

 

 

 

 

 

 

 

 

}‘ImpE‘

 

 

 

 

 

 

 

(FALSE)

 

 

35.

 

 

 

 

 

 

 

 

 

hwThm2 = Theorem [A] ((A ‘Imp‘ FALSE) ‘Imp‘ FALSE)

proof_hwThm2 =

 

 

 

 

 

 

 

 

 

(Assume A,

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Assume(A ‘Imp‘ FALSE))

{---------------------------------------------------

 

 

 

 

 

 

 

 

} ‘ImpE‘

 

 

 

 

 

 

 

FALSE

 

 

{-------------------------------------------------------

 

 

 

 

 

 

 

 

} ‘ImpI‘

 

 

((A ‘Imp‘ FALSE) ‘Imp‘ FALSE)

 

A A → False

E

 

 

 

 

 

 

 

 

 

{→

 

 

}

 

 

 

 

False

{→I}

(A → False) False

408

APPENDIX C. SOLUTIONS TO SELECTED EXERCISES

36.

hwThm3 = Theorem [A, A ‘Imp‘ B, B ‘Imp‘ C, C ‘Imp‘ D] (D)

proof_hwThm3 =

(((Assume A, Assume(A ‘Imp‘ B))

{--------------------------

} ‘ImpE‘

B,

Assume(B ‘Imp‘ C))

{--------------------------------------

} ‘ImpE‘

C,

Assume(C ‘Imp‘ D))

{----------------------------------------------

} ‘ImpE‘

 

D

A A → B

{→E}

BB → C

 

 

 

{→E}

 

 

 

 

 

 

 

 

C

 

C → D

E

 

 

 

 

 

{→

 

}

 

 

D

 

 

37.

hwThm6 = Theorem [A ‘Imp‘ B] ((B ‘Imp‘ FALSE) ‘Imp‘ (A ‘Imp‘ FALSE))

proofThm6 =

(((Assume A, Assume(A ‘Imp‘ B))

{-----------------------------

} ‘ImpE‘

B),

Assume(B ‘Imp‘ FALSE))

{-------------------------------------------

} ‘ImpE‘

 

FALSE

{-----------------------------------

} ‘ImpI‘

(A ‘Imp‘ FALSE)

{-----------------------------------

} ‘ImpI‘

((B ‘Imp‘ FALSE) ‘Imp‘ (A ‘Imp‘ FALSE))

A A → B

 

 

 

 

 

{→E}

B → False

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

B

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

{→E}

 

 

 

 

 

 

 

 

 

 

 

 

False

 

 

{→I}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A → False

 

 

 

 

I

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

{→

}

 

 

 

(B → False) (A → False)

 

 

 

 

 

 

 

 

 

38.

 

 

 

 

A A → ¬B

 

 

 

 

 

 

 

 

 

 

 

 

A A → B

E

 

 

E

 

 

 

 

 

 

 

 

 

 

 

{→

 

}

¬B

{→

 

}

 

 

 

 

 

 

 

 

 

B

 

 

 

 

 

 

{→

E

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

False

{→I}

A → False

C.6. PROPOSITIONAL LOGIC

 

 

 

 

 

 

 

 

 

 

 

 

 

409

39.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

A A → False

 

 

 

 

 

 

 

 

 

 

 

 

 

A A → False

E

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

E

 

 

 

 

 

 

 

 

 

 

{→

 

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

{→

 

}

 

 

 

 

 

 

 

 

False

 

 

 

{CTR}

 

 

 

 

False

 

 

 

 

 

{CTR}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

B

 

 

 

 

 

 

 

¬B

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I

 

 

 

 

 

 

 

 

 

 

I

 

 

 

 

 

 

A → B

 

 

 

 

 

 

{→

}

 

 

 

A → ¬B

 

 

{→

}

I

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

{

}

41.

 

 

 

 

 

(A → B) (A → ¬B)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

P Q

 

 

 

 

R S

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

{ I}

 

 

{ I}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

P Q

 

 

 

 

R S

 

 

 

I

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(P Q) (R S)

 

{

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

42.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

P Q

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

{ EL}

 

P → R

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

P

 

 

 

 

E

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

{→

 

 

}

 

 

 

 

 

 

 

R

{→I}

PQ → R

43.We prove that True True True and then that True True True.

 

True

True

 

 

 

 

{ID}

 

{ID}

 

 

 

 

 

 

 

True True True

True

E

 

 

True

 

 

{

 

}

 

 

 

 

 

 

{→I}

True True True

True

{ IL}

True True

{→I}

True True True

45. A list comprehension can generate a truth table for you.

logicExprValue1 = [((a,b),logicExpr1 a b) | a <- [False,True],

b <- [False,True]

]

logicExprValue2 = [((a,b),logicExpr2 a b) | a <- [False,True],

b <- [False,True]

]

410

APPENDIX C. SOLUTIONS TO SELECTED EXERCISES

46.

logicExprValue3 = [((a,b,c),logicExpr3 a b c) | a <- [False,True],

b <- [False,True], c <- [False,True]

]

logicExprValue4 = [((a,b,c),logicExpr4 a b c) | a <- [False,True],

b <- [False,True], c <- [False,True]

]

47.

distribute :: Logic -> Logic

distribute (And a (Or b c)) = Or (And a b) (And a c) distribute (Or a (And b c)) = And (Or a b) (Or a c)

deMorgan :: Logic -> Logic

deMorgan (Not (Or a b)) = And (Not a) (Not b) deMorgan (Not (And a b)) = Or (Not a) (Not b) deMorgan (And (Not a) (Not b)) = Not (Or a b) deMorgan (Or (Not a) (Not b)) = Not (And a b)

48.

(C A B) C

{ commutative}

= C (C A B)

= (C C) (C A) (C B)

{ distributes over }

= C (C A) (C B)

{ idempotent}

= C ((C A) (C B))

{ associative}

= C (C (A B))

{ distributes over }

49.

C (A (B C))

{ distributes over }

= C ((A B) (A C))

= C ((A C) (A B))

{ commutative}

= (C (A C)) (A B)

{ associative}

= ((C A) (C C)) (A B))

{ distributes over }

= ((C A) C) (A B)

{ idempotent}

Соседние файлы в предмете Дискретная математика