/*
A -> (N v Q)
~(N v ~A)
A -> Q (conclusion)
*/
func SatValid(t *testing.T) {
	a := literal.Literal{"A", false}
	na := a.Negation()
	n := literal.Literal{"N", false}
	nn := n.Negation()
	q := literal.Literal{"Q", false}
	nq := q.Negation()

	one := clause.Clause{}
	one.Append(a)

	two := clause.Clause{}
	two.Append(nq)

	three := clause.Clause{}
	three.Append(nn)

	four := clause.Clause{}
	four.Append(na)
	four.Append(n)
	four.Append(q)

	CS := clauseset.ClauseSet{}
	CS.Append(one)
	CS.Append(two)
	CS.Append(three)
	CS.Append(four)

	sat, _ := Satisfiable(CS)
	if sat {
		t.Errorf("ClauseSet %q was Satisfiable, so it is an invalid argument (it should be valid)", CS)
	}

}
//Reduce transforms S by removing any clauses that contain the literal L1
//   and removing L2 (i.e. ~L1) from any clauses that contain it
func (c ClauseSet) Reduce(l1 literal.Literal) ClauseSet {
	cs := c.Copy()
	l2 := l1.Negation()

	newClauseSet := ClauseSet{}

	for _, clause := range cs.clauses {
		i := clause.Contains(l1)
		if i != -1 {
			continue
		}

		j := clause.Contains(l2)
		if j != -1 {
			clause.RemoveIndex(j)
		}
		//tautological elemination
		if !clause.Tautology() {
			newClauseSet.Append(clause)
		}

	}
	return newClauseSet
}