public RuleSpec Simplify(ISet <Mode> modesEntered, LexerSpec lexer) { var reducedModes = new HashSet <Mode>(Modes.Intersect(modesEntered)); var simplfiedExpression = Expression.Simplify(lexer); if (reducedModes.Count >= Modes.Count && Expression == simplfiedExpression) { return(this); } return(new RuleSpec(reducedModes, Name, simplfiedExpression, Commands)); }