@@ -2,9 +2,9 @@ import Mathlib.Algebra.FreeMonoid.Basic
22import Mathlib.Data.Fintype.Basic
33import Mathlib.Data.Finset.Basic
44import Mathlib.Data.List.Basic
5+ import Mathlib.Data.Set.Basic
56import Mathlib.Computability.Language
67import Mathlib.Logic.Relation
7- import Mathlib.Data.Set.Basic
88
99variable {α : Type *} [DecidableEq α]
1010-- An alphabet is a finite set of symbols / letters
@@ -1471,6 +1471,134 @@ theorem morphism_images_isomorphic (φ : I.DependencyMorphism M) (ψ : I.Depende
14711471 exact arbitrary_morphism_finer
14721472 exact ⟨monoidEquiv φ.hom ψ.hom φ.surj ψ.surj hM hN⟩
14731473
1474+ end Independency
14741475
1476+ namespace Dependency
14751477
1476- end Independency
1478+ variable {α : Type } [Fintype α] {D : Dependency α}
1479+ variable {V : Type } [Fintype V]
1480+
1481+ structure DependencyGraph (V) where
1482+ adj : V → V → Prop
1483+ φ : V → α
1484+ acyclic : ∀ x, ¬ Relation.TransGen adj x x
1485+ dep : ∀ x y, (adj x y ∨ adj y x ↔ D.r (φ x) (φ y))
1486+
1487+ /- lemma subdependency_generates_subgraph {D' D'' : Dependency α}
1488+ {G' : D'.DependencyGraph V} {G'' : D''.DependencyGraph V} {hp : G'.φ = G''.φ} :
1489+ (∀ x y, D'.r x y → D''.r x y) → (∀ u v, G'.adj u v → G''.adj u v) := by
1490+ intro h u v hg
1491+ sorry
1492+ -/
1493+
1494+ variable {V₁ V₂ : Type } [Fintype V₁] [Fintype V₂] in
1495+ def compose (G₁ : D.DependencyGraph V₁) (G₂ : D.DependencyGraph V₂) :
1496+ D.DependencyGraph (V₁ ⊕ V₂) where
1497+ adj := fun u v =>
1498+ match u, v with
1499+ | Sum.inl u, Sum.inl v => G₁.adj u v
1500+ | Sum.inl u, Sum.inr v => D.r (G₁.φ u) (G₂.φ v)
1501+ | Sum.inr u, Sum.inl v => False
1502+ | Sum.inr u, Sum.inr v => G₂.adj u v
1503+ φ := fun v =>
1504+ match v with
1505+ | Sum.inl v => G₁.φ v
1506+ | Sum.inr v => G₂.φ v
1507+ acyclic := by
1508+ intro x h
1509+ /- Invariant: x ∈ G₁ has descendants in G₁ (+ path is contained in G₁) and G₂,
1510+ x ∈ G₂ has only descendants in G₂ -/
1511+ have H : ∀ (x y : V₁ ⊕ V₂), Relation.TransGen (fun u v =>
1512+ match u, v with
1513+ | Sum.inl u, Sum.inl v => G₁.adj u v
1514+ | Sum.inl u, Sum.inr v => D.r (G₁.φ u) (G₂.φ v)
1515+ | Sum.inr u, Sum.inl v => False
1516+ | Sum.inr u, Sum.inr v => G₂.adj u v) x y →
1517+ (∀ u, x = Sum.inl u →
1518+ (∃ v, y = Sum.inl v ∧ Relation.TransGen (G₁.adj) u v) ∨ (∃ w, y = Sum.inr w)) ∧
1519+ (∀ u, x = Sum.inr u →
1520+ ∃ v, y = Sum.inr v ∧ Relation.TransGen (G₂.adj) u v) := by
1521+ intro x y hxy
1522+ induction hxy with
1523+ | single h =>
1524+ rename_i b
1525+ constructor
1526+ · intro u ha
1527+ subst ha
1528+ cases b with
1529+ | inl b => left; exists b; constructor; rfl; exact Relation.TransGen.single h
1530+ | inr b => right; exists b
1531+ · intro u ha
1532+ subst ha
1533+ cases b with
1534+ | inl b => contradiction
1535+ | inr b => exists b; constructor; rfl; exact Relation.TransGen.single h
1536+ | tail hab hbc ih =>
1537+ rename_i b c
1538+ rcases ih with ⟨ih_left, ih_right⟩
1539+ constructor
1540+ · intro u ha
1541+ subst ha
1542+ specialize ih_left u rfl
1543+ cases ih_left with
1544+ | inl h1 =>
1545+ rcases h1 with ⟨v, hb, hab_seq⟩
1546+ subst b
1547+ cases c with
1548+ | inl w => left; exists w; constructor; rfl; exact Relation.TransGen.tail hab_seq hbc
1549+ | inr w => right; exists w
1550+ | inr h2 =>
1551+ rcases h2 with ⟨w, hb⟩
1552+ subst b
1553+ cases c with
1554+ | inl z => contradiction
1555+ | inr z => right; exists z
1556+ · intro u ha
1557+ subst ha
1558+ specialize ih_right u rfl
1559+ rcases ih_right with ⟨v, hb, hab_seq⟩
1560+ subst b
1561+ cases c with
1562+ | inl w => contradiction
1563+ | inr w => exists w; constructor; rfl; exact Relation.TransGen.tail hab_seq hbc
1564+
1565+ -- Apply invariant to derive contradiction
1566+ cases x with
1567+ | inl u =>
1568+ have := H (Sum.inl u) (Sum.inl u) h
1569+ rcases this with ⟨left_part, _⟩
1570+ specialize left_part u rfl
1571+ cases left_part with
1572+ | inl hc =>
1573+ rcases hc with ⟨v, heq, hcycle⟩
1574+ injection heq with heq'
1575+ subst v
1576+ exact G₁.acyclic u hcycle
1577+ | inr hc =>
1578+ rcases hc with ⟨w, heq⟩
1579+ contradiction
1580+ | inr u =>
1581+ have := H (Sum.inr u) (Sum.inr u) h
1582+ rcases this with ⟨_, right_part⟩
1583+ specialize right_part u rfl
1584+ rcases right_part with ⟨v, heq, hcycle⟩
1585+ injection heq with heq'
1586+ subst v
1587+ exact G₂.acyclic u hcycle
1588+ dep := by
1589+ intro u v
1590+ cases u with
1591+ | inl u =>
1592+ cases v with
1593+ | inl v => simp; exact G₁.dep u v
1594+ | inr v => simp
1595+ | inr u =>
1596+ cases v with
1597+ | inl v =>
1598+ simp
1599+ apply Iff.intro
1600+ · exact D.symm
1601+ · exact D.symm
1602+ | inr v => simp; exact G₂.dep u v
1603+
1604+ end Dependency
0 commit comments