Skip to content

Conversation

fmontesi
Copy link
Collaborator

This PR creates a new Cslib.Data.Relation file with some utilities and a union notation for relations, merging the previous files Cslib.Utils.Rel and Cslib.Utils.Relation (now deleted).

It removes all dependencies of the recently-changed Rel type from mathlib, in preparation for bumping our mathlib dependency.

I'm a bit in doubt as to the name styling for definitions such as 'Relation.inv' and 'Relation.union'. In mathlib, they are uppercased for Relation but lowercased for Rel, I guess because for Relation one knows that the final type is Prop. It is however a bit weird.

@fmontesi fmontesi requested a review from a team as a code owner July 22, 2025 15:08
@fmontesi fmontesi requested a review from chenson2018 July 22, 2025 15:09
@fmontesi fmontesi requested review from a team as code owners July 22, 2025 15:15
@fmontesi fmontesi merged commit aac6d4e into main Jul 23, 2025
2 checks passed
@fmontesi fmontesi deleted the relation branch July 23, 2025 13:47
lemma Relation.ReflTransGen.diamond_extend (h : Diamond R) :
Relation.ReflTransGen R A B →
R A C →
lemma Relation.ReflTransGen.diamond_extend (h : Diamond R) :
Copy link
Collaborator

Choose a reason for hiding this comment

The 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?

/-- Inverse of a relation. -/
def Relation.inv (r : α → β → Prop) : β → α → Prop := flip r

-- /-- Composition of two relations. -/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented out definition?

(r1 r2 : Rel State State) (h1 : Simulation lts r1) (h2 : Simulation lts r2) :
Simulation lts (r1.comp r2) := by
(r1 r2 : State StateProp) (h1 : Simulation lts r1) (h2 : Simulation lts r2) :
Simulation lts (Relation.Comp r1 r2) := by
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Relation.Comp have a notation? If so, that would be preferred here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question regarding the usage of Relation.inv.

constructor
case left =>
simp only [Rel.comp]
simp only [Relation.Comp]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All uses of simp only [Relation.Comp] in this file are not needed.

constructor
· exact h2'tr
· simp [Rel.comp]
· simp only [Relation.Comp]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All uses of simp only [Relation.Comp] in this file are not needed.

Comment on lines +15 to +20
/-- 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

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

Comment on lines +32 to +34
/-- The identity relation. -/
inductive Relation.Id : α → α → Prop where
| id {x : α} : Id x x

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Eq

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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 Rel a long time ago.. the Eq from Lean is of course what I want. Adopting it is even simplifying some proofs!

thomaskwaring pushed a commit to thomaskwaring/cslib_SKI that referenced this pull request Oct 6, 2025
* Switch to the standard type for relations.

* Missing changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants