@ -60,7 +60,8 @@ import acceptance.AcceptanceType;
public class LTL2DA extends PrismComponent
{
public LTL2DA ( PrismComponent parent ) throws PrismException {
public LTL2DA ( PrismComponent parent ) throws PrismException
{
super ( parent ) ;
}
@ -72,7 +73,7 @@ public class LTL2DA extends PrismComponent
* @param constantValues the values of constants , may be { @code null }
* /
@SuppressWarnings ( "unchecked" )
public DA < BitSet , AcceptanceRabin > convertLTLFormulaToDRA ( Expression ltl , Values constantValues ) throws PrismException
public DA < BitSet , AcceptanceRabin > convertLTLFormulaToDRA ( Expression ltl , Values constantValues ) throws PrismException
{
return ( DA < BitSet , AcceptanceRabin > ) convertLTLFormulaToDA ( ltl , constantValues , AcceptanceType . RABIN ) ;
}
@ -85,7 +86,8 @@ public class LTL2DA extends PrismComponent
* @param constants the values of constants , may be { @code null }
* @param allowedAcceptance the AcceptanceTypes that are allowed to be returned
* /
public DA < BitSet , ? extends AcceptanceOmega > convertLTLFormulaToDA ( Expression ltl , Values constants , AcceptanceType . . . allowedAcceptance ) throws PrismException
public DA < BitSet , ? extends AcceptanceOmega > convertLTLFormulaToDA ( Expression ltl , Values constants , AcceptanceType . . . allowedAcceptance )
throws PrismException
{
DA < BitSet , ? extends AcceptanceOmega > result = null ;
@ -95,8 +97,7 @@ public class LTL2DA extends PrismComponent
useExternal = false ;
}
if ( AcceptanceType . contains ( allowedAcceptance , AcceptanceType . RABIN ) & &
! useExternal ) {
if ( AcceptanceType . contains ( allowedAcceptance , AcceptanceType . RABIN ) & & ! useExternal ) {
/ / If we may construct a Rabin automaton , check the library first
try {
result = LTL2RabinLibrary . getDRAforLTL ( ltl , constants ) ;
@ -112,7 +113,7 @@ public class LTL2DA extends PrismComponent
/ / there is the possibility that we might be able to construct
/ / an automaton below , just issue a warning
getLog ( ) . println ( "Warning: Exception during attempt to construct DRA using the LTL2RabinLibrary:" ) ;
getLog ( ) . println ( " " + e . getMessage ( ) ) ;
getLog ( ) . println ( " " + e . getMessage ( ) ) ;
}
}
}
@ -136,7 +137,8 @@ public class LTL2DA extends PrismComponent
return result ;
}
public DA < BitSet , ? extends AcceptanceOmega > convertLTLFormulaToDAWithExternalTool ( Expression ltl , Values constants , AcceptanceType . . . allowedAcceptance ) throws PrismException
public DA < BitSet , ? extends AcceptanceOmega > convertLTLFormulaToDAWithExternalTool ( Expression ltl , Values constants , AcceptanceType . . . allowedAcceptance )
throws PrismException
{
String ltl2daTool = getSettings ( ) . getString ( PrismSettings . PRISM_LTL2DA_TOOL ) ;
@ -171,12 +173,12 @@ public class LTL2DA extends PrismComponent
ltlOutput = ltlFormulaSafeAP . toStringSpot ( ) ;
break ;
default :
throw new PrismException ( "Unknown LTL syntax option \"" + syntax + "\"" ) ;
throw new PrismException ( "Unknown LTL syntax option \"" + syntax + "\"" ) ;
}
File ltl_file = File . createTempFile ( "prism-ltl-external-" , ".ltl" , null ) ;
File da_file = File . createTempFile ( "prism-ltl-external-" , ".hoa" , null ) ;
File tool_output = File . createTempFile ( "prism-ltl-external-" , ".output" , null ) ;
File ltl_file = File . createTempFile ( "prism-ltl-external-" , ".ltl" , null ) ;
File da_file = File . createTempFile ( "prism-ltl-external-" , ".hoa" , null ) ;
File tool_output = File . createTempFile ( "prism-ltl-external-" , ".output" , null ) ;
FileWriter ltlWriter = new FileWriter ( ltl_file ) ;
ltlWriter . write ( ltlOutput ) ;
@ -191,14 +193,13 @@ public class LTL2DA extends PrismComponent
}
getLog ( ) . println ( ) ;
getLog ( ) . print ( "LTL formula (in " + syntax + " syntax): " ) ;
getLog ( ) . print ( "LTL formula (in " + syntax + " syntax): " ) ;
getLog ( ) . println ( ltlOutput ) ;
getLog ( ) . println ( ) ;
arguments . add ( ltl_file . getAbsolutePath ( ) ) ;
arguments . add ( da_file . getAbsolutePath ( ) ) ;
ProcessBuilder builder = new ProcessBuilder ( arguments ) ;
builder . redirectOutput ( tool_output ) ;
builder . redirectErrorStream ( true ) ;
@ -215,17 +216,14 @@ public class LTL2DA extends PrismComponent
}
}
if ( rv ! = 0 ) {
throw new PrismException ( "Call to external LTL->DA tool failed, return value = " + rv + ".\n"
+ "To investigate, please consult the following files:"
+ "\n LTL formula: " + ltl_file . getAbsolutePath ( )
+ "\n Automaton output: " + da_file . getAbsolutePath ( )
+ "\n Tool output (stdout and stderr): " + tool_output . getAbsolutePath ( )
+ "\n" ) ;
throw new PrismException ( "Call to external LTL->DA tool failed, return value = " + rv + ".\n"
+ "To investigate, please consult the following files:" + "\n LTL formula: " + ltl_file . getAbsolutePath ( )
+ "\n Automaton output: " + da_file . getAbsolutePath ( ) + "\n Tool output (stdout and stderr): "
+ tool_output . getAbsolutePath ( ) + "\n" ) ;
}
tool_output . delete ( ) ;
try {
try {
HOAF2DA consumerDA = new HOAF2DA ( ) ;
@ -258,17 +256,11 @@ public class LTL2DA extends PrismComponent
}
}
} catch ( ParseException e ) {
throw new PrismException ( "Parse error: " + e . getMessage ( ) + ".\n"
+ "To investigate, please consult the following files:\n"
+ " LTL formula: " + ltl_file . getAbsolutePath ( )
+ "\n Automaton output: " + da_file . getAbsolutePath ( )
+ "\n" ) ;
throw new PrismException ( "Parse error: " + e . getMessage ( ) + ".\n" + "To investigate, please consult the following files:\n"
+ " LTL formula: " + ltl_file . getAbsolutePath ( ) + "\n Automaton output: " + da_file . getAbsolutePath ( ) + "\n" ) ;
} catch ( PrismException e ) {
throw new PrismException ( e . getMessage ( ) + ".\n"
+ "To investigate, please consult the following files:"
+ "\n LTL formula: " + ltl_file . getAbsolutePath ( )
+ "\n Automaton output: " + da_file . getAbsolutePath ( )
+ "\n" ) ;
throw new PrismException ( e . getMessage ( ) + ".\n" + "To investigate, please consult the following files:" + "\n LTL formula: "
+ ltl_file . getAbsolutePath ( ) + "\n Automaton output: " + da_file . getAbsolutePath ( ) + "\n" ) ;
}
da_file . delete ( ) ;
@ -286,7 +278,8 @@ public class LTL2DA extends PrismComponent
DA . switchAcceptance ( result , acceptance . toAcceptanceGeneric ( ) ) ;
return result ;
} else {
throw new PrismException ( "The external LTL->DA tool returned an automaton with " + acceptance . getTypeName ( ) + " acceptance, which is not yet supported for model checking this model / property" ) ;
throw new PrismException ( "The external LTL->DA tool returned an automaton with " + acceptance . getTypeName ( )
+ " acceptance, which is not yet supported for model checking this model / property" ) ;
}
}
@ -294,7 +287,7 @@ public class LTL2DA extends PrismComponent
private boolean useExternal ( )
{
String ltl2da_tool = getSettings ( ) . getString ( PrismSettings . PRISM_LTL2DA_TOOL ) ;
if ( ltl2da_tool ! = null & & ! ltl2da_tool . isEmpty ( ) ) {
if ( ltl2da_tool ! = null & & ! ltl2da_tool . isEmpty ( ) ) {
return true ;
}
return false ;
@ -306,7 +299,7 @@ public class LTL2DA extends PrismComponent
APSet ltlAPs = ltl . getAPs ( ) ;
for ( String ap : automatonAPs ) {
if ( ! ltlAPs . hasAP ( ap ) ) {
throw new PrismException ( "Generated automaton has extra atomic proposition \"" + ap + "\"" ) ;
throw new PrismException ( "Generated automaton has extra atomic proposition \"" + ap + "\"" ) ;
}
}
/ / It ' s fine for the automaton to not have APs that occur in the formula , e . g . , for
@ -344,7 +337,7 @@ public class LTL2DA extends PrismComponent
/ / Build / export DA
LTL2DA ltl2da = new LTL2DA ( new PrismComponent ( ) ) ;
DA < BitSet , ? extends AcceptanceOmega > da = ltl2da . convertLTLFormulaToDA ( expr , null , AcceptanceType . RABIN , AcceptanceType . REACH ) ;
DA < BitSet , ? extends AcceptanceOmega > da = ltl2da . convertLTLFormulaToDA ( expr , null , AcceptanceType . RABIN , AcceptanceType . REACH ) ;
PrintStream out = ( args . length < 2 | | "-" . equals ( args [ 1 ] ) ) ? System . out : new PrintStream ( args [ 1 ] ) ;
String format = ( args . length < 3 ) ? "hoa" : args [ 2 ] ;
da . print ( out , format ) ;