PLAIN/TEXT — ISSUE 95/456 COMPUTER SCIENCE · FOUNDATION / CS · LOGICAL RULES · ~4 MIN READING DATE: 2027-01-04 ARCHIVE: https://plaintext.click/newsletter/ SUBJECT: What exactly does “and” mean in a program? What exactly does “and” mean in a program? ========================================== / START HERE A website might allow a download only when you are signed in and your subscription is active. Boolean logic is a system for combining statements that have two values: true or false. It turns a rule written in words into a decision with a definite result for each possible combination of inputs. / WHY NOW Small changes in these rules can admit the wrong person or block the right one. Understanding the connectors helps you read settings, filters and basic code without treating a complicated sentence as a single mysterious condition. / THE IDEA AND produces true only when both of its inputs are true. OR produces true when at least one is true, including when both are true. NOT reverses one truth value. These are operations on statements, not judgements about whether the whole policy is wise or fair. Use parentheses to say which smaller rule is evaluated together. In our download example, imagine a free preview is also allowed. The intended policy might require an account for paid content while allowing previews without signing in. Writing the groups explicitly removes the ambiguity of a long sentence containing both “and” and “or”. / THE FORMAL IDEA allow = (signed_in AND subscribed) OR preview - signed_in, subscribed and preview each hold either true or false. - The parenthesised pair is evaluated first. Its result is then combined with preview using OR; allow is the final decision. / RUN THE TINY EXAMPLE Change one thing. Predict what happens. Toy policy input: signed_in = true; subscribed = false; preview = false. Inside parentheses: true AND false = false. Then false OR false = false: deny. Change only preview to true: false OR true = true: allow. Alternative rule: signed_in AND (subscribed OR preview) would deny an unsigned-in visitor even for a preview. The third input genuinely bypasses the paid-content requirement in the first rule. Moving the parentheses would change that policy rather than merely changing its appearance. To compare the alternatives, try signed_in = false and preview = true; they produce different answers. / SO WHAT? A truth table lists every possible input combination and its result. For our three yes-or-no inputs there are eight combinations, so a complete check is small enough to do by hand. Testing only the happy path, where everything is true, would miss the difference between the two parenthesised policies. / ONE CAVEAT Here the inputs are already reliable true-or-false facts. Real software must also define missing information and check who may set each input. Some languages return input values from AND or OR rather than literal Boolean values. / KEEP THIS Grouping changes which conditions can override others; test mixed true-and-false inputs to reveal the actual rule. / SOURCE TRAIL [1] MIT Computation Structures — Boolean equations https://computation-structures.github.io/course/lectures/L04_Combinational_Logic.html [2] Python — Boolean operations https://docs.python.org/3/library/stdtypes.html#boolean-operations-and-or-not NEXT: Why is a door handle far from the hinges? --- HARD IDEAS. PLAIN TEXT. You are receiving this because you asked for one clear computer-science or physics idea each day. Unsubscribe: https://plaintext.click/unsubscribe View in browser: https://plaintext.click/newsletter/2027/01/2027-01-04-boolean-rules.html From: Plain/Text / Brickston Consulting · 30 N Gould St Ste N, Sheridan, WY 82801 US · knowledge@plaintext.click