Theory CDCL_W_Implementation
theory CDCL_W_Implementation
imports DPLL_CDCL_W_Implementation CDCL_W_Termination
"HOL-Library.Code_Target_Numeral"
begin
subsection ‹List-based CDCL Implementation›
text ‹We here have a very simple implementation of Weidenbach's CDCL, based on the same principle as
the implementation of DPLL: iterating over-and-over on lists. We do not use any fancy
data-structure (see the two-watched literals for a better suited data-structure).
The goal was (as for DPLL) to test the infrastructure and see if an important lemma was missing to
prove the correctness and the termination of a simple implementation.›
subsubsection ‹Types and Instantiation›
notation image_mset (infixr "`#" 90)
type_synonym 'a cdcl⇩W_restart_mark = "'a clause"
type_synonym 'v cdcl⇩W_restart_ann_lit = "('v, 'v cdcl⇩W_restart_mark) ann_lit"
type_synonym 'v cdcl⇩W_restart_ann_lits = "('v, 'v cdcl⇩W_restart_mark) ann_lits"
type_synonym 'v cdcl⇩W_restart_state =
"'v cdcl⇩W_restart_ann_lits × 'v clauses × 'v clauses × 'v clause option"
abbreviation raw_trail :: "'a × 'b × 'c × 'd ⇒ 'a" where
"raw_trail ≡ (λ(M, _). M)"
abbreviation raw_cons_trail :: "'a ⇒ 'a list × 'b × 'c × 'd ⇒ 'a list × 'b × 'c × 'd"
where
"raw_cons_trail ≡ (λL (M, S). (L#M, S))"
abbreviation raw_tl_trail :: "'a list × 'b × 'c × 'd ⇒ 'a list × 'b × 'c × 'd" where
"raw_tl_trail ≡ (λ(M, S). (tl M, S))"
abbreviation raw_init_clss :: "'a × 'b × 'c × 'd ⇒ 'b" where
"raw_init_clss ≡ λ(M, N, _). N"
abbreviation raw_learned_clss :: "'a × 'b × 'c × 'd ⇒ 'c" where
"raw_learned_clss ≡ λ(M, N, U, _). U"
abbreviation raw_conflicting :: "'a × 'b × 'c × 'd ⇒ 'd" where
"raw_conflicting ≡ λ(M, N, U, D). D"
abbreviation raw_update_conflicting :: "'d ⇒ 'a × 'b × 'c × 'd ⇒ 'a × 'b × 'c × 'd"
where
"raw_update_conflicting ≡ λS (M, N, U, _). (M, N, U, S)"
abbreviation "S0_cdcl⇩W_restart N ≡ (([], N, {#}, None):: 'v cdcl⇩W_restart_state)"
abbreviation raw_add_learned_clss where
"raw_add_learned_clss ≡ λC (M, N, U, S). (M, N, {#C#} + U, S)"
abbreviation raw_remove_cls where
"raw_remove_cls ≡ λC (M, N, U, S). (M, removeAll_mset C N, removeAll_mset C U, S)"
lemma raw_trail_conv: "raw_trail (M, N, U, D) = M" and
clauses_conv: "raw_init_clss (M, N, U, D) = N" and
raw_learned_clss_conv: "raw_learned_clss (M, N, U, D) = U" and
raw_conflicting_conv: "raw_conflicting (M, N, U, D) = D"
by auto
lemma state_conv:
"S = (raw_trail S, raw_init_clss S, raw_learned_clss S, raw_conflicting S)"
by (cases S) auto
definition state where
‹state S = (raw_trail S, raw_init_clss S, raw_learned_clss S, raw_conflicting S, ())›