How is binary addition performed?

In summary, the conversation discusses the addition of binary numbers and how it differs from addition in the decimal system. It is mentioned that in the binary system, 1+1=0 with a carryover, while in the decimal system, 5+5=0 with a carryover. The conversation also touches on how to prove that a DFA represents binary addition and suggests checking all addition rules with and without carry to show that the DFA is correct. It is also mentioned that the definition of the desired function of the DFA should be checked. Finally, the conversation considers using induction on the length of the binary numbers to prove that the DFA performs the correct addition.
  • #1
evinda
Gold Member
MHB
3,836
0
Hello! (Wave)

According to some notes of computability theory:

Addition of binary numbers

$$10011\\ +11111 \\ ------ \\ 110010$$

View attachment 5766

I haven't understood how they do the addition, since it holds that $1+1=0$... (Sweating)

Could you explain it to me?
 

Attachments

  • nf.png
    nf.png
    4.1 KB · Views: 137
Physics news on Phys.org
  • #2
evinda said:
I haven't understood how they do the addition, since it holds that $1+1=0$...
I am not sure if you mean "I don't understand addition, in particular, why 1 + 1 = 0" or "I don't understand addition. I understand that 1 + 1 = 0, and this does not square with what the notes have".

In decimal system we also have 5 + 5 = 0 plus a carry into the next (more senior) position.
 
  • #3
Evgeny.Makarov said:
I am not sure if you mean "I don't understand addition, in particular, why 1 + 1 = 0" or "I don't understand addition. I understand that 1 + 1 = 0, and this does not square with what the notes have".

I meant this: " I understand that 1 + 1 = 0, and this does not square with what the notes have".

So you mean that we are not in the binary system?
 
  • #4
evinda said:
I meant this: " I understand that 1 + 1 = 0, and this does not square with what the notes have".

So you mean that we are not in the binary system?

Don't we have 1 + 1 = 10 in the binary system? (Wondering)

And for instance 11 + 01 = 100?
That is, starting from the right we have 1 + 1 = 0 with 1 to carry over.
And then we have 1 + 0 + carry-over = 0 with again 1 to carry over. (Nerd)
 
  • #5
evinda said:
I meant this: " I understand that 1 + 1 = 0, and this does not square with what the notes have".
Then you'll have to point out exactly what you don't understand in the notes.

evinda said:
So you mean that we are not in the binary system?
No, I was pointing out that sometimes the sum of two positive integers is 0 (modulo the base).
 
  • #6
I like Serena said:
Don't we have 1 + 1 = 10 in the binary system? (Wondering)

And for instance 11 + 01 = 100?
That is, starting from the right we have 1 + 1 = 0 with 1 to carry over.
And then we have 1 + 0 + carry-over = 0 with again 1 to carry over. (Nerd)

Oh, I didn't know so... So this is the only rule we have to take into consideration in the binary system? (Thinking)

For example, it holds that $10+1=11$, right?
 
  • #7
evinda said:
Oh, I didn't know so... So this is the only rule we have to take into consideration in the binary system? (Thinking)

For example, it holds that $10+1=11$, right?

Right. (Nod)
 
  • #8
I like Serena said:
Right. (Nod)

Nice... Thank you very much! (Smirk)
 
  • #9
How can we prove that the dfa of my initial post indeed represents the addition in the binary system?
 
  • #10
evinda said:
How can we prove that the dfa of my initial post indeed represents the addition in the binary system?

How does binary addition work? (Wondering)

Once we know how it works, we can see what kind of dfa covers it. (Thinking)
 
  • #11
I like Serena said:
How does binary addition work? (Wondering)

Once we know how it works, we can see what kind of dfa covers it. (Thinking)

As you said in post 4. http://mathhelpboards.com/discrete-mathematics-set-theory-logic-15/addition-binary-numbers-19097.html#post87326

We have to take into consideration that $1+1=10$, we start from the right and if we have 1+1 we write 0 and have to remember a 1.
 
  • #12
In general, given a language and having drawn a dfa that recognizes it, how can we formally prove that the dfa is the right one? (Thinking)
 
  • #13
Also I think that a transition is missed at the automaton of my initial post, namely the [m](0,1)/0[/m] at the second state. I think it should be as follows.View attachment 6123

Like that we just don't get the first number of the result of the addition. But this cannot be done by the automaton since the number of the input symbols must be equal to the number of the output symbols. Right?
 

Attachments

  • nfa.png
    nfa.png
    3.1 KB · Views: 101
  • #14
evinda said:
As you said in post 4. http://mathhelpboards.com/discrete-mathematics-set-theory-logic-15/addition-binary-numbers-19097.html#post87326

We have to take into consideration that $1+1=10$, we start from the right and if we have 1+1 we write 0 and have to remember a 1.

Exactly.
Additionally, we need to specify all addition rules with and without carry.

So we add from right to left and apply the following rules:
0+0+(no carry)=0
0+1+(no carry)=1
1+0+(no carry)=1
1+1+(no carry)=0+(carry)
0+0+(carry)=1
0+1+(carry)=0+(carry)
1+0+(carry)=0+(carry)
1+1+(carry)=1+(carry)

If the DFA implements those rules and stops when it is complete, I believe we have our proof. (Wink)

evinda said:
In general, given a language and having drawn a dfa that recognizes it, how can we formally prove that the dfa is the right one? (Thinking)

We start from the definition, and check if every part of the definition is covered by our DFA. (Nerd)
evinda said:
Also I think that a transition is missed at the automaton of my initial post, namely the [m](0,1)/0[/m] at the second state. I think it should be as follows.

Like that we just don't get the first number of the result of the addition. But this cannot be done by the automaton since the number of the input symbols must be equal to the number of the output symbols. Right?

You're right and I think (1,0)/0 is missing in the second state as well. (Thinking)
 
  • #15
I like Serena said:
Exactly.
Additionally, we need to specify all addition rules with and without carry.

So we add from right to left and apply the following rules:
0+0+(no carry)=0
0+1+(no carry)=1
1+0+(no carry)=1
1+1+(no carry)=0+(carry)
0+0+(carry)=1
0+1+(carry)=0+(carry)
1+0+(carry)=0+(carry)
1+1+(carry)=1+(carry)

I see...

I like Serena said:
If the DFA implements those rules and stops when it is complete, I believe we have our proof. (Wink)

You mean that we have to check all these rules and if they are implemented, we will have shown that the automaton is the right one?

I like Serena said:
We start from the definition, and check if every part of the definition is covered by our DFA. (Nerd)

You mean the definition of the desired function of the dfa?

I like Serena said:
You're right and I think (1,0)/0 is missing in the second state as well. (Thinking)

Yes, that's true. (Nod)In order to show that the definition makes correctly the addition of binary numbers, couldn't we also use induction on the length of the binary numbers?
 
  • #16
I have thought that we could prove that the dfa is the right one using induction on the length of the given binary numbers.

Suppose that we symbolize with $n$ the length of the given binary numbers.Base case: Let $n=1$. Then we could have the input $(0,0), (0,1), (1,0), (1,1) $.

If the input is $(0,0)$ then the machine prints $0$ which is right, since $0+0=0$.
If the input is $(0,1)$ or $(1,0)$ then the machine prints $1$ which is right since $0+1=1+0=1$.
If the input is $(1,1)$ then the machine prints $0$, which is again right since $1+1=0$ with $1$ to carry over.Induction hypothesis: We suppose that the automaton makes correctly the addition of two binary numbers of length $n$.Induction step: We want to show that the automaton makes correctly the addition of two binary numbers of length $n+1$.
If we have two numbers of length $n+1$, we first add the last $n$ digits.
So we have from the induction hypothesis that the the result of the addition of the last $n$ digits will be right. So from each number, will one digit remain.

If after the addition of the last $n$ digits we are at the first state, it follows from the base case that the result of the addition of the remaining digits will be right.

If after the addition of the last $n$ digits we are at the second state, then we have to remember that we have carried over a 1.
The possible pairs of the remaining digits are these: $(0,0), (1,0), (0,1), (1,1)$.

Suppose that we have $(0,0)$. The machine will print $1$. This is right, since 0+0+carry over =1.

If we have (1,0) or (0,1), then the machine prints $0$, which is again right since 1+0+carry over =0+1+carry over=0+carry over.

If we have (1,1) then the machine prints 1, which is right since 1+1+carry over=1+carry over.
Is it right? Could I improve something?
 
  • #17
evinda said:
I have thought that we could prove that the dfa is the right one using induction on the length of the given binary numbers.

Suppose that we symbolize with $n$ the length of the given binary numbers.Base case: Let $n=1$. Then we could have the input $(0,0), (0,1), (1,0), (1,1) $.

If the input is $(0,0)$ then the machine prints $0$ which is right, since $0+0=0$.
If the input is $(0,1)$ or $(1,0)$ then the machine prints $1$ which is right since $0+1=1+0=1$.
If the input is $(1,1)$ then the machine prints $0$, which is again right since $1+1=0$ with $1$ to carry over.Induction hypothesis: We suppose that the automaton makes correctly the addition of two binary numbers of length $n$.Induction step: We want to show that the automaton makes correctly the addition of two binary numbers of length $n+1$.
If we have two numbers of length $n+1$, we first add the last $n$ digits.
So we have from the induction hypothesis that the the result of the addition of the last $n$ digits will be right. So from each number, will one digit remain.

If after the addition of the last $n$ digits we are at the first state, it follows from the base case that the result of the addition of the remaining digits will be right.

If after the addition of the last $n$ digits we are at the second state, then we have to remember that we have carried over a 1.
The possible pairs of the remaining digits are these: $(0,0), (1,0), (0,1), (1,1)$.

Suppose that we have $(0,0)$. The machine will print $1$. This is right, since 0+0+carry over =1.

If we have (1,0) or (0,1), then the machine prints $0$, which is again right since 1+0+carry over =0+1+carry over=0+carry over.

If we have (1,1) then the machine prints 1, which is right since 1+1+carry over=1+carry over.
Is it right? Could I improve something?

It looks right to me. (Happy)
There's one thing left - the numbers do not have to have the same length.
We need that if one number is shorter, it is filled out with zeroes on the left.
And then the dfa will stop when both numbers have fully been processed, which we need as well. (Thinking)
 
  • #18
I like Serena said:
It looks right to me. (Happy)
There's one thing left - the numbers do not have to have the same length.
We need that if one number is shorter, it is filled out with zeroes on the left.
And then the dfa will stop when both numbers have fully been processed, which we need as well. (Thinking)

I see... Thanks a lot! (Smirk)
 

FAQ: How is binary addition performed?

What is addition of binary numbers?

Addition of binary numbers is a mathematical operation that involves adding two numbers together in binary form. This is commonly used in computer science and digital electronics.

What are binary numbers?

Binary numbers are a number system that uses only two digits, 0 and 1, to represent all values. This is the basis of how computers store and process information.

How do you add binary numbers?

To add binary numbers, you follow the same rules as addition in the decimal system. You add each column from right to left, carrying over any 1s to the next column if the sum is greater than 1.

Can binary numbers have decimal points?

Yes, binary numbers can have decimal points just like decimal numbers. In this case, the digits to the right of the decimal point represent values less than 1, while the digits to the left represent values greater than 1.

What is the carry over rule in binary addition?

The carry over rule in binary addition states that if the sum of two digits in a column is greater than 1, the extra 1 will be carried over to the next column to the left. This is similar to carrying over in decimal addition.

Similar threads

Replies
45
Views
3K
Replies
3
Views
1K
Replies
1
Views
1K
Replies
2
Views
1K
Replies
3
Views
1K
Replies
24
Views
2K
Back
Top