Conservativity.CK_Idb_Ndb_not_conserv_CK

Require Import List.
Export ListNotations.
Require Import Arith.
Require Import Ensembles.
Require Import Bool.
Require Import Btauto.

Require Import im_syntax.
Require Import CKH_export.
Require Import kripke_export.
Require Import CK_soundness.

Section negboxbot_negneg_box.

(* The logic CK + Idb + Ndb proves the following formula. *)

Lemma negboxbot_negneg_box_prv : Γ φ, CKIdbNdbH_prv Γ ((¬ ) (¬ ¬ φ) ¬ ¬ φ).
Proof.
intros.
assert (CKIdbNdbH_prv Γ (( φ) (( ¬ φ) ( )))).
{ eapply MP. eapply MP. apply Imp_trans.
  - Unshelve. 2: exact ( ¬ ¬ φ). eapply MP. apply Ax ; left ; right ; eapply Kb ; reflexivity.
    apply Nec. apply extCKH_Deduction_Theorem. apply extCKH_Deduction_Theorem.
    eapply MP. apply Id. right ; apply In_singleton. apply Id ; left ; right ; apply In_singleton.
  - eapply MP. eapply MP. apply Imp_trans. Unshelve. 3: exact (( (¬ φ)) ( )).
    + apply Ax ; left ; right ; eapply Kd ; reflexivity.
    + apply extCKH_Deduction_Theorem. eapply MP. eapply MP. apply Imp_trans.
       apply Id ; right ; apply In_singleton.
       apply Ax ; right ; right ; auto. }
assert (CKIdbNdbH_prv Γ ((¬ ( φ))) ((¬ ) (¬ ¬ φ)))).
repeat apply extCKH_Deduction_Theorem. eapply MP. apply Id ; left ; left ; right ; apply In_singleton.
apply extCKH_Deduction_Theorem. eapply MP. apply Id ; left ; left ; right ; apply In_singleton.
repeat apply extCKH_Detachment_Theorem in H.
apply (extCKH_monot _ _ _ H). intros A HA. inversion HA ; subst.
inversion ; subst. left ; left ; left ; left ; auto. right ; auto.
left ; right ; auto.
apply extCKH_Deduction_Theorem. apply extCKH_Deduction_Theorem.
eapply MP. apply Ax ; right ; left ; eexists ; eexists ; reflexivity.
repeat apply extCKH_Deduction_Theorem. eapply MP.
apply EFQ. apply extCKH_Detachment_Theorem.
apply extCKH_Detachment_Theorem in .
apply extCKH_Detachment_Theorem in .
apply (extCKH_monot _ _ _ ). intros A HA. inversion HA ; subst.
inversion ; subst. left ; left ; auto. right ; auto.
left ; right ; auto.
Qed.


End negboxbot_negneg_box.

Section CKIdbNdb_not_conserv_CK.

(* The diamond free fragment of CK + Idb + Ndb extends the one of CK. *)

Theorem diam_free_ext_CKIdbNdb_CK : Γ φ, ( ψ, (Γ ψ φ = ψ) diam_free ψ)
              CKH_prv Γ φ CKIdbNdbH_prv Γ φ.
Proof.
intros. apply more_AdAx_more_prv with (fun x False) ; auto. intros A F ; contradiction.
Qed.


(* We proceed to show that this extension is strict, by proving that the formula
    in the section negboxbot_negneg_box is not validated in the class of all frames.
    We thus need to provide a countermodel for it. *)


(* Intuitionistic relation *)

Definition obireach (ob0 ob1 : option (bool * bool)) : Prop :=
  match with
  | None match with
                   | None True
                   | _ False
                   end
  | Some match with
                   | None False
                   | Some if eqb (fst ) (fst ) then (if eqb (snd ) (snd ) then True else False) else
                                            if fst then (if snd then False else if eqb (snd ) (snd ) then True else False) else False
                   end
  end.

Lemma obireach_refl b : obireach b b.
Proof.
unfold obireach ; destruct b ; repeat rewrite eqb_reflx ; cbn ; auto.
Qed.


Lemma obireach_trans u v w: obireach u v obireach v w obireach u w.
Proof.
intros ; unfold obireach in *. destruct w ; destruct v ; destruct u ; cbn in * ; auto ; try contradiction.
destruct p ; destruct ; destruct ; cbn in * ; auto.
destruct (eqb ) eqn:; destruct (eqb ) eqn:; destruct (eqb b) eqn:;
destruct (eqb ) eqn:; destruct (eqb b) eqn:; destruct (eqb ) eqn:;
cbn in * ; try apply eqb_prop in ; try apply eqb_prop in ; try apply eqb_prop in ;
try apply eqb_prop in ; try apply eqb_prop in ; try apply eqb_prop in ; subst ;
firstorder. 1,3,4,5,9,10,11: destruct ; cbn in ; discriminate.
destruct b ; cbn in ; discriminate. destruct b ; cbn in ; discriminate.
1,4:destruct ; cbn in ; discriminate. destruct ; cbn in ; discriminate.
1,4,5,6,7:destruct b, ; cbn in * ; auto.
1,4,5: destruct ; cbn in ; discriminate.
1,5: destruct ; cbn in ; discriminate. destruct ; auto.
contradiction. destruct b ; cbn in ; discriminate.
Qed.


Lemma obireach_expl u : obireach None u u = None.
Proof.
intros. unfold obireach in H ; destruct u ; cbn in * ; auto ; try contradiction.
Qed.


(* Modal relation *)

Definition obmreach (ob0 ob1 : option (bool * bool)) : Prop :=
  match with
  | None match with
                   | None True
                   | _ False
                   end
  | Some match with
                   | None False
                   | Some if fst then (if snd then (if fst then (if snd then False else True) else False) else False) else
                                            if negb (fst ) then (if negb (snd ) then (if negb (fst ) then (if snd then True else False) else False) else False) else False
                   end
  end.

Lemma obmreach_expl u : obmreach None u u = None.
Proof.
split ; unfold obmreach ; intro ; destruct u ; cbn in * ; subst ; auto ; try contradiction.
inversion H.
Qed.


(* We can define a frame. *)

Instance obF : frame :=
      {|
        nodes := option (bool * bool) ;
        expl:= (@None (bool * bool)) ;

        ireachable := obireach ;
        ireach_refl := obireach_refl ;
        ireach_tran := obireach_trans ;
        ireach_expl := obireach_expl ;

        mreachable := obmreach ;
        mreach_expl := obmreach_expl ;
      |}.

(* We define a valuation. *)

Definition obval (ob : option (bool * bool)) (p : ) :=
  match ob with
  | None True
  | Some b if fst b then (if snd b then True else False) else False
  end.

Lemma obval_persist : u v, obireach u v (p : ), obval u p obval v p.
Proof.
intros. unfold obval in *.
destruct u ; destruct v ; cbn in * ; auto ; try contradiction.
destruct ; destruct ; destruct b ; destruct ; destruct ; destruct ; cbn in * ; auto.
Qed.


Lemma obval_expl : p, obval expl p.
Proof.
intros. unfold obval. destruct expl eqn:E ; auto.
unfold expl in E. inversion E.
Qed.


(* Finally we can define a model. *)

Instance obM : model :=
      {|
        fra := obF ;

        val := obval ;
        persist := obval_persist ;
        val_expl := obval_expl
      |}.

(* We use this model to show that the extension is strict. *)

Theorem diam_free_strict_ext_CKIdbNdb_CK :
               CKIdbNdbH_prv (Empty_set _) ((¬ ) (¬ ¬ (#0)) ¬ ¬ (#0))
                 CKH_prv (Empty_set _) ((¬ ) (¬ ¬ (#0)) ¬ ¬ (#0)).
Proof.
split.
- apply negboxbot_negneg_box_prv.
- intro. repeat apply extCKH_Detachment_Theorem in H. apply CK_Soundness in H.
  assert (forces obM (Some (false,false)) ((¬ ( )))).
  { intros b ifb Hb. destruct b ; cbn in * ; unfold obireach in ifb ; cbn in ifb ; auto.
    destruct p ; cbn in *. destruct b ; cbn in *.
    - destruct ; cbn in * ; auto ; try contradiction.
      assert (obmreach (Some (true, false)) (Some (true, true))) ; cbn ; auto.
      pose (Hb (Some (true,false)) I (Some (true,true)) ). inversion e.
    - destruct ; cbn in * ; auto ; try contradiction.
      assert (obmreach (Some (false, false)) (Some (false, true))) ; cbn ; auto.
      pose (Hb (Some (false,false)) I (Some (false,true)) ). inversion e. }
  assert (forces obM (Some (false,false)) (¬ ( (#0))))).
  { intros b ifb Hb. exfalso. destruct b ; cbn in * ; unfold obireach in ifb ; cbn in ifb ; auto.
    destruct p ; cbn in *. destruct b ; cbn in *.
    - destruct ; cbn in * ; auto ; try contradiction.
      assert (obmreach (Some (true, false)) (Some (true, true))) ; cbn ; auto.
      assert ( v : option (bool * bool), obireach (Some (true, false)) v
       u : option (bool * bool), obmreach v u forces obM u (#0)).
      { intros. destruct v ; cbn in * ; try contradiction.
        destruct p ; cbn in * ; try contradiction.
        destruct b ; destruct ; cbn in * ; auto ; try contradiction.
        destruct u ; cbn in * ; auto ; try contradiction. }
      pose (Hb (Some (true,false)) I ). inversion e.
    - destruct ; cbn in * ; auto ; try contradiction.
      assert (obmreach (Some (true, false)) (Some (true, true))) ; cbn ; auto.
      assert ( v : option (bool * bool), obireach (Some (true, false)) v
       u : option (bool * bool), obmreach v u forces obM u (#0)).
      { intros. destruct v ; cbn in * ; try contradiction.
        destruct p ; cbn in * ; try contradiction.
        destruct b ; destruct ; cbn in * ; auto ; try contradiction.
        destruct u ; cbn in * ; auto ; try contradiction. }
      pose (Hb (Some (true,false)) I ). inversion e. }
  assert ( forces obM (Some (false,false)) ( ¬ ¬ (#0))).
  { intro.
    assert (( v : option (bool * bool),
    match v with
    | Some
        if if fst then false else true
        then if if snd then true else false then True else False
        else
         if fst
         then
          if snd
          then False
          else if if snd then true else false then True else False
         else False
    | None False
    end obval v 0 v = None)).
    { intros. destruct v ; cbn in * ; auto. destruct p ; cbn in * ; try contradiction.
      destruct b ; destruct ; cbn in * ; auto ; try contradiction. }
    pose ( (Some (false,false)) I (Some (false,true)) I (Some (false,true)) I ) ; cbn in f. inversion f. }
  apply . apply H ; auto. intros. inversion ; subst. inversion ; subst.
  inversion . inversion ; subst ; auto. inversion ; subst ; auto.
Qed.


End CKIdbNdb_not_conserv_CK.