Skip to content
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

[Civl] Fixed treiber stack #885

Merged
merged 9 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Source/Concurrency/LinearRewriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public List<Cmd> RewriteCallCmd(CallCmd callCmd)
switch (Monomorphizer.GetOriginalDecl(callCmd.Proc).Name)
{
case "One_New":
case "One_To_Fractions":
case "Fractions_To_One":
case "Cell_Pack":
case "Cell_Unpack":
case "Set_MakeEmpty":
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/CivlAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public static class CivlPrimitives
{
public static HashSet<string> LinearPrimitives = new()
{
"One_New",
"One_New", "One_To_Fractions", "Fractions_To_One",
"Cell_Pack", "Cell_Unpack",
"Map_MakeEmpty", "Map_Split", "Map_Get", "Map_Put", "Map_Assume",
"Set_MakeEmpty", "Set_Split", "Set_Get", "Set_Put", "One_Split", "One_Get", "One_Put"
Expand Down
16 changes: 15 additions & 1 deletion Source/Core/base.bpl
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ function {:inline} Map_Swap<T,U>(a: Map T U, t1: T, t2: T): Map T U
(var u1, u2 := Map_At(a, t1), Map_At(a, t2); Map_Update(Map_Update(a, t1, u2), t2, u1))
}

function {:inline} Map_WellFormed<T,U>(a: Map T U): bool {
function {:inline} Map_WellFormed<T,U>(a: Map T U): bool
{
a->val == MapIte(a->dom->val, a->val, MapConst(Default()))
}

Expand All @@ -295,6 +296,19 @@ function {:inline} One_Collector<T>(a: One T): [T]bool
MapOne(a->val)
}

datatype Fraction<T, K> { Fraction(val: T, id: K, ids: [K]bool) }

pure procedure {:inline 1} One_To_Fractions<T,K>({:linear_in} one_t: One T, ids: [K]bool) returns ({:linear} pieces: Set (Fraction T K))
{
pieces := Set((lambda piece: Fraction T K :: piece->val == one_t->val && ids[piece->id] && piece->ids == ids));
}

pure procedure {:inline 1} Fractions_To_One<T,K>({:linear_out} one_t: One T, ids: [K]bool, {:linear_in} pieces: Set (Fraction T K))
{
assert (forall piece: Fraction T K:: Set_Contains(pieces, piece) ==> piece->val == one_t->val && piece->ids == ids);
assert pieces == Set((lambda piece: Fraction T K :: piece->val == one_t->val && ids[piece->id] && piece->ids == ids));
}

/// singleton map
datatype Cell<T,U> { Cell(key: T, val: U) }

Expand Down
Loading
Loading