Theory CZH_DG_Small_Digraph

(* Copyright 2021 (C) Mihails Milehins *)

section‹Smallness for digraphs›
theory CZH_DG_Small_Digraph
  imports CZH_DG_Digraph
begin



subsection‹Background›

named_theorems dg_small_cs_simps
named_theorems dg_small_cs_intros



subsection‹Tiny digraph›


subsubsection‹Definition and elementary properties›

locale tiny_digraph = 𝒵 α + vfsequence  + Dom: vsv Dom + Cod: vsv Cod 
  for α  +
  assumes tiny_dg_length[dg_cs_simps]: "vcard  = 4"  
    and tiny_dg_Dom_vdomain[dg_cs_simps]: "𝒟 (Dom) = Arr"    
    and tiny_dg_Dom_vrange: " (Dom)  Obj"
    and tiny_dg_Cod_vdomain[dg_cs_simps]: "𝒟 (Cod) = Arr"
    and tiny_dg_Cod_vrange: " (Cod)  Obj"
    and tiny_dg_Obj_in_Vset[dg_small_cs_intros]: "Obj  Vset α"
    and tiny_dg_Arr_in_Vset[dg_small_cs_intros]: "Arr  Vset α"

lemmas [dg_small_cs_intros] = 
  tiny_digraph.tiny_dg_Obj_in_Vset
  tiny_digraph.tiny_dg_Arr_in_Vset


text‹Rules.›

lemma (in tiny_digraph) tiny_digraph_axioms'[dg_small_cs_intros]:
  assumes "α' = α"
  shows "tiny_digraph α' "
  unfolding assms by (rule tiny_digraph_axioms)

mk_ide rf tiny_digraph_def[unfolded tiny_digraph_axioms_def]
  |intro tiny_digraphI|
  |dest tiny_digraphD[dest]|
  |elim tiny_digraphE[elim]|

lemma tiny_digraphI':
  assumes "digraph α " and "Obj  Vset α" and "Arr  Vset α"
  shows "tiny_digraph α "
  using assms by (meson digraphD(5,6,7,8,9) digraph_def tiny_digraphI)


text‹Elementary properties.›

sublocale tiny_digraph  digraph 
proof(rule digraphI)
  from tiny_dg_Obj_in_Vset show "Obj  Vset α" by auto
  fix A B assume "A  Obj" "B  Obj" "A  Vset α" "B  Vset α" 
  then have "(aA. bB. Hom  a b)  Arr" by auto
  with tiny_dg_Arr_in_Vset show "(aA. bB. Hom  a b)  Vset α" by blast
qed 
  (
    cs_concl cs_shallow
      cs_simp: dg_cs_simps  
      cs_intro: tiny_dg_Cod_vrange tiny_dg_Dom_vrange dg_cs_intros V_cs_intros
  )+

lemmas (in tiny_digraph) tiny_dg_digraph = digraph_axioms

lemmas [dg_small_cs_intros] = tiny_digraph.tiny_dg_digraph


text‹Size.›

lemma (in tiny_digraph) tiny_dg_Dom_in_Vset: "Dom  Vset α"
proof-
  from 𝒵_Limit_αω have "𝒟 (Dom)  Vset α"  
    by (simp add: tiny_dg_Arr_in_Vset dg_cs_simps)
  moreover from tiny_dg_Dom_vrange have " (Dom)  Vset α" 
    by (auto intro: tiny_dg_Obj_in_Vset)
  ultimately show ?thesis 
    by (simp add: Dom.vbrelation_Limit_in_VsetI 𝒵_Limit_αω)
qed

lemma (in tiny_digraph) tiny_dg_Cod_in_Vset: "Cod  Vset α"
proof-
  from 𝒵_Limit_αω have "𝒟 (Cod)  Vset α"  
    by (simp add: tiny_dg_Arr_in_Vset dg_cs_simps)
  moreover from tiny_dg_Cod_vrange have " (Cod)  Vset α" 
    by (auto intro: tiny_dg_Obj_in_Vset)
  ultimately show ?thesis 
    by (simp add: Cod.vbrelation_Limit_in_VsetI 𝒵_Limit_αω)
qed

lemma (in tiny_digraph) tiny_dg_in_Vset: "  Vset α"
proof-
  note [dg_cs_intros] = 
    tiny_dg_Obj_in_Vset 
    tiny_dg_Arr_in_Vset
    tiny_dg_Dom_in_Vset
    tiny_dg_Cod_in_Vset
  show ?thesis
    by (subst dg_def) (cs_concl cs_shallow cs_intro: dg_cs_intros V_cs_intros)
qed

lemma small_tiny_digraphs[simp]: "small {. tiny_digraph α }"
proof(rule down)
  show "{. tiny_digraph α }  elts (set {. digraph α })" 
    by (auto intro: dg_small_cs_intros)
qed

lemma tiny_digraphs_vsubset_Vset: "set {. tiny_digraph α }  Vset α"
  by (rule vsubsetI) (simp add: tiny_digraph.tiny_dg_in_Vset)

lemma (in digraph) dg_tiny_digraph_if_ge_Limit:
  assumes "𝒵 β" and "α  β"
  shows "tiny_digraph β "
proof(intro tiny_digraphI')
  interpret β: 𝒵 β by (rule assms(1))
  show "digraph β "
    by (intro dg_digraph_if_ge_Limit)
      (use assms(2) in cs_concl cs_shallow cs_intro: dg_cs_intros)+
  show "Obj  Vset β" "Arr  Vset β" 
    by (auto simp: β.𝒵_β assms(2) dg_Obj_in_Vset dg_Arr_in_Vset)
qed


subsubsection‹Opposite tiny digraph›

lemma (in tiny_digraph) tiny_digraph_op: "tiny_digraph α (op_dg )"
  by (intro tiny_digraphI', unfold dg_op_simps)
    (auto simp: tiny_dg_Obj_in_Vset tiny_dg_Arr_in_Vset dg_cs_simps dg_op_intros)

lemmas tiny_digraph_op[dg_op_intros] = tiny_digraph.tiny_digraph_op



subsection‹Finite digraph›


subsubsection‹Definition and elementary properties›


text‹
A finite digraph 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_digraph = digraph α  for α  +
  assumes fin_dg_Obj_vfinite[dg_small_cs_intros]: "vfinite (Obj)"
    and fin_dg_Arr_vfinite[dg_small_cs_intros]: "vfinite (Arr)"

lemmas [dg_small_cs_intros] = 
  finite_digraph.fin_dg_Obj_vfinite
  finite_digraph.fin_dg_Arr_vfinite


text‹Rules.›

lemma (in finite_digraph) finite_digraph_axioms'[dg_small_cs_intros]:
  assumes "α' = α"
  shows "finite_digraph α' "
  unfolding assms by (rule finite_digraph_axioms)

mk_ide rf finite_digraph_def[unfolded finite_digraph_axioms_def]
  |intro finite_digraphI|
  |dest finite_digraphD[dest]|
  |elim finite_digraphE[elim]|


text‹Elementary properties.›

sublocale finite_digraph  tiny_digraph 
proof(rule tiny_digraphI')
  show "Obj  Vset α"
    by
      (
        cs_concl cs_shallow cs_intro: 
          dg_small_cs_intros V_cs_intros 
          dg_Obj_vsubset_Vset Limit_vfinite_in_VsetI
      )
  show "Arr  Vset α"
    by 
      (
        cs_concl cs_shallow cs_intro: 
          dg_small_cs_intros V_cs_intros 
          dg_Arr_vsubset_Vset Limit_vfinite_in_VsetI
      )
qed (auto intro: dg_cs_intros)

lemmas (in finite_digraph) fin_dg_tiny_digraph = tiny_digraph_axioms

lemmas [dg_small_cs_intros] = finite_digraph.fin_dg_tiny_digraph


text‹Size.›

lemma small_finite_digraphs[simp]: "small {. finite_digraph α }"
proof(rule down)
  show "{. finite_digraph α }  elts (set {. digraph α })" 
    by (auto intro: dg_cs_intros)
qed 

lemma finite_digraphs_vsubset_Vset: "set {. finite_digraph α }  Vset α"
  by 
    (
      force simp: 
        tiny_digraph.tiny_dg_in_Vset finite_digraph.fin_dg_tiny_digraph
    )


subsubsection‹Opposite finite digraph›

lemma (in finite_digraph) fininte_digraph_op: "finite_digraph α (op_dg )"
  by (intro finite_digraphI, unfold dg_op_simps)
    (auto simp: dg_small_cs_intros dg_op_intros)

lemmas fininte_digraph_op[dg_op_intros] = finite_digraph.fininte_digraph_op

text‹\newpage›

end