{ localUrl: '../page/associativity_examples.html', arbitalUrl: 'https://arbital.com/p/associativity_examples', rawJsonUrl: '../raw/3mt.json', likeableId: '2509', likeableType: 'page', myLikeValue: '0', likeCount: '2', dislikeCount: '0', likeScore: '2', individualLikes: [ 'EricBruylant', 'NateSoares' ], pageId: 'associativity_examples', edit: '3', editSummary: 'fixed formatting issues, added toc', prevEdit: '2', currentEdit: '3', wasPublished: 'true', type: 'wiki', title: 'Associativity: Examples', clickbait: '', textLength: '6721', alias: 'associativity_examples', externalUrl: '', sortChildrenBy: 'likes', hasVote: 'false', voteType: '', votesAnonymous: 'false', editCreatorId: 'EricBruylant', editCreatedAt: '2016-08-19 23:28:56', pageCreatorId: 'NateSoares', pageCreatedAt: '2016-05-15 12:10:10', seeDomainId: '0', editDomainId: 'AlexeiAndreev', submitToDomainId: '0', isAutosave: 'false', isSnapshot: 'false', isLiveEdit: 'true', isMinorEdit: 'false', indirectTeacher: 'false', todoCount: '0', isEditorComment: 'false', isApprovedComment: 'true', isResolved: 'false', snapshotText: '', anchorContext: '', anchorText: '', anchorOffset: '0', mergedInto: '', isDeleted: 'false', viewCount: '56', text: '[summary: Yes: [Addition], [multiplication], [3jv string concatenation]. No: [subtraction], [division], a [-3jy] that concatenates strings and then puts an "x" on the front.]\n\n[toc:]\n\n## Positive examples\n\n### Addition\n\n$(x + y) + z = x + (y + z)$ for all numbers $x, y,$ and $z.$ Thus, addition associates. One easy way to see this fact is to consider a [3mb physical system] that implements addition, e.g., by taking two piles of poker chips (where a poker chip with $n$ chips represents the number $n$) in on two input belts, and producing a pile of poker chips on the output belt. This function can be implemented by simply shoving both input piles onto the output pile. Clearly, when combining three piles, it doesn't matter which piles get shoved onto the output tape in which order, so addition is associative.\n\n### Multiplication\n\n$(x \\times y) \\times z = x \\times (y \\times z)$ for all numbers $x, y,$ and $z.$ Thus, multiplication associates. It is, however, a little harder to see why this must be the case for multiplication.\n\nImagine a physical system implementing multiplication, by taking stacks of poker chips as input (where stacks with $n$ chips in them represents the number $n$), and producing an output by putting a copy of the left stack on the output tape for every chip in the right stack. Imagine using this function to combine three stacks of poker chips, a blue stack (representing $x$), a yellow stack (representing $y$), and a red stack (representing $z$). We can either calculate $(x \\times y) \\times z$ or $x \\times (y \\times z).$ In both cases, the result will be a bunch of copies of the original blue $x$ stack. The question is, how many copies will there be in each case?\n\nIn the first case, the machine first puts $y$ copies of the blue stack in a line, and then makes $z$ copies of that line. In the second case, the machine first makes $z$ copies of the yellow stack. Each of those yellow stacks corresponds to one of the lines from the first case, and each yellow chip on each yellow stack corresponds to one of the blue stacks in the first case. A blue stack is placed on the output in the second case for each of those yellow chips, so the number of blue stacks in each case is the same.\n\n### Concatenation\n\nThe concatenation of [3jr strings] is another associative function: `concat("a",concat("b","c")) = concat(concat("a","b"),"c") = "abc"`.\n\nConcatenation is an example of an associative function that is not [3jb commutative]: When reducing a list of strings to a single string, it doesn't matter what order you combine adjacent elements in, but it _does_ matter that you leave the elements in their original order.\n\nIn fact, any function that just sticks its inputs together (possibly with some extra stuff in the middle) is associative: A function which takes wooden blocks as input, and glues them together (with a small white block in the middle) is associative, because if you put in blue, yellow, and red blocks then you get a blue-white-yellow-white-red block out the end, regardless of the order you combine adjacent blocks in.\n\n## Negative examples\n\n### Functions with a history\n\nThe function `xconcat` that concatenates its inputs and puts an "x" on the front: `xconcat("A", xconcat("B","C")) = "xAxBC"`, but `xconcat(xconcat("A", "B"), "C") = "xxABC"`. The problem in this case is that the output carries a trace of which adjacent elements were combined in which order, which makes the function non-associative.\n\nIn fact, any function that carries a history of the application order with it can't be associative. Thus, if the inputs carry history about which inputs were combined with which other inputs, and the output preserves (and adds to) that history, the function can't be associative. Associativity is, fundamentally, about the output not depending on which path was taken to get to it.\n\n### Subtraction\n\nSubtraction does not associate, as $(5-3)-2=0$ but $5-(3-2)=4.$ To see what went wrong, first notice that all inputs contribute either positively or negatively to the result. Label all inputs (in their original positive states) with up-arrows; we will track whether that input has a positive or negative impact on the final output. Subtraction flips its right-hand input upside down before combining it with its left-hand input, so given inputs labeled $\\uparrow$ and $\\uparrow$ we should label its output $\\uparrow\\downarrow.$ When combining three inputs, we can either combine the left two first or the right two first. If we combine the left two first, then the second subtraction is run on inputs labeled $\\uparrow\\downarrow$ and $\\uparrow,$ and produces an output $\\uparrow\\downarrow\\downarrow,$ in which the first input contributes positively and the other inputs contribute negatively. But if we combine the right two inputs first, then the second subtraction is run on inputs labeled $\\uparrow$ and $\\uparrow\\downarrow,$ and produces an output $\\uparrow\\downarrow\\uparrow,$ in which the first and third inputs contribute positively and the second contributes negatively. Thus, the contribution of the third input depends on which adjacent elements are combined in which order, so subtraction does not associate.\n\n### Cyclical preferences\n\nConsider a person who is playing a game that works as follows. The board has three positions: red, green, and blue. The player's objective is to complete as many clockwise red-green-blue cycles as possible, without ever backtracking in the counter-clockwise direction.\n\n![3-cycle board](http://i.imgur.com/bxCnXUs.png)\n\n Each turn, the game offers them a choice of one of the three spaces, and they get to choose whether or not to travel to that square or stay where they are. Clearly, their preferences depend on where they currently are: If they're on "red", "green" is a good move and "blue" is a bad one; but if they're on "blue" then choosing "green" is ill-advised.\n\nWe can consider a binary operation $?$ which takes their current position on the left and the proposed position on the right, and returns the position that the player prefers. Specifically:\n\n\\begin{align}\n& red \\ ?\\ red \\ &= red\\\\\n& red \\ ?\\ green \\ &= green\\\\\n& red \\ ?\\ blue \\ &= red\\\\\n\\end{align}\n\\begin{align}\n& green \\ ?\\ red \\ &= green\\\\\n& green \\ ?\\ green \\ &= green\\\\\n& green \\ ?\\ blue \\ &= blue\\\\\n\\end{align}\n\\begin{align}\n& blue \\ ?\\ red \\ &= red\\\\\n& blue \\ ?\\ green \\ &= blue\\\\\n& blue \\ ?\\ blue \\ &= blue\n\\end{align}\n\nThis function does not associate, because $(red\\ ?\\ green)\\ ?\\ blue = blue$ but $red\\ ?\\ (green\\ ?\\ blue)=red.$ To show that a function is not associative, it is sufficient to simply do out the whole function table and then find any one case that violates the axiom of associativity, as above.', metaText: '', isTextLoaded: 'true', isSubscribedToDiscussion: 'false', isSubscribedToUser: 'false', isSubscribedAsMaintainer: 'false', discussionSubscriberCount: '1', maintainerCount: '1', userSubscriberCount: '0', lastVisit: '', hasDraft: 'false', votes: [], voteSummary: 'null', muVoteSummary: '0', voteScaling: '0', currentUserVote: '-2', voteCount: '0', lockedVoteType: '', maxEditEver: '0', redLinkCount: '0', lockedBy: '', lockedUntil: '', nextPageId: '', prevPageId: '', usedAsMastery: 'false', proposalEditNum: '0', permissions: { edit: { has: 'false', reason: 'You don't have domain permission to edit this page' }, proposeEdit: { has: 'true', reason: '' }, delete: { has: 'false', reason: 'You don't have domain permission to delete this page' }, comment: { has: 'false', reason: 'You can't comment in this domain because you are not a member' }, proposeComment: { has: 'true', reason: '' } }, summaries: {}, creatorIds: [ 'NateSoares', 'EricBruylant' ], childIds: [], parentIds: [ 'associative_operation' ], commentIds: [], questionIds: [], tagIds: [ 'b_class_meta_tag' ], relatedIds: [], markIds: [], explanations: [], learnMore: [], requirements: [], subjects: [], lenses: [], lensParentId: 'associative_operation', pathPages: [], learnMoreTaughtMap: {}, learnMoreCoveredMap: {}, learnMoreRequiredMap: {}, editHistory: {}, domainSubmissions: {}, answers: [], answerCount: '0', commentCount: '0', newCommentCount: '0', linkedMarkCount: '0', changeLogs: [ { likeableId: '0', likeableType: 'changeLog', myLikeValue: '0', likeCount: '0', dislikeCount: '0', likeScore: '0', individualLikes: [], id: '18851', pageId: 'associativity_examples', userId: 'EricBruylant', edit: '3', type: 'newEdit', createdAt: '2016-08-19 23:28:56', auxPageId: '', oldSettingsValue: '', newSettingsValue: 'fixed formatting issues, added toc' }, { likeableId: '0', likeableType: 'changeLog', myLikeValue: '0', likeCount: '0', dislikeCount: '0', likeScore: '0', individualLikes: [], id: '18850', pageId: 'associativity_examples', userId: 'EricBruylant', edit: '0', type: 'newTag', createdAt: '2016-08-19 23:27:04', auxPageId: 'b_class_meta_tag', oldSettingsValue: '', newSettingsValue: '' }, { likeableId: '0', likeableType: 'changeLog', myLikeValue: '0', likeCount: '0', dislikeCount: '0', likeScore: '0', individualLikes: [], id: '18849', pageId: 'associativity_examples', userId: 'EricBruylant', edit: '0', type: 'deleteTag', createdAt: '2016-08-19 23:26:56', auxPageId: 'formatting_issues_meta_tag', oldSettingsValue: '', newSettingsValue: '' }, { likeableId: '0', likeableType: 'changeLog', myLikeValue: '0', likeCount: '0', dislikeCount: '0', likeScore: '0', individualLikes: [], id: '17140', pageId: 'associativity_examples', userId: 'EricBruylant', edit: '0', type: 'newTag', createdAt: '2016-07-19 02:14:37', auxPageId: 'formatting_issues_meta_tag', oldSettingsValue: '', newSettingsValue: '' }, { likeableId: '0', likeableType: 'changeLog', myLikeValue: '0', likeCount: '0', dislikeCount: '0', likeScore: '0', individualLikes: [], id: '10433', pageId: 'associativity_examples', userId: 'NateSoares', edit: '0', type: 'newAlias', createdAt: '2016-05-15 13:24:53', auxPageId: '', oldSettingsValue: 'associative_function_examples', newSettingsValue: 'associativity_examples' }, { likeableId: '0', likeableType: 'changeLog', myLikeValue: '0', likeCount: '0', dislikeCount: '0', likeScore: '0', individualLikes: [], id: '10426', pageId: 'associativity_examples', userId: 'NateSoares', edit: '2', type: 'newEdit', createdAt: '2016-05-15 13:21:59', auxPageId: '', oldSettingsValue: '', newSettingsValue: '' }, { likeableId: '0', likeableType: 'changeLog', myLikeValue: '0', likeCount: '0', dislikeCount: '0', likeScore: '0', individualLikes: [], id: '10425', pageId: 'associativity_examples', userId: 'NateSoares', edit: '0', type: 'newAlias', createdAt: '2016-05-15 13:21:57', auxPageId: '', oldSettingsValue: 'associativity_examples', newSettingsValue: 'associative_function_examples' }, { likeableId: '0', likeableType: 'changeLog', myLikeValue: '0', likeCount: '0', dislikeCount: '0', likeScore: '0', individualLikes: [], id: '10409', pageId: 'associativity_examples', userId: 'NateSoares', edit: '1', type: 'newEdit', createdAt: '2016-05-15 12:10:10', auxPageId: '', oldSettingsValue: '', newSettingsValue: '' }, { likeableId: '0', likeableType: 'changeLog', myLikeValue: '0', likeCount: '0', dislikeCount: '0', likeScore: '0', individualLikes: [], id: '10403', pageId: 'associativity_examples', userId: 'NateSoares', edit: '1', type: 'newParent', createdAt: '2016-05-15 09:27:38', auxPageId: 'associative_operation', oldSettingsValue: '', newSettingsValue: '' } ], feedSubmissions: [], searchStrings: {}, hasChildren: 'false', hasParents: 'true', redAliases: {}, improvementTagIds: [], nonMetaTagIds: [], todos: [], slowDownMap: 'null', speedUpMap: 'null', arcPageIds: 'null', contentRequests: {} }