Skip to content

Constraint independence #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 57 commits into from

Conversation

mxprshn
Copy link
Member

@mxprshn mxprshn commented Dec 1, 2021

No description provided.

@dvvrd dvvrd requested a review from MchKosticyn December 1, 2021 19:45
Comment on lines 45 to 78
let condConsts = discoverConstants [cond] |> PersistentSet.ofSeq
let pufWithNewConsts =
condConsts
|> PersistentSet.filter (fun t -> None = PersistentUnionFind.tryFind t pc.constants)
|> PersistentSet.fold PersistentUnionFind.add pc.constants
let constsWithSources =
Seq.map
(function
| ConstantT(_, src, _) as constant -> constant, src
| _ -> __unreachable__()
)
// Merge sets of constants dependent in terms of ISymbolicConstantSource
let pufMergedByConstantSource =
Seq.allPairs
(condConsts |> PersistentSet.toSeq |> constsWithSources)
(pc.constants |> PersistentUnionFind.toSeq |> constsWithSources)
|> Seq.filter (fun ((_, src1), (_, src2)) -> not <| src1.IndependentWith src2)
|> Seq.fold (fun puf ((const1, _), (const2, _)) -> PersistentUnionFind.union const1 const2 puf) pufWithNewConsts
(*
Merge sets of constants dependent in terms of reachability in graph where
edge between constants means that they are contained in the same condition
*)
let pufMergedByDependentCondition =
condConsts
|> someSetElement
|> function
| Some(parent) ->
PersistentSet.fold (fun puf t -> PersistentUnionFind.union t parent puf) pufMergedByConstantSource condConsts
| None -> pufMergedByConstantSource
{constants = pufMergedByDependentCondition
conditionsWithConstants =
condConsts
|> someSetElement
|> (fun head -> PersistentDict.add cond head pc.conditionsWithConstants)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше это выделить в отдельную функцию

Comment on lines 669 to 671
|> function
| Some(fragment) -> fragment
| None -> pc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вероятно, Option.defaultValue здесь будет лучше смотреться

Comment on lines 50 to 61
let constsWithSources =
Seq.map
(function
| ConstantT(_, src, _) as constant -> constant, src
| _ -> __unreachable__()
)
// Merge sets of constants dependent in terms of ISymbolicConstantSource
let pufMergedByConstantSource =
Seq.allPairs
(condConsts |> PersistentSet.toSeq |> constsWithSources)
(pc.constants |> PersistentUnionFind.toSeq |> constsWithSources)
|> Seq.filter (fun ((_, src1), (_, src2)) -> not <| src1.IndependentWith src2)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source из константы не нужен в последствии, поэтому вместо создания последовательности из пар (константа, source), стоит объявить функцию, которая будет принимать пару конастант и сравнивать их source

pc.conditionsWithConstants
|> PersistentDict.fold groupConditionsByUnionFindParent PersistentDict.empty
|> PersistentDict.toSeq
|> Seq.map conditionsGroupToPathCondition
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Стоит добавить пустую строчку, чтобы гит не ругался

Comment on lines 99 to 101
|> function
| Some(someConst) -> PersistentUnionFind.tryFind someConst pc.constants
| None -> None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут можно использовать Option.bind

traverse unwrappedNext updatedDict
else updatedDict
let subsetElements = traverse a PersistentDict.empty
{elements = subsetElements}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Нужно добавить пустую строчку в конец файла

@@ -333,6 +349,20 @@ module internal Memory =
let declaringType = fromDotNetType m.DeclaringType
if isValueType declaringType then __insufficientInformation__ "Can't execute in isolation methods of value types, because we can't be sure where exactly \"this\" is allocated!"
else HeapRef (Constant "this" {baseSource = {key = ThisKey m; time = Some VectorTime.zero}} AddressType) declaringType

let fillWithParametersAndThis state (method : System.Reflection.MethodBase) =
let parameters = method.GetParameters() |> Seq.map (fun param ->
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В этом месте не уверен по поводу того, нужно ли вместе с параметрами добавить что-то в allocatedTypes у state

@mxprshn
Copy link
Member Author

mxprshn commented Mar 21, 2022

Сломалась версия runtime, пофикшу

// let usedPaths =
// pathAtoms
// |> Seq.filter (fun atom -> z3Model.Eval(atom, false).IsTrue)
// |> Seq.map (fun atom -> paths.[atom])
SmtSat { mdl = model; usedPaths = [](*usedPaths*) }
builder.ClearT2E()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Немного напрягло, что пришлось чистить кэш (иначе в модель попадали лишние константы из кэша)

@mxprshn
Copy link
Member Author

mxprshn commented Jun 2, 2022

@mxprshn mxprshn closed this Jul 15, 2022
@mxprshn mxprshn deleted the constraint-independence branch July 27, 2023 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants