Group Abstract Group Abstract

Message Boards Message Boards

Is there anything that stops a rule from being applied twice in same place?

Posted 5 years ago

Greetings, I am looking into how to apply rules, particularly like the rule of order $2_2 \rightarrow 4_2$

I would like to use a rule like: $\{\{a,x\}, \{a,y\} \} \rightarrow \left\{\{a,x\}, \{a,y\}, \{x,b\}, \{y,b\}\right\}$, but rule could be applied multiple times at the same location. Is this a problem or a feature?

I am interested in rules which might be able to show that they preserve some form of probability amplitude* (unitary in the quantum mechanical sense).

Thoughts? Cheers, and Thanks.

Notes: * - Still early days as I work my way through the Wolfram Physics Project documentation.

POSTED BY: Paul Schulz
4 Replies
Posted 5 years ago
POSTED BY: Max Piskunov

It is recommended to look at Wolfram's notes of the NKS book (for the specific chapter). This will help you figure out the programming part, as there are numerous programming examples written by Stephen.

best

Posted 5 years ago

Thanks. I need to install/access Mathematica/Wolfram Language system so I can try this out with code.

The question was more of a philosophical one, with regards to the underlying graph theoretic considerations.

I think I have my answer: (TL;DR in short) - No

Applying the rule more than once to the same location, results in the gives the same graph and hence same result. I was trying to avoid a 'multiworld interpretation' where applying the rule causes the graph to split.

POSTED BY: Updating Name

You should be more specific or a least give a snippet of code, since ReplaceAll replaces only one (and only the first replacement rule that matches) Try this and notice that the rule is used only once.

Range[5]/. {left___, x_, y_, right___} :> {left, {x, y}, right}

If you have two rules, only the first that matches is used, and only once (ReplaceAll is /. )

ReplaceAll[
 Range[5], {{left___, x_, y_, right___} :> {left, {x, y}, 
    right}, {left___, x_, y_, z_, right___} :> {left, {x, y, z}, 
    right}}]

If you would like to make all the replacements possible, than you need to use ReplaceList

ReplaceList[ Range[5], {left, x, y, right} :> {left, {x, y}, right}] or

ReplaceList[
 Range[5], {{left___, x_, y_, right___} :> {left, {x, y}, 
    right}, {left___, x_, y_, z_, right___} :> {left, {x, y, z}, 
    right}}]

So, it matters which replacement instructions is used (there are more than just the two I mentioned)

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard