package de.tudresden.inf.lat.born.core.rule;

import java.util.ArrayList;
import java.util.List;

import de.tudresden.inf.lat.born.core.term.Clause;
import de.tudresden.inf.lat.born.core.term.Term;

/**
 * This is an optimization rule for Problog.
 * <ul>
 * <li><b>if</b>X \u2291 Y &isin; <i>T</i><br>
 * <b>then</b> S := S &cup; {X \u2291 Y}</li>
 * </ul>
 * <br>
 * 
 * @author Julian Mendez
 *
 */
public class BR3Rule implements CompletionRule {

	private final Clause clause;

	/**
	 * Constructs a new BR 3 rule.
	 */
	public BR3Rule() {
		FormulaConstructor c = new FormulaConstructor();

		Term x = c.newVar("X");
		Term y = c.newVar("Y");

		Term head = c.sub(x, y);
		List<Term> body = new ArrayList<Term>();
		body.add(c.subs(x, y));

		this.clause = c.rule(head, body);
	}

	@Override
	public Term getHead() {
		return this.clause.getHead();
	}

	@Override
	public List<Term> getBody() {
		return this.clause.getBody();
	}

	@Override
	public String asString() {
		return this.clause.asString();
	}

	@Override
	public boolean equals(Object obj) {
		return this.clause.equals(obj);
	}

	@Override
	public int hashCode() {
		return this.clause.hashCode();
	}

	@Override
	public String toString() {
		return this.clause.toString();
	}

}

@@ -274,17 +274,17 @@
  %5Cu2291 
-Y
+B
  &isin; 
@@ -334,17 +334,17 @@
  %5Cu2291 
-Y
+B
 %7D%3C/li%3E%0A 
@@ -623,17 +623,17 @@
 %0A%09%09Term 
-y
+b
  = c.new
@@ -641,9 +641,9 @@
 ar(%22
-Y
+B
 %22);%0A
@@ -666,17 +666,17 @@
 .sub(x, 
-y
+b
 );%0A%09%09Lis
@@ -734,17 +734,17 @@
 subs(x, 
-y
+b
 ));%0A%0A%09%09t

Rename variable in completion rule