COMP9020 4 – Guide 2024 Term 1SQL

Java Python COMP9020

Assignment 4 – Guide

2024 Term 1

Due: Thursday, 18th April, 18:00 (AEST)

Submission is through inspera. Your assignment will be automatically submitted at the above due date. If you manually submit before this time, you can reopen your submission and continue until the deadline. If you need to make a submission after the deadline,  please use this link to request an extension: https://www.cse.unsw.edu.au/ cs9020/extension_request.html. Unless you are granted Special Consid- eration, a lateness penalty of 5% of raw mark per 24 hours or part thereof for a maximum of 5 days will apply. You can request an extension up to 5 days after the deadline.

Answers are expected to be provided either:

•  In the text box provided using plaintext, including unicode characters and/or the built-in formula editor (diagrams can be drawn using the built-in drawing tool); or

•  as a pdf (e.g.  using LATEX) – each question should be submitted on its own pdf, with at most one pdf per question.

Handwritten solutions will be accepted if unavoidable, but we don’t recommend this approach as the assessments are designed to familiarise you with typesetting mathematics in preparation for the final exam and for future courses.

Discussion of assignment material with others is permitted, but the work submitted must be your own in line with the University’s plagiarism policy.

Objectives and Outcomes

The aim of this assignment is to build your understanding of logic and combinatorics.  Most questions are presented at a highly abstract level so that the consequences are very general, and can be applied in a variety of situations: not just later on in the course, but also beyond.  The specific motivation for each problem can be summarised as follows:

Problem 1: In this problem you are asked to show some identities that hold for an arbitrary boolean algebra by using the laws of boolean algebra operations. The problem is similar to what was asked in Assignment 1 with set operations, showcasing the link between the laws of set operations and the laws of boolean algebras.

Problem 2: In this problem you are asked to prove or  disprove logical equivalences in propositional logic.  This can also be solved in a similar way to Question 1 (and Q2 of Assignment 1), again showcasing the link between different aspects of this course.

Problem 3: Problem 3 asks you to apply propositional logic to a problem we saw in Assignment 2 which we modelled using graph structures and colourings on graphs.  This problem will showcase how one can use propositional logic to model constraint problems. The goal is to familiarise yourselves with how to think about applying propositional logic in the context of problems you have seen before.

Problem 4: This problem tests your ability to solve counting problems.   The problem requires to use tricks that were given in the lecture so that you can find a succinct way to express the number you are looking for.

Problem 5: In problem 5, you will use recursion to count the number of configurations of binary trees of certain size. The problem will thene explore how to link this back to other structures: full binary trees which were introduced in Assignment 3 and a special case of propositional formulas. Further demonstrating connections between different aspects of the course.

After completing this assignment, you will:

•  Understand Boolean and propositional logic (problems 1, 2, 3 and 5)

•  Understand the fundamental Computer Science concepts of recursion (problem 5)

•  Understand simple combinatorics and probability (problems 3, 4 and 5)

•  Be able to create and reason about abstract models of concrete (“real-world”) problems and objects (problems 3 and 5)

•  Understand several deeper connections between different topics of the course (all problems)

Advice on how to do assignments

Collaboration is encouraged, but all submitted work must be done individually without consulting someone else’s solutions in accordance with the University’s “Academic Dishonesty and Plagiarism” policies.

• Assignments are to be submitted in inspera.

• When giving answers to questions, we always would like you to prove/explain/motivate your answers. You are being assessed on your understanding and ability.

• Be careful with giving multiple or alternative answers.  If you give multiple answers, then we will give you marks only for your worst answer, as this indicateshow well you understood the question.

• Some of the questions are very easy (with the help of external resources).  You may make use of external material provided it is properly referenced – however, answers that depend too heavily on external resources may not receive full marks if you have not adequately demonstrated ability/understanding.

• In the assignment specification, questions have been given an indicative difficulty level:

Pass Credit Distinction High distinction

This should be taken as a guide only. Partial marks are available in all questions, and achievable by students of all abilities.

Specific advice on how to do this assignment

Problem 1: For this problem you are asked to prove identities using the laws of Boolean algebras.

Important

Full marks for these questions will only be awarded to proofs using the laws of Boolean algebra. Partial marks are available for proofs that show validity for a specific Boolean algebra.

• To get full marks your proof should apply for all boolean algebras.   The only thing that all boolean algebras have in common is the 10 laws of boolean algebras - so this means your proof should rely on these.

• You may use any result proven in lectures.  Note that any result proven using the laws of set operations translates directly to a proof using the laws of boolean algebras.  In particular this means that you can use:

Idempotence of Λ and ∨

Double complement: x′′ = x

Principle of duality

Uniqueness of complement

• In addition, since the results of Assignment 1 were proven using the laws of set operations (see solutions) you can also use:

Complement of 1: 1′ = 0 (this was a side result proven for Assignment 1)

Complement of 0: 0′ = 1 (the dual of the above)

Annihiliation: x Λ 0 = 0 and x ∨ 1 = 1 (Q2a and its dual)

De Morgan’s laws: (x Λ y)′  = x′ ∨ y′ and (x ∨ y)′ = x′ Λ y′ (Q2d and its dual)

• Partial marks are available for showing the results hold in a particular boolean algebra (e.g. the two element boolean algebra B). However as this is only one specific boolean algebra, you will

not receive full marks.

Remark

Some of these identities are useful intermediary results when working with Boolean algebras.

• Part b) corresponds to what is called the "absorption rule" in Boolean algebra, as you can see the y term gets "absorbed". There is a dual expression to this absorption rule, which might be of interest to think about (not necessary for the exercise).

• Part c) corresponds to what is called the "simplification rule", as we can see the compound term on the right gets simplified by getting rid of the x’ term. Again there is a dual rule to this one.

Problem 2 In this problems you will need to prove or disprove identities in propositional logic.

Important

Note that the question says prove or disprove - some (or all) of these equivalences may not hold

• Several approaches for proving/disproving logical equivalence were discussed in lectures - any of these are applicable.

• As an example, here is an HD-level answer for the question prove/disprove:

p → q ≡ ¬q → ¬p

This statement is true. We will prove it by truth table.

Using the definition of implication to rewrite p → 9 as →p V 9 and →9 → →p as → →9 V →p:

p 9

→p

→ →9

→p V 9

→ →9 V →p

T T

F

T

T

T

T F

F

F

F

F

F T

T

T

T

T

F     F

T

F

T

T

The two propositions have the same valuation for all valuations of the propositional vari- ables p and 9, and therefore the logical equivalence holds.

• An alternative proof could be:

This statement is true. We will prove it using the transitivity of logical equivalence and the equivalences stated in lectures.

We will rewrite the right-hand side to get the left-hide side:

→9 → →p = → →9 V →p                             (Implication)

= 9 V →p                                (Double negation)

= →p V 9 &n COMP9020 Assignment 4 – Guide 2024 Term 1SQL bsp;                             (Commutativity of V)

= p → 9                               (Implication)

Giving us the left-hand side and thus proving the logical equivalence.

• The proof assistant has been set up to do proofs of the second form.   Note you cannot  do disproofs using the proof assistant.

• To disprove a logical equivalence you need to find a valuation which makes one proposition true and the other one false.  In particular tis not sufficient to argue inequivalence based on syntax: e.g.  an argument that proceeds by proving that φ 三 p V (9 Λ p) and ψ 三 p Λ (9 V p) and then claiming that since p V (9 Λ p) and p Λ (9 V p) are "clearly different" it follows that φ and ψ are not equivalent - is not adequate. In fact, in this example it is invalid.

Problem 3 The purpose of this problem is to test your ability to model problems using propositional logic. We reuse the problem given in assignment 2, where graphs were used to model network problem with adjacency constraints.  The problem was to find a valid colouring of the graph such that no 2 colours were neighbours to one another.  Here you are given the same situation but have to use the newly introduced framework of propositional logic to model the constraints of the problem.

The problem guides you through a demonstration of how propositional logic can be used to model all kinds of constraint problems on the mathematical objects you have seen in this course. In this example you are encoding a graph colouring problem as a propositional formula, but you would be able to apply the same ideas to solve many other types of constraint problems.

Let’s use an example of a different graph problem to help you see how propositional logic can model these types of problems

• In part a) you are asked to define your variables. There are several valid choices for this. The idea is to define atomic propositions whose truth assignments will correspond to something about the network configuration chosen. In our example, we built statements pi="vertex i is selected". Here you must find propositions such that the truth or falsehood of the propositions tell us something about the networks that houses are using.

• Part b) then asks you to build from part a) to model the constraints in your problem.  In this part you will build compound formula that represent statements about how the network config- uration must behave. In the graph example above these corresponded to our φ and ψ formulas, which ensured that the constraints of the problem were represented as propositional logic. φ1 represented the proposition "One vertex must be selected" whilst φ2 represented the proposition "At least two vertices must not be selected". ψ represents the proposition "e1  must include the selected vertex and e2 must include the selected vertex".

In the network problem you are asked to solve, you must find formulas that will capture the constraints of the problem in terms of the propositions that you chose in part a).  Make sure to explain what propositions your propositional formulas represent.

• Part c) asks you how propositional logic can help you find a solution to the network problem. For the vertex selection problem, finding a satisfying assignment for our formula F gives us a solution to the initial problem.

• Part d) encourages you to reflect on the way you chose your propositions to model the problem, and if you can extend it for 3 networks.   There are many ways to model such problems in propositional logic.  Ideally we want to choose a way to model that doesn’t cause unnecessary complications, but can also be extended without too much difficulty.

• Part e) makes the link with probability and counting. Since we are uniformly choosing between each configuration, you may find the probability of choosing a valid configuration from all the possible configurations by counting each set and dividing the former by the latter. You have seen from previous questionshow you could count the number of valid configurations.

Problem 4 The goal of this question is to test your ability to use some of the tools you’ve seen in lecture 14 on counting.

If you are stuck on these questions, a good way to proceed is to first make sure you have understood the simplifying assumptions you can make. Then you can try and work with a scaled down version of the problem to figure out the possible arrangements and constraints and try and extract patterns and a strategy for how you would count effectively for the scaled up problem.

• The first question asks you to generalise your answer to a question in assignment 2.  Instead of looking for the number of valid colourings with a specific number of colours, we want a general formula with the number of colourings as a variable of the formula.  To find this formula you will need to use the product rule seen in the lectures and model how the constraints on a valid colouring affect the number of possible choices for each vertex.

• For part b) you must make use of symmetry to decompose the problem. The fact that the digits must be distinct allows us to reduce the problem to very few cases: no matter what the digits of our snakelike number are, they will have the form a < b < c < d with a, b, c, d ∈ [0, 9]. You do need to be careful with the 0 since it behaves a bit differently from the other digits (it cannot be placed at the beginning of our snakelike number).

• For part c) you want to define events that would satisfy our condition that are easy to count. If you have a relatively small number of such events, even if they overlap you can account for double counting using the principle of inclusion-exclusion.

It is helpful to consider how you might approach this problem for 3 people where 2 have to be in order of height.  If I define an event A="The first two people are in order of height" and an event B="The last two people are in order of height" I can then calculate the number of times A happens, along with the number of times B happens.This accounts for all cases since either A or B is true for my condition to be true, but I might be double counting when A and B are true. To account for this I need to count the number of cases where A and B are true and subtract it to the total. In this case just means that people are standing in order of height.

Problem 5 The goal of this problem is both to familiarise yourself with using recurrence relations to count the configurations of abstract structures but also to practice building correspondences between such structures.

As an example of how you build recurrence relations for counting the number of configurations satis- fying a certain condition of a structure defined recursively let’s have a look at the following example:

The set of paths moving down or right on an infinite grid defined recursively the following way:

Path.B: The sequence consisting of vertex v1  = (0, 0) is a path.

Path.I: If sequence v1, . . . , v kis a path then sequence v1, . . . , vk, v k+1 with v k+1 = v k+(0, 1) or v k+1 = v k+ (1, 0) is a path.

We are asked to count the number of such paths going from the top left (position (0,0)) to the bottom right (position (2,2)) of a grid.  For example for the 3 × 3 grid, these are the possible paths:

To get an expression to count the number of such paths, we want to use the recursive definition of a path to express the problem in term of sub-problems.

Based on the definition of a path, the number of paths that will make it to the bottom right of the grid can be expressed as the sum of paths coming from the top and paths that come from the left. Therefore if we can solve the following two subproblems:

We can solve our larger problem.

This points to the following recurrence relation:

Base case 1: For all n ≥ 1 P(n, 1) = 1

Base case 2: For all m ≥ 1 P(1, m) = 1

Recurrence: For all n, m > 1 P(n, m) = P(n − 1, m) + P(n, m − 1)

• In part a) you’re asked to derive a recurrence relation to count the number of possible configu- rations for binary trees of size n. As in the example, given above, you ust think about how you

can use the recursive definition for a binary tree to express the number of possible binary trees of size n in terms of smaller trees. All possible ways need to be accounted for in you recurrence relation.

• Part b) is guiding you through the reasoning you will need to answer c) by having you derive an identity that will be useful in linking full binary trees to binary trees. In assignment 3 you were asked to derive a link between the number of leaves and internal nodes in fully binary trees. This should allow you to say something on the total number of nodes.

• In part c), you need to establish a link between full binary trees and binary trees. Part b) lead you to decompose the number of nodes of a full binary tree in terms of its leaves and inner nodes, allowing us to make a statement about the fact that full binary trees must have an odd number of nodes. What does this say for B(n) when n is even? When n is odd, how can the identity from assignment 3 help us relate full binary trees to binary trees? The hint given along with the work you did to answer b) should help you build the correspondence you need.

• In part d), you are asked to derive an expression for F(n), the number of well-formed, negated normal form formulas that use precisely n propositional variables exactly one time each.  This question extends the discussion on the structural properties of binary trees to the realm of logical expressions, specifically focusing on those in negated normal form. Given that full binary trees can be closely associated with the structure of these logical expressions—where internal nodes represent binary operations (Λ or ∨), and leaves represent literals (propositional variables or their negations)—your task is to leverage this association to derive F(n). Considering the structure of well-formed formulas in negated normal form, you must account for all possible combinations of propositional variables and their negations, along with the two binary operations. This entails a comprehensive enumeration of the ways in which n variables can be combined under the constraints of negated normal form.  Use the insights from part b) and c), especially regarding the distribution of nodes within binary trees and how they correlate to logical operations and literals, to inform. your derivation of F(n). Reflect on the combinatorial aspects of this problem: each variable can appear as itself or negated, and each pair of terms (variables or compound expressions) can be combined with either Λ or ∨, but not in associative manners         

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值