Theory CZH_DG_Simple

(* Copyright 2021 (C) Mihails Milehins *)

section‹Simple digraphs›
theory CZH_DG_Simple
  imports CZH_DG_TDGHM
begin



subsection‹Background›


text‹
The section presents a variety of simple digraphs, such as the empty digraph 0›
and a digraph with one object and one arrow 1›. All of the entities 
presented in this section are generalizations of certain simple categories,
whose definitions can be found in cite"mac_lane_categories_2010".
›



subsection‹Empty digraph 0›


subsubsection‹Definition and elementary properties›


text‹See Chapter I-2 in cite"mac_lane_categories_2010".›

definition dg_0 :: V
  where "dg_0 = [0, 0, 0, 0]"


text‹Components.›

lemma dg_0_components:
  shows "dg_0Obj = 0"
    and "dg_0Arr = 0"
    and "dg_0Dom = 0"
    and "dg_0Cod = 0"
  unfolding dg_0_def dg_field_simps by (simp_all add: nat_omega_simps)


subsubsection0› is a digraph›

lemma (in 𝒵) digraph_dg_0[dg_cs_intros]: "digraph α dg_0"
proof(intro digraphI)
  show "vfsequence dg_0" unfolding dg_0_def by (simp add: nat_omega_simps)
  show "vcard dg_0 = 4" unfolding dg_0_def by (simp add: nat_omega_simps)
qed (auto simp: dg_0_components)

lemmas [dg_cs_intros] = 𝒵.digraph_dg_0


subsubsection‹Opposite of the digraph 0›

lemma op_dg_dg_0[dg_op_simps]: "op_dg (dg_0) = dg_0"
proof(rule dg_eqI, unfold dg_op_simps)
  define β where "β = ω + ω"
  interpret β: 𝒵 β unfolding β_def by (rule 𝒵_ωω)
  show "digraph β (op_dg dg_0)"
    by (cs_concl cs_shallow cs_intro: dg_cs_intros dg_op_intros)
  show "digraph β dg_0" by (cs_concl cs_shallow cs_intro: dg_cs_intros)
qed (simp_all add: dg_0_components op_dg_components)


subsubsection‹Arrow with a domain and a codomain›

lemma dg_0_is_arr_iff[simp]: "𝔉 : 𝔄 dg_0𝔅  False" 
  by (rule iffI; (elim is_arrE)?) (auto simp: dg_0_components)


subsubsection‹A digraph without objects is empty›

lemma (in digraph) dg_dg_0_if_Obj_0:
  assumes "Obj = 0"
  shows " = dg_0"
  by (rule dg_eqI[of α])
    (
      auto simp:
        dg_cs_intros
        assms
        digraph_dg_0 
        dg_0_components 
        dg_Arr_vempty_if_Obj_vempty 
        dg_Cod_vempty_if_Arr_vempty 
        dg_Dom_vempty_if_Arr_vempty
    )



subsection‹Empty digraph homomorphism›


subsubsection‹Definition and elementary properties›

definition dghm_0 :: "V  V"
  where "dghm_0 𝔄 = [0, 0, dg_0, 𝔄]"


text‹Components.›

lemma dghm_0_components:
  shows "dghm_0 𝔄ObjMap = 0"
    and "dghm_0 𝔄ArrMap = 0"
    and "dghm_0 𝔄HomDom = dg_0"
    and "dghm_0 𝔄HomCod = 𝔄"
  unfolding dghm_0_def dghm_field_simps by (simp_all add: nat_omega_simps)


text‹Opposite empty digraph homomorphism.›

lemma op_dghm_dghm_0: "op_dghm (dghm_0 ) = dghm_0 (op_dg )"
  unfolding 
    dghm_0_def op_dg_def op_dghm_def dg_0_def dghm_field_simps dg_field_simps
  by (simp add: nat_omega_simps)


subsubsection‹Object map›

lemma dghm_0_ObjMap_vsv[dg_cs_intros]: "vsv (dghm_0 ObjMap)"
  unfolding dghm_0_components by simp


subsubsection‹Arrow map›

lemma dghm_0_ArrMap_vsv[dg_cs_intros]: "vsv (dghm_0 ArrMap)"
  unfolding dghm_0_components by simp


subsubsection‹Empty digraph homomorphism is a faithful digraph homomorphism›

lemma (in 𝒵) dghm_0_is_ft_dghm: 
  assumes "digraph α 𝔄"
  shows "dghm_0 𝔄 : dg_0 ↦↦DG.faithfulα𝔄"
proof(rule is_ft_dghmI)
  show "dghm_0 𝔄 : dg_0 ↦↦DGα𝔄"
  proof(rule is_dghmI)
    show "vfsequence (dghm_0 𝔄)" unfolding dghm_0_def by simp
    show "vcard (dghm_0 𝔄) = 4"
      unfolding dghm_0_def by (simp add: nat_omega_simps)
  qed (auto simp: assms digraph_dg_0 dghm_0_components dg_0_components)
qed (auto simp: dg_0_components dghm_0_components)

lemma (in 𝒵) dghm_0_is_ft_dghm'[dghm_cs_intros]:
  assumes "digraph α 𝔄"
    and "𝔅' = 𝔄"
    and "𝔄' = dg_0"
  shows "dghm_0 𝔄 : 𝔄' ↦↦DG.faithfulα𝔅'"
  using assms(1) unfolding assms(2,3) by (rule dghm_0_is_ft_dghm)

lemmas [dghm_cs_intros] = 𝒵.dghm_0_is_ft_dghm'

lemma (in 𝒵) dghm_0_is_dghm: 
  assumes "digraph α 𝔄"
  shows "dghm_0 𝔄 : dg_0 ↦↦DGα𝔄"
  using dghm_0_is_ft_dghm[OF assms] by auto

lemma (in 𝒵) dghm_0_is_dghm'[dg_cs_intros]: 
  assumes "digraph α 𝔄"
    and "𝔅' = 𝔄"
    and "𝔄' = dg_0"
  shows "dghm_0 𝔄 : 𝔄' ↦↦DGα𝔅'"
  using assms(1) unfolding assms(2,3) by (rule dghm_0_is_dghm)

lemmas [dg_cs_intros] = 𝒵.dghm_0_is_dghm'


subsubsection‹Further properties›

lemma is_dghm_is_dghm_0_if_dg_0:
  assumes "𝔉 : dg_0 ↦↦DGα"
  shows "𝔉 = dghm_0 "
proof(rule dghm_eqI)
  interpret 𝔉: is_dghm α dg_0  𝔉 by (rule assms(1))
  show "𝔉 : dg_0 ↦↦DGα" by (rule assms(1))
  then have dom_lhs: "𝒟 (𝔉ObjMap) = 0" "𝒟 (𝔉ArrMap) = 0" 
    by (cs_concl cs_simp: dg_cs_simps dg_0_components)+
  show "dghm_0  : dg_0 ↦↦DGα" by (cs_concl cs_intro: dg_cs_intros)
  then have dom_rhs: "𝒟 (dghm_0 ObjMap) = 0" "𝒟 (dghm_0 ArrMap) = 0" 
    by (cs_concl cs_simp: dg_cs_simps dg_0_components)+
  show "𝔉ObjMap = dghm_0 ObjMap"
    by (rule vsv_eqI, unfold dom_lhs dom_rhs) (auto intro: dg_cs_intros)
  show "𝔉ArrMap = dghm_0 ArrMap"
    by (rule vsv_eqI, unfold dom_lhs dom_rhs) (auto intro: dg_cs_intros)
qed simp_all



subsection‹Empty transformation of digraph homomorphisms›


subsubsection‹Definition and elementary properties›

definition tdghm_0 :: "V  V" 
  where "tdghm_0  = [0, dghm_0 , dghm_0 , dg_0, ]"


text‹Components.›

lemma tdghm_0_components:
  shows "tdghm_0 NTMap = 0"
    and [dg_cs_simps]: "tdghm_0 NTDom = dghm_0 "
    and [dg_cs_simps]: "tdghm_0 NTCod = dghm_0 "
    and [dg_cs_simps]: "tdghm_0 NTDGDom = dg_0"
    and [dg_cs_simps]: "tdghm_0  NTDGCod = "
  unfolding tdghm_0_def nt_field_simps by (simp_all add: nat_omega_simps)


text‹Duality.›

lemma op_tdghm_tdghm_0: "op_tdghm (tdghm_0 ) = tdghm_0 (op_dg )"
  by
    (
      simp_all add:
        tdghm_0_def op_tdghm_def op_dg_def dg_0_def op_dghm_dghm_0 
        nt_field_simps dg_field_simps nat_omega_simps
    )


subsubsection‹Transformation map›

lemma tdghm_0_NTMap_vsv[dg_cs_intros]: "vsv (tdghm_0 NTMap)"
  unfolding tdghm_0_components by simp

lemma tdghm_0_NTMap_vdomain[dg_cs_simps]: "𝒟 (tdghm_0 NTMap) = 0"
  unfolding tdghm_0_components by simp

lemma tdghm_0_NTMap_vrange[dg_cs_simps]: " (tdghm_0 NTMap) = 0"
  unfolding tdghm_0_components by simp


subsubsection‹
Empty transformation of digraph homomorphisms
is a transformation of digraph homomorphisms
›

lemma (in digraph) dg_tdghm_0_is_tdghmI: 
  "tdghm_0  : dghm_0  DGHM dghm_0  : dg_0 ↦↦DGα"
proof(intro is_tdghmI)
  show "vfsequence (tdghm_0 )" unfolding tdghm_0_def by simp
  show "vcard (tdghm_0 ) = 5"
    unfolding tdghm_0_def by (simp add: nat_omega_simps)
  show "tdghm_0 NTMapa : dghm_0 ObjMapa dghm_0 ObjMapa"
    if "a  dg_0Obj" for a 
    using that unfolding dg_0_components by simp
qed 
  (
    cs_concl cs_shallow 
      cs_simp: dg_cs_simps dg_0_components(1) cs_intro: dg_cs_intros
  )+

lemma (in digraph) dg_tdghm_0_is_tdghmI'[dg_cs_intros]:
  assumes "𝔉' = dghm_0 "
    and "𝔊' = dghm_0 "
    and "𝔄' = dg_0"
    and "𝔅' = "
    and "𝔉' = 𝔉"
    and "𝔊' = 𝔊"
  shows "tdghm_0  : 𝔉' DGHM 𝔊' : 𝔄' ↦↦DGα𝔅'"
  unfolding assms by (rule dg_tdghm_0_is_tdghmI)

lemmas [dg_cs_intros] = digraph.dg_tdghm_0_is_tdghmI'

lemma is_tdghm_is_tdghm_0_if_dg_0:
  assumes "𝔑 : 𝔉 DGHM 𝔊 : dg_0 ↦↦DGα"
  shows "𝔑 = tdghm_0 " and "𝔉 = dghm_0 " and "𝔊 = dghm_0 "
proof-
  interpret 𝔑: is_tdghm α dg_0  𝔉 𝔊 𝔑 by (rule assms(1))
  show 𝔉_def: "𝔉 = dghm_0 " and 𝔊_def: "𝔊 = dghm_0 "
    by (auto intro: is_dghm_is_dghm_0_if_dg_0 dg_cs_intros)
  show "𝔑 = tdghm_0 "
  proof(rule tdghm_eqI)
    show "𝔑 : 𝔉 DGHM 𝔊 : dg_0 ↦↦DGα" by (rule assms(1))
    then have dom_lhs: "𝒟 (𝔑NTMap) = 0"
      by (cs_concl cs_simp: dg_cs_simps dg_0_components(1))
    show "tdghm_0  : dghm_0  DGHM dghm_0  : dg_0 ↦↦DGα"
      by (cs_concl cs_intro: dg_cs_intros)
    then have dom_rhs: "𝒟 (tdghm_0 NTMap) = 0"
      by (cs_concl cs_simp: dg_cs_simps dg_0_components(1))
    show "𝔑NTMap = tdghm_0 NTMap"
      by (rule vsv_eqI, unfold dom_lhs dom_rhs) (auto intro: dg_cs_intros)
  qed (auto simp: 𝔉_def 𝔊_def)
qed



subsection10›: digraph with one object and no arrows›


subsubsection‹Definition and elementary properties›

definition dg_10 :: "V  V"
  where "dg_10 𝔞 = [set {𝔞}, 0, 0, 0]"


text‹Components.›

lemma dg_10_components:
  shows "dg_10 𝔞Obj = set {𝔞}"
    and "dg_10 𝔞Arr = 0"
    and "dg_10 𝔞Dom = 0"
    and "dg_10 𝔞Cod = 0"
  unfolding dg_10_def dg_field_simps by (auto simp: nat_omega_simps)


subsubsection10› is a digraph›

lemma (in 𝒵) digraph_dg_10: 
  assumes "𝔞  Vset α" 
  shows "digraph α (dg_10 𝔞)"
proof(intro digraphI)
  show "vfsequence (dg_10 𝔞)" unfolding dg_10_def by (simp add: nat_omega_simps)
  show "vcard (dg_10 𝔞) = 4" unfolding dg_10_def by (simp add: nat_omega_simps)
  show "(a'A. b'B. Hom (dg_10 𝔞) a' b')  Vset α" for A B
  proof-
    have "(a'A. b'B. Hom (dg_10 𝔞) a' b')  dg_10 𝔞Arr" by auto
    moreover have "dg_10 𝔞Arr  0" unfolding dg_10_components by auto
    ultimately show ?thesis using vempty_is_zet vsubset_in_VsetI by presburger
  qed
qed (auto simp: assms dg_10_components vsubset_vsingleton_leftI)


subsubsection‹Arrow with a domain and a codomain›

lemma dg_10_is_arr_iff: "𝔉 : 𝔄 dg_10 𝔞𝔅  False"
  unfolding is_arr_def dg_10_components by simp



subsection1›: digraph with one object and one arrow›


subsubsection‹Definition and elementary properties›

definition dg_1 :: "V  V  V"
  where "dg_1 𝔞 𝔣 = [set {𝔞}, set {𝔣}, set {𝔣, 𝔞}, set {𝔣, 𝔞}]"


text‹Components.›

lemma dg_1_components:
  shows "dg_1 𝔞 𝔣Obj = set {𝔞}"
    and "dg_1 𝔞 𝔣Arr = set {𝔣}"
    and "dg_1 𝔞 𝔣Dom = set {𝔣, 𝔞}"
    and "dg_1 𝔞 𝔣Cod = set {𝔣, 𝔞}"
  unfolding dg_1_def dg_field_simps by (simp_all add: nat_omega_simps)


subsubsection1› is a digraph›

lemma (in 𝒵) digraph_dg_1: 
  assumes "𝔞  Vset α" and "𝔣  Vset α" 
  shows "digraph α (dg_1 𝔞 𝔣)"
proof(intro digraphI)
  show "vfsequence (dg_1 𝔞 𝔣)" unfolding dg_1_def by (simp add: nat_omega_simps)
  show "vcard (dg_1 𝔞 𝔣) = 4" unfolding dg_1_def by (simp add: nat_omega_simps)
  show "(a'A. b'B. Hom (dg_1 𝔞 𝔣) a' b')  Vset α" for A B
  proof-
    have "(a'A. b'B. Hom (dg_1 𝔞 𝔣) a' b')  dg_1 𝔞 𝔣Arr" by auto
    moreover have "dg_1 𝔞 𝔣Arr  set {𝔣}" unfolding dg_1_components by auto
    moreover from assms(2) have "set {𝔣}  Vset α" 
      by (simp add: Limit_vsingleton_in_VsetI)
    ultimately show ?thesis 
      unfolding dg_1_components by (auto simp: vsubset_in_VsetI)
  qed
qed (auto simp: assms dg_1_components vsubset_vsingleton_leftI)


subsubsection‹Arrow with a domain and a codomain›

lemma dg_1_is_arrI:
  assumes "a = 𝔞" and "b = 𝔞" and "f = 𝔣" 
  shows "f : a dg_1 𝔞 𝔣b"
  using assms by (intro is_arrI) (auto simp: dg_1_components)

lemma dg_1_is_arrD:
  assumes "f : a dg_1 𝔞 𝔣b"
  shows "a = 𝔞" and "b = 𝔞" and "f = 𝔣" 
  using assms by (allelim is_arrE) (auto simp: dg_1_components)

lemma dg_1_is_arrE:
  assumes "f : a dg_1 𝔞 𝔣b"
  obtains "a = 𝔞" and "b = 𝔞" and "f = 𝔣" 
  using assms by (elim is_arrE) (force simp: dg_1_components)

lemma dg_1_is_arr_iff: "f : a dg_1 𝔞 𝔣b  (a = 𝔞  b = 𝔞  f = 𝔣)" 
  by (rule iffI; (elim is_arrE)?) 
    (auto simp: dg_1_components intro: dg_1_is_arrI)

text‹\newpage›

end