anchor.diff:      | RANDOM name=symbol ':' parameters+=symbol (X parameters+=symbol)* '->' range=symbol
       ;
       
  -rule_definition
  -    : IF formula THEN rule_definition ELSE rule_definition #conditionalRule
  -    | f=formula (p=potential)? #formulaWithOptionalPotentialRule
  -    ;
  -    
  -formula
  -    : '(' formula ')' #termWithParentheses
  -    | functor=symbol '(' ( args+=formula (',' args+=formula)* )? ')' #formulaFunctionApplication
  -    | NOT formula #notFunctionApplication
  -    | leftconj=formula AND rightconj=formula #andFunctionApplication
  -    | leftconj=formula OR rightconj=formula #orFunctionApplication
  -    | IF condition=formula THEN thenbranch=formula ELSE elsebranch=formula #ifThenElseFunctionApplication
  -    | quantified_expression #termQuantifiedExpression
  +term
  +      // parenthesis, e.g.:(1+2)
  +    : '(' term ')' #parentheses
  +      // function application, e.g.: f(X)
  +    | functor=symbol '(' ( args+=term (',' args+=term)* )? ')' #functionApplication
  +      // not, e.g.: not A and B -> (not(A)) and B
  +    | NOT term #not // <boolean-typed> term
  +       // negative, e.g.: 2 * -1 -> 2 * (-1)
  +     | '-' term #negative // We set the unary minus to higher precedence // <number-typed> term;
  +       // NOTE:  P)arentheses, E)xponents, ( M)ultiplication, D)ivision ), ( A)ddition, S)ubtraction )
  +       // see: http://en.wikipedia.org/wiki/Order_of_operations
  +	  // exponentiation, e.g. 2^3^4 ---> 2^(3^4)
  +	|  <assoc=right> base=term '^' exponent=term #exponentiation // <number-typed> term;
  +	  // multiplication or division, e.g.: 2*3/2 ---> 2*(3/2)
  +	| leftop=term op=('*' | '/') rightop=term #multiplicationOrDivision // <number-typed> term;
  +	  // addition or subtraction, e.g.: 1-2+3 ---> (1-2)+3
  +	| leftop=term op=('+' | '-') rightop=term #additionOrSubtraction // <number-typed> term;
  +      // comparison operators, e.g.: X = Y, 2 < 3
  +    | leftop=term op=('<' | '<=' | '=' | '!=' | '>=' | '>') rightop=term #comparison
  +      // conjunction, e.g.: A or B and C ---> A or (B and C)
  +    | leftconj=term AND rightconj=term #conjunction // <boolean-typed> terms
  +      // disjunction, e.g.: A => B or C ---> A => (B or C)
  +    | leftconj=term OR rightconj=term #disjunction // <boolean-typed> terms
  +      // implication, e.g.: A = B => C = D
  +    |<assoc=right> antecedent=term IMPLICATION consequent=term #implication // <boolean-typed> terms
  +      // biconditional, e.g.: A = B <=> C = D
  +    |<assoc=right> leftop=term BICONDITIONAL rightop=term #biconditional // <boolean-typed> terms
  +      // conditional, e.g.: if X = Y then 1 else 2
  +    | IF condition=term THEN thenbranch=term ELSE elsebranch=term #conditional // same type terms on all leafs
  +      // universal quantification, e.g.: for all X : X != a
  +    | FOR ALL index=variable ':' body=term #forAll  // <boolean-typed> terms
  +      // existential quantification, e.g.: there exists X : X = a
  +    | THERE EXISTS index=variable ':' body=term #thereExists // <boolean-typed> terms
  +    //| formula=term number_typed_term=term #shorthandpotential // parse it as formula (i.e. <boolean-typed> term) and <number-typed> term, create if Formula then <number-typed> term else 1 - <number-typed> term
       | constant #termConstant
  -    | variable #termVariable
  -    ;
  -    
  -quantified_expression
  -    : FOR ALL index=variable ':' body=formula #forAll
  -    | THERE EXISTS index=variable ':' body=formula #thereExists
  +    | variable #termVaria
       ;
       
   constant
       : CONSTANT
  +    | INTEGER
  +    | RATIONAL
       ;
       
   variable
       : VARIABLE
  -    ;
  -
  -potential
  -    :  // parenthesis, e.g.:(1+2)
  -     '(' potential ')' #potentialWithParentheses
  -       // exponentiation, e.g. 2^3^4 -> 2^(3^4)
  -     |<assoc=right> base=potential '^' exponent=potential #potentialExponentiation
  -       // multiplication or division, e.g.: 2*3/2 -> 2*(3/2)
  -     | leftop=potential op=('*' | '/') rightop=potential #potentialMultiplicationOrDivision
  -       // addition or subtraction, e.g.: 1-2+3 -> (1-2)+3
  -     | leftop=potential op=('+' | '-') rightop=potential #potentialAdditionOrSubtraction
  -       // i.e. a constant value between [0-1]
  -     | atomic_potential #potentialValue
  -    ;
  -
  -atomic_potential
  -    : INTEGER
  -    | RATIONAL
       ;
   
   symbol
  
positive.code: PLUS                    : '+' ;
  SUBTRACT                : '-' ;
  // Comparison
  EQUAL                   : '=' ;
  NOT_EQUAL               : '!=' ;
  // Brackets
  OPEN_PAREN              : '(' ;
  CLOSE_PAREN             : ')' ;
  
negative.code:     
  statement
      : declaration
      | term     // <number-typed> term;
      ;
  
  declaration
  