Skip to content

Commit bad2ea9

Browse files
committed
Redefine trace equivalence without using ConGen.Rel
1 parent 30e5d65 commit bad2ea9

1 file changed

Lines changed: 38 additions & 23 deletions

File tree

TraceTheory/TraceTheory/Trace.lean

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Mathlib.Data.Fintype.Basic
2-
import Mathlib.GroupTheory.Congruence.Defs
32
import TraceTheory.Basic
43

54
variable {α : Type*} [DecidableEq α] [Fintype α]
@@ -10,39 +9,55 @@ namespace Trace
109
A dependence relation is a finite, reflexive, and symmetric relation.
1110
-/
1211
structure Dependence where
13-
r : α → α → Prop
14-
refl : ∀ a, r a a
15-
symm: ∀ a b, r a b → r b a
12+
rel : α → α → Prop
13+
refl : ∀ a, rel a a
14+
symm: ∀ a b, rel a b → rel b a
1615

1716
/--
1817
An independence relation is a finite, irreflexive, and symmetric relation.
1918
-/
2019
structure Independence where
21-
r : α → α → Prop
22-
irrefl : ∀ a, ¬ r a a
23-
symm : ∀ a b, r a b → r b a
20+
rel : α → α → Prop
21+
irrefl : ∀ a, ¬ rel a a
22+
symm : ∀ a b, rel a b → rel b a
2423

2524
variable {I : Independence}
2625

26+
variable (I) in
2727
/--
28-
The product of two traces (i.e. list of symbols) is the concatenation of the two traces.
29-
-/
30-
instance : Mul (List α) := ⟨List.append⟩
31-
32-
/--
33-
The trace equivalence relation is defined as the smallest multiplicative (i.e. concatenation) congruence relation induced by the independence relation `I.r`.
34-
That is, two traces (i.e. lists of symbols) are equivalent if one can be transformed into the other by a finite sequence of swaps of adjacent independent symbols.
28+
The trace equivalence relation is the smallest congruence relation induced by the independence relation `I.r`.
29+
Two traces (i.e. lists of symbols) are equivalent if one can be transformed into the other by a finite sequence of swaps of adjacent independent symbols.
3530
36-
More precisely, `ConGen.Rel I.r` is the inductive closure of the following axioms:
37-
- **Base:** If `I.r a b`, then `[a, b]` is equivalent to `[b, a]` (i.e., swapping adjacent independent symbols).
31+
The relation is inductively generated by:
32+
- **Swap:** If `I.r a b`, then `[a, b]` is equivalent to `[b, a]` (swapping adjacent independent symbols).
3833
- **Reflexivity:** Every word is equivalent to itself.
39-
- **Symmetry:** If `u` is equivalent to `v`, then `v` is equivalent to `u`.
40-
- **Transitivity:** If `u` is equivalent to `v` and `v` is equivalent to `w`, then `u` is equivalent to `w`.
41-
- **Compatibility:** If `u₁` is equivalent to `v₁` and `u₂` is equivalent to `v₂`, then `u₁ ++ u₂` is equivalent to `v₁ ++ v₂`.
42-
43-
Thus, two traces are equivalent if and only if one can be obtained from the other by a finite sequence of these operations (or their inverses).
34+
- **Symmetry:** If `t₁` is equivalent to `t₂`, then `t₂` is equivalent to `t₁`.
35+
- **Transitivity:** If `t₁` is equivalent to `t₂` and `t₂` is equivalent to `t₃`, then `t₁` is equivalent to `t₃`.
36+
- **Compatibility:** If `t₁` is equivalent to `t₂` and `t₃` is equivalent to `t₄`, then `t₁ ++ t₃` is equivalent to `t₂ ++ t₄`.
4437
-/
45-
def trace_equiv : List α → List α → Prop :=
46-
ConGen.Rel I.r
38+
inductive TraceEquiv : List α → List α → Prop
39+
| swap : ∀ a b, I.rel a b → TraceEquiv [a, b] [b, a]
40+
| refl : ∀ t₁, TraceEquiv t₁ t₁
41+
| symm : ∀ t₁ t₂, TraceEquiv t₁ t₂ → TraceEquiv t₂ t₁
42+
| trans : ∀ t₁ t₂ t₃, TraceEquiv t₁ t₂ → TraceEquiv t₂ t₃ → TraceEquiv t₁ t₃
43+
| compat : ∀ t₁ t₂ t₃ t₄, TraceEquiv t₁ t₂ → TraceEquiv t₃ t₄ → TraceEquiv (t₁ ++ t₃) (t₂ ++ t₄)
44+
45+
omit [DecidableEq α] [Fintype α] in
46+
variable (I) in
47+
@[simp]
48+
lemma trace_equiv_length_eq {t₁ t₂ : List α} :
49+
TraceEquiv I t₁ t₂ → t₁.length = t₂.length := by
50+
intro h
51+
induction h with
52+
| swap _ _ _ =>
53+
rfl
54+
| refl _ =>
55+
rfl
56+
| symm _ _ _ IH =>
57+
exact Eq.symm IH
58+
| trans _ _ _ _ _ IH₁ IH₂ =>
59+
exact Eq.trans IH₁ IH₂
60+
| compat _ _ _ _ _ _ IH₁ IH₂ =>
61+
simp [IH₁, IH₂]
4762

4863
end Trace

0 commit comments

Comments
 (0)