Skip to content

Commit 4da5d68

Browse files
benbrastmckieclaude
andcommitted
fix(Logics/Temporal): quality convention fixes for Formula.lean
- Convert module docstring references to Mathlib BibKey format - Add GPSS1980 entry to references.bib (Gabbay, Pnueli, Shelah, Stavi 1980) - Remove redundant nat_pair_inj theorem, replace with Mathlib Nat.pair_eq_pair.mp - Add standard ## Main definitions and ## Notation module docstring sections - Polish derived operator docs with Unicode notation symbols Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d0c1aaa commit 4da5d68

2 files changed

Lines changed: 76 additions & 41 deletions

File tree

Cslib/Logics/Temporal/Syntax/Formula.lean

Lines changed: 64 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,52 @@ This module defines the formula type for temporal logic with primitives
1818
are the basic temporal modalities from which all other temporal operators
1919
(globally, eventually, etc.) are derived.
2020
21+
## Main definitions
22+
23+
- `Formula` : Inductive type for temporal logic formulas with constructors
24+
`atom`, `bot`, `imp`, `untl`, `snce`
25+
- `Formula.encodeNat` : Injective encoding of formulas into natural numbers
26+
(via Cantor pairing), used to establish countability
27+
- `Formula.encodeNat_injective` : Proof that `encodeNat` is injective
28+
- `Formula.someFuture` (𝐅): `φ U ⊤` — φ holds at some future point
29+
- `Formula.allFuture` (𝐆): `¬𝐅¬φ` — φ holds at all future points
30+
- `Formula.somePast` (𝐏): `φ S ⊤` — φ held at some past point
31+
- `Formula.allPast` (𝐇): `¬𝐏¬φ` — φ held at all past points
32+
33+
## Notation
34+
35+
Propositional connectives (scoped to `Cslib.Logic.Temporal`):
36+
- `¬` (prefix, 40) : negation (`Formula.neg`)
37+
- `∧` (infix, 36) : conjunction (`Formula.and`)
38+
- `∨` (infix, 35) : disjunction (`Formula.or`)
39+
- `→` (infix, 30) : implication (`Formula.imp`)
40+
- `↔` (infix, 30) : biconditional (`Formula.iff`)
41+
42+
Temporal operators (scoped to `Cslib.Logic.Temporal`):
43+
- `U` (infix, 40) : until (`Formula.untl`)
44+
- `S` (infix, 40) : since (`Formula.snce`)
45+
- `𝐅` (prefix, 40) : some future / eventually (`Formula.someFuture`)
46+
- `𝐆` (prefix, 40) : all future / globally (`Formula.allFuture`)
47+
- `𝐏` (prefix, 40) : some past (`Formula.somePast`)
48+
- `𝐇` (prefix, 40) : all past / historically (`Formula.allPast`)
49+
- `△` (prefix, 80) : always — at all times past, present, and future (`Formula.always`)
50+
- `▽` (prefix, 80) : sometimes — at some time past, present, or future (`Formula.sometimes`)
51+
2152
## Derived Temporal Operators
2253
2354
The derived operators use the Burgess convention: in `untl event guard` and `snce event guard`,
2455
the first argument is the **event** (holds at the witness point) and the second is the **guard**
2556
(holds at all intermediate points). This matches the abstract typeclass expansion in `Axioms.lean`.
2657
27-
- `someFuture φ` (F φ): `φ U ⊤` — φ holds at some future point (Burgess: `untl φ ⊤`)
28-
- `allFuture φ` (G φ): `¬F ¬φ` — φ holds at all future points
29-
- `somePast φ` (P φ): `φ S ⊤` — φ held at some past point (Burgess: `snce φ ⊤`)
30-
- `allPast φ` (H φ): `¬P ¬φ` — φ held at all past points
58+
- `someFuture φ` (𝐅 φ): `φ U ⊤` — φ holds at some future point (Burgess: `untl φ ⊤`)
59+
- `allFuture φ` (𝐆 φ): `¬𝐅¬φ` — φ holds at all future points
60+
- `somePast φ` (𝐏 φ): `φ S ⊤` — φ held at some past point (Burgess: `snce φ ⊤`)
61+
- `allPast φ` (𝐇 φ): `¬𝐏¬φ` — φ held at all past points
3162
3263
## References
3364
34-
- Kamp, H. (1968). *Tense Logic and the Theory of Linear Order*. PhD thesis, UCLA.
35-
- Gabbay, D., Pnueli, A., Shelah, S., and Stavi, J. (1980). On the temporal analysis of fairness.
36-
In *Proceedings of the 7th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages*,
37-
pp. 163–173. ACM.
65+
* [H. Kamp, *Tense Logic and the Theory of Linear Order*][Kamp1968]
66+
* [D. Gabbay, A. Pnueli, S. Shelah, J. Stavi, *On the temporal analysis of fairness*][GPSS1980]
3867
-/
3968

4069
@[expose] public section
@@ -156,12 +185,6 @@ noncomputable def encodeNat [Encodable Atom] : Formula Atom → ℕ
156185
| .untl φ ψ => Nat.pair 3 (Nat.pair φ.encodeNat ψ.encodeNat)
157186
| .snce φ ψ => Nat.pair 4 (Nat.pair φ.encodeNat ψ.encodeNat)
158187

159-
theorem nat_pair_inj {a b c d : ℕ} (h : Nat.pair a b = Nat.pair c d) :
160-
a = c ∧ b = d := by
161-
have := congr_arg Nat.unpair h
162-
simp only [Nat.unpair_pair] at this
163-
exact Prod.mk.inj this
164-
165188
/-- The encoding is injective. -/
166189
theorem encodeNat_injective [Encodable Atom] :
167190
Function.Injective (encodeNat (Atom := Atom)) := by
@@ -170,49 +193,49 @@ theorem encodeNat_injective [Encodable Atom] :
170193
| atom a =>
171194
cases ψ with
172195
| atom b =>
173-
have ⟨_, h2⟩ := nat_pair_inj h
196+
have ⟨_, h2⟩ := Nat.pair_eq_pair.mp h
174197
exact congrArg Formula.atom (Encodable.encode_injective h2)
175-
| bot => exact absurd (nat_pair_inj h).1 (by decide)
176-
| imp _ _ => exact absurd (nat_pair_inj h).1 (by decide)
177-
| untl _ _ => exact absurd (nat_pair_inj h).1 (by decide)
178-
| snce _ _ => exact absurd (nat_pair_inj h).1 (by decide)
198+
| bot => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
199+
| imp _ _ => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
200+
| untl _ _ => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
201+
| snce _ _ => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
179202
| bot =>
180203
cases ψ with
181204
| bot => rfl
182-
| atom _ => exact absurd (nat_pair_inj h).1 (by decide)
183-
| imp _ _ => exact absurd (nat_pair_inj h).1 (by decide)
184-
| untl _ _ => exact absurd (nat_pair_inj h).1 (by decide)
185-
| snce _ _ => exact absurd (nat_pair_inj h).1 (by decide)
205+
| atom _ => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
206+
| imp _ _ => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
207+
| untl _ _ => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
208+
| snce _ _ => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
186209
| imp a b iha ihb =>
187210
cases ψ with
188211
| imp c d =>
189-
have ⟨_, h2⟩ := nat_pair_inj h
190-
have ⟨h3, h4⟩ := nat_pair_inj h2
212+
have ⟨_, h2⟩ := Nat.pair_eq_pair.mp h
213+
have ⟨h3, h4⟩ := Nat.pair_eq_pair.mp h2
191214
exact congrArg₂ Formula.imp (iha h3) (ihb h4)
192-
| atom _ => exact absurd (nat_pair_inj h).1 (by decide)
193-
| bot => exact absurd (nat_pair_inj h).1 (by decide)
194-
| untl _ _ => exact absurd (nat_pair_inj h).1 (by decide)
195-
| snce _ _ => exact absurd (nat_pair_inj h).1 (by decide)
215+
| atom _ => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
216+
| bot => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
217+
| untl _ _ => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
218+
| snce _ _ => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
196219
| untl a b iha ihb =>
197220
cases ψ with
198221
| untl c d =>
199-
have ⟨_, h2⟩ := nat_pair_inj h
200-
have ⟨h3, h4⟩ := nat_pair_inj h2
222+
have ⟨_, h2⟩ := Nat.pair_eq_pair.mp h
223+
have ⟨h3, h4⟩ := Nat.pair_eq_pair.mp h2
201224
exact congrArg₂ Formula.untl (iha h3) (ihb h4)
202-
| atom _ => exact absurd (nat_pair_inj h).1 (by decide)
203-
| bot => exact absurd (nat_pair_inj h).1 (by decide)
204-
| imp _ _ => exact absurd (nat_pair_inj h).1 (by decide)
205-
| snce _ _ => exact absurd (nat_pair_inj h).1 (by decide)
225+
| atom _ => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
226+
| bot => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
227+
| imp _ _ => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
228+
| snce _ _ => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
206229
| snce a b iha ihb =>
207230
cases ψ with
208231
| snce c d =>
209-
have ⟨_, h2⟩ := nat_pair_inj h
210-
have ⟨h3, h4⟩ := nat_pair_inj h2
232+
have ⟨_, h2⟩ := Nat.pair_eq_pair.mp h
233+
have ⟨h3, h4⟩ := Nat.pair_eq_pair.mp h2
211234
exact congrArg₂ Formula.snce (iha h3) (ihb h4)
212-
| atom _ => exact absurd (nat_pair_inj h).1 (by decide)
213-
| bot => exact absurd (nat_pair_inj h).1 (by decide)
214-
| imp _ _ => exact absurd (nat_pair_inj h).1 (by decide)
215-
| untl _ _ => exact absurd (nat_pair_inj h).1 (by decide)
235+
| atom _ => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
236+
| bot => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
237+
| imp _ _ => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
238+
| untl _ _ => exact absurd (Nat.pair_eq_pair.mp h).1 (by decide)
216239

217240
end Formula
218241

references.bib

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,18 @@ @phdthesis{Kamp1968
520520
school = {Ucla}
521521
}
522522

523+
@inproceedings{GPSS1980,
524+
author = {Gabbay, Dov and Pnueli, Amir and Shelah, Saharon and Stavi, Jonathan},
525+
title = {On the Temporal Analysis of Fairness},
526+
booktitle = {Proceedings of the 7th Annual {ACM} {SIGPLAN}-{SIGACT} Symposium on
527+
Principles of Programming Languages},
528+
pages = {163--173},
529+
publisher = {Association for Computing Machinery},
530+
address = {New York, NY, USA},
531+
year = {1980},
532+
doi = {10.1145/567446.567462}
533+
}
534+
523535
@article{Xu1988,
524536
author = {Xu, Ming},
525537
title = {On Some {U,S}-Tense Logics},

0 commit comments

Comments
 (0)