Skip to content

Instantly share code, notes, and snippets.

View aterga's full-sized avatar
🎯
Focusing

Arshavir Ter-Gabrielyan aterga

🎯
Focusing
View GitHub Profile
@aterga
aterga / run_docker.sh
Created March 17, 2020 00:43
How to run Docker image and attach to it
docker build -t IMAGE_NAME
docker run -it -d --name INSTANCE_NAME IMAGE_NAME
docker exec -it INSTANCE_NAME /bin/bash
@aterga
aterga / z3-core.sh
Created March 13, 2020 19:28
Outputs comma-separated pairs of the form: "file.smt2, (A0, A1, ..., AN)" where As are the names of SMT assertions (set via the :named annotations).
#!/bin/bash
printf "$1,"
RESPONSE=$((
(echo "(set-option :produce-unsat-cores true)");
(echo "(set-option :smt.core.minimize true)");
(cat $1);
(echo "(get-unsat-core)")
) | z3 -smt2 -in)
if echo $RESPONSE | grep -q unknown;
@aterga
aterga / vamp_throttle.sh
Last active March 13, 2020 14:27
Run Vampire in fixed number of threads for all files in all directories
for dir in *;
do
for file in $dir/*;
do
$(vampire
--mode casc
--input_syntax smtlib2
--time_limit 18000s
--memory_limit 2000000
--random_seed 0
@aterga
aterga / full_throttle_dummy_miner.sh
Last active June 2, 2020 12:22
Split a large set of SMT files into even group and process the groups in parallel
N_FILES_IN_GROUP=333
TIMEOUT_PER_RUN_SEC=2000
i=0; for f in *.smt2; do d=group_$(printf %03d $((i/$N_FILES_IN_GROUP+1))); mkdir -p $d; mv "$f" $d; let i++; done
for dir in *; do python ~/axiom-testing-project/axioms/src/minimizer/main.py --is_debug=false --timeout $TIMEOUT_PER_RUN_SEC --location $dir mine_dummies & echo $! >> active_pids.txt; done; wait; echo ">>> Processed all groups. <<<"; rm -f active_pids.txt
# You can use "kill -9 $(cat active_pids.txt)" to terminate all Python sub-processes started by the command above.
@aterga
aterga / vpr_2_smt.sh
Created February 25, 2020 14:26
Generate SMT files for all Viper files using Carbon
for file in *.vpr; do java -Xmx2048m -Xss16m -cp :/usr/local/Viper/backends/*.jar viper.carbon.Carbon --z3Exe "/usr/local/Viper/z3/bin/z3" --boogieExe "/usr/local/Viper/boogie/Binaries/Boogie.exe" --proverLog "$file.smt2" $file ; done
@aterga
aterga / move.sh
Created February 24, 2020 16:00
Move files that match pattern while preserving origin directory information
#!/bin/bash
####################################################################################
## Move files that match pattern while preserving origin directory information.
## Run as follows:
##
## find non-incremental/ -type f -name "*.smt2" -exec ./move.sh "forall" {} \;
##
####################################################################################
@aterga
aterga / gist:473b050b73f93cf38240c3356bcf45a9
Created September 14, 2019 07:10
VMI Summer Retreat 2019 Master Class on Code Verification
field f: Ref
define CLOSED(nodes)
(forall n:Ref :: { n in nodes, n.f } n in nodes && n.f != null ==> n.f in nodes)
define STRUCT(nodes)
(forall n:Ref :: { n.f } n in nodes ==> acc(n.f)) &&
!(null in nodes) &&
CLOSED(nodes)
@aterga
aterga / leg.sil
Created April 6, 2016 17:50
LSeg
field next: Ref
field value: Int
predicate lseg(this: Ref, end: Ref) {
acc(this.value, write) && acc(this.next, write) &&
(this.next != end ==> this.next != null && acc(lseg(this.next, end), write))
}
function get(this: Ref, i: Int, end: Ref): Int
requires acc(lseg(this, end), write)
@aterga
aterga / sv_boogie.bpl
Last active November 21, 2015 00:28
Verifying QuickSort in Boogie
const N: int;
axiom 1 < N;
var a: [int]int;
var perm: [int]int;
procedure __new_perm__() returns (perm: [int]int)
ensures perm_ok(perm);
ensures (forall k: int :: 0 <= k && k < N ==> perm[k] == k);
{
var n: int; n := 0;
// class Node
field left: Ref
field right: Ref
field is_marked: Bool
predicate inv(node: Ref, graph: Set[Ref]) {
node != null
&& acc(node.left)
&& acc(node.right)
&& acc(node.is_marked)