Theory CZH_SMC_Small_Semicategory

(* Copyright 2021 (C) Mihails Milehins *)

section‹Smallness for semicategories›
theory CZH_SMC_Small_Semicategory
  imports 
    CZH_DG_Small_Digraph
    CZH_SMC_Semicategory
begin



subsection‹Background›


text‹
An explanation of the methodology chosen for the exposition of all
matters related to the size of the semicategories and associated entities
is given in the previous chapter.
›

named_theorems smc_small_cs_simps
named_theorems smc_small_cs_intros



subsection‹Tiny semicategory›


subsubsection‹Definition and elementary properties›

locale tiny_semicategory = 𝒵 α + vfsequence  + Comp: vsv Comp for α  +
  assumes tiny_smc_length[smc_cs_simps]: "vcard  = 5"
    and tiny_smc_tiny_digraph[slicing_intros]: "tiny_digraph α (smc_dg )"
    and tiny_smc_Comp_vdomain: "gf  𝒟 (Comp) 
      (g f b c a. gf = [g, f]  g : b c  f : a b)"
    and tiny_smc_Comp_is_arr[smc_cs_intros]: 
      " g : b c; f : a b   g Af : a c"
    and tiny_smc_assoc[smc_cs_simps]:
      " h : c d; g : b c; f : a b  
        (h Ag) Af = h A(g Af)"

lemmas [smc_cs_simps] = 
  tiny_semicategory.tiny_smc_length
  tiny_semicategory.tiny_smc_assoc

lemmas [slicing_intros] = 
  tiny_semicategory.tiny_smc_Comp_is_arr


text‹Rules.›

lemma (in tiny_semicategory) tiny_semicategory_axioms'[smc_small_cs_intros]:
  assumes "α' = α"
  shows "tiny_semicategory α' "
  unfolding assms by (rule tiny_semicategory_axioms)

mk_ide rf tiny_semicategory_def[unfolded tiny_semicategory_axioms_def]
  |intro tiny_semicategoryI|
  |dest tiny_semicategoryD[dest]|
  |elim tiny_semicategoryE[elim]|

lemma tiny_semicategoryI': 
  assumes "semicategory α " and "Obj  Vset α" and "Arr  Vset α"
  shows "tiny_semicategory α "
proof-
  interpret semicategory α  by (rule assms(1))
  show ?thesis
  proof(intro tiny_semicategoryI)
    show "vfsequence " by (simp add: vfsequence_axioms)
    from assms show "tiny_digraph α (smc_dg )"
      by (intro tiny_digraphI') (auto simp: slicing_simps)
  qed (auto simp: smc_cs_simps intro: smc_cs_intros)
qed

lemma tiny_semicategoryI'':
  assumes "𝒵 α"
    and "vfsequence "
    and "vsv (Comp)"
    and "vcard  = 5"
    and "vsv (Dom)"
    and "vsv (Cod)"
    and "𝒟 (Dom) = Arr"
    and " (Dom)  Obj"
    and "𝒟 (Cod) = Arr"
    and " (Cod)  Obj"
    and "gf. gf  𝒟 (Comp) 
      (g f b c a. gf = [g, f]  g : b c  f : a b)"
    and "b c g a f.  g : b c; f : a b   g Af : a c"
    and "c d h b g a f.  h : c d; g : b c; f : a b  
        (h Ag) Af = h A(g Af)"
    and "Obj  Vset α" 
    and "Arr  Vset α"
  shows "tiny_semicategory α "
  by (intro tiny_semicategoryI tiny_digraphI, unfold slicing_simps) 
    (simp_all add: smc_dg_def nat_omega_simps assms)


text‹Slicing.›

context tiny_semicategory
begin

interpretation dg: tiny_digraph α smc_dg  by (rule tiny_smc_tiny_digraph)

lemmas_with [unfolded slicing_simps]:
  tiny_smc_Obj_in_Vset[smc_small_cs_intros] = dg.tiny_dg_Obj_in_Vset
  and tiny_smc_Arr_in_Vset[smc_small_cs_intros] = dg.tiny_dg_Arr_in_Vset
  and tiny_smc_Dom_in_Vset[smc_small_cs_intros] = dg.tiny_dg_Dom_in_Vset
  and tiny_smc_Cod_in_Vset[smc_small_cs_intros] = dg.tiny_dg_Cod_in_Vset

end


text‹Elementary properties.›

sublocale tiny_semicategory  semicategory
  by (rule semicategoryI)
    (
      auto 
        simp: 
          vfsequence_axioms
          tiny_digraph.tiny_dg_digraph 
          tiny_smc_tiny_digraph
          tiny_smc_Comp_vdomain         
        intro: smc_cs_intros smc_cs_simps 
    )

lemmas (in tiny_semicategory) tiny_smc_semicategory = semicategory_axioms

lemmas [smc_small_cs_intros] = tiny_semicategory.tiny_smc_semicategory


text‹Size.›

lemma (in tiny_semicategory) tiny_smc_Comp_in_Vset: "Comp  Vset α"
proof-
  have "Arr  Vset α" by (simp add: tiny_smc_Arr_in_Vset)
  with Axiom_of_Infinity have "Arr ^× 2  Vset α" 
    by (intro Limit_vcpower_in_VsetI) auto
  with Comp.pnop_vdomain have D: "𝒟 (Comp)  Vset α" by auto
  moreover from tiny_smc_Arr_in_Vset smc_Comp_vrange have 
    " (Comp)  Vset α"
    by auto
  ultimately show ?thesis by (simp add: Comp.vbrelation_Limit_in_VsetI)
qed

lemma (in tiny_semicategory) tiny_smc_in_Vset: "  Vset α"
proof-
  note [smc_cs_intros] = 
    tiny_smc_Obj_in_Vset 
    tiny_smc_Arr_in_Vset
    tiny_smc_Dom_in_Vset
    tiny_smc_Cod_in_Vset
    tiny_smc_Comp_in_Vset
  show ?thesis 
    by (subst smc_def) (cs_concl cs_shallow cs_intro: smc_cs_intros V_cs_intros)
qed

lemma small_tiny_semicategories[simp]: "small {. tiny_semicategory α }"
proof(rule down)
  show "{. tiny_semicategory α }  elts (set {. semicategory α })" 
    by (auto intro: smc_small_cs_intros)
qed

lemma tiny_semicategories_vsubset_Vset: 
  "set {. tiny_semicategory α }  Vset α" 
  by (rule vsubsetI) (simp add: tiny_semicategory.tiny_smc_in_Vset)

lemma (in semicategory) smc_tiny_semicategory_if_ge_Limit:
  assumes "𝒵 β" and "α  β"
  shows "tiny_semicategory β "
proof(intro tiny_semicategoryI)
  show "tiny_digraph β (smc_dg )"
    by (rule digraph.dg_tiny_digraph_if_ge_Limit, rule smc_digraph; intro assms)
qed 
  (
    auto simp: 
      assms(1)
      smc_cs_simps 
      smc_cs_intros 
      smc_digraph digraph.dg_tiny_digraph_if_ge_Limit 
      smc_Comp_vdomain vfsequence_axioms
  )


subsubsection‹Opposite tiny semicategory›

lemma (in tiny_semicategory) tiny_semicategory_op: 
  "tiny_semicategory α (op_smc )"
  by (intro tiny_semicategoryI', unfold smc_op_simps)
    (auto simp: smc_op_intros smc_small_cs_intros)

lemmas tiny_semicategory_op[smc_op_intros] = 
  tiny_semicategory.tiny_semicategory_op



subsection‹Finite semicategory›


subsubsection‹Definition and elementary properties›


text‹
A finite semicategory is a generalization of the concept of a finite category,
as presented in nLab 
cite"noauthor_nlab_nodate"
\footnote{\url{https://ncatlab.org/nlab/show/finite+category}}.
›

locale finite_semicategory = 𝒵 α + vfsequence  + Comp: vsv Comp for α  +
  assumes fin_smc_length[smc_cs_simps]: "vcard  = 5"
    and fin_smc_finite_digraph[slicing_intros]: "finite_digraph α (smc_dg )"
    and fin_smc_Comp_vdomain: "gf  𝒟 (Comp) 
      (g f b c a. gf = [g, f]  g : b c  f : a b)"
    and fin_smc_Comp_is_arr[smc_cs_intros]: 
      " g : b c; f : a b   g Af : a c"
    and fin_smc_assoc[smc_cs_simps]:
      " h : c d; g : b c; f : a b  
        (h Ag) Af = h A(g Af)"

lemmas [smc_cs_simps] = 
  finite_semicategory.fin_smc_length
  finite_semicategory.fin_smc_assoc

lemmas [slicing_intros] = 
  finite_semicategory.fin_smc_Comp_is_arr


text‹Rules.›

lemma (in finite_semicategory) finite_semicategory_axioms'[smc_small_cs_intros]:
  assumes "α' = α"
  shows "finite_semicategory α' "
  unfolding assms by (rule finite_semicategory_axioms)

mk_ide rf finite_semicategory_def[unfolded finite_semicategory_axioms_def]
  |intro finite_semicategoryI|
  |dest finite_semicategoryD[dest]|
  |elim finite_semicategoryE[elim]|

lemma finite_semicategoryI': 
  assumes "semicategory α " and "vfinite (Obj)" and "vfinite (Arr)"
  shows "finite_semicategory α "
proof-
  interpret semicategory α  by (rule assms(1))
  show ?thesis
  proof(intro finite_semicategoryI)
    show "vfsequence " by (simp add: vfsequence_axioms)
    from assms show "finite_digraph α (smc_dg )"
      by (intro finite_digraphI) (auto simp: slicing_simps)
  qed (auto simp: smc_cs_simps intro: smc_cs_intros)
qed

lemma finite_semicategoryI'': 
  assumes "tiny_semicategory α " and "vfinite (Obj)" and "vfinite (Arr)"
  shows "finite_semicategory α "
  using assms by (intro finite_semicategoryI') 
    (auto intro: smc_cs_intros smc_small_cs_intros)


text‹Slicing.›

context finite_semicategory
begin

interpretation dg: finite_digraph α smc_dg  by (rule fin_smc_finite_digraph)

lemmas_with [unfolded slicing_simps]:
  fin_smc_Obj_vfinite[smc_small_cs_intros] = dg.fin_dg_Obj_vfinite
  and fin_smc_Arr_vfinite[smc_small_cs_intros] = dg.fin_dg_Arr_vfinite

end


text‹Elementary properties.›

sublocale finite_semicategory  tiny_semicategory
  by (rule tiny_semicategoryI)
    (
      auto simp: 
        vfsequence_axioms
        fin_smc_Comp_vdomain         
        fin_smc_finite_digraph 
        finite_digraph.fin_dg_tiny_digraph
        intro: smc_cs_intros smc_cs_simps 
    )

lemmas (in finite_semicategory) fin_smc_tiny_semicategory = 
  tiny_semicategory_axioms

lemmas [smc_small_cs_intros] = finite_semicategory.fin_smc_tiny_semicategory

lemma (in finite_semicategory) fin_smc_in_Vset: "  Vset α"
  by (rule tiny_smc_in_Vset)


text‹Size.›

lemma small_finite_semicategories[simp]: "small {. finite_semicategory α }"
proof(rule down)
  show "{. finite_semicategory α }  elts (set {. semicategory α })" 
    by (auto intro: smc_small_cs_intros)
qed

lemma finite_semicategories_vsubset_Vset: 
  "set {. finite_semicategory α }  Vset α" 
  by (rule vsubsetI) (simp add: finite_semicategory.fin_smc_in_Vset)
 

subsubsection‹Opposite finite semicategory›

lemma (in finite_semicategory) finite_semicategory_op: 
  "finite_semicategory α (op_smc )"
  by (intro finite_semicategoryI', unfold smc_op_simps)
    (auto simp: smc_op_intros smc_small_cs_intros)

lemmas finite_semicategory_op[smc_op_intros] = 
  finite_semicategory.finite_semicategory_op

text‹\newpage›

end