Some basic sets (#94)

This commit is contained in:
Patrick Stevens
2020-02-03 07:09:51 +00:00
committed by GitHub
parent cbe55c9b56
commit d29c7ea681
8 changed files with 213 additions and 71 deletions

View File

@@ -0,0 +1,19 @@
{-# OPTIONS --safe --warning=error --without-K #-}
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import LogicalFormulae
open import Sets.EquivalenceRelations
open import Setoids.Setoids
module Setoids.Union.Definition {a b : _} {A : Set a} (S : Setoid {a} {b} A) where
open Setoid S
open Equivalence eq
open import Setoids.Subset S
unionPredicate : {c d : _} {pred1 : A Set c} {pred2 : A Set d} (s1 : subset pred1) (s2 : subset pred2) A Set (c d)
unionPredicate {pred1 = pred1} {pred2} s1 s2 a = pred1 a || pred2 a
union : {c d : _} {pred1 : A Set c} {pred2 : A Set d} (s1 : subset pred1) (s2 : subset pred2) subset (unionPredicate s1 s2)
union s1 s2 {x1} {x2} x1=x2 (inl x) = inl (s1 x1=x2 x)
union s1 s2 {x1} {x2} x1=x2 (inr x) = inr (s2 x1=x2 x)

34
Setoids/Union/Lemmas.agda Normal file
View File

@@ -0,0 +1,34 @@
{-# OPTIONS --safe --warning=error --without-K #-}
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import LogicalFormulae
open import Sets.EquivalenceRelations
open import Setoids.Setoids
open import Setoids.Subset
module Setoids.Union.Lemmas {a b : _} {A : Set a} (S : Setoid {a} {b} A) {c d : _} {pred1 : A Set c} {pred2 : A Set d} (s1 : subset S pred1) (s2 : subset S pred2) where
open import Setoids.Union.Definition S
open import Setoids.Equality S
unionCommutative : union s1 s2 =S union s2 s1
unionCommutative i = ans1 ,, ans2
where
ans1 : unionPredicate s1 s2 i unionPredicate s2 s1 i
ans1 (inl x) = inr x
ans1 (inr x) = inl x
ans2 : unionPredicate s2 s1 i unionPredicate s1 s2 i
ans2 (inl x) = inr x
ans2 (inr x) = inl x
unionAssociative : {e : _} {pred3 : A Set e} (s3 : subset S pred3) union (union s1 s2) s3 =S union s1 (union s2 s3)
unionAssociative s3 x = ans1 ,, ans2
where
ans1 : unionPredicate (union s1 s2) s3 x unionPredicate s1 (union s2 s3) x
ans1 (inl (inl x)) = inl x
ans1 (inl (inr x)) = inr (inl x)
ans1 (inr x) = inr (inr x)
ans2 : _
ans2 (inl x) = inl (inl x)
ans2 (inr (inl x)) = inl (inr x)
ans2 (inr (inr x)) = inr x