@ -1,89 +1,104 @@ 
			
		
	
		
			
				
					# include  "src/solver/Z3SmtSolver.h" 
  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					# include  "src/exceptions/NotSupportedException.h" 
  
			
		
	
		
			
				
					# include  "src/exceptions/InvalidStateException.h" 
  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					namespace  storm  {  
			
		
	
		
			
				
						namespace  solver  {  
			
		
	
		
			
				
					# ifdef STORM_HAVE_Z3 
  
			
		
	
		
			
				
							Z3SmtSolver : : Z3ModelReference : : Z3ModelReference ( z3 : : model  & m ,  storm : : adapters : : Z3ExpressionAdapter  & a dapter )  :  m_m odel ( m ) ,  m_adapter ( a dapter)  {  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
							Z3SmtSolver : : Z3ModelReference : : Z3ModelReference ( z3 : : model  const &   model  ,  storm : : adapters : : Z3ExpressionAdapter &  expressionA dapter)  :  model ( model  ) ,  expressionAdapter ( expressionA dapter)  {  
			
		
	
		
			
				
					            // Intentionally left empty. 
  
			
		
	
		
			
				
							}  
			
		
	
		
			
				
					# endif 
  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
							bool  Z3SmtSolver : : Z3ModelReference : : getBooleanValue ( std : : string  const &  name )  const  {  
			
		
	
		
			
				
					# ifdef STORM_HAVE_Z3 
  
			
		
	
		
			
				
								z3 : : expr  z3Expr  =  this - > m_a dapter. translateExpression ( storm : : expressions : : Expression : : createBooleanVariable ( name ) ) ;  
			
		
	
		
			
				
								z3 : : expr  z3ExprValuation  =  m_m odel . eval ( z3Expr ,  true ) ;  
			
		
	
		
			
				
								return  this - > m_a dapter. translateExpression ( z3ExprValuation ) . evaluateAsBool ( ) ;  
			
		
	
		
			
				
								z3 : : expr  z3Expr  =  this - > expressionA dapter. translateExpression ( storm : : expressions : : Expression : : createBooleanVariable ( name ) ) ;  
			
		
	
		
			
				
								z3 : : expr  z3ExprValuation  =  model . eval ( z3Expr ,  true ) ;  
			
		
	
		
			
				
								return  this - > expressionA dapter. translateExpression ( z3ExprValuation ) . evaluateAsBool ( ) ;  
			
		
	
		
			
				
					# else 
  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotImplemen tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotSuppor tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
					# endif 
  
			
		
	
		
			
				
							}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
							int_fast64_t  Z3SmtSolver : : Z3ModelReference : : getIntegerValue ( std : : string  const &  name )  const  {  
			
		
	
		
			
				
					# ifdef STORM_HAVE_Z3 
  
			
		
	
		
			
				
								z3 : : expr  z3Expr  =  this - > m_a dapter. translateExpression ( storm : : expressions : : Expression : : createIntegerVariable ( name ) ) ;  
			
		
	
		
			
				
								z3 : : expr  z3ExprValuation  =  m_m odel . eval ( z3Expr ,  true ) ;  
			
		
	
		
			
				
								return  this - > m_a dapter. translateExpression ( z3ExprValuation ) . evaluateAsInt ( ) ;  
			
		
	
		
			
				
								z3 : : expr  z3Expr  =  this - > expressionA dapter. translateExpression ( storm : : expressions : : Expression : : createIntegerVariable ( name ) ) ;  
			
		
	
		
			
				
								z3 : : expr  z3ExprValuation  =  model . eval ( z3Expr ,  true ) ;  
			
		
	
		
			
				
								return  this - > expressionA dapter. translateExpression ( z3ExprValuation ) . evaluateAsInt ( ) ;  
			
		
	
		
			
				
					# else 
  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotImplemen tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotSuppor tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
					# endif 
  
			
		
	
		
			
				
							}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
							 Z3SmtSolver : : Z3SmtSolver ( Options  options )   
			
		
	
		
			
				
					        double   Z3SmtSolver : : Z3ModelReference : : getDoubleValue ( std : : string  const &  name )  const  {   
			
		
	
		
			
				
					# ifdef STORM_HAVE_Z3 
  
			
		
	
		
			
				
								:  m_context ( )  
			
		
	
		
			
				
								,  m_solver ( m_context )  
			
		
	
		
			
				
								,  m_adapter ( m_context ,  std : : map < std : : string ,  z3 : : expr > ( ) )  
			
		
	
		
			
				
								z3 : : expr  z3Expr  =  this - > expressionAdapter . translateExpression ( storm : : expressions : : Expression : : createDoubleVariable ( name ) ) ;  
			
		
	
		
			
				
								z3 : : expr  z3ExprValuation  =  model . eval ( z3Expr ,  true ) ;  
			
		
	
		
			
				
								return  this - > expressionAdapter . translateExpression ( z3ExprValuation ) . evaluateAsDouble ( ) ;  
			
		
	
		
			
				
					# else 
  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotSupportedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
					# endif 
  
			
		
	
		
			
				
							}  
			
		
	
		
			
				
					         
			
		
	
		
			
				
							Z3SmtSolver : : Z3SmtSolver ( )  
			
		
	
		
			
				
					# ifdef STORM_HAVE_Z3 
  
			
		
	
		
			
				
								:  context ( )  
			
		
	
		
			
				
								,  solver ( context )  
			
		
	
		
			
				
								,  expressionAdapter ( context ,  std : : map < std : : string ,  z3 : : expr > ( ) )  
			
		
	
		
			
				
								,  lastCheckAssumptions ( false )  
			
		
	
		
			
				
					            ,  lastResult ( CheckResult : : UNKNOWN )  
			
		
	
		
			
				
					            ,  lastResult ( CheckResult : : Unknown  )  
			
		
	
		
			
				
					# endif 
  
			
		
	
		
			
				
							{  
			
		
	
		
			
				
								//intentionally left empty
  
			
		
	
		
			
				
								// Intentionally left empty.
  
			
		
	
		
			
				
							}  
			
		
	
		
			
				
					         
			
		
	
		
			
				
							Z3SmtSolver : : ~ Z3SmtSolver ( )  {  
			
		
	
		
			
				
					            // Intentionally left empty.
  
			
		
	
		
			
				
					        }  
			
		
	
		
			
				
							Z3SmtSolver : : ~ Z3SmtSolver ( )  { } ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
							void  Z3SmtSolver : : push ( )  
			
		
	
		
			
				
							{  
			
		
	
		
			
				
					# ifdef STORM_HAVE_Z3 
  
			
		
	
		
			
				
								this - > m_ solver. push ( ) ;  
			
		
	
		
			
				
								this - > solver . push ( ) ;  
			
		
	
		
			
				
					# else 
  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotImplemen tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotSuppor tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
					# endif 
  
			
		
	
		
			
				
							}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
							void  Z3SmtSolver : : pop ( )  
			
		
	
		
			
				
							{  
			
		
	
		
			
				
					# ifdef STORM_HAVE_Z3 
  
			
		
	
		
			
				
								this - > m_ solver. pop ( ) ;  
			
		
	
		
			
				
								this - > solver . pop ( ) ;  
			
		
	
		
			
				
					# else 
  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotImplemen tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotSuppor tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
					# endif 
  
			
		
	
		
			
				
							}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
							void  Z3SmtSolver : : pop ( uint_fast64_t  n )  
			
		
	
		
			
				
							{  
			
		
	
		
			
				
					# ifdef STORM_HAVE_Z3 
  
			
		
	
		
			
				
								this - > m_ solver. pop ( ( unsigned  int ) n ) ;  
			
		
	
		
			
				
								this - > solver . pop ( static_cast < unsigned  int > ( n ) ) ;  
			
		
	
		
			
				
					# else 
  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotImplemen tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotSuppor tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
					# endif 
  
			
		
	
		
			
				
							}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
							void  Z3SmtSolver : : reset ( )  
			
		
	
		
			
				
							{  
			
		
	
		
			
				
					# ifdef STORM_HAVE_Z3 
  
			
		
	
		
			
				
								this - > m_ solver. reset ( ) ;  
			
		
	
		
			
				
								this - > solver . reset ( ) ;  
			
		
	
		
			
				
					# else 
  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotImplemen tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotSuppor tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
					# endif 
  
			
		
	
		
			
				
							}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
							void  Z3SmtSolver : : assertExpression  ( storm : : expressions : : Expression  const &  e )  
			
		
	
		
			
				
							void  Z3SmtSolver : : add  ( storm : : expressions : : Expression  const &  ass ertion )  
			
		
	
		
			
				
							{  
			
		
	
		
			
				
					# ifdef STORM_HAVE_Z3 
  
			
		
	
		
			
				
								this - > m_ solver. add ( m_a dapter. translateExpression ( e ,  true ) ) ;  
			
		
	
		
			
				
								this - > solver . add ( expressionA dapter. translateExpression ( ass ertion ,  true ) ) ;  
			
		
	
		
			
				
					# else 
  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotImplemen tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotSuppor tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
					# endif 
  
			
		
	
		
			
				
							}  
			
		
	
		
			
				
					
 
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -91,20 +106,20 @@ namespace storm { 
			
		
	
		
			
				
							{  
			
		
	
		
			
				
					# ifdef STORM_HAVE_Z3 
  
			
		
	
		
			
				
								lastCheckAssumptions  =  false ;  
			
		
	
		
			
				
								switch  ( this - > m_ solver. check ( ) )  {  
			
		
	
		
			
				
								switch  ( this - > solver . check ( ) )  {  
			
		
	
		
			
				
									case  z3 : : sat :  
			
		
	
		
			
				
										this - > lastResult  =  SmtSolver : : CheckResult : : SAT  ;  
			
		
	
		
			
				
										this - > lastResult  =  SmtSolver : : CheckResult : : Sat  ;  
			
		
	
		
			
				
										break ;  
			
		
	
		
			
				
									case  z3 : : unsat :  
			
		
	
		
			
				
										this - > lastResult  =  SmtSolver : : CheckResult : : UNSAT  ;  
			
		
	
		
			
				
										this - > lastResult  =  SmtSolver : : CheckResult : : Unsat  ;  
			
		
	
		
			
				
										break ;  
			
		
	
		
			
				
									default :  
			
		
	
		
			
				
										this - > lastResult  =  SmtSolver : : CheckResult : : UNKNOWN  ;  
			
		
	
		
			
				
										this - > lastResult  =  SmtSolver : : CheckResult : : Unknown  ;  
			
		
	
		
			
				
										break ;  
			
		
	
		
			
				
								}  
			
		
	
		
			
				
								return  this - > lastResult ;  
			
		
	
		
			
				
					# else 
  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotImplemen tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotSuppor tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
					# endif 
  
			
		
	
		
			
				
							}  
			
		
	
		
			
				
					
 
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -112,26 +127,26 @@ namespace storm { 
			
		
	
		
			
				
							{  
			
		
	
		
			
				
					# ifdef STORM_HAVE_Z3 
  
			
		
	
		
			
				
								lastCheckAssumptions  =  true ;  
			
		
	
		
			
				
								z3 : : expr_vector  z3Assumptions ( this - > m_ context) ;  
			
		
	
		
			
				
								z3 : : expr_vector  z3Assumptions ( this - > context ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
								for  ( storm : : expressions : : Expression  assumption  :  assumptions )  {  
			
		
	
		
			
				
									z3Assumptions . push_back ( this - > m_a dapter. translateExpression ( assumption ) ) ;  
			
		
	
		
			
				
									z3Assumptions . push_back ( this - > expressionA dapter. translateExpression ( assumption ) ) ;  
			
		
	
		
			
				
								}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
								switch  ( this - > m_ solver. check ( z3Assumptions ) )  {  
			
		
	
		
			
				
								switch  ( this - > solver . check ( z3Assumptions ) )  {  
			
		
	
		
			
				
									case  z3 : : sat :  
			
		
	
		
			
				
										this - > lastResult  =  SmtSolver : : CheckResult : : SAT  ;  
			
		
	
		
			
				
										this - > lastResult  =  SmtSolver : : CheckResult : : Sat  ;  
			
		
	
		
			
				
										break ;  
			
		
	
		
			
				
									case  z3 : : unsat :  
			
		
	
		
			
				
										this - > lastResult  =  SmtSolver : : CheckResult : : UNSAT  ;  
			
		
	
		
			
				
										this - > lastResult  =  SmtSolver : : CheckResult : : Unsat  ;  
			
		
	
		
			
				
										break ;  
			
		
	
		
			
				
									default :  
			
		
	
		
			
				
										this - > lastResult  =  SmtSolver : : CheckResult : : UNKNOWN  ;  
			
		
	
		
			
				
										this - > lastResult  =  SmtSolver : : CheckResult : : Unknown  ;  
			
		
	
		
			
				
										break ;  
			
		
	
		
			
				
								}  
			
		
	
		
			
				
								return  this - > lastResult ;  
			
		
	
		
			
				
					# else 
  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotImplemen tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotSuppor tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
					# endif 
  
			
		
	
		
			
				
							}  
			
		
	
		
			
				
					
 
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -139,58 +154,56 @@ namespace storm { 
			
		
	
		
			
				
							{  
			
		
	
		
			
				
					# ifdef STORM_HAVE_Z3 
  
			
		
	
		
			
				
								lastCheckAssumptions  =  true ;  
			
		
	
		
			
				
								z3 : : expr_vector  z3Assumptions ( this - > m_ context) ;  
			
		
	
		
			
				
								z3 : : expr_vector  z3Assumptions ( this - > context ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
								for  ( storm : : expressions : : Expression  assumption  :  assumptions )  {  
			
		
	
		
			
				
									z3Assumptions . push_back ( this - > m_a dapter. translateExpression ( assumption ) ) ;  
			
		
	
		
			
				
									z3Assumptions . push_back ( this - > expressionA dapter. translateExpression ( assumption ) ) ;  
			
		
	
		
			
				
								}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
								switch  ( this - > m_ solver. check ( z3Assumptions ) )  {  
			
		
	
		
			
				
								switch  ( this - > solver . check ( z3Assumptions ) )  {  
			
		
	
		
			
				
									case  z3 : : sat :  
			
		
	
		
			
				
										this - > lastResult  =  SmtSolver : : CheckResult : : SAT  ;  
			
		
	
		
			
				
										this - > lastResult  =  SmtSolver : : CheckResult : : Sat  ;  
			
		
	
		
			
				
										break ;  
			
		
	
		
			
				
									case  z3 : : unsat :  
			
		
	
		
			
				
										this - > lastResult  =  SmtSolver : : CheckResult : : UNSAT  ;  
			
		
	
		
			
				
										this - > lastResult  =  SmtSolver : : CheckResult : : Unsat  ;  
			
		
	
		
			
				
										break ;  
			
		
	
		
			
				
									default :  
			
		
	
		
			
				
										this - > lastResult  =  SmtSolver : : CheckResult : : UNKNOWN  ;  
			
		
	
		
			
				
										this - > lastResult  =  SmtSolver : : CheckResult : : Unknown  ;  
			
		
	
		
			
				
										break ;  
			
		
	
		
			
				
								}  
			
		
	
		
			
				
								return  this - > lastResult ;  
			
		
	
		
			
				
					# else 
  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotImplemen tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotSuppor tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
					# endif 
  
			
		
	
		
			
				
							}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
							storm : : expressions : : SimpleValuation  Z3SmtSolver : : getModel ( )  
			
		
	
		
			
				
							{  
			
		
	
		
			
				
					# ifdef STORM_HAVE_Z3 
  
			
		
	
		
			
				
								 
			
		
	
		
			
				
								STORM_LOG_THROW ( this - > lastResult  = =  SmtSolver : : CheckResult : : SAT ,  storm : : exceptions : : InvalidStateException ,  " Requested Model but last check result was not SAT. " ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
								return  this - > z3ModelToStorm ( this - > m_solver . get_model ( ) ) ;  
			
		
	
		
			
				
								STORM_LOG_THROW ( this - > lastResult  = =  SmtSolver : : CheckResult : : Sat ,  storm : : exceptions : : InvalidStateException ,  " Unable to create model for formula that was not determined to be satisfiable. " ) ;  
			
		
	
		
			
				
								return  this - > convertZ3ModelToValuation ( this - > solver . get_model ( ) ) ;  
			
		
	
		
			
				
					# else 
  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotImplemen tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotSupportedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
					# endif 
  
			
		
	
		
			
				
							}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					# ifdef STORM_HAVE_Z3 
  
			
		
	
		
			
				
							storm : : expressions : : SimpleValuation  Z3SmtSolver : : z3ModelToStorm ( z3 : : model  m )  {  
			
		
	
		
			
				
							storm : : expressions : : SimpleValuation  Z3SmtSolver : : convertZ3ModelToValuation ( z3 : : model  const &  model  )  {  
			
		
	
		
			
				
								storm : : expressions : : SimpleValuation  stormModel ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
								for  ( unsigned  i  =  0 ;  i  <  m . num_consts ( ) ;  + + i )  {  
			
		
	
		
			
				
									z3 : : func_decl  var_ i  =  m . get_const_decl ( i ) ;  
			
		
	
		
			
				
									storm : : expressions : : Expression  var_i_interp   =  this - > m_a dapter. translateExpression ( m . get_const_interp ( var_ i ) ) ;  
			
		
	
		
			
				
								for  ( unsigned  i  =  0 ;  i  <  model  . num_consts ( ) ;  + + i )  {  
			
		
	
		
			
				
									z3 : : func_decl  variableI   =  model  . get_const_decl ( i ) ;  
			
		
	
		
			
				
									storm : : expressions : : Expression  variableIInterpretation   =  this - > expressionA dapter. translateExpression ( model  . get_const_interp ( variableI  ) ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
									switch  ( var_i_interp  . getReturnType ( ) )  {  
			
		
	
		
			
				
									switch  ( variableIInterpretation  . getReturnType ( ) )  {  
			
		
	
		
			
				
										case  storm : : expressions : : ExpressionReturnType : : Bool :  
			
		
	
		
			
				
											stormModel . addBooleanIdentifier ( var_ i . name ( ) . str ( ) ,  var_i_interp  . evaluateAsBool ( ) ) ;  
			
		
	
		
			
				
											stormModel . addBooleanIdentifier ( variableI  . name ( ) . str ( ) ,  variableIInterpretation  . evaluateAsBool ( ) ) ;  
			
		
	
		
			
				
											break ;  
			
		
	
		
			
				
										case  storm : : expressions : : ExpressionReturnType : : Int :  
			
		
	
		
			
				
											stormModel . addIntegerIdentifier ( var_ i . name ( ) . str ( ) ,  var_i_interp  . evaluateAsInt ( ) ) ;  
			
		
	
		
			
				
											stormModel . addIntegerIdentifier ( variableI  . name ( ) . str ( ) ,  variableIInterpretation  . evaluateAsInt ( ) ) ;  
			
		
	
		
			
				
											break ;  
			
		
	
		
			
				
										case  storm : : expressions : : ExpressionReturnType : : Double :  
			
		
	
		
			
				
											stormModel . addDoubleIdentifier ( var_ i . name ( ) . str ( ) ,  var_i_interp  . evaluateAsDouble ( ) ) ;  
			
		
	
		
			
				
											stormModel . addDoubleIdentifier ( variableI  . name ( ) . str ( ) ,  variableIInterpretation  . evaluateAsDouble ( ) ) ;  
			
		
	
		
			
				
											break ;  
			
		
	
		
			
				
										default :  
			
		
	
		
			
				
											STORM_LOG_THROW ( false ,  storm : : exceptions : : ExpressionEvaluationException ,  " Variable interpretation in model is not of type bool, int or double. " )  
			
		
	
	
		
			
				
					
						
						
						
							
								 
						
					 
				
				@ -206,128 +219,122 @@ namespace storm { 
			
		
	
		
			
				
							std : : vector < storm : : expressions : : SimpleValuation >  Z3SmtSolver : : allSat ( std : : vector < storm : : expressions : : Expression >  const &  important )  
			
		
	
		
			
				
							{  
			
		
	
		
			
				
					# ifdef STORM_HAVE_Z3 
  
			
		
	
		
			
				
								 
			
		
	
		
			
				
								std : : vector < storm : : expressions : : SimpleValuation >  valuations ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
								this - > allSat ( important ,  [ & valuations ] ( storm : : expressions : : SimpleValuation &  valuation )  - >  bool  {  valuations . push_back ( valuation ) ;  return  true ;  } ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
								return  valuations ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					# else 
  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotImplemen tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotSuppor tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
					# endif 
  
			
		
	
		
			
				
							}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
							uint_fast64_t  Z3SmtSolver : : allSat ( std : : vector < storm : : expressions : : Expression >  const &  important ,  std : : function < bool ( storm : : expressions : : SimpleValuation & ) >  callback )  
			
		
	
		
			
				
							{  
			
		
	
		
			
				
					# ifdef STORM_HAVE_Z3 
  
			
		
	
		
			
				
								for  ( storm : : expressions : : Expression  e  :  important )  {  
			
		
	
		
			
				
									if  ( ! e . isVariable ( ) )  {  
			
		
	
		
			
				
										throw  storm : : exceptions : : InvalidArgumentException ( )  < <  " The important expressions for AllSat must be atoms, i.e. variable expressions. " ;  
			
		
	
		
			
				
									}  
			
		
	
		
			
				
								for  ( storm : : expressions : : Expression  const &  atom  :  important )  {  
			
		
	
		
			
				
					                STORM_LOG_THROW ( atom . isVariable ( ) ,  storm : : exceptions : : InvalidArgumentException ,  " The important atoms for AllSat must be atoms, i.e. variables. " ) ;  
			
		
	
		
			
				
								}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
								uint_fast64_t  numModels  =  0 ;  
			
		
	
		
			
				
								uint_fast64_t  numberOf Models  =  0 ;  
			
		
	
		
			
				
								bool  proceed  =  true ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					            // Save the current assertion stack, to be able to backtrack after the procedure.
  
			
		
	
		
			
				
								this - > push ( ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
								while  ( proceed  & &  this - > check ( )  = =  CheckResult : : SAT )  {  
			
		
	
		
			
				
									+ + numModels ;  
			
		
	
		
			
				
									z3 : : model  m  =  this - > m_solver . get_model ( ) ;  
			
		
	
		
			
				
					            // Enumerate models as long as the conjunction is satisfiable and the callback has not aborted the enumeration.
  
			
		
	
		
			
				
								while  ( proceed  & &  this - > check ( )  = =  CheckResult : : Sat )  {  
			
		
	
		
			
				
									+ + numberOfModels ;  
			
		
	
		
			
				
									z3 : : model  model  =  this - > solver . get_model ( ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
									z3 : : expr  modelExpr  =  this - > m_ context. bool_val ( true ) ;  
			
		
	
		
			
				
									z3 : : expr  modelExpr  =  this - > context . bool_val ( true ) ;  
			
		
	
		
			
				
									storm : : expressions : : SimpleValuation  valuation ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
									for  ( storm : : expressions : : Expression  importantAtom  :  important )  {  
			
		
	
		
			
				
										z3 : : expr  z3ImportantAtom  =  this - > m_a dapter. translateExpression ( importantAtom ) ;  
			
		
	
		
			
				
										z3 : : expr  z3ImportantAtomValuation  =  m . eval ( z3ImportantAtom ,  true ) ;  
			
		
	
		
			
				
									for  ( storm : : expressions : : Expression  const &  importantAtom  :  important )  {  
			
		
	
		
			
				
										z3 : : expr  z3ImportantAtom  =  this - > expressionA dapter. translateExpression ( importantAtom ) ;  
			
		
	
		
			
				
										z3 : : expr  z3ImportantAtomValuation  =  model  . eval ( z3ImportantAtom ,  true ) ;  
			
		
	
		
			
				
										modelExpr  =  modelExpr  & &  ( z3ImportantAtom  = =  z3ImportantAtomValuation ) ;  
			
		
	
		
			
				
										if  ( importantAtom . getReturnType ( )  = =  storm : : expressions : : ExpressionReturnType : : Bool )  {  
			
		
	
		
			
				
											valuation . addBooleanIdentifier ( importantAtom . getIdentifier ( ) ,  this - > m_a dapter. translateExpression ( z3ImportantAtomValuation ) . evaluateAsBool ( ) ) ;  
			
		
	
		
			
				
											valuation . addBooleanIdentifier ( importantAtom . getIdentifier ( ) ,  this - > expressionA dapter. translateExpression ( z3ImportantAtomValuation ) . evaluateAsBool ( ) ) ;  
			
		
	
		
			
				
										}  else  if  ( importantAtom . getReturnType ( )  = =  storm : : expressions : : ExpressionReturnType : : Int )  {  
			
		
	
		
			
				
											valuation . addIntegerIdentifier ( importantAtom . getIdentifier ( ) ,  this - > m_a dapter. translateExpression ( z3ImportantAtomValuation ) . evaluateAsInt ( ) ) ;  
			
		
	
		
			
				
											valuation . addIntegerIdentifier ( importantAtom . getIdentifier ( ) ,  this - > expressionA dapter. translateExpression ( z3ImportantAtomValuation ) . evaluateAsInt ( ) ) ;  
			
		
	
		
			
				
										}  else  if  ( importantAtom . getReturnType ( )  = =  storm : : expressions : : ExpressionReturnType : : Double )  {  
			
		
	
		
			
				
											valuation . addDoubleIdentifier ( importantAtom . getIdentifier ( ) ,  this - > m_a dapter. translateExpression ( z3ImportantAtomValuation ) . evaluateAsDouble ( ) ) ;  
			
		
	
		
			
				
											valuation . addDoubleIdentifier ( importantAtom . getIdentifier ( ) ,  this - > expressionA dapter. translateExpression ( z3ImportantAtomValuation ) . evaluateAsDouble ( ) ) ;  
			
		
	
		
			
				
										}  else  {  
			
		
	
		
			
				
											throw  storm : : exceptions : : InvalidTypeException ( )  < <   " Important atom has invalid type " ;  
			
		
	
		
			
				
					                        STORM_LOG_THROW ( false ,  storm : : exceptions : : InvalidTypeException ,   " Important atom has invalid type.  " ) ;  
			
		
	
		
			
				
										}  
			
		
	
		
			
				
									}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					                // Check if we are required to proceed, and if so rule out the current model.
  
			
		
	
		
			
				
									proceed  =  callback ( valuation ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
									this - > m_solver . add ( ! modelExpr ) ;  
			
		
	
		
			
				
					                if  ( proceed )  {  
			
		
	
		
			
				
					                    this - > solver . add ( ! modelExpr ) ;  
			
		
	
		
			
				
					                }  
			
		
	
		
			
				
								}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					            // Restore the old assertion stack and return.
  
			
		
	
		
			
				
								this - > pop ( ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
								return  numModels ;  
			
		
	
		
			
				
								return  numberOfModels ;  
			
		
	
		
			
				
					# else 
  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotImplemen tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotSuppor tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
					# endif 
  
			
		
	
		
			
				
							}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
							uint_fast64_t  Z3SmtSolver : : allSat ( std : : function < bool ( SmtSolver : : ModelReference & ) >  callback ,  std : : vector < storm : : expressions : : Expression >  const &  important )  
			
		
	
		
			
				
							uint_fast64_t  Z3SmtSolver : : allSat ( std : : vector < storm : : expressions : : Expression >  const &  important ,  std : : function < bool ( SmtSolver : : ModelReference & ) >  callback )  
			
		
	
		
			
				
							{  
			
		
	
		
			
				
					# ifdef STORM_HAVE_Z3 
  
			
		
	
		
			
				
								for  ( storm : : expressions : : Expression  e  :  important )  {  
			
		
	
		
			
				
									if  ( ! e . isVariable ( ) )  {  
			
		
	
		
			
				
										throw  storm : : exceptions : : InvalidArgumentException ( )  < <  " The important expressions for AllSat must be atoms, i.e. variable expressions. " ;  
			
		
	
		
			
				
									}  
			
		
	
		
			
				
								for  ( storm : : expressions : : Expression  const &  atom  :  important )  {  
			
		
	
		
			
				
					                STORM_LOG_THROW ( atom . isVariable ( ) ,  storm : : exceptions : : InvalidArgumentException ,  " The important atoms for AllSat must be atoms, i.e. variables. " ) ;  
			
		
	
		
			
				
								}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
								uint_fast64_t  numModels  =  0 ;  
			
		
	
		
			
				
								uint_fast64_t  numberOf Models  =  0 ;  
			
		
	
		
			
				
								bool  proceed  =  true ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
					            // Save the current assertion stack, to be able to backtrack after the procedure.
  
			
		
	
		
			
				
								this - > push ( ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
								while  ( proceed  & &  this - > check ( )  = =  CheckResult : : SAT )  {  
			
		
	
		
			
				
									+ + numModels ;  
			
		
	
		
			
				
									z3 : : model  m  =  this - > m_solver . get_model ( ) ;  
			
		
	
		
			
				
					            // Enumerate models as long as the conjunction is satisfiable and the callback has not aborted the enumeration.
  
			
		
	
		
			
				
								while  ( proceed  & &  this - > check ( )  = =  CheckResult : : Sat )  {  
			
		
	
		
			
				
									+ + numberOfModels ;  
			
		
	
		
			
				
									z3 : : model  model  =  this - > solver . get_model ( ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
									z3 : : expr  modelExpr  =  this - > m_ context. bool_val ( true ) ;  
			
		
	
		
			
				
									z3 : : expr  modelExpr  =  this - > context . bool_val ( true ) ;  
			
		
	
		
			
				
									storm : : expressions : : SimpleValuation  valuation ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
									for  ( storm : : expressions : : Expression  importantAtom  :  important )  {  
			
		
	
		
			
				
										z3 : : expr  z3ImportantAtom  =  this - > m_a dapter. translateExpression ( importantAtom ) ;  
			
		
	
		
			
				
										z3 : : expr  z3ImportantAtomValuation  =  m . eval ( z3ImportantAtom ,  true ) ;  
			
		
	
		
			
				
									for  ( storm : : expressions : : Expression  const &  importantAtom  :  important )  {  
			
		
	
		
			
				
										z3 : : expr  z3ImportantAtom  =  this - > expressionA dapter. translateExpression ( importantAtom ) ;  
			
		
	
		
			
				
										z3 : : expr  z3ImportantAtomValuation  =  model  . eval ( z3ImportantAtom ,  true ) ;  
			
		
	
		
			
				
										modelExpr  =  modelExpr  & &  ( z3ImportantAtom  = =  z3ImportantAtomValuation ) ;  
			
		
	
		
			
				
									}  
			
		
	
		
			
				
									Z3ModelReference  modelRef ( model ,  expressionAdapter ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
									Z3ModelReference  modelRef ( m ,  m_adapter ) ;   
			
		
	
		
			
				
					                // Check if we are required to proceed, and if so rule out the current model.
   
			
		
	
		
			
				
									proceed  =  callback ( modelRef ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
									this - > m_solver . add ( ! modelExpr ) ;  
			
		
	
		
			
				
					                if  ( proceed )  {  
			
		
	
		
			
				
					                    this - > solver . add ( ! modelExpr ) ;  
			
		
	
		
			
				
					                }  
			
		
	
		
			
				
								}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
								this - > pop ( ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
								return  numModels ;  
			
		
	
		
			
				
								return  numberOfModels ;  
			
		
	
		
			
				
					# else 
  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotImplemen tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotSuppor tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
					# endif 
  
			
		
	
		
			
				
							}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
							std : : vector < storm : : expressions : : Expression >  Z3SmtSolver : : getUnsatAssumptions ( )  {  
			
		
	
		
			
				
					# ifdef STORM_HAVE_Z3 
  
			
		
	
		
			
				
								if  ( lastResult  ! =  SmtSolver : : CheckResult : : UNSAT )  {  
			
		
	
		
			
				
									throw  storm : : exceptions : : InvalidStateException ( )  < <  " Unsat Assumptions was called but last state is not unsat. " ;  
			
		
	
		
			
				
								}  
			
		
	
		
			
				
								if  ( ! lastCheckAssumptions )  {  
			
		
	
		
			
				
									throw  storm : : exceptions : : InvalidStateException ( )  < <  " Unsat Assumptions was called but last check had no assumptions. " ;  
			
		
	
		
			
				
								}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
								z3 : : expr_vector  z3UnsatAssumptions  =  this - > m_solver . unsat_core ( ) ;  
			
		
	
		
			
				
					            STORM_LOG_THROW ( lastResult  = =  SmtSolver : : CheckResult : : Unsat ,  storm : : exceptions : : InvalidStateException ,  " Unable to generate unsatisfiable core of assumptions, because the last check did not determine the formulas to be unsatisfiable. " )  
			
		
	
		
			
				
					            STORM_LOG_THROW ( lastCheckAssumptions ,  storm : : exceptions : : InvalidStateException ,  " Unable to generate unsatisfiable core of assumptions, because the last check did not involve assumptions. " ) ;  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
								z3 : : expr_vector  z3UnsatAssumptions  =  this - > solver . unsat_core ( ) ;  
			
		
	
		
			
				
								std : : vector < storm : : expressions : : Expression >  unsatAssumptions ;  
			
		
	
		
			
				
								 
			
		
	
		
			
				
								for  ( unsigned  int  i  =  0 ;  i  <  z3UnsatAssumptions . size ( ) ;  + + i )  {  
			
		
	
		
			
				
									unsatAssumptions . push_back ( this - > m_a dapter. translateExpression ( z3UnsatAssumptions [ i ] ) ) ;  
			
		
	
		
			
				
									unsatAssumptions . push_back ( this - > expressionAdapter . translateExpression ( z3UnsatAssumptions [ i ] ) ) ;  
			
		
	
		
			
				
								}  
			
		
	
		
			
				
					
 
			
		
	
		
			
				
								return  unsatAssumptions ;  
			
		
	
		
			
				
					# else 
  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotImplemen tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
								STORM_LOG_THROW ( false ,  storm : : exceptions : : NotSuppor tedException ,  " StoRM is compiled without Z3 support. " ) ;  
			
		
	
		
			
				
					# endif 
  
			
		
	
		
			
				
							}  
			
		
	
		
			
				
						}