# 9 topics : how to prove string concatenation is associative ?

Rate this post

How to Prove String Concatenation is Associative

# How to Prove String Concatenation is Associative

String concatenation is the process of combining two or more strings into a single string. It is a common operation in programming and is used in many applications. One of the properties of string concatenation is associativity. In this article, we will discuss how to prove that string concatenation is associative.

## Outline

• Introduction
• What is Associativity?
• What is String Concatenation?
• Proving Associativity of String Concatenation
• Conclusion

## What is Associativity?

Associativity is a property of binary operations that determines the order in which the operations are performed. In other words, it determines whether the operations are performed from left to right or from right to left. If an operation is associative, it means that the order in which the operations are performed does not affect the result.

## What is String Concatenation?

String concatenation is the process of combining two or more strings into a single string. In programming, it is usually denoted by the plus (+) operator. For example, if we have two strings “hello” and “world”, we can concatenate them using the following code:

```		String s1 = "hello";
String s2 = "world";
String s3 = s1 + s2;
```

The value of s3 will be “helloworld”.

## Proving Associativity of String Concatenation

To prove that string concatenation is associative, we need to show that:

1. (s1 + s2) + s3 = s1 + (s2 + s3) for any strings s1, s2, and s3.
2. The result of string concatenation is independent of the order in which the operations are performed.

### Proof of Property 1

Let s1, s2, and s3 be any strings. Then:

```		(s1 + s2) + s3 = (s1.concat(s2)).concat(s3) // using the concat() method
= s1.concat(s2.concat(s3)) // using the associative property of the concat() method
= s1 + (s2 + s3) // using the concat() method
```

Therefore, property 1 holds for any strings s1, s2, and s3.

### Proof of Property 2

To prove that the result of string concatenation is independent of the order in which the operations are performed, we need to show that:

• s1 + s2 = s2 + s1 for any strings s1 and s2.

Let s1 and s2 be any strings. Then:

```		s1 + s2 = s1.concat(s2) // using the concat() method
= s2.concat(s1) // using the commutative property of the concat() method
= s2 + s1 // using the concat() method
```

Therefore, property 2 holds for any strings s1 and s2.

## Conclusion

In conclusion, we have shown that string concatenation is associative. This property is important in programming as it allows us to combine multiple strings in a flexible and efficient way. By understanding the properties of string concatenation, we can write better and more efficient code.

You are looking : how to prove string concatenation is associative

## 9 how to prove string concatenation is associative for reference

### 1.Prove concatenation of strings is associative

• Publish: 19 days ago
• Rating: 4(1956 Rating)
• Highest rating: 5
• Lowest rating: 1
• Descriptions: Prove, using the definition of concatenation given in the text, that concatenation of strings is associative. Will show that (ab)c=a( …
• Source : https://math.stackexchange.com/questions/1673718/prove-concatenation-of-strings-is-associative

### 2.Proof 1 : Associativity, Non-Commutativity and the Identity Element …

• Publish: 29 days ago
• Rating: 2(1938 Rating)
• Highest rating: 3
• Lowest rating: 1
• Descriptions:
• Source : https://juspreetsandhu.wordpress.com/2015/05/25/proof-1-associativity-non-commutativity-and-the-identity-element-of-concatenation-of-strings-in-a-finite-alphabet-set/

### 3.Lecture 4 – EECS WSU

• Publish: 3 days ago
• Rating: 1(755 Rating)
• Highest rating: 3
• Lowest rating: 1
• Descriptions: Concatenation is associative (wx)y = w(xy) for any strings w, x, and y. A string v is a “substring” of a string w iff there are strings x and y (x or y …
• Source : https://eecs.wsu.edu/~cook/tcs/l4.html

### 4.[PDF] CMPSCI 250 Lecture #20

• Publish: 30 days ago
• Rating: 4(1406 Rating)
• Highest rating: 3
• Lowest rating: 1
• Descriptions:
• Source : https://people.cs.umass.edu/~barring/cs250s12/lecture/20.pdf

### 5.[PDF] Regular Expressions and Language Properties – cs.wisc.edu

• Publish: 18 days ago
• Rating: 2(569 Rating)
• Highest rating: 3
• Lowest rating: 1
• Descriptions:
• Source : https://pages.cs.wisc.edu/~aanjneya/courses/cs154/lectures/lec3.pdf

### 6.[PDF] Solutions to Problem Set 3 – Massachusetts Institute of Technology

• Publish: 13 days ago
• Rating: 2(1437 Rating)
• Highest rating: 5
• Lowest rating: 3
• Descriptions:
• Source : https://courses.csail.mit.edu/6.042/past-devel/spring06/solutions/ps3sol.pdf

### 7.[PDF] Algebraic Laws for languages

• Publish: 2 days ago
• Rating: 4(1085 Rating)
• Highest rating: 3
• Lowest rating: 1
• Descriptions: Union is associative. … Note: Concatenation is not commutative, i.e., … a sequence of strings, each of which is an element of L U M. Therefore, …
• Source : http://www.cs.ucr.edu/~jiang/cs150/slides4week3_AlgebraicLaws%2BPL.pdf

### 8.[PDF] Languages and Strings – Computer Science

• Publish: 26 days ago
• Rating: 3(1964 Rating)
• Highest rating: 3
• Lowest rating: 1
• Descriptions: ε in string concatenation: ∀x (x ε = ε x = x). Concatenation is associative: ∀s, t, w ((st) …
• Source : https://userweb.cs.txstate.edu/~jg66/teaching/theory/notes/ch2.pdf

### 9.See answer: how to prove string concatenation is associative?

• Publish: 29 days ago
• Rating: 5(246 Rating)
• Highest rating: 3
• Lowest rating: 2
• Descriptions: Concatenation is associative: for any strings w, x, and y, (w 4 x) 4 y = w 4 (x 4 y). Proof: Assume that w, x, and y are random strings.
• Source : https://brainly.com/question/30389508