Class ProcedureContract<E,V>
- java.lang.Object
-
- org.sosy_lab.java_smt.test.ultimate.ProcedureContract<E,V>
-
- Type Parameters:
E
- The type of expressionsV
- The type of variables
public class ProcedureContract<E,V> extends Object
A contract specifying the behaviour of a procedure (in Boogie or the ICFG) or function (in C).The behaviour is specified using up to three kinds of clauses:
- A "requires" clause specifies a precondition that must hold before a call.
- An "ensures" clause specifies a relation guaranteed to hold between the state before the call and the state at the procedure exit.
- Optionally, a "modifies" clause specifies a subset of global variables that the procedure may write to. Writes to any other global state is forbidden.
- Author:
- Dominik Klumpp (klumpp@informatik.uni-freiburg.de)
-
-
Constructor Summary
Constructors Constructor Description ProcedureContract(String procedure, E requires, E ensures)
Creates a new contract that does not have a "modifies" clause, i.e., the contract specifies that the procedure may arbitrarily modify global state as long as it satisfies the "ensures" clause.ProcedureContract(String procedure, E requires, E ensures, Set<V> modifies)
Creates a new contract with a "modifies" clause, i.e., the contract specifies that the procedure may only modify the given global variables.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description E
getEnsures()
Set<V>
getModifies()
String
getProcedure()
E
getRequires()
boolean
hasModifies()
boolean
hasOnlyTrivialClauses()
Determines whether both the "requires" and "ensures" clauses of the contract arenull
, i.e., represent the logical formulatrue
, and the contract does not have a "modifies" clause.
-
-
-
Constructor Detail
-
ProcedureContract
public ProcedureContract(String procedure, E requires, E ensures)
Creates a new contract that does not have a "modifies" clause, i.e., the contract specifies that the procedure may arbitrarily modify global state as long as it satisfies the "ensures" clause.- Parameters:
procedure
- The procedure for which a contract is being createdrequires
- The "requires" clause. A value ofnull
represents a trivial clause, i.e., the logical formulatrue
.ensures
- The "ensures" clause. A value ofnull
represents a trivial clause, i.e., the logical formulatrue
.
-
ProcedureContract
public ProcedureContract(String procedure, E requires, E ensures, Set<V> modifies)
Creates a new contract with a "modifies" clause, i.e., the contract specifies that the procedure may only modify the given global variables.- Parameters:
procedure
- The procedure for which a contract is being createdrequires
- The "requires" clause. A value ofnull
represents a trivial clause, i.e., the logical formulatrue
.ensures
- The "ensures" clause. A value ofnull
represents a trivial clause, i.e., the logical formulatrue
.modifies
- The set of global variables modifiable by the procedure.
-
-
Method Detail
-
hasModifies
public boolean hasModifies()
-
getProcedure
public String getProcedure()
-
getRequires
public E getRequires()
-
getEnsures
public E getEnsures()
-
hasOnlyTrivialClauses
public boolean hasOnlyTrivialClauses()
Determines whether both the "requires" and "ensures" clauses of the contract arenull
, i.e., represent the logical formulatrue
, and the contract does not have a "modifies" clause.Note that this does not mean that the entire contract is trivial in the sense that any procedure would satisfy it, as a "requires" clause of
true
indicates that there can be no assertion failure during execution of the procedure for any input or initial global state. An entirely trivial contract would thus instead need to have a "requires" clausefalse
.For contracts with "modifies" clauses this method always return
false
as there is no way to determine if the "modifies" clause is trivial without knowing the entire set of global variables in the program: only when every variable can be modified, the clause would be trivial.
-
-