mirror of
https://github.com/Smaug123/agdaproofs
synced 2025-10-08 21:38:40 +00:00
113 lines
3.9 KiB
Agda
113 lines
3.9 KiB
Agda
{-# OPTIONS --safe --warning=error #-}
|
|
|
|
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
|
|
|
|
module LogicalFormulae where
|
|
|
|
infix 5 _≡_
|
|
data _≡_ {a} {A : Set a} (x : A) : A → Set a where
|
|
refl : x ≡ x
|
|
|
|
{-# BUILTIN EQUALITY _≡_ #-}
|
|
|
|
data False : Set where
|
|
|
|
record True : Set where
|
|
record Unit : Set where
|
|
|
|
infix 10 _||_
|
|
data _||_ {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where
|
|
inl : A → A || B
|
|
inr : B → A || B
|
|
|
|
data Bool : Set where
|
|
BoolTrue : Bool
|
|
BoolFalse : Bool
|
|
|
|
infix 15 _&&_
|
|
record _&&_ {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where
|
|
constructor _,,_
|
|
field
|
|
fst : A
|
|
snd : B
|
|
|
|
infix 15 _&_&_
|
|
record _&_&_ {a b c} (A : Set a) (B : Set b) (C : Set c) : Set (a ⊔ b ⊔ c) where
|
|
field
|
|
one : A
|
|
two : B
|
|
three : C
|
|
|
|
data Sg {n : _} {m : _} (A : Set m) (B : A → Set n) : Set (m ⊔ n) where
|
|
_,_ : (a : A) → (b : B a) → Sg A B
|
|
|
|
underlying : {n m : _} {A : _} {prop : _} → Sg {n} {m} A prop -> A
|
|
underlying (a , b) = a
|
|
|
|
transitivity : {a : _} {A : Set a} {x y z : A} → (x ≡ y) → (y ≡ z) → (x ≡ z)
|
|
transitivity refl refl = refl
|
|
|
|
liftEquality : {a : _} {A B : Set a} (f g : A → B) → (x y : A) → (f ≡ g) → (x ≡ y) → ((f x) ≡ (g y))
|
|
liftEquality f .f x .x refl refl = refl
|
|
|
|
applyEquality : {a : _} {b : _} {A : Set a} {B : Set b} (f : A → B) → {x y : A} → (x ≡ y) → ((f x) ≡ (f y))
|
|
applyEquality {A} {B} f {x} {.x} refl = refl
|
|
|
|
identityOfIndiscernablesLeft : {m n o : _} {A : Set m} {B : Set n} (a : A) (b : B) (c : A) → (prop : A → B → Set o) → (prop a b) → (a ≡ c) → (prop c b)
|
|
identityOfIndiscernablesLeft a b .a prop pAB refl = pAB
|
|
|
|
identityOfIndiscernablesRight : {m n o : _} {A : Set m} {B : Set n} (a : A) (b c : B) → (prop : A → B → Set o) → (prop a b) → (b ≡ c) → (prop a c)
|
|
identityOfIndiscernablesRight a b .b prop prAB refl = prAB
|
|
|
|
equalityCommutative : {a : _} {A : Set a} {x y : A} → (x ≡ y) → (y ≡ x)
|
|
equalityCommutative refl = refl
|
|
|
|
exFalso : {n : _} {A : Set n} → False → A
|
|
exFalso {a} = λ ()
|
|
|
|
orIsAssociative : {n : _} {a b c : Set n} → ((a || b) || c) → (a || (b || c))
|
|
orIsAssociative (inl (inl x)) = inl x
|
|
orIsAssociative (inl (inr x)) = inr (inl x)
|
|
orIsAssociative (inr x) = inr (inr x)
|
|
|
|
leqConstructive : {n : _} → {p : Set n} → (p || (p → False)) → (((p → False) → False) → p)
|
|
leqConstructive (inl p) = λ _ → p
|
|
leqConstructive (inr notP) = λ negnegP → exFalso (negnegP notP)
|
|
|
|
lemConverse : {n : _} → {p : Set n} → p → ((p → False) → False)
|
|
lemConverse p = λ notP → notP p
|
|
|
|
if_then_else_ : {a : _} → {A : Set a} → Bool → A → A → A
|
|
if BoolTrue then tr else fls = tr
|
|
if BoolFalse then tr else fls = fls
|
|
|
|
not : Bool → Bool
|
|
not BoolTrue = BoolFalse
|
|
not BoolFalse = BoolTrue
|
|
|
|
typeCast : {a : _} {A : Set a} {B : Set a} (el : A) (pr : A ≡ B) → B
|
|
typeCast {a} {A} {.A} elt refl = elt
|
|
|
|
typeCastEqual : {a : _} {A : Set a} {B : Set a} {el : A} (pr1 pr2 : A ≡ B) → (typeCast el pr1) ≡ (typeCast el pr2)
|
|
typeCastEqual {a} {A} {.A} {el} refl refl = refl
|
|
|
|
data Singleton {a} {A : Set a} (x : A) : Set a where
|
|
_with≡_ : (y : A) → x ≡ y → Singleton x
|
|
|
|
inspect : ∀ {a} {A : Set a} (x : A) → Singleton x
|
|
inspect x = x with≡ refl
|
|
|
|
curry : {a b c : _} {A : Set a} {B : Set b} {C : Set c} (f : A → B → C) → ((Sg A (λ _ → B)) → C)
|
|
curry f (a , b) = f a b
|
|
|
|
uncurry : {a b c : _} {A : Set a} {B : Set b} {C : Set c} (f : (Sg A (λ _ → B)) → C) → (A → B → C)
|
|
uncurry f a b = f (a , b)
|
|
|
|
decidableOr : {a b : _} → (A : Set a) → (B : Set b) → (A || (A → False)) → (A || B) → (A || ((A → False) && B))
|
|
decidableOr {a} {b} A B decidable (inl x) = inl x
|
|
decidableOr {a} {b} A B (inl y) (inr x) = inl y
|
|
decidableOr {a} {b} A B (inr y) (inr x) = inr (record { fst = y ; snd = x})
|
|
|
|
reflRefl : {a : _} {A : Set a} → {r s : A} → (pr1 pr2 : r ≡ s) → pr1 ≡ pr2
|
|
reflRefl refl refl = refl
|