Revision a7062da6
Added by LĂ©lio Brun over 3 years ago
src/backends/Horn/horn_backend_collecting_sem.ml | ||
---|---|---|
14 | 14 |
|
15 | 15 |
This is a modified version that handle reset *) |
16 | 16 |
|
17 |
open Utils |
|
17 | 18 |
open Format |
18 | 19 |
open Lustre_types |
19 | 20 |
open Machine_code_types |
... | ... | |
45 | 46 |
in |
46 | 47 |
|
47 | 48 |
fprintf fmt "(declare-rel MAIN (%a))@." |
48 |
(Utils.fprintf_list ~sep:" " pp_type)
|
|
49 |
(pp_print_list pp_type)
|
|
49 | 50 |
(List.map (fun v -> v.var_type) main_memory_next); |
50 | 51 |
|
51 | 52 |
(* Init case *) |
... | ... | |
59 | 60 |
fprintf fmt "@[<v 2>(rule (=> @ (and @[<v 0>"; |
60 | 61 |
fprintf fmt "INIT_STATE@ "; |
61 | 62 |
fprintf fmt "(@[<v 0>%a %a@])" step_name node |
62 |
(Utils.fprintf_list ~sep:" " (pp_horn_var machine))
|
|
63 |
(pp_print_list (pp_horn_var machine))
|
|
63 | 64 |
(step_vars_m_x machines machine); |
64 | 65 |
fprintf fmt "@]@ )@ "; |
65 | 66 |
fprintf fmt "(MAIN %a)@]@.))@.@." |
66 |
(Utils.fprintf_list ~sep:" " (pp_horn_var machine))
|
|
67 |
(pp_print_list (pp_horn_var machine))
|
|
67 | 68 |
main_memory_next) |
68 | 69 |
else |
69 | 70 |
let reset_name, step_name = pp_machine_reset_name, pp_machine_step_name in |
... | ... | |
73 | 74 |
fprintf fmt "@[<v 2>(rule (=> @ (and @[<v 0>"; |
74 | 75 |
fprintf fmt "INIT_STATE@ "; |
75 | 76 |
fprintf fmt "(@[<v 0>%a %a@])@ " reset_name node |
76 |
(Utils.fprintf_list ~sep:" " (pp_horn_var machine))
|
|
77 |
(pp_print_list (pp_horn_var machine))
|
|
77 | 78 |
(reset_vars machines machine); |
78 | 79 |
fprintf fmt "(@[<v 0>%a %a@])" step_name node |
79 |
(Utils.fprintf_list ~sep:" " (pp_horn_var machine))
|
|
80 |
(pp_print_list (pp_horn_var machine))
|
|
80 | 81 |
(step_vars_m_x machines machine); |
81 | 82 |
|
82 | 83 |
fprintf fmt "@]@ )@ "; |
83 | 84 |
fprintf fmt "(MAIN %a)@]@.))@.@." |
84 |
(Utils.fprintf_list ~sep:" " (pp_horn_var machine))
|
|
85 |
(pp_print_list (pp_horn_var machine))
|
|
85 | 86 |
main_memory_next |
86 | 87 |
in |
87 | 88 |
|
... | ... | |
91 | 92 |
in |
92 | 93 |
|
93 | 94 |
fprintf fmt "; Inductive def@."; |
94 |
(Utils.fprintf_list ~sep:" " (fun fmt v -> fprintf fmt "%a@." pp_decl_var v))
|
|
95 |
(pp_print_list (fun fmt v -> fprintf fmt "%a@." pp_decl_var v))
|
|
95 | 96 |
fmt main_output_dummy; |
96 | 97 |
fprintf fmt |
97 | 98 |
"@[<v 2>(rule (=> @ (and @[<v 0>(MAIN %a)@ (@[<v 0>%a %a@])@]@ )@ (MAIN \ |
98 | 99 |
%a)@]@.))@.@." |
99 |
(Utils.fprintf_list ~sep:" " (pp_horn_var machine))
|
|
100 |
(pp_print_list (pp_horn_var machine))
|
|
100 | 101 |
main_memory_current step_name node |
101 |
(Utils.fprintf_list ~sep:" " (pp_horn_var machine))
|
|
102 |
(pp_print_list (pp_horn_var machine))
|
|
102 | 103 |
(step_vars machines machine) |
103 |
(Utils.fprintf_list ~sep:" " (pp_horn_var machine))
|
|
104 |
(pp_print_list (pp_horn_var machine))
|
|
104 | 105 |
main_memory_next |
105 | 106 |
|
106 | 107 |
let check_prop machines fmt machine = |
... | ... | |
115 | 116 |
fprintf fmt "@[<v 2>(rule (=> @ (and @[<v 0>(not %a)@ (MAIN %a)@])@ ERR))@." |
116 | 117 |
(pp_conj (pp_horn_var machine)) |
117 | 118 |
main_output |
118 |
(Utils.fprintf_list ~sep:" " (pp_horn_var machine))
|
|
119 |
(pp_print_list (pp_horn_var machine))
|
|
119 | 120 |
main_memory_next; |
120 | 121 |
if !Options.horn_query then fprintf fmt "(query ERR)@." |
121 | 122 |
|
... | ... | |
157 | 158 |
in |
158 | 159 |
|
159 | 160 |
fprintf fmt "(declare-rel CEX (Int %a))@.@." |
160 |
(Utils.fprintf_list ~sep:" " pp_type)
|
|
161 |
(pp_print_list pp_type)
|
|
161 | 162 |
(List.map (fun v -> v.var_type) cex_memory_next); |
162 | 163 |
|
163 | 164 |
fprintf fmt "; Initial set: Reset(c,m) + One Step(m,x) @."; |
... | ... | |
166 | 167 |
fprintf fmt "@[<v 2>(rule (=> @ (and @[<v 0>"; |
167 | 168 |
fprintf fmt "INIT_STATE_CEX@ "; |
168 | 169 |
fprintf fmt "(@[<v 0>%a %a@])@ " reset_name node |
169 |
(Utils.fprintf_list ~sep:" " (pp_horn_var machine))
|
|
170 |
(pp_print_list (pp_horn_var machine))
|
|
170 | 171 |
(reset_vars machines machine); |
171 | 172 |
fprintf fmt "(@[<v 0>%a %a@])" step_name node |
172 |
(Utils.fprintf_list ~sep:" " (pp_horn_var machine))
|
|
173 |
(pp_print_list (pp_horn_var machine))
|
|
173 | 174 |
(step_vars_m_x machines machine); |
174 | 175 |
|
175 | 176 |
fprintf fmt "@]@ )@ "; |
176 | 177 |
fprintf fmt "(CEX 0 %a)@]@.))@.@." |
177 |
(Utils.fprintf_list ~sep:" " (pp_horn_var machine))
|
|
178 |
(pp_print_list (pp_horn_var machine))
|
|
178 | 179 |
cex_memory_next; |
179 | 180 |
|
180 | 181 |
fprintf fmt "; Inductive def@."; |
181 | 182 |
(* Declare dummy inputs. Outputs should have been declared previously with |
182 | 183 |
collecting sem *) |
183 |
(Utils.fprintf_list ~sep:" " (fun fmt v -> fprintf fmt "%a@." pp_decl_var v))
|
|
184 |
(pp_print_list (fun fmt v -> fprintf fmt "%a@." pp_decl_var v))
|
|
184 | 185 |
fmt cex_input_dummy; |
185 | 186 |
fprintf fmt "(declare-var cexcpt Int)@."; |
186 | 187 |
fprintf fmt |
187 | 188 |
"@[<v 2>(rule (=> @ (and @[<v 0>(CEX cexcpt %a)@ (@[<v 0>%a %a@])@]@ )@ \ |
188 | 189 |
(CEX (+ 1 cexcpt) %a)@]@.))@.@." |
189 |
(Utils.fprintf_list ~sep:" " (pp_horn_var machine))
|
|
190 |
(pp_print_list (pp_horn_var machine))
|
|
190 | 191 |
cex_memory_current step_name node |
191 |
(Utils.fprintf_list ~sep:" " (pp_horn_var machine))
|
|
192 |
(pp_print_list (pp_horn_var machine))
|
|
192 | 193 |
(step_vars machines machine) |
193 |
(Utils.fprintf_list ~sep:" " (pp_horn_var machine))
|
|
194 |
(pp_print_list (pp_horn_var machine))
|
|
194 | 195 |
cex_memory_next |
195 | 196 |
|
196 | 197 |
let get_cex machines fmt machine = |
... | ... | |
211 | 212 |
"@[<v 2>(rule (=> @ (and @[<v 0>(not %a)@ (CEX cexcpt %a)@])@ CEXTRACE))@." |
212 | 213 |
(pp_conj (pp_horn_var machine)) |
213 | 214 |
cex_output |
214 |
(Utils.fprintf_list ~sep:" " (pp_horn_var machine))
|
|
215 |
(pp_print_list (pp_horn_var machine))
|
|
215 | 216 |
cex_memory_next; |
216 | 217 |
fprintf fmt "(query CEXTRACE)@." |
217 | 218 |
|
Also available in: Unified diff
another step towards refactoring