Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metatheorem about duals #285

Merged
merged 8 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion blueprint/src/chapter/general_implications.tex
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ \chapter{General implications}

The pre-ordering on laws has a duality symmetry:

\begin{lemma}[Duality of laws]\label{duality}\uses{pre-order} If $w \formaleq w'$ implies $w'' \formaleq w'''$, then $w^{\mathrm{op}} \formaleq (w')^{\mathrm{op}}$ implies $w''^{\mathrm{op}} \formaleq (w''')^{\mathrm{op}}$.
\begin{lemma}[Duality of laws]\lean{Law.MagmaLaw.implies_op}\leanok\label{duality}\uses{pre-order} If $w \formaleq w'$ implies $w'' \formaleq w'''$, then $w^{\mathrm{op}} \formaleq (w')^{\mathrm{op}}$ implies $w''^{\mathrm{op}} \formaleq (w''')^{\mathrm{op}}$.
\end{lemma}

\begin{proof} This follows from the fact that a magma $G$ satisfies a law $w \formaleq w'$ if and only if $G^{\mathrm{op}}$ satisfies $w^{\mathrm{op}} \formaleq (w')^{\mathrm{op}}$.
Expand Down
Binary file removed blueprint/src/print.pdf
Binary file not shown.
41 changes: 41 additions & 0 deletions equational_theories/MagmaLaw.lean
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,44 @@ infix:50 " ⊧ " => (models)
infix:50 " ⊢ " => (derive)

infix:50 " ⊢' " => (derive')

namespace Law

def MagmaLaw.symm {α : Type} (l : MagmaLaw α) : MagmaLaw α := {lhs := l.rhs, rhs:=l.lhs}

@[simp]
theorem MagmaLaw.symm_symm {α : Type} (l : MagmaLaw α) : l.symm.symm = l := by
simp [symm]

theorem satisfiesPhi_symm_law {α G : Type} [Magma G] (φ : α → G) (E : MagmaLaw α)
(h : satisfiesPhi φ E) : satisfiesPhi φ E.symm := by
simp [Law.MagmaLaw.symm, satisfiesPhi]
exact h.symm

theorem satisfiesPhi_symm {α G : Type} [Magma G] (φ : α → G) (w₁ w₂ : FreeMagma α)
(h : satisfiesPhi φ (w₁ ≃ w₂)) : satisfiesPhi φ (w₂ ≃ w₁) := Law.satisfiesPhi_symm_law φ (w₁ ≃ w₂) h

theorem satisfies_symm_law {α : Type} (G : Type) [Magma G] (E : MagmaLaw α)
(h : G ⊧ E) : G ⊧ E.symm := fun φ ↦ satisfiesPhi_symm_law φ E (h φ)

theorem satisfies_symm {α : Type} (G : Type) [Magma G] (w₁ w₂ : FreeMagma α)
(h : G ⊧ w₁ ≃ w₂) : G ⊧ w₂ ≃ w₁ := satisfies_symm_law G (w₁ ≃ w₂) h

def set_symm {α} (Γ : Set (MagmaLaw α)) : Set (MagmaLaw α) := { (γ.symm) | γ ∈ Γ}

theorem satisfiesSet_symm {α : Type} (G : Type) [Magma G] (Γ : Set (MagmaLaw α))
(h : G ⊧ Γ) : G ⊧ (set_symm Γ) := by
simp [set_symm]
intro E ⟨Esymm, ⟨hEsymm,hEsymmE⟩⟩
rw [← hEsymmE]
apply Law.satisfies_symm
apply h
exact hEsymm

theorem models_symm_law {α} (Γ : Ctx α) (E : MagmaLaw α) (h : Γ ⊧ E) : Γ ⊧ E.symm :=
fun G [Magma G] hsatisfiesSet ↦ satisfies_symm_law G E (h G hsatisfiesSet)

theorem models_symm {α} (Γ : Ctx α) (w₁ w₂ : FreeMagma α) (h : Γ ⊧ w₁ ≃ w₂) : Γ ⊧ w₂ ≃ w₁ :=
Law.models_symm_law Γ (w₁ ≃ w₂) h

end Law
44 changes: 44 additions & 0 deletions equational_theories/MagmaOp.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import equational_theories.FreeMagma
import equational_theories.MagmaLaw
import equational_theories.Preorder

open FreeMagma
open Law
Expand All @@ -14,12 +15,20 @@ match w with
| .Leaf x => .Leaf x
| .Fork w₁ w₂ => .Fork w₂.op w₁.op

/--
The dual is indeed dual (an involution).
-/
@[simp]
theorem FreeMagma.op_op {α} (w : FreeMagma α) : w.op.op = w := by
induction w <;> simp [op, *]

@[simp]
def Op (G : Type) : Type := G

@[simp]
instance opMagma {G : Type} [Magma G] : Magma (Op G) := { op := λ (x y : G) ↦ (y ◇ x : G) }

def Magma.opHom {G} [Magma G] : G → Op G := fun x => x

theorem evalInMagmaOp {α G} [Magma G] (φ : α → G) (w : FreeMagma α):
evalInMagma (G := Op G) φ w.op = evalInMagma (G := G) φ w :=
Expand All @@ -36,3 +45,38 @@ by
simp [satisfies, satisfiesPhi]
repeat rw [@evalInMagmaOp]
apply h

namespace Law.MagmaLaw

def op {α} (l : MagmaLaw α) : MagmaLaw α := { lhs := l.lhs.op, rhs := l.rhs.op}

theorem law_op_op {α} (l : MagmaLaw α) : l.op.op = l := by simp [op]

theorem satisfiesPhi_op {α G} [Magma G] {l : MagmaLaw α} {φ : α → G}
(h : satisfiesPhi (Magma.opHom ∘ φ) l) : satisfiesPhi φ l.op := by
simp [satisfiesPhi, evalInMagma, op] at *
rw [← evalInMagmaOp φ l.lhs.op, ← evalInMagmaOp φ l.rhs.op]
simp
exact h

theorem satisfies_op_op {α G} [Magma G] {l : MagmaLaw α} (h : (Op G) ⊧ l) : G ⊧ l.op := by
intro φ
simp [op, satisfies]
apply satisfiesPhi_op
apply h

theorem implies_op {α} {l₁ l₂ : MagmaLaw α} (h : l₁.implies l₂) : l₁.op.implies l₂.op := by
simp [op, implies] at *
intro G inst hsat
apply satisfies_op_op
apply h
rw [← law_op_op l₁]
apply satisfies_op_op
exact hsat

theorem le_op {α} {l₁ l₂ : MagmaLaw α} (h : l₁ ≤ l₂) : l₁.op ≤ l₂.op := by
simp [LE.le]
apply implies_op
exact h

end Law.MagmaLaw