Martin Escardo.
General terminology and notation.
\begin{code}
{-# OPTIONS --safe --without-K #-}
module Notation.General where
open import MLTT.Pi
open import MLTT.Sigma
open import MLTT.Universes
open import MLTT.Id
open import MLTT.Negation public
\end{code}
The notation `Type ๐ค` should be avoided in favour of `๐ค ฬ`, but some
module do use it.
\begin{code}
Type = Set
Typeโ = Setโ
fiber : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } โ (X โ Y) โ Y โ ๐ค โ ๐ฅ ฬ
fiber f y = ฮฃ x ๊ domain f , f x ๏ผ y
to-fiber : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y) (x : X)
โ fiber f (f x)
to-fiber f x = x , refl
fiber-point : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } {f : X โ Y} {y : Y} โ fiber f y โ X
fiber-point = prโ
fiber-identification : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } {f : X โ Y} {y : Y} (w : fiber f y)
โ f (fiber-point w) ๏ผ y
fiber-identification = prโ
each-fiber-of : {X : ๐ค ฬ } {Y : ๐ฅ ฬ }
โ (X โ Y)
โ (๐ค โ ๐ฅ ฬ โ ๐ฆ ฬ )
โ ๐ฅ โ ๐ฆ ฬ
each-fiber-of f P = โ y โ P (fiber f y)
fix : {X : ๐ค ฬ } โ (f : X โ X) โ ๐ค ฬ
fix f = ฮฃ x ๊ domain f , x ๏ผ f x
from-fix : {X : ๐ค ฬ } (f : X โ X) โ fix f โ X
from-fix f = prโ
from-fix-is-fixed : {X : ๐ค ฬ } (f : X โ X) (ฯ : fix f)
โ from-fix f ฯ ๏ผ f (from-fix f ฯ)
from-fix-is-fixed f = prโ
reflexive : {X : ๐ค ฬ } โ (X โ X โ ๐ฅ ฬ ) โ ๐ค โ ๐ฅ ฬ
reflexive R = โ x โ R x x
symmetric : {X : ๐ค ฬ } โ (X โ X โ ๐ฅ ฬ ) โ ๐ค โ ๐ฅ ฬ
symmetric R = โ x y โ R x y โ R y x
antisymmetric : {X : ๐ค ฬ } โ (X โ X โ ๐ฅ ฬ ) โ ๐ค โ ๐ฅ ฬ
antisymmetric R = โ x y โ R x y โ R y x โ x ๏ผ y
transitive : {X : ๐ค ฬ } โ (X โ X โ ๐ฅ ฬ ) โ ๐ค โ ๐ฅ ฬ
transitive R = โ x y z โ R x y โ R y z โ R x z
idempotent-map : {X : ๐ฅ ฬ } โ (f : X โ X) โ ๐ฅ ฬ
idempotent-map f = โ x โ f (f x) ๏ผ f x
involutive : {X : ๐ฅ ฬ } โ (f : X โ X) โ ๐ฅ ฬ
involutive f = โ x โ f (f x) ๏ผ x
left-neutral : {X : ๐ค ฬ } โ X โ (X โ X โ X) โ ๐ค ฬ
left-neutral e _ยท_ = โ x โ e ยท x ๏ผ x
right-neutral : {X : ๐ค ฬ } โ X โ (X โ X โ X) โ ๐ค ฬ
right-neutral e _ยท_ = โ x โ x ยท e ๏ผ x
associative : {X : ๐ค ฬ } โ (X โ X โ X) โ ๐ค ฬ
associative _ยท_ = โ x y z โ (x ยท y) ยท z ๏ผ x ยท (y ยท z)
associative' : {X : ๐ค ฬ } โ (X โ X โ X) โ ๐ค ฬ
associative' _ยท_ = โ x y z โ x ยท (y ยท z) ๏ผ (x ยท y) ยท z
commutative : {X : ๐ค ฬ } โ (X โ X โ X) โ ๐ค ฬ
commutative _ยท_ = โ x y โ (x ยท y) ๏ผ (y ยท x)
left-cancellable : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } โ (X โ Y) โ ๐ค โ ๐ฅ ฬ
left-cancellable f = โ {x x'} โ f x ๏ผ f x' โ x ๏ผ x'
left-cancellable' : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } โ (X โ Y) โ ๐ค โ ๐ฅ ฬ
left-cancellable' f = โ x x' โ f x ๏ผ f x' โ x ๏ผ x'
right-cancellable : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } โ (X โ Y) โ ๐คฯ
right-cancellable f = {๐ฆ : Universe} {Z : ๐ฆ ฬ } (g h : codomain f โ Z)
โ g โ f โผ h โ f
โ g โผ h
_โ_ : ๐ค ฬ โ ๐ฅ ฬ โ ๐ค โ ๐ฅ ฬ
A โ B = (A โ B) ร (B โ A)
lr-implication : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } โ (X โ Y) โ (X โ Y)
lr-implication = prโ
rl-implication : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } โ (X โ Y) โ (Y โ X)
rl-implication = prโ
โ-sym : {X : ๐ค' ฬ } {Y : ๐ฅ' ฬ } โ X โ Y โ Y โ X
โ-sym (f , g) = (g , f)
โ-trans : {X : ๐ค' ฬ } {Y : ๐ฅ' ฬ } {Z : ๐ฆ' ฬ }
โ X โ Y โ Y โ Z โ X โ Z
โ-trans (f , g) (h , k) = (h โ f , g โ k)
โ-refl : {X : ๐ค' ฬ } โ X โ X
โ-refl = (id , id)
\end{code}
This is to avoid naming implicit arguments:
\begin{code}
type-of : {X : ๐ค ฬ } โ X โ ๐ค ฬ
type-of {๐ค} {X} x = X
\end{code}
We use the following to indicate the type of a subterm (where "โถ"
(typed "\:" in emacs) is not the same as ":"):
\begin{code}
-id : (X : ๐ค ฬ ) โ X โ X
-id X x = x
syntax -id X x = x โถ X
\end{code}
This is used for efficiency as a substitute for lazy "let" (or "where"):
\begin{code}
case_of_ : {A : ๐ค ฬ } {B : A โ ๐ฅ ฬ } โ (a : A) โ ((a : A) โ B a) โ B a
case x of f = f x
Case_of_ : {A : ๐ค ฬ } {B : A โ ๐ฅ ฬ } โ (a : A) โ ((x : A) โ a ๏ผ x โ B a) โ B a
Case x of f = f x refl
{-# NOINLINE case_of_ #-}
\end{code}
Notation to try to make proofs readable:
\begin{code}
need_which-is-given-by_ : (A : ๐ค ฬ ) โ A โ A
need A which-is-given-by a = a
have_by_ : (A : ๐ค ฬ ) โ A โ A
have A by a = a
have_so_ : {A : ๐ค ฬ } {B : ๐ฅ ฬ } โ A โ B โ B
have a so b = b
have_so-use_ : {A : ๐ค ฬ } {B : ๐ฅ ฬ } โ A โ B โ B
have a so-use b = b
have_and_ : {A : ๐ค ฬ } {B : ๐ฅ ฬ } โ A โ B โ B
have a and b = b
apply_to_ : {A : ๐ค ฬ } {B : ๐ฅ ฬ } โ (A โ B) โ A โ B
apply f to a = f a
have_so-apply_ : {A : ๐ค ฬ } {B : ๐ฅ ฬ } โ A โ (A โ B) โ B
have a so-apply f = f a
assume-then : (A : ๐ค ฬ ) {B : A โ ๐ฅ ฬ } โ ((a : A) โ B a) โ (a : A) โ B a
assume-then A f x = f x
syntax assume-then A (ฮป x โ b) = assume x โถ A then b
assume-and : (A : ๐ค ฬ ) {B : A โ ๐ฅ ฬ } โ ((a : A) โ B a) โ (a : A) โ B a
assume-and A f x = f x
syntax assume-and A (ฮป x โ b) = assume x โถ A and b
mapsto : {A : ๐ค ฬ } {B : A โ ๐ฅ ฬ } โ ((a : A) โ B a) โ (a : A) โ B a
mapsto f = f
syntax mapsto (ฮป x โ b) = x โฆ b
infixr 10 mapsto
Mapsto : (A : ๐ค ฬ ) {B : A โ ๐ฅ ฬ } โ ((a : A) โ B a) โ (a : A) โ B a
Mapsto A f = f
syntax Mapsto A (ฮป x โ b) = x ๊ A โฆ b
infixr 10 Mapsto
\end{code}
Get rid of this:
\begin{code}
ฮฃ! : {X : ๐ค ฬ } (A : X โ ๐ฅ ฬ ) โ ๐ค โ ๐ฅ ฬ
ฮฃ! {๐ค} {๐ฅ} {X} A = (ฮฃ x ๊ X , A x) ร ((x x' : X) โ A x โ A x' โ x ๏ผ x')
Sigma! : (X : ๐ค ฬ ) (A : X โ ๐ฅ ฬ ) โ ๐ค โ ๐ฅ ฬ
Sigma! X A = ฮฃ! A
syntax Sigma! A (ฮป x โ b) = ฮฃ! x ๊ A , b
infixr -1 Sigma!
\end{code}
Note: ฮฃ! is to be avoided, in favour of the contractibility of ฮฃ,
following univalent mathematics.
Fixities:
\begin{code}
infixl -1 -id
infix -1 _โ_
\end{code}