/* Lemma -- Automatically generated by TreeBuilder (2024-10-27T16:47Z) */ package de.uni_freiburg.informatik.ultimate.model.acsl.ast; import java.util.List; import java.util.ArrayList; import de.uni_freiburg.informatik.ultimate.model.acsl.ACSLNode; /** * Represents a lemma which is a special form of a logic statement. */ public class Lemma extends LogicStatement { private static final java.util.function.Predicate VALIDATOR = ACSLNode.VALIDATORS.get(Lemma.class); /** * The formula of this lemma. */ Expression formula; /** * The constructor taking initial values. * @param polyId the poly id of this logic statement. * @param formula the formula of this lemma. */ public Lemma(PolyIdentifier polyId, Expression formula) { super(polyId); this.formula = formula; assert VALIDATOR == null || VALIDATOR.test(this) : "Invalid Lemma: " + this; } /** * The constructor taking initial values. * @param polyId the poly id of this logic statement. * @param parameters the parameters of this logic statement. * @param formula the formula of this lemma. */ public Lemma(PolyIdentifier polyId, Parameter[] parameters, Expression formula) { super(polyId, parameters); this.formula = formula; assert VALIDATOR == null || VALIDATOR.test(this) : "Invalid Lemma: " + this; } /** * Returns a textual description of this object. */ public String toString() { StringBuffer sb = new StringBuffer(); sb.append("Lemma").append('['); sb.append(formula); return sb.append(']').toString(); } /** * Gets the formula of this lemma. * @return the formula of this lemma. */ public Expression getFormula() { return formula; } public List getOutgoingNodes() { List children = super.getOutgoingNodes(); children.add(formula); return children; } public void accept(ACSLVisitor visitor) { if (visitor.visit((LogicStatement)this)) { //visit parent types higher up if necessary } else { return; } if (visitor.visit(this)) { if(formula!=null){ formula.accept(visitor); } if(polyId!=null){ polyId.accept(visitor); } if(parameters!=null){ for (Parameter elem : parameters) { elem.accept(visitor); } } } } public LogicStatement accept(ACSLTransformer visitor) { LogicStatement node = visitor.transform(this); if(node != this){ return node; } Expression newformula = null; if(formula != null){ newformula = (Expression)formula.accept(visitor); } PolyIdentifier newpolyId = null; if(polyId != null){ newpolyId = (PolyIdentifier)polyId.accept(visitor); } boolean isChanged=false; ArrayList tmpListnewparameters = new ArrayList<>(); if(parameters != null){ for(Parameter elem : parameters){ Parameter newparameters = (Parameter)elem.accept(visitor); isChanged = isChanged || newparameters != elem; tmpListnewparameters.add(newparameters); } } if(isChanged || formula != newformula || polyId != newpolyId){ return new Lemma(newpolyId, tmpListnewparameters.toArray(new Parameter[0]), newformula); } return this; } }