-
Notifications
You must be signed in to change notification settings - Fork 21
Switch to the standard type for relations. #16
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import Cslib.Semantics.LTS.Basic | ||
import Cslib.Semantics.LTS.Bisimulation | ||
import Cslib.Semantics.LTS.TraceEq | ||
import Cslib.Utils.Relation | ||
import Cslib.Data.Relation | ||
import Cslib.Computability.CombinatoryLogic.Defs | ||
import Cslib.Computability.CombinatoryLogic.Basic |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,37 @@ | ||
/- | ||
Copyright (c) 2025 Thomas Waring. All rights reserved. | ||
Copyright (c) 2025 Fabrizio Montesi and Thomas Waring. All rights reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Authors: Thomas Waring, Chris Henson | ||
Authors: Fabrizio Montesi, Thomas Waring, Chris Henson | ||
-/ | ||
|
||
import Mathlib.Logic.Relation | ||
|
||
universe u | ||
/-! # Relations -/ | ||
|
||
universe u v | ||
|
||
section Relation | ||
|
||
/-- Union of two relations. -/ | ||
def Relation.union (r s : α → β → Prop) : α → β → Prop := | ||
fun x y => r x y ∨ s x y | ||
|
||
instance {α : Type u} {β : Type v} : Union (α → β → Prop) where | ||
union := Relation.union | ||
|
||
variable {α : Type u} {R R' : α → α → Prop} | ||
/-- Inverse of a relation. -/ | ||
def Relation.inv (r : α → β → Prop) : β → α → Prop := flip r | ||
|
||
-- /-- Composition of two relations. -/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commented out definition? |
||
-- def Relation.comp (r : α → β → Prop) (s : β → γ → Prop) : α → γ → Prop := | ||
-- fun x z => ∃ y, r x y ∧ s y z | ||
|
||
/-- The relation `r` 'up to' the relation `s`. -/ | ||
def Relation.upTo (r s : α → α → Prop) : α → α → Prop := Relation.Comp s (Relation.Comp r s) | ||
|
||
/-- The identity relation. -/ | ||
inductive Relation.Id : α → α → Prop where | ||
| id {x : α} : Id x x | ||
Comment on lines
+32
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, that's a surprising name from the textbooks I'm used to. Thanks for pointing it out, I'd been naively looking for Id. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, it's because I was looking for it in mathlib as a |
||
|
||
/-- A relation has the diamond property when all reductions with a common origin are joinable -/ | ||
abbrev Diamond (R : α → α → Prop) := ∀ {A B C : α}, R A B → R A C → (∃ D, R B D ∧ R C D) | ||
|
@@ -16,9 +40,9 @@ abbrev Diamond (R : α → α → Prop) := ∀ {A B C : α}, R A B → R A C → | |
abbrev Confluence (R : α → α → Prop) := Diamond (Relation.ReflTransGen R) | ||
|
||
/-- Extending a multistep reduction by a single step preserves multi-joinability. -/ | ||
lemma Relation.ReflTransGen.diamond_extend (h : Diamond R) : | ||
Relation.ReflTransGen R A B → | ||
R A C → | ||
lemma Relation.ReflTransGen.diamond_extend (h : Diamond R) : | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these identified by a linter? If so, can we enable this by default/include it in a workflow check? |
||
Relation.ReflTransGen R A B → | ||
R A C → | ||
∃ D, Relation.ReflTransGen R B D ∧ Relation.ReflTransGen R C D := by | ||
intros AB _ | ||
revert C | ||
|
@@ -75,3 +99,5 @@ theorem church_rosser_of_diamond {α : Type _} {r : α → α → Prop} | |
constructor | ||
. exact Relation.ReflGen.single hd.1 | ||
. exact Relation.ReflTransGen.single hd.2 | ||
|
||
end Relation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mathlib already provides this with
⊔
notation