Skip to content
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

Modal logic #1146

Draft
wants to merge 63 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
8a92a52
first syntax and semantics draft
spcfox Oct 1, 2023
63b0e15
add soundness
spcfox Oct 8, 2023
5f89c97
- Change Hilbert system
spcfox Oct 8, 2023
49f2cf6
Kripke fram should be not empty
spcfox Oct 8, 2023
517fc91
Refactor soundness
spcfox Oct 8, 2023
6053173
Add finite model
spcfox Oct 9, 2023
d1744d9
simplify finite-is-classical proof
spcfox Oct 9, 2023
1f8f53f
- Rewrite valuate to Propositions
spcfox Oct 22, 2023
661adc6
Small fixes, and refactor kripke-frame
spcfox Oct 22, 2023
3b3ba68
Refactor modal logic
spcfox Oct 22, 2023
957e112
- Refactor
spcfox Oct 23, 2023
341456a
Change operators levels and associativity
spcfox Oct 23, 2023
9db88ca
Refactor universe levels
spcfox Oct 23, 2023
30056ba
Small fixes
spcfox Oct 23, 2023
0d22369
Refactor
spcfox Oct 23, 2023
21d74ce
Add logics as sets of formulas
spcfox Oct 26, 2023
8ecf60e
Remove old K definition
spcfox Oct 26, 2023
bb2f31b
Fix index file
spcfox Oct 26, 2023
41d20ab
Add K soundness
spcfox Oct 26, 2023
03d2142
Refactor kripke-models
spcfox Oct 27, 2023
88cb89f
Add finite models
spcfox Oct 27, 2023
ef73d85
Experiments with axioms definitions
spcfox Oct 28, 2023
28fc80e
Add completeness definition
spcfox Oct 29, 2023
2ddac8e
Refactor axioms
spcfox Nov 6, 2023
e17134d
Add uncompleted proof of completeness K
spcfox Nov 10, 2023
c1ae1ff
Run pre-commit
spcfox Nov 10, 2023
b358d85
Proof canonical model theorem
spcfox Feb 5, 2024
9e3bb01
fix pre-commit
spcfox Feb 5, 2024
fd1cc31
Prove the second point of canonical model theorem
spcfox Feb 6, 2024
39bccd5
Prove completeness K
spcfox Feb 6, 2024
200901a
fix renamed functions
spcfox Feb 14, 2024
77f1901
fix pre-commit
spcfox Feb 14, 2024
f31d02d
Small refactor and add canonical axioms
spcfox Mar 25, 2024
eb31291
Add S5 soundness and refactor kripke-frame
spcfox Mar 27, 2024
0e1fd0e
Proof completeness of S5
spcfox Mar 29, 2024
b019f5b
Add filtrations and finite approximability
spcfox Apr 5, 2024
f41eaff
Rename map-list to dependent-map-list
spcfox Apr 6, 2024
53eb3bf
Small fixes
spcfox Apr 30, 2024
e51080a
Refactor weak-deduction and L-complete theories
spcfox May 2, 2024
317fd29
Refactor Lindanbaum's lemma
spcfox May 3, 2024
998bd15
Remove old code from weak-deduction
spcfox May 3, 2024
8d29db3
Refactor canonical kripke model
spcfox May 3, 2024
02b75b6
Refactor canonical model theorem
spcfox May 5, 2024
7696793
Fix types in filtrations
spcfox May 5, 2024
89951d2
Remove upper characters from file names
spcfox May 5, 2024
c60b49b
Make pre-commit one more time
spcfox May 5, 2024
706ff33
Refactor after rebase
spcfox May 5, 2024
424667a
Small refactor filtrations
spcfox May 5, 2024
873449a
Refactor subtypes
spcfox May 5, 2024
4111374
Refactor formulas and module names
spcfox May 5, 2024
662bc0f
Refactor var
spcfox May 5, 2024
29eed33
Fix filtration lemma and deduction theorem
spcfox May 5, 2024
b2d85c4
Fix filtratiom lemma file name
spcfox May 5, 2024
294ae82
Add recurser for equivalence classes and refactor
spcfox May 5, 2024
b978ed1
Prove inductor for equivalence classes
spcfox May 6, 2024
e44f24f
Replace zorn lemma in canonical model theorem
spcfox May 7, 2024
081aa53
Refactor kripke semantics
spcfox May 8, 2024
0df9fd4
Fix filtration definition
spcfox May 9, 2024
3555784
Complete eliminators for equivalence class
spcfox May 11, 2024
e1bc75f
Refactor finite approximability
spcfox May 16, 2024
a9d4e80
Refactor
spcfox May 25, 2024
2cc2b80
Refactor filtrations
spcfox May 31, 2024
ba35873
Fix import in finite-approximability
spcfox May 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CONTRIBUTORS.toml
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,8 @@ github = "UlrikBuchholtz"
displayName = "Garrett Figueroa"
usernames = [ "Garrett Figueroa", "djspacewhale" ]
github = "djspacewhale"

[[contributors]]
displayName = "Viktor Yudov"
usernames = [ "Viktor Yudov" ]
github = "spcfox"
35 changes: 34 additions & 1 deletion src/foundation-core/decidable-propositions.lagda.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ open import foundation.coproduct-types
open import foundation.decidable-types
open import foundation.dependent-pair-types
open import foundation.double-negation
open import foundation.empty-types
open import foundation.equivalences
open import foundation.logical-equivalences
open import foundation.negation
open import foundation.propositional-truncations
open import foundation.small-types
open import foundation.unit-type
open import foundation.universe-levels

open import foundation-core.cartesian-product-types
open import foundation-core.empty-types
open import foundation-core.function-types
open import foundation-core.functoriality-dependent-pair-types
open import foundation-core.propositions
Expand Down Expand Up @@ -189,3 +192,33 @@ is-merely-decidable-is-decidable-trunc-Prop A (inl x) =
is-merely-decidable-is-decidable-trunc-Prop A (inr f) =
unit-trunc-Prop (inr (f ∘ unit-trunc-Prop))
```

### TODO

```agda
-- TODO: not only for decidable
equiv-empty-is-decidable-prop :
{l : Level} {A : UU l} → is-decidable-prop A → ¬ A → A ≃ empty
equiv-empty-is-decidable-prop {l} {A} (is-p , _) contra =
equiv-iff (A , is-p) empty-Prop contra ex-falso
Comment on lines +200 to +203
Copy link
Collaborator

Choose a reason for hiding this comment

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

This already in the library as equiv-is-empty. Note that any map into the empty type (or indeed into any empty type) is an equivalence.


-- TODO: not only for decidable
equiv-unit-is-decidable-prop :
{l : Level} {A : UU l} → is-decidable-prop A → A → A ≃ unit
equiv-unit-is-decidable-prop {l} {A} (is-p , _) a =
equiv-iff (A , is-p) unit-Prop (λ _ → star) (λ _ → a)
Comment on lines +206 to +209
Copy link
Collaborator

Choose a reason for hiding this comment

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

A few pointers:

  • Any proposition equipped with an element is contractible. This is shown here: is-proof-irrelevant-is-prop. The notion of proof irrelevance means A -> is-contr A in agda-unimath.
  • Any contractible type is equivalent to the unit type: equiv-unit-is-contr.


equiv-empty-or-unit-is-decidable-prop :
{l : Level} {A : UU l} → is-decidable-prop A → (A ≃ unit) + (A ≃ empty)
equiv-empty-or-unit-is-decidable-prop {l} {A} H@(_ , is-d) with is-d
... | inl contra = inl (equiv-unit-is-decidable-prop H contra)
... | inr a = inr (equiv-empty-is-decidable-prop H a)

-- TODO: move to foundation
is-small-prop-is-decidable-prop :
{l1 : Level} (l2 : Level) (A : UU l1) → is-decidable-prop A → is-small l2 A
is-small-prop-is-decidable-prop l2 A H
with equiv-empty-or-unit-is-decidable-prop H
... | inl e = is-small-equiv unit e (raise-unit l2 , compute-raise-unit l2)
... | inr e = is-small-equiv empty e (raise-empty l2 , compute-raise-empty l2)
Comment on lines +218 to +223
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice!

```
5 changes: 5 additions & 0 deletions src/foundation-core/injective-maps.lagda.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ module _
is-injective h → is-injective g → is-injective (g ∘ h)
is-injective-comp is-inj-h is-inj-g = is-inj-h ∘ is-inj-g

injection-comp :
injection A B → injection B C → injection A C
injection-comp (f , is-inj-f) (g , is-inj-g) =
g ∘ f , is-injective-comp is-inj-f is-inj-g
Comment on lines +93 to +96
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would you mind renaming this to comp-injection? This would fit better with the naming scheme we currently have, which goes comp-pointed-map, comp-hom-Group, and so on.

Note that I just found an exception to this naming scheme, which is that we use equiv-comp. That's probably a mistake on our part, which we missed because we usually use the infix notation for composition of equivalences.


is-injective-left-map-triangle :
(f : A → C) (g : B → C) (h : A → B) → f ~ (g ∘ h) →
is-injective h → is-injective g → is-injective f
Expand Down
1 change: 1 addition & 0 deletions src/foundation.lagda.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ open import foundation.binary-homotopies public
open import foundation.binary-operations-unordered-pairs-of-types public
open import foundation.binary-reflecting-maps-equivalence-relations public
open import foundation.binary-relations public
open import foundation.binary-relations-transitive-closures public
open import foundation.binary-relations-with-extensions public
open import foundation.binary-relations-with-lifts public
open import foundation.binary-transport public
Expand Down
120 changes: 120 additions & 0 deletions src/foundation/binary-relations-transitive-closures.lagda.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Transitive Closures

```agda
module foundation.binary-relations-transitive-closures where
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would you mind renaming this file to transitive-closures-binary-relations?

We usually name the concept of interest first, and then disambiguate later. For instance, we have several files about the action on identifications files all named action-on-identifications-disambiguation.

```

<details><summary>Imports</summary>

```agda
open import foundation.binary-relations
open import foundation.propositional-truncations
open import foundation.universe-levels

open import foundation-core.function-types
open import foundation-core.propositions
```

</details>

## Idea

TODO
Copy link
Collaborator

Choose a reason for hiding this comment

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

### Transitive closures of binary relations valued in types

The {{#concept "transitive closure" Agda=transitive-closure}} of a [binary relation](foundation.binary-relations.md) `R : A → A → Type` is a transitive binary relation `R' : A → A → Type` equipped with a family of maps

```text
  (x y : A) → R x y → R' x y,
```

satisfying the universal property that for any transitive binary relation `S : A → A → Type` the evaluation map

```text
  hom-transitive-relation R' S → (x y : A) → R x y → S x y
```

is an [equivalence](foundation-core.equivalences.md). Here, the type `hom-transitive-relation R' S` is the type of families of maps

```text
  (x y : A) → R' x y → S x y
```

that preserve the composition operation.

### Transitive closures of binary relations valued in propositions

The transitive closure of a binary relation `R : A → A → Prop` valued in [propositions](foundation-core.propositions.md) is the least transitive relation containing `R`. In other words, it is a transitive relation `R' : A → A → Prop` such that for any transitive relation `S : A → A → Prop` the map

```text
  ((x y : A) → R' x y → S x y) → ((x y : A) → R x y → S x y)
```

is an equivalence. Since the relations here are all valued in propositions, and hence proof irrelevant, we do not need to require that the morphisms from `R'` to `S` preserve composition.


## Definition

```agda
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
```agda
### Transitive closures of binary relations valued in types
```agda

module _
{l1 l2 : Level} {A : UU l1}
where

data transitive-closure (R : Relation l2 A) : Relation (l1 ⊔ l2) A
where
transitive-closure-base : {x y : A} → R x y → transitive-closure R x y
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is the unit of an adjunction, we could consider calling this unit-transitive-closure.

transitive-closure-step :
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would probably call this step-transitive-closure. We like to name the function first, and then any disambiguative information.

{x y z : A} → R x y → transitive-closure R y z → transitive-closure R x z

is-transitive-transitive-closure :
(R : Relation l2 A) → is-transitive (transitive-closure R)
is-transitive-transitive-closure
R x y z c-yz (transitive-closure-base r-xy) =
transitive-closure-step r-xy c-yz
is-transitive-transitive-closure
R x y z c-yz (transitive-closure-step {y = u} r-xu c-uy) =
transitive-closure-step r-xu
( is-transitive-transitive-closure R u y z c-yz c-uy)

transitive-closure-preserves-reflexivity :
(R : Relation l2 A) →
is-reflexive R →
is-reflexive (transitive-closure R)
transitive-closure-preserves-reflexivity R is-refl x =
transitive-closure-base (is-refl x)
Comment on lines +47 to +52
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here: preserves-reflexivity-transitive-closure

I would also consider creating a section ## Properties below for this entry, and have a header ### The transitive closure operation preserves proofs of reflexivity

Your work will be more easily searchable that way :)


transitive-closure-preserves-symmetry :
(R : Relation l2 A) →
is-symmetric R →
is-symmetric (transitive-closure R)
transitive-closure-preserves-symmetry R is-sym x y
(transitive-closure-base r) =
transitive-closure-base (is-sym x y r)
transitive-closure-preserves-symmetry
R is-sym x y (transitive-closure-step {y = u} r-xu c-uy) =
is-transitive-transitive-closure R y u x
( transitive-closure-base (is-sym x u r-xu))
( transitive-closure-preserves-symmetry R is-sym u y c-uy)
Comment on lines +54 to +65
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here: preserves-symmetry-transitive-closure.

This could also go under ## Properties with a header ### The transitive closure operation on binary relations preserves proofs of symmetry.

```

### Transitive closure of a relation valued in propositions
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
### Transitive closure of a relation valued in propositions
### Transitive closures of a relation valued in propositions

This should either be "The transitive closure of ..." or "Transitive closures of". In English we use definite/indefinite articles, like "the" or "a", a bit more than in Slavic languages. I live in Slovenia, so I know from experience that people tend to struggle with this, so it is no biggie.


```agda
transitive-closure-Prop :
(R : Relation-Prop l2 A) → Relation-Prop (l1 ⊔ l2) A
transitive-closure-Prop R x y =
trunc-Prop (transitive-closure (type-Relation-Prop R) x y)

is-transitive-transitive-closure-Prop :
(R : Relation-Prop l2 A) →
is-transitive-Relation-Prop (transitive-closure-Prop R)
is-transitive-transitive-closure-Prop R x y z c-yz c-xy =
apply-twice-universal-property-trunc-Prop
( c-yz)
( c-xy)
( transitive-closure-Prop R x z)
( λ r-yz r-xy →
unit-trunc-Prop
( is-transitive-transitive-closure
( type-Relation-Prop R)
( x)
( y)
( z)
( r-yz)
( r-xy)))

transitive-closure-Prop-preserves-reflexivity :
(R : Relation-Prop l2 A) →
is-reflexive-Relation-Prop R →
is-reflexive-Relation-Prop (transitive-closure-Prop R)
transitive-closure-Prop-preserves-reflexivity R is-refl x =
unit-trunc-Prop
( transitive-closure-preserves-reflexivity
( type-Relation-Prop R)
( is-refl)
( x))

transitive-closure-Prop-preserves-symmetry :
(R : Relation-Prop l2 A) →
is-symmetric-Relation-Prop R →
is-symmetric-Relation-Prop (transitive-closure-Prop R)
transitive-closure-Prop-preserves-symmetry R is-sym x y =
map-universal-property-trunc-Prop
( transitive-closure-Prop R y x)
( λ r-xy →
unit-trunc-Prop
( transitive-closure-preserves-symmetry
( type-Relation-Prop R)
( is-sym)
( x)
( y)
Comment on lines +94 to +118
Copy link
Collaborator

Choose a reason for hiding this comment

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

These two can also go under ## Properties with section names ### The transitive closure operation on binary relations valued in propositions preserves proofs of reflexivity and ### The transitive closure operation on binary relations valued in propositions preserves proofs of symmetry.

( r-xy)))
```
12 changes: 12 additions & 0 deletions src/foundation/decidable-types.lagda.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,15 @@ module _
is-decidable-raise (inl p) = inl (map-raise p)
is-decidable-raise (inr np) = inr (λ p' → np (map-inv-raise p'))
```

### For decidable type `Q` `¬ Q → ¬ P` implies `P → Q`

```agda
contraposition-is-decidable :
{l1 l2 : Level} {P : UU l1} {Q : UU l2} →
is-decidable Q →
(¬ Q → ¬ P) →
P → Q
contraposition-is-decidable {Q = Q} (inl q) f p = q
contraposition-is-decidable {Q = Q} (inr nq) f p = ex-falso (f nq p)
```
Comment on lines +274 to +284
Copy link
Collaborator

Choose a reason for hiding this comment

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

Excellent!

Loading
Loading