private IEnumerable <CounterExampleItem> GetCounterExamples(DafnyModel model) { return(model.States .WithCancellation(cancellationToken) .OfType <DafnyModelState>() .Where(state => !state.IsInitialState) .Select(GetCounterExample)); }
/// <summary> /// Extract the counterexample corresponding to the first failing /// assertion and print it to the console /// </summary> /// <param name="modelViewFile"> Name of the file from which to read /// the counterexample </param> private static void PrintCounterexample(string modelViewFile) { var model = DafnyModel.ExtractModel(File.ReadAllText(modelViewFile)); Console.WriteLine("Counterexample for first failing assertion: "); foreach (var state in model.States.Where(state => !state.IsInitialState)) { Console.WriteLine(state.FullStateName + ":"); var vars = state.ExpandedVariableSet(-1); foreach (var variable in vars) { Console.WriteLine($"\t{variable.ShortName} : " + $"{variable.Type.InDafnyFormat()} = " + $"{variable.Value}"); } } }