Theory topo_derivative_algebra

theory topo_derivative_algebra
  imports topo_operators_derivative
begin
nitpick_params[assms=true, user_axioms=true, show_all, expect=genuine, format=3] (*default Nitpick settings*)

section β€ΉDerivative algebraβ€Ί
textβ€Ή\noindent{The closure of a set A (@{text "π’ž(A)"}) can be seen as the set A augmented by (i) its boundary points, or
(ii) its accumulation/limit points. We explore the second variant by drawing on the notion of derivative algebra.}β€Ί

textβ€Ή\noindent{Declares a primitive (unconstrained) derivative (aka. derived-set) operation and defines others from it.}β€Ί
consts π’Ÿ::"Οƒβ‡’Οƒ"
abbreviation "ℐ ≑ ℐD π’Ÿ" ―‹ interior β€Ί
abbreviation "π’ž ≑ π’žD π’Ÿ" ―‹ closure β€Ί
abbreviation "ℬ ≑ ℬD π’Ÿ" ―‹ border β€Ί
abbreviation "β„± ≑ β„±D π’Ÿ" ―‹ frontier β€Ί
abbreviation "𝒦 ≑ 𝒦D π’Ÿ" ―‹ coherence β€Ί


subsection β€ΉBasic propertiesβ€Ί

textβ€Ή\noindent{Verifies minimal conditions under which operators resulting from conversion functions coincide.}β€Ί
lemma ICdual: "ℐ ≑ π’žd" by (simp add: dual_der2 equal_op_def)
lemma ICdual': "π’ž ≑ ℐd" by (simp add: dual_der1 equal_op_def)
lemma BI_rel: "ℬ ≑ ℬI ℐ" using Br_der_def Br_int_def Int_der_def unfolding equal_op_def conn by auto
lemma IB_rel: "ℐ ≑ ℐB ℬ" using Br_der_def Int_br_def Int_der_def unfolding equal_op_def conn by auto
lemma BC_rel: "ℬ ≑ ℬC π’ž" using BI_BC_rel BI_rel dual_der1 by auto
lemma CB_rel: "π’ž ≑ π’žB ℬ" using Br_der_def2 Cl_br_def Int_der_def2 dual_def dual_der1 unfolding equal_op_def conn by auto
lemma FI_rel: "β„± ≑ β„±I ℐ" by (metis Cl_der_def FI2 Fr_2_def Fr_der_def2 Fr_int_def ICdual' dual_def eq_ext' equal_op_def)
lemma FC_rel: "β„± ≑ β„±C π’ž" by (simp add: Cl_der_def Fr_cl_def Fr_der_def2 equal_op_def)
lemma FB_rel: "β„± ≑ β„±B ℬ" by (smt Br_der_def CB_rel Cl_br_def Cl_der_def Fr_br_def Fr_der_def Fr_der_def2 equal_op_def conn)

textβ€Ή\noindent{Recall that derivative and coherence operations cannot be obtained from either interior, closure, border
nor frontier. The derivative operation can indeed be seen as being more fundamental than the other ones.}β€Ί

textβ€Ή\noindent{Fixed-point and other operators are interestingly related.}β€Ί
lemma fp1: "ℐfp ≑ ℬc" by (smt BI_rel Br_int_def IB_rel Int_br_def equal_op_def conn)
lemma fp2: "ℬfp ≑ ℐc" using Br_der_def Int_der_def unfolding equal_op_def conn by auto 
lemma fp3: "π’žfp ≑ ℬd" by (smt BI_rel Br_int_def CB_rel Cl_br_def dual_def equal_op_def conn)
lemma fp4: "(ℬd)fp ≑ π’ž" by (smt dimp_def equal_op_def fp3)
lemma fp5: "β„±fp ≑ ℬ βŠ” (π’žc)" using Br_der_def Cl_der_def Fr_der_def unfolding equal_op_def conn by auto
lemma fp6: "π’Ÿfp ≑ 𝒦 βŠ” (π’žc)" using Cl_der_def Kh_der_def equal_op_def conn by fastforce

textβ€Ή\noindent{Different inter-relations (some redundant ones are kept to help the provers).}β€Ί
lemma monI: "Der_1b π’Ÿ ⟹ MONO ℐ" by (simp add: ID1b MONO_MULTa)
lemma monC: "Der_1b π’Ÿ ⟹ MONO π’ž" by (simp add: CD1b MONO_ADDIb)
lemma pB1: "βˆ€A. ℬ A β‰ˆ A β†Ό ℐ A" using BI_rel Br_int_def eq_ext' by fastforce
lemma pB2: "βˆ€A. ℬ A β‰ˆ A ∧ β„± A" using Br_der_def Fr_der_def conn by auto
lemma pB3: "βˆ€A. ℬ(─A) β‰ˆ ─A ∧ β„± A" using FD2 Fr_2_def meet_def pB2 by auto
lemma pB4: "βˆ€A. ℬ(─A) β‰ˆ ─A ∧ π’ž A" by (simp add: dual_def dual_der1 pB1 conn)
lemma pB5: "Der_1b π’Ÿ ⟹ βˆ€A. ℬ(π’ž A) β‰Ό (ℬ A) ∨ ℬ(─A)" using ADDI_b_def Cl_der_def MONO_ADDIb monI pB1 pB4 unfolding conn by auto
lemma pF1: "βˆ€A. β„± A β‰ˆ π’ž A β†Ό ℐ A"  using Cl_der_def Fr_der_def Int_der_def conn by auto
lemma pF2: "βˆ€A. β„± A β‰ˆ π’ž A ∧ π’ž(─A)" by (simp add: Cl_der_def Fr_der_def2)
lemma pF3: "βˆ€A. β„± A β‰ˆ ℬ A ∨ ℬ(─A)" by (smt Br_der_def Cl_der_def dual_def dual_der1 dual_der2 pF2 conn)
lemma pF4: "Der_1 π’Ÿ ⟹ Der_4e π’Ÿ ⟹ βˆ€A. β„±(ℐ A) β‰Ό β„± A" by (metis CD1 CD2 CD4a ICdual ID4 IDEM_def PC1 PC4 PC5 PD8 diff_def eq_ext' pF1)
lemma pF5: "Der_1 π’Ÿ ⟹ Der_4e π’Ÿ ⟹ βˆ€A. β„±(π’ž A) β‰Ό β„± A" by (metis FD2 Fr_2_def ICdual' dual_def eq_ext' pF4)
lemma pA1: "βˆ€A. A β‰ˆ ℐ A ∨ ℬ A" using Br_der_def2 Int_der_def2 conn by auto
lemma pA2: "βˆ€A. A β‰ˆ π’ž A β†Ό ℬ(─A)" using Cl_der_def pB4 conn by auto
lemma pC1: "βˆ€A. π’ž A β‰ˆ A ∨ ℬ(─A)" using CB_rel Cl_br_def eq_ext' by fastforce
lemma pC2: "βˆ€A. π’ž A β‰ˆ A ∨ β„± A" using Cl_der_def Fr_der_def2 conn by auto
lemma pI1: "βˆ€A. ℐ A β‰ˆ A β†Ό ℬ A" using pA1 pB1 conn by auto
lemma pI2: "βˆ€A. ℐ A β‰ˆ A β†Ό β„± A" using Br_der_def Fr_der_def pI1 conn by auto

lemma IC_imp: "Der_1 π’Ÿ ⟹ Der_3 π’Ÿ ⟹ βˆ€A B. ℐ(A β†’ B) β‰Ό π’ž A β†’ π’ž B" proof -
  assume der1: "Der_1 π’Ÿ" and der3: "Der_3 π’Ÿ"
  { fix a b
    have "(a β†’ b) ∧ ─b β†’ ─a = ⊀" unfolding conn by auto
    hence "ℐ((a β†’ b) ∧ ─b β†’ ─a) β‰ˆ ℐ(⊀)" by simp
    hence "ℐ((a β†’ b) ∧ ─b β†’ ─a) β‰ˆ ⊀" using der3 dNOR_def using ID3 by auto 
    moreover have "let A=(a β†’ b) ∧ ─b; B=─a in ℐ(A β†’ B) β‰Ό ℐ(A) β†’ ℐ(B)" using ID1 Int_7_def PI7 der1 by auto
    ultimately have "ℐ((a β†’ b) ∧ ─b) β†’ ℐ(─a) β‰ˆ ⊀" unfolding conn by simp
    moreover have "let A=a β†’ b; B=─b in ℐ(A ∧ B) β‰ˆ ℐ(A) ∧ ℐ(B)" using ID1 MULT_def der1 by auto
    ultimately have "ℐ(a β†’ b) ∧ ℐ(─b) β†’ ℐ(─a) β‰ˆ ⊀" unfolding conn by simp
    moreover have "βˆ€A. ℐ(─A) β‰ˆ β”€π’ž(A)" by (simp add: dual_def dual_der1 conn)
    ultimately have "ℐ(a β†’ b) ∧ β”€π’ž(b) β†’ β”€π’ž(a) β‰ˆ ⊀" unfolding conn by simp
    hence "ℐ(a β†’ b) ∧ β”€π’ž(b) β‰Ό β”€π’ž(a)" unfolding conn by simp
    hence "ℐ(a β†’ b) ∧ π’ž a β‰Ό π’ž b" unfolding conn by metis
  } thus ?thesis unfolding conn by simp
qed

textβ€Ή\noindent{Define some fixed-point predicates and prove some properties.}β€Ί
abbreviation openset ("Op") where "Op A ≑ fp ℐ A"
abbreviation closedset ("Cl") where "Cl A ≑ fp π’ž A"
abbreviation borderset ("Br") where "Br A ≑ fp ℬ A"
abbreviation frontierset ("Fr") where "Fr A ≑ fp β„± A"

lemma Int_Open: "Der_1a π’Ÿ ⟹ Der_4e π’Ÿ ⟹ βˆ€A. Op(ℐ A)" using ID4a IDEM_def by blast
lemma Cl_Closed: "Der_1a π’Ÿ ⟹ Der_4e π’Ÿ ⟹ βˆ€A. Cl(π’ž A)" using CD4a IDEM_def by blast
lemma Br_Border: "Der_1b π’Ÿ ⟹ βˆ€A. Br(ℬ A)" by (smt Br_der_def CI1b IC1_dual PD1 conn)
textβ€Ή\noindent{In contrast, there is no analogous fixed-point result for frontier:}β€Ί
lemma "𝔇 π’Ÿ ⟹ βˆ€A. Fr(β„± A)" nitpick oops (*counterexample even if assuming all derivative conditions*)
  
lemma OpCldual: "βˆ€A. Cl A ⟷ Op(─A)" using dual_def dual_der1 conn by auto
lemma ClOpdual: "βˆ€A. Op A ⟷ Cl(─A)" by (simp add: dual_def dual_der1 conn)
lemma Fr_ClBr: "βˆ€A. Fr(A) = (Cl(A) ∧ Br(A))" using join_def meet_def pB2 pC2 by auto
lemma Cl_F: "Der_1 π’Ÿ ⟹ Der_4e π’Ÿ ⟹ βˆ€A. Cl(β„± A)" using FD4 Fr_4_def join_def pC2 by auto


subsection β€ΉFurther propertiesβ€Ί

textβ€Ή\noindent{The definitions and theorems below are well known in the literature (e.g. @{cite Kuratowski2}).
Here we uncover the minimal conditions under which they hold (taking derivative operation as primitive).}β€Ί
lemma Cl_Bzero: "βˆ€A. Cl A ⟷ ℬ(─A) β‰ˆ βŠ₯" using pA2 pC1 unfolding conn by metis
lemma Op_Bzero: "βˆ€A. Op A ⟷  ℬ A β‰ˆ βŠ₯" using pB1 pI1 unfolding conn by metis
lemma Br_boundary: "βˆ€A. Br(A) ⟷ ℐ A β‰ˆ βŠ₯" using Br_der_def2 Int_der_def2 unfolding conn by metis
lemma Fr_nowhereDense: "βˆ€A. Fr(A) ⟢ ℐ(π’ž A) β‰ˆ βŠ₯" using Fr_ClBr Br_boundary eq_ext by metis
lemma Cl_FB: "βˆ€A. Cl A ⟷ β„± A β‰ˆ ℬ A" using Br_der_def2 pA2 pF1 pF3 unfolding conn by metis
lemma Op_FB: "βˆ€A. Op A ⟷ β„± A β‰ˆ ℬ(─A)" using pA1 pA2 pF3 pI2 unfolding conn by metis
lemma Clopen_Fzero: "βˆ€A. Cl A ∧ Op A ⟷ β„± A β‰ˆ βŠ₯" using Cl_der_def Int_der_def Fr_der_def unfolding conn by smt

lemma Int_sup_closed: "Der_1b π’Ÿ ⟹ supremum_closed (Ξ»A. Op A)" by (smt IC1_dual ID1b Int_der_def2 PD1 sup_char diff_def)
lemma Int_meet_closed: "Der_1a π’Ÿ ⟹ meet_closed (Ξ»A. Op A)" by (metis ID1a Int_der_def MULT_b_def meet_def)
lemma Int_inf_closed: "Der_inf π’Ÿ ⟹ infimum_closed (Ξ»A. Op A)" by (simp add: fp_ID_inf_closed)
lemma Cl_inf_closed: "Der_1b π’Ÿ ⟹ infimum_closed (Ξ»A. Cl A)" by (smt Cl_der_def IC1_dual ID1b PD2 dual_der1 inf_char join_def)
lemma Cl_join_closed: "Der_1a π’Ÿ ⟹ join_closed (Ξ»A. Cl A)" using ADDI_a_def Cl_der_def join_def by fastforce
lemma Cl_sup_closed: "Der_inf π’Ÿ ⟹ supremum_closed (Ξ»A. Cl A)" by (simp add: fp_CD_sup_closed)
lemma Br_inf_closed: "Der_1b π’Ÿ ⟹ infimum_closed (Ξ»A. Br A)" by (smt Br_der_def CI1b IC1_dual PD1 inf_char diff_def)
lemma Fr_inf_closed: "Der_1b π’Ÿ ⟹ infimum_closed (Ξ»A. Fr A)" by (metis (full_types) Br_der_def Br_inf_closed Cl_der_def Cl_inf_closed Fr_der_def join_def diff_def)
lemma Br_Fr_join: "Der_1 π’Ÿ ⟹ Der_4e π’Ÿ ⟹ βˆ€A B. Br A ∧ Fr B ⟢ Br(A ∨ B)" proof -
  assume der1: "Der_1 π’Ÿ" and der4: "Der_4e π’Ÿ"
  { fix A B
    { assume bra: "Br A" and frb: "Fr B"
      from bra have "ℐ A β‰ˆ βŠ₯" using Br_boundary by auto
      hence 1: "π’ž(─A) β‰ˆ ⊀" by (metis ICdual bottom_def compl_def dual_def eq_ext' top_def)
      from frb have "ℐ(π’ž B) β‰ˆ βŠ₯" by (simp add: Fr_nowhereDense)
      hence 2: "π’ž(─(π’ž B)) β‰ˆ ⊀" by (metis ICdual bottom_def compl_def dual_def eq_ext' top_def)
      from der1 have "π’ž(─A) β†Ό π’ž B β‰Ό π’ž((─A) β†Ό B)" by (simp add: CD1 PD4)
      hence "π’ž(─A) β†Ό π’ž B β‰Ό π’ž(─(A ∨ B))" unfolding conn by simp
      hence "⊀ β†Ό π’ž B β‰Ό π’ž(─(A ∨ B))" using 1 unfolding conn by simp
      hence 3: "─(π’ž B) β‰Ό π’ž(─(A ∨ B))" unfolding conn by simp
      from der1 der4 have 4: "let M=─(π’ž B); N=─(A ∨ B) in  M β‰Ό π’ž N ⟢ π’ž M β‰Ό π’ž N" by (smt CD1b Cl_Closed PC1 PD1)
      from 3 4 have "π’ž(─(π’ž B)) β‰Ό π’ž(─(A ∨ B))" by simp 
      hence "⊀ β‰ˆ π’ž(─(A ∨ B))" using 2 unfolding top_def by simp
      hence "βŠ₯ β‰ˆ ℐ(A ∨ B)" using ICdual dual_def eq_ext' conn by metis
      hence "Br (A ∨ B)" using Br_boundary by simp
    } hence "Br A ∧ Fr B ⟢ Br (A ∨ B)" by simp
  } hence "βˆ€A B. Br A ∧ Fr B ⟢ Br (A ∨ B)" by simp
  thus ?thesis by simp
qed
lemma Fr_join_closed: "Der_1 π’Ÿ ⟹ Der_4e π’Ÿ ⟹ join_closed (Ξ»A. Fr A)" by (simp add: Br_Fr_join Cl_join_closed Fr_ClBr PC1)


textβ€Ή\noindent{Introduces a predicate for indicating that two sets are disjoint and proves some properties.}β€Ί
abbreviation "Disj A B ≑ A ∧ B β‰ˆ βŠ₯" 

lemma Disj_comm: "βˆ€A B. Disj A B ⟢ Disj B A" unfolding conn by fastforce
lemma Disj_IF: "βˆ€A. Disj (ℐ A) (β„± A)" by (simp add: Cl_der_def Fr_der_def2 dual_def dual_der2 conn)
lemma Disj_B: "βˆ€A. Disj (ℬ A) (ℬ(─A))" by (simp add: Br_der_def2 conn)
lemma Disj_I: "βˆ€A. Disj (ℐ A) (─A)" by (simp add: Int_der_def conn)
lemma Disj_BCI: "βˆ€A. Disj (ℬ(π’ž A)) (ℐ(─A))" by (simp add: Br_der_def2 dual_def dual_der1 conn)
lemma Disj_CBI: "Der_1b π’Ÿ ⟹ Der_4e π’Ÿ ⟹ βˆ€A. Disj (π’ž(ℬ(─A))) (ℐ(─A))" by (smt Br_der_def2 Der_4e_def Cl_der_def Int_der_def2 PD3 conn)

textβ€Ή\noindent{Introduce a predicate for indicating that two sets are separated and proves some properties.}β€Ί
definition "Sep A B ≑ Disj (π’ž A) B ∧ Disj (π’ž B) A"

lemma Sep_comm: "βˆ€A B. Sep A B ⟢ Sep B A" by (simp add: Sep_def)
lemma Sep_disj: "βˆ€A B. Sep A B ⟢ Disj A B" using CD2 EXP_def Sep_def conn by auto
lemma Sep_I: "Der_1 π’Ÿ ⟹ Der_4e π’Ÿ ⟹ βˆ€A. Sep (ℐ A) (ℐ (─A))" unfolding Sep_def by (smt CD2 CD4 IC1 ID1 PC4 PC5 PD8 dual_def dual_der1 dual_der2 conn)

lemma Sep_sub: "Der_1b π’Ÿ ⟹ βˆ€A B C D. Sep A B ∧ C β‰Ό A ∧ D β‰Ό B ⟢ Sep C D" using MONO_ADDIb PD2 dual_der1 monI unfolding Sep_def conn by metis
lemma Sep_Cl_diff: "Der_1b π’Ÿ ⟹ βˆ€A B. Cl(A) ∧ Cl(B) ⟢ Sep (A β†Ό B) (B β†Ό A)" unfolding Sep_def using CD1b PD1 bottom_def diff_def meet_def by smt
lemma Sep_Op_diff: "Der_1b π’Ÿ ⟹ βˆ€A B. Op(A) ∧ Op(B) ⟢ Sep (A β†Ό B) (B β†Ό A)" proof - 
  assume der1b:"Der_1b π’Ÿ"
  { fix A B 
    from der1b have aux: "let M=─A ; N=─B in (Cl(M) ∧ Cl(N) ⟢ Sep (M β†Ό N) (N β†Ό M))" using Sep_Cl_diff by simp
    { assume "Op(A) ∧ Op(B)"
      hence "Cl(─A) ∧ Cl(─B)" using der1b ClOpdual by simp
      hence "Sep (─A β†Ό ─B) (─B β†Ό ─A)" using der1b aux unfolding conn by simp
      moreover have "(─A β†Ό ─B) β‰ˆ (B β†Ό A)" unfolding conn by auto
      moreover have "(─B β†Ό ─A) β‰ˆ (A β†Ό B)" unfolding conn by auto
      ultimately have "Sep (B β†Ό A) (A β†Ό B)" unfolding conn by simp
      hence "Sep (A β†Ό B) (B β†Ό A)" using Sep_comm by simp
    } hence "Op(A) ∧ Op(B) ⟢ Sep (A β†Ό B) (B β†Ό A)" by (rule impI)
  } thus ?thesis by simp
qed
lemma Sep_Cl: "βˆ€A B. Cl(A) ∧ Cl(B) ∧ Disj A B ⟢ Sep A B" unfolding Sep_def conn by blast
lemma Sep_Op: "Der_1b π’Ÿ  ⟹ βˆ€A B. Op(A) ∧ Op(B) ∧ Disj A B ⟢ Sep A B" proof -
  assume der1b:"Der_1b π’Ÿ"
  { fix A B 
    from der1b have aux: "Op(A) ∧ Op(B) ⟢ Sep (A β†Ό B) (B β†Ό A)" using Sep_Op_diff by simp
    { assume op: "Op(A) ∧ Op(B)" and disj: "Disj A B"
      hence "(A β†Ό B) β‰ˆ A ∧ (B β†Ό A) β‰ˆ B" unfolding conn by blast
      hence "Sep A B" using op aux unfolding conn by simp
    } hence "Op(A) ∧ Op(B) ∧ Disj A B ⟢ Sep A B" by simp
  } thus ?thesis by simp
qed
lemma "Der_1a π’Ÿ ⟹ βˆ€A B C. Sep A B ∧ Sep A C ⟢ Sep A (B ∨ C)" using ADDI_a_def CD1a unfolding Sep_def conn by metis


textβ€Ή\noindent{Verifies a neighborhood-based definition of interior.}β€Ί
definition "nbhd A p ≑ βˆƒE. E β‰Ό A ∧ Op(E) ∧ (E p)"
lemma nbhd_def2: "Der_1 π’Ÿ ⟹ Der_4e π’Ÿ ⟹ βˆ€A p. (nbhd A p) = (ℐ A p)" unfolding nbhd_def by (smt Int_Open MONO_def PC1 monI pI2 conn)

lemma I_def'_lr': "βˆ€A p. (ℐ A p) ⟢ (βˆƒE. (ℐ E p) ∧ E β‰Ό A)" by blast
lemma I_def'_rl': "Der_1b π’Ÿ ⟹ βˆ€A p. (ℐ A p) ⟡ (βˆƒE. (ℐ E p) ∧ E β‰Ό A)" using MONO_def monI by metis
lemma I_def': "Der_1b π’Ÿ ⟹  βˆ€A p. (ℐ A p) ⟷ (βˆƒE. (ℐ E p) ∧ E β‰Ό A)" using MONO_def monI by metis


textβ€Ή\noindent{Explore the Barcan and converse Barcan formulas.}β€Ί
lemma Barcan_I: "Der_inf π’Ÿ ⟹ βˆ€P. (βˆ€x. ℐ(P x)) β‰Ό ℐ(βˆ€x. P x)" using ID_inf Barcan1 by auto
lemma Barcan_C: "Der_inf π’Ÿ ⟹ βˆ€P. π’ž(βˆƒx. P x) β‰Ό (βˆƒx. π’ž(P x))" using CD_inf Barcan2 by metis
lemma CBarcan_I: "Der_1b π’Ÿ ⟹ βˆ€P. ℐ(βˆ€x. P x)  β‰Ό (βˆ€x. ℐ(P x))" by (metis (mono_tags, lifting) MONO_def monI)
lemma CBarcan_C: "Der_1b π’Ÿ ⟹ βˆ€P. (βˆƒx. π’ž(P x)) β‰Ό π’ž(βˆƒx. P x)"  by (metis (mono_tags, lifting) MONO_def monC)

end