Tarski Soundness


Require Import Undecidability.FOL.Syntax.Facts.
Require Import Undecidability.FOL.Semantics.Tarski.FullFacts.
Require Import Undecidability.FOL.Deduction.FullND.
From Undecidability Require Import Shared.ListAutomation.
Import ListAutomationNotations.
Import ListNotations.
Require Import Vector Lia.

Local Set Implicit Arguments.
Local Unset Strict Implicit.

Set Default Proof Using "Type".

#[local] Ltac comp := repeat (progress (cbn in *; autounfold in *)).


Section Soundness.

  Context {Σ_funcs : funcs_signature}.
  Context {Σ_preds : preds_signature}.

  Lemma soundness {ff : falsity_flag} A phi :
    A I valid_ctx A .
  Proof.
    remember intu as p.
    induction 1; intros D I HA; comp.
    - intros Hphi. apply IHprv; trivial. intros ? []; subst. assumption. now apply HA.
    - now apply , .
    - intros d. apply IHprv; trivial. intros [[ H' % HA]] % in_map_iff.
      eapply sat_comp. now comp.
    - eapply sat_comp, sat_ext. 2: apply (IHprv Heqp D I HA (eval t)). now intros [].
    - exists (eval t). cbn. specialize (IHprv Heqp D I HA).
      apply sat_comp in IHprv. eapply sat_ext; try apply IHprv. now intros [].
    - edestruct as [d HD]; eauto.
      assert (H' : psi, = List.map (subst_form ) A (d.:) ).
      + intros P [|[[ H' % HA]] % in_map_iff]; trivial. apply sat_comp. apply H'.
      + specialize ( Heqp D I (d.:) H'). apply sat_comp in . apply .
    - apply (IHprv Heqp) in HA. firstorder.
    - firstorder.
    - firstorder.
    - firstorder. now apply .
    - firstorder. now apply .
    - firstorder.
    - firstorder.
    - edestruct ; eauto.
      + apply ; trivial. intros [|HX]; auto.
      + apply ; trivial. intros [|HX]; auto.
    - discriminate.
  Qed.


  Lemma soundness' {ff : falsity_flag} phi :
    [] I valid .
  Proof.
    intros H % soundness. firstorder.
  Qed.


  Corollary tsoundness {ff : falsity_flag} T phi :
    T TI D (I : interp D) rho, ( psi, T ) .
  Proof.
    intros (A & & ) D I HI. apply (soundness ).
    intros HP. apply HI, , HP.
  Qed.


  Lemma sound_for_classical_model {p:peirce} {ff : falsity_flag} A phi (D : Type) (I : interp D) (rho : env D) :
    ( rho phi, ( ) ~( )) A A .
  Proof.
    intros LEM HD. revert LEM . induction HD; cbn; intros LEM HA.
    - intros Hphi. apply IHHD; trivial. intros ? []; subst. assumption. now apply HA.
    - now apply , .
    - intros d. apply IHHD; trivial. intros [[ H' % HA]] % in_map_iff.
      eapply sat_comp. now comp.
    - eapply sat_comp, sat_ext. 2: apply (IHHD LEM HA (eval t)). now intros [].
    - exists (eval t). cbn. specialize (IHHD LEM HA).
      apply sat_comp in IHHD. eapply sat_ext; try apply IHHD. now intros [].
    - edestruct as [d HD]; eauto.
      assert (H' : psi, = List.map (subst_form ) A (d.:) ).
      + intros P [|[[ H' % HA]] % in_map_iff]; trivial. apply sat_comp. apply H'.
      + specialize ( LEM (d.:) H'). apply sat_comp in . apply .
    - apply (IHHD LEM) in HA. firstorder.
    - firstorder.
    - firstorder.
    - firstorder.
    - firstorder.
    - firstorder.
    - firstorder.
    - edestruct ; eauto.
      + apply ; trivial. intros [|HX]; auto.
      + apply ; trivial. intros [|HX]; auto.
    - intros H.
      destruct (LEM ) as [Ht|Hf]. 1:easy.
      destruct (LEM ) as [|]; tauto.
  Qed.


  Hypothesis LEM : P, P P.

  Lemma Peirce (P Q : Prop) :
    ((P Q) P) P.
  Proof using LEM.
    destruct (LEM (((P Q) P) P)); tauto.
  Qed.


  Lemma soundness_class {ff : falsity_flag} A phi :
    A C valid_ctx A .
  Proof using LEM.
    remember class as p.
    induction 1; intros D I HA; comp.
    - intros Hphi. apply IHprv; trivial. intros ? []; subst. assumption. now apply HA.
    - now apply , .
    - intros d. apply IHprv; trivial. intros [[ H' % HA]] % in_map_iff.
      eapply sat_comp. now comp.
    - eapply sat_comp, sat_ext. 2: apply (IHprv Heqp D I HA (eval t)). now intros [].
    - exists (eval t). cbn. specialize (IHprv Heqp D I HA).
      apply sat_comp in IHprv. eapply sat_ext; try apply IHprv. now intros [].
    - edestruct as [d HD]; eauto.
      assert (H' : psi, = List.map (subst_form ) A (d.:) ).
      + intros P [|[[ H' % HA]] % in_map_iff]; trivial. apply sat_comp. apply H'.
      + specialize ( Heqp D I (d.:) H'). apply sat_comp in . apply .
    - apply (IHprv Heqp) in HA. firstorder.
    - firstorder.
    - clear LEM. firstorder.
    - firstorder. now apply .
    - firstorder. now apply .
    - clear LEM. firstorder.
    - clear LEM. firstorder.
    - edestruct ; eauto.
      + apply ; trivial. intros [|HX]; auto.
      + apply ; trivial. intros [|HX]; auto.
    - apply Peirce.
  Qed.


  Lemma soundness_class' {ff : falsity_flag} phi :
    [] C valid .
  Proof using LEM.
    intros H % soundness_class. clear LEM. firstorder.
  Qed.


  Corollary tsoundness_class {ff : falsity_flag} T phi :
    T TC D (I : interp D) rho, ( psi, T ) .
  Proof using LEM.
    intros (A & & ) D I HI. apply (soundness_class ).
    intros HP. apply HI, , HP.
  Qed.


End Soundness.