@@ -74,6 +74,7 @@ void ObjectInvariant()
7474 Contract . Invariant ( cce . NonNullDictionaryAndValues ( calleeCounterexamples ) ) ;
7575 }
7676
77+ public ProofRun ProofRun { get ; }
7778 protected readonly VCGenOptions options ;
7879 [ Peer ] public List < Block > Trace ;
7980 public List < object > AugmentedTrace ;
@@ -88,7 +89,8 @@ void ObjectInvariant()
8889
8990 public Dictionary < TraceLocation , CalleeCounterexampleInfo > calleeCounterexamples ;
9091
91- internal Counterexample ( VCGenOptions options , List < Block > trace , List < object > augmentedTrace , Model model , VC . ModelViewInfo mvInfo , ProverContext context )
92+ internal Counterexample ( VCGenOptions options , List < Block > trace , List < object > augmentedTrace , Model model ,
93+ VC . ModelViewInfo mvInfo , ProverContext context , ProofRun proofRun )
9294 {
9395 Contract . Requires ( trace != null ) ;
9496 Contract . Requires ( context != null ) ;
@@ -97,6 +99,7 @@ internal Counterexample(VCGenOptions options, List<Block> trace, List<object> au
9799 this . Model = model ;
98100 this . MvInfo = mvInfo ;
99101 this . Context = context ;
102+ this . ProofRun = proofRun ;
100103 this . calleeCounterexamples = new Dictionary < TraceLocation , CalleeCounterexampleInfo > ( ) ;
101104 // the call to instance method GetModelValue in the following code requires the fields Model and Context to be initialized
102105 if ( augmentedTrace != null )
@@ -213,14 +216,12 @@ public void Print(int indent, TextWriter tw, Action<Block> blockAction = null)
213216 }
214217 }
215218
216- public static bool firstModelFile = true ;
217-
218219 public void PrintModel ( TextWriter tw , Counterexample counterexample )
219220 {
220221 Contract . Requires ( counterexample != null ) ;
221222
222- var filename = options . ModelViewFile ;
223- if ( Model == null || filename == null || options . StratifiedInlining > 0 )
223+ var filenameTemplate = options . ModelViewFile ;
224+ if ( Model == null || filenameTemplate == null || options . StratifiedInlining > 0 )
224225 {
225226 return ;
226227 }
@@ -238,14 +239,14 @@ public void PrintModel(TextWriter tw, Counterexample counterexample)
238239 Model . ModelHasStatesAlready = true ;
239240 }
240241
241- if ( filename == "-" )
242+ if ( filenameTemplate == "-" )
242243 {
243244 Model . Write ( tw ) ;
244245 tw . Flush ( ) ;
245246 }
246247 else {
247- using var wr = new StreamWriter ( filename , ! firstModelFile ) ;
248- firstModelFile = false ;
248+ var ( filename , reused ) = Helpers . GetLogFilename ( ProofRun . Description , filenameTemplate , true ) ;
249+ using var wr = new StreamWriter ( filename , reused ) ;
249250 Model . Write ( wr ) ;
250251 }
251252 }
@@ -476,8 +477,8 @@ void ObjectInvariant()
476477
477478
478479 public AssertCounterexample ( VCGenOptions options , List < Block > trace , List < object > augmentedTrace , AssertCmd failingAssert , Model model , VC . ModelViewInfo mvInfo ,
479- ProverContext context )
480- : base ( options , trace , augmentedTrace , model , mvInfo , context )
480+ ProverContext context , ProofRun proofRun )
481+ : base ( options , trace , augmentedTrace , model , mvInfo , context , proofRun )
481482 {
482483 Contract . Requires ( trace != null ) ;
483484 Contract . Requires ( failingAssert != null ) ;
@@ -497,7 +498,7 @@ public override byte[] Checksum
497498
498499 public override Counterexample Clone ( )
499500 {
500- var ret = new AssertCounterexample ( options , Trace , AugmentedTrace , FailingAssert , Model , MvInfo , Context ) ;
501+ var ret = new AssertCounterexample ( options , Trace , AugmentedTrace , FailingAssert , Model , MvInfo , Context , ProofRun ) ;
501502 ret . calleeCounterexamples = calleeCounterexamples ;
502503 return ret ;
503504 }
@@ -517,8 +518,8 @@ void ObjectInvariant()
517518
518519
519520 public CallCounterexample ( VCGenOptions options , List < Block > trace , List < object > augmentedTrace , CallCmd failingCall , Requires failingRequires , Model model ,
520- VC . ModelViewInfo mvInfo , ProverContext context , byte [ ] checksum = null )
521- : base ( options , trace , augmentedTrace , model , mvInfo , context )
521+ VC . ModelViewInfo mvInfo , ProverContext context , ProofRun proofRun , byte [ ] checksum = null )
522+ : base ( options , trace , augmentedTrace , model , mvInfo , context , proofRun )
522523 {
523524 Contract . Requires ( ! failingRequires . Free ) ;
524525 Contract . Requires ( trace != null ) ;
@@ -545,7 +546,7 @@ public override byte[] Checksum
545546
546547 public override Counterexample Clone ( )
547548 {
548- var ret = new CallCounterexample ( options , Trace , AugmentedTrace , FailingCall , FailingRequires , Model , MvInfo , Context , Checksum ) ;
549+ var ret = new CallCounterexample ( options , Trace , AugmentedTrace , FailingCall , FailingRequires , Model , MvInfo , Context , ProofRun , Checksum ) ;
549550 ret . calleeCounterexamples = calleeCounterexamples ;
550551 return ret ;
551552 }
@@ -565,8 +566,8 @@ void ObjectInvariant()
565566
566567
567568 public ReturnCounterexample ( VCGenOptions options , List < Block > trace , List < object > augmentedTrace , TransferCmd failingReturn , Ensures failingEnsures , Model model ,
568- VC . ModelViewInfo mvInfo , ProverContext context , byte [ ] checksum )
569- : base ( options , trace , augmentedTrace , model , mvInfo , context )
569+ VC . ModelViewInfo mvInfo , ProverContext context , ProofRun proofRun , byte [ ] checksum )
570+ : base ( options , trace , augmentedTrace , model , mvInfo , context , proofRun )
570571 {
571572 Contract . Requires ( trace != null ) ;
572573 Contract . Requires ( context != null ) ;
@@ -595,7 +596,7 @@ public override byte[] Checksum
595596
596597 public override Counterexample Clone ( )
597598 {
598- var ret = new ReturnCounterexample ( options , Trace , AugmentedTrace , FailingReturn , FailingEnsures , Model , MvInfo , Context , checksum ) ;
599+ var ret = new ReturnCounterexample ( options , Trace , AugmentedTrace , FailingReturn , FailingEnsures , Model , MvInfo , Context , ProofRun , checksum ) ;
599600 ret . calleeCounterexamples = calleeCounterexamples ;
600601 return ret ;
601602 }
0 commit comments