All Downloads are FREE. Search and download functionalities are using the official Maven repository.

astra.lang.Logic Maven / Gradle / Ivy

There is a newer version: 1.4.3
Show newest version
package astra.lang;

import astra.core.Module;
import astra.formula.Formula;
import astra.formula.Predicate;
import astra.term.Funct;

public class Logic extends Module {
	@FORMULA
	public Formula toPredicate(Funct funct) {
		return new Predicate(funct.functor(), funct.terms());
	}

	@FORMULA
	public Formula eval(boolean value) {
		return value ? Predicate.TRUE:Predicate.FALSE;
	}
	
	@TERM
	public Funct toFunctor(Formula formula) {
		if (formula instanceof Predicate) {
			Predicate predicate = (Predicate) formula;
			return new Funct(predicate.predicate(), predicate.terms());
		}
		throw new RuntimeException("Invalid Formula Type: " + formula.getClass().getCanonicalName());
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy