Jump to content
Banner by ~ Wizard
  • entries
    55
  • comments
    136
  • views
    14,933

Grammar Rant 01


Brony Number 42

740 views

It bothers me when people are imprecise with their writing. Consider the use of the conjunctions OR and AND. You will see sentences of the form: A or B and C or D. Without parentheses this is ambiguous. Let’s examine the various possible interpretations.

Let the circle with a cross represent a logic bit that can be true or false. I like to think of it as a normally-open contact, as in a motor control logic. The lines are a flow path. Think of them like a wire in a circuit. Reading from left to right.

image.thumb.jpeg.b394d3ae069e31d939723b7f7cf2e2f9.jpegimage.thumb.jpeg.b589fa227c1fca8c807589ab41fabc79.jpeg

We also need to consider how adjectives modify (nouns or verbs) that are conjoined. Using a negation, such as not or don’t, makes it even worse.

The NOT distributes into parentheses thusly:

not (A and B )= not A or not B

not (A or B )= not A and not B

For example, “I don’t like warm soda or milk.” Does “warm” distribute to milk, or just soda? Let us assume that it does distribute to “milk.” Therefore, the example sentence would be:

don’t like warm (soda or milk) = don’t like (warm soda or warm milk) = don’t (like warm soda or like warm milk) = don’t like warm soda and don’t like warm milk

But what about this: “Hunters wear orange vests and boots.” Orange is not intended to distribute to “boots.”

I suggest we insert more parentheses into our writing.

 

Edited by Brony Number 42

  • Brohoof 1

13 Comments


Recommended Comments

Makes me think of logic gates. People’s way of understanding others even when not spelled out correctly logically, is quite amazing.

I read the A or B and C or D like a Dot Product, which I am usually very good at using parentheses with (when I don’t have to, since multiplication come before addition in priority). We like to group things together to make things easier and faster to write, and in the end, we do understand each other, kinda.

  • Brohoof 1
Link to comment

On another point, it is quite difficult to get logic right. I don't blame people for taking shortcuts in their grammar. As a programmer, I have made quite a lot of mistakes on logic, the latest one was a JavaScript if-statement which caught me off guard since I thought it was going to yield something similar to my C++ programming, but it turned out I needed to be very specific with the and and or for that case. In C++ you get warnings if something you type is ambiguous, but JavaScript, it just lets you silently fail in disbelief until you find the issue.

  • Brohoof 1
Link to comment

@Splashee I guess Javascript is passive aggressive. I just read another example, "is not an option or convenient." The author meant "not an option and not convenient." It could also have been written "not ( an option or convenient )." Reading English is like solving a mystery! :Cozy: I'm going to take things literally from now on.

At work, the counter in the parts room has a sign that reads: "no food or drink allowed." Therefore I can have a drink, because it is allowed.

  • Brohoof 1
Link to comment

Going back to JavaScript again since the rules are well documented, we have the so called short-circuit evaluation:
 

Quote

The logical OR expression is evaluated left to right, it is tested for possible "short-circuit" evaluation using the following rule:

(some truthy expression) || expr is short-circuit evaluated to the truthy expression.

Short circuit means that the expr part above is not evaluated, hence any side effects of doing so do not take effect (e.g., if expr is a function call, the calling never takes place). This happens because the value of the operator is already determined after the evaluation of the first operand.


And then, not to forget the operator precedence:

Quote

The following expressions might seem equivalent, but they are not, because the && operator is executed before the ||operator:

true || false && false; // returns true, because && is executed first
(true || false) && false; // returns false, because grouping has the highest precedence


I am not a true JavaScript person, but I do like rules, so these are quite fascinating to me! C/C++ may work differently here.

if (!food || drink); // Won’t allow food as long as drink

if (!food || !drink); // Won’t allow any

if (!(food || drink)); // Won’t allow any

  • Brohoof 1
Link to comment
5 minutes ago, Splashee said:

if (!food || !drink)

I think you are incorrect. The above will be true if I have no food or no drink. So I am allowed to have one as long as I don't have the other.

  • Brohoof 1
Link to comment
48 minutes ago, Brony Number 42 said:

"no food or drink allowed."

Hell, by this statement, I can have both food and drink!

Link to comment
1 minute ago, Brony Number 42 said:

I think you are incorrect. The above will be true if I have no food or no drink. So I am allowed to have one as long as I don't have the other.

I’ll have to actually test this one when I get to my PC.

It is one of the most difficult to understand, hence why I never program using the ! operator.

  • Brohoof 1
Link to comment
2 minutes ago, Brony Number 42 said:

Hell, by this statement, I can have both food and drink!

You would be allowed only both if it was:

No(No(food) or No(drink))

as it would evaluate to simply:

food and drink.

  • Brohoof 1
Link to comment
6 minutes ago, Splashee said:

as it would evaluate to simply:

food and drink.

I don't think so. I read it as

No food or drink = (no food) or drink

So if I have both food and drink:

no food = false

drink = true

Edited by Brony Number 42
  • Brohoof 1
Link to comment
12 minutes ago, Splashee said:

No(No(food) or No(drink))

I meant this one will evaluate… I am really missing the code format button (I made a thread in Site Questions about it).

I can write it as:

!(!food || !drink) === (food && drink)

Where === is the JavaScript is equal to operator.

  • Brohoof 1
Link to comment
4 hours ago, Brony Number 42 said:

I think you are incorrect. The above will be true if I have no food or no drink. So I am allowed to have one as long as I don't have the other.

I am currently programming C so I had a chance to put this logic into test, but just so you know, C doesn't have booleans like C++ or JavaScript, so this is the test code:

	signed int food = 1;
	signed int drink = 1;
	signed int result = (!food || !drink);

Result became 0 after running this.

And now, for the compiled (unoptimized) code (intel x86 assembler):
 

												signed int food = 1;
01011AAE  mov         dword ptr [food],1  
												signed int drink = 1;
01011AB5  mov         dword ptr [drink],1  
												signed int result = (!food || !drink);
01011ABC  cmp         dword ptr [food],0  
01011AC0  je          1011AD4  
01011AC2  cmp         dword ptr [drink],0  
01011AC6  je          1011AD4  

01011AC8  mov         dword ptr [temp],0  
01011AD2  jmp         1011ADE  

01011AD4  mov         dword ptr [temp],1  

01011ADE  mov         eax,dword ptr [temp]  
01011AE4  mov         dword ptr [result],eax  

I just find it interesting to see how C compiles the logic into smaller components (very unoptimized because the use of a temporary variable).

 

result will be 1 (true) for all combinations of 'them' (you are making me say 'food and drink' which will probably trigger your grammar correction :awwthanks:), except when both of them are set to 1 (true), in which case result will be 0 (false).

 

  • Brohoof 1
Link to comment

Language is imprecise. You could just turn it around to be clear: "Hunters wear boots and orange vests." but yeah "Hunters wear orange vests and boots." is still unclear.

  • Brohoof 2
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Join the herd!

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...