Theory IsaSAT_Initialisation_State_LLVM
theory IsaSAT_Initialisation_State_LLVM
imports IsaSAT_Initialisation Tuple15_LLVM IsaSAT_Setup_LLVM IsaSAT_Mark_LLVM
IsaSAT_VMTF_LLVM Watched_Literals.Watched_Literals_Watch_List_Initialisation
IsaSAT_Mark_LLVM
begin
hide_const (open) NEMonad.RETURN NEMonad.ASSERT
type_synonym bump_heuristics_init_assn = ‹
((32 word ptr × 32 word ptr × 32 word ptr × 32 word ptr × 64 word ptr × 32 word) × 64 word,
(64 word × 32 word × 32 word) ptr × 64 word × 32 word × 32 word × 32 word,
1 word, (64 word × 64 word × 32 word ptr) × 1 word ptr) tuple4›
type_synonym vmtf_init = ‹(nat, nat) vmtf_node list × nat × nat option × nat option × nat option›
definition (in -) vmtf_init_assn :: ‹vmtf_init ⇒ _ ⇒ llvm_amemory ⇒ bool› where
‹vmtf_init_assn ≡ (array_assn vmtf_node_assn ×⇩a uint64_nat_assn ×⇩a
atom.option_assn ×⇩a atom.option_assn ×⇩a atom.option_assn)›
type_synonym bump_heuristics_init = ‹((nat,nat)acids, vmtf_init, bool, nat list × bool list) tuple4›
abbreviation Bump_Heuristics_Init :: ‹_ ⇒ _ ⇒ _ ⇒ _ ⇒ bump_heuristics_init› where
‹Bump_Heuristics_Init a b c d ≡ Tuple4 a b c d›
definition heuristic_bump_init_assn :: ‹bump_heuristics_init ⇒ bump_heuristics_init_assn ⇒ _› where
‹heuristic_bump_init_assn = tuple4_assn acids_assn2 vmtf_init_assn bool1_assn distinct_atoms_assn›
definition bottom_atom where
‹bottom_atom = 0›
definition bottom_init_vmtf :: ‹vmtf_init› where
‹bottom_init_vmtf = (replicate 0 (VMTF_Node 0 None None), 0, None, None, None)›
where
‹extract_bump_stable = tuple4_state_ops.remove_a empty_acids›
where
‹extract_bump_focused = tuple4_state_ops.remove_b bottom_init_vmtf›
lemma [sepref_fr_rules]: ‹(uncurry0 (Mreturn 0), uncurry0 (RETURN bottom_atom)) ∈ unit_assn⇧k →⇩a atom_assn›
unfolding bottom_atom_def
apply sepref_to_hoare
apply vcg
apply (auto simp: atom_rel_def unat_rel_def unat.rel_def br_def entails_def ENTAILS_def)
by (smt (verit, best) pure_true_conv rel_simps(51) sep.add_0)
sepref_def bottom_init_vmtf_code
is ‹uncurry0 (RETURN bottom_init_vmtf)›
:: ‹unit_assn⇧k →⇩a vmtf_init_assn›
unfolding bottom_init_vmtf_def
apply (rewrite in ‹((⌑, _, _, _, _))› array_fold_custom_replicate)
unfolding
atom.fold_option array_fold_custom_replicate vmtf_init_assn_def
al_fold_custom_empty[where 'l=64]
apply (rewrite at 0 in ‹VMTF_Node ⌑› unat_const_fold[where 'a=64])
apply (rewrite at ‹(_, ⌑, _, _)› unat_const_fold[where 'a=64])
apply (annot_snat_const ‹TYPE(64)›)
by sepref
schematic_goal free_vmtf_remove_assn[sepref_frame_free_rules]: ‹MK_FREE vmtf_init_assn ?a›
unfolding vmtf_init_assn_def
by synthesize_free
sepref_def free_vmtf_remove
is ‹mop_free›
:: ‹vmtf_init_assn⇧d →⇩a unit_assn›
by sepref
where
‹extract_bump_is_focused = tuple4_state_ops.remove_c False›
definition bottom_atms_hash where
‹bottom_atms_hash = ([], replicate 0 False)›
where
‹extract_bump_atms_to_bump = tuple4_state_ops.remove_d bottom_atms_hash›
sepref_def bottom_atms_hash_code
is ‹uncurry0 (RETURN bottom_atms_hash)›
:: ‹unit_assn⇧k →⇩a distinct_atoms_assn›
unfolding bottom_atms_hash_def
unfolding
atom.fold_option array_fold_custom_replicate
al_fold_custom_empty[where 'l=64]
apply (rewrite at ‹(⌑, _)› annotate_assn[where A =‹al_assn atom_assn›])
apply (rewrite at ‹(_, ⌑)› annotate_assn[where A =‹atoms_hash_assn›])
apply (annot_snat_const ‹TYPE(64)›)
by sepref
lemma free_vmtf_init_assn_assn2: ‹MK_FREE vmtf_init_assn free_vmtf_remove›
unfolding free_vmtf_remove_def
by (rule back_subst[of ‹MK_FREE vmtf_init_assn›, OF free_vmtf_remove_assn])
(auto intro!: ext)
global_interpretation Bump_Heur_Init: tuple4_state where
a_assn = acids_assn2 and
b_assn = vmtf_init_assn and
c_assn = bool1_assn and
d_assn = distinct_atoms_assn and
a_default = empty_acids and
a = ‹empty_acids_code› and
a_free = free_acids and
b_default = bottom_init_vmtf and
b = ‹bottom_init_vmtf_code› and
b_free = free_vmtf_remove and
c_default = False and
c = ‹bottom_focused› and
c_free = free_focused and
d_default = ‹bottom_atms_hash› and
d = ‹bottom_atms_hash_code› and
d_free = ‹free_atms_hash_code›
rewrites
‹Bump_Heur_Init.tuple4_int_assn ≡ heuristic_bump_init_assn›and
‹Bump_Heur_Init.remove_a ≡ extract_bump_stable› and
‹Bump_Heur_Init.remove_b ≡ extract_bump_focused› and
‹Bump_Heur_Init.remove_c ≡ extract_bump_is_focused› and
‹Bump_Heur_Init.remove_d ≡ extract_bump_atms_to_bump›
apply unfold_locales
apply (rule bottom_init_vmtf_code.refine bottom_focused.refine free_acids_assn2
bottom_atms_hash_code.refine free_vmtf_init_assn_assn2 free_focused_assn2
free_distinct_atoms_assn2 empty_acids_code.refine free_acids_assn2')+
subgoal unfolding heuristic_bump_init_assn_def tuple4_state_ops.tuple4_int_assn_def by auto
subgoal unfolding extract_bump_stable_def by auto
subgoal unfolding extract_bump_focused_def by auto
subgoal unfolding extract_bump_is_focused_def by auto
subgoal unfolding extract_bump_atms_to_bump_def by auto
done
lemmas [unfolded Tuple4_LLVM.inline_direct_return_node_case, llvm_code] =
Bump_Heur_Init.code_rules[unfolded Mreturn_comp_Tuple4]
lemmas [sepref_fr_rules] =
Bump_Heur_Init.separation_rules
type_synonym (in -)twl_st_wll_trail_init =
‹(trail_pol_fast_assn, arena_assn, option_lookup_clause_assn,
64 word, watched_wl_uint32, bump_heuristics_init_assn, phase_saver_assn,
32 word, cach_refinement_l_assn, lbd_assn, vdom_fast_assn, vdom_fast_assn, 1 word,
(64 word × 64 word × 64 word × 64 word × 64 word), mark_assn) tuple15›
definition isasat_init_assn
:: ‹twl_st_wl_heur_init ⇒ twl_st_wll_trail_init ⇒ assn›
where
‹isasat_init_assn = tuple15_assn
trail_pol_fast_assn arena_fast_assn
conflict_option_rel_assn
sint64_nat_assn
watchlist_fast_assn
heuristic_bump_init_assn phase_saver_assn
uint32_nat_assn
cach_refinement_l_assn
lbd_assn
vdom_fast_assn
vdom_fast_assn
bool1_assn lcount_assn
marked_struct_assn›
definition bottom_vdom :: ‹_› where
‹bottom_vdom = []›
sepref_def bottom_vdom_code
is ‹uncurry0 (RETURN bottom_vdom)›
:: ‹unit_assn⇧k →⇩a vdom_fast_assn›
supply [[goals_limit=1]]
unfolding bottom_vdom_def
unfolding al_fold_custom_empty[where 'l=64]
by sepref
sepref_def free_vdom
is ‹mop_free›
:: ‹vdom_fast_assn⇧d →⇩a unit_assn›
by sepref
schematic_goal free_vdom[sepref_frame_free_rules]: ‹MK_FREE vdom_fast_assn ?a›
by synthesize_free
lemma free_vdom2: ‹MK_FREE vdom_fast_assn free_vdom›
unfolding free_arena_fast_def
by (rule back_subst[of ‹MK_FREE vdom_fast_assn›, OF free_vdom])
(auto intro!: ext simp: free_vdom_def)
sepref_def free_phase_saver
is ‹mop_free›
:: ‹phase_saver_assn⇧d →⇩a unit_assn›
by sepref
definition bottom_phase_saver :: ‹phase_saver› where
‹bottom_phase_saver = op_larray_custom_replicate 0 False›
sepref_def bottom_phase_saver_code
is ‹uncurry0 (RETURN bottom_phase_saver)›
:: ‹unit_assn⇧k →⇩a phase_saver_assn›
supply [[goals_limit=1]]
unfolding bottom_phase_saver_def
unfolding larray_fold_custom_replicate
apply (annot_snat_const ‹TYPE(64)›)
by sepref
schematic_goal free_phase_saver[sepref_frame_free_rules]: ‹MK_FREE phase_saver_assn ?a›
by synthesize_free
lemma free_phase_saver2: ‹MK_FREE phase_saver_assn free_phase_saver›
unfolding free_arena_fast_def
by (rule back_subst[of ‹MK_FREE phase_saver_assn›, OF free_phase_saver])
(auto intro!: ext simp: free_phase_saver_def)
definition bottom_init_bump :: ‹bump_heuristics_init› where
‹bottom_init_bump = Bump_Heuristics_Init empty_acids bottom_init_vmtf False bottom_atms_hash›
schematic_goal free_vmtf_init_assn[sepref_frame_free_rules]: ‹MK_FREE heuristic_bump_init_assn ?a›
unfolding heuristic_bump_init_assn_def
by synthesize_free
sepref_def free_bottom_init_bump_code
is ‹mop_free›
:: ‹heuristic_bump_init_assn⇧d →⇩a unit_assn›
by sepref
lemma free_vmtf_remove2: ‹MK_FREE heuristic_bump_init_assn free_bottom_init_bump_code›
unfolding free_bottom_init_bump_code_def
apply (rule back_subst[of ‹MK_FREE heuristic_bump_init_assn›, OF free_vmtf_init_assn])
apply (auto intro!: ext simp: M_monad_laws)
by (metis M_monad_laws(1))
definition op_empty_array where
‹op_empty_array ≡ []›
lemma [sepref_fr_rules]: ‹(uncurry0 (Mreturn null), uncurry0 (RETURN op_empty_array)) ∈ unit_assn⇧k →⇩a array_assn R›
unfolding array_assn_def op_empty_array_def
apply sepref_to_hoare
apply vcg
apply (auto simp: array_assn_def ENTAILS_def hr_comp_def[abs_def] Exists_eq_simp
pure_true_conv narray_assn_null_init)
done
sepref_def bottom_init_vmtf2_code
is ‹uncurry0 (RETURN bottom_init_bump)›
:: ‹unit_assn⇧k →⇩a heuristic_bump_init_assn›
unfolding bottom_init_bump_def atom.fold_None
unfolding al_fold_custom_empty[where 'l=64]
by sepref
definition bottom_bool where
‹bottom_bool = False›
sepref_def bottom_bool_code
is ‹uncurry0 (RETURN bottom_bool)›
:: ‹unit_assn⇧k →⇩a bool1_assn›
unfolding bottom_bool_def
by sepref
sepref_def free_bool
is ‹mop_free›
:: ‹bool1_assn⇧d →⇩a unit_assn›
by sepref
schematic_goal free_bool[sepref_frame_free_rules]: ‹MK_FREE bool1_assn ?a›
by synthesize_free
lemma free_bool2: ‹MK_FREE bool1_assn free_bool›
unfolding free_focused_def
by (rule back_subst[of ‹MK_FREE bool1_assn›, OF free_bool])
(auto intro!: ext simp: free_bool_def free_focused_def)
definition bottom_marked_struct :: ‹_› where
‹bottom_marked_struct = (0, [])›
sepref_def bottom_marked_struct_code
is ‹uncurry0 (RETURN bottom_marked_struct)›
:: ‹unit_assn⇧k →⇩a marked_struct_assn›
unfolding bottom_marked_struct_def marked_struct_assn_def op_empty_array_def[symmetric]
apply (annot_unat_const ‹TYPE(32)›)
by sepref
sepref_def free_marked_struct_code
is ‹mop_free›
:: ‹marked_struct_assn⇧d →⇩a unit_assn›
unfolding bottom_marked_struct_def marked_struct_assn_def
by sepref
schematic_goal free_marked_struct[sepref_frame_free_rules]: ‹MK_FREE marked_struct_assn ?a›
unfolding marked_struct_assn_def
by synthesize_free
lemma free_marked_struct2: ‹MK_FREE marked_struct_assn free_marked_struct_code›
unfolding free_arena_fast_def
by (rule back_subst[of ‹MK_FREE marked_struct_assn›, OF free_marked_struct])
(auto intro!: ext simp: free_marked_struct_code_def)
global_interpretation IsaSAT_Init: tuple15_state_ops where
a_assn = trail_pol_fast_assn and
b_assn = arena_fast_assn and
c_assn = conflict_option_rel_assn and
d_assn = sint64_nat_assn and
e_assn = watchlist_fast_assn and
f_assn = heuristic_bump_init_assn and
g_assn = phase_saver_assn and
h_assn = uint32_nat_assn and
i_assn = cach_refinement_l_assn and
j_assn = lbd_assn and
k_assn = vdom_fast_assn and
l_assn = vdom_fast_assn and
m_assn = bool1_assn and
n_assn = lcount_assn and
o_assn = marked_struct_assn and
a_default = bottom_trail and
a = ‹bottom_trail_code› and
b_default = bottom_arena and
b = ‹bottom_arena_code› and
c_default = bottom_conflict and
c = ‹bottom_conflict_code› and
d_default = ‹bottom_decision_level› and
d = ‹(bottom_decision_level_code)› and
e_default = bottom_watchlist and
e = ‹bottom_watchlist_code› and
f_default = bottom_init_bump and
f = ‹bottom_init_vmtf2_code› and
g_default = bottom_phase_saver and
g = ‹bottom_phase_saver_code› and
h_default = bottom_clvls and
h = ‹bottom_clvls_code›and
i_default = bottom_ccach and
i = ‹bottom_ccach_code› and
j_default = empty_lbd and
j = ‹empty_lbd_code› and
k_default = bottom_vdom and
k = ‹bottom_vdom_code› and
l_default = bottom_vdom and
l = ‹bottom_vdom_code› and
m_default = bottom_bool and
m = ‹bottom_bool_code› and
n_default = bottom_lcount and
n = ‹bottom_lcount_code› and
ko_default = bottom_marked_struct and
ko = ‹bottom_marked_struct_code›
.
where
‹extract_trail_wl_heur_init = IsaSAT_Init.remove_a›
where
‹extract_arena_wl_heur_init = IsaSAT_Init.remove_b›
where
‹extract_conflict_wl_heur_init = IsaSAT_Init.remove_c›
where
‹extract_literals_to_update_wl_heur_init = IsaSAT_Init.remove_d›
where
‹extract_watchlist_wl_heur_init = IsaSAT_Init.remove_e›
where
‹extract_vmtf_wl_heur_init = IsaSAT_Init.remove_f›
where
‹extract_phase_saver_wl_heur_init = IsaSAT_Init.remove_g›
where
‹extract_clvls_wl_heur_init = IsaSAT_Init.remove_h›
where
‹extract_ccach_wl_heur_init = IsaSAT_Init.remove_i›
where
‹extract_lbd_wl_heur_init = IsaSAT_Init.remove_j›
where
‹extract_vdom_wl_heur_init = IsaSAT_Init.remove_k›
where
‹extract_ivdom_wl_heur_init = IsaSAT_Init.remove_l›
where
‹extract_failed_wl_heur_init = IsaSAT_Init.remove_m›
where
‹extract_lcount_wl_heur_init = IsaSAT_Init.remove_n›
where
‹extract_marked_wl_heur_init = IsaSAT_Init.remove_o›