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

nl.uu.cs.ape.models.sltlxStruc.SLTLxExists Maven / Gradle / Ivy

Go to download

APE is a command line tool and an API for the automated exploration of possible computational pipelines (workflows) from large collections of computational tools.

The newest version!
package nl.uu.cs.ape.models.sltlxStruc;

import java.util.HashSet;
import java.util.Set;

import nl.uu.cs.ape.automaton.State;
import nl.uu.cs.ape.solver.minisat.SATSynthesisEngine;

/**
 * Structure used to model exists statement in SLTLx.
 * 
 * @author Vedran Kasalica
 *
 */
public class SLTLxExists extends SLTLxVarQuantification {

	public SLTLxExists(SLTLxVariable boundVariable, SLTLxFormula formula) {
		super(boundVariable, formula);
	}

	@Override
	public Set getCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollection curVarMapping,
			SATSynthesisEngine synthesisEngine) {
		Set clauses = new HashSet<>();
		SLTLxVariableSubstitutionCollection newVarMappping = new SLTLxVariableSubstitutionCollection(curVarMapping);
		SLTLxVariable flatBindedVariable = newVarMappping.addNewVariable(boundVariable,
				SLTLxVariable.getVariableDomain(stateNo, synthesisEngine));

		/** Encode the possible substitutions for the given variable. */
		clauses.addAll(flatBindedVariable.getExistentialCNFEncoding(stateNo, newVarMappping, synthesisEngine));

		/** Encode the variable substitution and the underlying formula. */
		clauses.addAll(super.getCNFEncoding(stateNo, newVarMappping, synthesisEngine));
		return clauses;
	}

	@Override
	public Set getNegatedCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollection curVarMapping,
			SATSynthesisEngine synthesisEngine) {
		Set clauses = new HashSet<>();

		/** Encode the possible substitutions for the given variable. */
		SLTLxVariable.getVariableDomain(stateNo, synthesisEngine).forEach(
				state -> {
					SLTLxVariableSubstitutionCollection newVarMappping = new SLTLxVariableSubstitutionCollection(
							curVarMapping);
					Set domainState = new HashSet<>();
					domainState.add(state);
					SLTLxVariable flatBindedVariable = newVarMappping.addNewVariable(boundVariable, domainState);

					/* Encode the substitution. */
					clauses.addAll(
							flatBindedVariable.getUniversalCNFEncoding(stateNo, newVarMappping, synthesisEngine));
					/** Encode the variable substitution and the underlying formula. */
					clauses.addAll(super.getNegatedCNFEncoding(stateNo, newVarMappping, synthesisEngine));
				});

		return clauses;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy