Module CCS := CCSound VSM. Import CCS.
Implicit Arguments list_denote [A T].
Local Notation "'listd'" := list_denote.
Implicit Arguments andp [A].
Local Notation "'inter'" := (@andp _). (*implicit arguments acting weird*)
(* the following five rules (barring reflexivity resolution, which is performed during the simplification phase) are collected in rule "sp" *)
Definition reflexivity_resolution (d : clause) l0 : list clause :=
match d with
| PureClause (Eqv u v :: neg) pos _ _ =>
if expr_eq u v then mkPureClause neg pos :: l0 else l0
| _ => l0
end.
Definition ordered_factoring (c : clause) l0 : list clause :=
match c with
| PureClause nil (Eqv s t :: Eqv u v :: pos) _ _ =>
if pure_atom_eq (Eqv s t) (Eqv u v)
then mkPureClause nil (insert_uniq pure_atom_cmp
(norm_pure_atom (Eqv s t)) pos)
:: l0
else l0
| _ => l0
end.
Definition positive_superposition (c d : clause) l0 : list clause :=
match c, d with
(* positive (right) superposition *)
| PureClause neg (Eqv (Var s0 as s) t :: pos) _ _,
PureClause neg' (Eqv (Var s'0 as s') v :: pos') _ _ =>
if expr_eq s s' && expr_lt t s && expr_lt v s' &&
pure_atom_gt1 (Eqv s t) pos && pure_atom_gt1 (Eqv s' v) pos' &&
pure_atom_gt (Eqv s t) (Eqv s' v) &&
greater_than_all s0 neg && greater_than_all s'0 neg'
then mkPureClause
(merge pure_atom_cmp neg neg')
(insu_atm (norm_pure_atom (Eqv t v)) (merge pure_atom_cmp pos pos')) :: l0
else l0
| _, _ => l0
end.
Definition negative_superposition (c d : clause) l0 : list clause :=
match c, d with
(* negative (left) superposition *)
| PureClause (Eqv s' v :: neg') pos' _ _,
PureClause neg (Eqv (Var s0 as s) t :: pos) _ _ =>
if expr_eq s s' && expr_lt t s && expr_lt v s' &&
pure_atom_gt1 (Eqv s t) pos && greater_than_all s0 neg
then mkPureClause
(insu_atm (norm_pure_atom (Eqv t v)) (merge pure_atom_cmp neg neg'))
(merge pure_atom_cmp pos pos') :: l0
else l0
| _, _ => l0
end.
Proof with simpl; auto.
intros A B; destruct c as [gamma delta| |]; destruct d as [gamma' delta'| |]...
2: simpl; destruct gamma, delta... 2: destruct p... 2: destruct e...
2: destruct p0... 2: destruct e...
2: simpl; destruct gamma, delta... 2: destruct p... 2: destruct e...
2: destruct p0... 2: destruct e...
destruct delta... destruct p... destruct e...
destruct delta'... destruct p... destruct e...
remember (expr_eq (Var v) (Var v0)) as b; destruct b... if_tac...
rewrite <-(expr_eq_eq' _ _ Heqb) in *. intros H. split... intros H1.
simpl in A, B. apply listd_merge_inter' in H1. destruct H1 as [H2 H3].
2: intros; rewrite pure_atom_cmp_eq...
specialize (A H2); specialize (B H3); rewrite (@listd_insert_uniq_un _ state).
2: intros x y; rewrite <-pure_atom_cmp_eq... destruct A, B.
assert (C: (e0 === e1) s) by (eapply var_eq_trans; apply var_eq_sym in H0; eauto).
left. if_tac... apply var_eq_sym...
right; apply listd_merge_un2... solve[apply pure_atom_cmp_eq; auto].
right; apply listd_merge_un1... solve[apply pure_atom_cmp_eq; auto].
right; apply listd_merge_un1... solve[apply pure_atom_cmp_eq; auto].
Qed.
Proof with simpl; auto.
intros A B; destruct c as [gamma delta| |]; destruct d as [gamma' delta'| |]...
2: simpl; destruct gamma, delta... 2: destruct p... 2: destruct p...
2: simpl; destruct gamma, delta... 2: destruct p... 2: destruct p...
destruct gamma... destruct p... destruct delta'... destruct p...
destruct e1... remember (expr_eq (Var v) e) as b; destruct b...
if_tac; [simpl|simpl; auto]; rewrite interS; simpl. intro H3. split...
rewrite (@listd_insert_uniq_inter _ state)... 2: apply pure_atom_cmp_eq.
intros [H1 H2].
assert ((e2 === e0) s). if_tac in H1; simpl in H1... apply var_eq_sym...
apply listd_merge_inter' in H2. destruct H2 as [H4 H5]. simpl in B; spec B...
2: intros x y; rewrite <-pure_atom_cmp_eq...
destruct B.
assert ((e === e0) s). apply var_eq_trans with (y:=e2)...
solve[apply expr_eq_eq' in Heqb; rewrite Heqb in H0; auto].
simpl in A; spec A... split...
apply listd_merge_un2... solve[apply pure_atom_cmp_eq].
apply listd_merge_un1... solve[apply pure_atom_cmp_eq].
Qed.

Lemma reflexivity_resolution_sound c l0 s :
clause_denote c s -> listd clause_denote inter TT l0 s ->
listd clause_denote inter TT (reflexivity_resolution c l0) s.