m1-internship/PropUtil.agda

125 lines
3.7 KiB
Agda
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{-# OPTIONS --prop --rewriting #-}
module PropUtil where
-- ⊥ is a data with no constructor
-- is a record with one always-available constructor
data : Prop where
record : Prop where
constructor tt
data __ : Prop Prop Prop where
inj₁ : {P Q : Prop} P P Q
inj₂ : {P Q : Prop} Q P Q
record _∧_ (P Q : Prop) : Prop where
constructor ⟨_,_⟩
field
p : P
q : Q
infixr 10 _∧_
infixr 11 __
-- ∧ elimination
proj₁ : {P Q : Prop} P Q P
proj₁ pq = _∧_.p pq
proj₂ : {P Q : Prop} P Q Q
proj₂ pq = _∧_.q pq
-- elimination
dis : {P Q S : Prop} (P Q) (P S) (Q S) S
dis (inj₁ p) ps qs = ps p
dis (inj₂ q) ps qs = qs q
-- ¬ is a shorthand for « → ⊥ »
¬ : Prop Prop
¬ P = P
-- ⊥ elimination
case⊥ : {P : Prop} P
case⊥ ()
-- ⇔ shorthand
_⇔_ : Prop Prop Prop
P Q = (P Q) (Q P)
-- Syntactic sugar for writing applications
infixr 200 _$_
_$_ : {T U : Prop} (T U) T U
h $ t = h t
open import Agda.Primitive
postulate _≈_ : {}{A : Set }(a : A) A Set
{-# BUILTIN REWRITE _≈_ #-}
infix 3 _≡_
data _≡_ {}{A : Set }(a : A) : A Prop where
refl : a a
≡sym : { : Level} {A : Set } {a a' : A} a a' a' a
≡sym refl = refl
≡tran : { : Level} {A : Set } {a a' a'' : A} a a' a' a'' a a''
≡tran refl refl = refl
postulate ≡fun : { ' : Level} {A : Set } {B : Set '} {f g : A B} ((x : A) (f x g x)) f g
postulate ≡fun' : { ' : Level} {A : Set } {B : A Set '} {f g : (a : A) B a} ((x : A) (f x g x)) f g
postulate subst : {}{A : Set }{'}(P : A Set '){a a' : A} a a' P a P a'
postulate substP : {}{A : Set }{'}(P : A Prop '){a a' : A} a a' P a P a'
postulate substrefl : {}{A : Set }{'}{P : A Set '}{a : A}{e : a a}{p : P a} subst P e p p
{-# REWRITE substrefl #-}
cong : { ' : Level}{A : Set }{B : Set '} (f : A B) {a a' : A} a a' f a f a'
cong f refl = refl
cong₂ : { ' '' : Level}{A : Set }{B : Set '}{C : Set ''} (f : A B C) {a a' : A} {b b' : B} a a' b b' f a b f a' b'
cong₂ f refl refl = refl
{-# BUILTIN EQUALITY _≡_ #-}
data Nat : Set where
zero : Nat
succ : Nat Nat
{-# BUILTIN NATURAL Nat #-}
variable
' : Level
record _×_ (A : Set ) (B : Set ) : Set where
constructor _,×_
field
a : A
b : B
record _×'_ (A : Set ) (B : Prop ) : Set where
constructor _,×'_
field
a : A
b : B
record _×''_ (A : Set ) (B : A Prop ') : Set ( ') where
constructor _,×''_
field
a : A
b : B a
proj× : {A B : Set} (A × B) A
proj× p = _×_.a p
proj× : {A B : Set} (A × B) B
proj× p = _×_.b p
proj×'₁ : {A : Set} {B : Prop} (A ×' B) A
proj×'₁ p = _×'_.a p
proj×'₂ : {A : Set} {B : Prop} (A ×' B) B
proj×'₂ p = _×'_.b p
proj×''₁ : {A : Set} {B : A Prop} (A ×'' B) A
proj×''₁ p = _×''_.a p
proj×''₂ : {A : Set} {B : A Prop} (p : A ×'' B) B (proj×''₁ p)
proj×''₂ p = _×''_.b p