public FuncDecl GetAndAssertPureDecl(IMethodSymbol symbol) { FuncDecl declaration; if (!_assertedDeclarations.TryGetValue(symbol, out declaration)) { var ctx = _info.Ctx; var cfg = GetCFG(symbol); var parameterMappings = symbol.Parameters.Select(x => _info.Mapper.GetSortMapping(x.Type)); var parameterVars = parameterMappings.Select((x, i) => ctx.MkBound((uint)i, x.Sort)).ToArray(); var arguments = parameterMappings.Zip(parameterVars, (a, b) => a.MutatorForValue(b)); Dictionary <ISymbol, Mutator> parameters = symbol.Parameters .Zip(arguments, (Parameter, Mutator) => new { Parameter, Mutator }) .ToDictionary(x => (ISymbol)x.Parameter, x => x.Mutator); var returnType = _info.Mapper.GetSortMapping(symbol.ReturnType); var invocationEntryState = new PureExplorationState(_info, cfg.EntryPoint, returnType, parameters, parameterVars); var explored = invocationEntryState.Explore(); var definition = explored.CreateUpdate(); var domain = parameterMappings.Select(x => x.Sort).ToArray(); var range = _info.Mapper.GetSortMapping(symbol.ReturnType).Sort; declaration = ctx.MkFuncDecl(symbol.Name, domain, range); var body = ctx.MkEq(ctx.MkApp(declaration, parameterVars), definition); var parameterSymbols = parameterMappings.Select((x, i) => ctx.MkSymbol(i)); var forall = ctx.MkForall(parameterVars.Select(x => x.Sort).ToArray(), parameterSymbols.ToArray(), body); _info.AutomataCtx.Z3S.Assert(forall); Assertions.Add(forall); _assertedDeclarations.Add(symbol, declaration); _functionBodies.Add(Tuple.Create(declaration, definition, parameterVars)); } return(declaration); }
public Mutator GetPureExpr(IMethodSymbol symbol, Mutator[] arguments, Expr[] boundVars) { var cfg = GetCFG(symbol); Dictionary <ISymbol, Mutator> parameters = symbol.Parameters .Zip(arguments, (Parameter, Mutator) => new { Parameter, Mutator }) .ToDictionary(x => (ISymbol)x.Parameter, x => x.Mutator); var returnType = _info.Mapper.GetSortMapping(symbol.ReturnType); var invocationEntryState = new PureExplorationState(_info, cfg.EntryPoint, returnType, parameters, boundVars); return(invocationEntryState.Explore()); }
public PureExplorationState(PureExplorationState toClone) : base(toClone) { _returnType = toClone._returnType; }