Skip to content

Commit 8f31fcf

Browse files
committed
feat(Logics): add LTL formula type, typeclass hierarchy, and import cleanup
1 parent dd06e39 commit 8f31fcf

11 files changed

Lines changed: 162 additions & 12 deletions

File tree

Cslib/Foundations/Data/HasFresh.lean

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ module -- shake: keep-downstream
88

99
public import Cslib.Init
1010
public import Mathlib.Analysis.Normed.Field.Lemmas
11-
meta import Lean.Elab.ConfigEval
12-
import Qq
1311

1412
/-! Computable chacterization of infinite types. -/
1513

Cslib/Foundations/Semantics/LTS/Notation.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Authors: Fabrizio Montesi, Chris Henson
66

77
module
88

9+
public import Cslib.Foundations.Semantics.LTS.Basic
910
public import Cslib.Foundations.Semantics.LTS.Relation
1011

1112
/-!

Cslib/Languages/CCS/Semantics.lean

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ Authors: Fabrizio Montesi
77
module
88

99
public import Cslib.Foundations.Semantics.LTS.HasTau
10-
public meta import Cslib.Foundations.Semantics.LTS.Notation
10+
public import Cslib.Foundations.Semantics.LTS.Relation
11+
public import Cslib.Foundations.Semantics.LTS.Notation
12+
public meta import Mathlib.Tactic.ToAdditive
13+
public meta import Mathlib.Tactic.ToDual
14+
public meta import Mathlib.Tactic.Basic
1115
public import Cslib.Languages.CCS.Basic
1216

1317
/-! # Semantics of CCS

Cslib/Languages/LambdaCalculus/LocallyNameless/Untyped/Congruence.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Authors: Maximiliano Onofre Martínez
66

77
module
88

9-
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.Properties
9+
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.LcAt
1010

1111
/-! # Congruence for the λ-calculus -/
1212

Cslib/Languages/LambdaCalculus/LocallyNameless/Untyped/FullBetaEta.lean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ Authors: Maximiliano Onofre Martínez, Yijun Leng
66

77
module
88

9-
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.FullBetaConfluence
10-
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.FullEtaConfluence
9+
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.FullEta
10+
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.FullBeta
11+
public import Cslib.Foundations.Relation.Confluence
1112

1213
/-! # βη-Confluence for the λ-calculus
1314

Cslib/Languages/LambdaCalculus/LocallyNameless/Untyped/FullEtaConfluence.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Authors: Maximiliano Onofre Martínez
77
module
88

99
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.FullEta
10-
public import Cslib.Foundations.Relation.Confluence
10+
public import Cslib.Foundations.Relation.Defs
1111

1212
/-! # η-confluence for the λ-calculus
1313

Cslib/Languages/LambdaCalculus/LocallyNameless/Untyped/MultiSubst.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ module
99

1010
public import Cslib.Foundations.Data.HasFresh
1111
public import Cslib.Foundations.Syntax.HasSubstitution
12-
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Stlc.Basic
13-
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.FullBeta
12+
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Untyped.Properties
13+
public import Cslib.Languages.LambdaCalculus.LocallyNameless.Context
1414

1515
/-! Multiple substitution for untyped lambda calculus. -/
1616

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/-
2+
Copyright (c) 2026 Benjamin Brast-McKie. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Benjamin Brast-McKie
5+
-/
6+
7+
module
8+
9+
public import Cslib.Init
10+
public import Cslib.Foundations.Logic.Connectives
11+
public import Cslib.Logics.Temporal.Syntax.Formula
12+
13+
/-! # LTL Formula Type
14+
15+
This module defines the formula type for Linear Temporal Logic with primitives
16+
`{atom, bot, imp, next, untl}`. The primitive `next` operator is kept separate from
17+
`untl` following the Burgess convention: in full temporal logic, `next φ` is sometimes
18+
encoded as `φ U ⊥`, but this encoding does not hold in all models (it relies on
19+
discreteness and non-triviality). An independent primitive `next` avoids this coupling.
20+
21+
## Main definitions
22+
23+
- `Formula` : Inductive type for LTL formulas with constructors
24+
`atom`, `bot`, `imp`, `next`, `untl`
25+
- `Formula.someFuture` (𝐅): `φ U ⊤` — φ holds at some future point
26+
- `Formula.allFuture` (𝐆): `¬𝐅¬φ` — φ holds at all future points
27+
- `Formula.toTemporal` : Embedding of `LTL.Formula` into `Temporal.Formula`
28+
29+
## Notation
30+
31+
Propositional connectives (scoped to `Cslib.Logic.LTL`):
32+
- `¬` (prefix, 40) : negation (`Formula.neg`)
33+
- `∧` (infix, 36) : conjunction (`Formula.and`)
34+
- `∨` (infix, 35) : disjunction (`Formula.or`)
35+
- `→` (infix, 30) : implication (`Formula.imp`)
36+
- `↔` (infix, 30) : biconditional (`Formula.iff`)
37+
38+
Temporal operators (scoped to `Cslib.Logic.LTL`):
39+
- `U` (infix, 40) : until (`Formula.untl`)
40+
- `X` (prefix, 40) : next-step (`Formula.next`)
41+
- `𝐅` (prefix, 40) : some future / eventually (`Formula.someFuture`)
42+
- `𝐆` (prefix, 40) : all future / globally (`Formula.allFuture`)
43+
44+
## Derived Operators
45+
46+
Derived operators follow the Burgess convention: in `untl event guard`, the first argument
47+
is the **event** (holds at the witness point) and the second is the **guard** (holds at all
48+
intermediate points). `someFuture φ` is `φ U ⊤` (φ is the event, ⊤ is the trivial guard).
49+
50+
## References
51+
52+
* [A. Pnueli, *The Temporal Logic of Programs*][Pnueli1977]
53+
* [H. Kamp, *Tense Logic and the Theory of Linear Order*][Kamp1968]
54+
* [J. P. Burgess, *Basic Tense Logic*][Burgess1984]
55+
* [M. Y. Vardi, P. Wolper,
56+
*An automata-theoretic approach to automatic program verification*][VardiWolper1986]
57+
-/
58+
59+
@[expose] public section
60+
61+
namespace Cslib.Logic.LTL
62+
63+
/-- LTL formula type. Primitives: atoms, falsum, implication, next-step, and until.
64+
65+
`next` is a primitive constructor and is not derived from `untl`. The encoding
66+
`next φ = φ U ⊥` holds on discrete non-ending sequences but fails in general temporal
67+
models; keeping `next` primitive supports broader model classes. -/
68+
inductive Formula (Atom : Type u) : Type u where
69+
/-- Atomic proposition. -/
70+
| atom (p : Atom)
71+
/-- Falsum / bottom. -/
72+
| bot
73+
/-- Implication. -/
74+
| imp (φ₁ φ₂ : Formula Atom)
75+
/-- Next-step operator: Xφ holds at t iff φ holds at t+1. -/
76+
| next (φ : Formula Atom)
77+
/-- Until temporal operator: φ₁ U φ₂ (Burgess: event U guard). -/
78+
| untl (φ₁ φ₂ : Formula Atom)
79+
deriving DecidableEq, BEq
80+
81+
/-- Negation: ¬φ := φ → ⊥ -/
82+
abbrev Formula.neg (φ : Formula Atom) : Formula Atom := .imp φ .bot
83+
84+
/-- Verum / top: ⊤ := ⊥ → ⊥ -/
85+
abbrev Formula.top : Formula Atom := .imp .bot .bot
86+
87+
/-- Disjunction: φ₁ ∨ φ₂ := ¬φ₁ → φ₂ -/
88+
abbrev Formula.or (φ₁ φ₂ : Formula Atom) : Formula Atom :=
89+
.imp (.imp φ₁ .bot) φ₂
90+
91+
/-- Conjunction: φ₁ ∧ φ₂ := ¬(φ₁ → ¬φ₂) -/
92+
abbrev Formula.and (φ₁ φ₂ : Formula Atom) : Formula Atom :=
93+
.imp (.imp φ₁ (.imp φ₂ .bot)) .bot
94+
95+
/-- Biconditional: φ₁ ↔ φ₂ := (φ₁ → φ₂) ∧ (φ₂ → φ₁) -/
96+
abbrev Formula.iff (φ₁ φ₂ : Formula Atom) : Formula Atom :=
97+
(φ₁.imp φ₂).and (φ₂.imp φ₁)
98+
99+
/-- Some future (eventually): F φ := φ U ⊤.
100+
Uses Burgess convention: φ is the event (holds at witness), ⊤ is the trivial guard. -/
101+
abbrev Formula.someFuture (φ : Formula Atom) : Formula Atom :=
102+
.untl φ .top
103+
104+
/-- All future (globally): G φ := ¬F ¬φ -/
105+
abbrev Formula.allFuture (φ : Formula Atom) : Formula Atom :=
106+
.neg (.someFuture (.neg φ))
107+
108+
@[inherit_doc] scoped prefix:40 "¬" => Formula.neg
109+
@[inherit_doc] scoped infix:36 " ∧ " => Formula.and
110+
@[inherit_doc] scoped infix:35 " ∨ " => Formula.or
111+
@[inherit_doc] scoped infix:30 " → " => Formula.imp
112+
@[inherit_doc] scoped infix:30 " ↔ " => Formula.iff
113+
@[inherit_doc] scoped infix:40 " U " => Formula.untl
114+
@[inherit_doc] scoped prefix:40 "X" => Formula.next
115+
@[inherit_doc] scoped prefix:40 "𝐅" => Formula.someFuture
116+
@[inherit_doc] scoped prefix:40 "𝐆" => Formula.allFuture
117+
118+
/-- Register `LTL.Formula` as an instance of `LTLConnectives`. -/
119+
instance : LTLConnectives (Formula Atom) where
120+
bot := .bot
121+
imp := .imp
122+
untl := .untl
123+
next := .next
124+
125+
instance : Bot (Formula Atom) := ⟨.bot⟩
126+
instance : Top (Formula Atom) := ⟨.top⟩
127+
128+
/-- Embed `LTL.Formula` into `Temporal.Formula`. Translates `next φ` as `φ U ⊥`
129+
(strict until forces the immediate successor on ℕ) and `untl` as reflexive until. -/
130+
def Formula.toTemporal : Formula Atom → Temporal.Formula Atom
131+
| .atom p => .atom p
132+
| .bot => .bot
133+
| .imp φ ψ => .imp (toTemporal φ) (toTemporal ψ)
134+
| .next φ => .untl (toTemporal φ) .bot
135+
| .untl φ ψ => (toTemporal φ).reflexiveUntl (toTemporal ψ)
136+
137+
end Cslib.Logic.LTL
138+
139+
end

Cslib/Logics/Modal/Basic.lean

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@ module
88

99
public import Cslib.Init
1010
public import Cslib.Foundations.Logic.InferenceSystem
11-
public import Mathlib.Data.Set.Basic
1211
public import Mathlib.Order.Defs.Unbundled
13-
public import Cslib.Foundations.Relation.Euclidean
1412
public import Mathlib.Logic.Nonempty
13+
public import Cslib.Foundations.Relation.Defs
14+
public import Mathlib.Data.Finset.Attr
15+
public import Mathlib.Tactic.SetLike
16+
public import Mathlib.Tactic.Finiteness.Attr
17+
public import Mathlib.Tactic.Attr.Core
18+
public import Mathlib.Data.Set.Operations
19+
public import Mathlib.Tactic.ToAdditive
1520

1621
/-! # Modal Logic
1722
@@ -178,7 +183,7 @@ set_option linter.tacticAnalysis.verifyGrindOnly false in
178183
/-- The dual axiom, valid for all models. -/
179184
theorem Satisfies.dual : ⇓Modal[m,w ⊨ ◇φ ↔ ¬□¬φ] := by
180185
grind only [Satisfies.iff_iff_iff.mpr, → satisfies_theory, usr Set.mem_setOf_eq, = impl_iff_impl,
181-
=_ derivation_def, = not_satisfies, Satisfies, = box_iff_forall, = Set.setOf_true]
186+
=_ derivation_def, = not_satisfies, Satisfies, = box_iff_forall]
182187

183188
/-- The T axiom, valid for all reflexive models. -/
184189
theorem Satisfies.t {m : Model World Atom} [instRefl : Std.Refl m.r] {w : World}

Cslib/Logics/Modal/Cube.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Authors: Fabrizio Montesi, Marianna Girlando
77
module
88

99
public import Cslib.Logics.Modal.Basic
10+
public import Cslib.Foundations.Relation.Euclidean
1011

1112
/-! # Modal Logic Cube
1213

0 commit comments

Comments
 (0)