Skip to content
Snippets Groups Projects
Select Git revision
  • df0c81b008315ba2e3fc66e823f060c972b134f2
  • master default protected
  • emoUS
  • add_default_vectorizer_and_pretrained_loading
  • clean_code
  • readme
  • issue127
  • generalized_action_dicts
  • ppo_num_dialogues
  • crossowoz_ddpt
  • issue_114
  • robust_masking_feature
  • scgpt_exp
  • e2e-soloist
  • convlab_exp
  • change_system_act_in_env
  • pre-training
  • nlg-scgpt
  • remapping_actions
  • soloist
20 results

__init__.py

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    BOperation.java 13.00 KiB
    package de.tla2b.analysis;
    
    import de.be4.classicalb.core.parser.node.*;
    import de.tla2b.global.BBuiltInOPs;
    import de.tla2b.global.TranslationGlobals;
    import de.tla2b.types.TLAType;
    import de.tla2bAst.BAstCreator;
    import tla2sany.semantic.*;
    import tlc2.tool.BuiltInOPs;
    import tlc2.tool.ToolGlobals;
    
    import java.util.*;
    import java.util.Map.Entry;
    import java.util.stream.Collectors;
    
    public class BOperation extends BuiltInOPs implements ASTConstants, ToolGlobals, TranslationGlobals {
    	private final String name;
    	private final OpApplNode node;
    	private final List<OpApplNode> existQuans;
    	private List<String> opParams;
    	private List<FormalParamNode> formalParams;
    	private List<String> unchangedVariables;
    	private final List<OpDeclNode> unchangedVariablesList;
    	private final List<ExprOrOpArgNode> guards;
    	private final List<ExprOrOpArgNode> beforeAfterPredicates;
    	private final LinkedHashMap<SymbolNode, ExprOrOpArgNode> assignments = new LinkedHashMap<>();
    	private List<OpDeclNode> anyVariables;
    	private final SpecAnalyser specAnalyser;
    
    	public BOperation(String name, OpApplNode n, List<OpApplNode> existQuans, SpecAnalyser specAnalyser) {
    		this.name = name;
    		this.node = n;
    		this.existQuans = existQuans;
    		this.specAnalyser = specAnalyser;
    		this.unchangedVariablesList = new ArrayList<>();
    		this.guards = new ArrayList<>();
    		this.beforeAfterPredicates = new ArrayList<>();
    		anyVariables = new ArrayList<>(Arrays.asList(specAnalyser.getModuleNode().getVariableDecls()));
    
    		evalParams();
    		// System.out.println("Construction B Operation for TLA+ action: " + name);
    		findUnchangedVariables();
    		// System.out.println(" UNCHANGED = " + unchangedVariables.toString());
    		separateGuardsAndBeforeAfterPredicates(node);
    		findAssignments();
    	}
    
    	public AOperation getBOperation(BAstCreator bASTCreator) {
    		bASTCreator.setUnchangedVariablesNames(unchangedVariables);
    		List<PPredicate> whereList = new ArrayList<>();
    		for (OpApplNode o : this.getExistQuans()) {
    			whereList.add(bASTCreator.visitBoundsOfLocalVariables(o));
    		}
    
    		for (ExprOrOpArgNode g : guards) {
    			whereList.add(bASTCreator.visitExprOrOpArgNodePredicate(g));
    		}
    
    		List<PExpression> leftSideOfAssigment = new ArrayList<>();
    		List<PExpression> rightSideOfAssigment = new ArrayList<>();
    		for (Entry<SymbolNode, ExprOrOpArgNode> entry : assignments.entrySet()) {
    			leftSideOfAssigment.add(bASTCreator.createIdentifierNode(entry.getKey()));
    			rightSideOfAssigment.add(bASTCreator.visitExprOrOpArgNodeExpression(entry.getValue()));
    		}
    		PSubstitution operationBody;
    		AAssignSubstitution assign = new AAssignSubstitution();
    		if (!anyVariables.isEmpty()) { // ANY x_n WHERE P THEN A END
    			List<PExpression> anyParams = new ArrayList<>();
    			for (OpDeclNode var : anyVariables) {
    				String nextName = var.getName().toString() + "_n";