cielseven commited on
Commit
8d657f0
·
1 Parent(s): 3805fe5

add gcd, exgcd and seven linked-list cases

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. README.md +7 -7
  2. benchmarks/Algorithms/exgcd/manifest.json +19 -0
  3. benchmarks/Algorithms/exgcd/problem.md +13 -0
  4. benchmarks/Algorithms/exgcd/rocq/groundtruth/exgcd_goal.v +1035 -0
  5. benchmarks/Algorithms/exgcd/rocq/groundtruth/exgcd_goal_check.v +6 -0
  6. benchmarks/Algorithms/exgcd/rocq/groundtruth/exgcd_proof_auto.v +96 -0
  7. benchmarks/Algorithms/exgcd/rocq/groundtruth/exgcd_proof_manual.v +394 -0
  8. benchmarks/Algorithms/exgcd/rocq/groundtruth/proof_lib.v +181 -0
  9. benchmarks/Algorithms/exgcd/rocq/solution_annotated.c +55 -0
  10. benchmarks/Algorithms/exgcd/rocq/solution_spec.c +33 -0
  11. benchmarks/Algorithms/exgcd/solution.c +25 -0
  12. benchmarks/Algorithms/gcd/manifest.json +19 -0
  13. benchmarks/Algorithms/gcd/problem.md +13 -0
  14. benchmarks/Algorithms/gcd/rocq/groundtruth/gcd_goal.v +241 -0
  15. benchmarks/Algorithms/gcd/rocq/groundtruth/gcd_goal_check.v +6 -0
  16. benchmarks/Algorithms/gcd/rocq/groundtruth/gcd_proof_auto.v +45 -0
  17. benchmarks/Algorithms/gcd/rocq/groundtruth/gcd_proof_manual.v +95 -0
  18. benchmarks/Algorithms/gcd/rocq/groundtruth/proof_lib.v +2 -0
  19. benchmarks/Algorithms/gcd/rocq/solution_annotated.c +32 -0
  20. benchmarks/Algorithms/gcd/rocq/solution_spec.c +25 -0
  21. benchmarks/Algorithms/gcd/solution.c +18 -0
  22. benchmarks/Algorithms/sll_insertion_sort/manifest.json +19 -0
  23. benchmarks/Algorithms/sll_insertion_sort/problem.md +22 -0
  24. benchmarks/Algorithms/sll_insertion_sort/rocq/groundtruth/proof_lib.v +105 -0
  25. benchmarks/Algorithms/sll_insertion_sort/rocq/groundtruth/sll_insertion_sort_goal.v +506 -0
  26. benchmarks/Algorithms/sll_insertion_sort/rocq/groundtruth/sll_insertion_sort_goal_check.v +7 -0
  27. benchmarks/Algorithms/sll_insertion_sort/rocq/groundtruth/sll_insertion_sort_proof_auto.v +47 -0
  28. benchmarks/Algorithms/sll_insertion_sort/rocq/groundtruth/sll_insertion_sort_proof_manual.v +252 -0
  29. benchmarks/Algorithms/sll_insertion_sort/rocq/helper_lib.v +23 -0
  30. benchmarks/Algorithms/sll_insertion_sort/rocq/solution_annotated.c +116 -0
  31. benchmarks/Algorithms/sll_insertion_sort/rocq/solution_spec.c +39 -0
  32. benchmarks/Algorithms/sll_insertion_sort/solution.c +28 -0
  33. benchmarks/Algorithms/sll_merge_sort/manifest.json +19 -0
  34. benchmarks/Algorithms/sll_merge_sort/problem.md +22 -0
  35. benchmarks/Algorithms/sll_merge_sort/rocq/groundtruth/proof_lib.v +302 -0
  36. benchmarks/Algorithms/sll_merge_sort/rocq/groundtruth/sll_merge_sort_goal.v +900 -0
  37. benchmarks/Algorithms/sll_merge_sort/rocq/groundtruth/sll_merge_sort_goal_check.v +8 -0
  38. benchmarks/Algorithms/sll_merge_sort/rocq/groundtruth/sll_merge_sort_proof_auto.v +96 -0
  39. benchmarks/Algorithms/sll_merge_sort/rocq/groundtruth/sll_merge_sort_proof_manual.v +421 -0
  40. benchmarks/Algorithms/sll_merge_sort/rocq/helper_lib.v +95 -0
  41. benchmarks/Algorithms/sll_merge_sort/rocq/solution_annotated.c +205 -0
  42. benchmarks/Algorithms/sll_merge_sort/rocq/solution_spec.c +66 -0
  43. benchmarks/Algorithms/sll_merge_sort/rocq/spec_lib.v +18 -0
  44. benchmarks/Algorithms/sll_merge_sort/solution.c +54 -0
  45. benchmarks/Data_structures/dll_queue/manifest.json +19 -0
  46. benchmarks/Data_structures/dll_queue/problem.md +15 -0
  47. benchmarks/Data_structures/dll_queue/rocq/dll_queue_store.strategies +24 -0
  48. benchmarks/Data_structures/dll_queue/rocq/dll_queue_store_def.h +16 -0
  49. benchmarks/Data_structures/dll_queue/rocq/groundtruth/dll_queue_goal.v +453 -0
  50. benchmarks/Data_structures/dll_queue/rocq/groundtruth/dll_queue_goal_check.v +7 -0
README.md CHANGED
@@ -22,22 +22,22 @@ size_categories:
22
 
23
  A benchmark for measuring how well LLMs do **program verification** — not code generation — on real, human-authored problems.
24
 
25
- It has 233 problems. Each one comes with a correct C solution that has been given a formal
26
  spec and checked by [**QCP**](https://www.qua.codes/en/index.html). The proofs are done in one
27
- of two backends, **Rocq** or **Lean 4**. All 233 have a Rocq version; 83 also have a Lean one.
28
 
29
  The problems are in four groups, all under `benchmarks/`, next to the build files:
30
 
31
  | group | problems | C lines | source |
32
  |---|---:|---:|---|
33
  | `benchmarks/Codeforces/` | 147 | 6,899 | competitive-programming problems, grouped into `examples_shard<NN>/` slices |
34
- | `benchmarks/Algorithms/` | 73 | 3,986 | classic algorithms, one directory per algorithm |
35
- | `benchmarks/Data_structures/` | 5 | 404 | array stack, BIT and three priority-queue interfaces |
36
  | `benchmarks/Engineering/` | 8 | 338 | MiniSat vectors and C string / memory routines |
37
- | total | 233 | 11,627 | |
38
 
39
  "C lines" counts the unannotated `solution.c` — the program a model is asked to specify and
40
- verify. They are small by design: a median of 40 lines, 50 on average, from 5 up to 189
41
  (`Algorithms/kosaraju`). The difficulty is in the property to be proved, not in the size of the
42
  code.
43
 
@@ -93,7 +93,7 @@ backend's assertion language.
93
  └── groundtruth/
94
  ```
95
 
96
- `rocq/` is present for all 233 problems; `lean/` for 83 of them — 45 Algorithms,
97
  34 Codeforces (14 in `examples_shard00`, 20 in `examples_shard01`), 3 Data_structures and
98
  1 Engineering. The `.lean` libraries mirror the corresponding `.v` files; cases without
99
  private definitions import shared libraries directly from the C annotations.
 
22
 
23
  A benchmark for measuring how well LLMs do **program verification** — not code generation — on real, human-authored problems.
24
 
25
+ It has 242 problems. Each one comes with a correct C solution that has been given a formal
26
  spec and checked by [**QCP**](https://www.qua.codes/en/index.html). The proofs are done in one
27
+ of two backends, **Rocq** or **Lean 4**. All 242 have a Rocq version; 83 also have a Lean one.
28
 
29
  The problems are in four groups, all under `benchmarks/`, next to the build files:
30
 
31
  | group | problems | C lines | source |
32
  |---|---:|---:|---|
33
  | `benchmarks/Codeforces/` | 147 | 6,899 | competitive-programming problems, grouped into `examples_shard<NN>/` slices |
34
+ | `benchmarks/Algorithms/` | 77 | 4,111 | classic algorithms, one directory per algorithm |
35
+ | `benchmarks/Data_structures/` | 10 | 618 | array stack, BIT, three priority-queue interfaces, linked lists and three linked queues |
36
  | `benchmarks/Engineering/` | 8 | 338 | MiniSat vectors and C string / memory routines |
37
+ | total | 242 | 11,966 | |
38
 
39
  "C lines" counts the unannotated `solution.c` — the program a model is asked to specify and
40
+ verify. They are small by design: a median of 40 lines, 49 on average, from 5 up to 189
41
  (`Algorithms/kosaraju`). The difficulty is in the property to be proved, not in the size of the
42
  code.
43
 
 
93
  └── groundtruth/
94
  ```
95
 
96
+ `rocq/` is present for all 242 problems; `lean/` for 83 of them — 45 Algorithms,
97
  34 Codeforces (14 in `examples_shard00`, 20 in `examples_shard01`), 3 Data_structures and
98
  1 Engineering. The `.lean` libraries mirror the corresponding `.v` files; cases without
99
  private definitions import shared libraries directly from the C annotations.
benchmarks/Algorithms/exgcd/manifest.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": "exgcd",
3
+ "source": {
4
+ "dataset": "classical_algorithm",
5
+ "problem_id": "exgcd",
6
+ "title": "Extended Euclidean Algorithm",
7
+ "tags": [
8
+ "gcd",
9
+ "bezout",
10
+ "recursion"
11
+ ]
12
+ },
13
+ "stratification": {
14
+ "band": "unclassified",
15
+ "output_mode": "CONSTRUCT",
16
+ "interactive": false,
17
+ "multi_test": false
18
+ }
19
+ }
benchmarks/Algorithms/exgcd/problem.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Extended Euclidean Algorithm
2
+
3
+ ## Description
4
+
5
+ Compute the greatest common divisor of two integers together with a pair of Bézout coefficients, using the recursive extended Euclidean algorithm.
6
+
7
+ ## Input
8
+
9
+ The function receives two integers $a$ and $b$ ($-2^{31} < a, b \le 2^{31} - 1$), and two pointers `x` and `y` to two distinct writable `int` cells.
10
+
11
+ ## Output
12
+
13
+ Return $g = \gcd(a, b)$ and store integers in `*x` and `*y` such that $a \cdot x + b \cdot y = g$.
benchmarks/Algorithms/exgcd/rocq/groundtruth/exgcd_goal.v ADDED
@@ -0,0 +1,1035 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Require Import Coq.ZArith.ZArith.
2
+ Require Import Coq.Bool.Bool.
3
+ Require Import Coq.Strings.String.
4
+ Require Import Coq.Strings.Ascii.
5
+ Require Import Coq.Lists.List.
6
+ Require Import Coq.Classes.RelationClasses.
7
+ Require Import Coq.Classes.Morphisms.
8
+ Require Import Coq.micromega.Psatz.
9
+ Require Import Coq.Sorting.Permutation.
10
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap.
11
+ Require Import SetsClass.SetsClass. Import SetsNotation.
12
+ From SimpleC.SL Require Import Mem SeparationLogic.
13
+ Require Import Logic.LogicGenerator.demo932.Interface.
14
+ Local Open Scope Z_scope.
15
+ Local Open Scope sets.
16
+ Local Open Scope string_scope.
17
+ Local Open Scope list.
18
+ Import naive_C_Rules.
19
+ Local Open Scope sac.
20
+
21
+ (*----- Function abs -----*)
22
+
23
+ Definition abs_safety_wit_1 :=
24
+ forall (x_pre: Z) (PreH1 : (INT_MIN < x_pre)) (PreH2 : (x_pre <= INT_MAX)) ,
25
+ ((( &( "x" ) )) # Int |-> x_pre)
26
+ |--
27
+ “ (0 <= INT_MAX) ”
28
+ && “ ((INT_MIN) <= 0) ”
29
+ .
30
+
31
+ Definition abs_safety_wit_2 :=
32
+ forall (x_pre: Z) (PreH1 : (x_pre < 0)) (PreH2 : (INT_MIN < x_pre)) (PreH3 : (x_pre <= INT_MAX)) ,
33
+ ((( &( "x" ) )) # Int |-> x_pre)
34
+ |--
35
+ “ (x_pre <> (INT_MIN)) ”
36
+ .
37
+
38
+ Definition abs_return_wit_1 :=
39
+ (
40
+ forall (x_pre: Z) (PreH1 : (x_pre >= 0)) (PreH2 : (INT_MIN < x_pre)) (PreH3 : (x_pre <= INT_MAX)) ,
41
+ TT && emp
42
+ |--
43
+ “ (x_pre = (Zabs (x_pre))) ”
44
+ && emp
45
+ ) \/
46
+ (
47
+ forall (x_pre: Z) (PreH1 : (x_pre >= 0)) (PreH2 : (INT_MIN < x_pre)) (PreH3 : (x_pre <= INT_MAX)) ,
48
+ TT && emp
49
+ |--
50
+ “ (x_pre = (Zabs (x_pre))) ”
51
+ && emp
52
+ ).
53
+
54
+ Definition abs_return_wit_1_split_goal_1 :=
55
+ forall (x_pre: Z) (PreH1 : (x_pre >= 0)) (PreH2 : (INT_MIN < x_pre)) (PreH3 : (x_pre <= INT_MAX)) ,
56
+ (x_pre = (Zabs (x_pre)))
57
+ .
58
+
59
+ Definition abs_return_wit_2 :=
60
+ (
61
+ forall (x_pre: Z) (PreH1 : (x_pre < 0)) (PreH2 : (INT_MIN < x_pre)) (PreH3 : (x_pre <= INT_MAX)) ,
62
+ TT && emp
63
+ |--
64
+ “ ((-x_pre) = (Zabs (x_pre))) ”
65
+ && emp
66
+ ) \/
67
+ (
68
+ forall (x_pre: Z) (PreH1 : (x_pre < 0)) (PreH2 : (INT_MIN < x_pre)) (PreH3 : (x_pre <= INT_MAX)) ,
69
+ TT && emp
70
+ |--
71
+ “ ((-x_pre) = (Zabs (x_pre))) ”
72
+ && emp
73
+ ).
74
+
75
+ Definition abs_return_wit_2_split_goal_1 :=
76
+ forall (x_pre: Z) (PreH1 : (x_pre < 0)) (PreH2 : (INT_MIN < x_pre)) (PreH3 : (x_pre <= INT_MAX)) ,
77
+ ((-x_pre) = (Zabs (x_pre)))
78
+ .
79
+
80
+ (*----- Function exgcd -----*)
81
+
82
+ Definition exgcd_safety_wit_1 :=
83
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (INT_MIN < a_pre)) (PreH2 : (a_pre <= INT_MAX)) (PreH3 : (INT_MIN < b_pre)) (PreH4 : (b_pre <= INT_MAX)) ,
84
+ ((( &( "a" ) )) # Int |-> a_pre)
85
+ ** ((( &( "b" ) )) # Int |-> b_pre)
86
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
87
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
88
+ ** ((x_pre) # Int |->_)
89
+ ** ((y_pre) # Int |->_)
90
+ |--
91
+ “ (0 <= INT_MAX) ”
92
+ && “ ((INT_MIN) <= 0) ”
93
+ .
94
+
95
+ Definition exgcd_safety_wit_2 :=
96
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (b_pre = 0)) (PreH2 : (INT_MIN < a_pre)) (PreH3 : (a_pre <= INT_MAX)) (PreH4 : (INT_MIN < b_pre)) (PreH5 : (b_pre <= INT_MAX)) ,
97
+ ((( &( "a" ) )) # Int |-> a_pre)
98
+ ** ((( &( "b" ) )) # Int |-> b_pre)
99
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
100
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
101
+ ** ((x_pre) # Int |->_)
102
+ ** ((y_pre) # Int |->_)
103
+ |--
104
+ “ (0 <= INT_MAX) ”
105
+ && “ ((INT_MIN) <= 0) ”
106
+ .
107
+
108
+ Definition exgcd_safety_wit_3 :=
109
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (a_pre < 0)) (PreH2 : (b_pre = 0)) (PreH3 : (INT_MIN < a_pre)) (PreH4 : (a_pre <= INT_MAX)) (PreH5 : (INT_MIN < b_pre)) (PreH6 : (b_pre <= INT_MAX)) ,
110
+ ((( &( "a" ) )) # Int |-> a_pre)
111
+ ** ((( &( "b" ) )) # Int |-> b_pre)
112
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
113
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
114
+ ** ((x_pre) # Int |->_)
115
+ ** ((y_pre) # Int |->_)
116
+ |--
117
+ “ (1 <> (INT_MIN)) ”
118
+ .
119
+
120
+ Definition exgcd_safety_wit_4 :=
121
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (a_pre < 0)) (PreH2 : (b_pre = 0)) (PreH3 : (INT_MIN < a_pre)) (PreH4 : (a_pre <= INT_MAX)) (PreH5 : (INT_MIN < b_pre)) (PreH6 : (b_pre <= INT_MAX)) ,
122
+ ((( &( "a" ) )) # Int |-> a_pre)
123
+ ** ((( &( "b" ) )) # Int |-> b_pre)
124
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
125
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
126
+ ** ((x_pre) # Int |->_)
127
+ ** ((y_pre) # Int |->_)
128
+ |--
129
+ “ (1 <= INT_MAX) ”
130
+ && “ ((INT_MIN) <= 1) ”
131
+ .
132
+
133
+ Definition exgcd_safety_wit_5 :=
134
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (a_pre >= 0)) (PreH2 : (b_pre = 0)) (PreH3 : (INT_MIN < a_pre)) (PreH4 : (a_pre <= INT_MAX)) (PreH5 : (INT_MIN < b_pre)) (PreH6 : (b_pre <= INT_MAX)) ,
135
+ ((( &( "a" ) )) # Int |-> a_pre)
136
+ ** ((( &( "b" ) )) # Int |-> b_pre)
137
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
138
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
139
+ ** ((x_pre) # Int |->_)
140
+ ** ((y_pre) # Int |->_)
141
+ |--
142
+ “ (0 <= INT_MAX) ”
143
+ && “ ((INT_MIN) <= 0) ”
144
+ .
145
+
146
+ Definition exgcd_safety_wit_6 :=
147
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (a_pre = 0)) (PreH2 : (a_pre >= 0)) (PreH3 : (b_pre = 0)) (PreH4 : (INT_MIN < a_pre)) (PreH5 : (a_pre <= INT_MAX)) (PreH6 : (INT_MIN < b_pre)) (PreH7 : (b_pre <= INT_MAX)) ,
148
+ ((( &( "a" ) )) # Int |-> a_pre)
149
+ ** ((( &( "b" ) )) # Int |-> b_pre)
150
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
151
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
152
+ ** ((x_pre) # Int |->_)
153
+ ** ((y_pre) # Int |->_)
154
+ |--
155
+ “ (0 <= INT_MAX) ”
156
+ && “ ((INT_MIN) <= 0) ”
157
+ .
158
+
159
+ Definition exgcd_safety_wit_7 :=
160
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (a_pre <> 0)) (PreH2 : (a_pre >= 0)) (PreH3 : (b_pre = 0)) (PreH4 : (INT_MIN < a_pre)) (PreH5 : (a_pre <= INT_MAX)) (PreH6 : (INT_MIN < b_pre)) (PreH7 : (b_pre <= INT_MAX)) ,
161
+ ((( &( "a" ) )) # Int |-> a_pre)
162
+ ** ((( &( "b" ) )) # Int |-> b_pre)
163
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
164
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
165
+ ** ((x_pre) # Int |->_)
166
+ ** ((y_pre) # Int |->_)
167
+ |--
168
+ “ (1 <= INT_MAX) ”
169
+ && “ ((INT_MIN) <= 1) ”
170
+ .
171
+
172
+ Definition exgcd_safety_wit_8 :=
173
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (a_pre < 0)) (PreH2 : (b_pre = 0)) (PreH3 : (INT_MIN < a_pre)) (PreH4 : (a_pre <= INT_MAX)) (PreH5 : (INT_MIN < b_pre)) (PreH6 : (b_pre <= INT_MAX)) ,
174
+ ((( &( "a" ) )) # Int |-> a_pre)
175
+ ** ((( &( "b" ) )) # Int |-> b_pre)
176
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
177
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
178
+ ** ((x_pre) # Int |-> (-1))
179
+ ** ((y_pre) # Int |->_)
180
+ |--
181
+ “ (0 <= INT_MAX) ”
182
+ && “ ((INT_MIN) <= 0) ”
183
+ .
184
+
185
+ Definition exgcd_safety_wit_9 :=
186
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (a_pre = 0)) (PreH2 : (a_pre >= 0)) (PreH3 : (b_pre = 0)) (PreH4 : (INT_MIN < a_pre)) (PreH5 : (a_pre <= INT_MAX)) (PreH6 : (INT_MIN < b_pre)) (PreH7 : (b_pre <= INT_MAX)) ,
187
+ ((( &( "a" ) )) # Int |-> a_pre)
188
+ ** ((( &( "b" ) )) # Int |-> b_pre)
189
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
190
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
191
+ ** ((x_pre) # Int |-> 0)
192
+ ** ((y_pre) # Int |->_)
193
+ |--
194
+ “ (0 <= INT_MAX) ”
195
+ && “ ((INT_MIN) <= 0) ”
196
+ .
197
+
198
+ Definition exgcd_safety_wit_10 :=
199
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (a_pre <> 0)) (PreH2 : (a_pre >= 0)) (PreH3 : (b_pre = 0)) (PreH4 : (INT_MIN < a_pre)) (PreH5 : (a_pre <= INT_MAX)) (PreH6 : (INT_MIN < b_pre)) (PreH7 : (b_pre <= INT_MAX)) ,
200
+ ((( &( "a" ) )) # Int |-> a_pre)
201
+ ** ((( &( "b" ) )) # Int |-> b_pre)
202
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
203
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
204
+ ** ((x_pre) # Int |-> 1)
205
+ ** ((y_pre) # Int |->_)
206
+ |--
207
+ “ (0 <= INT_MAX) ”
208
+ && “ ((INT_MIN) <= 0) ”
209
+ .
210
+
211
+ Definition exgcd_safety_wit_11 :=
212
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (b_pre <> 0)) (PreH2 : (INT_MIN < a_pre)) (PreH3 : (a_pre <= INT_MAX)) (PreH4 : (INT_MIN < b_pre)) (PreH5 : (b_pre <= INT_MAX)) ,
213
+ ((( &( "g" ) )) # Int |->_)
214
+ ** ((( &( "a" ) )) # Int |-> a_pre)
215
+ ** ((( &( "b" ) )) # Int |-> b_pre)
216
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
217
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
218
+ ** ((x_pre) # Int |->_)
219
+ ** ((y_pre) # Int |->_)
220
+ |--
221
+ “ ((a_pre <> (INT_MIN)) \/ (b_pre <> (-1))) ”
222
+ && “ (b_pre <> 0) ”
223
+ .
224
+
225
+ Definition exgcd_safety_wit_12 :=
226
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) = 0)) (PreH4 : ((Zabs (x_callee_v)) <= 1)) (PreH5 : (y_callee_v = 0)) (PreH6 : (b_pre <> 0)) (PreH7 : (INT_MIN < a_pre)) (PreH8 : (a_pre <= INT_MAX)) (PreH9 : (INT_MIN < b_pre)) (PreH10 : (b_pre <= INT_MAX)) ,
227
+ ((y_pre) # Int |-> x_callee_v)
228
+ ** ((x_pre) # Int |-> y_callee_v)
229
+ ** ((( &( "g" ) )) # Int |-> retval)
230
+ ** ((( &( "a" ) )) # Int |-> a_pre)
231
+ ** ((( &( "b" ) )) # Int |-> b_pre)
232
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
233
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
234
+ |--
235
+ “ ((x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) ) <= INT_MAX) ”
236
+ && “ ((INT_MIN) <= (x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) )) ”
237
+ .
238
+
239
+ Definition exgcd_safety_wit_13 :=
240
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) = 0)) (PreH4 : ((Zabs (x_callee_v)) <= 1)) (PreH5 : (y_callee_v = 0)) (PreH6 : (b_pre <> 0)) (PreH7 : (INT_MIN < a_pre)) (PreH8 : (a_pre <= INT_MAX)) (PreH9 : (INT_MIN < b_pre)) (PreH10 : (b_pre <= INT_MAX)) ,
241
+ ((y_pre) # Int |-> x_callee_v)
242
+ ** ((x_pre) # Int |-> y_callee_v)
243
+ ** ((( &( "g" ) )) # Int |-> retval)
244
+ ** ((( &( "a" ) )) # Int |-> a_pre)
245
+ ** ((( &( "b" ) )) # Int |-> b_pre)
246
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
247
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
248
+ |--
249
+ “ (((a_pre ÷ b_pre ) * y_callee_v ) <= INT_MAX) ”
250
+ && “ ((INT_MIN) <= ((a_pre ÷ b_pre ) * y_callee_v )) ”
251
+ .
252
+
253
+ Definition exgcd_safety_wit_14 :=
254
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) = 0)) (PreH4 : ((Zabs (x_callee_v)) <= 1)) (PreH5 : (y_callee_v = 0)) (PreH6 : (b_pre <> 0)) (PreH7 : (INT_MIN < a_pre)) (PreH8 : (a_pre <= INT_MAX)) (PreH9 : (INT_MIN < b_pre)) (PreH10 : (b_pre <= INT_MAX)) ,
255
+ ((y_pre) # Int |-> x_callee_v)
256
+ ** ((x_pre) # Int |-> y_callee_v)
257
+ ** ((( &( "g" ) )) # Int |-> retval)
258
+ ** ((( &( "a" ) )) # Int |-> a_pre)
259
+ ** ((( &( "b" ) )) # Int |-> b_pre)
260
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
261
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
262
+ |--
263
+ “ ((a_pre <> (INT_MIN)) \/ (b_pre <> (-1))) ”
264
+ && “ (b_pre <> 0) ”
265
+ .
266
+
267
+ Definition exgcd_safety_wit_15 :=
268
+ (
269
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) = 0)) (PreH5 : (x_callee_v = 0)) (PreH6 : ((Zabs (y_callee_v)) <= 1)) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
270
+ ((y_pre) # Int |-> x_callee_v)
271
+ ** ((x_pre) # Int |-> y_callee_v)
272
+ ** ((( &( "g" ) )) # Int |-> retval)
273
+ ** ((( &( "a" ) )) # Int |-> a_pre)
274
+ ** ((( &( "b" ) )) # Int |-> b_pre)
275
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
276
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
277
+ |--
278
+ “ ((x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) ) <= INT_MAX) ”
279
+ && “ ((INT_MIN) <= (x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) )) ”
280
+ ) \/
281
+ (
282
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) = 0)) (PreH5 : (x_callee_v = 0)) (PreH6 : ((Zabs (y_callee_v)) <= 1)) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
283
+ ((y_pre) # Int |-> x_callee_v)
284
+ ** ((x_pre) # Int |-> y_callee_v)
285
+ ** ((( &( "g" ) )) # Int |-> retval)
286
+ ** ((( &( "a" ) )) # Int |-> a_pre)
287
+ ** ((( &( "b" ) )) # Int |-> b_pre)
288
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
289
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
290
+ |--
291
+ “ ((x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) ) <= INT_MAX) ”
292
+ && “ ((INT_MIN) <= (x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) )) ”
293
+ ).
294
+
295
+ Definition exgcd_safety_wit_15_split_goal_1 :=
296
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) = 0)) (PreH5 : (x_callee_v = 0)) (PreH6 : ((Zabs (y_callee_v)) <= 1)) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
297
+ ((y_pre) # Int |-> x_callee_v)
298
+ ** ((x_pre) # Int |-> y_callee_v)
299
+ ** ((( &( "g" ) )) # Int |-> retval)
300
+ ** ((( &( "a" ) )) # Int |-> a_pre)
301
+ ** ((( &( "b" ) )) # Int |-> b_pre)
302
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
303
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
304
+ |--
305
+ “ ((x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) ) <= INT_MAX) ”
306
+ .
307
+
308
+ Definition exgcd_safety_wit_15_split_goal_2 :=
309
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) = 0)) (PreH5 : (x_callee_v = 0)) (PreH6 : ((Zabs (y_callee_v)) <= 1)) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
310
+ ((y_pre) # Int |-> x_callee_v)
311
+ ** ((x_pre) # Int |-> y_callee_v)
312
+ ** ((( &( "g" ) )) # Int |-> retval)
313
+ ** ((( &( "a" ) )) # Int |-> a_pre)
314
+ ** ((( &( "b" ) )) # Int |-> b_pre)
315
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
316
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
317
+ |--
318
+ “ ((INT_MIN) <= (x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) )) ”
319
+ .
320
+
321
+ Definition exgcd_safety_wit_16 :=
322
+ (
323
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) = 0)) (PreH5 : (x_callee_v = 0)) (PreH6 : ((Zabs (y_callee_v)) <= 1)) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
324
+ ((y_pre) # Int |-> x_callee_v)
325
+ ** ((x_pre) # Int |-> y_callee_v)
326
+ ** ((( &( "g" ) )) # Int |-> retval)
327
+ ** ((( &( "a" ) )) # Int |-> a_pre)
328
+ ** ((( &( "b" ) )) # Int |-> b_pre)
329
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
330
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
331
+ |--
332
+ “ (((a_pre ÷ b_pre ) * y_callee_v ) <= INT_MAX) ”
333
+ && “ ((INT_MIN) <= ((a_pre ÷ b_pre ) * y_callee_v )) ”
334
+ ) \/
335
+ (
336
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) = 0)) (PreH5 : (x_callee_v = 0)) (PreH6 : ((Zabs (y_callee_v)) <= 1)) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
337
+ ((y_pre) # Int |-> x_callee_v)
338
+ ** ((x_pre) # Int |-> y_callee_v)
339
+ ** ((( &( "g" ) )) # Int |-> retval)
340
+ ** ((( &( "a" ) )) # Int |-> a_pre)
341
+ ** ((( &( "b" ) )) # Int |-> b_pre)
342
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
343
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
344
+ |--
345
+ “ (((a_pre ÷ b_pre ) * y_callee_v ) <= INT_MAX) ”
346
+ && “ ((INT_MIN) <= ((a_pre ÷ b_pre ) * y_callee_v )) ”
347
+ ).
348
+
349
+ Definition exgcd_safety_wit_16_split_goal_1 :=
350
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) = 0)) (PreH5 : (x_callee_v = 0)) (PreH6 : ((Zabs (y_callee_v)) <= 1)) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
351
+ ((y_pre) # Int |-> x_callee_v)
352
+ ** ((x_pre) # Int |-> y_callee_v)
353
+ ** ((( &( "g" ) )) # Int |-> retval)
354
+ ** ((( &( "a" ) )) # Int |-> a_pre)
355
+ ** ((( &( "b" ) )) # Int |-> b_pre)
356
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
357
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
358
+ |--
359
+ “ (((a_pre ÷ b_pre ) * y_callee_v ) <= INT_MAX) ”
360
+ .
361
+
362
+ Definition exgcd_safety_wit_16_split_goal_2 :=
363
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) = 0)) (PreH5 : (x_callee_v = 0)) (PreH6 : ((Zabs (y_callee_v)) <= 1)) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
364
+ ((y_pre) # Int |-> x_callee_v)
365
+ ** ((x_pre) # Int |-> y_callee_v)
366
+ ** ((( &( "g" ) )) # Int |-> retval)
367
+ ** ((( &( "a" ) )) # Int |-> a_pre)
368
+ ** ((( &( "b" ) )) # Int |-> b_pre)
369
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
370
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
371
+ |--
372
+ “ ((INT_MIN) <= ((a_pre ÷ b_pre ) * y_callee_v )) ”
373
+ .
374
+
375
+ Definition exgcd_safety_wit_17 :=
376
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) = 0)) (PreH5 : (x_callee_v = 0)) (PreH6 : ((Zabs (y_callee_v)) <= 1)) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
377
+ ((y_pre) # Int |-> x_callee_v)
378
+ ** ((x_pre) # Int |-> y_callee_v)
379
+ ** ((( &( "g" ) )) # Int |-> retval)
380
+ ** ((( &( "a" ) )) # Int |-> a_pre)
381
+ ** ((( &( "b" ) )) # Int |-> b_pre)
382
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
383
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
384
+ |--
385
+ “ ((a_pre <> (INT_MIN)) \/ (b_pre <> (-1))) ”
386
+ && “ (b_pre <> 0) ”
387
+ .
388
+
389
+ Definition exgcd_safety_wit_18 :=
390
+ (
391
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) <> 0)) (PreH5 : ((Zabs (x_callee_v)) <= ((Zabs ((a_pre % ( b_pre ) ))) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH6 : ((Zabs (y_callee_v)) <= ((Zabs (b_pre)) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
392
+ ((y_pre) # Int |-> x_callee_v)
393
+ ** ((x_pre) # Int |-> y_callee_v)
394
+ ** ((( &( "g" ) )) # Int |-> retval)
395
+ ** ((( &( "a" ) )) # Int |-> a_pre)
396
+ ** ((( &( "b" ) )) # Int |-> b_pre)
397
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
398
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
399
+ |--
400
+ “ ((x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) ) <= INT_MAX) ”
401
+ && “ ((INT_MIN) <= (x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) )) ”
402
+ ) \/
403
+ (
404
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) <> 0)) (PreH5 : ((Zabs (x_callee_v)) <= ((Zabs ((a_pre % ( b_pre ) ))) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH6 : ((Zabs (y_callee_v)) <= ((Zabs (b_pre)) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
405
+ ((y_pre) # Int |-> x_callee_v)
406
+ ** ((x_pre) # Int |-> y_callee_v)
407
+ ** ((( &( "g" ) )) # Int |-> retval)
408
+ ** ((( &( "a" ) )) # Int |-> a_pre)
409
+ ** ((( &( "b" ) )) # Int |-> b_pre)
410
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
411
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
412
+ |--
413
+ “ ((x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) ) <= INT_MAX) ”
414
+ && “ ((INT_MIN) <= (x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) )) ”
415
+ ).
416
+
417
+ Definition exgcd_safety_wit_18_split_goal_1 :=
418
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) <> 0)) (PreH5 : ((Zabs (x_callee_v)) <= ((Zabs ((a_pre % ( b_pre ) ))) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH6 : ((Zabs (y_callee_v)) <= ((Zabs (b_pre)) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
419
+ ((y_pre) # Int |-> x_callee_v)
420
+ ** ((x_pre) # Int |-> y_callee_v)
421
+ ** ((( &( "g" ) )) # Int |-> retval)
422
+ ** ((( &( "a" ) )) # Int |-> a_pre)
423
+ ** ((( &( "b" ) )) # Int |-> b_pre)
424
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
425
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
426
+ |--
427
+ “ ((x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) ) <= INT_MAX) ”
428
+ .
429
+
430
+ Definition exgcd_safety_wit_18_split_goal_2 :=
431
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) <> 0)) (PreH5 : ((Zabs (x_callee_v)) <= ((Zabs ((a_pre % ( b_pre ) ))) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH6 : ((Zabs (y_callee_v)) <= ((Zabs (b_pre)) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
432
+ ((y_pre) # Int |-> x_callee_v)
433
+ ** ((x_pre) # Int |-> y_callee_v)
434
+ ** ((( &( "g" ) )) # Int |-> retval)
435
+ ** ((( &( "a" ) )) # Int |-> a_pre)
436
+ ** ((( &( "b" ) )) # Int |-> b_pre)
437
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
438
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
439
+ |--
440
+ “ ((INT_MIN) <= (x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) )) ”
441
+ .
442
+
443
+ Definition exgcd_safety_wit_19 :=
444
+ (
445
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) <> 0)) (PreH5 : ((Zabs (x_callee_v)) <= ((Zabs ((a_pre % ( b_pre ) ))) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH6 : ((Zabs (y_callee_v)) <= ((Zabs (b_pre)) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
446
+ ((y_pre) # Int |-> x_callee_v)
447
+ ** ((x_pre) # Int |-> y_callee_v)
448
+ ** ((( &( "g" ) )) # Int |-> retval)
449
+ ** ((( &( "a" ) )) # Int |-> a_pre)
450
+ ** ((( &( "b" ) )) # Int |-> b_pre)
451
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
452
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
453
+ |--
454
+ “ (((a_pre ÷ b_pre ) * y_callee_v ) <= INT_MAX) ”
455
+ && “ ((INT_MIN) <= ((a_pre ÷ b_pre ) * y_callee_v )) ”
456
+ ) \/
457
+ (
458
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) <> 0)) (PreH5 : ((Zabs (x_callee_v)) <= ((Zabs ((a_pre % ( b_pre ) ))) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH6 : ((Zabs (y_callee_v)) <= ((Zabs (b_pre)) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
459
+ ((y_pre) # Int |-> x_callee_v)
460
+ ** ((x_pre) # Int |-> y_callee_v)
461
+ ** ((( &( "g" ) )) # Int |-> retval)
462
+ ** ((( &( "a" ) )) # Int |-> a_pre)
463
+ ** ((( &( "b" ) )) # Int |-> b_pre)
464
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
465
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
466
+ |--
467
+ “ (((a_pre ÷ b_pre ) * y_callee_v ) <= INT_MAX) ”
468
+ && “ ((INT_MIN) <= ((a_pre ÷ b_pre ) * y_callee_v )) ”
469
+ ).
470
+
471
+ Definition exgcd_safety_wit_19_split_goal_1 :=
472
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) <> 0)) (PreH5 : ((Zabs (x_callee_v)) <= ((Zabs ((a_pre % ( b_pre ) ))) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH6 : ((Zabs (y_callee_v)) <= ((Zabs (b_pre)) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
473
+ ((y_pre) # Int |-> x_callee_v)
474
+ ** ((x_pre) # Int |-> y_callee_v)
475
+ ** ((( &( "g" ) )) # Int |-> retval)
476
+ ** ((( &( "a" ) )) # Int |-> a_pre)
477
+ ** ((( &( "b" ) )) # Int |-> b_pre)
478
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
479
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
480
+ |--
481
+ “ (((a_pre ÷ b_pre ) * y_callee_v ) <= INT_MAX) ”
482
+ .
483
+
484
+ Definition exgcd_safety_wit_19_split_goal_2 :=
485
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) <> 0)) (PreH5 : ((Zabs (x_callee_v)) <= ((Zabs ((a_pre % ( b_pre ) ))) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH6 : ((Zabs (y_callee_v)) <= ((Zabs (b_pre)) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
486
+ ((y_pre) # Int |-> x_callee_v)
487
+ ** ((x_pre) # Int |-> y_callee_v)
488
+ ** ((( &( "g" ) )) # Int |-> retval)
489
+ ** ((( &( "a" ) )) # Int |-> a_pre)
490
+ ** ((( &( "b" ) )) # Int |-> b_pre)
491
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
492
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
493
+ |--
494
+ “ ((INT_MIN) <= ((a_pre ÷ b_pre ) * y_callee_v )) ”
495
+ .
496
+
497
+ Definition exgcd_safety_wit_20 :=
498
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) <> 0)) (PreH5 : ((Zabs (x_callee_v)) <= ((Zabs ((a_pre % ( b_pre ) ))) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH6 : ((Zabs (y_callee_v)) <= ((Zabs (b_pre)) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
499
+ ((y_pre) # Int |-> x_callee_v)
500
+ ** ((x_pre) # Int |-> y_callee_v)
501
+ ** ((( &( "g" ) )) # Int |-> retval)
502
+ ** ((( &( "a" ) )) # Int |-> a_pre)
503
+ ** ((( &( "b" ) )) # Int |-> b_pre)
504
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
505
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
506
+ |--
507
+ “ ((a_pre <> (INT_MIN)) \/ (b_pre <> (-1))) ”
508
+ && “ (b_pre <> 0) ”
509
+ .
510
+
511
+ Definition exgcd_return_wit_1 :=
512
+ (
513
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) = 0)) (PreH4 : ((Zabs (x_callee_v)) <= 1)) (PreH5 : (y_callee_v = 0)) (PreH6 : (b_pre <> 0)) (PreH7 : (INT_MIN < a_pre)) (PreH8 : (a_pre <= INT_MAX)) (PreH9 : (INT_MIN < b_pre)) (PreH10 : (b_pre <= INT_MAX)) ,
514
+ ((y_pre) # Int |-> (x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) ))
515
+ ** ((x_pre) # Int |-> y_callee_v)
516
+ |--
517
+ EX (y_pre_v_2: Z) (x_pre_v_2: Z) ,
518
+ “ (retval = (Zgcd (a_pre) (b_pre))) ”
519
+ && “ (((a_pre * x_pre_v_2 ) + (b_pre * y_pre_v_2 ) ) = (Zgcd (a_pre) (b_pre))) ”
520
+ && “ (b_pre <> 0) ”
521
+ && “ ((a_pre % ( b_pre ) ) = 0) ”
522
+ && “ (x_pre_v_2 = 0) ”
523
+ && “ ((Zabs (y_pre_v_2)) <= 1) ”
524
+ && ((x_pre) # Int |-> x_pre_v_2)
525
+ ** ((y_pre) # Int |-> y_pre_v_2)
526
+ ) \/
527
+ (
528
+ forall (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) = 0)) (PreH4 : ((Zabs (x_callee_v)) <= 1)) (PreH5 : (y_callee_v = 0)) (PreH6 : (b_pre <> 0)) (PreH7 : (INT_MIN < a_pre)) (PreH8 : (a_pre <= INT_MAX)) (PreH9 : (INT_MIN < b_pre)) (PreH10 : (b_pre <= INT_MAX)) ,
529
+ TT && emp
530
+ |--
531
+ “ ((Zabs ((x_callee_v - ((a_pre ÷ b_pre ) * 0 ) ))) <= 1) ”
532
+ && “ (((a_pre * 0 ) + (b_pre * (x_callee_v - ((a_pre ÷ b_pre ) * 0 ) ) ) ) = (Zgcd (a_pre) (b_pre))) ”
533
+ && “ (retval = (Zgcd (a_pre) (b_pre))) ”
534
+ && emp
535
+ ).
536
+
537
+ Definition exgcd_return_wit_1_split_goal_1 :=
538
+ forall (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) = 0)) (PreH4 : ((Zabs (x_callee_v)) <= 1)) (PreH5 : (y_callee_v = 0)) (PreH6 : (b_pre <> 0)) (PreH7 : (INT_MIN < a_pre)) (PreH8 : (a_pre <= INT_MAX)) (PreH9 : (INT_MIN < b_pre)) (PreH10 : (b_pre <= INT_MAX)) ,
539
+ ((Zabs ((x_callee_v - ((a_pre ÷ b_pre ) * 0 ) ))) <= 1)
540
+ .
541
+
542
+ Definition exgcd_return_wit_1_split_goal_2 :=
543
+ forall (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) = 0)) (PreH4 : ((Zabs (x_callee_v)) <= 1)) (PreH5 : (y_callee_v = 0)) (PreH6 : (b_pre <> 0)) (PreH7 : (INT_MIN < a_pre)) (PreH8 : (a_pre <= INT_MAX)) (PreH9 : (INT_MIN < b_pre)) (PreH10 : (b_pre <= INT_MAX)) ,
544
+ (((a_pre * 0 ) + (b_pre * (x_callee_v - ((a_pre ÷ b_pre ) * 0 ) ) ) ) = (Zgcd (a_pre) (b_pre)))
545
+ .
546
+
547
+ Definition exgcd_return_wit_1_split_goal_3 :=
548
+ forall (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) = 0)) (PreH4 : ((Zabs (x_callee_v)) <= 1)) (PreH5 : (y_callee_v = 0)) (PreH6 : (b_pre <> 0)) (PreH7 : (INT_MIN < a_pre)) (PreH8 : (a_pre <= INT_MAX)) (PreH9 : (INT_MIN < b_pre)) (PreH10 : (b_pre <= INT_MAX)) ,
549
+ (retval = (Zgcd (a_pre) (b_pre)))
550
+ .
551
+
552
+ Definition exgcd_return_wit_2 :=
553
+ (
554
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) = 0)) (PreH5 : (x_callee_v = 0)) (PreH6 : ((Zabs (y_callee_v)) <= 1)) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
555
+ ((y_pre) # Int |-> (x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) ))
556
+ ** ((x_pre) # Int |-> y_callee_v)
557
+ |--
558
+ EX (y_pre_v_3: Z) (x_pre_v_3: Z) ,
559
+ “ (retval = (Zgcd (a_pre) (b_pre))) ”
560
+ && “ (((a_pre * x_pre_v_3 ) + (b_pre * y_pre_v_3 ) ) = (Zgcd (a_pre) (b_pre))) ”
561
+ && “ (b_pre <> 0) ”
562
+ && “ ((a_pre % ( b_pre ) ) <> 0) ”
563
+ && “ ((Zabs (x_pre_v_3)) <= ((Zabs (b_pre)) ÷ (Zgcd (a_pre) (b_pre)) )) ”
564
+ && “ ((Zabs (y_pre_v_3)) <= ((Zabs (a_pre)) ÷ (Zgcd (a_pre) (b_pre)) )) ”
565
+ && ((x_pre) # Int |-> x_pre_v_3)
566
+ ** ((y_pre) # Int |-> y_pre_v_3)
567
+ ) \/
568
+ (
569
+ forall (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) = 0)) (PreH5 : (x_callee_v = 0)) (PreH6 : ((Zabs (y_callee_v)) <= 1)) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
570
+ TT && emp
571
+ |--
572
+ “ ((Zabs ((0 - ((a_pre ÷ b_pre ) * y_callee_v ) ))) <= ((Zabs (a_pre)) ÷ (Zgcd (a_pre) (b_pre)) )) ”
573
+ && “ ((Zabs (y_callee_v)) <= ((Zabs (b_pre)) ÷ (Zgcd (a_pre) (b_pre)) )) ”
574
+ && “ (((a_pre * y_callee_v ) + (b_pre * (0 - ((a_pre ÷ b_pre ) * y_callee_v ) ) ) ) = (Zgcd (a_pre) (b_pre))) ”
575
+ && “ (retval = (Zgcd (a_pre) (b_pre))) ”
576
+ && emp
577
+ ).
578
+
579
+ Definition exgcd_return_wit_2_split_goal_1 :=
580
+ forall (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) = 0)) (PreH5 : (x_callee_v = 0)) (PreH6 : ((Zabs (y_callee_v)) <= 1)) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
581
+ ((Zabs ((0 - ((a_pre ÷ b_pre ) * y_callee_v ) ))) <= ((Zabs (a_pre)) ÷ (Zgcd (a_pre) (b_pre)) ))
582
+ .
583
+
584
+ Definition exgcd_return_wit_2_split_goal_2 :=
585
+ forall (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) = 0)) (PreH5 : (x_callee_v = 0)) (PreH6 : ((Zabs (y_callee_v)) <= 1)) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
586
+ ((Zabs (y_callee_v)) <= ((Zabs (b_pre)) ÷ (Zgcd (a_pre) (b_pre)) ))
587
+ .
588
+
589
+ Definition exgcd_return_wit_2_split_goal_3 :=
590
+ forall (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) = 0)) (PreH5 : (x_callee_v = 0)) (PreH6 : ((Zabs (y_callee_v)) <= 1)) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
591
+ (((a_pre * y_callee_v ) + (b_pre * (0 - ((a_pre ÷ b_pre ) * y_callee_v ) ) ) ) = (Zgcd (a_pre) (b_pre)))
592
+ .
593
+
594
+ Definition exgcd_return_wit_2_split_goal_4 :=
595
+ forall (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) = 0)) (PreH5 : (x_callee_v = 0)) (PreH6 : ((Zabs (y_callee_v)) <= 1)) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
596
+ (retval = (Zgcd (a_pre) (b_pre)))
597
+ .
598
+
599
+ Definition exgcd_return_wit_3 :=
600
+ (
601
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) <> 0)) (PreH5 : ((Zabs (x_callee_v)) <= ((Zabs ((a_pre % ( b_pre ) ))) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH6 : ((Zabs (y_callee_v)) <= ((Zabs (b_pre)) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
602
+ ((y_pre) # Int |-> (x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) ))
603
+ ** ((x_pre) # Int |-> y_callee_v)
604
+ |--
605
+ EX (y_pre_v_3: Z) (x_pre_v_3: Z) ,
606
+ “ (retval = (Zgcd (a_pre) (b_pre))) ”
607
+ && “ (((a_pre * x_pre_v_3 ) + (b_pre * y_pre_v_3 ) ) = (Zgcd (a_pre) (b_pre))) ”
608
+ && “ (b_pre <> 0) ”
609
+ && “ ((a_pre % ( b_pre ) ) <> 0) ”
610
+ && “ ((Zabs (x_pre_v_3)) <= ((Zabs (b_pre)) ÷ (Zgcd (a_pre) (b_pre)) )) ”
611
+ && “ ((Zabs (y_pre_v_3)) <= ((Zabs (a_pre)) ÷ (Zgcd (a_pre) (b_pre)) )) ”
612
+ && ((x_pre) # Int |-> x_pre_v_3)
613
+ ** ((y_pre) # Int |-> y_pre_v_3)
614
+ ) \/
615
+ (
616
+ forall (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) <> 0)) (PreH5 : ((Zabs (x_callee_v)) <= ((Zabs ((a_pre % ( b_pre ) ))) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH6 : ((Zabs (y_callee_v)) <= ((Zabs (b_pre)) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
617
+ TT && emp
618
+ |--
619
+ “ ((Zabs ((x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) ))) <= ((Zabs (a_pre)) ÷ (Zgcd (a_pre) (b_pre)) )) ”
620
+ && “ ((Zabs (y_callee_v)) <= ((Zabs (b_pre)) ÷ (Zgcd (a_pre) (b_pre)) )) ”
621
+ && “ (((a_pre * y_callee_v ) + (b_pre * (x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) ) ) ) = (Zgcd (a_pre) (b_pre))) ”
622
+ && “ (retval = (Zgcd (a_pre) (b_pre))) ”
623
+ && emp
624
+ ).
625
+
626
+ Definition exgcd_return_wit_3_split_goal_1 :=
627
+ forall (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) <> 0)) (PreH5 : ((Zabs (x_callee_v)) <= ((Zabs ((a_pre % ( b_pre ) ))) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH6 : ((Zabs (y_callee_v)) <= ((Zabs (b_pre)) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
628
+ ((Zabs ((x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) ))) <= ((Zabs (a_pre)) ÷ (Zgcd (a_pre) (b_pre)) ))
629
+ .
630
+
631
+ Definition exgcd_return_wit_3_split_goal_2 :=
632
+ forall (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) <> 0)) (PreH5 : ((Zabs (x_callee_v)) <= ((Zabs ((a_pre % ( b_pre ) ))) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH6 : ((Zabs (y_callee_v)) <= ((Zabs (b_pre)) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
633
+ ((Zabs (y_callee_v)) <= ((Zabs (b_pre)) ÷ (Zgcd (a_pre) (b_pre)) ))
634
+ .
635
+
636
+ Definition exgcd_return_wit_3_split_goal_3 :=
637
+ forall (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) <> 0)) (PreH5 : ((Zabs (x_callee_v)) <= ((Zabs ((a_pre % ( b_pre ) ))) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH6 : ((Zabs (y_callee_v)) <= ((Zabs (b_pre)) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
638
+ (((a_pre * y_callee_v ) + (b_pre * (x_callee_v - ((a_pre ÷ b_pre ) * y_callee_v ) ) ) ) = (Zgcd (a_pre) (b_pre)))
639
+ .
640
+
641
+ Definition exgcd_return_wit_3_split_goal_4 :=
642
+ forall (b_pre: Z) (a_pre: Z) (y_callee_v: Z) (x_callee_v: Z) (retval: Z) (PreH1 : (retval = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH2 : (((b_pre * x_callee_v ) + ((a_pre % ( b_pre ) ) * y_callee_v ) ) = (Zgcd (b_pre) ((a_pre % ( b_pre ) ))))) (PreH3 : ((a_pre % ( b_pre ) ) <> 0)) (PreH4 : ((b_pre % ( (a_pre % ( b_pre ) ) ) ) <> 0)) (PreH5 : ((Zabs (x_callee_v)) <= ((Zabs ((a_pre % ( b_pre ) ))) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH6 : ((Zabs (y_callee_v)) <= ((Zabs (b_pre)) ÷ (Zgcd (b_pre) ((a_pre % ( b_pre ) ))) ))) (PreH7 : (b_pre <> 0)) (PreH8 : (INT_MIN < a_pre)) (PreH9 : (a_pre <= INT_MAX)) (PreH10 : (INT_MIN < b_pre)) (PreH11 : (b_pre <= INT_MAX)) ,
643
+ (retval = (Zgcd (a_pre) (b_pre)))
644
+ .
645
+
646
+ Definition exgcd_return_wit_4 :=
647
+ (
648
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (retval: Z) (PreH1 : (retval = (Zabs (a_pre)))) (PreH2 : (a_pre < 0)) (PreH3 : (b_pre = 0)) (PreH4 : (INT_MIN < a_pre)) (PreH5 : (a_pre <= INT_MAX)) (PreH6 : (INT_MIN < b_pre)) (PreH7 : (b_pre <= INT_MAX)) ,
649
+ ((x_pre) # Int |-> (-1))
650
+ ** ((y_pre) # Int |-> 0)
651
+ |--
652
+ EX (y_pre_v: Z) (x_pre_v: Z) ,
653
+ “ (retval = (Zgcd (a_pre) (b_pre))) ”
654
+ && “ (((a_pre * x_pre_v ) + (b_pre * y_pre_v ) ) = (Zgcd (a_pre) (b_pre))) ”
655
+ && “ (b_pre = 0) ”
656
+ && “ ((Zabs (x_pre_v)) <= 1) ”
657
+ && “ (y_pre_v = 0) ”
658
+ && ((x_pre) # Int |-> x_pre_v)
659
+ ** ((y_pre) # Int |-> y_pre_v)
660
+ ) \/
661
+ (
662
+ forall (b_pre: Z) (a_pre: Z) (retval: Z) (PreH1 : (retval = (Zabs (a_pre)))) (PreH2 : (a_pre < 0)) (PreH3 : (b_pre = 0)) (PreH4 : (INT_MIN < a_pre)) (PreH5 : (a_pre <= INT_MAX)) (PreH6 : (INT_MIN < b_pre)) (PreH7 : (b_pre <= INT_MAX)) ,
663
+ TT && emp
664
+ |--
665
+ “ ((Zabs ((-1))) <= 1) ”
666
+ && “ (((a_pre * (-1) ) + (0 * 0 ) ) = (Zgcd (a_pre) (0))) ”
667
+ && “ (retval = (Zgcd (a_pre) (0))) ”
668
+ && emp
669
+ ).
670
+
671
+ Definition exgcd_return_wit_4_split_goal_1 :=
672
+ forall (b_pre: Z) (a_pre: Z) (retval: Z) (PreH1 : (retval = (Zabs (a_pre)))) (PreH2 : (a_pre < 0)) (PreH3 : (b_pre = 0)) (PreH4 : (INT_MIN < a_pre)) (PreH5 : (a_pre <= INT_MAX)) (PreH6 : (INT_MIN < b_pre)) (PreH7 : (b_pre <= INT_MAX)) ,
673
+ ((Zabs ((-1))) <= 1)
674
+ .
675
+
676
+ Definition exgcd_return_wit_4_split_goal_2 :=
677
+ forall (b_pre: Z) (a_pre: Z) (retval: Z) (PreH1 : (retval = (Zabs (a_pre)))) (PreH2 : (a_pre < 0)) (PreH3 : (b_pre = 0)) (PreH4 : (INT_MIN < a_pre)) (PreH5 : (a_pre <= INT_MAX)) (PreH6 : (INT_MIN < b_pre)) (PreH7 : (b_pre <= INT_MAX)) ,
678
+ (((a_pre * (-1) ) + (0 * 0 ) ) = (Zgcd (a_pre) (0)))
679
+ .
680
+
681
+ Definition exgcd_return_wit_4_split_goal_3 :=
682
+ forall (b_pre: Z) (a_pre: Z) (retval: Z) (PreH1 : (retval = (Zabs (a_pre)))) (PreH2 : (a_pre < 0)) (PreH3 : (b_pre = 0)) (PreH4 : (INT_MIN < a_pre)) (PreH5 : (a_pre <= INT_MAX)) (PreH6 : (INT_MIN < b_pre)) (PreH7 : (b_pre <= INT_MAX)) ,
683
+ (retval = (Zgcd (a_pre) (0)))
684
+ .
685
+
686
+ Definition exgcd_return_wit_5 :=
687
+ (
688
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (retval: Z) (PreH1 : (retval = (Zabs (a_pre)))) (PreH2 : (a_pre = 0)) (PreH3 : (a_pre >= 0)) (PreH4 : (b_pre = 0)) (PreH5 : (INT_MIN < a_pre)) (PreH6 : (a_pre <= INT_MAX)) (PreH7 : (INT_MIN < b_pre)) (PreH8 : (b_pre <= INT_MAX)) ,
689
+ ((x_pre) # Int |-> 0)
690
+ ** ((y_pre) # Int |-> 0)
691
+ |--
692
+ EX (y_pre_v: Z) (x_pre_v: Z) ,
693
+ “ (retval = (Zgcd (a_pre) (b_pre))) ”
694
+ && “ (((a_pre * x_pre_v ) + (b_pre * y_pre_v ) ) = (Zgcd (a_pre) (b_pre))) ”
695
+ && “ (b_pre = 0) ”
696
+ && “ ((Zabs (x_pre_v)) <= 1) ”
697
+ && “ (y_pre_v = 0) ”
698
+ && ((x_pre) # Int |-> x_pre_v)
699
+ ** ((y_pre) # Int |-> y_pre_v)
700
+ ) \/
701
+ (
702
+ forall (b_pre: Z) (a_pre: Z) (retval: Z) (PreH1 : (retval = (Zabs (a_pre)))) (PreH2 : (a_pre = 0)) (PreH3 : (a_pre >= 0)) (PreH4 : (b_pre = 0)) (PreH5 : (INT_MIN < a_pre)) (PreH6 : (a_pre <= INT_MAX)) (PreH7 : (INT_MIN < b_pre)) (PreH8 : (b_pre <= INT_MAX)) ,
703
+ TT && emp
704
+ |--
705
+ “ ((Zabs (0)) <= 1) ”
706
+ && “ (((0 * 0 ) + (0 * 0 ) ) = (Zgcd (0) (0))) ”
707
+ && “ (retval = (Zgcd (0) (0))) ”
708
+ && emp
709
+ ).
710
+
711
+ Definition exgcd_return_wit_5_split_goal_1 :=
712
+ forall (b_pre: Z) (a_pre: Z) (retval: Z) (PreH1 : (retval = (Zabs (a_pre)))) (PreH2 : (a_pre = 0)) (PreH3 : (a_pre >= 0)) (PreH4 : (b_pre = 0)) (PreH5 : (INT_MIN < a_pre)) (PreH6 : (a_pre <= INT_MAX)) (PreH7 : (INT_MIN < b_pre)) (PreH8 : (b_pre <= INT_MAX)) ,
713
+ ((Zabs (0)) <= 1)
714
+ .
715
+
716
+ Definition exgcd_return_wit_5_split_goal_2 :=
717
+ forall (b_pre: Z) (a_pre: Z) (retval: Z) (PreH1 : (retval = (Zabs (a_pre)))) (PreH2 : (a_pre = 0)) (PreH3 : (a_pre >= 0)) (PreH4 : (b_pre = 0)) (PreH5 : (INT_MIN < a_pre)) (PreH6 : (a_pre <= INT_MAX)) (PreH7 : (INT_MIN < b_pre)) (PreH8 : (b_pre <= INT_MAX)) ,
718
+ (((0 * 0 ) + (0 * 0 ) ) = (Zgcd (0) (0)))
719
+ .
720
+
721
+ Definition exgcd_return_wit_5_split_goal_3 :=
722
+ forall (b_pre: Z) (a_pre: Z) (retval: Z) (PreH1 : (retval = (Zabs (a_pre)))) (PreH2 : (a_pre = 0)) (PreH3 : (a_pre >= 0)) (PreH4 : (b_pre = 0)) (PreH5 : (INT_MIN < a_pre)) (PreH6 : (a_pre <= INT_MAX)) (PreH7 : (INT_MIN < b_pre)) (PreH8 : (b_pre <= INT_MAX)) ,
723
+ (retval = (Zgcd (0) (0)))
724
+ .
725
+
726
+ Definition exgcd_return_wit_6 :=
727
+ (
728
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (retval: Z) (PreH1 : (retval = (Zabs (a_pre)))) (PreH2 : (a_pre <> 0)) (PreH3 : (a_pre >= 0)) (PreH4 : (b_pre = 0)) (PreH5 : (INT_MIN < a_pre)) (PreH6 : (a_pre <= INT_MAX)) (PreH7 : (INT_MIN < b_pre)) (PreH8 : (b_pre <= INT_MAX)) ,
729
+ ((x_pre) # Int |-> 1)
730
+ ** ((y_pre) # Int |-> 0)
731
+ |--
732
+ EX (y_pre_v: Z) (x_pre_v: Z) ,
733
+ “ (retval = (Zgcd (a_pre) (b_pre))) ”
734
+ && “ (((a_pre * x_pre_v ) + (b_pre * y_pre_v ) ) = (Zgcd (a_pre) (b_pre))) ”
735
+ && “ (b_pre = 0) ”
736
+ && “ ((Zabs (x_pre_v)) <= 1) ”
737
+ && “ (y_pre_v = 0) ”
738
+ && ((x_pre) # Int |-> x_pre_v)
739
+ ** ((y_pre) # Int |-> y_pre_v)
740
+ ) \/
741
+ (
742
+ forall (b_pre: Z) (a_pre: Z) (retval: Z) (PreH1 : (retval = (Zabs (a_pre)))) (PreH2 : (a_pre <> 0)) (PreH3 : (a_pre >= 0)) (PreH4 : (b_pre = 0)) (PreH5 : (INT_MIN < a_pre)) (PreH6 : (a_pre <= INT_MAX)) (PreH7 : (INT_MIN < b_pre)) (PreH8 : (b_pre <= INT_MAX)) ,
743
+ TT && emp
744
+ |--
745
+ “ ((Zabs (1)) <= 1) ”
746
+ && “ (((a_pre * 1 ) + (0 * 0 ) ) = (Zgcd (a_pre) (0))) ”
747
+ && “ (retval = (Zgcd (a_pre) (0))) ”
748
+ && emp
749
+ ).
750
+
751
+ Definition exgcd_return_wit_6_split_goal_1 :=
752
+ forall (b_pre: Z) (a_pre: Z) (retval: Z) (PreH1 : (retval = (Zabs (a_pre)))) (PreH2 : (a_pre <> 0)) (PreH3 : (a_pre >= 0)) (PreH4 : (b_pre = 0)) (PreH5 : (INT_MIN < a_pre)) (PreH6 : (a_pre <= INT_MAX)) (PreH7 : (INT_MIN < b_pre)) (PreH8 : (b_pre <= INT_MAX)) ,
753
+ ((Zabs (1)) <= 1)
754
+ .
755
+
756
+ Definition exgcd_return_wit_6_split_goal_2 :=
757
+ forall (b_pre: Z) (a_pre: Z) (retval: Z) (PreH1 : (retval = (Zabs (a_pre)))) (PreH2 : (a_pre <> 0)) (PreH3 : (a_pre >= 0)) (PreH4 : (b_pre = 0)) (PreH5 : (INT_MIN < a_pre)) (PreH6 : (a_pre <= INT_MAX)) (PreH7 : (INT_MIN < b_pre)) (PreH8 : (b_pre <= INT_MAX)) ,
758
+ (((a_pre * 1 ) + (0 * 0 ) ) = (Zgcd (a_pre) (0)))
759
+ .
760
+
761
+ Definition exgcd_return_wit_6_split_goal_3 :=
762
+ forall (b_pre: Z) (a_pre: Z) (retval: Z) (PreH1 : (retval = (Zabs (a_pre)))) (PreH2 : (a_pre <> 0)) (PreH3 : (a_pre >= 0)) (PreH4 : (b_pre = 0)) (PreH5 : (INT_MIN < a_pre)) (PreH6 : (a_pre <= INT_MAX)) (PreH7 : (INT_MIN < b_pre)) (PreH8 : (b_pre <= INT_MAX)) ,
763
+ (retval = (Zgcd (a_pre) (0)))
764
+ .
765
+
766
+ Definition exgcd_partial_solve_wit_1_pure :=
767
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (a_pre < 0)) (PreH2 : (b_pre = 0)) (PreH3 : (INT_MIN < a_pre)) (PreH4 : (a_pre <= INT_MAX)) (PreH5 : (INT_MIN < b_pre)) (PreH6 : (b_pre <= INT_MAX)) ,
768
+ ((( &( "a" ) )) # Int |-> a_pre)
769
+ ** ((( &( "b" ) )) # Int |-> b_pre)
770
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
771
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
772
+ ** ((x_pre) # Int |-> (-1))
773
+ ** ((y_pre) # Int |-> 0)
774
+ |--
775
+ “ (INT_MIN < a_pre) ”
776
+ && “ (a_pre <= INT_MAX) ”
777
+ .
778
+
779
+ Definition exgcd_partial_solve_wit_1_aux :=
780
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (a_pre < 0)) (PreH2 : (b_pre = 0)) (PreH3 : (INT_MIN < a_pre)) (PreH4 : (a_pre <= INT_MAX)) (PreH5 : (INT_MIN < b_pre)) (PreH6 : (b_pre <= INT_MAX)) ,
781
+ ((x_pre) # Int |-> (-1))
782
+ ** ((y_pre) # Int |-> 0)
783
+ |--
784
+ “ (INT_MIN < a_pre) ”
785
+ && “ (a_pre <= INT_MAX) ”
786
+ && “ (a_pre < 0) ”
787
+ && “ (b_pre = 0) ”
788
+ && “ (INT_MIN < a_pre) ”
789
+ && “ (a_pre <= INT_MAX) ”
790
+ && “ (INT_MIN < b_pre) ”
791
+ && “ (b_pre <= INT_MAX) ”
792
+ && ((x_pre) # Int |-> (-1))
793
+ ** ((y_pre) # Int |-> 0)
794
+ .
795
+
796
+ Definition exgcd_partial_solve_wit_1 := exgcd_partial_solve_wit_1_pure -> exgcd_partial_solve_wit_1_aux.
797
+
798
+ Definition exgcd_partial_solve_wit_2_pure :=
799
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (a_pre = 0)) (PreH2 : (a_pre >= 0)) (PreH3 : (b_pre = 0)) (PreH4 : (INT_MIN < a_pre)) (PreH5 : (a_pre <= INT_MAX)) (PreH6 : (INT_MIN < b_pre)) (PreH7 : (b_pre <= INT_MAX)) ,
800
+ ((( &( "a" ) )) # Int |-> a_pre)
801
+ ** ((( &( "b" ) )) # Int |-> b_pre)
802
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
803
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
804
+ ** ((x_pre) # Int |-> 0)
805
+ ** ((y_pre) # Int |-> 0)
806
+ |--
807
+ “ (INT_MIN < a_pre) ”
808
+ && “ (a_pre <= INT_MAX) ”
809
+ .
810
+
811
+ Definition exgcd_partial_solve_wit_2_aux :=
812
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (a_pre = 0)) (PreH2 : (a_pre >= 0)) (PreH3 : (b_pre = 0)) (PreH4 : (INT_MIN < a_pre)) (PreH5 : (a_pre <= INT_MAX)) (PreH6 : (INT_MIN < b_pre)) (PreH7 : (b_pre <= INT_MAX)) ,
813
+ ((x_pre) # Int |-> 0)
814
+ ** ((y_pre) # Int |-> 0)
815
+ |--
816
+ “ (INT_MIN < a_pre) ”
817
+ && “ (a_pre <= INT_MAX) ”
818
+ && “ (a_pre = 0) ”
819
+ && “ (a_pre >= 0) ”
820
+ && “ (b_pre = 0) ”
821
+ && “ (INT_MIN < a_pre) ”
822
+ && “ (a_pre <= INT_MAX) ”
823
+ && “ (INT_MIN < b_pre) ”
824
+ && “ (b_pre <= INT_MAX) ”
825
+ && ((x_pre) # Int |-> 0)
826
+ ** ((y_pre) # Int |-> 0)
827
+ .
828
+
829
+ Definition exgcd_partial_solve_wit_2 := exgcd_partial_solve_wit_2_pure -> exgcd_partial_solve_wit_2_aux.
830
+
831
+ Definition exgcd_partial_solve_wit_3_pure :=
832
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (a_pre <> 0)) (PreH2 : (a_pre >= 0)) (PreH3 : (b_pre = 0)) (PreH4 : (INT_MIN < a_pre)) (PreH5 : (a_pre <= INT_MAX)) (PreH6 : (INT_MIN < b_pre)) (PreH7 : (b_pre <= INT_MAX)) ,
833
+ ((( &( "a" ) )) # Int |-> a_pre)
834
+ ** ((( &( "b" ) )) # Int |-> b_pre)
835
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
836
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
837
+ ** ((x_pre) # Int |-> 1)
838
+ ** ((y_pre) # Int |-> 0)
839
+ |--
840
+ “ (INT_MIN < a_pre) ”
841
+ && “ (a_pre <= INT_MAX) ”
842
+ .
843
+
844
+ Definition exgcd_partial_solve_wit_3_aux :=
845
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (a_pre <> 0)) (PreH2 : (a_pre >= 0)) (PreH3 : (b_pre = 0)) (PreH4 : (INT_MIN < a_pre)) (PreH5 : (a_pre <= INT_MAX)) (PreH6 : (INT_MIN < b_pre)) (PreH7 : (b_pre <= INT_MAX)) ,
846
+ ((x_pre) # Int |-> 1)
847
+ ** ((y_pre) # Int |-> 0)
848
+ |--
849
+ “ (INT_MIN < a_pre) ”
850
+ && “ (a_pre <= INT_MAX) ”
851
+ && “ (a_pre <> 0) ”
852
+ && “ (a_pre >= 0) ”
853
+ && “ (b_pre = 0) ”
854
+ && “ (INT_MIN < a_pre) ”
855
+ && “ (a_pre <= INT_MAX) ”
856
+ && “ (INT_MIN < b_pre) ”
857
+ && “ (b_pre <= INT_MAX) ”
858
+ && ((x_pre) # Int |-> 1)
859
+ ** ((y_pre) # Int |-> 0)
860
+ .
861
+
862
+ Definition exgcd_partial_solve_wit_3 := exgcd_partial_solve_wit_3_pure -> exgcd_partial_solve_wit_3_aux.
863
+
864
+ Definition exgcd_partial_solve_wit_4_pure :=
865
+ (
866
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (b_pre <> 0)) (PreH2 : (INT_MIN < a_pre)) (PreH3 : (a_pre <= INT_MAX)) (PreH4 : (INT_MIN < b_pre)) (PreH5 : (b_pre <= INT_MAX)) ,
867
+ ((( &( "g" ) )) # Int |->_)
868
+ ** ((( &( "a" ) )) # Int |-> a_pre)
869
+ ** ((( &( "b" ) )) # Int |-> b_pre)
870
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
871
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
872
+ ** ((x_pre) # Int |->_)
873
+ ** ((y_pre) # Int |->_)
874
+ |--
875
+ “ (INT_MIN < b_pre) ”
876
+ && “ (b_pre <= INT_MAX) ”
877
+ && “ ((a_pre % ( b_pre ) ) <= INT_MAX) ”
878
+ && “ (INT_MIN < (a_pre % ( b_pre ) )) ”
879
+ ) \/
880
+ (
881
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (b_pre >= INT_MIN)) (PreH2 : (a_pre >= INT_MIN)) (PreH3 : (b_pre <> 0)) (PreH4 : (INT_MIN < a_pre)) (PreH5 : (a_pre <= INT_MAX)) (PreH6 : (INT_MIN < b_pre)) (PreH7 : (b_pre <= INT_MAX)) ,
882
+ ((( &( "g" ) )) # Int |->_)
883
+ ** ((( &( "a" ) )) # Int |-> a_pre)
884
+ ** ((( &( "b" ) )) # Int |-> b_pre)
885
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
886
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
887
+ ** ((x_pre) # Int |->_)
888
+ ** ((y_pre) # Int |->_)
889
+ |--
890
+ “ (INT_MIN < (a_pre % ( b_pre ) )) ”
891
+ && “ ((a_pre % ( b_pre ) ) <= INT_MAX) ”
892
+ ).
893
+
894
+ Definition exgcd_partial_solve_wit_4_pure_split_goal_1 :=
895
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (b_pre >= INT_MIN)) (PreH2 : (a_pre >= INT_MIN)) (PreH3 : (b_pre <> 0)) (PreH4 : (INT_MIN < a_pre)) (PreH5 : (a_pre <= INT_MAX)) (PreH6 : (INT_MIN < b_pre)) (PreH7 : (b_pre <= INT_MAX)) ,
896
+ ((( &( "g" ) )) # Int |->_)
897
+ ** ((( &( "a" ) )) # Int |-> a_pre)
898
+ ** ((( &( "b" ) )) # Int |-> b_pre)
899
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
900
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
901
+ ** ((x_pre) # Int |->_)
902
+ ** ((y_pre) # Int |->_)
903
+ |--
904
+ “ (INT_MIN < (a_pre % ( b_pre ) )) ”
905
+ .
906
+
907
+ Definition exgcd_partial_solve_wit_4_pure_split_goal_2 :=
908
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (b_pre >= INT_MIN)) (PreH2 : (a_pre >= INT_MIN)) (PreH3 : (b_pre <> 0)) (PreH4 : (INT_MIN < a_pre)) (PreH5 : (a_pre <= INT_MAX)) (PreH6 : (INT_MIN < b_pre)) (PreH7 : (b_pre <= INT_MAX)) ,
909
+ ((( &( "g" ) )) # Int |->_)
910
+ ** ((( &( "a" ) )) # Int |-> a_pre)
911
+ ** ((( &( "b" ) )) # Int |-> b_pre)
912
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
913
+ ** ((( &( "y" ) )) # Ptr |-> y_pre)
914
+ ** ((x_pre) # Int |->_)
915
+ ** ((y_pre) # Int |->_)
916
+ |--
917
+ “ ((a_pre % ( b_pre ) ) <= INT_MAX) ”
918
+ .
919
+
920
+ Definition exgcd_partial_solve_wit_4_aux :=
921
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) (PreH1 : (b_pre <> 0)) (PreH2 : (INT_MIN < a_pre)) (PreH3 : (a_pre <= INT_MAX)) (PreH4 : (INT_MIN < b_pre)) (PreH5 : (b_pre <= INT_MAX)) ,
922
+ ((x_pre) # Int |->_)
923
+ ** ((y_pre) # Int |->_)
924
+ |--
925
+ “ (INT_MIN < b_pre) ”
926
+ && “ (b_pre <= INT_MAX) ”
927
+ && “ ((a_pre % ( b_pre ) ) <= INT_MAX) ”
928
+ && “ (INT_MIN < (a_pre % ( b_pre ) )) ”
929
+ && “ (b_pre <> 0) ”
930
+ && “ (INT_MIN < a_pre) ”
931
+ && “ (a_pre <= INT_MAX) ”
932
+ && “ (INT_MIN < b_pre) ”
933
+ && “ (b_pre <= INT_MAX) ”
934
+ && ((y_pre) # Int |->_)
935
+ ** ((x_pre) # Int |->_)
936
+ .
937
+
938
+ Definition exgcd_partial_solve_wit_4 := exgcd_partial_solve_wit_4_pure -> exgcd_partial_solve_wit_4_aux.
939
+
940
+ Definition exgcd_derive_Inter_by_Proof :=
941
+ forall (y_pre: Z) (x_pre: Z) (b_pre: Z) (a_pre: Z) ,
942
+ “ (INT_MIN < a_pre) ”
943
+ && “ (a_pre <= INT_MAX) ”
944
+ && “ (INT_MIN < b_pre) ”
945
+ && “ (b_pre <= INT_MAX) ”
946
+ && ((x_pre) # Int |->_)
947
+ ** ((y_pre) # Int |->_)
948
+ |--
949
+ (“ (INT_MIN < a_pre) ”
950
+ && “ (a_pre <= INT_MAX) ”
951
+ && “ (INT_MIN < b_pre) ”
952
+ && “ (b_pre <= INT_MAX) ”
953
+ && ((x_pre) # Int |->_)
954
+ ** ((y_pre) # Int |->_))
955
+ **
956
+ (((EX y_callee_v x_callee_v retval_2,
957
+ “ (retval_2 = (Zgcd (a_pre) (b_pre))) ”
958
+ && “ (((a_pre * x_callee_v ) + (b_pre * y_callee_v ) ) = (Zgcd (a_pre) (b_pre))) ”
959
+ && “ (b_pre = 0) ”
960
+ && “ ((Zabs (x_callee_v)) <= 1) ”
961
+ && “ (y_callee_v = 0) ”
962
+ && ((x_pre) # Int |-> x_callee_v)
963
+ ** ((y_pre) # Int |-> y_callee_v))
964
+ ||
965
+ (EX y_callee_v_2 x_callee_v_2 retval_2,
966
+ “ (retval_2 = (Zgcd (a_pre) (b_pre))) ”
967
+ && “ (((a_pre * x_callee_v_2 ) + (b_pre * y_callee_v_2 ) ) = (Zgcd (a_pre) (b_pre))) ”
968
+ && “ (b_pre <> 0) ”
969
+ && “ ((a_pre % ( b_pre ) ) = 0) ”
970
+ && “ (x_callee_v_2 = 0) ”
971
+ && “ ((Zabs (y_callee_v_2)) <= 1) ”
972
+ && ((x_pre) # Int |-> x_callee_v_2)
973
+ ** ((y_pre) # Int |-> y_callee_v_2))
974
+ ||
975
+ (EX y_callee_v_3 x_callee_v_3 retval_2,
976
+ “ (retval_2 = (Zgcd (a_pre) (b_pre))) ”
977
+ && “ (((a_pre * x_callee_v_3 ) + (b_pre * y_callee_v_3 ) ) = (Zgcd (a_pre) (b_pre))) ”
978
+ && “ (b_pre <> 0) ”
979
+ && “ ((a_pre % ( b_pre ) ) <> 0) ”
980
+ && “ ((Zabs (x_callee_v_3)) <= ((Zabs (b_pre)) ÷ (Zgcd (a_pre) (b_pre)) )) ”
981
+ && “ ((Zabs (y_callee_v_3)) <= ((Zabs (a_pre)) ÷ (Zgcd (a_pre) (b_pre)) )) ”
982
+ && ((x_pre) # Int |-> x_callee_v_3)
983
+ ** ((y_pre) # Int |-> y_callee_v_3)))
984
+ -*
985
+ (EX y_pre_v x_pre_v retval,
986
+ “ (retval = (Zgcd (a_pre) (b_pre))) ”
987
+ && “ (((a_pre * x_pre_v ) + (b_pre * y_pre_v ) ) = (Zgcd (a_pre) (b_pre))) ”
988
+ && ((x_pre) # Int |-> x_pre_v)
989
+ ** ((y_pre) # Int |-> y_pre_v)))
990
+ .
991
+
992
+ Module Type VC_Correct.
993
+
994
+
995
+ Axiom proof_of_abs_safety_wit_1 : abs_safety_wit_1.
996
+ Axiom proof_of_abs_safety_wit_2 : abs_safety_wit_2.
997
+ Axiom proof_of_abs_return_wit_1 : abs_return_wit_1.
998
+ Axiom proof_of_abs_return_wit_2 : abs_return_wit_2.
999
+ Axiom proof_of_exgcd_safety_wit_1 : exgcd_safety_wit_1.
1000
+ Axiom proof_of_exgcd_safety_wit_2 : exgcd_safety_wit_2.
1001
+ Axiom proof_of_exgcd_safety_wit_3 : exgcd_safety_wit_3.
1002
+ Axiom proof_of_exgcd_safety_wit_4 : exgcd_safety_wit_4.
1003
+ Axiom proof_of_exgcd_safety_wit_5 : exgcd_safety_wit_5.
1004
+ Axiom proof_of_exgcd_safety_wit_6 : exgcd_safety_wit_6.
1005
+ Axiom proof_of_exgcd_safety_wit_7 : exgcd_safety_wit_7.
1006
+ Axiom proof_of_exgcd_safety_wit_8 : exgcd_safety_wit_8.
1007
+ Axiom proof_of_exgcd_safety_wit_9 : exgcd_safety_wit_9.
1008
+ Axiom proof_of_exgcd_safety_wit_10 : exgcd_safety_wit_10.
1009
+ Axiom proof_of_exgcd_safety_wit_11 : exgcd_safety_wit_11.
1010
+ Axiom proof_of_exgcd_safety_wit_12 : exgcd_safety_wit_12.
1011
+ Axiom proof_of_exgcd_safety_wit_13 : exgcd_safety_wit_13.
1012
+ Axiom proof_of_exgcd_safety_wit_14 : exgcd_safety_wit_14.
1013
+ Axiom proof_of_exgcd_safety_wit_15 : exgcd_safety_wit_15.
1014
+ Axiom proof_of_exgcd_safety_wit_16 : exgcd_safety_wit_16.
1015
+ Axiom proof_of_exgcd_safety_wit_17 : exgcd_safety_wit_17.
1016
+ Axiom proof_of_exgcd_safety_wit_18 : exgcd_safety_wit_18.
1017
+ Axiom proof_of_exgcd_safety_wit_19 : exgcd_safety_wit_19.
1018
+ Axiom proof_of_exgcd_safety_wit_20 : exgcd_safety_wit_20.
1019
+ Axiom proof_of_exgcd_return_wit_1 : exgcd_return_wit_1.
1020
+ Axiom proof_of_exgcd_return_wit_2 : exgcd_return_wit_2.
1021
+ Axiom proof_of_exgcd_return_wit_3 : exgcd_return_wit_3.
1022
+ Axiom proof_of_exgcd_return_wit_4 : exgcd_return_wit_4.
1023
+ Axiom proof_of_exgcd_return_wit_5 : exgcd_return_wit_5.
1024
+ Axiom proof_of_exgcd_return_wit_6 : exgcd_return_wit_6.
1025
+ Axiom proof_of_exgcd_partial_solve_wit_1_pure : exgcd_partial_solve_wit_1_pure.
1026
+ Axiom proof_of_exgcd_partial_solve_wit_1 : exgcd_partial_solve_wit_1.
1027
+ Axiom proof_of_exgcd_partial_solve_wit_2_pure : exgcd_partial_solve_wit_2_pure.
1028
+ Axiom proof_of_exgcd_partial_solve_wit_2 : exgcd_partial_solve_wit_2.
1029
+ Axiom proof_of_exgcd_partial_solve_wit_3_pure : exgcd_partial_solve_wit_3_pure.
1030
+ Axiom proof_of_exgcd_partial_solve_wit_3 : exgcd_partial_solve_wit_3.
1031
+ Axiom proof_of_exgcd_partial_solve_wit_4_pure : exgcd_partial_solve_wit_4_pure.
1032
+ Axiom proof_of_exgcd_partial_solve_wit_4 : exgcd_partial_solve_wit_4.
1033
+ Axiom proof_of_exgcd_derive_Inter_by_Proof : exgcd_derive_Inter_by_Proof.
1034
+
1035
+ End VC_Correct.
benchmarks/Algorithms/exgcd/rocq/groundtruth/exgcd_goal_check.v ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ From PVbench.Algorithms.exgcd.rocq.groundtruth Require Import exgcd_goal exgcd_proof_auto exgcd_proof_manual.
2
+
3
+ Module VC_Correctness : VC_Correct.
4
+ Include exgcd_proof_auto.
5
+ Include exgcd_proof_manual.
6
+ End VC_Correctness.
benchmarks/Algorithms/exgcd/rocq/groundtruth/exgcd_proof_auto.v ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Require Import Coq.ZArith.ZArith.
2
+ Require Import Coq.Bool.Bool.
3
+ Require Import Coq.Strings.String.
4
+ Require Import Coq.Strings.Ascii.
5
+ Require Import Coq.Lists.List.
6
+ Require Import Coq.Classes.RelationClasses.
7
+ Require Import Coq.Classes.Morphisms.
8
+ Require Import Coq.micromega.Psatz.
9
+ Require Import Coq.Sorting.Permutation.
10
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap.
11
+ Require Import SetsClass.SetsClass. Import SetsNotation.
12
+ From SimpleC.SL Require Import Mem SeparationLogic.
13
+ From PVbench.Algorithms.exgcd.rocq.groundtruth Require Import exgcd_goal.
14
+ Require Import Logic.LogicGenerator.demo932.Interface.
15
+ Local Open Scope Z_scope.
16
+ Local Open Scope sets.
17
+ Local Open Scope string_scope.
18
+ Local Open Scope list.
19
+ Import naive_C_Rules.
20
+ Local Open Scope sac.
21
+
22
+ Lemma proof_of_abs_safety_wit_1 : abs_safety_wit_1.
23
+ Proof. Admitted.
24
+
25
+ Lemma proof_of_abs_safety_wit_2 : abs_safety_wit_2.
26
+ Proof. Admitted.
27
+
28
+ Lemma proof_of_exgcd_safety_wit_1 : exgcd_safety_wit_1.
29
+ Proof. Admitted.
30
+
31
+ Lemma proof_of_exgcd_safety_wit_2 : exgcd_safety_wit_2.
32
+ Proof. Admitted.
33
+
34
+ Lemma proof_of_exgcd_safety_wit_3 : exgcd_safety_wit_3.
35
+ Proof. Admitted.
36
+
37
+ Lemma proof_of_exgcd_safety_wit_4 : exgcd_safety_wit_4.
38
+ Proof. Admitted.
39
+
40
+ Lemma proof_of_exgcd_safety_wit_5 : exgcd_safety_wit_5.
41
+ Proof. Admitted.
42
+
43
+ Lemma proof_of_exgcd_safety_wit_6 : exgcd_safety_wit_6.
44
+ Proof. Admitted.
45
+
46
+ Lemma proof_of_exgcd_safety_wit_7 : exgcd_safety_wit_7.
47
+ Proof. Admitted.
48
+
49
+ Lemma proof_of_exgcd_safety_wit_8 : exgcd_safety_wit_8.
50
+ Proof. Admitted.
51
+
52
+ Lemma proof_of_exgcd_safety_wit_9 : exgcd_safety_wit_9.
53
+ Proof. Admitted.
54
+
55
+ Lemma proof_of_exgcd_safety_wit_10 : exgcd_safety_wit_10.
56
+ Proof. Admitted.
57
+
58
+ Lemma proof_of_exgcd_safety_wit_11 : exgcd_safety_wit_11.
59
+ Proof. Admitted.
60
+
61
+ Lemma proof_of_exgcd_safety_wit_12 : exgcd_safety_wit_12.
62
+ Proof. Admitted.
63
+
64
+ Lemma proof_of_exgcd_safety_wit_13 : exgcd_safety_wit_13.
65
+ Proof. Admitted.
66
+
67
+ Lemma proof_of_exgcd_safety_wit_14 : exgcd_safety_wit_14.
68
+ Proof. Admitted.
69
+
70
+ Lemma proof_of_exgcd_safety_wit_17 : exgcd_safety_wit_17.
71
+ Proof. Admitted.
72
+
73
+ Lemma proof_of_exgcd_safety_wit_20 : exgcd_safety_wit_20.
74
+ Proof. Admitted.
75
+
76
+ Lemma proof_of_exgcd_partial_solve_wit_1_pure : exgcd_partial_solve_wit_1_pure.
77
+ Proof. Admitted.
78
+
79
+ Lemma proof_of_exgcd_partial_solve_wit_1 : exgcd_partial_solve_wit_1.
80
+ Proof. Admitted.
81
+
82
+ Lemma proof_of_exgcd_partial_solve_wit_2_pure : exgcd_partial_solve_wit_2_pure.
83
+ Proof. Admitted.
84
+
85
+ Lemma proof_of_exgcd_partial_solve_wit_2 : exgcd_partial_solve_wit_2.
86
+ Proof. Admitted.
87
+
88
+ Lemma proof_of_exgcd_partial_solve_wit_3_pure : exgcd_partial_solve_wit_3_pure.
89
+ Proof. Admitted.
90
+
91
+ Lemma proof_of_exgcd_partial_solve_wit_3 : exgcd_partial_solve_wit_3.
92
+ Proof. Admitted.
93
+
94
+ Lemma proof_of_exgcd_partial_solve_wit_4 : exgcd_partial_solve_wit_4.
95
+ Proof. Admitted.
96
+
benchmarks/Algorithms/exgcd/rocq/groundtruth/exgcd_proof_manual.v ADDED
@@ -0,0 +1,394 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Require Import Coq.ZArith.ZArith.
2
+ Require Import Coq.Bool.Bool.
3
+ Require Import Coq.Strings.String.
4
+ Require Import Coq.Strings.Ascii.
5
+ Require Import Coq.Lists.List.
6
+ Require Import Coq.Classes.RelationClasses.
7
+ Require Import Coq.Classes.Morphisms.
8
+ Require Import Coq.micromega.Psatz.
9
+ Require Import Coq.Sorting.Permutation.
10
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap.
11
+ Require Import SetsClass.SetsClass. Import SetsNotation.
12
+ From SimpleC.SL Require Import Mem SeparationLogic.
13
+ From PVbench.Algorithms.exgcd.rocq.groundtruth Require Import exgcd_goal.
14
+ From PVbench.Algorithms.exgcd.rocq.groundtruth Require Import exgcd_proof_auto.
15
+ Require Import Logic.LogicGenerator.demo932.Interface.
16
+ Local Open Scope Z_scope.
17
+ Local Open Scope sets.
18
+ Local Open Scope string_scope.
19
+ Local Open Scope list.
20
+ Import naive_C_Rules.
21
+ Require Import PVbench.Algorithms.exgcd.rocq.groundtruth.proof_lib.
22
+ Local Open Scope sac.
23
+
24
+
25
+
26
+ Lemma proof_of_exgcd_safety_wit_15_split_goal_1 : exgcd_safety_wit_15_split_goal_1.
27
+ Proof.
28
+ LLM_pre_process ltac:(int_auto).
29
+ assert (Zabs (a_pre ÷ b_pre * y_callee_v) <= 2147483647).
30
+ { rewrite Z.abs_mul.
31
+ rewrite <- Z.quot_abs by lia.
32
+ pose proof Z.quot_le_upper_bound (Zabs a_pre) (Zabs b_pre) 2147483647 ltac:(lia) ltac:(lia).
33
+ nia. }
34
+ repeat (split_pure_spatial || split_pures); try cancel; dump_pre_spatial; lia.
35
+ Qed.
36
+
37
+ Lemma proof_of_exgcd_safety_wit_15_split_goal_2 : exgcd_safety_wit_15_split_goal_2.
38
+ Proof.
39
+ LLM_pre_process ltac:(int_auto).
40
+ assert (Zabs (a_pre ÷ b_pre * y_callee_v) <= 2147483647).
41
+ { rewrite Z.abs_mul.
42
+ rewrite <- Z.quot_abs by lia.
43
+ pose proof Z.quot_le_upper_bound (Zabs a_pre) (Zabs b_pre) 2147483647 ltac:(lia) ltac:(lia).
44
+ nia. }
45
+ repeat (split_pure_spatial || split_pures); try cancel; dump_pre_spatial; lia.
46
+ Qed.
47
+
48
+ Lemma proof_of_exgcd_safety_wit_15 : exgcd_safety_wit_15.
49
+ Proof.
50
+ aggressive_pre_process.
51
+ - Goal_apply proof_of_exgcd_safety_wit_15_split_goal_1.
52
+ - Goal_apply proof_of_exgcd_safety_wit_15_split_goal_2.
53
+ Qed.
54
+
55
+ Lemma proof_of_exgcd_safety_wit_16_split_goal_1 : exgcd_safety_wit_16_split_goal_1.
56
+ Proof.
57
+ LLM_pre_process ltac:(int_auto).
58
+ assert (Zabs (a_pre ÷ b_pre * y_callee_v) <= 2147483647).
59
+ { rewrite Z.abs_mul.
60
+ rewrite <- Z.quot_abs by lia.
61
+ pose proof Z.quot_le_upper_bound (Zabs a_pre) (Zabs b_pre) 2147483647 ltac:(lia) ltac:(lia).
62
+ nia. }
63
+ repeat (split_pure_spatial || split_pures); try cancel; dump_pre_spatial; lia.
64
+ Qed.
65
+
66
+ Lemma proof_of_exgcd_safety_wit_16_split_goal_2 : exgcd_safety_wit_16_split_goal_2.
67
+ Proof.
68
+ LLM_pre_process ltac:(int_auto).
69
+ assert (Zabs (a_pre ÷ b_pre * y_callee_v) <= 2147483647).
70
+ { rewrite Z.abs_mul.
71
+ rewrite <- Z.quot_abs by lia.
72
+ pose proof Z.quot_le_upper_bound (Zabs a_pre) (Zabs b_pre) 2147483647 ltac:(lia) ltac:(lia).
73
+ nia. }
74
+ repeat (split_pure_spatial || split_pures); try cancel; dump_pre_spatial; lia.
75
+ Qed.
76
+
77
+ Lemma proof_of_exgcd_safety_wit_16 : exgcd_safety_wit_16.
78
+ Proof.
79
+ aggressive_pre_process.
80
+ - Goal_apply proof_of_exgcd_safety_wit_16_split_goal_1.
81
+ - Goal_apply proof_of_exgcd_safety_wit_16_split_goal_2.
82
+ Qed.
83
+
84
+ Lemma proof_of_exgcd_safety_wit_18_split_goal_1 : exgcd_safety_wit_18_split_goal_1.
85
+ Proof.
86
+ LLM_pre_process ltac:(int_auto).
87
+ pose proof exgcd_reduction a_pre b_pre x_callee_v y_callee_v PreH7 PreH5 PreH6.
88
+ pose proof Z_gcd_pos_l b_pre (a_pre % (b_pre)) PreH7.
89
+ assert (Zabs a_pre ÷ Zgcd b_pre (a_pre % (b_pre)) <= 2147483647).
90
+ { apply Z.quot_le_upper_bound; lia. }
91
+ repeat (split_pure_spatial || split_pures); try cancel; dump_pre_spatial; lia.
92
+ Qed.
93
+
94
+ Lemma proof_of_exgcd_safety_wit_18_split_goal_2 : exgcd_safety_wit_18_split_goal_2.
95
+ Proof.
96
+ LLM_pre_process ltac:(int_auto).
97
+ pose proof exgcd_reduction a_pre b_pre x_callee_v y_callee_v PreH7 PreH5 PreH6.
98
+ pose proof Z_gcd_pos_l b_pre (a_pre % (b_pre)) PreH7.
99
+ assert (Zabs a_pre ÷ Zgcd b_pre (a_pre % (b_pre)) <= 2147483647).
100
+ { apply Z.quot_le_upper_bound; lia. }
101
+ repeat (split_pure_spatial || split_pures); try cancel; dump_pre_spatial; lia.
102
+ Qed.
103
+
104
+ Lemma proof_of_exgcd_safety_wit_18 : exgcd_safety_wit_18.
105
+ Proof.
106
+ aggressive_pre_process.
107
+ - Goal_apply proof_of_exgcd_safety_wit_18_split_goal_1.
108
+ - Goal_apply proof_of_exgcd_safety_wit_18_split_goal_2.
109
+ Qed.
110
+
111
+ Lemma proof_of_exgcd_safety_wit_19_split_goal_1 : exgcd_safety_wit_19_split_goal_1.
112
+ Proof.
113
+ LLM_pre_process ltac:(int_auto).
114
+ pose proof Z_gcd_pos_l b_pre (a_pre % (b_pre)) PreH7.
115
+ assert (Zabs b_pre ÷ Zgcd b_pre (a_pre % (b_pre)) <= Zabs b_pre).
116
+ { apply Z.quot_le_upper_bound; nia. }
117
+ pose proof Z_abs_quot_rem a_pre b_pre PreH7.
118
+ assert (Zabs (a_pre ÷ b_pre * y_callee_v) <= Zabs a_pre).
119
+ { rewrite Z.abs_mul. nia. }
120
+ repeat (split_pure_spatial || split_pures); try cancel; dump_pre_spatial; lia.
121
+ Qed.
122
+
123
+ Lemma proof_of_exgcd_safety_wit_19_split_goal_2 : exgcd_safety_wit_19_split_goal_2.
124
+ Proof.
125
+ LLM_pre_process ltac:(int_auto).
126
+ pose proof Z_gcd_pos_l b_pre (a_pre % (b_pre)) PreH7.
127
+ assert (Zabs b_pre ÷ Zgcd b_pre (a_pre % (b_pre)) <= Zabs b_pre).
128
+ { apply Z.quot_le_upper_bound; nia. }
129
+ pose proof Z_abs_quot_rem a_pre b_pre PreH7.
130
+ assert (Zabs (a_pre ÷ b_pre * y_callee_v) <= Zabs a_pre).
131
+ { rewrite Z.abs_mul. nia. }
132
+ repeat (split_pure_spatial || split_pures); try cancel; dump_pre_spatial; lia.
133
+ Qed.
134
+
135
+ Lemma proof_of_exgcd_safety_wit_19 : exgcd_safety_wit_19.
136
+ Proof.
137
+ aggressive_pre_process.
138
+ - Goal_apply proof_of_exgcd_safety_wit_19_split_goal_1.
139
+ - Goal_apply proof_of_exgcd_safety_wit_19_split_goal_2.
140
+ Qed.
141
+
142
+ Lemma proof_of_exgcd_return_wit_1_split_goal_1 : exgcd_return_wit_1_split_goal_1.
143
+ Proof.
144
+ unfold exgcd_return_wit_1_split_goal_1; intros.
145
+ subst y_callee_v. lia.
146
+ Qed.
147
+
148
+ Lemma proof_of_exgcd_return_wit_1_split_goal_2 : exgcd_return_wit_1_split_goal_2.
149
+ Proof.
150
+ unfold exgcd_return_wit_1_split_goal_2; intros.
151
+ subst y_callee_v.
152
+ rewrite <- exgcd_gcd_step by auto.
153
+ nia.
154
+ Qed.
155
+
156
+ Lemma proof_of_exgcd_return_wit_1_split_goal_3 : exgcd_return_wit_1_split_goal_3.
157
+ Proof.
158
+ unfold exgcd_return_wit_1_split_goal_3; intros.
159
+ subst retval.
160
+ apply exgcd_gcd_step; auto.
161
+ Qed.
162
+
163
+ Lemma proof_of_exgcd_return_wit_1 : exgcd_return_wit_1.
164
+ Proof.
165
+ aggressive_pre_process.
166
+ - Goal_apply proof_of_exgcd_return_wit_1_split_goal_1.
167
+ - Goal_apply proof_of_exgcd_return_wit_1_split_goal_2.
168
+ - Goal_apply proof_of_exgcd_return_wit_1_split_goal_3.
169
+ Qed.
170
+
171
+ Lemma proof_of_exgcd_return_wit_2_split_goal_1 : exgcd_return_wit_2_split_goal_1.
172
+ Proof.
173
+ unfold exgcd_return_wit_2_split_goal_1; intros.
174
+ rewrite (exgcd_gcd_last_rem a_pre b_pre) by auto.
175
+ pose proof Z.rem_bound_abs a_pre b_pre PreH7.
176
+ replace (0 - a_pre ÷ b_pre * y_callee_v) with (-(a_pre ÷ b_pre * y_callee_v)) by lia.
177
+ rewrite Z.abs_opp, Z.abs_mul.
178
+ apply (Z.le_trans _ (Zabs (a_pre ÷ b_pre))); [nia |].
179
+ rewrite <- (Z.quot_abs _ _ PreH7).
180
+ pose proof Z.abs_nonneg a_pre.
181
+ apply Z.quot_le_compat_l; lia.
182
+ Qed.
183
+
184
+ Lemma proof_of_exgcd_return_wit_2_split_goal_2 : exgcd_return_wit_2_split_goal_2.
185
+ Proof.
186
+ unfold exgcd_return_wit_2_split_goal_2; intros.
187
+ rewrite (exgcd_gcd_last_rem a_pre b_pre) by auto.
188
+ pose proof Z.rem_bound_abs a_pre b_pre PreH7.
189
+ apply (Z.le_trans _ (Zabs b_pre ÷ Zabs b_pre)).
190
+ { rewrite Z.quot_same; lia. }
191
+ apply Z.quot_le_compat_l; lia.
192
+ Qed.
193
+
194
+ Lemma proof_of_exgcd_return_wit_2_split_goal_3 : exgcd_return_wit_2_split_goal_3.
195
+ Proof.
196
+ unfold exgcd_return_wit_2_split_goal_3; intros.
197
+ subst x_callee_v.
198
+ rewrite <- exgcd_gcd_step by auto.
199
+ rewrite <- PreH2.
200
+ pose proof Z.quot_rem a_pre b_pre PreH7.
201
+ nia.
202
+ Qed.
203
+
204
+ Lemma proof_of_exgcd_return_wit_2_split_goal_4 : exgcd_return_wit_2_split_goal_4.
205
+ Proof.
206
+ unfold exgcd_return_wit_2_split_goal_4; intros.
207
+ subst retval.
208
+ apply exgcd_gcd_step; auto.
209
+ Qed.
210
+
211
+ Lemma proof_of_exgcd_return_wit_2 : exgcd_return_wit_2.
212
+ Proof.
213
+ aggressive_pre_process.
214
+ - Goal_apply proof_of_exgcd_return_wit_2_split_goal_1.
215
+ - Goal_apply proof_of_exgcd_return_wit_2_split_goal_2.
216
+ - Goal_apply proof_of_exgcd_return_wit_2_split_goal_3.
217
+ - Goal_apply proof_of_exgcd_return_wit_2_split_goal_4.
218
+ Qed.
219
+
220
+ Lemma proof_of_exgcd_return_wit_3_split_goal_1 : exgcd_return_wit_3_split_goal_1.
221
+ Proof.
222
+ unfold exgcd_return_wit_3_split_goal_1; intros.
223
+ rewrite <- exgcd_gcd_step by auto.
224
+ apply exgcd_reduction; auto.
225
+ Qed.
226
+
227
+ Lemma proof_of_exgcd_return_wit_3_split_goal_2 : exgcd_return_wit_3_split_goal_2.
228
+ Proof.
229
+ unfold exgcd_return_wit_3_split_goal_2; intros.
230
+ rewrite <- exgcd_gcd_step by auto.
231
+ exact PreH6.
232
+ Qed.
233
+
234
+ Lemma proof_of_exgcd_return_wit_3_split_goal_3 : exgcd_return_wit_3_split_goal_3.
235
+ Proof.
236
+ unfold exgcd_return_wit_3_split_goal_3; intros.
237
+ rewrite <- exgcd_gcd_step by auto.
238
+ rewrite <- PreH2.
239
+ pose proof Z.quot_rem a_pre b_pre PreH7.
240
+ nia.
241
+ Qed.
242
+
243
+ Lemma proof_of_exgcd_return_wit_3_split_goal_4 : exgcd_return_wit_3_split_goal_4.
244
+ Proof.
245
+ unfold exgcd_return_wit_3_split_goal_4; intros.
246
+ subst retval.
247
+ apply exgcd_gcd_step; auto.
248
+ Qed.
249
+
250
+ Lemma proof_of_exgcd_return_wit_3 : exgcd_return_wit_3.
251
+ Proof.
252
+ aggressive_pre_process.
253
+ - Goal_apply proof_of_exgcd_return_wit_3_split_goal_1.
254
+ - Goal_apply proof_of_exgcd_return_wit_3_split_goal_2.
255
+ - Goal_apply proof_of_exgcd_return_wit_3_split_goal_3.
256
+ - Goal_apply proof_of_exgcd_return_wit_3_split_goal_4.
257
+ Qed.
258
+
259
+ Lemma proof_of_exgcd_return_wit_4_split_goal_1 : exgcd_return_wit_4_split_goal_1.
260
+ Proof.
261
+ unfold exgcd_return_wit_4_split_goal_1; intros.
262
+ subst; rewrite ?Z.gcd_0_r; simpl; lia.
263
+ Qed.
264
+
265
+ Lemma proof_of_exgcd_return_wit_4_split_goal_2 : exgcd_return_wit_4_split_goal_2.
266
+ Proof.
267
+ unfold exgcd_return_wit_4_split_goal_2; intros.
268
+ subst; rewrite ?Z.gcd_0_r; simpl; lia.
269
+ Qed.
270
+
271
+ Lemma proof_of_exgcd_return_wit_4_split_goal_3 : exgcd_return_wit_4_split_goal_3.
272
+ Proof.
273
+ unfold exgcd_return_wit_4_split_goal_3; intros.
274
+ subst; rewrite ?Z.gcd_0_r; simpl; lia.
275
+ Qed.
276
+
277
+ Lemma proof_of_exgcd_return_wit_4 : exgcd_return_wit_4.
278
+ Proof.
279
+ aggressive_pre_process.
280
+ - Goal_apply proof_of_exgcd_return_wit_4_split_goal_1.
281
+ - Goal_apply proof_of_exgcd_return_wit_4_split_goal_2.
282
+ - Goal_apply proof_of_exgcd_return_wit_4_split_goal_3.
283
+ Qed.
284
+
285
+ Lemma proof_of_exgcd_return_wit_5_split_goal_1 : exgcd_return_wit_5_split_goal_1.
286
+ Proof.
287
+ unfold exgcd_return_wit_5_split_goal_1; intros.
288
+ subst; rewrite ?Z.gcd_0_r; simpl; lia.
289
+ Qed.
290
+
291
+ Lemma proof_of_exgcd_return_wit_5_split_goal_2 : exgcd_return_wit_5_split_goal_2.
292
+ Proof.
293
+ unfold exgcd_return_wit_5_split_goal_2; intros.
294
+ subst; rewrite ?Z.gcd_0_r; simpl; lia.
295
+ Qed.
296
+
297
+ Lemma proof_of_exgcd_return_wit_5_split_goal_3 : exgcd_return_wit_5_split_goal_3.
298
+ Proof.
299
+ unfold exgcd_return_wit_5_split_goal_3; intros.
300
+ subst; rewrite ?Z.gcd_0_r; simpl; lia.
301
+ Qed.
302
+
303
+ Lemma proof_of_exgcd_return_wit_5 : exgcd_return_wit_5.
304
+ Proof.
305
+ aggressive_pre_process.
306
+ - Goal_apply proof_of_exgcd_return_wit_5_split_goal_1.
307
+ - Goal_apply proof_of_exgcd_return_wit_5_split_goal_2.
308
+ - Goal_apply proof_of_exgcd_return_wit_5_split_goal_3.
309
+ Qed.
310
+
311
+ Lemma proof_of_exgcd_return_wit_6_split_goal_1 : exgcd_return_wit_6_split_goal_1.
312
+ Proof.
313
+ unfold exgcd_return_wit_6_split_goal_1; intros.
314
+ subst; rewrite ?Z.gcd_0_r; simpl; lia.
315
+ Qed.
316
+
317
+ Lemma proof_of_exgcd_return_wit_6_split_goal_2 : exgcd_return_wit_6_split_goal_2.
318
+ Proof.
319
+ unfold exgcd_return_wit_6_split_goal_2; intros.
320
+ subst; rewrite ?Z.gcd_0_r; simpl; lia.
321
+ Qed.
322
+
323
+ Lemma proof_of_exgcd_return_wit_6_split_goal_3 : exgcd_return_wit_6_split_goal_3.
324
+ Proof.
325
+ unfold exgcd_return_wit_6_split_goal_3; intros.
326
+ subst; rewrite ?Z.gcd_0_r; simpl; lia.
327
+ Qed.
328
+
329
+ Lemma proof_of_exgcd_return_wit_6 : exgcd_return_wit_6.
330
+ Proof.
331
+ aggressive_pre_process.
332
+ - Goal_apply proof_of_exgcd_return_wit_6_split_goal_1.
333
+ - Goal_apply proof_of_exgcd_return_wit_6_split_goal_2.
334
+ - Goal_apply proof_of_exgcd_return_wit_6_split_goal_3.
335
+ Qed.
336
+
337
+ Lemma proof_of_exgcd_partial_solve_wit_4_pure_split_goal_1 : exgcd_partial_solve_wit_4_pure_split_goal_1.
338
+ Proof.
339
+ LLM_pre_process ltac:(int_auto).
340
+ pose proof Z.rem_bound_abs a_pre b_pre PreH3.
341
+ repeat (split_pure_spatial || split_pures); try cancel; dump_pre_spatial; lia.
342
+ Qed.
343
+
344
+ Lemma proof_of_exgcd_partial_solve_wit_4_pure_split_goal_2 : exgcd_partial_solve_wit_4_pure_split_goal_2.
345
+ Proof.
346
+ LLM_pre_process ltac:(int_auto).
347
+ pose proof Z.rem_bound_abs a_pre b_pre PreH3.
348
+ repeat (split_pure_spatial || split_pures); try cancel; dump_pre_spatial; lia.
349
+ Qed.
350
+
351
+ Lemma proof_of_exgcd_partial_solve_wit_4_pure : exgcd_partial_solve_wit_4_pure.
352
+ Proof.
353
+ aggressive_pre_process.
354
+ - Goal_apply proof_of_exgcd_partial_solve_wit_4_pure_split_goal_1.
355
+ - Goal_apply proof_of_exgcd_partial_solve_wit_4_pure_split_goal_2.
356
+ Qed.
357
+
358
+ Lemma proof_of_exgcd_derive_Inter_by_Proof : exgcd_derive_Inter_by_Proof.
359
+ Proof.
360
+ LLM_pre_process ltac:(int_auto).
361
+ split_pure_spatial.
362
+ - cancel (x_pre # Int |->_). cancel (y_pre # Int |->_).
363
+ apply derivable1_wand_sepcon_adjoint.
364
+ eapply derivable1_trans. { apply derivable1_sepcon_comm. }
365
+ eapply derivable1_trans. { apply derivable1_sepcon_emp_l. }
366
+ repeat apply derivable1_orp_elim.
367
+ all: Intros y x r; Exists y x r.
368
+ all: split_pure_spatial; [cancel | split_pures; dump_pre_spatial; auto].
369
+ - split_pures; dump_pre_spatial; lia.
370
+ Qed.
371
+
372
+ Lemma proof_of_abs_return_wit_1_split_goal_1 : abs_return_wit_1_split_goal_1.
373
+ Proof.
374
+ unfold abs_return_wit_1_split_goal_1; intros.
375
+ lia.
376
+ Qed.
377
+
378
+ Lemma proof_of_abs_return_wit_1 : abs_return_wit_1.
379
+ Proof.
380
+ aggressive_pre_process.
381
+ Goal_apply proof_of_abs_return_wit_1_split_goal_1.
382
+ Qed.
383
+
384
+ Lemma proof_of_abs_return_wit_2_split_goal_1 : abs_return_wit_2_split_goal_1.
385
+ Proof.
386
+ unfold abs_return_wit_2_split_goal_1; intros.
387
+ lia.
388
+ Qed.
389
+
390
+ Lemma proof_of_abs_return_wit_2 : abs_return_wit_2.
391
+ Proof.
392
+ aggressive_pre_process.
393
+ Goal_apply proof_of_abs_return_wit_2_split_goal_1.
394
+ Qed.
benchmarks/Algorithms/exgcd/rocq/groundtruth/proof_lib.v ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (* Supporting lemmas for exgcd: Bezout-coefficient bounds across one Euclid step. *)
2
+ Require Import Coq.ZArith.ZArith.
3
+ Require Import Coq.micromega.Psatz.
4
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap.
5
+ From SimpleC.SL Require Import Mem SeparationLogic.
6
+ Local Open Scope Z_scope.
7
+
8
+ Lemma Zabs_triangle: forall a b, Zabs(a - b) <= Zabs a + Zabs b.
9
+ Proof. lia. Qed.
10
+
11
+ Lemma Z_gcd_divide_l: forall a b, exists a', a = a' * (Zgcd a b).
12
+ Proof.
13
+ intros.
14
+ pose proof Z.gcd_divide_l a b.
15
+ unfold Z.divide in H.
16
+ exact H.
17
+ Qed.
18
+
19
+ Lemma Z_gcd_divide_r: forall a b, exists b', b = b' * (Zgcd a b).
20
+ Proof.
21
+ intros.
22
+ pose proof Z.gcd_divide_r a b.
23
+ unfold Z.divide in H.
24
+ exact H.
25
+ Qed.
26
+
27
+ Lemma Z_abs_quot_rem:
28
+ forall a b: Z, b <> 0 -> Zabs (a % (b)) + Zabs (a ÷ b) * Zabs b = Zabs a.
29
+ Proof.
30
+ intros.
31
+ assert(Zabs b <> 0) by lia.
32
+ pose proof Z.quot_rem (Zabs a) (Zabs b) H0.
33
+ rewrite <- Z.quot_abs. 2 : lia.
34
+ rewrite <- Z.rem_abs. 2 : lia.
35
+ lia.
36
+ Qed.
37
+
38
+ Lemma Z_gcd_pos_l:
39
+ forall a b, a <> 0 -> Zgcd a b > 0.
40
+ Proof.
41
+ intros.
42
+ assert(Zgcd a b <> 0). {
43
+ intros. intro.
44
+ pose proof Z.gcd_eq_0_l a b.
45
+ lia.
46
+ }
47
+ pose proof Z.gcd_nonneg a b.
48
+ lia.
49
+ Qed.
50
+
51
+ Lemma Z_gcd_pos_r:
52
+ forall a b, b <> 0 -> Zgcd a b > 0.
53
+ Proof.
54
+ intros.
55
+ assert(Zgcd a b <> 0). {
56
+ intros. intro.
57
+ pose proof Z.gcd_eq_0_r a b.
58
+ lia.
59
+ }
60
+ pose proof Z.gcd_nonneg a b.
61
+ lia.
62
+ Qed.
63
+
64
+ (* Proof goal:
65
+ |x'| <= |(a % b) / g|
66
+ |y'| <= |b / g|
67
+ x = y'
68
+ y = x' - (a / b) * y'
69
+ ===>
70
+ |x| <= |b / g|
71
+ |y| <= |a / g|
72
+
73
+ informal Proof:
74
+ |y| = |x' - (a / b) * y'|
75
+ <= |x'| + |a / b| * |y'|
76
+ <= |(a % b) / g| + |a / b| * |b / g|
77
+ = |(|a % b| + |a / b| * |b|) / g| (since g | (a % b) and g | b)
78
+ = |a / g|
79
+ *)
80
+
81
+ Lemma exgcd_reduction_pre:
82
+ forall a b y,
83
+ b <> 0 ->
84
+ Zabs y <= Zabs b ÷ Zgcd b (a % (b)) ->
85
+ Zabs (a ÷ b * y) <= Zabs (a ÷ b) * (Zabs b ÷ Zgcd b (a % (b))).
86
+ Proof.
87
+ intros.
88
+ rewrite Z.abs_mul. nia.
89
+ Qed.
90
+
91
+ Lemma exgcd_reduction':
92
+ forall a b x y,
93
+ b <> 0 ->
94
+ Zabs x <= Zabs (a % (b)) ÷ Zgcd b (a % (b)) ->
95
+ Zabs y <= Zabs b ÷ Zgcd b (a % (b)) ->
96
+ Zabs (x) + Zabs (a ÷ b * y) <= Zabs a ÷ Zgcd b (a % (b)).
97
+ Proof.
98
+ intros.
99
+ eapply Z.le_trans. 1: apply (Zplus_le_compat_r _ _ _ H0).
100
+ pose proof exgcd_reduction_pre a b y H H1.
101
+ eapply Z.le_trans. 1: apply (Zplus_le_compat_l _ _ _ H2).
102
+ replace (Zabs (a % (b)) ÷ Zgcd b (a % (b)) +
103
+ Zabs (a ÷ b) * (Zabs b ÷ Zgcd b (a % (b))))
104
+ with (Zabs(((Zabs(a % (b))) + Zabs(a ÷ b) * Zabs(b)) ÷ Zgcd b (a % (b)))).
105
+ 2: {
106
+ replace (Zgcd b (a % (b))) with (Zgcd a b) in *.
107
+ 2: { rewrite Z.gcd_comm. rewrite <- Z.gcd_rem. rewrite Z.gcd_comm. lia. lia. }
108
+ pose proof Z_gcd_divide_l a b as H_adiv.
109
+ pose proof Z_gcd_divide_r a b as H_bdiv.
110
+ destruct H_adiv as [a' H_adiv].
111
+ destruct H_bdiv as [b' H_bdiv].
112
+ pose proof Z_gcd_pos_r a b H.
113
+ set (g := Zgcd a b) in *.
114
+ replace (a % (b)) with (a' % (b') * g).
115
+ 2: { rewrite H_adiv, H_bdiv. rewrite Zquot.Zmult_rem_distr_r. reflexivity. }
116
+ replace (a ÷ b) with (a' ÷ b').
117
+ 2: { rewrite H_adiv, H_bdiv. rewrite Zquot.Zquot_mult_cancel_r; lia. }
118
+ replace (Zabs (a' ÷ b') * (Zabs b ÷ g)) with (Zabs (a' ÷ b') * Zabs b ÷ g).
119
+ 2: { rewrite Z.divide_quot_mul_exact; try lia.
120
+ unfold Z.divide.
121
+ exists (Z.abs b').
122
+ rewrite H_bdiv.
123
+ replace g with (Zabs g) at 2 by lia.
124
+ apply Z.abs_mul. }
125
+ replace (Zabs ((Zabs (a' % (b') * g) + Zabs (a' ÷ b') * Zabs b) ÷ g))
126
+ with ((Zabs (a' % (b') * g) + Zabs (a' ÷ b') * Zabs b) ÷ g).
127
+ 2: {
128
+ pose proof Z.abs_eq_iff ((Zabs (a' % (b') * g) + Zabs (a' ÷ b') * Zabs b) ÷ g) as H_abspos.
129
+ rewrite (proj2 H_abspos). 1 : reflexivity.
130
+ assert((Zabs (a' % (b') * g) + Zabs (a' ÷ b') * Zabs b) >= 0) by lia.
131
+ apply Z.quot_pos; lia.
132
+ }
133
+ replace (Zabs b) with (Zabs b' * g) by lia.
134
+ rewrite Z.mul_assoc.
135
+ rewrite Zquot.Z_quot_plus.
136
+ + rewrite Z.quot_mul; lia.
137
+ + lia.
138
+ + lia.
139
+ }
140
+ pose proof Z_gcd_pos_l b (a % (b)) H.
141
+ rewrite <- Z.quot_abs by ltac:(lia).
142
+ rewrite Z_abs_quot_rem by ltac:(lia).
143
+ rewrite Z.abs_idemp.
144
+ replace (Zabs (Zgcd b (a % (b)))) with (Zgcd b (a % (b))) by lia.
145
+ lia.
146
+ Qed.
147
+
148
+ Lemma exgcd_reduction:
149
+ forall a b x y,
150
+ b <> 0 ->
151
+ Zabs x <= Zabs (a % (b)) ÷ Zgcd b (a % (b)) ->
152
+ Zabs y <= Zabs b ÷ Zgcd b (a % (b)) ->
153
+ Zabs (x - a ÷ b * y) <= Zabs a ÷ Zgcd b (a % (b)).
154
+ Proof.
155
+ intros.
156
+ eapply Z.le_trans. 1: apply Zabs_triangle.
157
+ apply (exgcd_reduction' _ _ _ _ H H0 H1).
158
+ Qed.
159
+
160
+
161
+ (* One Euclid step preserves the gcd. *)
162
+ Lemma exgcd_gcd_step:
163
+ forall a b, b <> 0 -> Zgcd b (a % (b)) = Zgcd a b.
164
+ Proof.
165
+ intros.
166
+ rewrite Z.gcd_comm, Z.gcd_rem by auto.
167
+ apply Z.gcd_comm.
168
+ Qed.
169
+
170
+ (* When the remainder divides the divisor, it is the gcd up to sign. *)
171
+ Lemma exgcd_gcd_last_rem:
172
+ forall a b, b <> 0 -> a % (b) <> 0 -> b % (a % (b)) = 0 ->
173
+ Zgcd a b = Zabs (a % (b)).
174
+ Proof.
175
+ intros.
176
+ rewrite <- exgcd_gcd_step by auto.
177
+ rewrite Z.gcd_comm.
178
+ rewrite <- (Z.gcd_rem b (a % (b))) by auto.
179
+ rewrite H1.
180
+ apply Z.gcd_0_l.
181
+ Qed.
benchmarks/Algorithms/exgcd/rocq/solution_annotated.c ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*@ Extern Coq (Zgcd: Z -> Z -> Z)
2
+ (Zabs: Z -> Z) */
3
+
4
+ int abs(int x)
5
+ /*@ Require
6
+ INT_MIN < x && x <= INT_MAX && emp
7
+ Ensure
8
+ __return == Zabs(x) && emp
9
+ */
10
+ {
11
+ if (x < 0) {
12
+ return -x;
13
+ }
14
+ return x;
15
+ }
16
+
17
+ /* The public contract, derived from the stronger one the body is verified against. */
18
+ int exgcd(int a, int b, int *x, int *y)
19
+ /*@ Inter <= Proof
20
+ Require
21
+ INT_MIN < a && a <= INT_MAX && INT_MIN < b && b <= INT_MAX &&
22
+ has_int_permission(x) * has_int_permission(y)
23
+ Ensure
24
+ __return == Zgcd(a, b) && a * (*x) + b * (*y) == Zgcd(a, b)
25
+ */
26
+ ;
27
+
28
+ /* The coefficient bounds keep the recursive update free of overflow. */
29
+ int exgcd(int a, int b, int *x, int *y)
30
+ /*@ Proof
31
+ Require
32
+ INT_MIN < a && a <= INT_MAX && INT_MIN < b && b <= INT_MAX &&
33
+ has_int_permission(x) * has_int_permission(y)
34
+ Ensure
35
+ (__return == Zgcd(a, b) && a * (*x) + b * (*y) == Zgcd(a, b) && b == 0 && Zabs(*x) <= 1 && (*y) == 0) ||
36
+ (__return == Zgcd(a, b) && a * (*x) + b * (*y) == Zgcd(a, b) && b != 0 && a % b == 0 && (*x) == 0 && Zabs(*y) <= 1) ||
37
+ (__return == Zgcd(a, b) && a * (*x) + b * (*y) == Zgcd(a, b) && b != 0 && a % b != 0 &&
38
+ Zabs(*x) <= Zabs(b) / Zgcd(a, b) && Zabs(*y) <= Zabs(a) / Zgcd(a, b))
39
+ */
40
+ {
41
+ if (b == 0) {
42
+ if (a < 0) {
43
+ *x = -1;
44
+ } else if (a == 0) {
45
+ *x = 0;
46
+ } else {
47
+ *x = 1;
48
+ }
49
+ *y = 0;
50
+ return abs(a);
51
+ }
52
+ int g = exgcd(b, a % b, y, x);
53
+ *y -= (a / b) * (*x);
54
+ return g;
55
+ }
benchmarks/Algorithms/exgcd/rocq/solution_spec.c ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*@ Extern Coq (Zgcd: Z -> Z -> Z) */
2
+
3
+ int abs(int x)
4
+ {
5
+ if (x < 0) {
6
+ return -x;
7
+ }
8
+ return x;
9
+ }
10
+
11
+ int exgcd(int a, int b, int *x, int *y)
12
+ /*@ Require
13
+ INT_MIN < a && a <= INT_MAX && INT_MIN < b && b <= INT_MAX &&
14
+ has_int_permission(x) * has_int_permission(y)
15
+ Ensure
16
+ __return == Zgcd(a, b) && a * (*x) + b * (*y) == Zgcd(a, b)
17
+ */
18
+ {
19
+ if (b == 0) {
20
+ if (a < 0) {
21
+ *x = -1;
22
+ } else if (a == 0) {
23
+ *x = 0;
24
+ } else {
25
+ *x = 1;
26
+ }
27
+ *y = 0;
28
+ return abs(a);
29
+ }
30
+ int g = exgcd(b, a % b, y, x);
31
+ *y -= (a / b) * (*x);
32
+ return g;
33
+ }
benchmarks/Algorithms/exgcd/solution.c ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ int abs(int x)
2
+ {
3
+ if (x < 0) {
4
+ return -x;
5
+ }
6
+ return x;
7
+ }
8
+
9
+ int exgcd(int a, int b, int *x, int *y)
10
+ {
11
+ if (b == 0) {
12
+ if (a < 0) {
13
+ *x = -1;
14
+ } else if (a == 0) {
15
+ *x = 0;
16
+ } else {
17
+ *x = 1;
18
+ }
19
+ *y = 0;
20
+ return abs(a);
21
+ }
22
+ int g = exgcd(b, a % b, y, x);
23
+ *y -= (a / b) * (*x);
24
+ return g;
25
+ }
benchmarks/Algorithms/gcd/manifest.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": "gcd",
3
+ "source": {
4
+ "dataset": "classical_algorithm",
5
+ "problem_id": "gcd",
6
+ "title": "Euclidean Greatest Common Divisor",
7
+ "tags": [
8
+ "gcd",
9
+ "euclid",
10
+ "recursion"
11
+ ]
12
+ },
13
+ "stratification": {
14
+ "band": "unclassified",
15
+ "output_mode": "COUNTOPT",
16
+ "interactive": false,
17
+ "multi_test": false
18
+ }
19
+ }
benchmarks/Algorithms/gcd/problem.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Euclidean Greatest Common Divisor
2
+
3
+ ## Description
4
+
5
+ Compute the greatest common divisor of two integers with the recursive Euclidean algorithm.
6
+
7
+ ## Input
8
+
9
+ The function receives two integers $x$ and $y$ ($-2^{31} < x, y \le 2^{31} - 1$).
10
+
11
+ ## Output
12
+
13
+ Return $\gcd(x, y)$, the non-negative greatest common divisor, with $\gcd(x, 0) = |x|$.
benchmarks/Algorithms/gcd/rocq/groundtruth/gcd_goal.v ADDED
@@ -0,0 +1,241 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Require Import Coq.ZArith.ZArith.
2
+ Require Import Coq.Bool.Bool.
3
+ Require Import Coq.Strings.String.
4
+ Require Import Coq.Strings.Ascii.
5
+ Require Import Coq.Lists.List.
6
+ Require Import Coq.Classes.RelationClasses.
7
+ Require Import Coq.Classes.Morphisms.
8
+ Require Import Coq.micromega.Psatz.
9
+ Require Import Coq.Sorting.Permutation.
10
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap.
11
+ Require Import SetsClass.SetsClass. Import SetsNotation.
12
+ From SimpleC.SL Require Import Mem SeparationLogic.
13
+ Require Import Logic.LogicGenerator.demo932.Interface.
14
+ Local Open Scope Z_scope.
15
+ Local Open Scope sets.
16
+ Local Open Scope string_scope.
17
+ Local Open Scope list.
18
+ Import naive_C_Rules.
19
+ Local Open Scope sac.
20
+
21
+ (*----- Function abs -----*)
22
+
23
+ Definition abs_safety_wit_1 :=
24
+ forall (x_pre: Z) (PreH1 : (INT_MIN < x_pre)) (PreH2 : (x_pre <= INT_MAX)) ,
25
+ ((( &( "x" ) )) # Int |-> x_pre)
26
+ |--
27
+ “ (0 <= INT_MAX) ”
28
+ && “ ((INT_MIN) <= 0) ”
29
+ .
30
+
31
+ Definition abs_safety_wit_2 :=
32
+ forall (x_pre: Z) (PreH1 : (x_pre < 0)) (PreH2 : (INT_MIN < x_pre)) (PreH3 : (x_pre <= INT_MAX)) ,
33
+ ((( &( "x" ) )) # Int |-> x_pre)
34
+ |--
35
+ “ (x_pre <> (INT_MIN)) ”
36
+ .
37
+
38
+ Definition abs_return_wit_1 :=
39
+ (
40
+ forall (x_pre: Z) (PreH1 : (x_pre >= 0)) (PreH2 : (INT_MIN < x_pre)) (PreH3 : (x_pre <= INT_MAX)) ,
41
+ TT && emp
42
+ |--
43
+ “ (x_pre = (Zabs (x_pre))) ”
44
+ && emp
45
+ ) \/
46
+ (
47
+ forall (x_pre: Z) (PreH1 : (x_pre >= 0)) (PreH2 : (INT_MIN < x_pre)) (PreH3 : (x_pre <= INT_MAX)) ,
48
+ TT && emp
49
+ |--
50
+ “ (x_pre = (Zabs (x_pre))) ”
51
+ && emp
52
+ ).
53
+
54
+ Definition abs_return_wit_1_split_goal_1 :=
55
+ forall (x_pre: Z) (PreH1 : (x_pre >= 0)) (PreH2 : (INT_MIN < x_pre)) (PreH3 : (x_pre <= INT_MAX)) ,
56
+ (x_pre = (Zabs (x_pre)))
57
+ .
58
+
59
+ Definition abs_return_wit_2 :=
60
+ (
61
+ forall (x_pre: Z) (PreH1 : (x_pre < 0)) (PreH2 : (INT_MIN < x_pre)) (PreH3 : (x_pre <= INT_MAX)) ,
62
+ TT && emp
63
+ |--
64
+ “ ((-x_pre) = (Zabs (x_pre))) ”
65
+ && emp
66
+ ) \/
67
+ (
68
+ forall (x_pre: Z) (PreH1 : (x_pre < 0)) (PreH2 : (INT_MIN < x_pre)) (PreH3 : (x_pre <= INT_MAX)) ,
69
+ TT && emp
70
+ |--
71
+ “ ((-x_pre) = (Zabs (x_pre))) ”
72
+ && emp
73
+ ).
74
+
75
+ Definition abs_return_wit_2_split_goal_1 :=
76
+ forall (x_pre: Z) (PreH1 : (x_pre < 0)) (PreH2 : (INT_MIN < x_pre)) (PreH3 : (x_pre <= INT_MAX)) ,
77
+ ((-x_pre) = (Zabs (x_pre)))
78
+ .
79
+
80
+ (*----- Function gcd -----*)
81
+
82
+ Definition gcd_safety_wit_1 :=
83
+ forall (y_pre: Z) (x_pre: Z) (PreH1 : (x_pre <= INT_MAX)) (PreH2 : (y_pre <= INT_MAX)) (PreH3 : (y_pre >= INT_MIN)) (PreH4 : (INT_MIN < x_pre)) (PreH5 : (INT_MIN < y_pre)) ,
84
+ ((( &( "x" ) )) # Int |-> x_pre)
85
+ ** ((( &( "y" ) )) # Int |-> y_pre)
86
+ |--
87
+ “ (0 <= INT_MAX) ”
88
+ && “ ((INT_MIN) <= 0) ”
89
+ .
90
+
91
+ Definition gcd_safety_wit_2 :=
92
+ forall (y_pre: Z) (x_pre: Z) (PreH1 : (y_pre <> 0)) (PreH2 : (x_pre <= INT_MAX)) (PreH3 : (y_pre <= INT_MAX)) (PreH4 : (y_pre >= INT_MIN)) (PreH5 : (INT_MIN < x_pre)) (PreH6 : (INT_MIN < y_pre)) ,
93
+ ((( &( "x" ) )) # Int |-> x_pre)
94
+ ** ((( &( "y" ) )) # Int |-> y_pre)
95
+ |--
96
+ “ ((x_pre <> (INT_MIN)) \/ (y_pre <> (-1))) ”
97
+ && “ (y_pre <> 0) ”
98
+ .
99
+
100
+ Definition gcd_entail_wit_1 :=
101
+ forall (y_pre: Z) (x_pre: Z) (PreH1 : (INT_MIN < x_pre)) (PreH2 : (INT_MIN < y_pre)) ,
102
+ ((( &( "x" ) )) # Int |-> x_pre)
103
+ ** ((( &( "y" ) )) # Int |-> y_pre)
104
+ |--
105
+ “ (x_pre <= INT_MAX) ”
106
+ && “ (y_pre <= INT_MAX) ”
107
+ && “ (y_pre >= INT_MIN) ”
108
+ && “ (INT_MIN < x_pre) ”
109
+ && “ (INT_MIN < y_pre) ”
110
+ && ((( &( "x" ) )) # Int |-> x_pre)
111
+ ** ((( &( "y" ) )) # Int |-> y_pre)
112
+ .
113
+
114
+ Definition gcd_return_wit_1 :=
115
+ (
116
+ forall (y_pre: Z) (x_pre: Z) (retval: Z) (PreH1 : (retval = (Zgcd (y_pre) ((x_pre % ( y_pre ) ))))) (PreH2 : (y_pre <> 0)) (PreH3 : (x_pre <= INT_MAX)) (PreH4 : (y_pre <= INT_MAX)) (PreH5 : (y_pre >= INT_MIN)) (PreH6 : (INT_MIN < x_pre)) (PreH7 : (INT_MIN < y_pre)) ,
117
+ TT && emp
118
+ |--
119
+ “ (retval = (Zgcd (x_pre) (y_pre))) ”
120
+ && emp
121
+ ) \/
122
+ (
123
+ forall (y_pre: Z) (x_pre: Z) (retval: Z) (PreH1 : (retval = (Zgcd (y_pre) ((x_pre % ( y_pre ) ))))) (PreH2 : (y_pre <> 0)) (PreH3 : (x_pre <= INT_MAX)) (PreH4 : (y_pre <= INT_MAX)) (PreH5 : (y_pre >= INT_MIN)) (PreH6 : (INT_MIN < x_pre)) (PreH7 : (INT_MIN < y_pre)) ,
124
+ TT && emp
125
+ |--
126
+ “ (retval = (Zgcd (x_pre) (y_pre))) ”
127
+ && emp
128
+ ).
129
+
130
+ Definition gcd_return_wit_1_split_goal_1 :=
131
+ forall (y_pre: Z) (x_pre: Z) (retval: Z) (PreH1 : (retval = (Zgcd (y_pre) ((x_pre % ( y_pre ) ))))) (PreH2 : (y_pre <> 0)) (PreH3 : (x_pre <= INT_MAX)) (PreH4 : (y_pre <= INT_MAX)) (PreH5 : (y_pre >= INT_MIN)) (PreH6 : (INT_MIN < x_pre)) (PreH7 : (INT_MIN < y_pre)) ,
132
+ (retval = (Zgcd (x_pre) (y_pre)))
133
+ .
134
+
135
+ Definition gcd_return_wit_2 :=
136
+ (
137
+ forall (y_pre: Z) (x_pre: Z) (retval: Z) (PreH1 : (retval = (Zabs (x_pre)))) (PreH2 : (y_pre = 0)) (PreH3 : (x_pre <= INT_MAX)) (PreH4 : (y_pre <= INT_MAX)) (PreH5 : (y_pre >= INT_MIN)) (PreH6 : (INT_MIN < x_pre)) (PreH7 : (INT_MIN < y_pre)) ,
138
+ TT && emp
139
+ |--
140
+ “ (retval = (Zgcd (x_pre) (y_pre))) ”
141
+ && emp
142
+ ) \/
143
+ (
144
+ forall (y_pre: Z) (x_pre: Z) (retval: Z) (PreH1 : (retval = (Zabs (x_pre)))) (PreH2 : (y_pre = 0)) (PreH3 : (x_pre <= INT_MAX)) (PreH4 : (y_pre <= INT_MAX)) (PreH5 : (y_pre >= INT_MIN)) (PreH6 : (INT_MIN < x_pre)) (PreH7 : (INT_MIN < y_pre)) ,
145
+ TT && emp
146
+ |--
147
+ “ (retval = (Zgcd (x_pre) (0))) ”
148
+ && emp
149
+ ).
150
+
151
+ Definition gcd_return_wit_2_split_goal_1 :=
152
+ forall (y_pre: Z) (x_pre: Z) (retval: Z) (PreH1 : (retval = (Zabs (x_pre)))) (PreH2 : (y_pre = 0)) (PreH3 : (x_pre <= INT_MAX)) (PreH4 : (y_pre <= INT_MAX)) (PreH5 : (y_pre >= INT_MIN)) (PreH6 : (INT_MIN < x_pre)) (PreH7 : (INT_MIN < y_pre)) ,
153
+ (retval = (Zgcd (x_pre) (0)))
154
+ .
155
+
156
+ Definition gcd_partial_solve_wit_1_pure :=
157
+ forall (y_pre: Z) (x_pre: Z) (PreH1 : (y_pre = 0)) (PreH2 : (x_pre <= INT_MAX)) (PreH3 : (y_pre <= INT_MAX)) (PreH4 : (y_pre >= INT_MIN)) (PreH5 : (INT_MIN < x_pre)) (PreH6 : (INT_MIN < y_pre)) ,
158
+ ((( &( "x" ) )) # Int |-> x_pre)
159
+ ** ((( &( "y" ) )) # Int |-> y_pre)
160
+ |--
161
+ “ (INT_MIN < x_pre) ”
162
+ && “ (x_pre <= INT_MAX) ”
163
+ .
164
+
165
+ Definition gcd_partial_solve_wit_1_aux :=
166
+ forall (y_pre: Z) (x_pre: Z) (PreH1 : (y_pre = 0)) (PreH2 : (x_pre <= INT_MAX)) (PreH3 : (y_pre <= INT_MAX)) (PreH4 : (y_pre >= INT_MIN)) (PreH5 : (INT_MIN < x_pre)) (PreH6 : (INT_MIN < y_pre)) ,
167
+ TT && emp
168
+ |--
169
+ “ (INT_MIN < x_pre) ”
170
+ && “ (x_pre <= INT_MAX) ”
171
+ && “ (y_pre = 0) ”
172
+ && “ (x_pre <= INT_MAX) ”
173
+ && “ (y_pre <= INT_MAX) ”
174
+ && “ (y_pre >= INT_MIN) ”
175
+ && “ (INT_MIN < x_pre) ”
176
+ && “ (INT_MIN < y_pre) ”
177
+ && emp
178
+ .
179
+
180
+ Definition gcd_partial_solve_wit_1 := gcd_partial_solve_wit_1_pure -> gcd_partial_solve_wit_1_aux.
181
+
182
+ Definition gcd_partial_solve_wit_2_pure :=
183
+ (
184
+ forall (y_pre: Z) (x_pre: Z) (PreH1 : (y_pre <> 0)) (PreH2 : (x_pre <= INT_MAX)) (PreH3 : (y_pre <= INT_MAX)) (PreH4 : (y_pre >= INT_MIN)) (PreH5 : (INT_MIN < x_pre)) (PreH6 : (INT_MIN < y_pre)) ,
185
+ ((( &( "x" ) )) # Int |-> x_pre)
186
+ ** ((( &( "y" ) )) # Int |-> y_pre)
187
+ |--
188
+ “ (INT_MIN < y_pre) ”
189
+ && “ (INT_MIN < (x_pre % ( y_pre ) )) ”
190
+ ) \/
191
+ (
192
+ forall (y_pre: Z) (x_pre: Z) (PreH1 : (x_pre >= INT_MIN)) (PreH2 : (y_pre <> 0)) (PreH3 : (x_pre <= INT_MAX)) (PreH4 : (y_pre <= INT_MAX)) (PreH5 : (y_pre >= INT_MIN)) (PreH6 : (INT_MIN < x_pre)) (PreH7 : (INT_MIN < y_pre)) ,
193
+ ((( &( "x" ) )) # Int |-> x_pre)
194
+ ** ((( &( "y" ) )) # Int |-> y_pre)
195
+ |--
196
+ “ (INT_MIN < (x_pre % ( y_pre ) )) ”
197
+ ).
198
+
199
+ Definition gcd_partial_solve_wit_2_pure_split_goal_1 :=
200
+ forall (y_pre: Z) (x_pre: Z) (PreH1 : (x_pre >= INT_MIN)) (PreH2 : (y_pre <> 0)) (PreH3 : (x_pre <= INT_MAX)) (PreH4 : (y_pre <= INT_MAX)) (PreH5 : (y_pre >= INT_MIN)) (PreH6 : (INT_MIN < x_pre)) (PreH7 : (INT_MIN < y_pre)) ,
201
+ ((( &( "x" ) )) # Int |-> x_pre)
202
+ ** ((( &( "y" ) )) # Int |-> y_pre)
203
+ |--
204
+ “ (INT_MIN < (x_pre % ( y_pre ) )) ”
205
+ .
206
+
207
+ Definition gcd_partial_solve_wit_2_aux :=
208
+ forall (y_pre: Z) (x_pre: Z) (PreH1 : (y_pre <> 0)) (PreH2 : (x_pre <= INT_MAX)) (PreH3 : (y_pre <= INT_MAX)) (PreH4 : (y_pre >= INT_MIN)) (PreH5 : (INT_MIN < x_pre)) (PreH6 : (INT_MIN < y_pre)) ,
209
+ TT && emp
210
+ |--
211
+ “ (INT_MIN < y_pre) ”
212
+ && “ (INT_MIN < (x_pre % ( y_pre ) )) ”
213
+ && “ (y_pre <> 0) ”
214
+ && “ (x_pre <= INT_MAX) ”
215
+ && “ (y_pre <= INT_MAX) ”
216
+ && “ (y_pre >= INT_MIN) ”
217
+ && “ (INT_MIN < x_pre) ”
218
+ && “ (INT_MIN < y_pre) ”
219
+ && emp
220
+ .
221
+
222
+ Definition gcd_partial_solve_wit_2 := gcd_partial_solve_wit_2_pure -> gcd_partial_solve_wit_2_aux.
223
+
224
+ Module Type VC_Correct.
225
+
226
+
227
+ Axiom proof_of_abs_safety_wit_1 : abs_safety_wit_1.
228
+ Axiom proof_of_abs_safety_wit_2 : abs_safety_wit_2.
229
+ Axiom proof_of_abs_return_wit_1 : abs_return_wit_1.
230
+ Axiom proof_of_abs_return_wit_2 : abs_return_wit_2.
231
+ Axiom proof_of_gcd_safety_wit_1 : gcd_safety_wit_1.
232
+ Axiom proof_of_gcd_safety_wit_2 : gcd_safety_wit_2.
233
+ Axiom proof_of_gcd_entail_wit_1 : gcd_entail_wit_1.
234
+ Axiom proof_of_gcd_return_wit_1 : gcd_return_wit_1.
235
+ Axiom proof_of_gcd_return_wit_2 : gcd_return_wit_2.
236
+ Axiom proof_of_gcd_partial_solve_wit_1_pure : gcd_partial_solve_wit_1_pure.
237
+ Axiom proof_of_gcd_partial_solve_wit_1 : gcd_partial_solve_wit_1.
238
+ Axiom proof_of_gcd_partial_solve_wit_2_pure : gcd_partial_solve_wit_2_pure.
239
+ Axiom proof_of_gcd_partial_solve_wit_2 : gcd_partial_solve_wit_2.
240
+
241
+ End VC_Correct.
benchmarks/Algorithms/gcd/rocq/groundtruth/gcd_goal_check.v ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ From PVbench.Algorithms.gcd.rocq.groundtruth Require Import gcd_goal gcd_proof_auto gcd_proof_manual.
2
+
3
+ Module VC_Correctness : VC_Correct.
4
+ Include gcd_proof_auto.
5
+ Include gcd_proof_manual.
6
+ End VC_Correctness.
benchmarks/Algorithms/gcd/rocq/groundtruth/gcd_proof_auto.v ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Require Import Coq.ZArith.ZArith.
2
+ Require Import Coq.Bool.Bool.
3
+ Require Import Coq.Strings.String.
4
+ Require Import Coq.Strings.Ascii.
5
+ Require Import Coq.Lists.List.
6
+ Require Import Coq.Classes.RelationClasses.
7
+ Require Import Coq.Classes.Morphisms.
8
+ Require Import Coq.micromega.Psatz.
9
+ Require Import Coq.Sorting.Permutation.
10
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap.
11
+ Require Import SetsClass.SetsClass. Import SetsNotation.
12
+ From SimpleC.SL Require Import Mem SeparationLogic.
13
+ From PVbench.Algorithms.gcd.rocq.groundtruth Require Import gcd_goal.
14
+ Require Import Logic.LogicGenerator.demo932.Interface.
15
+ Local Open Scope Z_scope.
16
+ Local Open Scope sets.
17
+ Local Open Scope string_scope.
18
+ Local Open Scope list.
19
+ Import naive_C_Rules.
20
+ Local Open Scope sac.
21
+
22
+ Lemma proof_of_abs_safety_wit_1 : abs_safety_wit_1.
23
+ Proof. Admitted.
24
+
25
+ Lemma proof_of_abs_safety_wit_2 : abs_safety_wit_2.
26
+ Proof. Admitted.
27
+
28
+ Lemma proof_of_gcd_safety_wit_1 : gcd_safety_wit_1.
29
+ Proof. Admitted.
30
+
31
+ Lemma proof_of_gcd_safety_wit_2 : gcd_safety_wit_2.
32
+ Proof. Admitted.
33
+
34
+ Lemma proof_of_gcd_entail_wit_1 : gcd_entail_wit_1.
35
+ Proof. Admitted.
36
+
37
+ Lemma proof_of_gcd_partial_solve_wit_1_pure : gcd_partial_solve_wit_1_pure.
38
+ Proof. Admitted.
39
+
40
+ Lemma proof_of_gcd_partial_solve_wit_1 : gcd_partial_solve_wit_1.
41
+ Proof. Admitted.
42
+
43
+ Lemma proof_of_gcd_partial_solve_wit_2 : gcd_partial_solve_wit_2.
44
+ Proof. Admitted.
45
+
benchmarks/Algorithms/gcd/rocq/groundtruth/gcd_proof_manual.v ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Require Import Coq.ZArith.ZArith.
2
+ Require Import Coq.Bool.Bool.
3
+ Require Import Coq.Strings.String.
4
+ Require Import Coq.Strings.Ascii.
5
+ Require Import Coq.Lists.List.
6
+ Require Import Coq.Classes.RelationClasses.
7
+ Require Import Coq.Classes.Morphisms.
8
+ Require Import Coq.micromega.Psatz.
9
+ Require Import Coq.Sorting.Permutation.
10
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap.
11
+ Require Import SetsClass.SetsClass. Import SetsNotation.
12
+ From SimpleC.SL Require Import Mem SeparationLogic.
13
+ From PVbench.Algorithms.gcd.rocq.groundtruth Require Import gcd_goal.
14
+ From PVbench.Algorithms.gcd.rocq.groundtruth Require Import gcd_proof_auto.
15
+ Require Import Logic.LogicGenerator.demo932.Interface.
16
+ Local Open Scope Z_scope.
17
+ Local Open Scope sets.
18
+ Local Open Scope string_scope.
19
+ Local Open Scope list.
20
+ Import naive_C_Rules.
21
+ Require Import PVbench.Algorithms.gcd.rocq.groundtruth.proof_lib.
22
+ Local Open Scope sac.
23
+
24
+ Lemma proof_of_gcd_return_wit_1_split_goal_1 : gcd_return_wit_1_split_goal_1.
25
+ Proof.
26
+ LLM_pre_process ltac:(int_auto).
27
+ subst.
28
+ pose proof Z.gcd_rem x_pre y_pre ltac:(lia).
29
+ rewrite Z.gcd_comm, H, Z.gcd_comm.
30
+ reflexivity.
31
+ Qed.
32
+
33
+ Lemma proof_of_gcd_return_wit_1 : gcd_return_wit_1.
34
+ Proof.
35
+ aggressive_pre_process.
36
+ Goal_apply proof_of_gcd_return_wit_1_split_goal_1.
37
+ Qed.
38
+
39
+ Lemma proof_of_gcd_return_wit_2_split_goal_1 : gcd_return_wit_2_split_goal_1.
40
+ Proof.
41
+ LLM_pre_process ltac:(int_auto).
42
+ subst.
43
+ rewrite Z.gcd_0_r.
44
+ reflexivity.
45
+ Qed.
46
+
47
+ Lemma proof_of_gcd_return_wit_2 : gcd_return_wit_2.
48
+ Proof.
49
+ aggressive_pre_process.
50
+ Goal_apply proof_of_gcd_return_wit_2_split_goal_1.
51
+ Qed.
52
+
53
+ Lemma proof_of_gcd_partial_solve_wit_2_pure_split_goal_1 : gcd_partial_solve_wit_2_pure_split_goal_1.
54
+ Proof.
55
+ LLM_pre_process ltac:(int_auto).
56
+ prop_apply (store_int_range (&("y")) y_pre).
57
+ Intros.
58
+ change (Int.min_signed) with (-2147483648) in H.
59
+ change (Int.max_signed) with (2147483647) in H.
60
+ pose proof Z.rem_bound_pos_pos x_pre y_pre.
61
+ pose proof Z.rem_bound_neg_pos x_pre y_pre.
62
+ pose proof Z.rem_bound_pos_neg x_pre y_pre.
63
+ pose proof Z.rem_bound_neg_neg x_pre y_pre.
64
+ repeat (split_pure_spatial || split_pures); try cancel; dump_pre_spatial; lia.
65
+ Qed.
66
+
67
+ Lemma proof_of_gcd_partial_solve_wit_2_pure : gcd_partial_solve_wit_2_pure.
68
+ Proof.
69
+ aggressive_pre_process.
70
+ Goal_apply proof_of_gcd_partial_solve_wit_2_pure_split_goal_1.
71
+ Qed.
72
+
73
+ Lemma proof_of_abs_return_wit_1_split_goal_1 : abs_return_wit_1_split_goal_1.
74
+ Proof.
75
+ unfold abs_return_wit_1_split_goal_1; intros.
76
+ lia.
77
+ Qed.
78
+
79
+ Lemma proof_of_abs_return_wit_1 : abs_return_wit_1.
80
+ Proof.
81
+ aggressive_pre_process.
82
+ Goal_apply proof_of_abs_return_wit_1_split_goal_1.
83
+ Qed.
84
+
85
+ Lemma proof_of_abs_return_wit_2_split_goal_1 : abs_return_wit_2_split_goal_1.
86
+ Proof.
87
+ unfold abs_return_wit_2_split_goal_1; intros.
88
+ lia.
89
+ Qed.
90
+
91
+ Lemma proof_of_abs_return_wit_2 : abs_return_wit_2.
92
+ Proof.
93
+ aggressive_pre_process.
94
+ Goal_apply proof_of_abs_return_wit_2_split_goal_1.
95
+ Qed.
benchmarks/Algorithms/gcd/rocq/groundtruth/proof_lib.v ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ (* gcd needs no supporting lemmas: Coq's Z.gcd library closes every goal. *)
2
+ From Coq Require Import ZArith.
benchmarks/Algorithms/gcd/rocq/solution_annotated.c ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*@ Extern Coq (Zgcd: Z -> Z -> Z)
2
+ (Zabs: Z -> Z) */
3
+
4
+ int abs(int x)
5
+ /*@ Require
6
+ INT_MIN < x && x <= INT_MAX && emp
7
+ Ensure
8
+ __return == Zabs(x) && emp
9
+ */
10
+ {
11
+ if (x < 0) {
12
+ return -x;
13
+ }
14
+ return x;
15
+ }
16
+
17
+ int gcd(int x, int y)
18
+ /*@ Require
19
+ INT_MIN < x && INT_MIN < y
20
+ Ensure
21
+ __return == Zgcd(x, y)
22
+ */
23
+ {
24
+ /*@ x <= INT_MAX by local */
25
+ if (y == 0)
26
+ {
27
+ return abs(x);
28
+ }
29
+ else {
30
+ return gcd(y, x % y);
31
+ }
32
+ }
benchmarks/Algorithms/gcd/rocq/solution_spec.c ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*@ Extern Coq (Zgcd: Z -> Z -> Z) */
2
+
3
+ int abs(int x)
4
+ {
5
+ if (x < 0) {
6
+ return -x;
7
+ }
8
+ return x;
9
+ }
10
+
11
+ int gcd(int x, int y)
12
+ /*@ Require
13
+ INT_MIN < x && INT_MIN < y
14
+ Ensure
15
+ __return == Zgcd(x, y)
16
+ */
17
+ {
18
+ if (y == 0)
19
+ {
20
+ return abs(x);
21
+ }
22
+ else {
23
+ return gcd(y, x % y);
24
+ }
25
+ }
benchmarks/Algorithms/gcd/solution.c ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ int abs(int x)
2
+ {
3
+ if (x < 0) {
4
+ return -x;
5
+ }
6
+ return x;
7
+ }
8
+
9
+ int gcd(int x, int y)
10
+ {
11
+ if (y == 0)
12
+ {
13
+ return abs(x);
14
+ }
15
+ else {
16
+ return gcd(y, x % y);
17
+ }
18
+ }
benchmarks/Algorithms/sll_insertion_sort/manifest.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": "sll_insertion_sort",
3
+ "source": {
4
+ "dataset": "classical_algorithm",
5
+ "problem_id": "sll_insertion_sort",
6
+ "title": "Insertion Sort on a Singly Linked List",
7
+ "tags": [
8
+ "sort",
9
+ "insertion",
10
+ "linked list"
11
+ ]
12
+ },
13
+ "stratification": {
14
+ "band": "unclassified",
15
+ "output_mode": "CONSTRUCT",
16
+ "interactive": false,
17
+ "multi_test": false
18
+ }
19
+ }
benchmarks/Algorithms/sll_insertion_sort/problem.md ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Insertion Sort on a Singly Linked List
2
+
3
+ ## Description
4
+
5
+ Sort a null-terminated singly linked list of integers into nondecreasing order using insertion sort, relinking the existing nodes.
6
+
7
+ ## Input
8
+
9
+ A list is given by a pointer to its first node, or `NULL` when empty:
10
+
11
+ ```c
12
+ struct list {
13
+ int data;
14
+ struct list *next;
15
+ };
16
+ ```
17
+
18
+ The function receives the head `x` of the list.
19
+
20
+ ## Output
21
+
22
+ Return the head of a list holding the same values in nondecreasing order.
benchmarks/Algorithms/sll_insertion_sort/rocq/groundtruth/proof_lib.v ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (* Supporting lemmas for the manual proof. *)
2
+ Require Import Coq.ZArith.ZArith.
3
+ Require Import Coq.Bool.Bool.
4
+ Require Import Coq.Strings.String.
5
+ Require Import Coq.Lists.List.
6
+ Require Import Coq.Classes.RelationClasses.
7
+ Require Import Coq.Classes.Morphisms.
8
+ Require Import Coq.micromega.Psatz.
9
+ Require Import Coq.Sorting.Permutation.
10
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap.
11
+ Require Import SetsClass.SetsClass. Import SetsNotation.
12
+ From SimpleC.SL Require Import Mem SeparationLogic.
13
+ Require Import Logic.LogicGenerator.demo932.Interface.
14
+ Local Open Scope Z_scope.
15
+ Local Open Scope sets.
16
+ Local Open Scope string.
17
+ Local Open Scope list.
18
+ Import naive_C_Rules.
19
+ Require Import SimpleC.EE.QCP_demos_LLM.sll_lib.
20
+ Require Import PVbench.Algorithms.sll_insertion_sort.rocq.helper_lib.
21
+ Local Open Scope sac.
22
+ Import ListNotations.
23
+ Local Open Scope list.
24
+
25
+ Lemma upperbound_insert_nil:
26
+ forall x l,
27
+ strict_upperbound x l ->
28
+ insert x l = l ++ [x].
29
+ Proof.
30
+ intros.
31
+ induction l; simpl; try easy.
32
+ simpl in H. destruct H.
33
+ destruct (x >? a) eqn:b; simpl; try lia.
34
+ apply IHl in H0. rewrite H0. reflexivity.
35
+ Qed.
36
+
37
+ Lemma upperbound_insert_cons:
38
+ forall x l1 l2 y,
39
+ strict_upperbound x l1 ->
40
+ x <= y ->
41
+ insert x (l1 ++ y :: l2) = l1 ++ x :: y :: l2.
42
+ Proof.
43
+ intros.
44
+ induction l1; simpl; try easy; simpl in H.
45
+ - destruct (x >? y) eqn:b; simpl; [lia | easy].
46
+ - destruct H. destruct (x >? a) eqn:b; simpl; try lia.
47
+ apply IHl1 in H1. rewrite H1. reflexivity.
48
+ Qed.
49
+
50
+ Lemma increasing_aux_insert:
51
+ forall x l a,
52
+ increasing_aux l a ->
53
+ a <= x ->
54
+ increasing_aux (insert x l) a.
55
+ Proof.
56
+ intros. revert a H H0.
57
+ induction l; intros; simpl; try easy.
58
+ simpl in H.
59
+ destruct (x >? a) eqn:b; simpl.
60
+ - split; try easy.
61
+ apply IHl; [easy | lia].
62
+ - repeat split; try easy. lia.
63
+ Qed.
64
+
65
+ Lemma increasing_insert:
66
+ forall x l,
67
+ increasing l ->
68
+ increasing (insert x l).
69
+ Proof.
70
+ intros. destruct l; simpl; try easy.
71
+ simpl in H.
72
+ destruct (x >? z) eqn:b; simpl.
73
+ - apply increasing_aux_insert; [easy | lia].
74
+ - split; [lia | easy].
75
+ Qed.
76
+
77
+ Lemma perm_insert:
78
+ forall x l,
79
+ Permutation (l ++ [x]) (insert x l).
80
+ Proof.
81
+ intros. induction l; simpl; try easy.
82
+ destruct (x >? a).
83
+ - rewrite IHl. reflexivity.
84
+ - rewrite <- Permutation_cons_append. apply perm_swap.
85
+ Qed.
86
+
87
+
88
+ Lemma upperbound_insert_app:
89
+ forall x l1 l2,
90
+ strict_upperbound x l1 ->
91
+ insert x (l1 ++ l2) = l1 ++ insert x l2.
92
+ Proof.
93
+ intros x l1 l2 Hupper.
94
+ revert l2 Hupper.
95
+ induction l1; intros l2 Hupper.
96
+ - reflexivity.
97
+ - simpl in Hupper.
98
+ destruct Hupper.
99
+ simpl.
100
+ destruct (x >? a) eqn:Hgt.
101
+ + f_equal.
102
+ apply IHl1.
103
+ exact H0.
104
+ + lia.
105
+ Qed.
benchmarks/Algorithms/sll_insertion_sort/rocq/groundtruth/sll_insertion_sort_goal.v ADDED
@@ -0,0 +1,506 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Require Import Coq.ZArith.ZArith.
2
+ Require Import Coq.Bool.Bool.
3
+ Require Import Coq.Strings.String.
4
+ Require Import Coq.Strings.Ascii.
5
+ Require Import Coq.Lists.List.
6
+ Require Import Coq.Classes.RelationClasses.
7
+ Require Import Coq.Classes.Morphisms.
8
+ Require Import Coq.micromega.Psatz.
9
+ Require Import Coq.Sorting.Permutation.
10
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap.
11
+ Require Import SetsClass.SetsClass. Import SetsNotation.
12
+ From SimpleC.SL Require Import Mem SeparationLogic.
13
+ Require Import Logic.LogicGenerator.demo932.Interface.
14
+ Local Open Scope Z_scope.
15
+ Local Open Scope sets.
16
+ Local Open Scope string_scope.
17
+ Local Open Scope list.
18
+ Import naive_C_Rules.
19
+ Require Import SimpleC.EE.QCP_demos_LLM.sll_lib.
20
+ Require Import PVbench.Algorithms.sll_insertion_sort.rocq.helper_lib.
21
+ Local Open Scope sac.
22
+ From SimpleC.EE.QCP_demos_LLM Require Import sll_strategy_goal.
23
+ From SimpleC.EE.QCP_demos_LLM Require Import sll_strategy_proof.
24
+
25
+ (*----- Function insertion -----*)
26
+
27
+ Definition insertion_safety_wit_1 :=
28
+ forall (node_pre: Z) (p_pre: Z) (a: Z) (l: (@list Z)) (p2_v: Z) (p2: Z) (l1: (@list Z)) (l2: (@list Z)) (PreH1 : (node_pre <> 0)) (PreH2 : (l = (app (l1) (l2)))) (PreH3 : (strict_upperbound a l1 )) ,
29
+ ((( &( "node" ) )) # Ptr |-> node_pre)
30
+ ** ((( &( "p" ) )) # Ptr |-> p_pre)
31
+ ** ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
32
+ ** ((( &( "p2" ) )) # Ptr |-> p2)
33
+ ** (sllbseg ( &( "res" ) ) p2 l1 )
34
+ ** ((p2) # Ptr |-> p2_v)
35
+ ** (sll p2_v l2 )
36
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |->_)
37
+ |--
38
+ “ (0 <= INT_MAX) ”
39
+ && “ ((INT_MIN) <= 0) ”
40
+ .
41
+
42
+ Definition insertion_entail_wit_1 :=
43
+ (
44
+ forall (node_pre: Z) (p_pre: Z) (a: Z) (l: (@list Z)) (PreH1 : (node_pre <> 0)) ,
45
+ ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
46
+ ** (sll p_pre l )
47
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |->_)
48
+ |--
49
+ EX (l1: (@list Z)) (l2: (@list Z)) ,
50
+ “ (node_pre <> 0) ”
51
+ && “ (l = (app (l1) (l2))) ”
52
+ && “ (strict_upperbound a l1 ) ”
53
+ && ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
54
+ ** (sllbseg ( &( "res" ) ) ( &( "res" ) ) l1 )
55
+ ** (sll p_pre l2 )
56
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |->_)
57
+ ) \/
58
+ (
59
+ forall (node_pre: Z) (a: Z) (l: (@list Z)) (PreH1 : (node_pre <> 0)) ,
60
+ TT && emp
61
+ |--
62
+ EX (l1: (@list Z)) ,
63
+ “ (node_pre <> 0) ”
64
+ && “ (l = (app (l1) (l))) ”
65
+ && “ (strict_upperbound a l1 ) ”
66
+ && (sllbseg ( &( "res" ) ) ( &( "res" ) ) l1 )
67
+ ).
68
+
69
+ Definition insertion_entail_wit_2 :=
70
+ (
71
+ forall (node_pre: Z) (a: Z) (l: (@list Z)) (p2_v_2: Z) (p2: Z) (l1_2: (@list Z)) (l2_2: (@list Z)) (x: Z) (l0: (@list Z)) (y: Z) (PreH1 : (x < a)) (PreH2 : (l2_2 = (cons (x) (l0)))) (PreH3 : (p2_v_2 <> 0)) (PreH4 : (node_pre <> 0)) (PreH5 : (l = (app (l1_2) (l2_2)))) (PreH6 : (strict_upperbound a l1_2 )) ,
72
+ ((&((p2_v_2) # "list" ->ₛ "data")) # Int |-> x)
73
+ ** (sll y l0 )
74
+ ** ((&((p2_v_2) # "list" ->ₛ "next")) # Ptr |-> y)
75
+ ** ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
76
+ ** (sllbseg ( &( "res" ) ) p2 l1_2 )
77
+ ** ((p2) # Ptr |-> p2_v_2)
78
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |->_)
79
+ |--
80
+ EX (p2_v: Z) (l1: (@list Z)) (l2: (@list Z)) ,
81
+ “ (node_pre <> 0) ”
82
+ && “ (l = (app (l1) (l2))) ”
83
+ && “ (strict_upperbound a l1 ) ”
84
+ && ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
85
+ ** (sllbseg ( &( "res" ) ) &((p2_v_2) # "list" ->ₛ "next") l1 )
86
+ ** ((&((p2_v_2) # "list" ->ₛ "next")) # Ptr |-> p2_v)
87
+ ** (sll p2_v l2 )
88
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |->_)
89
+ ) \/
90
+ (
91
+ forall (node_pre: Z) (a: Z) (l: (@list Z)) (p2_v_2: Z) (p2: Z) (l1_2: (@list Z)) (l2_2: (@list Z)) (x: Z) (l0: (@list Z)) (PreH1 : (x <= INT_MAX)) (PreH2 : (x >= INT_MIN)) (PreH3 : (x < a)) (PreH4 : (l2_2 = (cons (x) (l0)))) (PreH5 : (p2_v_2 <> 0)) (PreH6 : (node_pre <> 0)) (PreH7 : (l = (app (l1_2) (l2_2)))) (PreH8 : (strict_upperbound a l1_2 )) ,
92
+ ((&((p2_v_2) # "list" ->ₛ "data")) # Int |-> x)
93
+ ** (sllbseg ( &( "res" ) ) p2 l1_2 )
94
+ ** ((p2) # Ptr |-> p2_v_2)
95
+ |--
96
+ EX (l1: (@list Z)) ,
97
+ “ (node_pre <> 0) ”
98
+ && “ (l = (app (l1) (l0))) ”
99
+ && “ (strict_upperbound a l1 ) ”
100
+ && (sllbseg ( &( "res" ) ) &((p2_v_2) # "list" ->ₛ "next") l1 )
101
+ ).
102
+
103
+ Definition insertion_entail_wit_3_1 :=
104
+ forall (node_pre: Z) (a: Z) (l: (@list Z)) (p2_v: Z) (p2: Z) (l1_3: (@list Z)) (l2: (@list Z)) (PreH1 : (p2_v = 0)) (PreH2 : (node_pre <> 0)) (PreH3 : (l = (app (l1_3) (l2)))) (PreH4 : (strict_upperbound a l1_3 )) ,
105
+ ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
106
+ ** (sllbseg ( &( "res" ) ) p2 l1_3 )
107
+ ** ((p2) # Ptr |-> p2_v)
108
+ ** (sll p2_v l2 )
109
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |->_)
110
+ |--
111
+ (EX (l1: (@list Z)) ,
112
+ “ (node_pre <> 0) ”
113
+ && “ (l = (app (l1) ((@nil Z)))) ”
114
+ && “ (strict_upperbound a l1 ) ”
115
+ && ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
116
+ ** (sllbseg ( &( "res" ) ) p2 l1 )
117
+ ** ((p2) # Ptr |-> 0)
118
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |->_))
119
+ ||
120
+ (EX (unext: Z) (l1_2: (@list Z)) (l0: (@list Z)) (x: Z) (u: Z) ,
121
+ “ (node_pre <> 0) ”
122
+ && “ (u <> 0) ”
123
+ && “ (x >= a) ”
124
+ && “ (l = (app (l1_2) ((cons (x) (l0))))) ”
125
+ && “ (strict_upperbound a l1_2 ) ”
126
+ && ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
127
+ ** (sllbseg ( &( "res" ) ) p2 l1_2 )
128
+ ** ((p2) # Ptr |-> u)
129
+ ** ((&((u) # "list" ->ₛ "data")) # Int |-> x)
130
+ ** ((&((u) # "list" ->ₛ "next")) # Ptr |-> unext)
131
+ ** (sll unext l0 )
132
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |->_))
133
+ .
134
+
135
+ Definition insertion_entail_wit_3_2 :=
136
+ forall (node_pre: Z) (a: Z) (l: (@list Z)) (p2_v: Z) (p2: Z) (l1_3: (@list Z)) (l2: (@list Z)) (x_2: Z) (l0_2: (@list Z)) (y: Z) (PreH1 : (x_2 >= a)) (PreH2 : (l2 = (cons (x_2) (l0_2)))) (PreH3 : (p2_v <> 0)) (PreH4 : (node_pre <> 0)) (PreH5 : (l = (app (l1_3) (l2)))) (PreH6 : (strict_upperbound a l1_3 )) ,
137
+ ((&((p2_v) # "list" ->ₛ "data")) # Int |-> x_2)
138
+ ** (sll y l0_2 )
139
+ ** ((&((p2_v) # "list" ->ₛ "next")) # Ptr |-> y)
140
+ ** ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
141
+ ** (sllbseg ( &( "res" ) ) p2 l1_3 )
142
+ ** ((p2) # Ptr |-> p2_v)
143
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |->_)
144
+ |--
145
+ (EX (l1: (@list Z)) ,
146
+ “ (node_pre <> 0) ”
147
+ && “ (l = (app (l1) ((@nil Z)))) ”
148
+ && “ (strict_upperbound a l1 ) ”
149
+ && ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
150
+ ** (sllbseg ( &( "res" ) ) p2 l1 )
151
+ ** ((p2) # Ptr |-> 0)
152
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |->_))
153
+ ||
154
+ (EX (unext: Z) (l1_2: (@list Z)) (l0: (@list Z)) (x: Z) (u: Z) ,
155
+ “ (node_pre <> 0) ”
156
+ && “ (u <> 0) ”
157
+ && “ (x >= a) ”
158
+ && “ (l = (app (l1_2) ((cons (x) (l0))))) ”
159
+ && “ (strict_upperbound a l1_2 ) ”
160
+ && ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
161
+ ** (sllbseg ( &( "res" ) ) p2 l1_2 )
162
+ ** ((p2) # Ptr |-> u)
163
+ ** ((&((u) # "list" ->ₛ "data")) # Int |-> x)
164
+ ** ((&((u) # "list" ->ₛ "next")) # Ptr |-> unext)
165
+ ** (sll unext l0 )
166
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |->_))
167
+ .
168
+
169
+ Definition insertion_entail_wit_4_1 :=
170
+ forall (node_pre: Z) (a: Z) (l: (@list Z)) (l1_3: (@list Z)) (p2: Z) (PreH1 : (node_pre <> 0)) (PreH2 : (l = (app (l1_3) ((@nil Z))))) (PreH3 : (strict_upperbound a l1_3 )) ,
171
+ ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
172
+ ** (sllbseg ( &( "res" ) ) p2 l1_3 )
173
+ ** ((p2) # Ptr |-> node_pre)
174
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |-> 0)
175
+ |--
176
+ (EX (resv: Z) (l1: (@list Z)) ,
177
+ “ (node_pre <> 0) ”
178
+ && “ (l = (app (l1) ((@nil Z)))) ”
179
+ && “ (strict_upperbound a l1 ) ”
180
+ && ((( &( "res" ) )) # Ptr |-> resv)
181
+ ** (sllseg resv node_pre l1 )
182
+ ** ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
183
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |-> 0))
184
+ ||
185
+ (EX (unext: Z) (resv_2: Z) (l1_2: (@list Z)) (l0: (@list Z)) (x: Z) (u: Z) ,
186
+ “ (node_pre <> 0) ”
187
+ && “ (u <> 0) ”
188
+ && “ (x >= a) ”
189
+ && “ (l = (app (l1_2) ((cons (x) (l0))))) ”
190
+ && “ (strict_upperbound a l1_2 ) ”
191
+ && ((( &( "res" ) )) # Ptr |-> resv_2)
192
+ ** (sllseg resv_2 node_pre l1_2 )
193
+ ** ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
194
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |-> u)
195
+ ** ((&((u) # "list" ->ₛ "data")) # Int |-> x)
196
+ ** ((&((u) # "list" ->ₛ "next")) # Ptr |-> unext)
197
+ ** (sll unext l0 ))
198
+ .
199
+
200
+ Definition insertion_entail_wit_4_2 :=
201
+ forall (node_pre: Z) (a: Z) (l: (@list Z)) (l1_3: (@list Z)) (x_2: Z) (l0_2: (@list Z)) (u_2: Z) (unext_2: Z) (p2: Z) (PreH1 : (node_pre <> 0)) (PreH2 : (u_2 <> 0)) (PreH3 : (x_2 >= a)) (PreH4 : (l = (app (l1_3) ((cons (x_2) (l0_2)))))) (PreH5 : (strict_upperbound a l1_3 )) ,
202
+ ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
203
+ ** (sllbseg ( &( "res" ) ) p2 l1_3 )
204
+ ** ((p2) # Ptr |-> node_pre)
205
+ ** ((&((u_2) # "list" ->ₛ "data")) # Int |-> x_2)
206
+ ** ((&((u_2) # "list" ->ₛ "next")) # Ptr |-> unext_2)
207
+ ** (sll unext_2 l0_2 )
208
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |-> u_2)
209
+ |--
210
+ (EX (resv: Z) (l1: (@list Z)) ,
211
+ “ (node_pre <> 0) ”
212
+ && “ (l = (app (l1) ((@nil Z)))) ”
213
+ && “ (strict_upperbound a l1 ) ”
214
+ && ((( &( "res" ) )) # Ptr |-> resv)
215
+ ** (sllseg resv node_pre l1 )
216
+ ** ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
217
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |-> 0))
218
+ ||
219
+ (EX (unext: Z) (resv_2: Z) (l1_2: (@list Z)) (l0: (@list Z)) (x: Z) (u: Z) ,
220
+ “ (node_pre <> 0) ”
221
+ && “ (u <> 0) ”
222
+ && “ (x >= a) ”
223
+ && “ (l = (app (l1_2) ((cons (x) (l0))))) ”
224
+ && “ (strict_upperbound a l1_2 ) ”
225
+ && ((( &( "res" ) )) # Ptr |-> resv_2)
226
+ ** (sllseg resv_2 node_pre l1_2 )
227
+ ** ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
228
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |-> u)
229
+ ** ((&((u) # "list" ->ₛ "data")) # Int |-> x)
230
+ ** ((&((u) # "list" ->ₛ "next")) # Ptr |-> unext)
231
+ ** (sll unext l0 ))
232
+ .
233
+
234
+ Definition insertion_return_wit_1 :=
235
+ (
236
+ forall (node_pre: Z) (a: Z) (l: (@list Z)) (resv: Z) (l1: (@list Z)) (PreH1 : (node_pre <> 0)) (PreH2 : (l = (app (l1) ((@nil Z))))) (PreH3 : (strict_upperbound a l1 )) ,
237
+ (sllseg resv node_pre l1 )
238
+ ** ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
239
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |-> 0)
240
+ |--
241
+ EX (l0: (@list Z)) ,
242
+ “ (l0 = (insert (a) (l))) ”
243
+ && (sll resv l0 )
244
+ ) \/
245
+ (
246
+ forall (node_pre: Z) (a: Z) (l: (@list Z)) (resv: Z) (l1: (@list Z)) (PreH1 : (a <= INT_MAX)) (PreH2 : (a >= INT_MIN)) (PreH3 : (node_pre <> 0)) (PreH4 : (l = (app (l1) ((@nil Z))))) (PreH5 : (strict_upperbound a l1 )) ,
247
+ (sllseg resv node_pre l1 )
248
+ ** ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
249
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |-> 0)
250
+ |--
251
+ (sll resv (insert (a) (l)) )
252
+ ).
253
+
254
+ Definition insertion_return_wit_1_split_goal_spatial :=
255
+ forall (node_pre: Z) (a: Z) (l: (@list Z)) (resv: Z) (l1: (@list Z)) (PreH1 : (a <= INT_MAX)) (PreH2 : (a >= INT_MIN)) (PreH3 : (node_pre <> 0)) (PreH4 : (l = (app (l1) ((@nil Z))))) (PreH5 : (strict_upperbound a l1 )) ,
256
+ (sllseg resv node_pre l1 )
257
+ ** ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
258
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |-> 0)
259
+ |--
260
+ (sll resv (insert (a) (l)) )
261
+ .
262
+
263
+ Definition insertion_return_wit_2 :=
264
+ (
265
+ forall (node_pre: Z) (a: Z) (l: (@list Z)) (resv: Z) (l1: (@list Z)) (x: Z) (l0_2: (@list Z)) (u: Z) (unext: Z) (PreH1 : (node_pre <> 0)) (PreH2 : (u <> 0)) (PreH3 : (x >= a)) (PreH4 : (l = (app (l1) ((cons (x) (l0_2)))))) (PreH5 : (strict_upperbound a l1 )) ,
266
+ (sllseg resv node_pre l1 )
267
+ ** ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
268
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |-> u)
269
+ ** ((&((u) # "list" ->ₛ "data")) # Int |-> x)
270
+ ** ((&((u) # "list" ->ₛ "next")) # Ptr |-> unext)
271
+ ** (sll unext l0_2 )
272
+ |--
273
+ EX (l0: (@list Z)) ,
274
+ “ (l0 = (insert (a) (l))) ”
275
+ && (sll resv l0 )
276
+ ) \/
277
+ (
278
+ forall (node_pre: Z) (a: Z) (l: (@list Z)) (resv: Z) (l1: (@list Z)) (x: Z) (l0_2: (@list Z)) (u: Z) (unext: Z) (PreH1 : (x <= INT_MAX)) (PreH2 : (a <= INT_MAX)) (PreH3 : (x >= INT_MIN)) (PreH4 : (a >= INT_MIN)) (PreH5 : (node_pre <> 0)) (PreH6 : (u <> 0)) (PreH7 : (x >= a)) (PreH8 : (l = (app (l1) ((cons (x) (l0_2)))))) (PreH9 : (strict_upperbound a l1 )) ,
279
+ (sllseg resv node_pre l1 )
280
+ ** ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
281
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |-> u)
282
+ ** ((&((u) # "list" ->ₛ "data")) # Int |-> x)
283
+ ** ((&((u) # "list" ->ₛ "next")) # Ptr |-> unext)
284
+ ** (sll unext l0_2 )
285
+ |--
286
+ (sll resv (insert (a) (l)) )
287
+ ).
288
+
289
+ Definition insertion_return_wit_2_split_goal_spatial :=
290
+ forall (node_pre: Z) (a: Z) (l: (@list Z)) (resv: Z) (l1: (@list Z)) (x: Z) (l0_2: (@list Z)) (u: Z) (unext: Z) (PreH1 : (x <= INT_MAX)) (PreH2 : (a <= INT_MAX)) (PreH3 : (x >= INT_MIN)) (PreH4 : (a >= INT_MIN)) (PreH5 : (node_pre <> 0)) (PreH6 : (u <> 0)) (PreH7 : (x >= a)) (PreH8 : (l = (app (l1) ((cons (x) (l0_2)))))) (PreH9 : (strict_upperbound a l1 )) ,
291
+ (sllseg resv node_pre l1 )
292
+ ** ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
293
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |-> u)
294
+ ** ((&((u) # "list" ->ₛ "data")) # Int |-> x)
295
+ ** ((&((u) # "list" ->ₛ "next")) # Ptr |-> unext)
296
+ ** (sll unext l0_2 )
297
+ |--
298
+ (sll resv (insert (a) (l)) )
299
+ .
300
+
301
+ Definition insertion_partial_solve_wit_1 :=
302
+ forall (node_pre: Z) (a: Z) (l: (@list Z)) (p2_v: Z) (p2: Z) (l1: (@list Z)) (l2: (@list Z)) (PreH1 : (p2_v <> 0)) (PreH2 : (node_pre <> 0)) (PreH3 : (l = (app (l1) (l2)))) (PreH4 : (strict_upperbound a l1 )) ,
303
+ ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
304
+ ** (sllbseg ( &( "res" ) ) p2 l1 )
305
+ ** ((p2) # Ptr |-> p2_v)
306
+ ** (sll p2_v l2 )
307
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |->_)
308
+ |--
309
+ EX (x: Z) (l0: (@list Z)) (y: Z) ,
310
+ “ (l2 = (cons (x) (l0))) ”
311
+ && “ (p2_v <> 0) ”
312
+ && “ (node_pre <> 0) ”
313
+ && “ (l = (app (l1) (l2))) ”
314
+ && “ (strict_upperbound a l1 ) ”
315
+ && ((&((p2_v) # "list" ->ₛ "data")) # Int |-> x)
316
+ ** (sll y l0 )
317
+ ** ((&((p2_v) # "list" ->ₛ "next")) # Ptr |-> y)
318
+ ** ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a)
319
+ ** (sllbseg ( &( "res" ) ) p2 l1 )
320
+ ** ((p2) # Ptr |-> p2_v)
321
+ ** ((&((node_pre) # "list" ->ₛ "next")) # Ptr |->_)
322
+ .
323
+
324
+ (*----- Function insertion_sort -----*)
325
+
326
+ Definition insertion_sort_safety_wit_1 :=
327
+ forall (x_pre: Z) (l: (@list Z)) ,
328
+ ((( &( "res" ) )) # Ptr |->_)
329
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
330
+ ** (sll x_pre l )
331
+ |--
332
+ “ (0 <= INT_MAX) ”
333
+ && “ ((INT_MIN) <= 0) ”
334
+ .
335
+
336
+ Definition insertion_sort_safety_wit_2 :=
337
+ forall (x_pre: Z) (l: (@list Z)) (p: Z) (res: Z) (l0: (@list Z)) (l1: (@list Z)) (l2: (@list Z)) (PreH1 : (l = (app (l1) (l2)))) (PreH2 : (Permutation l1 l0 )) (PreH3 : (increasing l0 )) ,
338
+ ((( &( "x" ) )) # Ptr |-> x_pre)
339
+ ** ((( &( "q" ) )) # Ptr |->_)
340
+ ** ((( &( "res" ) )) # Ptr |-> res)
341
+ ** (sll res l0 )
342
+ ** ((( &( "p" ) )) # Ptr |-> p)
343
+ ** (sll p l2 )
344
+ |--
345
+ “ (0 <= INT_MAX) ”
346
+ && “ ((INT_MIN) <= 0) ”
347
+ .
348
+
349
+ Definition insertion_sort_entail_wit_1 :=
350
+ (
351
+ forall (x_pre: Z) (l: (@list Z)) ,
352
+ (sll x_pre l )
353
+ |--
354
+ EX (l0: (@list Z)) (l1: (@list Z)) (l2: (@list Z)) ,
355
+ “ (l = (app (l1) (l2))) ”
356
+ && “ (Permutation l1 l0 ) ”
357
+ && “ (increasing l0 ) ”
358
+ && (sll 0 l0 )
359
+ ** (sll x_pre l2 )
360
+ ) \/
361
+ (
362
+ forall (l: (@list Z)) ,
363
+ TT && emp
364
+ |--
365
+ EX (l1: (@list Z)) ,
366
+ “ (l = (app (l1) (l))) ”
367
+ && “ (Permutation l1 (@nil Z) ) ”
368
+ && “ (increasing (@nil Z) ) ”
369
+ && emp
370
+ ).
371
+
372
+ Definition insertion_sort_entail_wit_2 :=
373
+ (
374
+ forall (l: (@list Z)) (p: Z) (l0_2: (@list Z)) (l1_2: (@list Z)) (l2_2: (@list Z)) (x: Z) (l0_3: (@list Z)) (y: Z) (l0_4: (@list Z)) (retval: Z) (PreH1 : (l0_4 = (insert (x) (l0_2)))) (PreH2 : (l2_2 = (cons (x) (l0_3)))) (PreH3 : (p <> 0)) (PreH4 : (l = (app (l1_2) (l2_2)))) (PreH5 : (Permutation l1_2 l0_2 )) (PreH6 : (increasing l0_2 )) ,
375
+ (sll retval l0_4 )
376
+ ** (sll y l0_3 )
377
+ ** ((( &( "q" ) )) # Ptr |-> y)
378
+ |--
379
+ EX (l0: (@list Z)) (l1: (@list Z)) (l2: (@list Z)) ,
380
+ “ (l = (app (l1) (l2))) ”
381
+ && “ (Permutation l1 l0 ) ”
382
+ && “ (increasing l0 ) ”
383
+ && ((( &( "q" ) )) # Ptr |->_)
384
+ ** (sll retval l0 )
385
+ ** (sll y l2 )
386
+ ) \/
387
+ (
388
+ forall (l: (@list Z)) (p: Z) (l0_2: (@list Z)) (l1_2: (@list Z)) (l2_2: (@list Z)) (x: Z) (l0_3: (@list Z)) (l0_4: (@list Z)) (PreH1 : (l0_4 = (insert (x) (l0_2)))) (PreH2 : (l2_2 = (cons (x) (l0_3)))) (PreH3 : (p <> 0)) (PreH4 : (l = (app (l1_2) (l2_2)))) (PreH5 : (Permutation l1_2 l0_2 )) (PreH6 : (increasing l0_2 )) ,
389
+ TT && emp
390
+ |--
391
+ EX (l1: (@list Z)) ,
392
+ “ ((app (l1_2) (l2_2)) = (app (l1) (l0_3))) ”
393
+ && “ (Permutation l1 (insert (x) (l0_2)) ) ”
394
+ && “ (increasing (insert (x) (l0_2)) ) ”
395
+ && emp
396
+ ).
397
+
398
+ Definition insertion_sort_return_wit_1 :=
399
+ (
400
+ forall (l: (@list Z)) (p: Z) (res: Z) (l0_2: (@list Z)) (l1: (@list Z)) (l2: (@list Z)) (PreH1 : (p = 0)) (PreH2 : (l = (app (l1) (l2)))) (PreH3 : (Permutation l1 l0_2 )) (PreH4 : (increasing l0_2 )) ,
401
+ (sll res l0_2 )
402
+ ** (sll p l2 )
403
+ |--
404
+ EX (l0: (@list Z)) ,
405
+ “ (Permutation l l0 ) ”
406
+ && “ (increasing l0 ) ”
407
+ && (sll res l0 )
408
+ ) \/
409
+ (
410
+ forall (l: (@list Z)) (p: Z) (l0_2: (@list Z)) (l1: (@list Z)) (l2: (@list Z)) (PreH1 : (p = 0)) (PreH2 : (l = (app (l1) (l2)))) (PreH3 : (Permutation l1 l0_2 )) (PreH4 : (increasing l0_2 )) ,
411
+ (sll p l2 )
412
+ |--
413
+ “ (Permutation l l0_2 ) ”
414
+ && emp
415
+ ).
416
+
417
+ Definition insertion_sort_return_wit_1_split_goal_1 :=
418
+ forall (l: (@list Z)) (p: Z) (l0_2: (@list Z)) (l1: (@list Z)) (l2: (@list Z)) (PreH1 : (p = 0)) (PreH2 : (l = (app (l1) (l2)))) (PreH3 : (Permutation l1 l0_2 )) (PreH4 : (increasing l0_2 )) ,
419
+ (sll p l2 )
420
+ |--
421
+ “ (Permutation l l0_2 ) ”
422
+ .
423
+
424
+ Definition insertion_sort_return_wit_1_split_goal_spatial :=
425
+ forall (l: (@list Z)) (p: Z) (l0_2: (@list Z)) (l1: (@list Z)) (l2: (@list Z)) (PreH1 : (p = 0)) (PreH2 : (l = (app (l1) (l2)))) (PreH3 : (Permutation l1 l0_2 )) (PreH4 : (increasing l0_2 )) ,
426
+ (sll p l2 )
427
+ |--
428
+ TT && emp
429
+ .
430
+
431
+ Definition insertion_sort_partial_solve_wit_1 :=
432
+ forall (l: (@list Z)) (p: Z) (res: Z) (l0: (@list Z)) (l1: (@list Z)) (l2: (@list Z)) (PreH1 : (p <> 0)) (PreH2 : (l = (app (l1) (l2)))) (PreH3 : (Permutation l1 l0 )) (PreH4 : (increasing l0 )) ,
433
+ (sll res l0 )
434
+ ** (sll p l2 )
435
+ |--
436
+ EX (x: Z) (l0_2: (@list Z)) (y: Z) ,
437
+ “ (l2 = (cons (x) (l0_2))) ”
438
+ && “ (p <> 0) ”
439
+ && “ (l = (app (l1) (l2))) ”
440
+ && “ (Permutation l1 l0 ) ”
441
+ && “ (increasing l0 ) ”
442
+ && ((&((p) # "list" ->ₛ "next")) # Ptr |-> y)
443
+ ** (sll y l0_2 )
444
+ ** ((&((p) # "list" ->ₛ "data")) # Int |-> x)
445
+ ** (sll res l0 )
446
+ .
447
+
448
+ Definition insertion_sort_partial_solve_wit_2_pure :=
449
+ forall (x_pre: Z) (l: (@list Z)) (p: Z) (res: Z) (l0: (@list Z)) (l1: (@list Z)) (l2: (@list Z)) (x: Z) (l0_2: (@list Z)) (y: Z) (PreH1 : (l2 = (cons (x) (l0_2)))) (PreH2 : (p <> 0)) (PreH3 : (l = (app (l1) (l2)))) (PreH4 : (Permutation l1 l0 )) (PreH5 : (increasing l0 )) ,
450
+ ((&((p) # "list" ->ₛ "next")) # Ptr |-> y)
451
+ ** (sll y l0_2 )
452
+ ** ((&((p) # "list" ->ₛ "data")) # Int |-> x)
453
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
454
+ ** ((( &( "q" ) )) # Ptr |-> y)
455
+ ** ((( &( "res" ) )) # Ptr |-> res)
456
+ ** (sll res l0 )
457
+ ** ((( &( "p" ) )) # Ptr |-> p)
458
+ |--
459
+ “ (p <> 0) ”
460
+ .
461
+
462
+ Definition insertion_sort_partial_solve_wit_2_aux :=
463
+ forall (l: (@list Z)) (p: Z) (res: Z) (l0: (@list Z)) (l1: (@list Z)) (l2: (@list Z)) (x: Z) (l0_2: (@list Z)) (y: Z) (PreH1 : (l2 = (cons (x) (l0_2)))) (PreH2 : (p <> 0)) (PreH3 : (l = (app (l1) (l2)))) (PreH4 : (Permutation l1 l0 )) (PreH5 : (increasing l0 )) ,
464
+ ((&((p) # "list" ->ₛ "next")) # Ptr |-> y)
465
+ ** (sll y l0_2 )
466
+ ** ((&((p) # "list" ->ₛ "data")) # Int |-> x)
467
+ ** (sll res l0 )
468
+ |--
469
+ “ (p <> 0) ”
470
+ && “ (l2 = (cons (x) (l0_2))) ”
471
+ && “ (p <> 0) ”
472
+ && “ (l = (app (l1) (l2))) ”
473
+ && “ (Permutation l1 l0 ) ”
474
+ && “ (increasing l0 ) ”
475
+ && ((&((p) # "list" ->ₛ "data")) # Int |-> x)
476
+ ** (sll res l0 )
477
+ ** ((&((p) # "list" ->ₛ "next")) # Ptr |->_)
478
+ ** (sll y l0_2 )
479
+ .
480
+
481
+ Definition insertion_sort_partial_solve_wit_2 := insertion_sort_partial_solve_wit_2_pure -> insertion_sort_partial_solve_wit_2_aux.
482
+
483
+ Module Type VC_Correct.
484
+
485
+ Include sll_Strategy_Correct.
486
+
487
+ Axiom proof_of_insertion_safety_wit_1 : insertion_safety_wit_1.
488
+ Axiom proof_of_insertion_entail_wit_1 : insertion_entail_wit_1.
489
+ Axiom proof_of_insertion_entail_wit_2 : insertion_entail_wit_2.
490
+ Axiom proof_of_insertion_entail_wit_3_1 : insertion_entail_wit_3_1.
491
+ Axiom proof_of_insertion_entail_wit_3_2 : insertion_entail_wit_3_2.
492
+ Axiom proof_of_insertion_entail_wit_4_1 : insertion_entail_wit_4_1.
493
+ Axiom proof_of_insertion_entail_wit_4_2 : insertion_entail_wit_4_2.
494
+ Axiom proof_of_insertion_return_wit_1 : insertion_return_wit_1.
495
+ Axiom proof_of_insertion_return_wit_2 : insertion_return_wit_2.
496
+ Axiom proof_of_insertion_partial_solve_wit_1 : insertion_partial_solve_wit_1.
497
+ Axiom proof_of_insertion_sort_safety_wit_1 : insertion_sort_safety_wit_1.
498
+ Axiom proof_of_insertion_sort_safety_wit_2 : insertion_sort_safety_wit_2.
499
+ Axiom proof_of_insertion_sort_entail_wit_1 : insertion_sort_entail_wit_1.
500
+ Axiom proof_of_insertion_sort_entail_wit_2 : insertion_sort_entail_wit_2.
501
+ Axiom proof_of_insertion_sort_return_wit_1 : insertion_sort_return_wit_1.
502
+ Axiom proof_of_insertion_sort_partial_solve_wit_1 : insertion_sort_partial_solve_wit_1.
503
+ Axiom proof_of_insertion_sort_partial_solve_wit_2_pure : insertion_sort_partial_solve_wit_2_pure.
504
+ Axiom proof_of_insertion_sort_partial_solve_wit_2 : insertion_sort_partial_solve_wit_2.
505
+
506
+ End VC_Correct.
benchmarks/Algorithms/sll_insertion_sort/rocq/groundtruth/sll_insertion_sort_goal_check.v ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ From PVbench.Algorithms.sll_insertion_sort.rocq.groundtruth Require Import sll_insertion_sort_goal sll_insertion_sort_proof_auto sll_insertion_sort_proof_manual.
2
+
3
+ Module VC_Correctness : VC_Correct.
4
+ Include sll_strategy_proof.
5
+ Include sll_insertion_sort_proof_auto.
6
+ Include sll_insertion_sort_proof_manual.
7
+ End VC_Correctness.
benchmarks/Algorithms/sll_insertion_sort/rocq/groundtruth/sll_insertion_sort_proof_auto.v ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Require Import Coq.ZArith.ZArith.
2
+ Require Import Coq.Bool.Bool.
3
+ Require Import Coq.Strings.String.
4
+ Require Import Coq.Strings.Ascii.
5
+ Require Import Coq.Lists.List.
6
+ Require Import Coq.Classes.RelationClasses.
7
+ Require Import Coq.Classes.Morphisms.
8
+ Require Import Coq.micromega.Psatz.
9
+ Require Import Coq.Sorting.Permutation.
10
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap.
11
+ Require Import SetsClass.SetsClass. Import SetsNotation.
12
+ From SimpleC.SL Require Import Mem SeparationLogic.
13
+ From PVbench.Algorithms.sll_insertion_sort.rocq.groundtruth Require Import sll_insertion_sort_goal.
14
+ Require Import Logic.LogicGenerator.demo932.Interface.
15
+ Local Open Scope Z_scope.
16
+ Local Open Scope sets.
17
+ Local Open Scope string_scope.
18
+ Local Open Scope list.
19
+ Import naive_C_Rules.
20
+ Require Import SimpleC.EE.QCP_demos_LLM.sll_lib.
21
+ Require Import PVbench.Algorithms.sll_insertion_sort.rocq.helper_lib.
22
+ Local Open Scope sac.
23
+
24
+ Lemma proof_of_insertion_safety_wit_1 : insertion_safety_wit_1.
25
+ Proof. Admitted.
26
+
27
+ Lemma proof_of_insertion_entail_wit_3_2 : insertion_entail_wit_3_2.
28
+ Proof. Admitted.
29
+
30
+ Lemma proof_of_insertion_partial_solve_wit_1 : insertion_partial_solve_wit_1.
31
+ Proof. Admitted.
32
+
33
+ Lemma proof_of_insertion_sort_safety_wit_1 : insertion_sort_safety_wit_1.
34
+ Proof. Admitted.
35
+
36
+ Lemma proof_of_insertion_sort_safety_wit_2 : insertion_sort_safety_wit_2.
37
+ Proof. Admitted.
38
+
39
+ Lemma proof_of_insertion_sort_partial_solve_wit_1 : insertion_sort_partial_solve_wit_1.
40
+ Proof. Admitted.
41
+
42
+ Lemma proof_of_insertion_sort_partial_solve_wit_2_pure : insertion_sort_partial_solve_wit_2_pure.
43
+ Proof. Admitted.
44
+
45
+ Lemma proof_of_insertion_sort_partial_solve_wit_2 : insertion_sort_partial_solve_wit_2.
46
+ Proof. Admitted.
47
+
benchmarks/Algorithms/sll_insertion_sort/rocq/groundtruth/sll_insertion_sort_proof_manual.v ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Require Import Coq.ZArith.ZArith.
2
+ Require Import Coq.Bool.Bool.
3
+ Require Import Coq.Strings.String.
4
+ Require Import Coq.Strings.Ascii.
5
+ Require Import Coq.Lists.List.
6
+ Require Import Coq.Classes.RelationClasses.
7
+ Require Import Coq.Classes.Morphisms.
8
+ Require Import Coq.micromega.Psatz.
9
+ Require Import Coq.Sorting.Permutation.
10
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap.
11
+ Require Import SetsClass.SetsClass. Import SetsNotation.
12
+ From SimpleC.SL Require Import Mem SeparationLogic.
13
+ From PVbench.Algorithms.sll_insertion_sort.rocq.groundtruth Require Import sll_insertion_sort_goal.
14
+ From PVbench.Algorithms.sll_insertion_sort.rocq.groundtruth Require Import sll_insertion_sort_proof_auto.
15
+ Require Import Logic.LogicGenerator.demo932.Interface.
16
+ Local Open Scope Z_scope.
17
+ Local Open Scope sets.
18
+ Local Open Scope string_scope.
19
+ Local Open Scope list.
20
+ Import naive_C_Rules.
21
+ Require Import SimpleC.EE.QCP_demos_LLM.sll_lib.
22
+ Require Import PVbench.Algorithms.sll_insertion_sort.rocq.helper_lib.
23
+ Require Import PVbench.Algorithms.sll_insertion_sort.rocq.groundtruth.proof_lib.
24
+ Local Open Scope sac.
25
+
26
+
27
+ Lemma proof_of_insertion_entail_wit_1 : insertion_entail_wit_1.
28
+ Proof.
29
+ LLM_pre_process ltac:(int_auto).
30
+ Exists nil.
31
+ Exists l.
32
+ split_pure_spatial.
33
+ - cancel (&((node_pre) # "list" ->ₛ "data") # Int |-> a).
34
+ cancel (sll p_pre l).
35
+ cancel (&((node_pre) # "list" ->ₛ "next") # Ptr |->_).
36
+ simpl sllbseg.
37
+ split_pure_spatial.
38
+ + cancel.
39
+ + dump_pre_spatial.
40
+ reflexivity.
41
+ - split_pures; try (dump_pre_spatial; auto).
42
+ Qed.
43
+
44
+ Lemma proof_of_insertion_entail_wit_2 : insertion_entail_wit_2.
45
+ Proof.
46
+ LLM_pre_process ltac:(int_auto).
47
+ Exists y.
48
+ Exists (l1_2 ++ x :: nil)%list.
49
+ Exists l0.
50
+ split_pure_spatial.
51
+ - sep_apply (sllbseg_len1 p2 p2_v_2 x); [ | assumption ].
52
+ sep_apply (sllbseg_sllbseg (&( "res" )) p2 (&((p2_v_2) # "list" ->ₛ "next")) l1_2 (x :: nil)%list).
53
+ cancel.
54
+ - split_pures; try (dump_pre_spatial; apply upperbound_app; try assumption; lia).
55
+ dump_pre_spatial ; auto.
56
+ dump_pre_spatial.
57
+ rewrite PreH5.
58
+ rewrite PreH2.
59
+ rewrite <- app_assoc.
60
+ reflexivity.
61
+ Qed.
62
+
63
+ Lemma proof_of_insertion_entail_wit_3_1 : insertion_entail_wit_3_1.
64
+ Proof.
65
+ LLM_pre_process ltac:(int_auto).
66
+ subst p2_v.
67
+ sep_apply (sll_zero 0 l2); [ | reflexivity ].
68
+ Intros_p Hl2.
69
+ Left.
70
+ Exists l1_3.
71
+ split_pure_spatial.
72
+ - cancel ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a).
73
+ cancel (sllbseg ( &( "res" ) ) p2 l1_3).
74
+ cancel ((p2) # Ptr |-> 0).
75
+ cancel ((&((node_pre) # "list" ->ₛ "next")) # Ptr |->_).
76
+ - split_pures.
77
+ + dump_pre_spatial.
78
+ exact PreH2.
79
+ + dump_pre_spatial.
80
+ rewrite Hl2 in PreH3.
81
+ exact PreH3.
82
+ + dump_pre_spatial.
83
+ exact PreH4.
84
+ Qed.
85
+
86
+ Lemma proof_of_insertion_entail_wit_4_1 : insertion_entail_wit_4_1.
87
+ Proof.
88
+ LLM_pre_process ltac:(int_auto).
89
+ Left.
90
+ sep_apply (sllbseg_2_sllseg (&( "res" )) p2 node_pre l1_3).
91
+ Intros resv_2.
92
+ Exists resv_2.
93
+ Exists l1_3.
94
+ split_pure_spatial.
95
+ - cancel ((( &( "res" ) )) # Ptr |-> resv_2).
96
+ cancel (sllseg resv_2 node_pre l1_3).
97
+ cancel ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a).
98
+ cancel ((&((node_pre) # "list" ->ₛ "next")) # Ptr |-> 0).
99
+ - split_pures.
100
+ + dump_pre_spatial.
101
+ exact PreH1.
102
+ + dump_pre_spatial.
103
+ exact PreH2.
104
+ + dump_pre_spatial.
105
+ exact PreH3.
106
+ Qed.
107
+
108
+ Lemma proof_of_insertion_entail_wit_4_2 : insertion_entail_wit_4_2.
109
+ Proof.
110
+ LLM_pre_process ltac:(int_auto).
111
+ Right.
112
+ sep_apply (sllbseg_2_sllseg (&( "res" )) p2 node_pre l1_3).
113
+ Intros resv.
114
+ Exists unext_2.
115
+ Exists resv.
116
+ Exists l1_3.
117
+ Exists l0_2.
118
+ Exists x_2.
119
+ Exists u_2.
120
+ split_pure_spatial.
121
+ - cancel ((( &( "res" ) )) # Ptr |-> resv).
122
+ cancel (sllseg resv node_pre l1_3).
123
+ cancel ((&((node_pre) # "list" ->ₛ "data")) # Int |-> a).
124
+ cancel ((&((node_pre) # "list" ->ₛ "next")) # Ptr |-> u_2).
125
+ cancel ((&((u_2) # "list" ->ₛ "data")) # Int |-> x_2).
126
+ cancel ((&((u_2) # "list" ->ₛ "next")) # Ptr |-> unext_2).
127
+ cancel (sll unext_2 l0_2).
128
+ - split_pures.
129
+ + dump_pre_spatial.
130
+ exact PreH1.
131
+ + dump_pre_spatial.
132
+ exact PreH2.
133
+ + dump_pre_spatial.
134
+ exact PreH3.
135
+ + dump_pre_spatial.
136
+ exact PreH4.
137
+ + dump_pre_spatial.
138
+ exact PreH5.
139
+ Qed.
140
+
141
+ Lemma proof_of_insertion_return_wit_1 : insertion_return_wit_1.
142
+ Proof.
143
+ left.
144
+ LLM_pre_process ltac:(int_auto).
145
+ Exists ((l1 ++ a :: nil)%list).
146
+ split_pure_spatial.
147
+ - sep_apply (sllseg_len1 node_pre a 0); [ | tauto ].
148
+ sep_apply (sllseg_sll resv node_pre l1 (a :: nil)%list).
149
+ cancel (sll resv (l1 ++ a :: nil)%list).
150
+ - dump_pre_spatial.
151
+ rewrite PreH2.
152
+ rewrite app_nil_r.
153
+ symmetry.
154
+ apply upperbound_insert_nil.
155
+ exact PreH3.
156
+ Qed.
157
+
158
+ Lemma proof_of_insertion_return_wit_2 : insertion_return_wit_2.
159
+ Proof.
160
+ left.
161
+ LLM_pre_process ltac:(int_auto).
162
+ Exists (((l1 ++ a :: nil)%list ++ x :: l0_2)%list).
163
+ split_pure_spatial.
164
+ - sep_apply (sllseg_len1 node_pre a u); [ | tauto ].
165
+ sep_apply (sllseg_sllseg resv node_pre u l1 (a :: nil)%list).
166
+ sep_apply_r_atomic (sllseg_sll resv u (l1 ++ a :: nil)%list (x :: l0_2)).
167
+ simpl sll.
168
+ Exists unext.
169
+ split_pure_spatial.
170
+ + cancel (sllseg resv u (l1 ++ a :: nil)%list).
171
+ cancel ((&((u) # "list" ->ₛ "data")) # Int |-> x).
172
+ cancel ((&((u) # "list" ->ₛ "next")) # Ptr |-> unext).
173
+ cancel (sll unext l0_2).
174
+ + dump_pre_spatial.
175
+ exact PreH2.
176
+ - dump_pre_spatial.
177
+ rewrite PreH4.
178
+ assert (a <= x) by lia.
179
+ rewrite (upperbound_insert_cons a l1 l0_2 x PreH5 H).
180
+ rewrite <- app_assoc.
181
+ reflexivity.
182
+ Qed.
183
+
184
+ Lemma proof_of_insertion_sort_entail_wit_1 : insertion_sort_entail_wit_1.
185
+ Proof.
186
+ LLM_pre_process ltac:(int_auto).
187
+ Exists nil.
188
+ Exists nil.
189
+ Exists l.
190
+ split_pure_spatial.
191
+ - simpl sll.
192
+ split_pure_spatial.
193
+ + cancel (sll x_pre l).
194
+ + dump_pre_spatial.
195
+ reflexivity.
196
+ - split_pures.
197
+ + dump_pre_spatial.
198
+ reflexivity.
199
+ + dump_pre_spatial.
200
+ reflexivity.
201
+ Qed.
202
+
203
+ Lemma proof_of_insertion_sort_entail_wit_2 : insertion_sort_entail_wit_2.
204
+ Proof.
205
+ LLM_pre_process ltac:(int_auto).
206
+ Exists l0_4.
207
+ Exists (l1_2 ++ x :: nil)%list.
208
+ Exists l0_3.
209
+ split_pure_spatial.
210
+ - sep_apply store_ptr_undef_store_ptr.
211
+ cancel (sll retval l0_4).
212
+ cancel (sll y l0_3).
213
+ cancel (((&( "q" ))) # Ptr |->_).
214
+ - split_pures.
215
+ + dump_pre_spatial.
216
+ rewrite PreH4.
217
+ rewrite PreH2.
218
+ rewrite <- app_assoc.
219
+ reflexivity.
220
+ + dump_pre_spatial.
221
+ rewrite PreH1.
222
+ rewrite <- perm_insert.
223
+ rewrite PreH5.
224
+ reflexivity.
225
+ + dump_pre_spatial.
226
+ rewrite PreH1.
227
+ apply increasing_insert.
228
+ exact PreH6.
229
+ Qed.
230
+
231
+ Lemma proof_of_insertion_sort_return_wit_1 : insertion_sort_return_wit_1.
232
+ Proof.
233
+ left.
234
+ LLM_pre_process ltac:(int_auto).
235
+ rewrite PreH1.
236
+ sep_apply (sll_zero 0 l2); [ | reflexivity ].
237
+ Intros_p Hl2.
238
+ Exists l0_2.
239
+ split_pure_spatial.
240
+ - rewrite Hl2 in PreH2.
241
+ rewrite app_nil_r in PreH2.
242
+ subst l.
243
+ cancel (sll res l0_2).
244
+ - split_pures.
245
+ + dump_pre_spatial.
246
+ rewrite Hl2 in PreH2.
247
+ rewrite app_nil_r in PreH2.
248
+ subst l.
249
+ exact PreH3.
250
+ + dump_pre_spatial.
251
+ exact PreH4.
252
+ Qed.
benchmarks/Algorithms/sll_insertion_sort/rocq/helper_lib.v ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Require Import Coq.ZArith.ZArith.
2
+ Require Import Coq.Bool.Bool.
3
+ Require Import Coq.Strings.String.
4
+ Require Import Coq.Lists.List.
5
+ Require Import Coq.Classes.RelationClasses.
6
+ Require Import Coq.Classes.Morphisms.
7
+ Require Import Coq.micromega.Psatz.
8
+ Require Import Coq.Sorting.Permutation.
9
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap.
10
+ Require Import SetsClass.SetsClass. Import SetsNotation.
11
+ From SimpleC.SL Require Import Mem SeparationLogic.
12
+ Require Import Logic.LogicGenerator.demo932.Interface.
13
+ Local Open Scope Z_scope.
14
+ Local Open Scope sets.
15
+ Import ListNotations.
16
+ Local Open Scope string.
17
+ Local Open Scope list.
18
+
19
+ Fixpoint insert (x: Z) (l: list Z): list Z :=
20
+ match l with
21
+ | nil => [x]
22
+ | y :: l' => if x >? y then y :: insert x l' else x :: l
23
+ end.
benchmarks/Algorithms/sll_insertion_sort/rocq/solution_annotated.c ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #include "sll_def.h"
2
+
3
+ /*@ Import Coq Require Import PVbench.Algorithms.sll_insertion_sort.rocq.helper_lib */
4
+
5
+ /*@ Extern Coq (Permutation: list Z -> list Z -> Prop)
6
+ (increasing: list Z -> Prop)
7
+ (insert: Z -> list Z -> list Z)
8
+ (strict_upperbound: Z -> list Z -> Prop)
9
+ */
10
+
11
+ struct list * insertion(struct list * p, struct list * node)
12
+ /*@ With l a
13
+ Require node != 0 && node->data == a &&
14
+ sll(p, l) *
15
+ undef_data_at(&(node->next), struct list*)
16
+ Ensure exists l0,
17
+ l0 == insert(a, l) && sll(__return, l0)
18
+ */
19
+ {
20
+ struct list * res = p;
21
+ struct list * * p2 = & res;
22
+ /*@ Inv Assert
23
+ exists l1 l2,
24
+ node == node@pre && p == p@pre &&
25
+ node != (void *)0 &&
26
+ l == app(l1, l2) &&
27
+ node->data == a &&
28
+ strict_upperbound(a, l1) &&
29
+ sllbseg(&res, p2, l1) * sll(*p2, l2) *
30
+ undef_data_at(&(node->next), struct list*)
31
+ */
32
+ while (* p2 != (void * )0 && (* p2) -> data < node -> data) {
33
+ p2 = &((* p2) -> next);
34
+ }
35
+ /*@ Assert
36
+ (exists l1,
37
+ node == node@pre && p == p@pre &&
38
+ node != (void *)0 &&
39
+ l == app(l1, nil) &&
40
+ node->data == a &&
41
+ strict_upperbound(a, l1) &&
42
+ sllbseg(&res, p2, l1) *
43
+ store(p2, struct list*, (void *)0) *
44
+ undef_data_at(&(node->next), struct list*))
45
+ ||
46
+ (exists l1 x l0 u unext,
47
+ node == node@pre && p == p@pre &&
48
+ node != (void *)0 &&
49
+ u != (void *)0 &&
50
+ x >= a &&
51
+ l == app(l1, cons(x, l0)) &&
52
+ node->data == a &&
53
+ strict_upperbound(a, l1) &&
54
+ sllbseg(&res, p2, l1) *
55
+ store(p2, struct list*, u) *
56
+ store(&(u->data), x) *
57
+ store(&(u->next), struct list*, unext) *
58
+ sll(unext, l0) *
59
+ undef_data_at(&(node->next), struct list*))
60
+ */
61
+ node -> next = * p2;
62
+ * p2 = node;
63
+ /*@ Assert
64
+ (exists resv l1,
65
+ node == node@pre && p == p@pre &&
66
+ node != (void *)0 &&
67
+ l == app(l1, nil) &&
68
+ strict_upperbound(a, l1) &&
69
+ store(&p2, struct list**, p2) *
70
+ store(&res, struct list*, resv) *
71
+ sllseg(resv, node, l1) *
72
+ store(&(node->data), a) *
73
+ store(&(node->next), struct list*, (void *)0))
74
+ ||
75
+ (exists resv l1 x l0 u unext,
76
+ node == node@pre && p == p@pre &&
77
+ node != (void *)0 &&
78
+ u != (void *)0 &&
79
+ x >= a &&
80
+ l == app(l1, cons(x, l0)) &&
81
+ strict_upperbound(a, l1) &&
82
+ store(&p2, struct list**, p2) *
83
+ store(&res, struct list*, resv) *
84
+ sllseg(resv, node, l1) *
85
+ store(&(node->data), a) *
86
+ store(&(node->next), struct list*, u) *
87
+ store(&(u->data), x) *
88
+ store(&(u->next), struct list*, unext) *
89
+ sll(unext, l0))
90
+ */
91
+ return res;
92
+ }
93
+
94
+ struct list * insertion_sort(struct list * x)
95
+ /*@ With l
96
+ Require sll(x, l)
97
+ Ensure exists l0,
98
+ Permutation(l, l0) && increasing(l0) &&
99
+ sll(__return, l0)
100
+ */
101
+ {
102
+ struct list * res = (void *)0, * p = x, * q;
103
+ /*@ Inv Assert
104
+ exists l0 l1 l2,
105
+ l == app(l1, l2) && x == x@pre &&
106
+ Permutation(l1, l0) && increasing(l0) &&
107
+ has_ptr_permission(&q) *
108
+ sll(res, l0) * sll(p, l2)
109
+ */
110
+ while (p != (void * )0) {
111
+ q = p -> next;
112
+ res = insertion(res, p);
113
+ p = q;
114
+ }
115
+ return res;
116
+ }
benchmarks/Algorithms/sll_insertion_sort/rocq/solution_spec.c ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #include "sll_def.h"
2
+
3
+ /*@ Extern Coq
4
+ (Permutation : list Z -> list Z -> Prop)
5
+ (increasing : list Z -> Prop)
6
+ */
7
+
8
+ struct list * insertion(struct list * p, struct list * node)
9
+ {
10
+ struct list * res = p;
11
+ struct list * * p2 = & res;
12
+
13
+ while (* p2 != (void * )0 && (* p2) -> data < node -> data) {
14
+ p2 = &((* p2) -> next);
15
+ }
16
+
17
+ node -> next = * p2;
18
+ * p2 = node;
19
+
20
+ return res;
21
+ }
22
+
23
+ struct list * insertion_sort(struct list * x)
24
+ /*@ With l
25
+ Require sll(x, l)
26
+ Ensure exists l0,
27
+ Permutation(l, l0) && increasing(l0) &&
28
+ sll(__return, l0)
29
+ */
30
+ {
31
+ struct list * res = (void *)0, * p = x, * q;
32
+
33
+ while (p != (void * )0) {
34
+ q = p -> next;
35
+ res = insertion(res, p);
36
+ p = q;
37
+ }
38
+ return res;
39
+ }
benchmarks/Algorithms/sll_insertion_sort/solution.c ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #include "sll_def.h"
2
+
3
+ struct list * insertion(struct list * p, struct list * node)
4
+ {
5
+ struct list * res = p;
6
+ struct list * * p2 = & res;
7
+
8
+ while (* p2 != (void * )0 && (* p2) -> data < node -> data) {
9
+ p2 = &((* p2) -> next);
10
+ }
11
+
12
+ node -> next = * p2;
13
+ * p2 = node;
14
+
15
+ return res;
16
+ }
17
+
18
+ struct list * insertion_sort(struct list * x)
19
+ {
20
+ struct list * res = (void *)0, * p = x, * q;
21
+
22
+ while (p != (void * )0) {
23
+ q = p -> next;
24
+ res = insertion(res, p);
25
+ p = q;
26
+ }
27
+ return res;
28
+ }
benchmarks/Algorithms/sll_merge_sort/manifest.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": "sll_merge_sort",
3
+ "source": {
4
+ "dataset": "classical_algorithm",
5
+ "problem_id": "sll_merge_sort",
6
+ "title": "Merge Sort on a Singly Linked List",
7
+ "tags": [
8
+ "sort",
9
+ "merge",
10
+ "linked list"
11
+ ]
12
+ },
13
+ "stratification": {
14
+ "band": "unclassified",
15
+ "output_mode": "CONSTRUCT",
16
+ "interactive": false,
17
+ "multi_test": false
18
+ }
19
+ }
benchmarks/Algorithms/sll_merge_sort/problem.md ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Merge Sort on a Singly Linked List
2
+
3
+ ## Description
4
+
5
+ Sort a null-terminated singly linked list of integers into nondecreasing order using top-down merge sort, relinking the existing nodes.
6
+
7
+ ## Input
8
+
9
+ A list is given by a pointer to its first node, or `NULL` when empty:
10
+
11
+ ```c
12
+ struct list {
13
+ int data;
14
+ struct list *next;
15
+ };
16
+ ```
17
+
18
+ The function receives the head `x` of the list.
19
+
20
+ ## Output
21
+
22
+ Return the head of a list holding the same values in nondecreasing order.
benchmarks/Algorithms/sll_merge_sort/rocq/groundtruth/proof_lib.v ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (* Supporting lemmas for the manual proof. *)
2
+ Require Import Coq.ZArith.ZArith.
3
+ Require Import Coq.Bool.Bool.
4
+ Require Import Coq.Strings.String.
5
+ Require Import Coq.Lists.List.
6
+ Require Import Coq.Classes.RelationClasses.
7
+ Require Import Coq.Classes.Morphisms.
8
+ Require Import Coq.micromega.Psatz.
9
+ Require Import Coq.Sorting.Permutation.
10
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap.
11
+ Require Import SetsClass.SetsClass. Import SetsNotation.
12
+ From SimpleC.SL Require Import Mem SeparationLogic.
13
+ Require Import Logic.LogicGenerator.demo932.Interface.
14
+ Local Open Scope Z_scope.
15
+ Local Open Scope sets.
16
+ Local Open Scope string.
17
+ Local Open Scope list.
18
+ Import naive_C_Rules.
19
+ From SimpleC.EE.QCP_demos_LLM Require Import sll_lib.
20
+ From FP Require Import SetsFixedpoints.
21
+ Require Import MonadLib.StateRelMonad.StateRelMonad.
22
+ Export MonadNotation.
23
+ Require Import PVbench.Algorithms.sll_merge_sort.rocq.helper_lib.
24
+ Local Open Scope monad.
25
+ Local Open Scope sac.
26
+ Import ListNotations.
27
+ Local Open Scope list.
28
+
29
+ (* From QCP's MonadLib/Examples/mergesort.v: the monadic merge sort is a sorted permutation. *)
30
+
31
+ Lemma split_rec_rel_unfold: split_rec_rel' == split_rec_rel_f split_rec_rel'.
32
+ Proof.
33
+ intros.
34
+ unfold split_rec_rel'.
35
+ apply Lfix_fixpoint'.
36
+ unfold split_rec_rel_f.
37
+ mono_cont_auto.
38
+ Qed.
39
+
40
+
41
+ Lemma split_rec_rel_eval_xnil: forall p q P,
42
+ P -@ (split_rec_rel' (nil, p, q)) -⥅
43
+ P ♯ (p, q).
44
+ Proof.
45
+ intros.
46
+ erewrite (program_para_equiv (split_rec_rel_unfold)).
47
+ unfold split_rec_rel_f.
48
+ apply highret_eval2.
49
+ Qed.
50
+
51
+
52
+ Lemma split_rel_eval_xnotnil: forall z x p q,
53
+ forall P X, safeExec P (split_rec_rel' (z::x, p, q)) X ->
54
+ safeExec P (x <- split_rec_rel' (x, q, z::p) ;; reversepair x ) X.
55
+ Proof.
56
+ unfold split_rel, reversepair. intros.
57
+ erewrite (program_para_equiv (split_rec_rel_unfold)) in H.
58
+ unfold split_rec_rel_f in H.
59
+ apply H.
60
+ Qed.
61
+
62
+ Lemma bind_2_reversepair_equiv_Id:
63
+ (fun p => z <- reversepair p ;; reversepair z) == ret.
64
+ Proof.
65
+ intros [x y].
66
+ unfold reversepair;sets_unfold.
67
+ intros s [u v] s'.
68
+ split;intros.
69
+ - destruct H as ([x' y'] & s'' & ? & ? ).
70
+ unfold_monad in H. destruct H.
71
+ unfold_monad in H0. destruct H0.
72
+ inversion H; inversion H0. subst.
73
+ unfold_monad. auto.
74
+ - unfold_monad in H. destruct H.
75
+ inversion H;subst.
76
+ do 3 eexists.
77
+ split;eauto.
78
+ cbn. sets_unfold. unfold_monad. auto.
79
+ Qed.
80
+
81
+ Lemma mergesortrec_unfold: mergesortrec == mergesortrec_f mergesortrec.
82
+ Proof.
83
+ intros.
84
+ unfold mergesortrec.
85
+ apply Lfix_fixpoint'.
86
+ unfold mergesortrec_f.
87
+ mono_cont_auto.
88
+ Qed.
89
+
90
+
91
+
92
+ Theorem merge_perm:
93
+ forall l1 l2,
94
+ Hoare (fun _ => True)
95
+ (merge_rel l1 l2)
96
+ (fun r _ => Permutation (l1 ++ l2) r).
97
+ Proof.
98
+ intros.
99
+ unfold merge_rel.
100
+ eapply Hoare_conseq_pre.
101
+ 2:
102
+ apply (Hoare_repeat_break _
103
+ (fun '(l1', l2', l3') _ =>
104
+ Permutation (l1 ++ l2) (l1' ++ l2' ++ l3'))).
105
+ { intros. simpl. rewrite app_nil_r. reflexivity. }
106
+
107
+ intros [[l1' l2'] l3'].
108
+ unfold merge_body.
109
+ destruct l1' as [ | x l1']; [| destruct l2' as [| y l2']].
110
+ + hoare_auto.
111
+ rewrite H; simpl.
112
+ apply Permutation_app_comm.
113
+ + hoare_auto.
114
+ rewrite H.
115
+ rewrite Permutation_app_comm.
116
+ reflexivity.
117
+ + hoare_auto.
118
+ - rewrite H0.
119
+ rewrite ! app_assoc.
120
+ rewrite (Permutation_app_comm _ [x]).
121
+ reflexivity.
122
+ - rewrite H0.
123
+ apply Permutation_app; [reflexivity |].
124
+ rewrite ! app_assoc.
125
+ rewrite (Permutation_app_comm _ [y]).
126
+ reflexivity.
127
+ Qed.
128
+
129
+ Lemma incr_app_cons: forall l1 x l2,
130
+ incr (l1 ++ [x]) ->
131
+ incr (x :: l2) ->
132
+ incr (l1 ++ x :: l2).
133
+ Proof.
134
+ intros.
135
+ simpl in H0.
136
+ destruct l1 as [| a l1]; simpl in *.
137
+ { tauto. }
138
+ revert a H; induction l1; simpl; intros.
139
+ + tauto.
140
+ + split; [tauto |].
141
+ apply IHl1.
142
+ tauto.
143
+ Qed.
144
+
145
+ Lemma incr_app_cons_inv1: forall l1 x l2,
146
+ incr (l1 ++ x :: l2) ->
147
+ incr (l1 ++ [x]).
148
+ Proof.
149
+ intros.
150
+ destruct l1 as [| a l1]; simpl in *.
151
+ { tauto. }
152
+ revert a H; induction l1; simpl; intros.
153
+ + tauto.
154
+ + split; [tauto |].
155
+ apply IHl1.
156
+ tauto.
157
+ Qed.
158
+
159
+ Lemma incr_app_cons_inv2: forall l1 x l2,
160
+ incr (l1 ++ x :: l2) ->
161
+ incr (x :: l2).
162
+ Proof.
163
+ intros.
164
+ simpl.
165
+ induction l1; simpl in *.
166
+ + tauto.
167
+ + apply IHl1.
168
+ destruct l1; simpl in *; tauto.
169
+ Qed.
170
+
171
+ Theorem merge_incr:
172
+ forall l1 l2,
173
+ incr l1 ->
174
+ incr l2 ->
175
+ Hoare (fun _ => True) (merge_rel l1 l2) (fun r _ => incr r).
176
+ Proof.
177
+ intros.
178
+ unfold merge_rel.
179
+ eapply Hoare_conseq_pre.
180
+ 2:
181
+ apply (Hoare_repeat_break _
182
+ (fun '(l1', l2', l3') _ =>
183
+ incr (l3' ++ l1') /\
184
+ incr (l3' ++ l2'))).
185
+ 1: {
186
+ tauto.
187
+ }
188
+ clear l1 l2 H H0.
189
+ intros [[l1 l2] l3].
190
+ unfold merge_body.
191
+ destruct l1 as [ | x l1]; [| destruct l2 as [| y l2]].
192
+ + hoare_auto. tauto.
193
+ + hoare_auto. tauto.
194
+ + hoare_auto.
195
+ - split.
196
+ * rewrite <- app_assoc.
197
+ tauto.
198
+ * rewrite <- app_assoc.
199
+ simpl.
200
+ destruct H0.
201
+ apply incr_app_cons_inv1 in H0.
202
+ apply incr_app_cons_inv2 in H1.
203
+ apply incr_app_cons; simpl in *; tauto.
204
+ - split.
205
+ * rewrite <- app_assoc.
206
+ simpl.
207
+ destruct H0.
208
+ apply incr_app_cons_inv1 in H1.
209
+ apply incr_app_cons_inv2 in H0.
210
+ apply incr_app_cons; simpl in *; tauto.
211
+ * rewrite <- app_assoc.
212
+ tauto.
213
+ Qed.
214
+
215
+ Theorem functional_correctness_merge:
216
+ forall l1 l2,
217
+ incr l1 ->
218
+ incr l2 ->
219
+ Hoare (fun _ => True)
220
+ (merge_rel l1 l2)
221
+ (fun l3 _ => Permutation (l1 ++ l2) l3 /\ incr l3).
222
+ Proof.
223
+ intros.
224
+ apply Hoare_conj.
225
+ + apply merge_perm.
226
+ + apply merge_incr; tauto.
227
+ Qed.
228
+
229
+
230
+ Theorem functional_correctness_split:
231
+ forall l,
232
+ Hoare (fun _ => True)
233
+ (split_rel l)
234
+ (fun '(l1, l2) _ => Permutation l (l1 ++ l2) /\ (0 <= length l1 - length l2 <= 1)%nat).
235
+ Proof.
236
+ intros.
237
+ unfold split_rel, split_rec_rel'.
238
+ apply Hoare_conseq_post with (Q2 := fun '(l1, l2) _ =>
239
+ Permutation ((fst (fst (l, @nil Z, @nil Z))) ++ (snd (fst (l, [], @nil Z))) ++ (snd (l, @nil Z, []))) (l1 ++ l2) /\
240
+ (@length Z (snd (fst (l, [], @nil Z))) <= length l1 /\
241
+ @length Z (snd (l, @nil Z, [])) <= length l2 /\
242
+ length l2 - @length Z (snd (l, @nil Z, [])) <= length l1 - @length Z (snd (fst (l, [], @nil Z))) <= S (length l2 - @length Z (snd (l, @nil Z, []))))%nat).
243
+ { simpl. rewrite app_nil_r.
244
+ intros [l1 l2];intros.
245
+ split; try tauto.
246
+ lia. }
247
+ hoare_fix_nolv_auto ((list Z * list Z)%type * list Z)%type.
248
+ simpl;intros * H [[l0 l1] l2]. simpl.
249
+ destruct l0.
250
+ - hoare_auto. split;auto. lia.
251
+ - eapply Hoare_bind;[apply H |].
252
+ simpl.
253
+ intros [? ?].
254
+ unfold reversepair.
255
+ hoare_auto.
256
+ split.
257
+ + rewrite (Permutation_app_comm l1 l2).
258
+ rewrite !Permutation_middle.
259
+ destruct H0 as [H0 _].
260
+ rewrite H0.
261
+ apply Permutation_app_comm.
262
+ + lia.
263
+ Qed.
264
+
265
+
266
+ Theorem functional_correctness_mergesort:
267
+ forall l,
268
+ Hoare ATrue (mergesortrec l) (fun l0 _ => Permutation l l0 /\ incr l0).
269
+ Proof.
270
+ intros.
271
+ unfold mergesortrec, ATrue.
272
+ hoare_fix_nolv_auto (list Z).
273
+ simpl.
274
+ intros.
275
+ unfold mergesortrec_f.
276
+ eapply Hoare_bind;[apply functional_correctness_split | ].
277
+ intros [l1 l2].
278
+ destruct l2.
279
+ - hoare_auto.
280
+ rewrite app_nil_r in H0. destruct H0. split;auto.
281
+ simpl in H1.
282
+ destruct l1;[cbn;auto | ].
283
+ destruct l1;[ | simpl in H1; lia].
284
+ cbn. auto.
285
+ - apply Hoare_stateless;intros.
286
+ eapply Hoare_bind;[apply H| ].
287
+ intros lp;simpl.
288
+ apply Hoare_stateless;intros.
289
+ eapply Hoare_bind;[apply H| ].
290
+ intros lq;simpl.
291
+ apply Hoare_stateless;intros.
292
+ eapply Hoare_conseq_post.
293
+ 2: { apply functional_correctness_merge;try tauto. }
294
+ destruct H0.
295
+ destruct H1. destruct H2.
296
+ intros lr ? [? ?].
297
+ rewrite H0.
298
+ rewrite H1, H2.
299
+ tauto.
300
+ Qed.
301
+
302
+
benchmarks/Algorithms/sll_merge_sort/rocq/groundtruth/sll_merge_sort_goal.v ADDED
@@ -0,0 +1,900 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Require Import Coq.ZArith.ZArith.
2
+ Require Import Coq.Bool.Bool.
3
+ Require Import Coq.Strings.String.
4
+ Require Import Coq.Strings.Ascii.
5
+ Require Import Coq.Lists.List.
6
+ Require Import Coq.Classes.RelationClasses.
7
+ Require Import Coq.Classes.Morphisms.
8
+ Require Import Coq.micromega.Psatz.
9
+ Require Import Coq.Sorting.Permutation.
10
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap.
11
+ Require Import SetsClass.SetsClass. Import SetsNotation.
12
+ From SimpleC.SL Require Import Mem SeparationLogic.
13
+ Require Import Logic.LogicGenerator.demo932.Interface.
14
+ Local Open Scope Z_scope.
15
+ Local Open Scope sets.
16
+ Local Open Scope string_scope.
17
+ Local Open Scope list.
18
+ Import naive_C_Rules.
19
+ Require Import SimpleC.EE.QCP_demos_LLM.sll_lib.
20
+ From MonadLib Require Export MonadLib.
21
+ From MonadLib.StateRelMonad Require Export StateRelMonad.
22
+ Export MonadNotation.
23
+ Local Open Scope monad.
24
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap relations.
25
+ From FP Require Import PartialOrder_Setoid BourbakiWitt.
26
+ Require Import PVbench.Algorithms.sll_merge_sort.rocq.spec_lib.
27
+ Require Import PVbench.Algorithms.sll_merge_sort.rocq.helper_lib.
28
+ Local Open Scope sac.
29
+ From SimpleC.EE.QCP_demos_LLM Require Import sll_strategy_goal.
30
+ From SimpleC.EE.QCP_demos_LLM Require Import sll_strategy_proof.
31
+ From SimpleC.EE.QCP_demos_LLM Require Import safeexec_strategy_goal.
32
+ From SimpleC.EE.QCP_demos_LLM Require Import safeexec_strategy_proof.
33
+
34
+ (*----- Function merge -----*)
35
+
36
+ Definition merge_safety_wit_1 :=
37
+ forall (X: ((@list Z) -> (unit -> Prop))) (t: Z) (y: Z) (x: Z) (l1: (@list Z)) (l2: (@list Z)) (l3: (@list Z)) (PreH1 : (safeExec ATrue (merge_from_mid_rel (l1) (l2) (l3)) X )) ,
38
+ ((( &( "x" ) )) # Ptr |-> x)
39
+ ** (sll x l1 )
40
+ ** ((( &( "y" ) )) # Ptr |-> y)
41
+ ** (sll y l2 )
42
+ ** ((( &( "t" ) )) # Ptr |-> t)
43
+ ** ((t) # Ptr |->_)
44
+ ** (sllbseg ( &( "ret" ) ) t l3 )
45
+ |--
46
+ “ (1 <= INT_MAX) ”
47
+ && “ ((INT_MIN) <= 1) ”
48
+ .
49
+
50
+ Definition merge_safety_wit_2 :=
51
+ forall (X: ((@list Z) -> (unit -> Prop))) (t: Z) (y: Z) (x: Z) (l1: (@list Z)) (l2: (@list Z)) (l3: (@list Z)) (PreH1 : (safeExec ATrue (merge_from_mid_rel (l1) (l2) (l3)) X )) ,
52
+ ((( &( "x" ) )) # Ptr |-> x)
53
+ ** (sll x l1 )
54
+ ** ((( &( "y" ) )) # Ptr |-> y)
55
+ ** (sll y l2 )
56
+ ** ((( &( "t" ) )) # Ptr |-> t)
57
+ ** ((t) # Ptr |->_)
58
+ ** (sllbseg ( &( "ret" ) ) t l3 )
59
+ |--
60
+ “ (0 <= INT_MAX) ”
61
+ && “ ((INT_MIN) <= 0) ”
62
+ .
63
+
64
+ Definition merge_safety_wit_3 :=
65
+ forall (X: ((@list Z) -> (unit -> Prop))) (t: Z) (y: Z) (x: Z) (l1: (@list Z)) (l2: (@list Z)) (l3: (@list Z)) (PreH1 : (x <> 0)) (PreH2 : (safeExec ATrue (merge_from_mid_rel (l1) (l2) (l3)) X )) ,
66
+ ((( &( "x" ) )) # Ptr |-> x)
67
+ ** (sll x l1 )
68
+ ** ((( &( "y" ) )) # Ptr |-> y)
69
+ ** (sll y l2 )
70
+ ** ((( &( "t" ) )) # Ptr |-> t)
71
+ ** ((t) # Ptr |->_)
72
+ ** (sllbseg ( &( "ret" ) ) t l3 )
73
+ |--
74
+ “ (0 <= INT_MAX) ”
75
+ && “ ((INT_MIN) <= 0) ”
76
+ .
77
+
78
+ Definition merge_entail_wit_1 :=
79
+ (
80
+ forall (y_pre: Z) (x_pre: Z) (X: ((@list Z) -> (unit -> Prop))) (s2: (@list Z)) (s1: (@list Z)) (PreH1 : (safeExec ATrue (merge_rel (s1) (s2)) X )) ,
81
+ ((( &( "ret" ) )) # Ptr |->_)
82
+ ** (sll x_pre s1 )
83
+ ** (sll y_pre s2 )
84
+ |--
85
+ EX (l1: (@list Z)) (l2: (@list Z)) (l3: (@list Z)) ,
86
+ “ (safeExec ATrue (merge_from_mid_rel (l1) (l2) (l3)) X ) ”
87
+ && (sll x_pre l1 )
88
+ ** (sll y_pre l2 )
89
+ ** ((( &( "ret" ) )) # Ptr |->_)
90
+ ** (sllbseg ( &( "ret" ) ) ( &( "ret" ) ) l3 )
91
+ ) \/
92
+ (
93
+ forall (X: ((@list Z) -> (unit -> Prop))) (s2: (@list Z)) (s1: (@list Z)) (PreH1 : (safeExec ATrue (merge_rel (s1) (s2)) X )) ,
94
+ TT && emp
95
+ |--
96
+ “ (safeExec ATrue (merge_from_mid_rel (s1) (s2) ((@nil Z))) X ) ”
97
+ && emp
98
+ ).
99
+
100
+ Definition merge_entail_wit_1_split_goal_1 :=
101
+ forall (X: ((@list Z) -> (unit -> Prop))) (s2: (@list Z)) (s1: (@list Z)) (PreH1 : (safeExec ATrue (merge_rel (s1) (s2)) X )) ,
102
+ (safeExec ATrue (merge_from_mid_rel (s1) (s2) ((@nil Z))) X )
103
+ .
104
+
105
+ Definition merge_entail_wit_2 :=
106
+ forall (X: ((@list Z) -> (unit -> Prop))) (t: Z) (y: Z) (x: Z) (l1_2: (@list Z)) (l2_2: (@list Z)) (l3_2: (@list Z)) (PreH1 : (y <> 0)) (PreH2 : (x <> 0)) (PreH3 : (safeExec ATrue (merge_from_mid_rel (l1_2) (l2_2) (l3_2)) X )) ,
107
+ (sll x l1_2 )
108
+ ** (sll y l2_2 )
109
+ ** ((t) # Ptr |->_)
110
+ ** (sllbseg ( &( "ret" ) ) t l3_2 )
111
+ |--
112
+ EX (ynext: Z) (xnext: Z) (ydata: Z) (l2_new: (@list Z)) (xdata: Z) (l1_new: (@list Z)) (l1: (@list Z)) (l2: (@list Z)) (l3: (@list Z)) ,
113
+ “ (safeExec ATrue (merge_from_mid_rel (l1) (l2) (l3)) X ) ”
114
+ && “ (x <> 0) ”
115
+ && “ (y <> 0) ”
116
+ && “ (l1 = (cons (xdata) (l1_new))) ”
117
+ && “ (l2 = (cons (ydata) (l2_new))) ”
118
+ && ((&((x) # "list" ->ₛ "data")) # Int |-> xdata)
119
+ ** ((&((y) # "list" ->ₛ "data")) # Int |-> ydata)
120
+ ** ((&((x) # "list" ->ₛ "next")) # Ptr |-> xnext)
121
+ ** ((&((y) # "list" ->ₛ "next")) # Ptr |-> ynext)
122
+ ** (sll xnext l1_new )
123
+ ** (sll ynext l2_new )
124
+ ** ((t) # Ptr |->_)
125
+ ** (sllbseg ( &( "ret" ) ) t l3 )
126
+ .
127
+
128
+ Definition merge_entail_wit_3_1 :=
129
+ (
130
+ forall (X: ((@list Z) -> (unit -> Prop))) (l1_2: (@list Z)) (l2_2: (@list Z)) (l3_2: (@list Z)) (l1_new: (@list Z)) (l2_new: (@list Z)) (xdata: Z) (ydata: Z) (xnext: Z) (ynext: Z) (x: Z) (y: Z) (t: Z) (PreH1 : (xdata < ydata)) (PreH2 : (safeExec ATrue (merge_from_mid_rel (l1_2) (l2_2) (l3_2)) X )) (PreH3 : (x <> 0)) (PreH4 : (y <> 0)) (PreH5 : (l1_2 = (cons (xdata) (l1_new)))) (PreH6 : (l2_2 = (cons (ydata) (l2_new)))) ,
131
+ ((&((x) # "list" ->ₛ "data")) # Int |-> xdata)
132
+ ** ((&((y) # "list" ->ₛ "data")) # Int |-> ydata)
133
+ ** ((&((x) # "list" ->ₛ "next")) # Ptr |-> xnext)
134
+ ** ((&((y) # "list" ->ₛ "next")) # Ptr |-> ynext)
135
+ ** (sll xnext l1_new )
136
+ ** (sll ynext l2_new )
137
+ ** ((t) # Ptr |-> x)
138
+ ** (sllbseg ( &( "ret" ) ) t l3_2 )
139
+ |--
140
+ EX (l1: (@list Z)) (l2: (@list Z)) (l3: (@list Z)) ,
141
+ “ (safeExec ATrue (merge_from_mid_rel (l1) (l2) (l3)) X ) ”
142
+ && (sll xnext l1 )
143
+ ** (sll y l2 )
144
+ ** ((&((x) # "list" ->ₛ "next")) # Ptr |->_)
145
+ ** (sllbseg ( &( "ret" ) ) &((x) # "list" ->ₛ "next") l3 )
146
+ ) \/
147
+ (
148
+ forall (X: ((@list Z) -> (unit -> Prop))) (l1_2: (@list Z)) (l2_2: (@list Z)) (l3_2: (@list Z)) (l1_new: (@list Z)) (l2_new: (@list Z)) (xdata: Z) (ydata: Z) (x: Z) (y: Z) (t: Z) (PreH1 : (xdata <= INT_MAX)) (PreH2 : (xdata >= INT_MIN)) (PreH3 : (xdata < ydata)) (PreH4 : (safeExec ATrue (merge_from_mid_rel (l1_2) (l2_2) (l3_2)) X )) (PreH5 : (x <> 0)) (PreH6 : (y <> 0)) (PreH7 : (l1_2 = (cons (xdata) (l1_new)))) (PreH8 : (l2_2 = (cons (ydata) (l2_new)))) ,
149
+ ((&((x) # "list" ->ₛ "data")) # Int |-> xdata)
150
+ ** ((t) # Ptr |-> x)
151
+ ** (sllbseg ( &( "ret" ) ) t l3_2 )
152
+ |--
153
+ EX (l3: (@list Z)) ,
154
+ “ (y <> 0) ”
155
+ && “ (safeExec ATrue (merge_from_mid_rel (l1_new) ((cons (ydata) (l2_new))) (l3)) X ) ”
156
+ && (sllbseg ( &( "ret" ) ) &((x) # "list" ->ₛ "next") l3 )
157
+ ).
158
+
159
+ Definition merge_entail_wit_3_2 :=
160
+ (
161
+ forall (X: ((@list Z) -> (unit -> Prop))) (l1_2: (@list Z)) (l2_2: (@list Z)) (l3_2: (@list Z)) (l1_new: (@list Z)) (l2_new: (@list Z)) (xdata: Z) (ydata: Z) (xnext: Z) (ynext: Z) (x: Z) (y: Z) (t: Z) (PreH1 : (xdata >= ydata)) (PreH2 : (safeExec ATrue (merge_from_mid_rel (l1_2) (l2_2) (l3_2)) X )) (PreH3 : (x <> 0)) (PreH4 : (y <> 0)) (PreH5 : (l1_2 = (cons (xdata) (l1_new)))) (PreH6 : (l2_2 = (cons (ydata) (l2_new)))) ,
162
+ ((&((x) # "list" ->ₛ "data")) # Int |-> xdata)
163
+ ** ((&((y) # "list" ->ₛ "data")) # Int |-> ydata)
164
+ ** ((&((x) # "list" ->ₛ "next")) # Ptr |-> xnext)
165
+ ** ((&((y) # "list" ->ₛ "next")) # Ptr |-> ynext)
166
+ ** (sll xnext l1_new )
167
+ ** (sll ynext l2_new )
168
+ ** ((t) # Ptr |-> y)
169
+ ** (sllbseg ( &( "ret" ) ) t l3_2 )
170
+ |--
171
+ EX (l1: (@list Z)) (l2: (@list Z)) (l3: (@list Z)) ,
172
+ “ (safeExec ATrue (merge_from_mid_rel (l1) (l2) (l3)) X ) ”
173
+ && (sll x l1 )
174
+ ** (sll ynext l2 )
175
+ ** ((&((y) # "list" ->ₛ "next")) # Ptr |->_)
176
+ ** (sllbseg ( &( "ret" ) ) &((y) # "list" ->ₛ "next") l3 )
177
+ ) \/
178
+ (
179
+ forall (X: ((@list Z) -> (unit -> Prop))) (l1_2: (@list Z)) (l2_2: (@list Z)) (l3_2: (@list Z)) (l1_new: (@list Z)) (l2_new: (@list Z)) (xdata: Z) (ydata: Z) (x: Z) (y: Z) (t: Z) (PreH1 : (ydata <= INT_MAX)) (PreH2 : (ydata >= INT_MIN)) (PreH3 : (xdata >= ydata)) (PreH4 : (safeExec ATrue (merge_from_mid_rel (l1_2) (l2_2) (l3_2)) X )) (PreH5 : (x <> 0)) (PreH6 : (y <> 0)) (PreH7 : (l1_2 = (cons (xdata) (l1_new)))) (PreH8 : (l2_2 = (cons (ydata) (l2_new)))) ,
180
+ ((&((y) # "list" ->ₛ "data")) # Int |-> ydata)
181
+ ** ((t) # Ptr |-> y)
182
+ ** (sllbseg ( &( "ret" ) ) t l3_2 )
183
+ |--
184
+ EX (l3: (@list Z)) ,
185
+ “ (x <> 0) ”
186
+ && “ (safeExec ATrue (merge_from_mid_rel ((cons (xdata) (l1_new))) (l2_new) (l3)) X ) ”
187
+ && (sllbseg ( &( "ret" ) ) &((y) # "list" ->ₛ "next") l3 )
188
+ ).
189
+
190
+ Definition merge_entail_wit_4_1 :=
191
+ (
192
+ forall (X: ((@list Z) -> (unit -> Prop))) (t: Z) (y: Z) (x: Z) (l1: (@list Z)) (l2: (@list Z)) (l3: (@list Z)) (PreH1 : (x = 0)) (PreH2 : (safeExec ATrue (merge_from_mid_rel (l1) (l2) (l3)) X )) ,
193
+ (sll x l1 )
194
+ ** (sll y l2 )
195
+ ** ((t) # Ptr |-> y)
196
+ ** (sllbseg ( &( "ret" ) ) t l3 )
197
+ |--
198
+ EX (ret: Z) (s3: (@list Z)) ,
199
+ “ (safeExec ATrue (return (s3)) X ) ”
200
+ && ((( &( "ret" ) )) # Ptr |-> ret)
201
+ ** (sll ret s3 )
202
+ ) \/
203
+ (
204
+ forall (X: ((@list Z) -> (unit -> Prop))) (t: Z) (y: Z) (x: Z) (l1: (@list Z)) (l2: (@list Z)) (l3: (@list Z)) (PreH1 : (x = 0)) (PreH2 : (safeExec ATrue (merge_from_mid_rel (l1) (l2) (l3)) X )) ,
205
+ (sll x l1 )
206
+ ** (sll y l2 )
207
+ ** ((t) # Ptr |-> y)
208
+ ** (sllbseg ( &( "ret" ) ) t l3 )
209
+ |--
210
+ EX (ret: Z) (s3: (@list Z)) ,
211
+ “ (safeExec ATrue (return (s3)) X ) ”
212
+ && ((( &( "ret" ) )) # Ptr |-> ret)
213
+ ** (sll ret s3 )
214
+ ).
215
+
216
+ Definition merge_entail_wit_4_2 :=
217
+ (
218
+ forall (X: ((@list Z) -> (unit -> Prop))) (t: Z) (y: Z) (x: Z) (l1: (@list Z)) (l2: (@list Z)) (l3: (@list Z)) (PreH1 : (y = 0)) (PreH2 : (x <> 0)) (PreH3 : (safeExec ATrue (merge_from_mid_rel (l1) (l2) (l3)) X )) ,
219
+ (sll x l1 )
220
+ ** (sll y l2 )
221
+ ** ((t) # Ptr |-> x)
222
+ ** (sllbseg ( &( "ret" ) ) t l3 )
223
+ |--
224
+ EX (ret: Z) (s3: (@list Z)) ,
225
+ “ (safeExec ATrue (return (s3)) X ) ”
226
+ && ((( &( "ret" ) )) # Ptr |-> ret)
227
+ ** (sll ret s3 )
228
+ ) \/
229
+ (
230
+ forall (X: ((@list Z) -> (unit -> Prop))) (t: Z) (y: Z) (x: Z) (l1: (@list Z)) (l2: (@list Z)) (l3: (@list Z)) (PreH1 : (y = 0)) (PreH2 : (x <> 0)) (PreH3 : (safeExec ATrue (merge_from_mid_rel (l1) (l2) (l3)) X )) ,
231
+ (sll x l1 )
232
+ ** (sll y l2 )
233
+ ** ((t) # Ptr |-> x)
234
+ ** (sllbseg ( &( "ret" ) ) t l3 )
235
+ |--
236
+ EX (ret: Z) (s3: (@list Z)) ,
237
+ “ (safeExec ATrue (return (s3)) X ) ”
238
+ && ((( &( "ret" ) )) # Ptr |-> ret)
239
+ ** (sll ret s3 )
240
+ ).
241
+
242
+ Definition merge_return_wit_1 :=
243
+ forall (X: ((@list Z) -> (unit -> Prop))) (s3_2: (@list Z)) (ret: Z) (PreH1 : (safeExec ATrue (return (s3_2)) X )) ,
244
+ (sll ret s3_2 )
245
+ |--
246
+ EX (s3: (@list Z)) ,
247
+ “ (safeExec ATrue (return (s3)) X ) ”
248
+ && (sll ret s3 )
249
+ .
250
+
251
+ (*----- Function split_rec -----*)
252
+
253
+ Definition split_rec_safety_wit_1 :=
254
+ forall (q_pre: Z) (p_pre: Z) (x_pre: Z) (qv_low_level_spec: Z) (pv_low_level_spec: Z) (X_low_level_spec: (((@list Z) * (@list Z)) -> (unit -> Prop))) (l2_low_level_spec: (@list Z)) (l1_low_level_spec: (@list Z)) (l_low_level_spec: (@list Z)) (PreH1 : (safeExec ATrue (split_rec_rel (l_low_level_spec) (l1_low_level_spec) (l2_low_level_spec)) X_low_level_spec )) ,
255
+ ((( &( "x" ) )) # Ptr |-> x_pre)
256
+ ** ((( &( "p" ) )) # Ptr |-> p_pre)
257
+ ** ((( &( "q" ) )) # Ptr |-> q_pre)
258
+ ** ((p_pre) # Ptr |-> pv_low_level_spec)
259
+ ** ((q_pre) # Ptr |-> qv_low_level_spec)
260
+ ** (sll x_pre l_low_level_spec )
261
+ ** (sll pv_low_level_spec l1_low_level_spec )
262
+ ** (sll qv_low_level_spec l2_low_level_spec )
263
+ |--
264
+ “ (0 <= INT_MAX) ”
265
+ && “ ((INT_MIN) <= 0) ”
266
+ .
267
+
268
+ Definition split_rec_entail_wit_1 :=
269
+ forall (q_pre: Z) (p_pre: Z) (x_pre: Z) (qv_low_level_spec: Z) (pv_low_level_spec: Z) (X_low_level_spec: (((@list Z) * (@list Z)) -> (unit -> Prop))) (l2_low_level_spec: (@list Z)) (l1_low_level_spec: (@list Z)) (l_low_level_spec: (@list Z)) (PreH1 : (x_pre <> 0)) (PreH2 : (safeExec ATrue (split_rec_rel (l_low_level_spec) (l1_low_level_spec) (l2_low_level_spec)) X_low_level_spec )) ,
270
+ ((p_pre) # Ptr |-> pv_low_level_spec)
271
+ ** ((q_pre) # Ptr |-> qv_low_level_spec)
272
+ ** (sll x_pre l_low_level_spec )
273
+ ** (sll pv_low_level_spec l1_low_level_spec )
274
+ ** (sll qv_low_level_spec l2_low_level_spec )
275
+ |--
276
+ EX (x_next: Z) (x_data: Z) (l_new: (@list Z)) ,
277
+ “ (x_pre <> 0) ”
278
+ && “ (safeExec ATrue (split_rec_rel (l_low_level_spec) (l1_low_level_spec) (l2_low_level_spec)) X_low_level_spec ) ”
279
+ && “ (l_low_level_spec = (cons (x_data) (l_new))) ”
280
+ && ((&((x_pre) # "list" ->ₛ "data")) # Int |-> x_data)
281
+ ** ((&((x_pre) # "list" ->ₛ "next")) # Ptr |-> x_next)
282
+ ** ((p_pre) # Ptr |-> pv_low_level_spec)
283
+ ** ((q_pre) # Ptr |-> qv_low_level_spec)
284
+ ** (sll x_next l_new )
285
+ ** (sll pv_low_level_spec l1_low_level_spec )
286
+ ** (sll qv_low_level_spec l2_low_level_spec )
287
+ .
288
+
289
+ Definition split_rec_entail_wit_2 :=
290
+ (
291
+ forall (q_pre: Z) (p_pre: Z) (x_pre: Z) (qv_low_level_spec: Z) (pv_low_level_spec: Z) (X_low_level_spec: (((@list Z) * (@list Z)) -> (unit -> Prop))) (l2_low_level_spec: (@list Z)) (l1_low_level_spec: (@list Z)) (l_low_level_spec: (@list Z)) (l_new_2: (@list Z)) (x_data_2: Z) (x_next: Z) (PreH1 : (x_pre <> 0)) (PreH2 : (safeExec ATrue (split_rec_rel (l_low_level_spec) (l1_low_level_spec) (l2_low_level_spec)) X_low_level_spec )) (PreH3 : (l_low_level_spec = (cons (x_data_2) (l_new_2)))) ,
292
+ ((&((x_pre) # "list" ->ₛ "data")) # Int |-> x_data_2)
293
+ ** ((&((x_pre) # "list" ->ₛ "next")) # Ptr |-> pv_low_level_spec)
294
+ ** ((p_pre) # Ptr |-> x_pre)
295
+ ** ((q_pre) # Ptr |-> qv_low_level_spec)
296
+ ** (sll x_next l_new_2 )
297
+ ** (sll pv_low_level_spec l1_low_level_spec )
298
+ ** (sll qv_low_level_spec l2_low_level_spec )
299
+ |--
300
+ EX (l_new: (@list Z)) (x_data: Z) ,
301
+ “ (x_pre <> 0) ”
302
+ && “ (safeExec ATrue (bind ((split_rec_rel (l_new) (l2_low_level_spec) ((cons (x_data) (l1_low_level_spec))))) (reversepair)) X_low_level_spec ) ”
303
+ && “ (l_low_level_spec = (cons (x_data) (l_new))) ”
304
+ && ((p_pre) # Ptr |-> x_pre)
305
+ ** ((q_pre) # Ptr |-> qv_low_level_spec)
306
+ ** (sll x_pre (cons (x_data) (l1_low_level_spec)) )
307
+ ** (sll x_next l_new )
308
+ ** (sll qv_low_level_spec l2_low_level_spec )
309
+ ) \/
310
+ (
311
+ forall (x_pre: Z) (X_low_level_spec: (((@list Z) * (@list Z)) -> (unit -> Prop))) (l2_low_level_spec: (@list Z)) (l1_low_level_spec: (@list Z)) (l_low_level_spec: (@list Z)) (l_new_2: (@list Z)) (x_data_2: Z) (PreH1 : (x_pre <> 0)) (PreH2 : (safeExec ATrue (split_rec_rel (l_low_level_spec) (l1_low_level_spec) (l2_low_level_spec)) X_low_level_spec )) (PreH3 : (l_low_level_spec = (cons (x_data_2) (l_new_2)))) ,
312
+ TT && emp
313
+ |--
314
+ “ (safeExec ATrue (bind ((split_rec_rel (l_new_2) (l2_low_level_spec) ((cons (x_data_2) (l1_low_level_spec))))) (reversepair)) X_low_level_spec ) ”
315
+ && emp
316
+ ).
317
+
318
+ Definition split_rec_entail_wit_2_split_goal_1 :=
319
+ forall (x_pre: Z) (X_low_level_spec: (((@list Z) * (@list Z)) -> (unit -> Prop))) (l2_low_level_spec: (@list Z)) (l1_low_level_spec: (@list Z)) (l_low_level_spec: (@list Z)) (l_new_2: (@list Z)) (x_data_2: Z) (PreH1 : (x_pre <> 0)) (PreH2 : (safeExec ATrue (split_rec_rel (l_low_level_spec) (l1_low_level_spec) (l2_low_level_spec)) X_low_level_spec )) (PreH3 : (l_low_level_spec = (cons (x_data_2) (l_new_2)))) ,
320
+ (safeExec ATrue (bind ((split_rec_rel (l_new_2) (l2_low_level_spec) ((cons (x_data_2) (l1_low_level_spec))))) (reversepair)) X_low_level_spec )
321
+ .
322
+
323
+ Definition split_rec_return_wit_1 :=
324
+ (
325
+ forall (q_pre: Z) (p_pre: Z) (x_pre: Z) (qv_low_level_spec: Z) (pv_low_level_spec: Z) (X_low_level_spec: (((@list Z) * (@list Z)) -> (unit -> Prop))) (l2_low_level_spec: (@list Z)) (l1_low_level_spec: (@list Z)) (l_low_level_spec: (@list Z)) (PreH1 : (x_pre = 0)) (PreH2 : (safeExec ATrue (split_rec_rel (l_low_level_spec) (l1_low_level_spec) (l2_low_level_spec)) X_low_level_spec )) ,
326
+ ((p_pre) # Ptr |-> pv_low_level_spec)
327
+ ** ((q_pre) # Ptr |-> qv_low_level_spec)
328
+ ** (sll x_pre l_low_level_spec )
329
+ ** (sll pv_low_level_spec l1_low_level_spec )
330
+ ** (sll qv_low_level_spec l2_low_level_spec )
331
+ |--
332
+ EX (qv': Z) (pv': Z) (s1: (@list Z)) (s2: (@list Z)) ,
333
+ “ (safeExec ATrue (return ((maketuple (s1) (s2)))) X_low_level_spec ) ”
334
+ && ((p_pre) # Ptr |-> pv')
335
+ ** ((q_pre) # Ptr |-> qv')
336
+ ** (sll pv' s1 )
337
+ ** (sll qv' s2 )
338
+ ) \/
339
+ (
340
+ forall (x_pre: Z) (X_low_level_spec: (((@list Z) * (@list Z)) -> (unit -> Prop))) (l2_low_level_spec: (@list Z)) (l1_low_level_spec: (@list Z)) (l_low_level_spec: (@list Z)) (PreH1 : (x_pre = 0)) (PreH2 : (safeExec ATrue (split_rec_rel (l_low_level_spec) (l1_low_level_spec) (l2_low_level_spec)) X_low_level_spec )) ,
341
+ (sll x_pre l_low_level_spec )
342
+ |--
343
+ “ (safeExec ATrue (return ((maketuple (l1_low_level_spec) (l2_low_level_spec)))) X_low_level_spec ) ”
344
+ && emp
345
+ ).
346
+
347
+ Definition split_rec_return_wit_1_split_goal_1 :=
348
+ forall (x_pre: Z) (X_low_level_spec: (((@list Z) * (@list Z)) -> (unit -> Prop))) (l2_low_level_spec: (@list Z)) (l1_low_level_spec: (@list Z)) (l_low_level_spec: (@list Z)) (PreH1 : (x_pre = 0)) (PreH2 : (safeExec ATrue (split_rec_rel (l_low_level_spec) (l1_low_level_spec) (l2_low_level_spec)) X_low_level_spec )) ,
349
+ (sll x_pre l_low_level_spec )
350
+ |--
351
+ “ (safeExec ATrue (return ((maketuple (l1_low_level_spec) (l2_low_level_spec)))) X_low_level_spec ) ”
352
+ .
353
+
354
+ Definition split_rec_return_wit_1_split_goal_spatial :=
355
+ forall (x_pre: Z) (X_low_level_spec: (((@list Z) * (@list Z)) -> (unit -> Prop))) (l2_low_level_spec: (@list Z)) (l1_low_level_spec: (@list Z)) (l_low_level_spec: (@list Z)) (PreH1 : (x_pre = 0)) (PreH2 : (safeExec ATrue (split_rec_rel (l_low_level_spec) (l1_low_level_spec) (l2_low_level_spec)) X_low_level_spec )) ,
356
+ (sll x_pre l_low_level_spec )
357
+ |--
358
+ TT && emp
359
+ .
360
+
361
+ Definition split_rec_return_wit_2 :=
362
+ (
363
+ forall (q_pre: Z) (p_pre: Z) (x_pre: Z) (X_low_level_spec: (((@list Z) * (@list Z)) -> (unit -> Prop))) (l_low_level_spec: (@list Z)) (l_new: (@list Z)) (x_data: Z) (qv'_2: Z) (pv'_2: Z) (s1_2: (@list Z)) (s2_2: (@list Z)) (PreH1 : (safeExec ATrue (applyf (reversepair) ((maketuple (s1_2) (s2_2)))) X_low_level_spec )) (PreH2 : (x_pre <> 0)) (PreH3 : (l_low_level_spec = (cons (x_data) (l_new)))) ,
364
+ ((q_pre) # Ptr |-> pv'_2)
365
+ ** ((p_pre) # Ptr |-> qv'_2)
366
+ ** (sll pv'_2 s1_2 )
367
+ ** (sll qv'_2 s2_2 )
368
+ |--
369
+ EX (qv': Z) (pv': Z) (s1: (@list Z)) (s2: (@list Z)) ,
370
+ “ (safeExec ATrue (return ((maketuple (s1) (s2)))) X_low_level_spec ) ”
371
+ && ((p_pre) # Ptr |-> pv')
372
+ ** ((q_pre) # Ptr |-> qv')
373
+ ** (sll pv' s1 )
374
+ ** (sll qv' s2 )
375
+ ) \/
376
+ (
377
+ forall (x_pre: Z) (X_low_level_spec: (((@list Z) * (@list Z)) -> (unit -> Prop))) (l_low_level_spec: (@list Z)) (l_new: (@list Z)) (x_data: Z) (s1_2: (@list Z)) (s2_2: (@list Z)) (PreH1 : (safeExec ATrue (applyf (reversepair) ((maketuple (s1_2) (s2_2)))) X_low_level_spec )) (PreH2 : (x_pre <> 0)) (PreH3 : (l_low_level_spec = (cons (x_data) (l_new)))) ,
378
+ TT && emp
379
+ |--
380
+ “ (safeExec ATrue (return ((maketuple (s2_2) (s1_2)))) X_low_level_spec ) ”
381
+ && emp
382
+ ).
383
+
384
+ Definition split_rec_return_wit_2_split_goal_1 :=
385
+ forall (x_pre: Z) (X_low_level_spec: (((@list Z) * (@list Z)) -> (unit -> Prop))) (l_low_level_spec: (@list Z)) (l_new: (@list Z)) (x_data: Z) (s1_2: (@list Z)) (s2_2: (@list Z)) (PreH1 : (safeExec ATrue (applyf (reversepair) ((maketuple (s1_2) (s2_2)))) X_low_level_spec )) (PreH2 : (x_pre <> 0)) (PreH3 : (l_low_level_spec = (cons (x_data) (l_new)))) ,
386
+ (safeExec ATrue (return ((maketuple (s2_2) (s1_2)))) X_low_level_spec )
387
+ .
388
+
389
+ Definition split_rec_partial_solve_wit_1_pure :=
390
+ forall (q_pre: Z) (p_pre: Z) (x_pre: Z) (qv_low_level_spec: Z) (X_low_level_spec: (((@list Z) * (@list Z)) -> (unit -> Prop))) (l2_low_level_spec: (@list Z)) (l1_low_level_spec: (@list Z)) (l_low_level_spec: (@list Z)) (l_new: (@list Z)) (x_data: Z) (t: Z) (PreH1 : (x_pre <> 0)) (PreH2 : (safeExec ATrue (bind ((split_rec_rel (l_new) (l2_low_level_spec) ((cons (x_data) (l1_low_level_spec))))) (reversepair)) X_low_level_spec )) (PreH3 : (l_low_level_spec = (cons (x_data) (l_new)))) ,
391
+ ((( &( "x" ) )) # Ptr |-> x_pre)
392
+ ** ((( &( "p" ) )) # Ptr |-> p_pre)
393
+ ** ((( &( "q" ) )) # Ptr |-> q_pre)
394
+ ** ((p_pre) # Ptr |-> x_pre)
395
+ ** ((q_pre) # Ptr |-> qv_low_level_spec)
396
+ ** (sll x_pre (cons (x_data) (l1_low_level_spec)) )
397
+ ** ((( &( "t" ) )) # Ptr |-> t)
398
+ ** (sll t l_new )
399
+ ** (sll qv_low_level_spec l2_low_level_spec )
400
+ |--
401
+ “ (safeExec ATrue (bind ((split_rec_rel (l_new) (l2_low_level_spec) ((cons (x_data) (l1_low_level_spec))))) (reversepair)) X_low_level_spec ) ”
402
+ .
403
+
404
+ Definition split_rec_partial_solve_wit_1_aux :=
405
+ forall (q_pre: Z) (p_pre: Z) (x_pre: Z) (qv_low_level_spec: Z) (X_low_level_spec: (((@list Z) * (@list Z)) -> (unit -> Prop))) (l2_low_level_spec: (@list Z)) (l1_low_level_spec: (@list Z)) (l_low_level_spec: (@list Z)) (l_new: (@list Z)) (x_data: Z) (t: Z) (PreH1 : (x_pre <> 0)) (PreH2 : (safeExec ATrue (bind ((split_rec_rel (l_new) (l2_low_level_spec) ((cons (x_data) (l1_low_level_spec))))) (reversepair)) X_low_level_spec )) (PreH3 : (l_low_level_spec = (cons (x_data) (l_new)))) ,
406
+ ((p_pre) # Ptr |-> x_pre)
407
+ ** ((q_pre) # Ptr |-> qv_low_level_spec)
408
+ ** (sll x_pre (cons (x_data) (l1_low_level_spec)) )
409
+ ** (sll t l_new )
410
+ ** (sll qv_low_level_spec l2_low_level_spec )
411
+ |--
412
+ “ (safeExec ATrue (bind ((split_rec_rel (l_new) (l2_low_level_spec) ((cons (x_data) (l1_low_level_spec))))) (reversepair)) X_low_level_spec ) ”
413
+ && “ (x_pre <> 0) ”
414
+ && “ (safeExec ATrue (bind ((split_rec_rel (l_new) (l2_low_level_spec) ((cons (x_data) (l1_low_level_spec))))) (reversepair)) X_low_level_spec ) ”
415
+ && “ (l_low_level_spec = (cons (x_data) (l_new))) ”
416
+ && ((q_pre) # Ptr |-> qv_low_level_spec)
417
+ ** ((p_pre) # Ptr |-> x_pre)
418
+ ** (sll t l_new )
419
+ ** (sll qv_low_level_spec l2_low_level_spec )
420
+ ** (sll x_pre (cons (x_data) (l1_low_level_spec)) )
421
+ .
422
+
423
+ Definition split_rec_partial_solve_wit_1 := split_rec_partial_solve_wit_1_pure -> split_rec_partial_solve_wit_1_aux.
424
+
425
+ (*----- Function merge_sort -----*)
426
+
427
+ Definition merge_sort_safety_wit_1 :=
428
+ forall (x_pre: Z) (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l_low_level_spec: (@list Z)) (PreH1 : (safeExec ATrue (mergesortrec (l_low_level_spec)) X_low_level_spec )) ,
429
+ ((( &( "q" ) )) # Ptr |->_)
430
+ ** ((( &( "p" ) )) # Ptr |->_)
431
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
432
+ ** (sll x_pre l_low_level_spec )
433
+ |--
434
+ “ (0 <= INT_MAX) ”
435
+ && “ ((INT_MIN) <= 0) ”
436
+ .
437
+
438
+ Definition merge_sort_safety_wit_2 :=
439
+ forall (x_pre: Z) (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l_low_level_spec: (@list Z)) (p: Z) (PreH1 : (p = 0)) (PreH2 : (safeExec ATrue (mergesortrec (l_low_level_spec)) X_low_level_spec )) ,
440
+ ((( &( "x" ) )) # Ptr |-> x_pre)
441
+ ** ((( &( "p" ) )) # Ptr |-> p)
442
+ ** ((( &( "q" ) )) # Ptr |->_)
443
+ ** (sll p (@nil Z) )
444
+ ** (sll x_pre l_low_level_spec )
445
+ |--
446
+ “ (0 <= INT_MAX) ”
447
+ && “ ((INT_MIN) <= 0) ”
448
+ .
449
+
450
+ Definition merge_sort_safety_wit_3 :=
451
+ forall (x_pre: Z) (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (p: Z) (q: Z) (qv': Z) (pv': Z) (s1: (@list Z)) (s2: (@list Z)) (PreH1 : (safeExec ATrue (applyf (mergesortrec_loc0) ((maketuple (s1) (s2)))) X_low_level_spec )) (PreH2 : (q = 0)) (PreH3 : (p = 0)) (PreH4 : (p = 0)) (PreH5 : (q = 0)) ,
452
+ ((( &( "p" ) )) # Ptr |-> pv')
453
+ ** ((( &( "q" ) )) # Ptr |-> qv')
454
+ ** (sll pv' s1 )
455
+ ** (sll qv' s2 )
456
+ ** ((( &( "x" ) )) # Ptr |-> x_pre)
457
+ |--
458
+ “ (0 <= INT_MAX) ”
459
+ && “ ((INT_MIN) <= 0) ”
460
+ .
461
+
462
+ Definition merge_sort_entail_wit_1 :=
463
+ forall (x_pre: Z) (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l_low_level_spec: (@list Z)) (PreH1 : (safeExec ATrue (mergesortrec (l_low_level_spec)) X_low_level_spec )) ,
464
+ (sll x_pre l_low_level_spec )
465
+ |--
466
+ “ (0 = 0) ”
467
+ && “ (safeExec ATrue (mergesortrec (l_low_level_spec)) X_low_level_spec ) ”
468
+ && (sll 0 (@nil Z) )
469
+ ** (sll x_pre l_low_level_spec )
470
+ .
471
+
472
+ Definition merge_sort_entail_wit_2 :=
473
+ forall (x_pre: Z) (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l_low_level_spec: (@list Z)) (p: Z) (PreH1 : (p = 0)) (PreH2 : (safeExec ATrue (mergesortrec (l_low_level_spec)) X_low_level_spec )) ,
474
+ (sll p (@nil Z) )
475
+ ** (sll x_pre l_low_level_spec )
476
+ |--
477
+ “ (p = 0) ”
478
+ && “ (0 = 0) ”
479
+ && “ (safeExec ATrue (mergesortrec (l_low_level_spec)) X_low_level_spec ) ”
480
+ && (sll p (@nil Z) )
481
+ ** (sll 0 (@nil Z) )
482
+ ** (sll x_pre l_low_level_spec )
483
+ .
484
+
485
+ Definition merge_sort_entail_wit_3 :=
486
+ (
487
+ forall (x_pre: Z) (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l_low_level_spec: (@list Z)) (p: Z) (q: Z) (PreH1 : (p = 0)) (PreH2 : (q = 0)) (PreH3 : (safeExec ATrue (mergesortrec (l_low_level_spec)) X_low_level_spec )) ,
488
+ (sll p (@nil Z) )
489
+ ** (sll q (@nil Z) )
490
+ ** (sll x_pre l_low_level_spec )
491
+ |--
492
+ “ (p = 0) ”
493
+ && “ (q = 0) ”
494
+ && “ (safeExec ATrue (bind ((split_rel (l_low_level_spec))) (mergesortrec_loc0)) X_low_level_spec ) ”
495
+ && (sll p (@nil Z) )
496
+ ** (sll q (@nil Z) )
497
+ ** (sll x_pre l_low_level_spec )
498
+ ) \/
499
+ (
500
+ forall (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l_low_level_spec: (@list Z)) (p: Z) (q: Z) (PreH1 : (q = 0)) (PreH2 : (p = 0)) (PreH3 : (p = 0)) (PreH4 : (q = 0)) (PreH5 : (safeExec ATrue (mergesortrec (l_low_level_spec)) X_low_level_spec )) ,
501
+ TT && emp
502
+ |--
503
+ “ (safeExec ATrue (bind ((split_rel (l_low_level_spec))) (mergesortrec_loc0)) X_low_level_spec ) ”
504
+ && emp
505
+ ).
506
+
507
+ Definition merge_sort_entail_wit_3_split_goal_1 :=
508
+ forall (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l_low_level_spec: (@list Z)) (p: Z) (q: Z) (PreH1 : (q = 0)) (PreH2 : (p = 0)) (PreH3 : (p = 0)) (PreH4 : (q = 0)) (PreH5 : (safeExec ATrue (mergesortrec (l_low_level_spec)) X_low_level_spec )) ,
509
+ (safeExec ATrue (bind ((split_rel (l_low_level_spec))) (mergesortrec_loc0)) X_low_level_spec )
510
+ .
511
+
512
+ Definition merge_sort_entail_wit_4 :=
513
+ (
514
+ forall (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (p: Z) (q: Z) (qv': Z) (pv': Z) (s1: (@list Z)) (s2: (@list Z)) (PreH1 : (qv' <> 0)) (PreH2 : (safeExec ATrue (applyf (mergesortrec_loc0) ((maketuple (s1) (s2)))) X_low_level_spec )) (PreH3 : (q = 0)) (PreH4 : (p = 0)) (PreH5 : (p = 0)) (PreH6 : (q = 0)) ,
515
+ (sll pv' s1 )
516
+ ** (sll qv' s2 )
517
+ |--
518
+ EX (l1: (@list Z)) (l2: (@list Z)) ,
519
+ “ (qv' <> 0) ”
520
+ && “ (safeExec ATrue (bind ((mergesortrec (l1))) ((mergesortrec_loc1 (l2)))) X_low_level_spec ) ”
521
+ && (sll pv' l1 )
522
+ ** (sll qv' l2 )
523
+ ) \/
524
+ (
525
+ forall (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (p: Z) (q: Z) (qv': Z) (s1: (@list Z)) (s2: (@list Z)) (PreH1 : (qv' <> 0)) (PreH2 : (safeExec ATrue (applyf (mergesortrec_loc0) ((maketuple (s1) (s2)))) X_low_level_spec )) (PreH3 : (q = 0)) (PreH4 : (p = 0)) (PreH5 : (p = 0)) (PreH6 : (q = 0)) ,
526
+ TT && emp
527
+ |--
528
+ “ (safeExec ATrue (bind ((mergesortrec (s1))) ((mergesortrec_loc1 (s2)))) X_low_level_spec ) ”
529
+ && emp
530
+ ).
531
+
532
+ Definition merge_sort_entail_wit_4_split_goal_1 :=
533
+ forall (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (p: Z) (q: Z) (qv': Z) (s1: (@list Z)) (s2: (@list Z)) (PreH1 : (qv' <> 0)) (PreH2 : (safeExec ATrue (applyf (mergesortrec_loc0) ((maketuple (s1) (s2)))) X_low_level_spec )) (PreH3 : (q = 0)) (PreH4 : (p = 0)) (PreH5 : (p = 0)) (PreH6 : (q = 0)) ,
534
+ (safeExec ATrue (bind ((mergesortrec (s1))) ((mergesortrec_loc1 (s2)))) X_low_level_spec )
535
+ .
536
+
537
+ Definition merge_sort_entail_wit_5 :=
538
+ (
539
+ forall (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l2_2: (@list Z)) (q: Z) (l0: (@list Z)) (retval: Z) (PreH1 : (safeExec ATrue (applyf ((mergesortrec_loc1 (l2_2))) (l0)) X_low_level_spec )) (PreH2 : (q <> 0)) ,
540
+ (sll retval l0 )
541
+ ** (sll q l2_2 )
542
+ |--
543
+ EX (l2: (@list Z)) (l1: (@list Z)) ,
544
+ “ (q <> 0) ”
545
+ && “ (safeExec ATrue (bind ((mergesortrec (l2))) ((mergesortrec_loc2 (l1)))) X_low_level_spec ) ”
546
+ && (sll retval l1 )
547
+ ** (sll q l2 )
548
+ ) \/
549
+ (
550
+ forall (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l2_2: (@list Z)) (q: Z) (l0: (@list Z)) (PreH1 : (safeExec ATrue (applyf ((mergesortrec_loc1 (l2_2))) (l0)) X_low_level_spec )) (PreH2 : (q <> 0)) ,
551
+ TT && emp
552
+ |--
553
+ “ (safeExec ATrue (bind ((mergesortrec (l2_2))) ((mergesortrec_loc2 (l0)))) X_low_level_spec ) ”
554
+ && emp
555
+ ).
556
+
557
+ Definition merge_sort_entail_wit_5_split_goal_1 :=
558
+ forall (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l2_2: (@list Z)) (q: Z) (l0: (@list Z)) (PreH1 : (safeExec ATrue (applyf ((mergesortrec_loc1 (l2_2))) (l0)) X_low_level_spec )) (PreH2 : (q <> 0)) ,
559
+ (safeExec ATrue (bind ((mergesortrec (l2_2))) ((mergesortrec_loc2 (l0)))) X_low_level_spec )
560
+ .
561
+
562
+ Definition merge_sort_entail_wit_6 :=
563
+ (
564
+ forall (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l1_2: (@list Z)) (q: Z) (p: Z) (l0: (@list Z)) (retval: Z) (PreH1 : (safeExec ATrue (applyf ((mergesortrec_loc2 (l1_2))) (l0)) X_low_level_spec )) (PreH2 : (q <> 0)) ,
565
+ (sll retval l0 )
566
+ ** (sll p l1_2 )
567
+ |--
568
+ EX (l1: (@list Z)) (l2: (@list Z)) ,
569
+ “ (safeExec ATrue (merge_rel (l1) (l2)) X_low_level_spec ) ”
570
+ && (sll p l1 )
571
+ ** (sll retval l2 )
572
+ ) \/
573
+ (
574
+ forall (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l1_2: (@list Z)) (q: Z) (l0: (@list Z)) (PreH1 : (safeExec ATrue (applyf ((mergesortrec_loc2 (l1_2))) (l0)) X_low_level_spec )) (PreH2 : (q <> 0)) ,
575
+ TT && emp
576
+ |--
577
+ “ (safeExec ATrue (merge_rel (l1_2) (l0)) X_low_level_spec ) ”
578
+ && emp
579
+ ).
580
+
581
+ Definition merge_sort_entail_wit_6_split_goal_1 :=
582
+ forall (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l1_2: (@list Z)) (q: Z) (l0: (@list Z)) (PreH1 : (safeExec ATrue (applyf ((mergesortrec_loc2 (l1_2))) (l0)) X_low_level_spec )) (PreH2 : (q <> 0)) ,
583
+ (safeExec ATrue (merge_rel (l1_2) (l0)) X_low_level_spec )
584
+ .
585
+
586
+ Definition merge_sort_return_wit_1 :=
587
+ forall (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (s3: (@list Z)) (retval: Z) (PreH1 : (safeExec ATrue (return (s3)) X_low_level_spec )) ,
588
+ (sll retval s3 )
589
+ |--
590
+ EX (l0: (@list Z)) ,
591
+ “ (safeExec ATrue (return (l0)) X_low_level_spec ) ”
592
+ && (sll retval l0 )
593
+ .
594
+
595
+ Definition merge_sort_return_wit_2 :=
596
+ (
597
+ forall (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (p: Z) (q: Z) (qv': Z) (pv': Z) (s1: (@list Z)) (s2: (@list Z)) (PreH1 : (qv' = 0)) (PreH2 : (safeExec ATrue (applyf (mergesortrec_loc0) ((maketuple (s1) (s2)))) X_low_level_spec )) (PreH3 : (q = 0)) (PreH4 : (p = 0)) (PreH5 : (p = 0)) (PreH6 : (q = 0)) ,
598
+ (sll pv' s1 )
599
+ ** (sll qv' s2 )
600
+ |--
601
+ EX (l0: (@list Z)) ,
602
+ “ (safeExec ATrue (return (l0)) X_low_level_spec ) ”
603
+ && (sll pv' l0 )
604
+ ) \/
605
+ (
606
+ forall (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (p: Z) (q: Z) (qv': Z) (s1: (@list Z)) (s2: (@list Z)) (PreH1 : (qv' = 0)) (PreH2 : (safeExec ATrue (applyf (mergesortrec_loc0) ((maketuple (s1) (s2)))) X_low_level_spec )) (PreH3 : (q = 0)) (PreH4 : (p = 0)) (PreH5 : (p = 0)) (PreH6 : (q = 0)) ,
607
+ (sll qv' s2 )
608
+ |--
609
+ “ (safeExec ATrue (return (s1)) X_low_level_spec ) ”
610
+ && emp
611
+ ).
612
+
613
+ Definition merge_sort_return_wit_2_split_goal_1 :=
614
+ forall (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (p: Z) (q: Z) (qv': Z) (s1: (@list Z)) (s2: (@list Z)) (PreH1 : (qv' = 0)) (PreH2 : (safeExec ATrue (applyf (mergesortrec_loc0) ((maketuple (s1) (s2)))) X_low_level_spec )) (PreH3 : (q = 0)) (PreH4 : (p = 0)) (PreH5 : (p = 0)) (PreH6 : (q = 0)) ,
615
+ (sll qv' s2 )
616
+ |--
617
+ “ (safeExec ATrue (return (s1)) X_low_level_spec ) ”
618
+ .
619
+
620
+ Definition merge_sort_return_wit_2_split_goal_spatial :=
621
+ forall (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (p: Z) (q: Z) (qv': Z) (s1: (@list Z)) (s2: (@list Z)) (PreH1 : (qv' = 0)) (PreH2 : (safeExec ATrue (applyf (mergesortrec_loc0) ((maketuple (s1) (s2)))) X_low_level_spec )) (PreH3 : (q = 0)) (PreH4 : (p = 0)) (PreH5 : (p = 0)) (PreH6 : (q = 0)) ,
622
+ (sll qv' s2 )
623
+ |--
624
+ TT && emp
625
+ .
626
+
627
+ Definition merge_sort_partial_solve_wit_1_pure :=
628
+ (
629
+ forall (x_pre: Z) (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l_low_level_spec: (@list Z)) (p: Z) (q: Z) (PreH1 : (p = 0)) (PreH2 : (q = 0)) (PreH3 : (safeExec ATrue (bind ((split_rel (l_low_level_spec))) (mergesortrec_loc0)) X_low_level_spec )) ,
630
+ ((( &( "x" ) )) # Ptr |-> x_pre)
631
+ ** ((( &( "p" ) )) # Ptr |-> p)
632
+ ** ((( &( "q" ) )) # Ptr |-> q)
633
+ ** (sll p (@nil Z) )
634
+ ** (sll q (@nil Z) )
635
+ ** (sll x_pre l_low_level_spec )
636
+ |--
637
+ “ (safeExec ATrue (bind ((split_rec_rel (l_low_level_spec) ((@nil Z)) ((@nil Z)))) (mergesortrec_loc0)) X_low_level_spec ) ”
638
+ ) \/
639
+ (
640
+ forall (x_pre: Z) (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l_low_level_spec: (@list Z)) (p: Z) (q: Z) (PreH1 : (q = 0)) (PreH2 : (p = 0)) (PreH3 : (p = 0)) (PreH4 : (q = 0)) (PreH5 : (safeExec ATrue (bind ((split_rel (l_low_level_spec))) (mergesortrec_loc0)) X_low_level_spec )) ,
641
+ ((( &( "x" ) )) # Ptr |-> x_pre)
642
+ ** ((( &( "p" ) )) # Ptr |-> p)
643
+ ** ((( &( "q" ) )) # Ptr |-> q)
644
+ ** (sll x_pre l_low_level_spec )
645
+ |--
646
+ “ (safeExec ATrue (bind ((split_rec_rel (l_low_level_spec) ((@nil Z)) ((@nil Z)))) (mergesortrec_loc0)) X_low_level_spec ) ”
647
+ ).
648
+
649
+ Definition merge_sort_partial_solve_wit_1_pure_split_goal_1 :=
650
+ forall (x_pre: Z) (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l_low_level_spec: (@list Z)) (p: Z) (q: Z) (PreH1 : (q = 0)) (PreH2 : (p = 0)) (PreH3 : (p = 0)) (PreH4 : (q = 0)) (PreH5 : (safeExec ATrue (bind ((split_rel (l_low_level_spec))) (mergesortrec_loc0)) X_low_level_spec )) ,
651
+ ((( &( "x" ) )) # Ptr |-> x_pre)
652
+ ** ((( &( "p" ) )) # Ptr |-> p)
653
+ ** ((( &( "q" ) )) # Ptr |-> q)
654
+ ** (sll x_pre l_low_level_spec )
655
+ |--
656
+ “ (safeExec ATrue (bind ((split_rec_rel (l_low_level_spec) ((@nil Z)) ((@nil Z)))) (mergesortrec_loc0)) X_low_level_spec ) ”
657
+ .
658
+
659
+ Definition merge_sort_partial_solve_wit_1_aux :=
660
+ forall (x_pre: Z) (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l_low_level_spec: (@list Z)) (p: Z) (q: Z) (PreH1 : (p = 0)) (PreH2 : (q = 0)) (PreH3 : (safeExec ATrue (bind ((split_rel (l_low_level_spec))) (mergesortrec_loc0)) X_low_level_spec )) ,
661
+ (sll p (@nil Z) )
662
+ ** (sll q (@nil Z) )
663
+ ** (sll x_pre l_low_level_spec )
664
+ |--
665
+ “ (safeExec ATrue (bind ((split_rec_rel (l_low_level_spec) ((@nil Z)) ((@nil Z)))) (mergesortrec_loc0)) X_low_level_spec ) ”
666
+ && “ (q = 0) ”
667
+ && “ (p = 0) ”
668
+ && “ (p = 0) ”
669
+ && “ (q = 0) ”
670
+ && “ (safeExec ATrue (bind ((split_rel (l_low_level_spec))) (mergesortrec_loc0)) X_low_level_spec ) ”
671
+ && (sll x_pre l_low_level_spec )
672
+ ** (sll p (@nil Z) )
673
+ ** (sll q (@nil Z) )
674
+ .
675
+
676
+ Definition merge_sort_partial_solve_wit_1 := merge_sort_partial_solve_wit_1_pure -> merge_sort_partial_solve_wit_1_aux.
677
+
678
+ Definition merge_sort_partial_solve_wit_2_pure :=
679
+ forall (x_pre: Z) (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l1: (@list Z)) (l2: (@list Z)) (q: Z) (p: Z) (PreH1 : (q <> 0)) (PreH2 : (safeExec ATrue (bind ((mergesortrec (l1))) ((mergesortrec_loc1 (l2)))) X_low_level_spec )) ,
680
+ ((( &( "x" ) )) # Ptr |-> x_pre)
681
+ ** ((( &( "q" ) )) # Ptr |-> q)
682
+ ** ((( &( "p" ) )) # Ptr |-> p)
683
+ ** (sll p l1 )
684
+ ** (sll q l2 )
685
+ |--
686
+ “ (safeExec ATrue (bind ((mergesortrec (l1))) ((mergesortrec_loc1 (l2)))) X_low_level_spec ) ”
687
+ .
688
+
689
+ Definition merge_sort_partial_solve_wit_2_aux :=
690
+ forall (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l1: (@list Z)) (l2: (@list Z)) (q: Z) (p: Z) (PreH1 : (q <> 0)) (PreH2 : (safeExec ATrue (bind ((mergesortrec (l1))) ((mergesortrec_loc1 (l2)))) X_low_level_spec )) ,
691
+ (sll p l1 )
692
+ ** (sll q l2 )
693
+ |--
694
+ “ (safeExec ATrue (bind ((mergesortrec (l1))) ((mergesortrec_loc1 (l2)))) X_low_level_spec ) ”
695
+ && “ (q <> 0) ”
696
+ && “ (safeExec ATrue (bind ((mergesortrec (l1))) ((mergesortrec_loc1 (l2)))) X_low_level_spec ) ”
697
+ && (sll p l1 )
698
+ ** (sll q l2 )
699
+ .
700
+
701
+ Definition merge_sort_partial_solve_wit_2 := merge_sort_partial_solve_wit_2_pure -> merge_sort_partial_solve_wit_2_aux.
702
+
703
+ Definition merge_sort_partial_solve_wit_3_pure :=
704
+ forall (x_pre: Z) (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l1: (@list Z)) (l2: (@list Z)) (q: Z) (p: Z) (PreH1 : (q <> 0)) (PreH2 : (safeExec ATrue (bind ((mergesortrec (l2))) ((mergesortrec_loc2 (l1)))) X_low_level_spec )) ,
705
+ ((( &( "x" ) )) # Ptr |-> x_pre)
706
+ ** ((( &( "q" ) )) # Ptr |-> q)
707
+ ** ((( &( "p" ) )) # Ptr |-> p)
708
+ ** (sll p l1 )
709
+ ** (sll q l2 )
710
+ |--
711
+ “ (safeExec ATrue (bind ((mergesortrec (l2))) ((mergesortrec_loc2 (l1)))) X_low_level_spec ) ”
712
+ .
713
+
714
+ Definition merge_sort_partial_solve_wit_3_aux :=
715
+ forall (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l1: (@list Z)) (l2: (@list Z)) (q: Z) (p: Z) (PreH1 : (q <> 0)) (PreH2 : (safeExec ATrue (bind ((mergesortrec (l2))) ((mergesortrec_loc2 (l1)))) X_low_level_spec )) ,
716
+ (sll p l1 )
717
+ ** (sll q l2 )
718
+ |--
719
+ “ (safeExec ATrue (bind ((mergesortrec (l2))) ((mergesortrec_loc2 (l1)))) X_low_level_spec ) ”
720
+ && “ (q <> 0) ”
721
+ && “ (safeExec ATrue (bind ((mergesortrec (l2))) ((mergesortrec_loc2 (l1)))) X_low_level_spec ) ”
722
+ && (sll q l2 )
723
+ ** (sll p l1 )
724
+ .
725
+
726
+ Definition merge_sort_partial_solve_wit_3 := merge_sort_partial_solve_wit_3_pure -> merge_sort_partial_solve_wit_3_aux.
727
+
728
+ Definition merge_sort_partial_solve_wit_4_pure :=
729
+ forall (x_pre: Z) (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l1: (@list Z)) (l2: (@list Z)) (p: Z) (q: Z) (PreH1 : (safeExec ATrue (merge_rel (l1) (l2)) X_low_level_spec )) ,
730
+ ((( &( "x" ) )) # Ptr |-> x_pre)
731
+ ** ((( &( "p" ) )) # Ptr |-> p)
732
+ ** (sll p l1 )
733
+ ** ((( &( "q" ) )) # Ptr |-> q)
734
+ ** (sll q l2 )
735
+ |--
736
+ “ (safeExec ATrue (merge_rel (l1) (l2)) X_low_level_spec ) ”
737
+ .
738
+
739
+ Definition merge_sort_partial_solve_wit_4_aux :=
740
+ forall (X_low_level_spec: ((@list Z) -> (unit -> Prop))) (l1: (@list Z)) (l2: (@list Z)) (p: Z) (q: Z) (PreH1 : (safeExec ATrue (merge_rel (l1) (l2)) X_low_level_spec )) ,
741
+ (sll p l1 )
742
+ ** (sll q l2 )
743
+ |--
744
+ “ (safeExec ATrue (merge_rel (l1) (l2)) X_low_level_spec ) ”
745
+ && “ (safeExec ATrue (merge_rel (l1) (l2)) X_low_level_spec ) ”
746
+ && (sll p l1 )
747
+ ** (sll q l2 )
748
+ .
749
+
750
+ Definition merge_sort_partial_solve_wit_4 := merge_sort_partial_solve_wit_4_pure -> merge_sort_partial_solve_wit_4_aux.
751
+
752
+ Definition merge_sort_derive_low_level_spec_aux_by_low_level_spec :=
753
+ forall (B: Type) ,
754
+ forall (x_pre: Z) (X_low_level_spec_aux: (B -> (unit -> Prop))) (c_low_level_spec_aux: ((@list Z) -> (@ StateRelMonad.M unit B))) (l_low_level_spec_aux: (@list Z)) ,
755
+ “ (safeExec ATrue (bind ((mergesortrec (l_low_level_spec_aux))) (c_low_level_spec_aux)) X_low_level_spec_aux ) ”
756
+ && (sll x_pre l_low_level_spec_aux )
757
+ |--
758
+ EX (l_low_level_spec: (@list Z)) (X_low_level_spec: ((@list Z) -> (unit -> Prop))) ,
759
+ (“ (safeExec ATrue (mergesortrec (l_low_level_spec)) X_low_level_spec ) ”
760
+ && (sll x_pre l_low_level_spec ))
761
+ **
762
+ ((EX l0_2 retval_2,
763
+ “ (safeExec ATrue (return (l0_2)) X_low_level_spec ) ”
764
+ && (sll retval_2 l0_2 ))
765
+ -*
766
+ (EX l0 retval,
767
+ “ (safeExec ATrue (applyf (c_low_level_spec_aux) (l0)) X_low_level_spec_aux ) ”
768
+ && (sll retval l0 )))
769
+ .
770
+
771
+ Definition merge_sort_derive_high_level_spec_by_low_level_spec :=
772
+ forall (x_pre: Z) (l_high_level_spec: (@list Z)) ,
773
+ (sll x_pre l_high_level_spec )
774
+ |--
775
+ EX (l_low_level_spec: (@list Z)) (X_low_level_spec: ((@list Z) -> (unit -> Prop))) ,
776
+ (“ (safeExec ATrue (mergesortrec (l_low_level_spec)) X_low_level_spec ) ”
777
+ && (sll x_pre l_low_level_spec ))
778
+ **
779
+ ((EX l0_2 retval_2,
780
+ “ (safeExec ATrue (return (l0_2)) X_low_level_spec ) ”
781
+ && (sll retval_2 l0_2 ))
782
+ -*
783
+ (EX l0 retval,
784
+ “ (Permutation l_high_level_spec l0 ) ”
785
+ && “ (incr l0 ) ”
786
+ && (sll retval l0 )))
787
+ .
788
+
789
+ Definition split_rec_derive_low_level_spec_aux_by_low_level_spec :=
790
+ forall (B: Type) ,
791
+ forall (q_pre: Z) (p_pre: Z) (x_pre: Z) (qv_low_level_spec_aux: Z) (pv_low_level_spec_aux: Z) (X_low_level_spec_aux: (B -> (unit -> Prop))) (c_low_level_spec_aux: (((@list Z) * (@list Z)) -> (@ StateRelMonad.M unit B))) (l2_low_level_spec_aux: (@list Z)) (l1_low_level_spec_aux: (@list Z)) (l_low_level_spec_aux: (@list Z)) ,
792
+ “ (safeExec ATrue (bind ((split_rec_rel (l_low_level_spec_aux) (l1_low_level_spec_aux) (l2_low_level_spec_aux))) (c_low_level_spec_aux)) X_low_level_spec_aux ) ”
793
+ && ((p_pre) # Ptr |-> pv_low_level_spec_aux)
794
+ ** ((q_pre) # Ptr |-> qv_low_level_spec_aux)
795
+ ** (sll x_pre l_low_level_spec_aux )
796
+ ** (sll pv_low_level_spec_aux l1_low_level_spec_aux )
797
+ ** (sll qv_low_level_spec_aux l2_low_level_spec_aux )
798
+ |--
799
+ EX (l_low_level_spec: (@list Z)) (l1_low_level_spec: (@list Z)) (l2_low_level_spec: (@list Z)) (X_low_level_spec: (((@list Z) * (@list Z)) -> (unit -> Prop))) (pv_low_level_spec: Z) (qv_low_level_spec: Z) ,
800
+ (“ (safeExec ATrue (split_rec_rel (l_low_level_spec) (l1_low_level_spec) (l2_low_level_spec)) X_low_level_spec ) ”
801
+ && ((p_pre) # Ptr |-> pv_low_level_spec)
802
+ ** ((q_pre) # Ptr |-> qv_low_level_spec)
803
+ ** (sll x_pre l_low_level_spec )
804
+ ** (sll pv_low_level_spec l1_low_level_spec )
805
+ ** (sll qv_low_level_spec l2_low_level_spec ))
806
+ **
807
+ ((EX qv'_2 pv'_2 s1_2 s2_2,
808
+ “ (safeExec ATrue (return ((maketuple (s1_2) (s2_2)))) X_low_level_spec ) ”
809
+ && ((p_pre) # Ptr |-> pv'_2)
810
+ ** ((q_pre) # Ptr |-> qv'_2)
811
+ ** (sll pv'_2 s1_2 )
812
+ ** (sll qv'_2 s2_2 ))
813
+ -*
814
+ (EX qv' pv' s1 s2,
815
+ “ (safeExec ATrue (applyf (c_low_level_spec_aux) ((maketuple (s1) (s2)))) X_low_level_spec_aux ) ”
816
+ && ((p_pre) # Ptr |-> pv')
817
+ ** ((q_pre) # Ptr |-> qv')
818
+ ** (sll pv' s1 )
819
+ ** (sll qv' s2 )))
820
+ .
821
+
822
+ Definition split_rec_derive_high_level_spec_by_low_level_spec :=
823
+ forall (q_pre: Z) (p_pre: Z) (x_pre: Z) (qv_high_level_spec: Z) (pv_high_level_spec: Z) (X_high_level_spec: (((@list Z) * (@list Z)) -> (unit -> Prop))) (l_high_level_spec: (@list Z)) ,
824
+ “ (safeExec ATrue (split_rel (l_high_level_spec)) X_high_level_spec ) ”
825
+ && ((p_pre) # Ptr |-> pv_high_level_spec)
826
+ ** ((q_pre) # Ptr |-> qv_high_level_spec)
827
+ ** (sll x_pre l_high_level_spec )
828
+ ** (sll pv_high_level_spec nil )
829
+ ** (sll qv_high_level_spec nil )
830
+ |--
831
+ EX (l_low_level_spec: (@list Z)) (l1_low_level_spec: (@list Z)) (l2_low_level_spec: (@list Z)) (X_low_level_spec: (((@list Z) * (@list Z)) -> (unit -> Prop))) (pv_low_level_spec: Z) (qv_low_level_spec: Z) ,
832
+ (“ (safeExec ATrue (split_rec_rel (l_low_level_spec) (l1_low_level_spec) (l2_low_level_spec)) X_low_level_spec ) ”
833
+ && ((p_pre) # Ptr |-> pv_low_level_spec)
834
+ ** ((q_pre) # Ptr |-> qv_low_level_spec)
835
+ ** (sll x_pre l_low_level_spec )
836
+ ** (sll pv_low_level_spec l1_low_level_spec )
837
+ ** (sll qv_low_level_spec l2_low_level_spec ))
838
+ **
839
+ ((EX qv'_2 pv'_2 s1_2 s2_2,
840
+ “ (safeExec ATrue (return ((maketuple (s1_2) (s2_2)))) X_low_level_spec ) ”
841
+ && ((p_pre) # Ptr |-> pv'_2)
842
+ ** ((q_pre) # Ptr |-> qv'_2)
843
+ ** (sll pv'_2 s1_2 )
844
+ ** (sll qv'_2 s2_2 ))
845
+ -*
846
+ (EX qv' pv' s1 s2,
847
+ “ (safeExec ATrue (return ((maketuple (s1) (s2)))) X_high_level_spec ) ”
848
+ && ((p_pre) # Ptr |-> pv')
849
+ ** ((q_pre) # Ptr |-> qv')
850
+ ** (sll pv' s1 )
851
+ ** (sll qv' s2 )))
852
+ .
853
+
854
+ Module Type VC_Correct.
855
+
856
+ Include sll_Strategy_Correct.
857
+ Include safeexec_Strategy_Correct.
858
+
859
+ Axiom proof_of_merge_safety_wit_1 : merge_safety_wit_1.
860
+ Axiom proof_of_merge_safety_wit_2 : merge_safety_wit_2.
861
+ Axiom proof_of_merge_safety_wit_3 : merge_safety_wit_3.
862
+ Axiom proof_of_merge_entail_wit_1 : merge_entail_wit_1.
863
+ Axiom proof_of_merge_entail_wit_2 : merge_entail_wit_2.
864
+ Axiom proof_of_merge_entail_wit_3_1 : merge_entail_wit_3_1.
865
+ Axiom proof_of_merge_entail_wit_3_2 : merge_entail_wit_3_2.
866
+ Axiom proof_of_merge_entail_wit_4_1 : merge_entail_wit_4_1.
867
+ Axiom proof_of_merge_entail_wit_4_2 : merge_entail_wit_4_2.
868
+ Axiom proof_of_merge_return_wit_1 : merge_return_wit_1.
869
+ Axiom proof_of_split_rec_safety_wit_1 : split_rec_safety_wit_1.
870
+ Axiom proof_of_split_rec_entail_wit_1 : split_rec_entail_wit_1.
871
+ Axiom proof_of_split_rec_entail_wit_2 : split_rec_entail_wit_2.
872
+ Axiom proof_of_split_rec_return_wit_1 : split_rec_return_wit_1.
873
+ Axiom proof_of_split_rec_return_wit_2 : split_rec_return_wit_2.
874
+ Axiom proof_of_split_rec_partial_solve_wit_1_pure : split_rec_partial_solve_wit_1_pure.
875
+ Axiom proof_of_split_rec_partial_solve_wit_1 : split_rec_partial_solve_wit_1.
876
+ Axiom proof_of_merge_sort_safety_wit_1 : merge_sort_safety_wit_1.
877
+ Axiom proof_of_merge_sort_safety_wit_2 : merge_sort_safety_wit_2.
878
+ Axiom proof_of_merge_sort_safety_wit_3 : merge_sort_safety_wit_3.
879
+ Axiom proof_of_merge_sort_entail_wit_1 : merge_sort_entail_wit_1.
880
+ Axiom proof_of_merge_sort_entail_wit_2 : merge_sort_entail_wit_2.
881
+ Axiom proof_of_merge_sort_entail_wit_3 : merge_sort_entail_wit_3.
882
+ Axiom proof_of_merge_sort_entail_wit_4 : merge_sort_entail_wit_4.
883
+ Axiom proof_of_merge_sort_entail_wit_5 : merge_sort_entail_wit_5.
884
+ Axiom proof_of_merge_sort_entail_wit_6 : merge_sort_entail_wit_6.
885
+ Axiom proof_of_merge_sort_return_wit_1 : merge_sort_return_wit_1.
886
+ Axiom proof_of_merge_sort_return_wit_2 : merge_sort_return_wit_2.
887
+ Axiom proof_of_merge_sort_partial_solve_wit_1_pure : merge_sort_partial_solve_wit_1_pure.
888
+ Axiom proof_of_merge_sort_partial_solve_wit_1 : merge_sort_partial_solve_wit_1.
889
+ Axiom proof_of_merge_sort_partial_solve_wit_2_pure : merge_sort_partial_solve_wit_2_pure.
890
+ Axiom proof_of_merge_sort_partial_solve_wit_2 : merge_sort_partial_solve_wit_2.
891
+ Axiom proof_of_merge_sort_partial_solve_wit_3_pure : merge_sort_partial_solve_wit_3_pure.
892
+ Axiom proof_of_merge_sort_partial_solve_wit_3 : merge_sort_partial_solve_wit_3.
893
+ Axiom proof_of_merge_sort_partial_solve_wit_4_pure : merge_sort_partial_solve_wit_4_pure.
894
+ Axiom proof_of_merge_sort_partial_solve_wit_4 : merge_sort_partial_solve_wit_4.
895
+ Axiom proof_of_merge_sort_derive_low_level_spec_aux_by_low_level_spec : merge_sort_derive_low_level_spec_aux_by_low_level_spec.
896
+ Axiom proof_of_merge_sort_derive_high_level_spec_by_low_level_spec : merge_sort_derive_high_level_spec_by_low_level_spec.
897
+ Axiom proof_of_split_rec_derive_low_level_spec_aux_by_low_level_spec : split_rec_derive_low_level_spec_aux_by_low_level_spec.
898
+ Axiom proof_of_split_rec_derive_high_level_spec_by_low_level_spec : split_rec_derive_high_level_spec_by_low_level_spec.
899
+
900
+ End VC_Correct.
benchmarks/Algorithms/sll_merge_sort/rocq/groundtruth/sll_merge_sort_goal_check.v ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ From PVbench.Algorithms.sll_merge_sort.rocq.groundtruth Require Import sll_merge_sort_goal sll_merge_sort_proof_auto sll_merge_sort_proof_manual.
2
+
3
+ Module VC_Correctness : VC_Correct.
4
+ Include sll_strategy_proof.
5
+ Include safeexec_strategy_proof.
6
+ Include sll_merge_sort_proof_auto.
7
+ Include sll_merge_sort_proof_manual.
8
+ End VC_Correctness.
benchmarks/Algorithms/sll_merge_sort/rocq/groundtruth/sll_merge_sort_proof_auto.v ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Require Import Coq.ZArith.ZArith.
2
+ Require Import Coq.Bool.Bool.
3
+ Require Import Coq.Strings.String.
4
+ Require Import Coq.Strings.Ascii.
5
+ Require Import Coq.Lists.List.
6
+ Require Import Coq.Classes.RelationClasses.
7
+ Require Import Coq.Classes.Morphisms.
8
+ Require Import Coq.micromega.Psatz.
9
+ Require Import Coq.Sorting.Permutation.
10
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap.
11
+ Require Import SetsClass.SetsClass. Import SetsNotation.
12
+ From SimpleC.SL Require Import Mem SeparationLogic.
13
+ From PVbench.Algorithms.sll_merge_sort.rocq.groundtruth Require Import sll_merge_sort_goal.
14
+ Require Import Logic.LogicGenerator.demo932.Interface.
15
+ Local Open Scope Z_scope.
16
+ Local Open Scope sets.
17
+ Local Open Scope string_scope.
18
+ Local Open Scope list.
19
+ Import naive_C_Rules.
20
+ Require Import SimpleC.EE.QCP_demos_LLM.sll_lib.
21
+ From MonadLib Require Export MonadLib.
22
+ From MonadLib.StateRelMonad Require Export StateRelMonad.
23
+ Export MonadNotation.
24
+ Local Open Scope monad.
25
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap relations.
26
+ From FP Require Import PartialOrder_Setoid BourbakiWitt.
27
+ Require Import PVbench.Algorithms.sll_merge_sort.rocq.spec_lib.
28
+ Require Import PVbench.Algorithms.sll_merge_sort.rocq.helper_lib.
29
+ Local Open Scope sac.
30
+
31
+ Lemma proof_of_merge_safety_wit_1 : merge_safety_wit_1.
32
+ Proof. Admitted.
33
+
34
+ Lemma proof_of_merge_safety_wit_2 : merge_safety_wit_2.
35
+ Proof. Admitted.
36
+
37
+ Lemma proof_of_merge_safety_wit_3 : merge_safety_wit_3.
38
+ Proof. Admitted.
39
+
40
+ Lemma proof_of_merge_entail_wit_2 : merge_entail_wit_2.
41
+ Proof. Admitted.
42
+
43
+ Lemma proof_of_merge_return_wit_1 : merge_return_wit_1.
44
+ Proof. Admitted.
45
+
46
+ Lemma proof_of_split_rec_safety_wit_1 : split_rec_safety_wit_1.
47
+ Proof. Admitted.
48
+
49
+ Lemma proof_of_split_rec_entail_wit_1 : split_rec_entail_wit_1.
50
+ Proof. Admitted.
51
+
52
+ Lemma proof_of_split_rec_partial_solve_wit_1_pure : split_rec_partial_solve_wit_1_pure.
53
+ Proof. Admitted.
54
+
55
+ Lemma proof_of_split_rec_partial_solve_wit_1 : split_rec_partial_solve_wit_1.
56
+ Proof. Admitted.
57
+
58
+ Lemma proof_of_merge_sort_safety_wit_1 : merge_sort_safety_wit_1.
59
+ Proof. Admitted.
60
+
61
+ Lemma proof_of_merge_sort_safety_wit_2 : merge_sort_safety_wit_2.
62
+ Proof. Admitted.
63
+
64
+ Lemma proof_of_merge_sort_safety_wit_3 : merge_sort_safety_wit_3.
65
+ Proof. Admitted.
66
+
67
+ Lemma proof_of_merge_sort_entail_wit_1 : merge_sort_entail_wit_1.
68
+ Proof. Admitted.
69
+
70
+ Lemma proof_of_merge_sort_entail_wit_2 : merge_sort_entail_wit_2.
71
+ Proof. Admitted.
72
+
73
+ Lemma proof_of_merge_sort_return_wit_1 : merge_sort_return_wit_1.
74
+ Proof. Admitted.
75
+
76
+ Lemma proof_of_merge_sort_partial_solve_wit_1 : merge_sort_partial_solve_wit_1.
77
+ Proof. Admitted.
78
+
79
+ Lemma proof_of_merge_sort_partial_solve_wit_2_pure : merge_sort_partial_solve_wit_2_pure.
80
+ Proof. Admitted.
81
+
82
+ Lemma proof_of_merge_sort_partial_solve_wit_2 : merge_sort_partial_solve_wit_2.
83
+ Proof. Admitted.
84
+
85
+ Lemma proof_of_merge_sort_partial_solve_wit_3_pure : merge_sort_partial_solve_wit_3_pure.
86
+ Proof. Admitted.
87
+
88
+ Lemma proof_of_merge_sort_partial_solve_wit_3 : merge_sort_partial_solve_wit_3.
89
+ Proof. Admitted.
90
+
91
+ Lemma proof_of_merge_sort_partial_solve_wit_4_pure : merge_sort_partial_solve_wit_4_pure.
92
+ Proof. Admitted.
93
+
94
+ Lemma proof_of_merge_sort_partial_solve_wit_4 : merge_sort_partial_solve_wit_4.
95
+ Proof. Admitted.
96
+
benchmarks/Algorithms/sll_merge_sort/rocq/groundtruth/sll_merge_sort_proof_manual.v ADDED
@@ -0,0 +1,421 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Require Import Coq.ZArith.ZArith.
2
+ Require Import Coq.Bool.Bool.
3
+ Require Import Coq.Strings.String.
4
+ Require Import Coq.Strings.Ascii.
5
+ Require Import Coq.Lists.List.
6
+ Require Import Coq.Classes.RelationClasses.
7
+ Require Import Coq.Classes.Morphisms.
8
+ Require Import Coq.micromega.Psatz.
9
+ Require Import Coq.Sorting.Permutation.
10
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap.
11
+ Require Import SetsClass.SetsClass. Import SetsNotation.
12
+ From SimpleC.SL Require Import Mem SeparationLogic.
13
+ From PVbench.Algorithms.sll_merge_sort.rocq.groundtruth Require Import sll_merge_sort_goal.
14
+ From PVbench.Algorithms.sll_merge_sort.rocq.groundtruth Require Import sll_merge_sort_proof_auto.
15
+ Require Import Logic.LogicGenerator.demo932.Interface.
16
+ Local Open Scope Z_scope.
17
+ Local Open Scope sets.
18
+ Local Open Scope string_scope.
19
+ Local Open Scope list.
20
+ Import naive_C_Rules.
21
+ Require Import SimpleC.EE.QCP_demos_LLM.sll_lib.
22
+ From MonadLib Require Export MonadLib.
23
+ From MonadLib.StateRelMonad Require Export StateRelMonad.
24
+ Export MonadNotation.
25
+ Local Open Scope monad.
26
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap relations.
27
+ From FP Require Import PartialOrder_Setoid BourbakiWitt.
28
+ Require Import PVbench.Algorithms.sll_merge_sort.rocq.helper_lib.
29
+ From SimpleC.EE.QCP_demos_LLM Require Import sll_lib.
30
+ Require Import PVbench.Algorithms.sll_merge_sort.rocq.groundtruth.proof_lib.
31
+ Local Open Scope sac.
32
+
33
+
34
+ Lemma proof_of_merge_entail_wit_1 : merge_entail_wit_1.
35
+ Proof.
36
+ left.
37
+ LLM_pre_process ltac:(int_auto).
38
+ Exists s1. Exists s2. Exists (@nil Z).
39
+ repeat (split_pure_spatial || split_pures).
40
+ + cancel (sll x_pre s1).
41
+ cancel (sll y_pre s2).
42
+ cancel (((&( "ret" ))) # Ptr |->_).
43
+ simpl.
44
+ split_pure_spatial.
45
+ - cancel.
46
+ - dump_pre_spatial. reflexivity.
47
+ + dump_pre_spatial.
48
+ unfold merge_rel, merge_from_mid_rel.
49
+ exact PreH1.
50
+ Qed.
51
+
52
+ Lemma proof_of_merge_entail_wit_3_1 : merge_entail_wit_3_1.
53
+ Proof.
54
+ LLM_pre_process ltac:(int_auto).
55
+ Exists l1_new. Exists (ydata :: l2_new). Exists (l3_2 ++ (xdata :: nil))%list.
56
+ simpl sll. Exists ynext.
57
+ repeat (split_pure_spatial || split_pures).
58
+ + cancel (&((y) # "list" ->ₛ"data") # Int |-> ydata).
59
+ cancel (&((y) # "list" ->ₛ"next") # Ptr |-> ynext).
60
+ cancel (sll ynext l2_new).
61
+ cancel (sll xnext l1_new).
62
+ sep_apply_l_atomic (sllbseg_len1 t x xdata).
63
+ * dump_pre_spatial. exact PreH3.
64
+ * sep_apply_l_atomic (store_ptr_undef_store_ptr (&((x) # "list" ->ₛ"next")) xnext).
65
+ cancel (&((x) # "list" ->ₛ"next") # Ptr |->_).
66
+ sep_apply_l_atomic (sllbseg_sllbseg (&( "ret")) t (&((x) # "list" ->ₛ"next")) l3_2 (xdata :: nil)).
67
+ cancel (sllbseg (&( "ret")) (&((x) # "list" ->ₛ"next")) (l3_2 ++ (xdata :: nil))%list).
68
+ + dump_pre_spatial.
69
+ rewrite PreH5 in PreH2.
70
+ rewrite PreH6 in PreH2.
71
+ unfold merge_from_mid_rel in PreH2 at 1.
72
+ prog_nf in PreH2.
73
+ unfold_loop in PreH2.
74
+ prog_nf in PreH2.
75
+ unfold merge_body in PreH2 at 1.
76
+ prog_nf in PreH2.
77
+ safe_choice_l PreH2; try lia.
78
+ exact PreH2.
79
+ + dump_pre_spatial. exact PreH4.
80
+ Qed.
81
+
82
+ Lemma proof_of_merge_entail_wit_3_2 : merge_entail_wit_3_2.
83
+ Proof.
84
+ LLM_pre_process ltac:(int_auto).
85
+ Exists (xdata :: l1_new). Exists l2_new. Exists (l3_2 ++ (ydata :: nil))%list.
86
+ simpl sll. Exists xnext.
87
+ repeat (split_pure_spatial || split_pures).
88
+ + cancel (&((x) # "list" ->ₛ"data") # Int |-> xdata).
89
+ cancel (&((x) # "list" ->ₛ"next") # Ptr |-> xnext).
90
+ cancel (sll xnext l1_new).
91
+ cancel (sll ynext l2_new).
92
+ sep_apply_l_atomic (sllbseg_len1 t y ydata).
93
+ * dump_pre_spatial. exact PreH4.
94
+ * sep_apply_l_atomic (store_ptr_undef_store_ptr (&((y) # "list" ->ₛ"next")) ynext).
95
+ cancel (&((y) # "list" ->ₛ"next") # Ptr |->_).
96
+ sep_apply_l_atomic (sllbseg_sllbseg (&( "ret")) t (&((y) # "list" ->ₛ"next")) l3_2 (ydata :: nil)).
97
+ cancel (sllbseg (&( "ret")) (&((y) # "list" ->ₛ"next")) (l3_2 ++ (ydata :: nil))%list).
98
+ + dump_pre_spatial.
99
+ rewrite PreH5 in PreH2.
100
+ rewrite PreH6 in PreH2.
101
+ unfold merge_from_mid_rel in PreH2 at 1.
102
+ prog_nf in PreH2.
103
+ unfold_loop in PreH2.
104
+ prog_nf in PreH2.
105
+ unfold merge_body in PreH2 at 1.
106
+ prog_nf in PreH2.
107
+ safe_choice_r PreH2; try lia.
108
+ exact PreH2.
109
+ + dump_pre_spatial. exact PreH3.
110
+ Qed.
111
+
112
+ Lemma proof_of_merge_entail_wit_4_1 : merge_entail_wit_4_1.
113
+ Proof.
114
+ LLM_pre_process ltac:(int_auto).
115
+ subst x.
116
+ sep_apply_l_atomic (sll_zero 0 l1).
117
+ * dump_pre_spatial. reflexivity.
118
+ * Intros_p Hl1nil.
119
+ subst l1.
120
+ sep_apply_l_atomic (sllbseg_2_sllseg (&( "ret")) t y l3).
121
+ Intros ret.
122
+ Exists ret. Exists (l3 ++ l2).
123
+ repeat (split_pure_spatial || split_pures).
124
+ + cancel (&( "ret") # Ptr |-> ret).
125
+ sep_apply_l_atomic (sllseg_sll ret y l3 l2).
126
+ cancel (sll ret (l3 ++ l2)).
127
+ + dump_pre_spatial.
128
+ unfold merge_from_mid_rel in PreH2 at 1.
129
+ prog_nf in PreH2.
130
+ unfold_loop in PreH2.
131
+ prog_nf in PreH2.
132
+ unfold merge_body in PreH2 at 1.
133
+ prog_nf in PreH2.
134
+ exact PreH2.
135
+ Qed.
136
+
137
+ Lemma proof_of_merge_entail_wit_4_2 : merge_entail_wit_4_2.
138
+ Proof.
139
+ LLM_pre_process ltac:(int_auto).
140
+ subst y.
141
+ sep_apply_l_atomic (sll_zero 0 l2).
142
+ * dump_pre_spatial. reflexivity.
143
+ * Intros_p Hl2nil.
144
+ subst l2.
145
+ sep_apply_l_atomic (sllbseg_2_sllseg (&( "ret")) t x l3).
146
+ Intros ret.
147
+ Exists ret. Exists (l3 ++ l1).
148
+ repeat (split_pure_spatial || split_pures).
149
+ + cancel (&( "ret") # Ptr |-> ret).
150
+ sep_apply_l_atomic (sllseg_sll ret x l3 l1).
151
+ cancel (sll ret (l3 ++ l1)).
152
+ + dump_pre_spatial.
153
+ unfold merge_from_mid_rel in PreH3 at 1.
154
+ prog_nf in PreH3.
155
+ unfold_loop in PreH3.
156
+ prog_nf in PreH3.
157
+ unfold merge_body in PreH3 at 1.
158
+ destruct l1 as [|h tl]; prog_nf in PreH3; exact PreH3.
159
+ Qed.
160
+
161
+ Lemma proof_of_split_rec_return_wit_2 : split_rec_return_wit_2.
162
+ Proof.
163
+ left.
164
+ LLM_pre_process ltac:(int_auto).
165
+ Exists pv'_2. Exists qv'_2. Exists s2_2. Exists s1_2.
166
+ repeat (split_pure_spatial || split_pures).
167
+ + cancel ((q_pre) # Ptr |-> pv'_2).
168
+ cancel (sll pv'_2 s1_2).
169
+ cancel ((p_pre) # Ptr |-> qv'_2).
170
+ cancel (sll qv'_2 s2_2).
171
+ + dump_pre_spatial.
172
+ unfold reversepair, applyf.
173
+ exact PreH1.
174
+ Qed.
175
+
176
+ Lemma proof_of_split_rec_return_wit_1 : split_rec_return_wit_1.
177
+ Proof.
178
+ left.
179
+ LLM_pre_process ltac:(int_auto).
180
+ subst x_pre.
181
+ sep_apply_l_atomic (sll_zero 0 l_low_level_spec).
182
+ * dump_pre_spatial. reflexivity.
183
+ * Intros_p Hlnil.
184
+ subst l_low_level_spec.
185
+ Exists qv_low_level_spec. Exists pv_low_level_spec. Exists l1_low_level_spec. Exists l2_low_level_spec.
186
+ repeat (split_pure_spatial || split_pures).
187
+ + cancel ((p_pre) # Ptr |-> pv_low_level_spec).
188
+ cancel (sll pv_low_level_spec l1_low_level_spec).
189
+ cancel ((q_pre) # Ptr |-> qv_low_level_spec).
190
+ cancel (sll qv_low_level_spec l2_low_level_spec).
191
+ + dump_pre_spatial.
192
+ unfold split_rec_rel in PreH2.
193
+ rewrite (split_rec_rel_unfold (nil, l1_low_level_spec, l2_low_level_spec)) in PreH2.
194
+ simpl in PreH2.
195
+ exact PreH2.
196
+ Qed.
197
+
198
+ Lemma proof_of_split_rec_entail_wit_2 : split_rec_entail_wit_2.
199
+ Proof.
200
+ left.
201
+ LLM_pre_process ltac:(int_auto).
202
+ Exists l_new_2. Exists x_data_2.
203
+ repeat (split_pure_spatial || split_pures).
204
+ + cancel ((q_pre) # Ptr |-> qv_low_level_spec).
205
+ cancel (sll qv_low_level_spec l2_low_level_spec).
206
+ cancel (sll x_next l_new_2).
207
+ simpl sll.
208
+ Exists pv_low_level_spec.
209
+ split_pure_spatial.
210
+ - cancel (&((x_pre) # "list" ->ₛ"data") # Int |-> x_data_2).
211
+ cancel (&((x_pre) # "list" ->ₛ"next") # Ptr |-> pv_low_level_spec).
212
+ cancel (sll pv_low_level_spec l1_low_level_spec).
213
+ cancel.
214
+ - dump_pre_spatial. exact PreH1.
215
+ + dump_pre_spatial. exact PreH1.
216
+ + dump_pre_spatial.
217
+ rewrite PreH3 in PreH2.
218
+ unfold split_rec_rel in PreH2.
219
+ rewrite (split_rec_rel_unfold (x_data_2 :: l_new_2, l1_low_level_spec, l2_low_level_spec)) in PreH2.
220
+ simpl in PreH2.
221
+ exact PreH2.
222
+ + dump_pre_spatial. exact PreH3.
223
+ Qed.
224
+
225
+ Lemma proof_of_merge_sort_partial_solve_wit_1_pure : merge_sort_partial_solve_wit_1_pure.
226
+ Proof.
227
+ left.
228
+ LLM_pre_process ltac:(int_auto).
229
+ Qed.
230
+
231
+ Lemma proof_of_merge_sort_entail_wit_3 : merge_sort_entail_wit_3.
232
+ Proof.
233
+ left.
234
+ LLM_pre_process ltac:(int_auto).
235
+ subst p. subst q.
236
+ simpl sll.
237
+ repeat (split_pure_spatial || split_pures).
238
+ + Intros_p Hp0. Intros_p Hq0. cancel.
239
+ + dump_pre_spatial. reflexivity.
240
+ + dump_pre_spatial. reflexivity.
241
+ + dump_pre_spatial.
242
+ unfold mergesortrec in PreH3 at 1.
243
+ erewrite (program_para_equiv (mergesortrec_unfold)) in PreH3.
244
+ unfold mergesortrec_f, mergesortrec_loc0 in PreH3.
245
+ exact PreH3.
246
+ + dump_pre_spatial. reflexivity.
247
+ + dump_pre_spatial. reflexivity.
248
+ Qed.
249
+
250
+ Lemma proof_of_merge_sort_entail_wit_4 : merge_sort_entail_wit_4.
251
+ Proof.
252
+ left.
253
+ LLM_pre_process ltac:(int_auto).
254
+ sep_apply_l_atomic (sll_not_zero qv' s2).
255
+ - dump_pre_spatial. exact PreH1.
256
+ - Intros q_next. Intros h. Intros t.
257
+ Exists s1. Exists (h :: t).
258
+ repeat (split_pure_spatial || split_pures).
259
+ + cancel (sll pv' s1).
260
+ simpl.
261
+ Exists q_next.
262
+ repeat (split_pure_spatial || split_pures).
263
+ * cancel (&(qv' # "list" ->ₛ"data") # Int |-> h).
264
+ cancel (&(qv' # "list" ->ₛ"next") # Ptr |-> q_next).
265
+ cancel (sll q_next t).
266
+ * dump_pre_spatial. exact PreH1.
267
+ + dump_pre_spatial. exact PreH1.
268
+ + dump_pre_spatial.
269
+ unfold applyf, maketuple, mergesortrec_loc0 in PreH2.
270
+ rewrite H in PreH2.
271
+ simpl in PreH2. exact PreH2.
272
+ Qed.
273
+
274
+ Lemma proof_of_merge_sort_entail_wit_5 : merge_sort_entail_wit_5.
275
+ Proof.
276
+ left.
277
+ LLM_pre_process ltac:(int_auto).
278
+ Exists l2_2. Exists l0.
279
+ repeat (split_pure_spatial || split_pures).
280
+ + cancel (sll retval l0).
281
+ cancel (sll q l2_2).
282
+ + dump_pre_spatial. exact PreH2.
283
+ + dump_pre_spatial.
284
+ unfold applyf, mergesortrec_loc1 in PreH1.
285
+ unfold mergesortrec_loc2.
286
+ exact PreH1.
287
+ Qed.
288
+
289
+ Lemma proof_of_merge_sort_entail_wit_6 : merge_sort_entail_wit_6.
290
+ Proof.
291
+ left.
292
+ LLM_pre_process ltac:(int_auto).
293
+ Exists l1_2. Exists l0.
294
+ repeat (split_pure_spatial || split_pures).
295
+ + cancel (sll retval l0).
296
+ cancel (sll p l1_2).
297
+ + dump_pre_spatial.
298
+ unfold applyf in PreH1 at 1.
299
+ unfold mergesortrec_loc2 in PreH1 at 1.
300
+ prog_nf in PreH1.
301
+ exact PreH1.
302
+ Qed.
303
+
304
+ Lemma proof_of_merge_sort_return_wit_2 : merge_sort_return_wit_2.
305
+ Proof.
306
+ left.
307
+ LLM_pre_process ltac:(int_auto).
308
+ sep_apply_l_atomic (sll_zero qv' s2).
309
+ * dump_pre_spatial. rewrite PreH1. reflexivity.
310
+ * Intros_p Hs2nil.
311
+ subst s2.
312
+ Exists s1.
313
+ repeat (split_pure_spatial || split_pures).
314
+ + cancel (sll pv' s1).
315
+ + dump_pre_spatial.
316
+ unfold applyf, maketuple, mergesortrec_loc0.
317
+ simpl.
318
+ exact PreH2.
319
+ Qed.
320
+
321
+ Lemma proof_of_merge_sort_derive_low_level_spec_aux_by_low_level_spec : merge_sort_derive_low_level_spec_aux_by_low_level_spec.
322
+ Proof.
323
+ LLM_pre_process ltac:(int_auto).
324
+ apply safeExec_bind in H as (X_low_level_spec & Hsafe_first & Hsafe_cont).
325
+ Exists l_low_level_spec_aux.
326
+ Exists X_low_level_spec.
327
+ split_pure_spatial.
328
+ + cancel (sll x_pre l_low_level_spec_aux).
329
+ apply derivable1_wand_sepcon_adjoint.
330
+ Intros l0_2. Intros retval_2.
331
+ Exists l0_2. Exists retval_2.
332
+ repeat (split_pure_spatial || split_pures).
333
+ - cancel (sll retval_2 l0_2).
334
+ - dump_pre_spatial.
335
+ apply (Hsafe_cont ATrue l0_2).
336
+ exact H.
337
+ + dump_pre_spatial. exact Hsafe_first.
338
+ Qed.
339
+
340
+ Lemma proof_of_merge_sort_derive_high_level_spec_by_low_level_spec : merge_sort_derive_high_level_spec_by_low_level_spec.
341
+ Proof.
342
+ LLM_pre_process ltac:(int_auto).
343
+ Exists l_high_level_spec.
344
+ Exists (fun l0 _ => Permutation l_high_level_spec l0 /\ incr l0).
345
+ split_pure_spatial.
346
+ + cancel (sll x_pre l_high_level_spec).
347
+ apply derivable1_wand_sepcon_adjoint.
348
+ Intros l0_2. Intros retval_2.
349
+ Exists l0_2. Exists retval_2.
350
+ repeat (split_pure_spatial || split_pures).
351
+ - cancel (sll retval_2 l0_2).
352
+ - dump_pre_spatial.
353
+ apply safeExec_ret in H as (? & _ & Hret).
354
+ sets_unfold in Hret.
355
+ exact (proj1 Hret).
356
+ - dump_pre_spatial.
357
+ apply safeExec_ret in H as (? & _ & Hret).
358
+ sets_unfold in Hret.
359
+ exact (proj2 Hret).
360
+ + dump_pre_spatial.
361
+ eapply safeExec_X_subset.
362
+ - apply Hoare_result_state.
363
+ apply functional_correctness_mergesort.
364
+ - apply safeExec_result_state.
365
+ exists tt. exact I.
366
+ Qed.
367
+
368
+ Lemma proof_of_split_rec_derive_low_level_spec_aux_by_low_level_spec : split_rec_derive_low_level_spec_aux_by_low_level_spec.
369
+ Proof.
370
+ LLM_pre_process ltac:(int_auto).
371
+ apply safeExec_bind in H as (X_low_level_spec & Hsafe_first & Hsafe_cont).
372
+ Exists l_low_level_spec_aux. Exists l1_low_level_spec_aux. Exists l2_low_level_spec_aux.
373
+ Exists X_low_level_spec.
374
+ Exists pv_low_level_spec_aux. Exists qv_low_level_spec_aux.
375
+ split_pure_spatial.
376
+ + cancel (sll x_pre l_low_level_spec_aux).
377
+ cancel ((p_pre) # Ptr |-> pv_low_level_spec_aux).
378
+ cancel (sll pv_low_level_spec_aux l1_low_level_spec_aux).
379
+ cancel ((q_pre) # Ptr |-> qv_low_level_spec_aux).
380
+ cancel (sll qv_low_level_spec_aux l2_low_level_spec_aux).
381
+ apply derivable1_wand_sepcon_adjoint.
382
+ Intros qv'_2. Intros pv'_2. Intros s1_2. Intros s2_2.
383
+ Exists qv'_2. Exists pv'_2. Exists s1_2. Exists s2_2.
384
+ repeat (split_pure_spatial || split_pures).
385
+ - cancel ((p_pre) # Ptr |-> pv'_2).
386
+ cancel (sll pv'_2 s1_2).
387
+ cancel ((q_pre) # Ptr |-> qv'_2).
388
+ cancel (sll qv'_2 s2_2).
389
+ - dump_pre_spatial.
390
+ unfold applyf, maketuple.
391
+ apply (Hsafe_cont ATrue (s1_2, s2_2)).
392
+ exact H.
393
+ + dump_pre_spatial. exact Hsafe_first.
394
+ Qed.
395
+
396
+ Lemma proof_of_split_rec_derive_high_level_spec_by_low_level_spec : split_rec_derive_high_level_spec_by_low_level_spec.
397
+ Proof.
398
+ LLM_pre_process ltac:(int_auto).
399
+ Exists l_high_level_spec. Exists (@nil Z). Exists (@nil Z).
400
+ Exists X_high_level_spec.
401
+ Exists pv_high_level_spec. Exists qv_high_level_spec.
402
+ split_pure_spatial.
403
+ + cancel (sll x_pre l_high_level_spec).
404
+ cancel ((p_pre) # Ptr |-> pv_high_level_spec).
405
+ cancel (sll pv_high_level_spec (@nil Z)).
406
+ cancel ((q_pre) # Ptr |-> qv_high_level_spec).
407
+ cancel (sll qv_high_level_spec (@nil Z)).
408
+ apply derivable1_wand_sepcon_adjoint.
409
+ Intros qv'_2. Intros pv'_2. Intros s1_2. Intros s2_2.
410
+ Exists qv'_2. Exists pv'_2. Exists s1_2. Exists s2_2.
411
+ repeat (split_pure_spatial || split_pures).
412
+ - cancel ((p_pre) # Ptr |-> pv'_2).
413
+ cancel (sll pv'_2 s1_2).
414
+ cancel ((q_pre) # Ptr |-> qv'_2).
415
+ cancel (sll qv'_2 s2_2).
416
+ - dump_pre_spatial. exact H0.
417
+ + dump_pre_spatial.
418
+ unfold split_rel in H.
419
+ unfold split_rec_rel.
420
+ exact H.
421
+ Qed.
benchmarks/Algorithms/sll_merge_sort/rocq/helper_lib.v ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Require Import Coq.ZArith.ZArith.
2
+ Require Import Coq.Bool.Bool.
3
+ Require Import Coq.Strings.String.
4
+ Require Import Coq.Lists.List.
5
+ Require Import Coq.Classes.RelationClasses.
6
+ Require Import Coq.micromega.Psatz.
7
+ Require Import Coq.Sorting.Permutation.
8
+ From SetsClass Require Import SetsClass.
9
+ From FP Require Import SetsFixedpoints.
10
+ Require Import MonadLib.StateRelMonad.StateRelMonad.
11
+
12
+
13
+ Local Open Scope Z_scope.
14
+ Import SetsNotation.
15
+ Local Open Scope sets.
16
+ Import ListNotations.
17
+ Local Open Scope string.
18
+ Local Open Scope list.
19
+
20
+ Export MonadNotation.
21
+ Local Open Scope monad.
22
+
23
+ Require Export PVbench.Algorithms.sll_merge_sort.rocq.spec_lib.
24
+
25
+ Definition merge_body:
26
+ list Z * list Z * list Z ->
27
+ MONAD (CntOrBrk (list Z * list Z * list Z) (list Z)) :=
28
+ fun '(l1, l2, l3) =>
29
+ match l1, l2 with
30
+ | nil, _ => return (by_break (l3 ++ l2))
31
+ | _, nil => return (by_break (l3 ++ l1))
32
+ | x :: l1', y :: l2' =>
33
+ choice
34
+ (test' (x <= y);; return (by_continue (l1', l2, l3 ++ x :: nil)))
35
+ (test' (y <= x);; return (by_continue (l1, l2', l3 ++ y :: nil)))
36
+ end.
37
+
38
+ Definition merge_rel l l0 :=
39
+ repeat_break merge_body (l, l0, nil).
40
+
41
+ Definition merge_from_mid_rel l1 l2 l3 :=
42
+ repeat_break merge_body (l1, l2, l3).
43
+
44
+ Definition reversepair : ((list Z) * (list Z)) -> MONAD ((list Z) * (list Z)) :=
45
+ fun '(p,q) => return (q,p).
46
+
47
+ Definition split_rec_rel_f (W : ((list Z) * (list Z) * (list Z)) -> MONAD ((list Z) * (list Z)))
48
+ : ((list Z) * (list Z) * (list Z)) -> MONAD ((list Z) * (list Z)) :=
49
+ fun '(x, p, q) => match x with
50
+ | nil => return (p, q)
51
+ | xh :: x' => x <- W (x', q, xh::p) ;;
52
+ reversepair x
53
+ end.
54
+
55
+ Definition split_rec_rel' : ((list Z) * (list Z) * (list Z)) -> MONAD ((list Z) * (list Z)) :=
56
+ Lfix split_rec_rel_f.
57
+
58
+ Definition split_rec_rel l1 l2 l3: MONAD ((list Z) * (list Z)) :=
59
+ split_rec_rel' (l1, l2, l3).
60
+
61
+ Definition split_rel x :=
62
+ split_rec_rel' (x, nil, nil).
63
+
64
+ Definition mergesortrec_f (W : (list Z) -> MONAD (list Z) )
65
+ : ((list Z) -> MONAD (list Z)) :=
66
+ fun x => '(p1, q1) <- split_rel x ;;
67
+ match q1 with
68
+ | nil => return p1
69
+ | _ :: _ => p2 <- W (p1) ;;
70
+ q2 <- W (q1) ;;
71
+ merge_rel p2 q2
72
+ end.
73
+
74
+ Definition mergesortrec := Lfix (mergesortrec_f).
75
+
76
+ Definition mergesortrec_loc0: ((list Z) * (list Z)) -> MONAD (list Z) :=
77
+ fun x => match x with
78
+ | (p1, q1) =>
79
+ match q1 with
80
+ | nil => return p1
81
+ | _ :: _ => p2 <- mergesortrec p1 ;;
82
+ q2 <- mergesortrec q1 ;;
83
+ merge_rel p2 q2
84
+ end
85
+ end.
86
+
87
+ Definition mergesortrec_loc1 q1: list Z -> MONAD (list Z) :=
88
+ fun p2 => q2 <- mergesortrec q1 ;;
89
+ merge_rel p2 q2.
90
+
91
+ Definition mergesortrec_loc2 p2: list Z -> MONAD (list Z) :=
92
+ fun q2 => merge_rel p2 q2.
93
+
94
+ Definition maketuple (x p :list Z): ((list Z) * (list Z)) := (x, p).
95
+ Definition applyf {A B: Type} (f: A -> B) (a: A) := f a.
benchmarks/Algorithms/sll_merge_sort/rocq/solution_annotated.c ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #include "sll_def.h"
2
+ #include "safeexec_def.h"
3
+
4
+ /*@ Extern Coq
5
+ (Permutation : list Z -> list Z -> Prop)
6
+ (incr : list Z -> Prop)
7
+ */
8
+ /*@ Import Coq Require Import PVbench.Algorithms.sll_merge_sort.rocq.spec_lib */
9
+ /*@ Import Coq Require Import PVbench.Algorithms.sll_merge_sort.rocq.helper_lib */
10
+ /*@ Extern Coq
11
+ (maketuple : list Z -> list Z -> ((list Z) * (list Z)))
12
+ (merge_rel : list Z -> list Z -> program unit (list Z))
13
+ (merge_from_mid_rel : list Z -> list Z -> list Z -> program unit (list Z))
14
+ (split_rec_rel : list Z -> list Z -> list Z -> program unit ((list Z) * (list Z)))
15
+ (split_rel : list Z -> program unit ((list Z) * (list Z)))
16
+ (reversepair : ((list Z) * (list Z)) -> program unit ((list Z) * (list Z)))
17
+ (mergesortrec : list Z -> program unit (list Z))
18
+ (mergesortrec_loc1 : list Z -> list Z -> program unit (list Z))
19
+ (mergesortrec_loc2 : list Z -> list Z -> program unit (list Z))
20
+ (mergesortrec_loc0 : ((list Z) * (list Z)) -> program unit (list Z))
21
+ */
22
+
23
+ struct list *merge(struct list *x, struct list *y)
24
+ /*@ With s1 s2 X
25
+ Require safeExec(ATrue, merge_rel(s1, s2), X) && sll(x, s1) * sll(y, s2)
26
+ Ensure exists s3, safeExec(ATrue, return(s3), X) && sll(__return, s3)
27
+ */
28
+ {
29
+ struct list **t, *ret;
30
+ t = &ret;
31
+ /*@ Inv Assert
32
+ exists l1 l2 l3,
33
+ safeExec(ATrue, merge_from_mid_rel(l1, l2, l3), X) &&
34
+ sll(x, l1) * sll(y, l2) *
35
+ has_ptr_permission(t) * sllbseg(&ret, t, l3)
36
+ */
37
+ while (1)
38
+ {
39
+ if (x == (void *)0) {
40
+ *t = y;
41
+ break;
42
+ }
43
+ if (y == (void *)0) {
44
+ *t = x;
45
+ break;
46
+ }
47
+ /*@ Assert
48
+ exists l1 l2 l3 l1_new l2_new xdata ydata xnext ynext,
49
+ safeExec(ATrue, merge_from_mid_rel(l1, l2, l3), X) &&
50
+ x != 0 && y != 0 &&
51
+ l1 == cons(xdata, l1_new) &&
52
+ l2 == cons(ydata, l2_new) &&
53
+ store(&(x->data), xdata) * store(&(y->data), ydata) *
54
+ store(&(x->next), xnext) * store(&(y->next), ynext) *
55
+ sll(xnext, l1_new) * sll(ynext, l2_new) *
56
+ has_ptr_permission(t) * sllbseg(&ret, t, l3)
57
+ */
58
+ if (x->data < y->data) {
59
+ *t = x;
60
+ t = &(x->next);
61
+ x = x->next;
62
+ } else {
63
+ *t = y;
64
+ t = &(y->next);
65
+ y = y->next;
66
+ }
67
+ }
68
+ /*@ Assert
69
+ exists s3,
70
+ safeExec(ATrue, return(s3), X) &&
71
+ store(&x, struct list*, x) *
72
+ store(&y, struct list*, y) *
73
+ store(&t, struct list**, t) *
74
+ sll(ret, s3)
75
+ */
76
+ return ret;
77
+ }
78
+
79
+ void split_rec(struct list * x, struct list * * p, struct list * * q)
80
+ /*@ high_level_spec <= low_level_spec
81
+ With l X pv qv
82
+ Require safeExec(ATrue, split_rel(l), X) &&
83
+ store(p, pv) * store(q, qv) *
84
+ sll(x, l) * sll(pv, nil) * sll(qv, nil)
85
+ Ensure exists s1 s2 pv' qv',
86
+ safeExec(ATrue, return(maketuple(s1, s2)), X) &&
87
+ store(p, pv') * store(q, qv') *
88
+ sll(pv', s1) * sll(qv', s2)
89
+ */
90
+ ;
91
+
92
+ void split_rec(struct list * x, struct list * * p, struct list * * q)
93
+ /*@ low_level_spec_aux <= low_level_spec
94
+ With {B} l l1 l2 (c : ((list Z) * (list Z)) -> program unit B) X pv qv
95
+ Require safeExec(ATrue, bind(split_rec_rel(l, l1, l2), c), X) &&
96
+ store(p, pv) * store(q, qv) *
97
+ sll(x, l) * sll(pv, l1) * sll(qv, l2)
98
+ Ensure exists s1 s2 pv' qv',
99
+ safeExec(ATrue, applyf(c, maketuple(s1,s2)), X) &&
100
+ store(p, pv') * store(q, qv') *
101
+ sll(pv', s1) * sll(qv', s2)
102
+ */
103
+ ;
104
+
105
+ void split_rec(struct list * x, struct list * * p, struct list * * q)
106
+ /*@ low_level_spec
107
+ With l l1 l2 X pv qv
108
+ Require safeExec(ATrue, split_rec_rel(l, l1, l2), X) &&
109
+ store(p, pv) * store(q, qv) *
110
+ sll(x, l) * sll(pv, l1) * sll(qv, l2)
111
+ Ensure exists s1 s2 pv' qv',
112
+ safeExec(ATrue, return(maketuple(s1, s2)), X) &&
113
+ store(p, pv') * store(q, qv') *
114
+ sll(pv', s1) * sll(qv', s2)
115
+ */
116
+ {
117
+ if (x == (void *)0) {
118
+ return;
119
+ }
120
+ /*@ Assert
121
+ exists l_new x_data x_next,
122
+ x == x@pre && p == p@pre && q == q@pre &&
123
+ x != 0 &&
124
+ safeExec(ATrue, split_rec_rel(l, l1, l2), X) &&
125
+ l == cons(x_data, l_new) &&
126
+ store(&(x->data), x_data) * store(&(x->next), x_next) *
127
+ store(p, pv) * store(q, qv) *
128
+ sll(x_next, l_new) * sll(pv, l1) * sll(qv, l2)
129
+ */
130
+ struct list * t;
131
+ t = x -> next;
132
+ x -> next = * p;
133
+ * p = x;
134
+ /*@ Assert
135
+ exists l_new x_data,
136
+ x == x@pre && p == p@pre && q == q@pre &&
137
+ x != 0 &&
138
+ safeExec(ATrue, bind(split_rec_rel(l_new, l2, cons(x_data, l1)), reversepair), X) &&
139
+ l == cons(x_data, l_new) &&
140
+ store(p, x) * store(q, qv) *
141
+ sll(x, cons(x_data, l1)) * sll(t, l_new) * sll(qv, l2)
142
+ */
143
+ split_rec(t, q, p) /*@ where(low_level_spec_aux) l1 = l2, c = reversepair, X = X; B = (list Z) * (list Z) */;
144
+ }
145
+
146
+ struct list * merge_sort(struct list * x)
147
+ /*@ high_level_spec <= low_level_spec
148
+ With l
149
+ Require sll(x, l)
150
+ Ensure exists l0,
151
+ Permutation(l, l0) && incr(l0) &&
152
+ sll(__return, l0)
153
+ */
154
+ ;
155
+
156
+ struct list * merge_sort(struct list * x)
157
+ /*@ low_level_spec_aux <= low_level_spec
158
+ With {B} l (c: list Z -> program unit B) X
159
+ Require safeExec(ATrue, bind(mergesortrec(l), c), X) && sll(x, l)
160
+ Ensure exists l0,
161
+ safeExec(ATrue, applyf(c, l0), X) &&
162
+ sll(__return, l0)
163
+ */
164
+ ;
165
+
166
+ struct list * merge_sort(struct list * x)
167
+ /*@ low_level_spec
168
+ With l X
169
+ Require safeExec(ATrue, mergesortrec(l), X) && sll(x, l)
170
+ Ensure exists l0,
171
+ safeExec(ATrue, return(l0), X) &&
172
+ sll(__return, l0)
173
+ */
174
+ {
175
+ struct list * p, * q;
176
+ p = (void *)0;
177
+ /*@ Assert
178
+ x == x@pre && p == 0 && has_ptr_permission(&q) && safeExec(ATrue, mergesortrec(l), X) && sll(p, nil) * sll(x, l)
179
+ */
180
+ q = (void *)0;
181
+ /*@ Assert
182
+ x == x@pre && p == 0 && q == 0 && safeExec(ATrue, mergesortrec(l), X) && sll(p, nil) * sll(q, nil) * sll(x, l)
183
+ */
184
+ /*@ Assert
185
+ x == x@pre && p == 0 && q == 0 && safeExec(ATrue, bind(split_rel(l), mergesortrec_loc0), X) && sll(p, nil) * sll(q, nil) * sll(x, l)
186
+ */
187
+ split_rec(x, &p, &q) /*@ where(low_level_spec_aux) X = X, c = mergesortrec_loc0; B = (list Z) */;
188
+ if (q == (void *)0) {
189
+ return p;
190
+ }
191
+ /*@ Assert
192
+ exists l1 l2,
193
+ x == x@pre && q != 0 &&
194
+ safeExec(ATrue, bind(mergesortrec(l1), mergesortrec_loc1(l2)), X) && sll(p, l1) * sll(q, l2) */
195
+ p = merge_sort(p) /*@ where(low_level_spec_aux) X = X; B = (list Z) */;
196
+ /*@ Assert
197
+ exists l1 l2,
198
+ x == x@pre && q != 0 &&
199
+ safeExec(ATrue, bind(mergesortrec(l2), mergesortrec_loc2(l1)), X) && sll(p, l1) * sll(q, l2) */
200
+ q = merge_sort(q) /*@ where(low_level_spec_aux) X = X; B = (list Z) */;
201
+ /*@ Assert
202
+ exists l1 l2, x == x@pre &&
203
+ safeExec(ATrue, merge_rel(l1, l2), X) && sll(p, l1) * sll(q, l2) */
204
+ return merge(p, q) /*@ where X = X */;
205
+ }
benchmarks/Algorithms/sll_merge_sort/rocq/solution_spec.c ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #include "sll_def.h"
2
+
3
+ /*@ Extern Coq
4
+ (Permutation : list Z -> list Z -> Prop)
5
+ (incr : list Z -> Prop)
6
+ */
7
+ /*@ Import Coq Require Import PVbench.Algorithms.sll_merge_sort.rocq.spec_lib */
8
+
9
+ struct list *merge(struct list *x, struct list *y)
10
+ {
11
+ struct list **t, *ret;
12
+ t = &ret;
13
+ while (1)
14
+ {
15
+ if (x == (void *)0) {
16
+ *t = y;
17
+ break;
18
+ }
19
+ if (y == (void *)0) {
20
+ *t = x;
21
+ break;
22
+ }
23
+ if (x->data < y->data) {
24
+ *t = x;
25
+ t = &(x->next);
26
+ x = x->next;
27
+ } else {
28
+ *t = y;
29
+ t = &(y->next);
30
+ y = y->next;
31
+ }
32
+ }
33
+ return ret;
34
+ }
35
+
36
+ void split_rec(struct list * x, struct list * * p, struct list * * q)
37
+ {
38
+ if (x == (void *)0) {
39
+ return;
40
+ }
41
+ struct list * t;
42
+ t = x -> next;
43
+ x -> next = * p;
44
+ * p = x;
45
+ split_rec(t, q, p);
46
+ }
47
+
48
+ struct list * merge_sort(struct list * x)
49
+ /*@ With l
50
+ Require sll(x, l)
51
+ Ensure exists l0,
52
+ Permutation(l, l0) && incr(l0) &&
53
+ sll(__return, l0)
54
+ */
55
+ {
56
+ struct list * p, * q;
57
+ p = (void *)0;
58
+ q = (void *)0;
59
+ split_rec(x, &p, &q);
60
+ if (q == (void *)0) {
61
+ return p;
62
+ }
63
+ p = merge_sort(p);
64
+ q = merge_sort(q);
65
+ return merge(p, q);
66
+ }
benchmarks/Algorithms/sll_merge_sort/rocq/spec_lib.v ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Require Import Coq.ZArith.ZArith.
2
+ Require Import Coq.Lists.List.
3
+
4
+ Local Open Scope Z_scope.
5
+ Import ListNotations.
6
+ Local Open Scope list.
7
+
8
+ Fixpoint incr_aux (l: list Z) (x: Z): Prop :=
9
+ match l with
10
+ | nil => True
11
+ | y :: l0 => x <= y /\ incr_aux l0 y
12
+ end.
13
+
14
+ Definition incr (l: list Z): Prop :=
15
+ match l with
16
+ | nil => True
17
+ | x :: l0 => incr_aux l0 x
18
+ end.
benchmarks/Algorithms/sll_merge_sort/solution.c ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #include "sll_def.h"
2
+
3
+ struct list *merge(struct list *x, struct list *y)
4
+ {
5
+ struct list **t, *ret;
6
+ t = &ret;
7
+ while (1)
8
+ {
9
+ if (x == (void *)0) {
10
+ *t = y;
11
+ break;
12
+ }
13
+ if (y == (void *)0) {
14
+ *t = x;
15
+ break;
16
+ }
17
+ if (x->data < y->data) {
18
+ *t = x;
19
+ t = &(x->next);
20
+ x = x->next;
21
+ } else {
22
+ *t = y;
23
+ t = &(y->next);
24
+ y = y->next;
25
+ }
26
+ }
27
+ return ret;
28
+ }
29
+
30
+ void split_rec(struct list * x, struct list * * p, struct list * * q)
31
+ {
32
+ if (x == (void *)0) {
33
+ return;
34
+ }
35
+ struct list * t;
36
+ t = x -> next;
37
+ x -> next = * p;
38
+ * p = x;
39
+ split_rec(t, q, p);
40
+ }
41
+
42
+ struct list * merge_sort(struct list * x)
43
+ {
44
+ struct list * p, * q;
45
+ p = (void *)0;
46
+ q = (void *)0;
47
+ split_rec(x, &p, &q);
48
+ if (q == (void *)0) {
49
+ return p;
50
+ }
51
+ p = merge_sort(p);
52
+ q = merge_sort(q);
53
+ return merge(p, q);
54
+ }
benchmarks/Data_structures/dll_queue/manifest.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "id": "dll_queue",
3
+ "source": {
4
+ "dataset": "classical_data_structure",
5
+ "problem_id": "dll_queue",
6
+ "title": "Queue on a Doubly Linked List",
7
+ "tags": [
8
+ "data structures",
9
+ "queue",
10
+ "linked list"
11
+ ]
12
+ },
13
+ "stratification": {
14
+ "band": "unclassified",
15
+ "output_mode": "CONSTRUCT",
16
+ "interactive": false,
17
+ "multi_test": false
18
+ }
19
+ }
benchmarks/Data_structures/dll_queue/problem.md ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Queue on a Doubly Linked List
2
+
3
+ ## Description
4
+
5
+ Maintain a first-in first-out queue of integers stored in a doubly linked list with head and tail pointers, supporting insertion at the back and removal from the front.
6
+
7
+ ## Input
8
+
9
+ - `enqueue` receives a queue `q` and an integer `x`.
10
+ - `dequeue` receives a non-empty queue `q`.
11
+
12
+ ## Output
13
+
14
+ - `enqueue` appends `x` at the back of `q`.
15
+ - `dequeue` removes the element at the front of `q` and returns it.
benchmarks/Data_structures/dll_queue/rocq/dll_queue_store.strategies ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //test curent rules
2
+ //max rule id:30
3
+
4
+ #include "dll_queue_store_def.h"
5
+
6
+
7
+
8
+
9
+ id : 0
10
+ priority : core(2)
11
+ left : store_queue(?p, ?l0) at 0
12
+ right : store_queue(p, ?l1) at 1
13
+ action : left_erase(0);
14
+ right_erase(1);
15
+ right_add(l0 == l1);
16
+
17
+ id : 1
18
+ priority : core(2)
19
+ left : dllseg(?p, 0, ?q, ?r, ?l0) at 0
20
+ right : dllseg(p, 0, q, r, ?l1) at 1
21
+ action : left_erase(0);
22
+ right_erase(1);
23
+ right_add(l0 == l1);
24
+
benchmarks/Data_structures/dll_queue/rocq/dll_queue_store_def.h ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ struct list {
2
+ int data;
3
+ struct list *next;
4
+ struct list *prev;
5
+ };
6
+
7
+ struct queue {
8
+ struct list * head;
9
+ struct list * tail;
10
+ };
11
+
12
+ /*@ Import Coq Require Import PVbench.Data_structures.dll_queue.rocq.spec_lib */
13
+
14
+ /*@ Extern Coq (store_queue : Z -> list Z -> Assertion)
15
+ (dllseg: Z -> Z -> Z -> Z -> list Z -> Assertion)
16
+ */
benchmarks/Data_structures/dll_queue/rocq/groundtruth/dll_queue_goal.v ADDED
@@ -0,0 +1,453 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Require Import Coq.ZArith.ZArith.
2
+ Require Import Coq.Bool.Bool.
3
+ Require Import Coq.Strings.String.
4
+ Require Import Coq.Strings.Ascii.
5
+ Require Import Coq.Lists.List.
6
+ Require Import Coq.Classes.RelationClasses.
7
+ Require Import Coq.Classes.Morphisms.
8
+ Require Import Coq.micromega.Psatz.
9
+ Require Import Coq.Sorting.Permutation.
10
+ From AUXLib Require Import int_auto Axioms Feq Idents ListLib VMap.
11
+ Require Import SetsClass.SetsClass. Import SetsNotation.
12
+ From SimpleC.SL Require Import Mem SeparationLogic.
13
+ Require Import Logic.LogicGenerator.demo932.Interface.
14
+ Local Open Scope Z_scope.
15
+ Local Open Scope sets.
16
+ Local Open Scope string_scope.
17
+ Local Open Scope list.
18
+ Import naive_C_Rules.
19
+ Require Import PVbench.Data_structures.dll_queue.rocq.spec_lib.
20
+ Local Open Scope sac.
21
+ From PVbench.Data_structures.dll_queue.rocq.groundtruth Require Import dll_queue_store_strategy_goal.
22
+ From PVbench.Data_structures.dll_queue.rocq.groundtruth Require Import dll_queue_store_strategy_proof.
23
+
24
+ (*----- Function enqueue -----*)
25
+
26
+ Definition enqueue_safety_wit_1 :=
27
+ forall (x_pre: Z) (q_pre: Z) (l: (@list Z)) (qhead: Z) (qtail: Z) (retval: Z) (PreH1 : (retval <> 0)) ,
28
+ ((&((retval) # "list" ->ₛ "next")) # Ptr |-> 0)
29
+ ** ((&((retval) # "list" ->ₛ "prev")) # Ptr |-> 0)
30
+ ** ((&((retval) # "list" ->ₛ "data")) # Int |-> x_pre)
31
+ ** ((( &( "p" ) )) # Ptr |-> retval)
32
+ ** ((( &( "q" ) )) # Ptr |-> q_pre)
33
+ ** ((( &( "x" ) )) # Int |-> x_pre)
34
+ ** (dllseg qhead 0 0 qtail l )
35
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qhead)
36
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> qtail)
37
+ |--
38
+ “ (0 <= INT_MAX) ”
39
+ && “ ((INT_MIN) <= 0) ”
40
+ .
41
+
42
+ Definition enqueue_safety_wit_2 :=
43
+ forall (x_pre: Z) (q_pre: Z) (l: (@list Z)) (qhead: Z) (qtail: Z) (retval: Z) (PreH1 : (qhead = 0)) (PreH2 : (retval <> 0)) ,
44
+ ((&((retval) # "list" ->ₛ "next")) # Ptr |-> 0)
45
+ ** ((&((retval) # "list" ->ₛ "prev")) # Ptr |-> 0)
46
+ ** ((&((retval) # "list" ->ₛ "data")) # Int |-> x_pre)
47
+ ** ((( &( "p" ) )) # Ptr |-> retval)
48
+ ** ((( &( "q" ) )) # Ptr |-> q_pre)
49
+ ** ((( &( "x" ) )) # Int |-> x_pre)
50
+ ** (dllseg qhead 0 0 qtail l )
51
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> retval)
52
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> retval)
53
+ |--
54
+ “ (0 <= INT_MAX) ”
55
+ && “ ((INT_MIN) <= 0) ”
56
+ .
57
+
58
+ Definition enqueue_safety_wit_3 :=
59
+ forall (x_pre: Z) (q_pre: Z) (l: (@list Z)) (qhead: Z) (qtail: Z) (retval: Z) (PreH1 : (qhead = 0)) (PreH2 : (retval <> 0)) ,
60
+ ((&((retval) # "list" ->ₛ "next")) # Ptr |-> 0)
61
+ ** ((&((retval) # "list" ->ₛ "prev")) # Ptr |-> 0)
62
+ ** ((&((retval) # "list" ->ₛ "data")) # Int |-> x_pre)
63
+ ** ((( &( "p" ) )) # Ptr |-> retval)
64
+ ** ((( &( "q" ) )) # Ptr |-> q_pre)
65
+ ** ((( &( "x" ) )) # Int |-> x_pre)
66
+ ** (dllseg qhead 0 0 qtail l )
67
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> retval)
68
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> retval)
69
+ |--
70
+ “ (0 <= INT_MAX) ”
71
+ && “ ((INT_MIN) <= 0) ”
72
+ .
73
+
74
+ Definition enqueue_safety_wit_4 :=
75
+ forall (x_pre: Z) (q_pre: Z) (l: (@list Z)) (l0: (@list Z)) (qtailv: Z) (qtail: Z) (qhead: Z) (qtailnext: Z) (qtailprev: Z) (p: Z) (PreH1 : (p <> 0)) (PreH2 : (qtail <> 0)) (PreH3 : (qhead <> 0)) (PreH4 : (l = (app (l0) ((cons (qtailv) ((@nil Z))))))) (PreH5 : (qtailnext = 0)) ,
76
+ ((( &( "x" ) )) # Int |-> x_pre)
77
+ ** ((( &( "q" ) )) # Ptr |-> q_pre)
78
+ ** ((( &( "p" ) )) # Ptr |-> p)
79
+ ** (dllseg qhead qtail 0 qtailprev l0 )
80
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> p)
81
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qhead)
82
+ ** ((&((qtail) # "list" ->ₛ "next")) # Ptr |-> p)
83
+ ** ((&((qtail) # "list" ->ₛ "prev")) # Ptr |-> qtailprev)
84
+ ** ((&((qtail) # "list" ->ₛ "data")) # Int |-> qtailv)
85
+ ** ((&((p) # "list" ->ₛ "next")) # Ptr |-> 0)
86
+ ** ((&((p) # "list" ->ₛ "prev")) # Ptr |-> qtail)
87
+ ** ((&((p) # "list" ->ₛ "data")) # Int |-> x_pre)
88
+ |--
89
+ “ (0 <= INT_MAX) ”
90
+ && “ ((INT_MIN) <= 0) ”
91
+ .
92
+
93
+ Definition enqueue_entail_wit_1 :=
94
+ (
95
+ forall (q_pre: Z) (l: (@list Z)) ,
96
+ (store_queue q_pre l )
97
+ |--
98
+ EX (qhead: Z) (qtail: Z) ,
99
+ (dllseg qhead 0 0 qtail l )
100
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qhead)
101
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> qtail)
102
+ ) \/
103
+ (
104
+ forall (q_pre: Z) (l: (@list Z)) ,
105
+ (store_queue q_pre l )
106
+ |--
107
+ EX (qhead: Z) (qtail: Z) ,
108
+ (dllseg qhead 0 0 qtail l )
109
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qhead)
110
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> qtail)
111
+ ).
112
+
113
+ Definition enqueue_entail_wit_2 :=
114
+ (
115
+ forall (x_pre: Z) (q_pre: Z) (l: (@list Z)) (qhead_2: Z) (qtail_2: Z) (retval: Z) (PreH1 : (qhead_2 <> 0)) (PreH2 : (retval <> 0)) ,
116
+ ((&((retval) # "list" ->ₛ "next")) # Ptr |-> 0)
117
+ ** ((&((retval) # "list" ->ₛ "prev")) # Ptr |-> 0)
118
+ ** ((&((retval) # "list" ->ₛ "data")) # Int |-> x_pre)
119
+ ** (dllseg qhead_2 0 0 qtail_2 l )
120
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qhead_2)
121
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> qtail_2)
122
+ |--
123
+ EX (qtailprev: Z) (qtailnext: Z) (l0: (@list Z)) (qtailv: Z) (qhead: Z) (qtail: Z) ,
124
+ “ (retval <> 0) ”
125
+ && “ (qtail <> 0) ”
126
+ && “ (qhead <> 0) ”
127
+ && “ (l = (app (l0) ((cons (qtailv) ((@nil Z)))))) ”
128
+ && “ (qtailnext = 0) ”
129
+ && (dllseg qhead qtail 0 qtailprev l0 )
130
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> qtail)
131
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qhead)
132
+ ** ((&((qtail) # "list" ->ₛ "next")) # Ptr |-> qtailnext)
133
+ ** ((&((qtail) # "list" ->ₛ "prev")) # Ptr |-> qtailprev)
134
+ ** ((&((qtail) # "list" ->ₛ "data")) # Int |-> qtailv)
135
+ ** ((&((retval) # "list" ->ₛ "next")) # Ptr |-> 0)
136
+ ** ((&((retval) # "list" ->ₛ "prev")) # Ptr |-> 0)
137
+ ** ((&((retval) # "list" ->ₛ "data")) # Int |-> x_pre)
138
+ ) \/
139
+ (
140
+ forall (l: (@list Z)) (qhead_2: Z) (qtail_2: Z) (retval: Z) (PreH1 : (qhead_2 <> 0)) (PreH2 : (retval <> 0)) ,
141
+ (dllseg qhead_2 0 0 qtail_2 l )
142
+ |--
143
+ EX (qtailprev: Z) (l0: (@list Z)) (qtailv: Z) ,
144
+ “ (retval <> 0) ”
145
+ && “ (qtail_2 <> 0) ”
146
+ && “ (qhead_2 <> 0) ”
147
+ && “ (l = (app (l0) ((cons (qtailv) ((@nil Z)))))) ”
148
+ && (dllseg qhead_2 qtail_2 0 qtailprev l0 )
149
+ ** ((&((qtail_2) # "list" ->ₛ "next")) # Ptr |-> 0)
150
+ ** ((&((qtail_2) # "list" ->ₛ "prev")) # Ptr |-> qtailprev)
151
+ ** ((&((qtail_2) # "list" ->ₛ "data")) # Int |-> qtailv)
152
+ ).
153
+
154
+ Definition enqueue_return_wit_1 :=
155
+ (
156
+ forall (x_pre: Z) (q_pre: Z) (l: (@list Z)) (qhead: Z) (qtail: Z) (retval: Z) (PreH1 : (qhead = 0)) (PreH2 : (retval <> 0)) ,
157
+ ((&((retval) # "list" ->ₛ "next")) # Ptr |-> 0)
158
+ ** ((&((retval) # "list" ->ₛ "prev")) # Ptr |-> 0)
159
+ ** ((&((retval) # "list" ->ₛ "data")) # Int |-> x_pre)
160
+ ** (dllseg qhead 0 0 qtail l )
161
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> retval)
162
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> retval)
163
+ |--
164
+ (store_queue q_pre (app (l) ((cons (x_pre) ((@nil Z))))) )
165
+ ) \/
166
+ (
167
+ forall (x_pre: Z) (q_pre: Z) (l: (@list Z)) (qhead: Z) (qtail: Z) (retval: Z) (PreH1 : (x_pre <= INT_MAX)) (PreH2 : (x_pre >= INT_MIN)) (PreH3 : (qhead = 0)) (PreH4 : (retval <> 0)) ,
168
+ ((&((retval) # "list" ->ₛ "next")) # Ptr |-> 0)
169
+ ** ((&((retval) # "list" ->ₛ "prev")) # Ptr |-> 0)
170
+ ** ((&((retval) # "list" ->ₛ "data")) # Int |-> x_pre)
171
+ ** (dllseg qhead 0 0 qtail l )
172
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> retval)
173
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> retval)
174
+ |--
175
+ (store_queue q_pre (app (l) ((cons (x_pre) ((@nil Z))))) )
176
+ ).
177
+
178
+ Definition enqueue_return_wit_1_split_goal_spatial :=
179
+ forall (x_pre: Z) (q_pre: Z) (l: (@list Z)) (qhead: Z) (qtail: Z) (retval: Z) (PreH1 : (x_pre <= INT_MAX)) (PreH2 : (x_pre >= INT_MIN)) (PreH3 : (qhead = 0)) (PreH4 : (retval <> 0)) ,
180
+ ((&((retval) # "list" ->ₛ "next")) # Ptr |-> 0)
181
+ ** ((&((retval) # "list" ->ₛ "prev")) # Ptr |-> 0)
182
+ ** ((&((retval) # "list" ->ₛ "data")) # Int |-> x_pre)
183
+ ** (dllseg qhead 0 0 qtail l )
184
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> retval)
185
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> retval)
186
+ |--
187
+ (store_queue q_pre (app (l) ((cons (x_pre) ((@nil Z))))) )
188
+ .
189
+
190
+ Definition enqueue_return_wit_2 :=
191
+ (
192
+ forall (x_pre: Z) (q_pre: Z) (l: (@list Z)) (l0: (@list Z)) (qtailv: Z) (qtail: Z) (qhead: Z) (qtailnext: Z) (qtailprev: Z) (p: Z) (PreH1 : (p <> 0)) (PreH2 : (qtail <> 0)) (PreH3 : (qhead <> 0)) (PreH4 : (l = (app (l0) ((cons (qtailv) ((@nil Z))))))) (PreH5 : (qtailnext = 0)) ,
193
+ (dllseg qhead qtail 0 qtailprev l0 )
194
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> p)
195
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qhead)
196
+ ** ((&((qtail) # "list" ->ₛ "next")) # Ptr |-> p)
197
+ ** ((&((qtail) # "list" ->ₛ "prev")) # Ptr |-> qtailprev)
198
+ ** ((&((qtail) # "list" ->ₛ "data")) # Int |-> qtailv)
199
+ ** ((&((p) # "list" ->ₛ "next")) # Ptr |-> 0)
200
+ ** ((&((p) # "list" ->ₛ "prev")) # Ptr |-> qtail)
201
+ ** ((&((p) # "list" ->ₛ "data")) # Int |-> x_pre)
202
+ |--
203
+ (store_queue q_pre (app (l) ((cons (x_pre) ((@nil Z))))) )
204
+ ) \/
205
+ (
206
+ forall (x_pre: Z) (q_pre: Z) (l: (@list Z)) (l0: (@list Z)) (qtailv: Z) (qtail: Z) (qhead: Z) (qtailnext: Z) (qtailprev: Z) (p: Z) (PreH1 : (x_pre <= INT_MAX)) (PreH2 : (qtailv <= INT_MAX)) (PreH3 : (x_pre >= INT_MIN)) (PreH4 : (qtailv >= INT_MIN)) (PreH5 : (p <> 0)) (PreH6 : (qtail <> 0)) (PreH7 : (qhead <> 0)) (PreH8 : (l = (app (l0) ((cons (qtailv) ((@nil Z))))))) (PreH9 : (qtailnext = 0)) ,
207
+ (dllseg qhead qtail 0 qtailprev l0 )
208
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> p)
209
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qhead)
210
+ ** ((&((qtail) # "list" ->ₛ "next")) # Ptr |-> p)
211
+ ** ((&((qtail) # "list" ->ₛ "prev")) # Ptr |-> qtailprev)
212
+ ** ((&((qtail) # "list" ->ₛ "data")) # Int |-> qtailv)
213
+ ** ((&((p) # "list" ->ₛ "next")) # Ptr |-> 0)
214
+ ** ((&((p) # "list" ->ₛ "prev")) # Ptr |-> qtail)
215
+ ** ((&((p) # "list" ->ₛ "data")) # Int |-> x_pre)
216
+ |--
217
+ (store_queue q_pre (app (l) ((cons (x_pre) ((@nil Z))))) )
218
+ ).
219
+
220
+ Definition enqueue_return_wit_2_split_goal_spatial :=
221
+ forall (x_pre: Z) (q_pre: Z) (l: (@list Z)) (l0: (@list Z)) (qtailv: Z) (qtail: Z) (qhead: Z) (qtailnext: Z) (qtailprev: Z) (p: Z) (PreH1 : (x_pre <= INT_MAX)) (PreH2 : (qtailv <= INT_MAX)) (PreH3 : (x_pre >= INT_MIN)) (PreH4 : (qtailv >= INT_MIN)) (PreH5 : (p <> 0)) (PreH6 : (qtail <> 0)) (PreH7 : (qhead <> 0)) (PreH8 : (l = (app (l0) ((cons (qtailv) ((@nil Z))))))) (PreH9 : (qtailnext = 0)) ,
222
+ (dllseg qhead qtail 0 qtailprev l0 )
223
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> p)
224
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qhead)
225
+ ** ((&((qtail) # "list" ->ₛ "next")) # Ptr |-> p)
226
+ ** ((&((qtail) # "list" ->ₛ "prev")) # Ptr |-> qtailprev)
227
+ ** ((&((qtail) # "list" ->ₛ "data")) # Int |-> qtailv)
228
+ ** ((&((p) # "list" ->ₛ "next")) # Ptr |-> 0)
229
+ ** ((&((p) # "list" ->ₛ "prev")) # Ptr |-> qtail)
230
+ ** ((&((p) # "list" ->ₛ "data")) # Int |-> x_pre)
231
+ |--
232
+ (store_queue q_pre (app (l) ((cons (x_pre) ((@nil Z))))) )
233
+ .
234
+
235
+ Definition enqueue_partial_solve_wit_1 :=
236
+ forall (q_pre: Z) (l: (@list Z)) (qhead: Z) (qtail: Z) ,
237
+ (dllseg qhead 0 0 qtail l )
238
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qhead)
239
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> qtail)
240
+ |--
241
+ (dllseg qhead 0 0 qtail l )
242
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qhead)
243
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> qtail)
244
+ .
245
+
246
+ (*----- Function dequeue -----*)
247
+
248
+ Definition dequeue_safety_wit_1 :=
249
+ forall (q_pre: Z) (l: (@list Z)) (x: Z) (qhead: Z) (qtail: Z) (qheadnext: Z) (PreH1 : (qhead <> 0)) ,
250
+ ((( &( "x0" ) )) # Int |-> x)
251
+ ** ((( &( "p" ) )) # Ptr |-> qhead)
252
+ ** ((( &( "q" ) )) # Ptr |-> q_pre)
253
+ ** (dllseg qheadnext 0 qhead qtail l )
254
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qheadnext)
255
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> qtail)
256
+ |--
257
+ “ (0 <= INT_MAX) ”
258
+ && “ ((INT_MIN) <= 0) ”
259
+ .
260
+
261
+ Definition dequeue_safety_wit_2 :=
262
+ forall (q_pre: Z) (l: (@list Z)) (x: Z) (qhead: Z) (qtail: Z) (qheadnext: Z) (PreH1 : (qheadnext = 0)) (PreH2 : (qhead <> 0)) ,
263
+ ((( &( "x0" ) )) # Int |-> x)
264
+ ** ((( &( "p" ) )) # Ptr |-> qhead)
265
+ ** ((( &( "q" ) )) # Ptr |-> q_pre)
266
+ ** (dllseg qheadnext 0 qhead qtail l )
267
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qheadnext)
268
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> qtail)
269
+ |--
270
+ “ (0 <= INT_MAX) ”
271
+ && “ ((INT_MIN) <= 0) ”
272
+ .
273
+
274
+ Definition dequeue_safety_wit_3 :=
275
+ forall (q_pre: Z) (l: (@list Z)) (x: Z) (qhead: Z) (qtail: Z) (headv: Z) (qheadnext: Z) (l0: (@list Z)) (p: Z) (PreH1 : (qhead <> 0)) (PreH2 : (l = (cons (headv) (l0)))) ,
276
+ ((( &( "q" ) )) # Ptr |-> q_pre)
277
+ ** ((( &( "x0" ) )) # Int |-> x)
278
+ ** ((( &( "p" ) )) # Ptr |-> p)
279
+ ** ((&((qhead) # "list" ->ₛ "prev")) # Ptr |-> p)
280
+ ** ((&((qhead) # "list" ->ₛ "data")) # Int |-> headv)
281
+ ** ((&((qhead) # "list" ->ₛ "next")) # Ptr |-> qheadnext)
282
+ ** (dllseg qheadnext 0 qhead qtail l0 )
283
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qhead)
284
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> qtail)
285
+ |--
286
+ “ (0 <= INT_MAX) ”
287
+ && “ ((INT_MIN) <= 0) ”
288
+ .
289
+
290
+ Definition dequeue_entail_wit_1 :=
291
+ (
292
+ forall (q_pre: Z) (l: (@list Z)) (x: Z) ,
293
+ (store_queue q_pre (cons (x) (l)) )
294
+ |--
295
+ EX (qtail: Z) (qheadnext: Z) (qhead: Z) ,
296
+ “ (qhead <> 0) ”
297
+ && ((&((qhead) # "list" ->ₛ "prev")) # Ptr |-> 0)
298
+ ** ((&((qhead) # "list" ->ₛ "data")) # Int |-> x)
299
+ ** ((&((qhead) # "list" ->ₛ "next")) # Ptr |-> qheadnext)
300
+ ** (dllseg qheadnext 0 qhead qtail l )
301
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qhead)
302
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> qtail)
303
+ ) \/
304
+ (
305
+ forall (q_pre: Z) (l: (@list Z)) (x: Z) ,
306
+ (store_queue q_pre (cons (x) (l)) )
307
+ |--
308
+ EX (qtail: Z) (qheadnext: Z) (qhead: Z) ,
309
+ “ (qhead <> 0) ”
310
+ && ((&((qhead) # "list" ->ₛ "prev")) # Ptr |-> 0)
311
+ ** ((&((qhead) # "list" ->ₛ "data")) # Int |-> x)
312
+ ** ((&((qhead) # "list" ->ₛ "next")) # Ptr |-> qheadnext)
313
+ ** (dllseg qheadnext 0 qhead qtail l )
314
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qhead)
315
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> qtail)
316
+ ).
317
+
318
+ Definition dequeue_entail_wit_2 :=
319
+ (
320
+ forall (q_pre: Z) (l: (@list Z)) (qhead: Z) (qtail_2: Z) (qheadnext_2: Z) (PreH1 : (qheadnext_2 <> 0)) (PreH2 : (qhead <> 0)) ,
321
+ (dllseg qheadnext_2 0 qhead qtail_2 l )
322
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qheadnext_2)
323
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> qtail_2)
324
+ |--
325
+ EX (qtail: Z) (qheadnext: Z) (headv: Z) (l0: (@list Z)) (qhead_2: Z) ,
326
+ “ (qhead_2 <> 0) ”
327
+ && “ (l = (cons (headv) (l0))) ”
328
+ && ((&((qhead_2) # "list" ->ₛ "prev")) # Ptr |-> qhead)
329
+ ** ((&((qhead_2) # "list" ->ₛ "data")) # Int |-> headv)
330
+ ** ((&((qhead_2) # "list" ->ₛ "next")) # Ptr |-> qheadnext)
331
+ ** (dllseg qheadnext 0 qhead_2 qtail l0 )
332
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qhead_2)
333
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> qtail)
334
+ ) \/
335
+ (
336
+ forall (l: (@list Z)) (qhead: Z) (qtail_2: Z) (qheadnext_2: Z) (PreH1 : (qheadnext_2 <> 0)) (PreH2 : (qhead <> 0)) ,
337
+ (dllseg qheadnext_2 0 qhead qtail_2 l )
338
+ |--
339
+ EX (qheadnext: Z) (headv: Z) (l0: (@list Z)) ,
340
+ “ (qheadnext_2 <> 0) ”
341
+ && “ (l = (cons (headv) (l0))) ”
342
+ && ((&((qheadnext_2) # "list" ->ₛ "prev")) # Ptr |-> qhead)
343
+ ** ((&((qheadnext_2) # "list" ->ₛ "data")) # Int |-> headv)
344
+ ** ((&((qheadnext_2) # "list" ->ₛ "next")) # Ptr |-> qheadnext)
345
+ ** (dllseg qheadnext 0 qheadnext_2 qtail_2 l0 )
346
+ ).
347
+
348
+ Definition dequeue_return_wit_1 :=
349
+ (
350
+ forall (q_pre: Z) (l: (@list Z)) (x: Z) (qhead: Z) (qtail: Z) (qheadnext: Z) (PreH1 : (qheadnext = 0)) (PreH2 : (qhead <> 0)) ,
351
+ (dllseg qheadnext 0 qhead qtail l )
352
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qheadnext)
353
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> 0)
354
+ |--
355
+ “ (x = x) ”
356
+ && (store_queue q_pre l )
357
+ ) \/
358
+ (
359
+ forall (q_pre: Z) (l: (@list Z)) (qhead: Z) (qtail: Z) (qheadnext: Z) (PreH1 : (qheadnext = 0)) (PreH2 : (qhead <> 0)) ,
360
+ (dllseg qheadnext 0 qhead qtail l )
361
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qheadnext)
362
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> 0)
363
+ |--
364
+ (store_queue q_pre l )
365
+ ).
366
+
367
+ Definition dequeue_return_wit_1_split_goal_spatial :=
368
+ forall (q_pre: Z) (l: (@list Z)) (qhead: Z) (qtail: Z) (qheadnext: Z) (PreH1 : (qheadnext = 0)) (PreH2 : (qhead <> 0)) ,
369
+ (dllseg qheadnext 0 qhead qtail l )
370
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qheadnext)
371
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> 0)
372
+ |--
373
+ (store_queue q_pre l )
374
+ .
375
+
376
+ Definition dequeue_return_wit_2 :=
377
+ (
378
+ forall (q_pre: Z) (l: (@list Z)) (x: Z) (qhead: Z) (qtail: Z) (headv: Z) (qheadnext: Z) (l0: (@list Z)) (PreH1 : (qhead <> 0)) (PreH2 : (l = (cons (headv) (l0)))) ,
379
+ ((&((qhead) # "list" ->ₛ "prev")) # Ptr |-> 0)
380
+ ** ((&((qhead) # "list" ->ₛ "data")) # Int |-> headv)
381
+ ** ((&((qhead) # "list" ->ₛ "next")) # Ptr |-> qheadnext)
382
+ ** (dllseg qheadnext 0 qhead qtail l0 )
383
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qhead)
384
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> qtail)
385
+ |--
386
+ “ (x = x) ”
387
+ && (store_queue q_pre l )
388
+ ) \/
389
+ (
390
+ forall (q_pre: Z) (l: (@list Z)) (qhead: Z) (qtail: Z) (headv: Z) (qheadnext: Z) (l0: (@list Z)) (PreH1 : (headv <= INT_MAX)) (PreH2 : (headv >= INT_MIN)) (PreH3 : (qhead <> 0)) (PreH4 : (l = (cons (headv) (l0)))) ,
391
+ ((&((qhead) # "list" ->ₛ "prev")) # Ptr |-> 0)
392
+ ** ((&((qhead) # "list" ->ₛ "data")) # Int |-> headv)
393
+ ** ((&((qhead) # "list" ->ₛ "next")) # Ptr |-> qheadnext)
394
+ ** (dllseg qheadnext 0 qhead qtail l0 )
395
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qhead)
396
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> qtail)
397
+ |--
398
+ (store_queue q_pre l )
399
+ ).
400
+
401
+ Definition dequeue_return_wit_2_split_goal_spatial :=
402
+ forall (q_pre: Z) (l: (@list Z)) (qhead: Z) (qtail: Z) (headv: Z) (qheadnext: Z) (l0: (@list Z)) (PreH1 : (headv <= INT_MAX)) (PreH2 : (headv >= INT_MIN)) (PreH3 : (qhead <> 0)) (PreH4 : (l = (cons (headv) (l0)))) ,
403
+ ((&((qhead) # "list" ->ₛ "prev")) # Ptr |-> 0)
404
+ ** ((&((qhead) # "list" ->ₛ "data")) # Int |-> headv)
405
+ ** ((&((qhead) # "list" ->ₛ "next")) # Ptr |-> qheadnext)
406
+ ** (dllseg qheadnext 0 qhead qtail l0 )
407
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qhead)
408
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> qtail)
409
+ |--
410
+ (store_queue q_pre l )
411
+ .
412
+
413
+ Definition dequeue_partial_solve_wit_1 :=
414
+ forall (q_pre: Z) (l: (@list Z)) (x: Z) (qhead: Z) (qtail: Z) (qheadnext: Z) (PreH1 : (qhead <> 0)) ,
415
+ ((&((qhead) # "list" ->ₛ "prev")) # Ptr |-> 0)
416
+ ** ((&((qhead) # "list" ->ₛ "data")) # Int |-> x)
417
+ ** ((&((qhead) # "list" ->ₛ "next")) # Ptr |-> qheadnext)
418
+ ** (dllseg qheadnext 0 qhead qtail l )
419
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qheadnext)
420
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> qtail)
421
+ |--
422
+ “ (qhead <> 0) ”
423
+ && ((&((qhead) # "list" ->ₛ "next")) # Ptr |-> qheadnext)
424
+ ** ((&((qhead) # "list" ->ₛ "prev")) # Ptr |-> 0)
425
+ ** ((&((qhead) # "list" ->ₛ "data")) # Int |-> x)
426
+ ** (dllseg qheadnext 0 qhead qtail l )
427
+ ** ((&((q_pre) # "queue" ->ₛ "head")) # Ptr |-> qheadnext)
428
+ ** ((&((q_pre) # "queue" ->ₛ "tail")) # Ptr |-> qtail)
429
+ .
430
+
431
+ Module Type VC_Correct.
432
+
433
+ Include dll_queue_store_Strategy_Correct.
434
+
435
+ Axiom proof_of_enqueue_safety_wit_1 : enqueue_safety_wit_1.
436
+ Axiom proof_of_enqueue_safety_wit_2 : enqueue_safety_wit_2.
437
+ Axiom proof_of_enqueue_safety_wit_3 : enqueue_safety_wit_3.
438
+ Axiom proof_of_enqueue_safety_wit_4 : enqueue_safety_wit_4.
439
+ Axiom proof_of_enqueue_entail_wit_1 : enqueue_entail_wit_1.
440
+ Axiom proof_of_enqueue_entail_wit_2 : enqueue_entail_wit_2.
441
+ Axiom proof_of_enqueue_return_wit_1 : enqueue_return_wit_1.
442
+ Axiom proof_of_enqueue_return_wit_2 : enqueue_return_wit_2.
443
+ Axiom proof_of_enqueue_partial_solve_wit_1 : enqueue_partial_solve_wit_1.
444
+ Axiom proof_of_dequeue_safety_wit_1 : dequeue_safety_wit_1.
445
+ Axiom proof_of_dequeue_safety_wit_2 : dequeue_safety_wit_2.
446
+ Axiom proof_of_dequeue_safety_wit_3 : dequeue_safety_wit_3.
447
+ Axiom proof_of_dequeue_entail_wit_1 : dequeue_entail_wit_1.
448
+ Axiom proof_of_dequeue_entail_wit_2 : dequeue_entail_wit_2.
449
+ Axiom proof_of_dequeue_return_wit_1 : dequeue_return_wit_1.
450
+ Axiom proof_of_dequeue_return_wit_2 : dequeue_return_wit_2.
451
+ Axiom proof_of_dequeue_partial_solve_wit_1 : dequeue_partial_solve_wit_1.
452
+
453
+ End VC_Correct.
benchmarks/Data_structures/dll_queue/rocq/groundtruth/dll_queue_goal_check.v ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ From PVbench.Data_structures.dll_queue.rocq.groundtruth Require Import dll_queue_goal dll_queue_proof_auto dll_queue_proof_manual.
2
+
3
+ Module VC_Correctness : VC_Correct.
4
+ Include dll_queue_store_strategy_proof.
5
+ Include dll_queue_proof_auto.
6
+ Include dll_queue_proof_manual.
7
+ End VC_Correctness.