AAmit’s LibraryLEARN · PRACTISE · REFLECT

BCA

Sets, logic, functions, counting, and proof

Study map: BCA mathematics extension; informed by comparative computing curricula

A set is a collection of distinct elements. Membership asks whether an element belongs to it. Union combines elements from either set; intersection retains common elements; difference retains elements of one set absent from another. A subset has every element contained in another set. An empty set has no elements and differs from a set containing zero.

1. Sets and operations

A set is a collection of distinct elements. Membership asks whether an element belongs to it. Union combines elements from either set; intersection retains common elements; difference retains elements of one set absent from another. A subset has every element contained in another set. An empty set has no elements and differs from a set containing zero.

For A={1,2,3} and B={3,4}, the union is {1,2,3,4}, the intersection is {3}, and A−B={1,2}. Counting a union uses |A∪B|=|A|+|B|−|A∩B| for finite sets. This avoids counting shared elements twice and parallels the addition rule in probability.

Further reading: MIT Mathematics for Computer Science

2. Logic and implication

A proposition is a statement with a truth value. Conjunction requires both propositions; disjunction requires at least one; negation reverses truth. An implication P→Q states that P is sufficient for Q. It does not say that Q requires P. The converse Q→P is a different statement.

The contrapositive ¬Q→¬P is logically equivalent to the original implication. Quantifiers distinguish ‘for all’ from ‘there exists’. One counterexample disproves a universal claim, while exhibiting an appropriate witness is one way to prove an existential claim. Classical proofs can also establish existence without constructing a specific witness. These distinctions help write program specifications and evaluate mathematical arguments.

Further reading: MIT Mathematics for Computer Science

3. Functions, relations, and counting

A function assigns each input in its domain exactly one output in its codomain. Injectivity means different inputs have different outputs. Surjectivity means every codomain element is reached. A relation is more general and can associate several outputs with an input. Composition applies one function after another, with compatible domains.

The multiplication rule counts choices performed in stages under stated conditions. If a code has two positions and each independently permits three symbols, there are 3²=9 strings. If repetition is forbidden, there are 3×2=6. Combinations count selections where order does not matter; permutations count arrangements. State whether repetition and ordering matter before selecting a formula.

Further reading: MIT Mathematics for Computer Science

4. Proof and computational use

A direct proof derives the conclusion from assumptions. A contradiction proof shows that denying the claim conflicts with established conditions. Induction proves a base case and a step from one case to the next, with a clearly stated domain. Checking several examples is not equivalent to a general proof.

For the sum 1+…+n=n(n+1)/2, the base n=1 holds. Assuming the formula for n, adding n+1 gives n(n+1)/2+(n+1)=(n+1)(n+2)/2, establishing the next case. Such reasoning connects to loop invariants and recursive algorithms. Work through the logic slowly before memorising the result.

Further reading: MIT Mathematics for Computer Science

Applied business–computing case: reason, implement and review

Model an approval process as a directed graph. Vertices represent states or activities and edges represent allowed transitions. A cycle may represent legitimate rework or an unintended route that never completes. Reachability asks whether a final state can be reached from a given start; an unreachable completion state reveals a structural problem before code is written.

Use sets to define permitted roles and logical predicates to express approval conditions. Check whether two conditions can both hold or whether no route applies. A truth table can expose a missing case in a rule such as “approve if credit is valid and stock is available”. Extend the model with an exception state and explicit ownership. Discrete reasoning helps computers follow complete rules while managers decide what the rules should mean.

Prove an access rule and count permitted codes

Let A={Ana, Bo, Chen} be trained staff and B={Bo, Devi} be authorised approvers. Find A union B, A intersection B and A minus B; the expected sets contain four, one and two people respectively. A rule states: if a person approves a payment, they are trained. Write its implication and contrapositive. The stated sets do not satisfy the rule: Devi is in the approver set B but not the trained set A. Identify this violation and explain why the rule would require B to be a subset of A. Separately, being trained does not by itself establish approval authority; Ana is a counterexample to that converse under these sets.

Next count three-symbol codes with two ordered positions. Repetition allowed gives nine possibilities; without repetition there are six. List the latter to check the multiplication rule, then explain why choosing two symbols without ordering gives three selections. Submit the sets, a truth table and the counting argument. Finite examples check this instance but cannot prove a universal policy about all staff.

An undergraduate should compute and distinguish implication from converse. A postgraduate should translate a more complex approval policy with quantifiers and test whether it admits an unintended case. A research learner should state a formal specification and a proof obligation for policy consistency. For retention, reproduce the induction step for the sum of the first n integers and identify the assumption used; checking three sums is not induction.

Study questions and answers

Is the converse of an implication always equivalent?

No. P→Q does not imply Q→P. The contrapositive is equivalent.

How many two-symbol strings from three symbols without repetition?

Six, because there are three first choices and two remaining second choices.

Extended practice questions

Explain sets and logical conditions using customer eligibility.

A set identifies a collection defined by a rule, such as customers with an active account. Another set may contain customers who completed a prerequisite. Eligibility requiring both conditions corresponds to their intersection; eligibility allowing either corresponds to their union. Specify the universe and definitions so missing status is not silently treated as a known false value. Logical rules can become software checks, but mathematical precision does not establish whether the business rule is fair, useful or authorised. Managers must examine the meaning before implementation.

Marking guide: Set rules; intersection/union; universe/missingness; business validity. Indicative allocation: reasoning 4; application or workings 3; assumptions and limits 3.

Marks: 10

In a group of 40 customers, 20 use service A, 15 use B and five use both. Calculate users of at least one and neither.

At least one service is the union: 20 plus 15 minus five equals 30 customers. Subtracting the overlap prevents counting those five twice. Neither is 40 minus 30, giving ten. Exactly A is 15 and exactly B is ten under these counts. The result assumes the sets refer to the same 40 customers and observation period, with complete membership information. If identifiers are duplicated or the periods differ, the arithmetic no longer answers the intended customer question. Define the counting universe before using the result.

Marking guide: Union30/neither10; overlap; exactly15/10; consistentuniverse. Indicative allocation: reasoning 4; application or workings 3; assumptions and limits 3.

Marks: 10

Critique assuming a logically valid eligibility rule is automatically good business policy.

A rule can be internally consistent while using inappropriate categories or omitting relevant circumstances. Requiring two recorded fields may exclude a legitimate customer whose record is incomplete. Examine the intended purpose, error consequences, exception route and authority for the rule. Test boundary cases and missing information separately. Computing can apply the logic consistently, which may amplify an unsuitable policy rather than improve it. Logical analysis establishes relationships between stated conditions and conclusions; it does not independently establish that the conditions are justified in the real setting.

Marking guide: Validity versus appropriateness; missing/boundaries; exceptions; amplification; purpose. Indicative allocation: reasoning 4; application or workings 3; assumptions and limits 3.

Marks: 10

Frame research on formalising business rules before software implementation.

Compare implementation episodes where teams define rules with explicit sets, conditions and examples against suitable less formal episodes. Measure ambiguity discovered, correction effort and accepted outcomes, not merely document length. Record task complexity, analyst experience and stakeholder participation. Examine whether formalisation surfaces disagreement or hides it behind unfamiliar symbols. A useful contribution identifies which representations improve shared understanding and under what conditions. It should acknowledge that fewer coding errors do not guarantee an appropriate policy, because the faithfully implemented rule may still be conceptually flawed.

Marking guide: Comparison/ambiguity/outcomes; confounders; shared understanding; policy limitation. Indicative allocation: reasoning 4; application or workings 3; assumptions and limits 3.

Marks: 10

A rule says 'if an order is approved, it has a review record'. Can a review record alone prove approval?

No. The implication approved⇒review record does not generally imply its converse review record⇒approved. A reviewed order may be rejected or remain pending. Use the actual approval state and evidence rather than substituting a necessary condition for a sufficient one. Define whether records can be incomplete or stale, and check the transition rules. Logic can clarify a business control, but the factual record quality still matters. IT should encode the intended condition and management should verify that the condition represents the real authorisation process.

Marking guide: Implication versus converse; pending/rejected counterexample; necessary/sufficient; record and authority limits. Indicative allocation:reasoning4;application or workings3;assumptions and limits3.

Marks: 10

Compare union and intersection when combining customer contact lists.

The union contains customers appearing in at least one list; the intersection contains those appearing in both. If records use stable customer identifiers, these operations can describe coverage and overlap. Name similarity alone is not a dependable identity rule. Decide how duplicates and conflicting contact preferences are handled before combining records. Set membership does not establish permission to contact a person or accuracy of the address. Marketing defines the intended audience and record rules; computing implements the agreed operation and exposes unresolved identity matches for review.

Marking guide: At-least-one versus both; identity/deduplication; permission distinction; ownership. Indicative allocation:reasoning4;application or workings3;assumptions and limits3.

Marks: 10

List A has 30 unique customers, B has 25, and 10 are shared. Find the union size and customers in A only.

The union size is30+25−10=45, subtracting the overlap once because it was counted twice in the sum. The A-only size is30−10=20. B-only is25−10=15, so20+10+15=45 independently checks the partition. The calculation assumes correctly matched unique identifiers and the stated overlap. It does not establish whether records are current or suitable for the intended action. A computer query should preserve the identity rule and counts so a manager can reconcile the result rather than treating 45 as automatically valid business coverage.

Marking guide: Union 45;A-only 20;partition check;unique-ID assumption; data-use limit. Indicative allocation:reasoning4;application or workings3;assumptions and limits3.

Marks: 10

Define a logical rule and counterexample test for dispatch authorisation.

State the intended rule explicitly, such as dispatch permitted only when the order is approved and stock is allocated. Test approved-without-stock, stock-without-approval and both-conditions-present cases. Also define cancellation, expired approval and changed quantities rather than relying solely on a Boolean shortcut. Preserve who approved and when. Logic identifies combinations; an implementation must validate current records and authorised transitions. Operations owns allocation and finance or the designated role owns approval. A true expression is not sufficient if its input flags are stale or can be changed by an unauthorised user.

Marking guide: Conjunction/counterexamples; temporal exceptions; evidence/currentness; role enforcement. Indicative allocation:reasoning4;application or workings3;assumptions and limits3.

Marks: 10

Revision cards

Explain sets and logical conditions using customer eligibility.

Both conditions means intersection; either means union. Define the universe and missing-status treatment before automating eligibility.

In a group of 40 customers, 20 use service A, 15 use B and five use both. Calculate users of at least one and neither.

At least one: 30; neither: ten; exactly A: 15 and exactly B: ten, within the stated universe.

A rule says 'if an order is approved, it has a review record'. Can a review record alone prove approval?

No:approval may require a review record, while a review can end in rejection or pending status. The converse does not follow.

Compare union and intersection when combining customer contact lists.

Union includes either list; intersection includes both. Apply them to agreed identifiers, not assumed identity or contact permission.

List A has 30 unique customers, B has 25, and 10 are shared. Find the union size and customers in A only.

Union 45; A-only 20; B-only 15. The result assumes 30 and 25 are unique counts with 10 correctly matched shared customers.

Define a logical rule and counterexample test for dispatch authorisation.

Test approval AND allocation, including each missing condition. Current, authorised inputs are needed; a true flag combination alone is not adequate control.

Why is a counterexample useful in reasoning about business rules?

One valid counterexample disproves a universal claim. Identify the rule’s domain and test boundary cases before encoding it. Passing selected examples cannot establish that a rule works for every possible input.

How can a graph represent departmental dependencies?

Represent tasks or departments as nodes and specify what each edge means. Directed edges can show required handoffs. Do not infer authority, duration or causation unless the graph explicitly models those relationships.

Practice task

Write a set-operation example, a truth table for implication, an injective function, and an induction proof. For each, explain one application to programming.

Sources and further reading

Related courses

Open interactive reading and progress tools