Skip to content
Draft
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
552d6bb
Reintroduce some ARG related code that was removed in 70e1be6
karoliineh Jun 28, 2025
f8f8915
Consider InlinedEdges correctly in BFS for violation path construction
karoliineh Jun 28, 2025
a16c8de
Add functionality to write violation yaml witnesses (with empty content)
karoliineh Jun 28, 2025
1756f67
Create assumption "1" waypoints and a target waypoint from violation …
karoliineh Jun 28, 2025
0396735
Differentiate function_enter, function_return and branching waypoints…
karoliineh Jun 28, 2025
87f5b8e
Use an efficient recursive function instead of map
karoliineh Jun 28, 2025
ae4679f
Find the right locations using WitnessInvariant.location_location
karoliineh Jun 29, 2025
1516a74
Disable function entry/return waypoints for now due to missing correc…
karoliineh Jun 29, 2025
a3fd139
Change violation path finding direction from bottom-up to top-down
karoliineh Jul 1, 2025
a0ff4fa
Add "mapping_start failed" to Yaml.to_string error handling
karoliineh Jul 2, 2025
d9cb04b
Temporarily disable conf immutability to bypass restriction on adding…
karoliineh Jul 2, 2025
745a4e8
Make `spec_module` a `ResettableLazy` to enable resetting hashcons li…
karoliineh Jul 2, 2025
0c1cea3
Add functionality to use witch for result refinement
karoliineh Jul 2, 2025
f73b8fa
Take into account that the verdicts can have suffixes (e.g. false(unr…
karoliineh Jul 2, 2025
c9eb38e
Bugfix: correctly account for InlinedEdges
karoliineh Jul 3, 2025
f40198a
Do not create waypoints of return edges (due to void fun-s not having…
karoliineh Jul 4, 2025
29efcde
Do uncilling only for witness waypoints (to keep the cilled path as a…
karoliineh Jul 4, 2025
a35192d
Add `--guide-only` flag for witch
karoliineh Jul 4, 2025
08a42eb
Trim path prefix up to the corresponding waypoint preceding the first…
karoliineh Jul 4, 2025
0d90cf9
Do not cut paths that contain the unreachable node within a loop
karoliineh Jul 6, 2025
da5b594
Log all of Witch'es output
karoliineh Jul 6, 2025
6cc99b7
Remove forgotten logging for debugging
karoliineh Jul 6, 2025
b47805c
Do not trim path when it includes setjump calls
karoliineh Jul 7, 2025
84bf053
Replace all `==` with `=`
karoliineh Jul 7, 2025
f6f8817
Bugfix: consider also Ret edges when removing function calls from cal…
karoliineh Jul 7, 2025
5ec6ae7
Bugfix: check that none of the function calls from the callstack are …
karoliineh Jul 7, 2025
798d41f
Move `collect_callstack` from `bfs` to `get_unreachable_path`
karoliineh Jul 7, 2025
b5600cf
Refactor: move `has_setjump_calls` check earlier
karoliineh Jul 7, 2025
4f1ec2a
Bugfix: include the step preceding the unreachable node (as identifie…
karoliineh Jul 8, 2025
4e6e78e
Bugfix: check loop containment for unreachable node itself, not just …
karoliineh Jul 8, 2025
842ef8d
Add branching waypoints at loop heads by considering loop locations f…
karoliineh Jul 9, 2025
7ca25fa
Count the number of times Witch runs
karoliineh Jul 9, 2025
3f3cbdc
Print number of Witch runs only once when SV-COMP result is printed
karoliineh Jul 10, 2025
c112d2d
Add branching "false" waypoints when the path skips the loop entirely
karoliineh Jul 10, 2025
99433a3
Do not add waypoints inside loops
karoliineh Jul 10, 2025
1e05007
Make the `uncil` option work again
karoliineh Jul 11, 2025
05feff9
Only print the nr of witch runs if Witch path is set
karoliineh Jul 11, 2025
8abcc15
Add tests where ARG uncilling crashes due to path sensitivity
sim642 Jul 11, 2025
063faa6
Hack ARG uncilling to remember and follow paths to avoid move_opt
sim642 Jul 11, 2025
67e4cef
Fix ARG uncilling hack duplicating edges
sim642 Jul 11, 2025
8883b72
Merge remote-tracking branch 'origin/arg-uncil-ambiguous' into violat…
karoliineh Jul 15, 2025
6333f93
Consider all possible paths in `next_opt`
karoliineh Sep 11, 2025
0604c03
Update configuration to the one used for server runs
karoliineh Oct 16, 2025
55acbb0
Merge branch 'master' into violation_witnesses
karoliineh Oct 16, 2025
98ecdf3
Merge branch 'master' into violation_witnesses
karoliineh Nov 27, 2025
9677dd4
Adapt Witch command to new witness-producing Witch
karoliineh Nov 4, 2025
86d696f
Use the cilled path prefix of the corresponding uncilling to determin…
karoliineh Nov 7, 2025
f037fa2
Refactor
karoliineh Nov 7, 2025
6ce9257
Remove branching waypoints with invalid locations using Witch
karoliineh Nov 8, 2025
cc6af51
Do not run Witch twice if result is already found during the location…
karoliineh Nov 10, 2025
afe27f5
Refactor
karoliineh Nov 10, 2025
78eaa50
Optimize
karoliineh Nov 10, 2025
275d60b
Fix indentation in `violation.ml`
karoliineh Nov 27, 2025
852f546
Address semgrep warnings
karoliineh Nov 27, 2025
19eb0bd
Rename violation.t -> violation-validation.t
karoliineh Nov 28, 2025
bb3d696
Add a cram test for violation witness generation
karoliineh Nov 28, 2025
01fd90c
Fix ambiguous ARG uncilling crash by remembering and following CFG paths
sim642 Jul 11, 2025
566813f
Comment ARG uncilling by following CFG paths
sim642 Nov 28, 2025
0cac26d
Merge branch 'master' into arg-uncil-ambiguous
sim642 Nov 28, 2025
b68f4e5
Remove now-unused ARG Node move_opt
sim642 Nov 28, 2025
60078ab
Remove unused ARG Node equal_node_context
sim642 Nov 28, 2025
ca40482
Change path printing log level to debug
karoliineh Nov 28, 2025
c2bbd89
Remove unused to_n argument in MyArg.Intra.follow
sim642 Nov 28, 2025
fdf1779
Add assert about to_n to MyARG.Intra.next
sim642 Nov 28, 2025
32c0acd
Remove ARG equivalent CFG chain detection
sim642 Nov 28, 2025
f85449f
Extract type MyARG.cfg_path
sim642 Nov 28, 2025
0f8b387
Disable violation cram tests on OSX
karoliineh Dec 1, 2025
4640382
Disable violation cram tests on OSX
karoliineh Dec 1, 2025
29d05cf
Add tests where MyARG.partition_if_next choosing arbitrary single pat…
sim642 Dec 1, 2025
1180f83
Return all possible paths MyARG.partition_if_next
karoliineh Sep 11, 2025
b8b6041
Simplify MyARG.partition_if_next by keeping triples paths with same e…
sim642 Dec 1, 2025
6d6c124
Revert to old partition_if_next but with path lists
sim642 Dec 1, 2025
0db8fea
Replace violation cram test
karoliineh Dec 1, 2025
bef86e2
Refactor old partition_if_next to check for more errors
sim642 Dec 1, 2025
eae4fb2
Remove Karoliine's partition_if_next
sim642 Dec 1, 2025
c630eae
Use List.concat_map in MyARG.cartesian_concat_paths
sim642 Dec 1, 2025
708edac
Fix MyARG.UnCilTernaryIntra returning duplicate edge and node
sim642 Dec 2, 2025
cc3768d
Merge branch 'arg-uncil-ambiguous' into violation_witnesses
sim642 Dec 2, 2025
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: 1 addition & 1 deletion conf/svcomp25.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,4 @@
"pre": {
"enabled": false
}
}
}
12 changes: 9 additions & 3 deletions src/arg/argTools.ml
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,17 @@ struct
let next = witness_next
end
in
let module Arg =
(val if GobConfig.get_bool "exp.arg.uncil" then
let open MyARG in
(module Intra (UnCilTernaryIntra (UnCilLogicIntra (CfgIntra (FileCfg.Cfg)))) (Arg): MyARG.S with type Node.t = Arg.Node.t and type Edge.t = Arg.Edge.t)
else
(module Arg)
)
in
let module Arg =
struct
open MyARG
module ArgIntra = UnCilTernaryIntra (UnCilLogicIntra (CfgIntra (FileCfg.Cfg)))
include Intra (ArgIntra) (Arg)
include Arg

let prev = witness_prev

Expand Down
145 changes: 105 additions & 40 deletions src/arg/myARG.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@

module type Edge =
sig
type t
type t [@@deriving eq, ord]

val embed: MyCFG.edge -> t
val to_string: t -> string
end

module CFGEdge: Edge with type t = MyCFG.edge =
struct
type t = edge
type t = Edge.t [@@deriving eq, ord]

let embed e = e
let to_string e = GobPretty.sprint Edge.pretty_plain e
Expand Down Expand Up @@ -102,7 +102,7 @@

module InlineEdge: Edge with type t = inline_edge =
struct
type t = inline_edge
type t = inline_edge [@@deriving eq, ord]

let embed e = CFGEdge e
let to_string e = InlineEdgePrintable.show e
Expand Down Expand Up @@ -268,13 +268,13 @@

module type SIntra =
sig
val next: MyCFG.node -> (MyCFG.edge * MyCFG.node) list
val next: MyCFG.node -> (MyCFG.edge * MyCFG.node * (MyCFG.edge * MyCFG.node) list) list
end

module type SIntraOpt =
sig
include SIntra
val next_opt: MyCFG.node -> ((MyCFG.edge * MyCFG.node) list) option
val next_opt: MyCFG.node -> ((MyCFG.edge * MyCFG.node * (MyCFG.edge * MyCFG.node) list) list) option
end

module CfgIntra (Cfg:CfgForward): SIntraOpt =
Expand All @@ -283,29 +283,54 @@
let open GobList.Syntax in
let* (es, to_n) = Cfg.next node in
let+ (_, e) = es in
(e, to_n)
(e, to_n, [(e, to_n)])
let next_opt _ = None
end

let partition_if_next if_next_n =
type path = (edge * node) list
let cartesian_concat_paths (ps : path list) (qs : path list) : path list = List.concat (List.map (fun p -> List.map (fun q -> p @ q) qs) ps)
let mk_edges (e : edge) (n : node) (paths : path list) : (edge * node * path) list = List.map (fun p -> (e, n, p)) paths
let combine_and_make (e : edge) (n : node) (lhs : path list) (rhs : path list) : (edge * node * path) list = mk_edges e n (cartesian_concat_paths lhs rhs)

let partition_if_next (if_next_n : (edge * node * (edge * node) list) list): exp * (node * path list) * (node * path list) =
(* TODO: refactor, check extra edges for error *)
let test_next b = List.find (function
| (Test (_, b'), _) when b = b' -> true
| (_, _) -> false
) if_next_n
let exp =
match if_next_n with
| [] -> failwith "partition_if_next: empty"
| (Test (exp, _), _, _) :: xs ->
let all_tests_same_cond =
List.for_all
(function
| (Test (exp', _), _, _) -> Basetype.CilExp.equal exp exp'
| _ -> false)
xs
in
if all_tests_same_cond then exp
else failwith "partition_if_next: bad branches"
| _ -> failwith "partition_if_next: not Test edge"
in
let collapse_branch b =
let paths_for_b = List.filter (function
| (Test (_, b'), _, _) when b = b' -> true
| _ -> false)
if_next_n
in
match paths_for_b with
| [] -> failwith (if b then "partition_if_next: missing true-branch" else "partition_if_next: missing false-branch")
| (e, n, p) :: rest ->
let all_same_en = List.for_all (fun (e', n', _) -> Edge.equal e e' && Node.equal n n') paths_for_b in
if not all_same_en then failwith "partition_if_next: branch has differing (edge,node) pairs";
let paths = List.map (fun (_,_,p) -> p) paths_for_b in
(n, paths)
in
(* assert (List.length if_next <= 2); *)
match test_next true, test_next false with
| (Test (e_true, true), if_true_next_n), (Test (e_false, false), if_false_next_n) when Basetype.CilExp.equal e_true e_false ->
(e_true, if_true_next_n, if_false_next_n)
| _, _ -> failwith "partition_if_next: bad branches"
(exp, collapse_branch true, collapse_branch false)

module UnCilLogicIntra (Arg: SIntraOpt): SIntraOpt =
struct
open Cil
(* TODO: questionable (=) and (==) use here *)

let is_equiv_stmtkind sk1 sk2 = match sk1, sk2 with
(* let is_equiv_stmtkind sk1 sk2 = match sk1, sk2 with
| Instr is1, Instr is2 -> GobList.equal (=) is1 is2
| Return _, Return _ -> sk1 = sk2
| _, _ -> false (* TODO: also consider others? not sure if they ever get duplicated *)
Expand All @@ -323,11 +348,14 @@
| [(e1, to_n1)], [(e2, to_n2)] ->
is_equiv_edge e1 e2 && is_equiv_chain to_n1 to_n2
| _, _-> false
*)

let rec is_equiv_chain n1 n2 =
Node.equal n1 n2

let rec next_opt' n = match n with
| Statement {sid; skind=If _; _} when GobConfig.get_bool "exp.arg.uncil" ->
let (e, if_true_next_n, if_false_next_n) = partition_if_next (Arg.next n) in
| Statement {sid; skind=If _; _} ->
let (e, (if_true_next_n, if_true_next_p), (if_false_next_n, if_false_next_p)) = partition_if_next (Arg.next n) in
(* avoid infinite recursion with sid <> sid2 in if_nondet_var *)
(* TODO: why physical comparison if_false_next_n != n doesn't work? *)
(* TODO: need to handle longer loops? *)
Expand All @@ -336,25 +364,25 @@
(* && *)
| Statement {sid=sid2; skind=If _; _}, _ when sid <> sid2 && CilType.Location.equal loc (Node.location if_true_next_n) ->
(* get e2 from edge because recursive next returns it there *)
let (e2, if_true_next_true_next_n, if_true_next_false_next_n) = partition_if_next (next if_true_next_n) in
let (e2, (if_true_next_true_next_n, if_true_next_true_next_p), (if_true_next_false_next_n, if_true_next_false_next_p)) = partition_if_next (next if_true_next_n) in
if is_equiv_chain if_false_next_n if_true_next_false_next_n then
let exp = BinOp (LAnd, e, e2, intType) in
Some [
(Test (exp, true), if_true_next_true_next_n);
(Test (exp, false), if_false_next_n)
]
let true_items = combine_and_make (Test (exp, true)) if_true_next_true_next_n if_true_next_p if_true_next_true_next_p in
let false_from_true_items = combine_and_make (Test (exp, false)) if_true_next_false_next_n if_true_next_p if_true_next_false_next_p in
let false_from_false_items = mk_edges (Test (exp, false)) if_false_next_n if_false_next_p in
Some (true_items @ false_from_true_items @ false_from_false_items)
else
None
(* || *)
| _, Statement {sid=sid2; skind=If _; _} when sid <> sid2 && CilType.Location.equal loc (Node.location if_false_next_n) ->
(* get e2 from edge because recursive next returns it there *)
let (e2, if_false_next_true_next_n, if_false_next_false_next_n) = partition_if_next (next if_false_next_n) in
let (e2, (if_false_next_true_next_n, if_false_next_true_next_p), (if_false_next_false_next_n, if_false_next_false_next_p)) = partition_if_next (next if_false_next_n) in
if is_equiv_chain if_true_next_n if_false_next_true_next_n then
let exp = BinOp (LOr, e, e2, intType) in
Some [
(Test (exp, true), if_true_next_n);
(Test (exp, false), if_false_next_false_next_n)
]
let true_from_true_items = mk_edges (Test (exp, true)) if_true_next_n if_true_next_p in
let true_from_false_items = combine_and_make (Test (exp, true)) if_false_next_true_next_n if_false_next_p if_false_next_true_next_p in
let false_from_false_items = combine_and_make (Test (exp, false)) if_false_next_false_next_n if_false_next_p if_false_next_false_next_p in
Some (true_from_true_items @ true_from_false_items @ false_from_false_items)
else
None
| _, _ -> None
Expand All @@ -380,16 +408,16 @@
Question(e_cond, e_true, e_false, Cilfacade.typeOf e_false)

let next_opt' n = match n with
| Statement {skind=If _; _} when GobConfig.get_bool "exp.arg.uncil" ->
let (e_cond, if_true_next_n, if_false_next_n) = partition_if_next (Arg.next n) in
| Statement {skind=If _; _} ->
let (e_cond, (if_true_next_n, if_true_next_p), (if_false_next_n, if_false_next_p)) = partition_if_next (Arg.next n) in
let loc = Node.location n in
if CilType.Location.equal (Node.location if_true_next_n) loc && CilType.Location.equal (Node.location if_false_next_n) loc then
match Arg.next if_true_next_n, Arg.next if_false_next_n with
| [(Assign (v_true, e_true), if_true_next_next_n)], [(Assign (v_false, e_false), if_false_next_next_n)] when v_true = v_false && Node.equal if_true_next_next_n if_false_next_next_n ->
| [(Assign (v_true, e_true), if_true_next_next_n, if_true_next_next_p)], [(Assign (v_false, e_false), if_false_next_next_n, if_false_next_next_p)] when v_true = v_false && Node.equal if_true_next_next_n if_false_next_next_n ->
let exp = ternary e_cond e_true e_false in
Some [
(Assign (v_true, exp), if_true_next_next_n)
]
let assigns_true = combine_and_make (Assign (v_true, exp)) if_true_next_next_n if_true_next_p [if_true_next_next_p] in
let assigns_false = combine_and_make (Assign (v_false, exp)) if_false_next_next_n if_false_next_p [if_false_next_next_p] in
Some (assigns_true @ assigns_false)
| _, _ -> None
else
None
Expand All @@ -402,19 +430,56 @@
| None -> Arg.next n
end

module Intra (ArgIntra: SIntraOpt) (Arg: S):
S with module Node = Arg.Node and module Edge = Arg.Edge =
module Intra (ArgIntra: SIntraOpt) (Arg: S) =
struct
include Arg

(* let rec follow node to_n p = Node.move_opt node to_n *)
let rec follow node to_n p =
let open GobList.Syntax in
match p with
| [] -> [node]
| (e, to_n) :: p' ->
let* (_, node') = List.filter (fun (e', to_node) ->
Edge.equal (Edge.embed e) e' && Node0.equal to_n (Node.cfgnode to_node)
) (Arg.next node)
in
follow node' to_n p'

let rec follow' (node : Node.t) to_n p : (Node.t * (Edge.t * Node.t) list) list =
let open GobList.Syntax in
match p with
| [] -> [node, []]
| (e, to_n) :: p' ->
let* (_, node') = List.filter (fun (e', to_node) ->
Edge.equal (Edge.embed e) e' && Node0.equal to_n (Node.cfgnode to_node)
) (Arg.next node)
in
let+ (n, l) = follow' node' to_n p' in
(n, (Edge.embed e, node') :: l)

let next node =
let open GobOption.Syntax in
let open GobList.Syntax in
match ArgIntra.next_opt (Node.cfgnode node) with
| None -> Arg.next node
| Some next ->
next
|> BatList.filter_map (fun (e, to_n) ->
let+ to_node = Node.move_opt node to_n in
|> BatList.concat_map (fun (e, to_n, p) ->
let+ to_node = follow node to_n p in
(Edge.embed e, to_node)
)
|> BatList.unique_cmp ~cmp:[%ord: Edge.t * Node.t] (* TODO: avoid generating duplicates in the first place? *)

let next' node =
let open GobList.Syntax in
match ArgIntra.next_opt (Node.cfgnode node) with
| None ->
Arg.next node
|> List.map (fun (e,n) -> (e,n, [e, n]))
| Some next ->
next
|> BatList.concat_map (fun (e, to_n, p) ->
let+ (to_node, path) = follow' node to_n p in
(Edge.embed e, to_node, path)
)
end
Loading
Loading