Theory MSOinHOL_experiments_extra

theory MSOinHOL_experiments_extra
  imports
    MSOinHOL_deep
    MSOinHOL_shallow
    MSOinHOL_shallow_minimal
begin

text ‹Additional MSO landmarks complementing the experiments in
  @{text MSOinHOL_experiments_classic}: 3-colorability, vertex cover,
  transitivity, symmetry and triangle existence, each replicated across
  the deep, maximal-shallow and minimal-shallow embeddings.›

abbreviation "(x::V)  1"
abbreviation "(y::V)  2"
abbreviation "(z::V)  3"
abbreviation "(u::V)  4"
abbreviation "(v::V)  5"
abbreviation "(X::V2)  1"
abbreviation "(Y::V2)  2"
abbreviation "(Z::V2)  3"

consts P :: R

subsubsection ‹Deep embedding (under @{text "⊨d'"})›

text ‹3-colorability (Thomas 1997): refuted on @{text ‹K4}
  (the complete graph on four vertices, which needs four colors).
  Generalisation of @{text two_colorability_not_valid_d}.›

lemma three_colorability_not_valid_d:
  "d' (d2X. d2Y. d2Z. ((du. (Xd(u) d Yd(u) d Zd(u))) d (du. dv. (Pd(u,v) d ((¬d (Xd(u) d Xd(v))) d (¬d (Yd(u) d Yd(v))) d (¬d (Zd(u) d Zd(v))))))))"
  unfolding DefD apply simp nitpick oops

text ‹Vertex cover existence: the predicate @{text Univ} is a witness, so
  the schema is universally valid.›

lemma vertex_cover_valid_d:
  "d' (d2X. du. dv. (Pd(u,v) d (Xd(u) d Xd(v))))"
  unfolding DefD
  apply (intro allI, simp add: SetMod_def EnvMod_def)
  by (rule exI[of _ "Univ"]) (auto simp: SetMod_def EnvMod_def)

text ‹Transitivity of @{text P}: not universally valid; refuted by any
  3-path @{text ‹a → b → c›} without the closing edge @{text ‹a → c›}.›

lemma transitivity_not_valid_d:
  "d' (dx. dy. dz. (Pd(x,y) d (Pd(y,z) d Pd(x,z))))"
  unfolding DefD apply simp nitpick oops

text ‹Symmetric extension: stating @{text P} is symmetric is also not
  universally valid; refuted by any directed edge without its converse.›

lemma symmetry_not_valid_d:
  "d' (dx. dy. (Pd(x,y) d Pd(y,x)))"
  unfolding DefD apply simp nitpick oops

text ‹Existence of a triangle: not universally valid; refuted on any
  triangle-free graph (e.g. the empty graph).›

lemma triangle_exists_not_valid_d:
  "d' (dx. dy. dz. (Pd(x,y) d Pd(y,z) d Pd(x,z)))"
  unfolding DefD apply simp nitpick oops

text ‹Existence of an edge: refuted on the empty graph.›

lemma has_edge_not_valid_d:
  "d' (dx. dy. Pd(x,y))"
  unfolding DefD apply simp nitpick oops

text ‹Loop-freeness: stating @{text P} has no self-loops is refuted by any
  graph with a fixed point.›

lemma loop_free_not_valid_d:
  "d' (dx. ¬d Pd(x,x))"
  unfolding DefD apply simp nitpick oops

subsubsection ‹Maximal-shallow embedding (under @{text "⊨s'"})›

lemma three_colorability_not_valid_s:
  "s' (s2X. s2Y. s2Z. ((su. (Xs(u) s Ys(u) s Zs(u))) s (su. sv. (Ps(u,v) s ((¬s (Xs(u) s Xs(v))) s (¬s (Ys(u) s Ys(v))) s (¬s (Zs(u) s Zs(v))))))))"
  unfolding DefS apply (intro allI) apply simp nitpick oops

lemma vertex_cover_valid_s:
  "s' (s2X. su. sv. (Ps(u,v) s (Xs(u) s Xs(v))))"
  unfolding DefS
  apply (intro allI, simp)
  by (rule exI[of _ "Univ"]) auto

lemma transitivity_not_valid_s:
  "s' (sx. sy. sz. (Ps(x,y) s (Ps(y,z) s Ps(x,z))))"
  unfolding DefS apply (intro allI) apply simp nitpick oops

lemma symmetry_not_valid_s:
  "s' (sx. sy. (Ps(x,y) s Ps(y,x)))"
  unfolding DefS apply (intro allI) apply simp nitpick oops

lemma triangle_exists_not_valid_s:
  "s' (sx. sy. sz. (Ps(x,y) s Ps(y,z) s Ps(x,z)))"
  unfolding DefS apply (intro allI) apply simp nitpick oops

lemma has_edge_not_valid_s:
  "s' (sx. sy. Ps(x,y))"
  unfolding DefS apply (intro allI) apply simp nitpick oops

lemma loop_free_not_valid_s:
  "s' (sx. ¬s Ps(x,x))"
  unfolding DefS apply (intro allI) apply simp nitpick oops

subsubsection ‹Minimal-shallow embedding (under @{text "⊨m"})›

text ‹In the minimal embedding the second-order existential ranges over
  the (countable) assignment range, so even formulae that hold under the
  full second-order domain (such as vertex cover) need not hold here.
  @{text nitpick} can certify a POTENTIAL countermodel only.›

lemma three_colorability_not_valid_m:
  "m (m2X. m2Y. m2Z. ((mu. (Xm(u) m Ym(u) m Zm(u))) m (mu. mv. (Pm(u,v) m ((¬m (Xm(u) m Xm(v))) m (¬m (Ym(u) m Ym(v))) m (¬m (Zm(u) m Zm(v))))))))"
  unfolding DefM nitpick[expect=potential] oops

lemma vertex_cover_not_valid_m:
  "m (m2X. mu. mv. (Pm(u,v) m (Xm(u) m Xm(v))))"
  unfolding DefM oops

text ‹Explicit refutability of the vertex-cover schema in the minimal
  embedding: with @{text II} interpreting @{text P} as the complete
  relation and @{text GG} mapping every symbol to the empty set, no
  symbol-indexed @{text X} can cover any edge.›

lemma vertex_cover_refutable_m:
  "(II'::) (gg'::) (GG'::𝒢).
     ¬ (X. u. v. II' P (gg' u) (gg' v)  (GG' X) (gg' u)  (GG' X) (gg' v))"
  by (rule exI[of _ "λr a b. True"],
      rule exI[of _ "λ_. undefined"],
      rule exI[of _ "λZ d. False"]) simp

lemma transitivity_not_valid_m:
  "m (mx. my. mz. (Pm(x,y) m (Pm(y,z) m Pm(x,z))))"
  unfolding DefM nitpick oops

lemma symmetry_not_valid_m:
  "m (mx. my. (Pm(x,y) m Pm(y,x)))"
  unfolding DefM nitpick oops

lemma triangle_exists_not_valid_m:
  "m (mx. my. mz. (Pm(x,y) m Pm(y,z) m Pm(x,z)))"
  unfolding DefM oops

text ‹Explicit refutability: with @{text II} interpreting @{text P} as
  the empty relation no triangle can exist.›

lemma triangle_exists_refutable_m:
  "(II'::) (gg'::).
     ¬ (x. y. z. II' P (gg' x) (gg' y)  II' P (gg' y) (gg' z)  II' P (gg' x) (gg' z))"
  by (rule exI[of _ "λr a b. False"], rule exI[of _ "λ_. undefined"]) simp

lemma has_edge_not_valid_m:
  "m (mx. my. Pm(x,y))"
  unfolding DefM nitpick oops

lemma loop_free_not_valid_m:
  "m (mx. ¬m Pm(x,x))"
  unfolding DefM nitpick oops

end