-
Notifications
You must be signed in to change notification settings - Fork 71
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
base: master
Are you sure you want to change the base?
Modal logic #1146
Changes from all commits
8a92a52
63b0e15
5f89c97
49f2cf6
517fc91
6053173
d1744d9
1f8f53f
661adc6
3b3ba68
957e112
341456a
9db88ca
30056ba
0d22369
21d74ce
8ecf60e
bb2f31b
41d20ab
03d2142
88cb89f
ef73d85
28fc80e
2ddac8e
e17134d
c1ae1ff
b358d85
9e3bb01
fd1cc31
39bccd5
200901a
77f1901
f31d02d
eb31291
0e1fd0e
b019f5b
f41eaff
53eb3bf
e51080a
317fd29
998bd15
8d29db3
02b75b6
7696793
89951d2
c60b49b
706ff33
424667a
873449a
4111374
662bc0f
29eed33
b2d85c4
294ae82
b978ed1
e44f24f
081aa53
0df9fd4
3555784
e1bc75f
a9d4e80
2cc2b80
ba35873
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
||
-- 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A few pointers:
|
||
|
||
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind renaming this to Note that I just found an exception to this naming scheme, which is that we use |
||
|
||
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 | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,120 @@ | ||||||||||
# Transitive Closures | ||||||||||
|
||||||||||
```agda | ||||||||||
module foundation.binary-relations-transitive-closures where | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind renaming this file to 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 |
||||||||||
``` | ||||||||||
|
||||||||||
<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 | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||
|
||||||||||
## Definition | ||||||||||
|
||||||||||
```agda | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
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 | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||||||
transitive-closure-step : | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would probably call this |
||||||||||
{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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here: I would also consider creating a section 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here: This could also go under |
||||||||||
``` | ||||||||||
|
||||||||||
### Transitive closure of a relation valued in propositions | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These two can also go under |
||||||||||
( r-xy))) | ||||||||||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Excellent! |
There was a problem hiding this comment.
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.