Theory IsaSAT_Stats_LLVM
theory IsaSAT_Stats_LLVM
imports IsaSAT_Stats IsaSAT_EMA_LLVM IsaSAT_Rephase_LLVM IsaSAT_Reluctant_LLVM Tuple16_LLVM
begin
hide_const (open) NEMonad.RETURN NEMonad.ASSERT
lemma Exists_eq_simp_sym: ‹(∃x. (P x ∧* ↑ (b = x)) s) ⟷ P b s›
by (subst eq_commute[of b])
(rule Exists_eq_simp)
definition code_hider_assn where
‹code_hider_assn R S = hr_comp R (⟨S⟩code_hider_rel)›
lemma get_content_destroyed_kept[sepref_fr_rules]:
‹CONSTRAINT is_pure R ⟹ (Mreturn o id, RETURN o get_content) ∈ (code_hider_assn R S)⇧k →⇩a hr_comp R S›
unfolding code_hider_assn_def code_hider_rel_def
apply sepref_to_hoare
apply vcg
apply (auto simp: br_def ENTAILS_def Exists_eq_simp Exists_eq_simp_sym hr_comp_def pure_true_conv)
by (smt (z3) Sep_Algebra_Add.pure_part_pure entails_def is_pure_conv pure_app_eq pure_partI sep.mult_assoc sep_conj_def split_conj_is_pure)
lemma Constructor_assn_destroyed:
‹(Mreturn o id, RETURN o Constructor) ∈ (hr_comp R S)⇧d →⇩a code_hider_assn R S›
unfolding code_hider_assn_def code_hider_rel_def
apply sepref_to_hoare
apply vcg
by (auto simp: br_def ENTAILS_def Exists_eq_simp Exists_eq_simp_sym hr_comp_def pure_true_conv)
lemma get_content_destroyed:
‹(Mreturn o id, RETURN o get_content) ∈ (code_hider_assn R S)⇧d →⇩a hr_comp R S›
unfolding code_hider_assn_def code_hider_rel_def
apply sepref_to_hoare
apply vcg
by (auto simp: br_def ENTAILS_def Exists_eq_simp Exists_eq_simp_sym hr_comp_def pure_true_conv)
lemma get_content_hnr[sepref_fr_rules]:
‹(id, get_content) ∈ ⟨S⟩code_hider_rel →⇩f S›
unfolding code_hider_rel_def
by (auto simp: intro!: frefI)
lemma Constructor_hnr[sepref_fr_rules]:
‹(id, Constructor) ∈ S →⇩f ⟨S⟩code_hider_rel›
unfolding code_hider_rel_def
by (auto simp: intro!: frefI)
definition search_stats_assn :: ‹search_stats ⇒ search_stats ⇒ _› where
‹search_stats_assn ≡ word64_assn ×⇩a word64_assn ×⇩a word64_assn ×⇩aword64_assn ×⇩a word64_assn ×⇩a word64_assn ×⇩aword64_assn ×⇩a word64_assn ×⇩a word64_assn ×⇩a word64_assn›
definition subsumption_stats_assn :: ‹inprocessing_subsumption_stats ⇒ inprocessing_subsumption_stats ⇒ _› where
‹subsumption_stats_assn = word64_assn ×⇩a word64_assn ×⇩a word64_assn ×⇩a word64_assn ×⇩a word64_assn›
definition binary_stats_assn :: ‹inprocessing_binary_stats ⇒ inprocessing_binary_stats ⇒ _› where
‹binary_stats_assn = word64_assn ×⇩a word64_assn ×⇩a word64_assn›
definition pure_lits_stats_assn :: ‹inprocessing_pure_lits_stats ⇒ inprocessing_pure_lits_stats ⇒ _› where
‹pure_lits_stats_assn = word64_assn ×⇩a word64_assn›
definition rephase_stats_assn :: ‹rephase_stats ⇒ rephase_stats ⇒ _› where
‹rephase_stats_assn ≡ word64_assn ×⇩a word64_assn ×⇩a word64_assn ×⇩aword64_assn ×⇩a word64_assn ×⇩a word64_assn›
definition empty_search_stats where
‹empty_search_stats = (0,0,0,0,0,0,0,0,0,0)›
sepref_def empty_search_stats_impl
is ‹uncurry0 (RETURN empty_search_stats)›
:: ‹unit_assn⇧k →⇩a search_stats_assn›
unfolding search_stats_assn_def empty_search_stats_def
by sepref
definition empty_binary_stats :: ‹inprocessing_binary_stats› where
‹empty_binary_stats = (0,0,0)›
sepref_def empty_binary_stats_impl
is ‹uncurry0 (RETURN empty_binary_stats)›
:: ‹unit_assn⇧k →⇩a binary_stats_assn›
unfolding binary_stats_assn_def empty_binary_stats_def
by sepref
definition empty_subsumption_stats :: ‹inprocessing_subsumption_stats› where
‹empty_subsumption_stats = (0,0,0,0,0)›
sepref_def empty_subsumption_stats_impl
is ‹uncurry0 (RETURN empty_subsumption_stats)›
:: ‹unit_assn⇧k →⇩a subsumption_stats_assn›
unfolding subsumption_stats_assn_def empty_subsumption_stats_def
by sepref
definition empty_pure_lits_stats :: ‹inprocessing_pure_lits_stats› where
‹empty_pure_lits_stats = (0,0)›
sepref_def empty_pure_lits_stats_impl
is ‹uncurry0 (RETURN empty_pure_lits_stats)›
:: ‹unit_assn⇧k →⇩a pure_lits_stats_assn›
unfolding pure_lits_stats_assn_def empty_pure_lits_stats_def
by sepref
definition lbd_size_limit_assn where
‹lbd_size_limit_assn = uint32_nat_assn ×⇩a sint64_nat_assn›
definition empty_lsize_limit_stats :: ‹lbd_size_limit_stats› where
‹empty_lsize_limit_stats = (0,0)›
sepref_def empty_lsize_limit_stats_impl
is ‹uncurry0 (RETURN empty_lsize_limit_stats)›
:: ‹unit_assn⇧k →⇩a lbd_size_limit_assn›
unfolding lbd_size_limit_assn_def empty_lsize_limit_stats_def
apply (rewrite at ‹(_, ⌑)› snat_const_fold[where 'a=64])
apply (rewrite at ‹(⌑, _)› unat_const_fold[where 'a=32])
by sepref
definition ema_init_bottom :: ‹ema› where
‹ema_init_bottom = ema_init 0›
sepref_def ema_init_bottom_impl
is ‹uncurry0 (RETURN ema_init_bottom)›
:: ‹unit_assn⇧k →⇩a ema_assn›
unfolding ema_init_bottom_def by sepref
lemma stats_bottom:
‹(uncurry0 (return⇩M 0), uncurry0 (RETURN 0)) ∈ unit_assn⇧k →⇩a word64_assn›
‹(uncurry0 (return⇩M 0), uncurry0 (RETURN 0)) ∈ unit_assn⇧k →⇩a word32_assn›
by (sepref_to_hoare; vcg; fail)+
definition empty_rephase_stats :: ‹rephase_stats› where
‹empty_rephase_stats = (0,0,0,0,0,0)›
sepref_def empty_rephase_stats_impl
is ‹uncurry0 (RETURN empty_rephase_stats)›
:: ‹unit_assn⇧k →⇩a rephase_stats_assn›
unfolding empty_rephase_stats_def rephase_stats_assn_def by sepref
schematic_goal mk_free_search_stats_assn[sepref_frame_free_rules]: ‹MK_FREE search_stats_assn ?fr› and
mk_free_binary_stats_assn[sepref_frame_free_rules]: ‹MK_FREE binary_stats_assn ?fr2› and
mk_free_subsumption_stats_assn[sepref_frame_free_rules]: ‹MK_FREE subsumption_stats_assn ?fr3› and
mk_free_ema_assn[sepref_frame_free_rules]: ‹MK_FREE ema_assn ?fr4›and
mk_free_pure_lits_stats_assn[sepref_frame_free_rules]: ‹MK_FREE pure_lits_stats_assn ?fr5› and
mk_free_rephase_stats_assn[sepref_frame_free_rules]: ‹MK_FREE rephase_stats_assn ?fr6›
unfolding search_stats_assn_def binary_stats_assn_def subsumption_stats_assn_def
pure_lits_stats_assn_def rephase_stats_assn_def
by synthesize_free+
sepref_def free_search_stats_assn
is ‹mop_free›
:: ‹search_stats_assn⇧d →⇩a unit_assn›
by sepref
sepref_def free_binary_stats_assn
is ‹mop_free›
:: ‹binary_stats_assn⇧d →⇩a unit_assn›
by sepref
sepref_def free_subsumption_stats_assn
is ‹mop_free›
:: ‹subsumption_stats_assn⇧d →⇩a unit_assn›
by sepref
sepref_def free_pure_lits_stats_assn
is ‹mop_free›
:: ‹pure_lits_stats_assn⇧d →⇩a unit_assn›
by sepref
sepref_def free_ema_assn
is ‹mop_free›
:: ‹ema_assn⇧d →⇩a unit_assn›
by sepref
sepref_def free_word64_assn
is ‹mop_free›
:: ‹word64_assn⇧d →⇩a unit_assn›
by sepref
sepref_def free_word32_assn
is ‹mop_free›
:: ‹word32_assn⇧d →⇩a unit_assn›
by sepref
sepref_def free_lbd_size_limit_assn
is ‹mop_free›
:: ‹lbd_size_limit_assn⇧d →⇩a unit_assn›
unfolding lbd_size_limit_assn_def
by sepref
sepref_def free_rephase_stats_assn
is ‹mop_free›
:: ‹rephase_stats_assn⇧d →⇩a unit_assn›
by sepref
lemma mop_free_hnr': ‹(f, mop_free) ∈ R⇧d →⇩a unit_assn ⟹ MK_FREE R f›
unfolding mop_free_def
apply (rule MK_FREEI)
apply simp
subgoal for a c
apply (drule hfrefD[of _ _ _ _ _ _ _ a c])
apply (rule TrueI)
apply (rule TrueI)
apply (drule hn_refineD)
apply simp
apply (rule htriple_pure_preI[of ])
unfolding fst_conv snd_conv hf_pres.simps
apply (clarsimp
simp: hn_ctxt_def pure_def sep_algebra_simps invalid_assn_def)
done
done
type_synonym isasat_stats_assn = ‹(search_stats, inprocessing_binary_stats, inprocessing_subsumption_stats, ema,
inprocessing_pure_lits_stats, 32 word × 64 word, rephase_stats, 64 word,
64 word, 64 word,64 word, 64 word,
64 word, 64 word, 32 word, 64 word) tuple16›
definition isasat_stats_assn :: ‹isasat_stats ⇒ isasat_stats_assn ⇒ _ ⇒ bool› where
‹isasat_stats_assn = tuple16_assn search_stats_assn binary_stats_assn subsumption_stats_assn ema_assn
pure_lits_stats_assn lbd_size_limit_assn rephase_stats_assn word64_assn word64_assn word64_assn
word64_assn word64_assn word64_assn word64_assn word32_assn word64_assn›
:: ‹isasat_stats ⇒ _› where
‹extract_search_strategy_stats = tuple16_ops.remove_a empty_search_stats›
:: ‹isasat_stats ⇒ _› where
‹extract_binary_stats = tuple16_ops.remove_b empty_binary_stats›
:: ‹isasat_stats ⇒ _› where
‹extract_subsumption_stats = tuple16_ops.remove_c empty_subsumption_stats›
:: ‹isasat_stats ⇒ _› where
‹extract_avg_lbd = tuple16_ops.remove_d ema_init_bottom›
:: ‹isasat_stats ⇒ _› where
‹extract_pure_lits_stats = tuple16_ops.remove_e empty_pure_lits_stats›
:: ‹isasat_stats ⇒ _› where
‹extract_lbd_size_limit_stats = tuple16_ops.remove_f empty_lsize_limit_stats›
:: ‹isasat_stats ⇒ _› where
‹extract_rephase_stats = tuple16_ops.remove_g empty_rephase_stats›