Search is not available for this dataset
text
string | meta
dict |
---|---|
{-# OPTIONS --without-K --rewriting #-}
open import lib.Basics
open import lib.two-semi-categories.Functor
open import lib.two-semi-categories.FundamentalCategory
open import lib.two-semi-categories.FunctorInverse
open import lib.types.Pi using ()
module lib.two-semi-categories.FunextFunctors where
module FunextFunctors {i j} (A : Type i) (B : Type j) {{B-level : has-level 2 B}} where
open import lib.two-semi-categories.FunCategory
private
app=-pres-comp : ∀ {f g h : A → B} (α : f == g) (β : g == h) → app= (α ∙ β) == (λ a → app= α a ∙ app= β a)
app=-pres-comp α β = λ= (λ a → ap-∙ (λ f → f a) α β)
abstract
app=-pres-comp-coh : ∀ {f g h i : A → B} (α : f == g) (β : g == h) (γ : h == i)
→ app=-pres-comp (α ∙ β) γ ◃∙
ap (λ s a → s a ∙ app= γ a) (app=-pres-comp α β) ◃∙
λ= (λ a → ∙-assoc (app= α a) (app= β a) (app= γ a)) ◃∎
=ₛ
ap app= (∙-assoc α β γ) ◃∙
app=-pres-comp α (β ∙ γ) ◃∙
ap (λ s a → app= α a ∙ s a) (app=-pres-comp β γ) ◃∎
app=-pres-comp-coh {f} idp idp γ =
app=-pres-comp idp γ ◃∙
ap (λ s a → s a ∙ app= γ a) (app=-pres-comp idp idp) ◃∙
λ= (λ a → idp) ◃∎
=ₛ⟨ 2 & 1 & =ₛ-in {t = []} (! (λ=-η idp)) ⟩
app=-pres-comp idp γ ◃∙
ap (λ s a → s a ∙ app= γ a) (λ= (λ a → idp {a = idp {a = f a}})) ◃∎
=ₛ₁⟨ 1 & 1 & ap (ap (λ s a → s a ∙ app= γ a)) (! (λ=-η idp)) ⟩
app=-pres-comp idp γ ◃∙
idp ◃∎
=ₛ₁⟨ 1 & 1 & ap (ap (λ s → s)) (λ=-η idp) ⟩
app=-pres-comp idp γ ◃∙
ap (λ s → s) (λ= (λ a → idp {a = app= γ a})) ◃∎
=ₛ⟨ 0 & 0 & contract ⟩
idp ◃∙
app=-pres-comp idp γ ◃∙
ap (λ s → s) (λ= (λ a → idp {a = app= γ a})) ◃∎ ∎ₛ
app=-functor : TwoSemiFunctor (2-type-fundamental-cat (A → B))
(fun-cat A (2-type-fundamental-cat B))
app=-functor =
record
{ F₀ = idf (A → B)
; F₁ = app=
; pres-comp = app=-pres-comp
; pres-comp-coh = app=-pres-comp-coh
}
private
module app=-functor =
TwoSemiFunctor app=-functor
module app=-inverse =
FunctorInverse
app=-functor
(idf-is-equiv _)
(λ f g → snd app=-equiv)
λ=-functor : TwoSemiFunctor (fun-cat A (2-type-fundamental-cat B))
(2-type-fundamental-cat (A → B))
λ=-functor = app=-inverse.functor
module λ=-functor = TwoSemiFunctor λ=-functor
abstract
λ=-functor-pres-comp=λ=-∙ : ∀ {f g h : A → B} (α : f ∼ g) (β : g ∼ h)
→ λ=-functor.pres-comp α β == =ₛ-out (λ=-∙ α β)
λ=-functor-pres-comp=λ=-∙ α β = =ₛ-out {t = =ₛ-out (λ=-∙ α β) ◃∎} $
λ=-functor.pres-comp α β ◃∎
=ₛ⟨ app=-inverse.pres-comp-β α β ⟩
idp ◃∙
ap2 (λ s t → λ= (λ a → s a ∙ t a)) (! (λ= (app=-β α))) (! (λ= (app=-β β))) ◃∙
ap λ= (! (λ= (λ a → ap-∙ (λ f → f a) (λ= α) (λ= β)))) ◃∙
! (λ=-η (λ= α ∙ λ= β)) ◃∎
=ₛ⟨ 0 & 1 & expand [] ⟩
ap2 (λ s t → λ= (λ a → s a ∙ t a)) (! (λ= (app=-β α))) (! (λ= (app=-β β))) ◃∙
ap λ= (! (λ= (λ a → ap-∙ (λ f → f a) (λ= α) (λ= β)))) ◃∙
! (λ=-η (λ= α ∙ λ= β)) ◃∎
=ₛ₁⟨ 0 & 1 & step₈ ⟩
ap λ= (! (λ= (λ a' → ap2 _∙_ (app=-β α a') (app=-β β a')))) ◃∙
ap λ= (! (λ= (λ a' → ap-∙ (λ γ → γ a') (λ= α) (λ= β)))) ◃∙
! (λ=-η (λ= α ∙ λ= β)) ◃∎
=ₛ⟨ 0 & 2 &
ap-seq-=ₛ λ= $ ∙-!-seq $
λ= (λ a' → ap-∙ (λ γ → γ a') (λ= α) (λ= β)) ◃∙
λ= (λ a' → ap2 _∙_ (app=-β α a') (app=-β β a')) ◃∎ ⟩
ap λ= (! (λ= (λ a' → ap-∙ (λ γ → γ a') (λ= α) (λ= β)) ∙
λ= (λ a' → ap2 _∙_ (app=-β α a') (app=-β β a')))) ◃∙
! (λ=-η (λ= α ∙ λ= β)) ◃∎
=ₛ₁⟨ 0 & 1 & ap-! λ= (λ= (λ a' → ap-∙ (λ γ → γ a') (λ= α) (λ= β)) ∙
λ= (λ a' → ap2 _∙_ (app=-β α a') (app=-β β a'))) ⟩
! (ap λ= (λ= (λ a' → ap-∙ (λ γ → γ a') (λ= α) (λ= β)) ∙
λ= (λ a' → ap2 _∙_ (app=-β α a') (app=-β β a')))) ◃∙
! (λ=-η (λ= α ∙ λ= β)) ◃∎
=ₛ₁⟨ 0 & 1 &
ap (! ∘ ap λ=) $ =ₛ-out $
∙-λ= (λ a' → ap-∙ (λ γ → γ a') (λ= α) (λ= β))
(λ a' → ap2 _∙_ (app=-β α a') (app=-β β a')) ⟩
! (ap λ= (λ= (λ a' → ap-∙ (λ γ → γ a') (λ= α) (λ= β) ∙
ap2 _∙_ (app=-β α a') (app=-β β a')))) ◃∙
! (λ=-η (λ= α ∙ λ= β)) ◃∎
=ₛ⟨ =ₛ-in $
∙-! (ap λ= (λ= (λ a' → ap-∙ (λ γ → γ a') (λ= α) (λ= β) ∙
ap2 _∙_ (app=-β α a') (app=-β β a'))))
(λ=-η (λ= α ∙ λ= β)) ⟩
! (λ=-η (λ= α ∙ λ= β) ∙
ap λ= (λ= (λ a' → ap-∙ (λ γ → γ a') (λ= α) (λ= β) ∙
ap2 _∙_ (app=-β α a') (app=-β β a')))) ◃∎ ∎ₛ
where
step₈' : ap2 (λ s t a → s a ∙ t a) (λ= (app=-β α)) (λ= (app=-β β)) ==
λ= (λ a' → ap2 _∙_ (app=-β α a') (app=-β β a'))
step₈' =
–>-is-inj app=-equiv _ _ $ λ= $ λ a →
app= (ap2 (λ s t a' → s a' ∙ t a') (λ= (app=-β α)) (λ= (app=-β β))) a
=⟨ ap-ap2 (λ f → f a) (λ s t a' → s a' ∙ t a') (λ= (app=-β α)) (λ= (app=-β β)) ⟩
ap2 (λ s t → s a ∙ t a) (λ= (app=-β α)) (λ= (app=-β β))
=⟨ ! (ap2-ap-lr _∙_ (λ f → f a) (λ f → f a) (λ= (app=-β α)) (λ= (app=-β β))) ⟩
ap2 _∙_ (app= (λ= (app=-β α)) a) (app= (λ= (app=-β β)) a)
=⟨ ap2 (ap2 _∙_) (app=-β (app=-β α) a) (app=-β (app=-β β) a) ⟩
ap2 _∙_ (app=-β α a) (app=-β β a)
=⟨ ! (app=-β (λ a' → ap2 _∙_ (app=-β α a') (app=-β β a')) a) ⟩
app= (λ= (λ a' → ap2 _∙_ (app=-β α a') (app=-β β a'))) a =∎
step₈ : ap2 (λ s t → λ= (λ a → s a ∙ t a)) (! (λ= (app=-β α))) (! (λ= (app=-β β))) ==
ap λ= (! (λ= (λ a' → ap2 _∙_ (app=-β α a') (app=-β β a'))))
step₈ =
ap2 (λ s t → λ= (λ a → s a ∙ t a)) (! (λ= (app=-β α))) (! (λ= (app=-β β)))
=⟨ ! (ap-ap2 λ= (λ s t a → s a ∙ t a) (! (λ= (app=-β α))) (! (λ= (app=-β β)))) ⟩
ap λ= (ap2 (λ s t a → s a ∙ t a) (! (λ= (app=-β α))) (! (λ= (app=-β β))))
=⟨ ap (ap λ=) (ap2-! (λ s t a → s a ∙ t a) (λ= (app=-β α)) (λ= (app=-β β))) ⟩
ap λ= (! (ap2 (λ s t a → s a ∙ t a) (λ= (app=-β α)) (λ= (app=-β β))))
=⟨ ap (ap λ= ∘ !) step₈' ⟩
ap λ= (! (λ= (λ a' → ap2 _∙_ (app=-β α a') (app=-β β a')))) =∎
|
{
"alphanum_fraction": 0.3751390876,
"avg_line_length": 44.9357142857,
"ext": "agda",
"hexsha": "fae3251e530f2c5dd7d0a2acbe3d3c997713f2fa",
"lang": "Agda",
"max_forks_count": 50,
"max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z",
"max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "AntoineAllioux/HoTT-Agda",
"max_forks_repo_path": "core/lib/two-semi-categories/FunextFunctors.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "AntoineAllioux/HoTT-Agda",
"max_issues_repo_path": "core/lib/two-semi-categories/FunextFunctors.agda",
"max_line_length": 110,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "AntoineAllioux/HoTT-Agda",
"max_stars_repo_path": "core/lib/two-semi-categories/FunextFunctors.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z",
"num_tokens": 2983,
"size": 6291
}
|
------------------------------------------------------------------------------
-- An inductive predicate for representing functions
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOT.FOTC.Data.Fun where
open import FOTC.Base
------------------------------------------------------------------------------
-- 2012-03-13. I don't see how we can distinguish between data
-- elements and functions in FOTC. The following inductive predicate
-- is true for any element d : D.
data Fun : D → Set where
fun : (f : D) → Fun f
-- But using a λ-abstraction we could make a distinguish:
postulate lam : (D → D) → D -- LTC-PCF λ-abstraction.
data Fun₁ : D → Set where
fun₁ : (f : D → D) → Fun₁ (lam f)
|
{
"alphanum_fraction": 0.4654226125,
"avg_line_length": 35.0384615385,
"ext": "agda",
"hexsha": "5e069bc891730d505c3e215c2be5256afa192a40",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "notes/FOT/FOTC/Data/Fun.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "notes/FOT/FOTC/Data/Fun.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/FOT/FOTC/Data/Fun.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z",
"num_tokens": 191,
"size": 911
}
|
-- Andreas, 2020-03-20, issue #4482, reported by gallai
-- Precise range for unexpected implicit argument.
_ : Set → {A : Set} → {B : Set} → {C : Set} → Set
_ = λ { _ {B = B} {A = A} → {!!} }
-- Unexpected implicit argument
-- when checking the clause left hand side
-- .extendedlambda0 _ {B = B} {A = A}
-- ^ highlight this
|
{
"alphanum_fraction": 0.5543175487,
"avg_line_length": 32.6363636364,
"ext": "agda",
"hexsha": "d106c9461b698f8012c7212b354d18612b3d7150",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "test/Fail/Issue4482.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue4482.agda",
"max_line_length": 55,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue4482.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 109,
"size": 359
}
|
{-# OPTIONS --prop --rewriting #-}
module Examples.Queue where
open import Calf.CostMonoid
open import Calf.CostMonoids using (ℕ-CostMonoid)
costMonoid = ℕ-CostMonoid
open CostMonoid costMonoid using (ℂ)
open import Calf costMonoid
open import Calf.Types.Nat
open import Calf.Types.Unit
open import Calf.Types.Sum
open import Calf.Types.Bounded costMonoid
open import Function
open import Data.Nat
open import Data.Nat.Properties
import Data.Integer as Int
import Data.Integer.Properties as IntP
open import Data.List renaming (sum to lsum)
open import Data.Product
open import Relation.Binary.PropositionalEquality as P
record Queue (A : tp pos) : Set where
field
Q : tp pos
emp : val Q
enq : cmp (Π Q λ _ → Π A λ _ → F Q)
deq : cmp (Π Q λ _ → F (sum unit (Σ++ Q λ _ → A)))
module CostList (A : tp pos) (n : ℕ) where
-- Suppose we want to implement the Queue signature above using lists.
-- One cost model is to count the number of times a cons node is inspected.
-- This is implemented by the following annotated list type:
-- destructing a cons node of type list n A consumes n steps.
postulate
list : tp pos
nil : val list
cons : val A → val list → val list
list/ind : (l : val list) → (X : val list → tp neg) → cmp (X nil) →
((a : val A) → (l : val list) → (r : val (U (X l))) →
cmp (X (cons a l))) →
cmp (X l)
list/ind/nil : ∀ {X} → (e0 : cmp (X nil)) →
(e1 : (a : val A) → (l : val list) → (r : val (U (X l))) →
cmp (X (cons a l))) →
list/ind nil X e0 e1 ≡ e0
{-# REWRITE list/ind/nil #-}
list/ind/cons : ∀ {X} → (a : val A) → (l : val list) → (e0 : cmp (X nil)) →
(e1 : (a : val A) → (l : val list) → (r : val (U (X l))) →
cmp (X (cons a l))) →
list/ind (cons a l) X e0 e1 ≡ step (X (cons a l)) n (e1 a l (list/ind l X e0 e1))
{-# REWRITE list/ind/cons #-}
list/match : (l : val list) → (X : val list → tp neg) → cmp (X nil) →
((a : val A) → (l : val list) → cmp (X (cons a l))) →
cmp (X l)
list/match l X e0 e1 = list/ind l X e0 (λ a l _ → e1 a l)
bound/list/match : ∀ (l : val list) (X : val list → tp pos)
{e0 : val (U (F (X nil)))} {e1 : (a : val A) → (l : val list) → val (U (F (X (cons a l))))}
{p0 : val (U cost)} {p1 : (a : val A) → (l : val list) → val (U cost)} →
IsBounded (X nil) e0 p0 →
((a : val A) → (l : val list) → IsBounded (X (cons a l)) (e1 a l) (p1 a l)) →
IsBounded (X l) (list/match l (F ∘ X) e0 e1) (list/match l (λ _ → cost) p0 (λ a l → n + p1 a l))
bound/list/match l X {e0} {e1} {p0} {p1} ub0 ub1 =
list/match l (λ l → meta (IsBounded (X l) (list/match l (F ∘ X) e0 e1) (list/match l (λ _ → cost) p0 (λ a l → n + p1 a l))))
ub0
λ a l → bound/circ n (bound/step n (p1 a l) (ub1 a l))
len : val list → ℕ
len l = list/ind l (λ _ → meta ℕ) 0 λ a l r → 1 + r
module Ex/CostList where
open CostList nat 0
ex : val list
ex = cons 0 (cons 1 nil)
module Rev (A : tp pos) where
open CostList A 1
revAppend : cmp (Π list λ _ → Π list λ _ → F list)
revAppend l =
list/ind l (λ _ → Π list λ _ → F list)
(λ l' → ret l')
λ x _ r → λ l' → r (cons x l')
revAppend/lemma/cons : ∀ x xs l' → ◯ (∃ λ y → ∃ λ ys → (len ys ≡ len xs + len l') × revAppend (cons x xs) l' ≡ ret (cons y ys))
revAppend/lemma/cons x xs =
list/ind xs (λ xs → meta (∀ x l' → ◯ (∃ λ y → ∃ λ ys → (len ys ≡ len xs + len l') × revAppend (cons x xs) l' ≡ ret (cons y ys))))
(λ x l' u → (x , l' , refl , step/ext (F list) (ret (cons x l')) 1 u))
(λ x' xs' ih x l' u →
let (y , ys , h , ≡) = ih x' (cons x l') u in
let open ≡-Reasoning in
y , ys , (
begin
len ys
≡⟨ h ⟩
len xs' + len (cons x l')
≡⟨⟩
len xs' + step (meta ℕ) 1 (suc (len l'))
≡⟨ cong (len xs' +_) (step/ext (meta ℕ) (suc (len l')) 1 u) ⟩
len xs' + suc (len l')
≡⟨ +-suc (len xs') (len l') ⟩
suc (len xs' + len l')
≡⟨⟩
suc (len xs') + len l'
≡˘⟨ cong (_+ len l') (step/ext (meta ℕ) (suc (len xs')) 1 u) ⟩
step (meta ℕ) 1 (suc (len xs')) + len l'
≡⟨⟩
len (cons x' xs') + len l'
∎
) , (
begin
revAppend (cons x (cons x' xs')) l'
≡⟨⟩
step (F list) 1 (revAppend (cons x' xs') (cons x l'))
≡⟨ step/ext (F list) _ 1 u ⟩
revAppend (cons x' xs') (cons x l')
≡⟨ (≡) ⟩
ret (cons y ys)
∎
))
x
revAppend/cost : cmp (Π list λ _ → Π list λ _ → cost)
revAppend/cost l l' = len l
revAppend≤revAppend/cost : ∀ l l' → IsBounded list (revAppend l l') (revAppend/cost l l')
revAppend≤revAppend/cost l =
list/ind l (λ l → meta (∀ l' → IsBounded list (revAppend l l') (revAppend/cost l l')))
(λ l' → bound/ret)
(λ a l r → λ l' → bound/circ 1 (bound/step 1 (len l) (r (cons a l'))))
rev : cmp (Π list λ _ → F list)
rev l = revAppend l nil
rev/lemma/cons : ∀ x xs → ◯ (∃ λ y → ∃ λ ys → len ys ≡ len xs × rev (cons x xs) ≡ ret (cons y ys))
rev/lemma/cons x xs =
subst (λ n → ◯ (∃ λ y → ∃ λ ys → len ys ≡ n × rev (cons x xs) ≡ ret (cons y ys)))
(+-identityʳ _)
(revAppend/lemma/cons x xs nil)
rev/cost : cmp (Π list λ _ → cost)
rev/cost l = len l
rev≤rev/cost : ∀ l → IsBounded list (rev l) (rev/cost l)
rev≤rev/cost l = revAppend≤revAppend/cost l nil
-- Implement Queue with a pair of lists; (f , b) represents the queue f :: rev b.
module FrontBack (A : tp pos) where
-- For simplicity, we charge 1 step for each cons node destruction.
open CostList A 1
open Rev A
Q : tp pos
Q = Σ++ list λ _ → list
emp : val Q
emp = (nil , nil)
enq : cmp (Π Q λ _ → Π A λ _ → F Q)
enq (f , b) x = ret (f , cons x b)
enq/cost : cmp (Π Q λ _ → Π A λ _ → cost)
enq/cost (f , b) x = 0
enq≤enq/cost : ∀ q x → IsBounded Q (enq q x) (enq/cost q x)
enq≤enq/cost q x = bound/ret
deq-tp = sum unit (Σ++ Q λ _ → A)
deq/emp : cmp (Π list λ _ → F deq-tp)
deq/emp l =
list/match l (λ _ → F deq-tp)
(ret (inj₁ triv))
λ a l' → ret (inj₂ ((l' , nil) , a))
deq/emp/cost : cmp (Π list λ _ → cost)
deq/emp/cost l =
list/match l (λ _ → cost)
0
λ a l' → 1 + 0
deq/emp≤deq/emp/cost : ∀ l → IsBounded deq-tp (deq/emp l) (deq/emp/cost l)
deq/emp≤deq/emp/cost l =
bound/list/match l (λ _ → deq-tp)
bound/ret
λ a l' → bound/ret
deq : cmp (Π Q λ _ → F deq-tp)
deq (f , b) =
list/match f (λ _ → F deq-tp)
(bind (F deq-tp) (rev b) (λ b' → deq/emp b'))
λ a l → ret (inj₂ ((l , b) , a))
deq/cost : cmp (Π Q λ _ → cost)
deq/cost (f , b) =
list/match f (λ _ → cost)
(bind cost (rev b) (λ b' → rev/cost b + deq/emp/cost b'))
λ a l → 1 + 0
deq/cost/closed : cmp (Π Q λ _ → cost)
deq/cost/closed (f , b) =
list/match f (λ _ → cost)
(list/match b (λ _ → cost) 0 (λ _ b' → 1 + len b))
λ _ _ → 1
deq/cost≤deq/cost/closed : ∀ q → ◯ (deq/cost q ≤ deq/cost/closed q)
deq/cost≤deq/cost/closed (f , b) u =
list/match f (λ f → meta (deq/cost (f , b) ≤ deq/cost/closed (f , b)))
(list/match b (λ b → meta (deq/cost (nil , b) ≤ deq/cost/closed (nil , b)))
≤-refl
λ x xs →
let open ≤-Reasoning in
let (y , ys , _ , ≡) = rev/lemma/cons x xs u in
begin
deq/cost (nil , cons x xs)
≡⟨⟩
bind cost (rev (cons x xs)) (λ b' → rev/cost (cons x xs) + deq/emp/cost b')
≡⟨⟩
bind cost (rev (cons x xs)) (λ b' → rev/cost (cons x xs) + deq/emp/cost b')
≡⟨ cong (λ e → bind cost e (λ b' → rev/cost (cons x xs) + deq/emp/cost b')) (≡) ⟩
rev/cost (cons x xs) + deq/emp/cost (cons y ys)
≡⟨⟩
step cost 1 (suc (len xs)) + step cost 1 1
≡⟨ cong₂ _+_ (step/ext cost (suc (len xs)) 1 u) (step/ext cost 1 1 u) ⟩
suc (len xs) + 1
≡⟨ +-comm (suc (len xs)) 1 ⟩
suc (suc (len xs))
≡˘⟨ cong suc (step/ext cost _ 1 u) ⟩
suc (step cost 1 (suc (len xs)))
≡⟨⟩
suc (len (cons x xs))
≡˘⟨ step/ext cost _ 1 u ⟩
step cost 1 (suc (len (cons x xs)))
≡⟨⟩
list/match (cons x xs) (λ _ → cost) 0 (λ _ b' → 1 + len (cons x xs))
≡⟨⟩
deq/cost/closed (nil , cons x xs)
∎
)
λ _ _ → ≤-refl
deq≤deq/cost : ∀ q → IsBounded deq-tp (deq q) (deq/cost q)
deq≤deq/cost (f , b) =
bound/list/match f (λ _ → deq-tp)
(bound/bind (rev/cost b) _ (rev≤rev/cost b) λ b' → deq/emp≤deq/emp/cost b')
λ a l → bound/ret
deq≤deq/cost/closed : ∀ q → IsBounded deq-tp (deq q) (deq/cost/closed q)
deq≤deq/cost/closed q = bound/relax (deq/cost≤deq/cost/closed q) (deq≤deq/cost q)
-- Amortized analysis for front-back queue.
-- The goal is to bound the cost of a single-thread sequence of queue operations staring with an initial queue q0,
-- where an operation is either an enqueue or a dequeue.
data op : Set where
op/enq : (x : val A) → op
op/deq : op
-- Potential function
ϕ : val Q → ℕ
ϕ (f , b) = len f + 2 * len b
-- o operate q is the computation induced by operation o on queue q.
-- Needed because deq doesn't always return a queue (e.g., deq emp).
-- In these cases we just return the empty queue.
_operate_ : op → val Q → cmp (F Q)
(op/enq x) operate q = enq q x
(op/deq) operate q =
bind (F Q) (deq q) λ s → (sum/case unit (Σ++ Q λ _ → A) (λ _ → F Q) s
(λ _ → ret (nil , nil))
(λ (q , x) → ret q))
-- o operateϕ q is morally ϕ (o operate q), which doesn't type-check since o operate q is a computation.
-- Easier to work with than bind cost (o operate q) ϕ (but they are equivalent, as shown below).
_operateϕ_ : op → val Q → ℂ
(op/enq x) operateϕ (f , b) = len f + 2 * (1 + len b)
(op/deq) operateϕ (f , b) = list/match f (λ _ → cost) (list/match b (λ _ → cost) 0 (λ _ b' → len b')) (λ _ f' → len f' + 2 * len b)
operateϕ≡ϕ∘operate : ∀ o q → ◯ (o operateϕ q ≡ bind cost (o operate q) ϕ)
operateϕ≡ϕ∘operate (op/enq x) (f , b) u =
begin
len f + 2 * (1 + len b)
≡˘⟨ cong (λ n → len f + 2 * n) (step/ext cost (1 + len b) 1 u) ⟩
len f + 2 * step cost 1 (1 + len b)
≡⟨⟩
bind cost (enq (f , b) x) ϕ
∎
where open ≡-Reasoning
operateϕ≡ϕ∘operate op/deq (f , b) u = list/match f
(λ f →
meta
((op/deq operateϕ (f , b)) ≡
bind cost (op/deq operate (f , b)) ϕ))
(list/ind b (λ b → meta ((op/deq operateϕ (nil , b)) ≡ bind cost (op/deq operate (nil , b)) ϕ))
refl
λ a l ih → emp/cons a l)
λ a l → refl
where
emp/cons : ∀ a l → op/deq operateϕ (nil , cons a l) ≡ bind cost (op/deq operate (nil , cons a l)) ϕ
emp/cons a l with rev/lemma/cons a l u
... | (x' , l' , eqn1 , eqn2) =
begin
op/deq operateϕ (nil , cons a l)
≡⟨⟩
step cost 1 (len l)
≡⟨ step/ext cost (len l) 1 u ⟩
len l
≡⟨ P.sym eqn1 ⟩
len l'
≡⟨ P.sym (+-identityʳ (len l')) ⟩
len l' + 0
≡⟨⟩
len l' + 2 * len nil
≡⟨⟩
ϕ (l' , nil)
≡˘⟨ step/ext cost (ϕ (l' , nil)) 1 u ⟩
step cost 1 (ϕ (l' , nil))
≡⟨⟩
bind cost
(step (F Q) 1 (ret (l' , nil)))
ϕ
≡⟨⟩
bind cost
(bind (F Q) (step (F deq-tp) 1 (ret (inj₂ ((l' , nil) , x')))) λ s → (sum/case unit (Σ++ Q λ _ → A) (λ _ → F Q) s
(λ _ → ret (nil , nil))
(λ (q , x) → ret q)))
ϕ
≡⟨⟩
bind cost
(bind (F Q) (deq/emp (cons x' l')) λ s → (sum/case unit (Σ++ Q λ _ → A) (λ _ → F Q) s
(λ _ → ret (nil , nil))
(λ (q , x) → ret q)))
ϕ
≡˘⟨
cong
(λ e →
bind cost
(bind (F Q) e λ l' →
bind (F Q) (deq/emp l') λ s → (sum/case unit (Σ++ Q λ _ → A) (λ _ → F Q) s
(λ _ → ret (nil , nil))
(λ (q , x) → ret q)))
ϕ
)
eqn2
⟩
bind cost
(bind (F Q) (rev (cons a l)) λ l' →
bind (F Q) (deq/emp l') λ s → (sum/case unit (Σ++ Q λ _ → A) (λ _ → F Q) s
(λ _ → ret (nil , nil))
(λ (q , x) → ret q)))
ϕ
≡⟨⟩
bind cost
(bind (F Q) (deq (nil , cons a l)) λ s → (sum/case unit (Σ++ Q λ _ → A) (λ _ → F Q) s
(λ _ → ret (nil , nil))
(λ (q , x) → ret q)))
ϕ
≡⟨⟩
bind cost (op/deq operate (nil , cons a l)) ϕ
∎
where open ≡-Reasoning
-- op/cost o q is the cost of o operate q.
op/cost : op → val Q → ℕ
op/cost (op/enq x) q = 0
op/cost (op/deq) (f , b) = list/match f (λ _ → cost) (list/match b (λ _ → cost) 0 (λ _ b' → 2 + len b')) (λ _ _ → 1)
deq/cost≡cost/deq : ∀ q → ◯ (deq/cost/closed q ≡ op/cost op/deq q)
deq/cost≡cost/deq (f , b) u =
P.cong (λ x → list/match f (λ _ → cost) x (λ _ _ → 1)) (
list/match b
(λ b →
meta
(list/match b (λ _ → cost) 0 (λ _ b' → 1 + len b) ≡
list/match b (λ _ → cost) 0 (λ _ b' → 2 + len b')))
refl
(λ a l →
let open ≡-Reasoning in
begin
list/match (cons a l) (λ _ → cost) 0 (λ _ b' → 1 + len (cons a l))
≡⟨⟩
step cost 1 (1 + len (cons a l))
≡⟨ step/ext cost (1 + len (cons a l)) 1 u ⟩
1 + len (cons a l)
≡⟨⟩
1 + step cost 1 (suc (len l))
≡⟨ cong (1 +_) (step/ext cost (suc (len l)) 1 u) ⟩
2 + len l
≡˘⟨ step/ext cost (2 + len l) 1 u ⟩
step cost 1 (2 + len l)
≡⟨⟩
list/match (cons a l) (λ _ → cost) 0 (λ _ b' → 2 + len b')
∎
)
)
-- cost o q upperbounds the cost of o operate q.
op≤op/cost : ∀ o q → IsBounded Q (o operate q) (op/cost o q)
op≤op/cost (op/enq x) q = enq≤enq/cost q x
op≤op/cost op/deq q rewrite P.sym (+-identityʳ (op/cost (op/deq) q)) =
bound/bind/const {A = deq-tp} {e = deq q} {f = λ s → (sum/case unit (Σ++ Q λ _ → A) (λ _ → F Q) s (λ _ → ret (nil , nil)) (λ (q , x) → ret q))}
(op/cost op/deq q) 0
(bound/relax (λ u → ≤-reflexive (deq/cost≡cost/deq q u)) (deq≤deq/cost/closed q))
λ a →
bound/sum/case/const/const unit ((Σ++ Q λ _ → A)) (λ _ → Q) a ((λ _ → ret (nil , nil))) (λ (q , x) → ret q) 0
(λ _ → bound/ret)
(λ _ → bound/ret)
-- is/acost o k when for any state q, k suffices for the cost of o on q and the difference in the potential.
is/acost : op → ℕ → Set
is/acost o k = ∀ q → (Int.+ (op/cost o q)) Int.+ ((o operateϕ q) Int.⊖ (ϕ q)) Int.≤ Int.+ k
acost/weaken : ∀ {m n o} → m ≤ n → is/acost o m → is/acost o n
acost/weaken h1 h2 = λ q → IntP.≤-trans (h2 q) (Int.+≤+ h1)
-- A sequence of operations induces a single computation by threading through the initial state q0.
_op/seq_ : List op → val Q → cmp (F Q)
[] op/seq q0 = ret q0
(o ∷ os) op/seq q = bind (F Q) (o operate q) λ q' → os op/seq q'
op/seq/cost : ∀ (l : List op) → val Q → ℂ
op/seq/cost [] q0 = 0
op/seq/cost (o ∷ os) q = bind cost (o operate q) λ q' → op/cost o q + op/seq/cost os q'
-- Cost of a sequence computation is bounded by the sum of cost of the constituents.
op/seq≤op/seq/cost : ∀ l q → IsBounded Q (l op/seq q) (op/seq/cost l q)
op/seq≤op/seq/cost [] q0 = bound/ret
op/seq≤op/seq/cost (o ∷ os) q = bound/bind {A = Q} {e = o operate q} {f = λ q → os op/seq q}
(op/cost o q) (op/seq/cost os) (op≤op/cost o q) λ q → op/seq≤op/seq/cost os q
-- Telescoping the potential.
op/seq/cost/tele : ∀ (l : List op) → val Q → Int.ℤ
op/seq/cost/tele [] q0 = Int.0ℤ
op/seq/cost/tele (o ∷ os) q = bind (meta Int.ℤ) (o operate q) λ q' → (Int.+ (op/cost o q)) Int.+ (o operateϕ q Int.⊖ ϕ q) Int.+ (op/seq/cost/tele os q')
ϕn : ℕ → List op → val Q → ℕ
ϕn zero l q0 = ϕ q0
ϕn (suc n) (o ∷ os) q = bind cost (o operate q) λ q' → ϕn n os q'
ϕn (suc n) [] q = 0
-- Potential of the initial state
ϕ/0 : List op → val Q → ℕ
ϕ/0 l = ϕn 0 l
-- Potential of the final state
ϕ/-1 : List op → val Q → ℕ
ϕ/-1 l = ϕn (length l) l
bind/dup : ∀ A 𝕊 𝕋 e f (g : val A → 𝕊 → 𝕋) → bind {A} (meta 𝕋) e (λ a → g a (bind {A} (meta 𝕊) e f)) ≡ bind {A} (meta 𝕋) e (λ a → g a (f a))
bind/dup A 𝕊 𝕋 e f g =
begin
bind (meta 𝕋) e (λ a → g a (bind (meta 𝕊) e f)) ≡⟨ P.cong (λ h → bind (meta 𝕋) e h) (funext (λ a → bind/meta A 𝕊 𝕋 e f (λ s → g a s))) ⟩
bind (meta 𝕋) e (λ a → bind (meta 𝕋) e (λ a' → g a (f a'))) ≡⟨ bind/idem A 𝕋 e (λ a a' → g a (f a')) ⟩
bind (meta 𝕋) e (λ a → g a (f a)) ≡⟨ refl ⟩
bind (meta 𝕋) e (λ a → g a (f a))
∎
where open ≡-Reasoning
-- Telescoping sum:
-- Σᵢⁿ op/cost oᵢ + ϕ qᵢ - ϕ qᵢ₋₁ = ϕ q_{n-1} - ϕ q_0 + Σᵢ costᵢ
cost≡cost/tele : ∀ l q → ◯ (op/seq/cost/tele l q ≡ (ϕ/-1 l q Int.⊖ ϕ/0 l q) Int.+ (Int.+ (op/seq/cost l q)))
cost≡cost/tele [] q u =
P.sym
(
begin
(ϕ q Int.⊖ ϕ q) Int.+ (Int.+ 0) ≡⟨ IntP.+-identityʳ (ϕ q Int.⊖ ϕ q) ⟩
ϕ q Int.⊖ ϕ q ≡⟨ IntP.n⊖n≡0 (ϕ q) ⟩
Int.+ 0 ≡⟨ refl ⟩
Int.+ 0
∎
)
where open ≡-Reasoning
cost≡cost/tele (o ∷ os) q u rewrite operateϕ≡ϕ∘operate o q u
| bind/meta Q ℕ Int.ℤ
(o operate q)
(λ q' → op/cost o q + op/seq/cost os q')
(λ x → (ϕ/-1 (o ∷ os) q Int.⊖ ϕ/0 (o ∷ os) q) Int.+ (Int.+ x))
| bind/dup Q ℕ Int.ℤ (o operate q) (ϕ/-1 os) (λ q' x → (x Int.⊖ ϕ q) Int.+ (Int.+ (op/cost o q + op/seq/cost os q')))
| bind/dup Q ℕ Int.ℤ (o operate q) ϕ (λ q' x → Int.+ (op/cost o q) Int.+ (x Int.⊖ ϕ q) Int.+ (op/seq/cost/tele os q')) =
P.cong (λ f → bind (meta Int.ℤ) (o operate q) f)
(funext (λ q' →
(
begin
(Int.+ (op/cost o q)) Int.+ (ϕ q' Int.⊖ ϕ q) Int.+ (op/seq/cost/tele os q') ≡⟨ P.cong (λ x → (Int.+ (op/cost o q)) Int.+ (ϕ q' Int.⊖ ϕ q) Int.+ x) (cost≡cost/tele os q' u) ⟩
Int.+ op/cost o q Int.+ (ϕ q' Int.⊖ ϕ q) Int.+ (ϕ/-1 os q' Int.⊖ ϕ/0 os q' Int.+ Int.+ op/seq/cost os q') ≡⟨ P.cong (λ x → x Int.+ (ϕ/-1 os q' Int.⊖ ϕ/0 os q' Int.+ Int.+ op/seq/cost os q')) (IntP.+-comm (Int.+ op/cost o q) (ϕ q' Int.⊖ ϕ q)) ⟩
ϕ q' Int.⊖ ϕ q Int.+ Int.+ op/cost o q Int.+ (ϕ/-1 os q' Int.⊖ ϕ/0 os q' Int.+ Int.+ op/seq/cost os q') ≡⟨ IntP.+-assoc (ϕ q' Int.⊖ ϕ q) (Int.+ op/cost o q) (ϕ/-1 os q' Int.⊖ ϕ/0 os q' Int.+ Int.+ op/seq/cost os q') ⟩
ϕ q' Int.⊖ ϕ q Int.+ (Int.+ op/cost o q Int.+ (ϕ/-1 os q' Int.⊖ ϕ/0 os q' Int.+ Int.+ op/seq/cost os q')) ≡⟨ P.cong (λ x → ϕ q' Int.⊖ ϕ q Int.+ x) (P.sym (IntP.+-assoc (Int.+ op/cost o q) (ϕ/-1 os q' Int.⊖ ϕ/0 os q') (Int.+ op/seq/cost os q'))) ⟩
ϕ q' Int.⊖ ϕ q Int.+ (Int.+ op/cost o q Int.+ (ϕ/-1 os q' Int.⊖ ϕ/0 os q') Int.+ Int.+ op/seq/cost os q') ≡⟨ P.cong (λ x → ϕ q' Int.⊖ ϕ q Int.+ (x Int.+ Int.+ op/seq/cost os q')) (IntP.+-comm (Int.+ op/cost o q) (ϕ/-1 os q' Int.⊖ ϕ/0 os q')) ⟩
ϕ q' Int.⊖ ϕ q Int.+ (ϕ/-1 os q' Int.⊖ ϕ/0 os q' Int.+ Int.+ op/cost o q Int.+ Int.+ op/seq/cost os q') ≡⟨ P.cong (λ x → ϕ q' Int.⊖ ϕ q Int.+ x) (IntP.+-assoc (ϕ/-1 os q' Int.⊖ ϕ/0 os q') (Int.+ op/cost o q) (Int.+ op/seq/cost os q')) ⟩
ϕ q' Int.⊖ ϕ q Int.+ (ϕ/-1 os q' Int.⊖ ϕ/0 os q' Int.+ (Int.+ op/cost o q Int.+ Int.+ op/seq/cost os q')) ≡⟨ P.sym (IntP.+-assoc (ϕ q' Int.⊖ ϕ q) (ϕ/-1 os q' Int.⊖ ϕ/0 os q') (Int.+ op/cost o q Int.+ Int.+ op/seq/cost os q')) ⟩
ϕ q' Int.⊖ ϕ q Int.+ (ϕ/-1 os q' Int.⊖ ϕ/0 os q') Int.+ (Int.+ op/cost o q Int.+ Int.+ op/seq/cost os q') ≡⟨ P.cong (λ x → x Int.+ (ϕ/-1 os q' Int.⊖ ϕ/0 os q') Int.+ (Int.+ op/cost o q Int.+ Int.+ op/seq/cost os q')) (P.sym (IntP.m-n≡m⊖n (ϕ q') (ϕ q))) ⟩
Int.+ ϕ q' Int.- (Int.+ ϕ q) Int.+ (ϕ/-1 os q' Int.⊖ ϕ/0 os q') Int.+ (Int.+ op/cost o q Int.+ Int.+ op/seq/cost os q') ≡⟨ P.cong (λ x → Int.+ ϕ q' Int.- (Int.+ ϕ q) Int.+ x Int.+ (Int.+ op/cost o q Int.+ Int.+ op/seq/cost os q')) (P.sym (IntP.m-n≡m⊖n (ϕ/-1 os q') (ϕ/0 os q'))) ⟩
Int.+ ϕ q' Int.- Int.+ ϕ q Int.+ (Int.+ ϕ/-1 os q' Int.- (Int.+ ϕ/0 os q')) Int.+ (Int.+ op/cost o q Int.+ Int.+ op/seq/cost os q') ≡⟨ P.cong (λ x → x Int.+ (Int.+ op/cost o q Int.+ Int.+ op/seq/cost os q')) (IntP.+-comm (Int.+ ϕ q' Int.- Int.+ ϕ q) (Int.+ ϕ/-1 os q' Int.- (Int.+ ϕ/0 os q'))) ⟩
Int.+ ϕ/-1 os q' Int.- Int.+ ϕ/0 os q' Int.+ (Int.+ ϕ q' Int.- Int.+ ϕ q) Int.+ (Int.+ op/cost o q Int.+ Int.+ op/seq/cost os q') ≡⟨ P.cong (λ x → x Int.+ (Int.+ op/cost o q Int.+ Int.+ op/seq/cost os q')) (IntP.+-minus-telescope (Int.+ ϕ/-1 os q') (Int.+ ϕ q') (Int.+ ϕ q)) ⟩
Int.+ ϕ/-1 os q' Int.- Int.+ ϕ q Int.+ (Int.+ op/cost o q Int.+ Int.+ op/seq/cost os q') ≡⟨ P.cong (λ x → x Int.+ (Int.+ op/cost o q Int.+ Int.+ op/seq/cost os q')) (IntP.m-n≡m⊖n (ϕ/-1 os q') (ϕ q )) ⟩
ϕ/-1 os q' Int.⊖ ϕ q Int.+ (Int.+ op/cost o q Int.+ Int.+ op/seq/cost os q') ≡⟨ refl ⟩
ϕ/-1 os q' Int.⊖ ϕ q Int.+ (Int.+ op/cost o q Int.+ Int.+ op/seq/cost os q')
∎
)
))
where open ≡-Reasoning
data Amortized : List op → List ℕ → Set where
a/emp : Amortized [] []
a/cons : ∀ o k l l' → is/acost o k → Amortized l l' → Amortized (o ∷ l) (k ∷ l')
amortized≥cost/tele : ∀ q0 l l' → Amortized l l' → Int.+ (lsum l') Int.≥ op/seq/cost/tele l q0
amortized≥cost/tele q .[] .[] a/emp = IntP.≤-refl
amortized≥cost/tele q .(o ∷ os) .(k ∷ l') (a/cons o k os l' x h) rewrite tbind/meta Q Int.ℤ (o operate q) (λ q' → (Int.+ (op/cost o q)) Int.+ (o operateϕ q Int.⊖ ϕ q) Int.+ (op/seq/cost/tele os q')) (λ z → z Int.≤ Int.+ lsum (k ∷ l')) =
dbind (λ q' → meta ((Int.+ (op/cost o q)) Int.+ (o operateϕ q Int.⊖ ϕ q) Int.+ (op/seq/cost/tele os q') Int.≤ Int.+ lsum (k ∷ l'))) (o operate q)
λ q' →
begin
Int.+ op/cost o q Int.+ ((o operateϕ q) Int.⊖ ϕ q) Int.+ op/seq/cost/tele os q' ≤⟨ IntP.+-monoˡ-≤ (op/seq/cost/tele os q') (x q) ⟩
Int.+ k Int.+ op/seq/cost/tele os q' ≤⟨ IntP.+-monoʳ-≤ (Int.+ k) (amortized≥cost/tele q' os l' h) ⟩
Int.+ k Int.+ Int.+ lsum l' ≤⟨ IntP.≤-refl ⟩
Int.+ k Int.+ Int.+ lsum l'
∎
where open IntP.≤-Reasoning
-- Sum of a sequence of amortized costs (plus the initial potential) bounds the sum of the sequence of actual costs
amortized≥cost : ∀ q l l' → Amortized l l' → ◯ (Int.+ (ϕ q + lsum l') Int.≥ Int.+ (op/seq/cost l q))
amortized≥cost q l l' h u =
begin
Int.+ (op/seq/cost l q) ≤⟨ IntP.n≤m+n (0 + ϕ/-1 l q) ⟩
Int.0ℤ Int.+ (Int.+ ϕ/-1 l q) Int.+ Int.+ op/seq/cost l q ≡⟨ P.cong (λ x → x Int.+ (Int.+ ϕ/-1 l q) Int.+ Int.+ op/seq/cost l q) (P.sym (IntP.n⊖n≡0 (ϕ q))) ⟩
ϕ q Int.⊖ ϕ q Int.+ Int.+ ϕ/-1 l q Int.+ Int.+ op/seq/cost l q ≡⟨ P.cong (λ x → x Int.+ (Int.+ ϕ/-1 l q) Int.+ Int.+ op/seq/cost l q) (P.sym (IntP.m-n≡m⊖n (ϕ q) (ϕ q))) ⟩
Int.+ ϕ q Int.+ Int.- (Int.+ ϕ q) Int.+ Int.+ ϕ/-1 l q Int.+ Int.+ op/seq/cost l q ≡⟨ P.cong (λ x → x Int.+ Int.+ op/seq/cost l q) (IntP.+-assoc (Int.+ ϕ q) (Int.- (Int.+ ϕ q)) (Int.+ ϕ/-1 l q)) ⟩
Int.+ ϕ q Int.+ (Int.- (Int.+ ϕ q) Int.+ Int.+ ϕ/-1 l q) Int.+ Int.+ op/seq/cost l q ≡⟨ P.cong (λ x → Int.+ ϕ q Int.+ x Int.+ Int.+ op/seq/cost l q) (IntP.+-comm (Int.- (Int.+ ϕ q)) (Int.+ ϕ/-1 l q)) ⟩
Int.+ ϕ q Int.+ (Int.+ ϕ/-1 l q Int.- (Int.+ ϕ q)) Int.+ Int.+ op/seq/cost l q ≡⟨ IntP.+-assoc (Int.+ ϕ q) (Int.+ ϕ/-1 l q Int.- (Int.+ ϕ q)) (Int.+ op/seq/cost l q) ⟩
Int.+ ϕ q Int.+ (Int.+ ϕ/-1 l q Int.- Int.+ ϕ q Int.+ Int.+ op/seq/cost l q) ≡⟨ P.cong (λ x → Int.+ ϕ q Int.+ (x Int.+ Int.+ op/seq/cost l q)) (IntP.m-n≡m⊖n (ϕ/-1 l q) (ϕ q)) ⟩
Int.+ ϕ q Int.+ (ϕ/-1 l q Int.⊖ ϕ q Int.+ Int.+ op/seq/cost l q) ≡⟨ P.cong (λ x → Int.+ ϕ q Int.+ x) (P.sym (cost≡cost/tele l q u)) ⟩
Int.+ ϕ q Int.+ op/seq/cost/tele l q ≤⟨ IntP.+-monoʳ-≤ (Int.+ ϕ q) (amortized≥cost/tele q l l' h) ⟩
Int.+ ϕ q Int.+ Int.+ lsum l' ≤⟨ IntP.≤-refl ⟩
Int.+ ϕ q Int.+ Int.+ lsum l'
∎
where open IntP.≤-Reasoning
-- Amortized cost for enq and deq on a front-back queue
enq/acost : ∀ x → ◯ (is/acost (op/enq x) 2)
enq/acost x u (f , b) =
begin
(Int.+ (op/cost (op/enq x) (f , b))) Int.+ (((op/enq x) operateϕ (f , b)) Int.⊖ (ϕ (f , b)))
≡⟨⟩
Int.0ℤ Int.+ ((len f + 2 * (1 + len b)) Int.⊖ (ϕ (f , b)))
≡⟨ IntP.+-identityˡ ((len f + 2 * (1 + len b)) Int.⊖ (ϕ (f , b))) ⟩
len f + 2 * (1 + len b) Int.⊖ ϕ (f , b)
≡⟨ P.cong (λ x → (len f + x) Int.⊖ (ϕ (f , b))) (*-distribˡ-+ 2 1 (len b)) ⟩
len f + (2 * 1 + 2 * len b) Int.⊖ ϕ (f , b)
≡⟨ P.cong (λ x → (len f + x) Int.⊖ (ϕ (f , b)) ) (+-comm 2 (2 * len b)) ⟩
len f + (2 * len b + 2) Int.⊖ ϕ (f , b)
≡⟨ P.cong (λ x → x Int.⊖ (ϕ (f , b))) (P.sym (+-assoc (len f) (2 * len b) 2)) ⟩
len f + 2 * len b + 2 Int.⊖ ϕ (f , b)
≡⟨ P.cong (λ x → (len f + 2 * len b + 2) Int.⊖ x) (P.sym (+-identityʳ (ϕ (f , b)))) ⟩
len f + 2 * len b + 2 Int.⊖ (ϕ (f , b) + 0)
≡⟨ IntP.+-cancelˡ-⊖ (len f + 2 * len b) 2 0 ⟩
Int.+ 2
∎
where open IntP.≤-Reasoning
n+n≡2*n : ∀ n → n + n ≡ 2 * n
n+n≡2*n n =
begin
n + n ≡⟨ P.cong (λ x → n + x) (P.sym (+-identityʳ n)) ⟩
2 * n ∎
where open ≡-Reasoning
deq/acost : ◯ (is/acost op/deq 0)
deq/acost u (f , b) =
list/match f (λ f → meta ((Int.+ (op/cost op/deq (f , b))) Int.+ ((op/deq operateϕ (f , b)) Int.⊖ (ϕ (f , b))) Int.≤ Int.0ℤ))
(
list/match b (λ b → meta ((Int.+ (op/cost op/deq (nil , b))) Int.+ ((op/deq operateϕ (nil , b)) Int.⊖ (ϕ (nil , b))) Int.≤ Int.0ℤ))
IntP.≤-refl
λ a b' →
begin
(Int.+ (op/cost op/deq (nil , cons a b'))) Int.+ ((op/deq operateϕ (nil , cons a b')) Int.⊖ (ϕ (nil , cons a b')))
≡⟨⟩
Int.+ (step cost 1 (2 + len b')) Int.+ (step cost 1 (len b') Int.⊖ (2 * (step cost 1 (1 + len b'))))
≡⟨
cong₂ Int._+_
(cong Int.+_ (step/ext cost (2 + len b') 1 u))
(cong₂ Int._⊖_
(step/ext cost (len b') 1 u)
(cong (2 *_) (step/ext cost (1 + len b') 1 u))
)
⟩
Int.+ (2 + len b') Int.+ (len b' Int.⊖ (2 * (1 + len b')))
≡⟨ IntP.distribʳ-⊖-+-pos (2 + len b') (len b') (2 * (1 + len b')) ⟩
2 + len b' + len b' Int.⊖ 2 * (1 + len b')
≡⟨ P.cong (λ x → x Int.⊖ 2 * (1 + len b')) (+-assoc 2 (len b') (len b')) ⟩
2 + (len b' + len b') Int.⊖ 2 * (1 + len b')
≡⟨ P.cong (λ x → 2 + (len b' + len b') Int.⊖ x) (*-distribˡ-+ 2 1 (len b')) ⟩
2 + (len b' + len b') Int.⊖ (2 * 1 + 2 * len b')
≡⟨ P.cong (λ x → 2 + x Int.⊖ (2 + 2 * len b')) (n+n≡2*n (len b')) ⟩
2 + 2 * len b' Int.⊖ (2 + 2 * len b')
≡⟨ IntP.n⊖n≡0 (2 + 2 * len b') ⟩
Int.0ℤ
∎
)
λ a f' →
begin
(Int.+ (op/cost op/deq (cons a f' , b))) Int.+ ((op/deq operateϕ (cons a f' , b)) Int.⊖ (ϕ (cons a f' , b)))
≡⟨⟩
Int.+ (step cost 1 1) Int.+ (step cost 1 (len f' + 2 * len b) Int.⊖ (step cost 1 (1 + len f') + 2 * len b))
≡⟨
cong₂ Int._+_
(cong Int.+_ (step/ext cost 1 1 u))
(cong₂ Int._⊖_
(step/ext cost (len f' + 2 * len b) 1 u)
(cong (_+ 2 * len b) (step/ext cost (1 + len f') 1 u))
)
⟩
Int.+ 1 Int.+ ((len f' + 2 * len b) Int.⊖ (1 + len f' + 2 * len b))
≡⟨ IntP.distribʳ-⊖-+-pos 1 (len f' + 2 * len b) (1 + len f' + 2 * len b) ⟩
1 + (len f' + 2 * len b) Int.⊖ (1 + len f' + 2 * len b)
≡⟨ P.cong (λ x → x Int.⊖ (1 + len f' + 2 * len b)) (P.sym (+-assoc 1 (len f') (2 * len b))) ⟩
1 + len f' + 2 * len b Int.⊖ (1 + len f' + 2 * len b)
≡⟨ IntP.n⊖n≡0 (1 + len f' + 2 * len b) ⟩
Int.0ℤ
∎
where open IntP.≤-Reasoning
all2s : ℕ → List ℕ
all2s n = tabulate {n = n} (λ _ → 2)
sum2s : ∀ n → lsum (all2s n) ≡ 2 * n
sum2s zero = refl
sum2s (suc n) =
begin
2 + lsum (all2s n) ≡⟨ P.cong (λ x → 2 + x) (sum2s n) ⟩
2 + 2 * n ≡⟨ P.cong (λ x → x + 2 * n) (*-identityʳ 2) ⟩
2 * 1 + 2 * n ≡⟨ P.sym (*-distribˡ-+ 2 1 n) ⟩
2 * (1 + n)
∎
where open ≡-Reasoning
all2s/is/acost : ∀ l → ◯ (Amortized l (all2s (length l)))
all2s/is/acost [] u = a/emp
all2s/is/acost ((op/enq x) ∷ os) u = a/cons (op/enq x) 2 os (all2s (length os)) (enq/acost x u) (all2s/is/acost os u)
all2s/is/acost (op/deq ∷ os) u = a/cons op/deq 2 os (all2s (length os)) (acost/weaken z≤n (deq/acost u)) (all2s/is/acost os u)
op/seq/cost≤ϕ₀+2*|l| : ∀ q l → ◯ (Int.+ (op/seq/cost l q) Int.≤ Int.+ (ϕ q + 2 * length l))
op/seq/cost≤ϕ₀+2*|l| q l u =
begin
Int.+ (op/seq/cost l q) ≤⟨ amortized≥cost q l (all2s (length l)) (all2s/is/acost l u) u ⟩
Int.+ (ϕ q + lsum (all2s (length l))) ≡⟨ P.cong (λ x → Int.+ (ϕ q + x)) (sum2s (length l)) ⟩
Int.+ (ϕ q + 2 * length l) ≤⟨ IntP.≤-refl ⟩
Int.+ (ϕ q + 2 * length l)
∎
where open IntP.≤-Reasoning
-- Starting with an empty queue, a sequence of n operations costs at most 2 * n
op/seq≤2*|l| : ∀ l → IsBounded Q (l op/seq emp) (2 * length l)
op/seq≤2*|l| l = bound/relax (λ u → IntP.drop‿+≤+ (op/seq/cost≤ϕ₀+2*|l| emp l u)) (op/seq≤op/seq/cost l emp)
|
{
"alphanum_fraction": 0.4858965176,
"avg_line_length": 44.2885196375,
"ext": "agda",
"hexsha": "3de95ab9863444b03c0bb40b73039e1ec578ba12",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-01-29T08:12:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-10-06T10:28:24.000Z",
"max_forks_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "jonsterling/agda-calf",
"max_forks_repo_path": "src/Examples/Queue.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "jonsterling/agda-calf",
"max_issues_repo_path": "src/Examples/Queue.agda",
"max_line_length": 301,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "e51606f9ca18d8b4cf9a63c2d6caa2efc5516146",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "jonsterling/agda-calf",
"max_stars_repo_path": "src/Examples/Queue.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T20:35:11.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-07-14T03:18:28.000Z",
"num_tokens": 12966,
"size": 29319
}
|
module Data.Either where
import Lvl
open import Data.Boolean using (Bool ; 𝑇 ; 𝐹)
open import Functional using (id ; _∘_)
open import Type
infixr 100 _‖_
private variable ℓ ℓ₁ ℓ₂ ℓ₃ ℓ₄ : Lvl.Level
private variable A B C A₁ A₂ B₁ B₂ : Type{ℓ}
data _‖_ (A : Type{ℓ₁}) (B : Type{ℓ₂}) : Type{ℓ₁ Lvl.⊔ ℓ₂} where
Left : A → (A ‖ B)
Right : B → (A ‖ B)
{-# FOREIGN GHC type AgdaEither ℓ₁ ℓ₂ = Either #-}
{-# COMPILE GHC _‖_ = data AgdaEither (Left | Right) #-}
elim : ∀{P : (A ‖ B) → Type{ℓ}} → ((a : A) → P(Left a)) → ((b : B) → P(Right b)) → ((e : (A ‖ B)) → P(e))
elim fa _ (Left a) = fa(a)
elim _ fb (Right b) = fb(b)
map1 : let _ = A ; _ = B ; _ = C in (A → C) → (B → C) → (A ‖ B) → C
map1 = elim
swap : (A ‖ B) → (B ‖ A)
swap (Left t) = Right t
swap (Right t) = Left t
extract : (A ‖ A) → A
extract = map1 id id
map : (A₁ → A₂) → (B₁ → B₂) → (A₁ ‖ B₁) → (A₂ ‖ B₂)
map fa fb = map1 (Left ∘ fa) (Right ∘ fb)
mapLeft : let _ = A₁ ; _ = A₂ ; _ = B in (A₁ → A₂) → (A₁ ‖ B) → (A₂ ‖ B)
mapLeft f = map f id
mapRight : let _ = A ; _ = B₁ ; _ = B₂ in (B₁ → B₂) → (A ‖ B₁) → (A ‖ B₂)
mapRight f = map id f
isLeft : (A ‖ B) → Bool
isLeft(Left _) = 𝑇
isLeft(Right _) = 𝐹
isRight : (A ‖ B) → Bool
isRight(Left _) = 𝐹
isRight(Right _) = 𝑇
|
{
"alphanum_fraction": 0.5336,
"avg_line_length": 25.5102040816,
"ext": "agda",
"hexsha": "8a72bbe2f9ecb8313cf0e145dcce54d68b633642",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Data/Either.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Data/Either.agda",
"max_line_length": 105,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Data/Either.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 581,
"size": 1250
}
|
{-
A possible implementation of the following HIT arr. Note that this type is
mutually defined with App, that is to say, they are defined by
induction-recursion!
Inductive arr (A,B:Set) : Set :=
| base : B -> arr A B
| step : (A -> arr A B) -> arr A B.
| path : (forall x : A, App f x = App g x) -> f = g.
where App is defined by
Fixpoint App (f : arr A B)(a : A) :=
match f with
| base b => b
| step g => App (g a) a
end.
Due to the fact that arr and App are defined by induction-recuriosn, the
recursion principle for arr needs to make extra assumptions, see the parameters
of the arr-Rec module.
Effectively, we see the function space A → B as algebra for the functor (-) × A
and App is an algebra homomorphism from arr A B to A → B.
This is reflected in the extra assumption in the recursion principle.
-}
{-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.PathGroupoid
open import lib.types.Paths
open import lib.Funext
module _ where
private
data #arr-aux (A B : Set) : Set where
#base : B → #arr-aux A B
#step : (A → #arr-aux A B) → #arr-aux A B
#App : ∀{A B} → #arr-aux A B → A → B
#App (#base b) a = b
#App (#step g) a = #App (g a) a
_~>_ : Set → Set → Set
_~>_ = #arr-aux
base : ∀{A B} → B → A ~> B
base = #base
step : ∀{A B} → (A → A ~> B) → A ~> B
step = #step
App : ∀{A B} → A ~> B → A → B
App = #App
Abstr : ∀{A B} → (A → B) → A ~> B
Abstr f = step (λ x → base (f x))
postulate
path : ∀{A B} (f g : A ~> B) (a : A) → App f a == App g a → f == g
module arr-Rec {A B X : Set}
(base* : B → X)
(step* : (A → X) → X)
(App* : X → A → B)
-- Here we need to make the assumption that App* is an algebra homomorphism
-- from X into the function space.
(App*-β₂ : (a : A) (f : A → X) → App* (step* f) a == App* (f a) a)
(path* : (x y : X) (a : A) → App* x a == App* y a → x == y)
where
rec : A ~> B → X
rec = rec-aux phantom where
rec-aux : Phantom path* → A ~> B → X
rec-aux ph (#base b) = base* b
rec-aux ph (#step f) = step* (λ a → rec-aux ph (f a))
lem : (f g : A ~> B) (a : A) →
App f a == App g a → App* (rec f) a == App* (rec g) a
lem (#base b) (#base .b) a idp = idp
lem (#base b) (#step g) a p =
let β-red* = App*-β₂ a (rec ∘ g)
IH = lem (#base b) (g a) a p
in IH ∙ ! β-red*
lem (#step f) (#base b) a p =
let β-red* = App*-β₂ a (rec ∘ f)
IH = lem (f a) (#base b) a p
in β-red* ∙ IH
lem (#step f) (#step g) a p =
let IH = lem (f a) (g a) a p
β-red-f = App*-β₂ a (rec ∘ f)
β-red-g = App*-β₂ a (rec ∘ g)
in β-red-f ∙ IH ∙ ! β-red-g
postulate
path-β : (f g : A ~> B) (a : A) (p : App f a == App g a) →
ap rec (path f g a p)
== path* (rec f) (rec g) a (lem f g a p)
|
{
"alphanum_fraction": 0.5155106309,
"avg_line_length": 28.4059405941,
"ext": "agda",
"hexsha": "7c1eedfcce12f476181a7cda32455f92904568c9",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hbasold/Sandbox",
"max_forks_repo_path": "TypeTheory/HoTT/Functions.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "hbasold/Sandbox",
"max_issues_repo_path": "TypeTheory/HoTT/Functions.agda",
"max_line_length": 79,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "8fc7a6cd878f37f9595124ee8dea62258da28aa4",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hbasold/Sandbox",
"max_stars_repo_path": "TypeTheory/HoTT/Functions.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1063,
"size": 2869
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some derivable properties
------------------------------------------------------------------------
open import Algebra
module Algebra.Properties.BooleanAlgebra
{b₁ b₂} (B : BooleanAlgebra b₁ b₂)
where
open BooleanAlgebra B
import Algebra.Properties.DistributiveLattice
private
open module DL = Algebra.Properties.DistributiveLattice
distributiveLattice public
hiding (replace-equality)
open import Algebra.Structures
import Algebra.FunctionProperties as P; open P _≈_
import Relation.Binary.EqReasoning as EqR; open EqR setoid
open import Relation.Binary
open import Function
open import Function.Equality using (_⟨$⟩_)
open import Function.Equivalence using (_⇔_; module Equivalence)
open import Data.Product
------------------------------------------------------------------------
-- Some simple generalisations
∨-complement : Inverse ⊤ ¬_ _∨_
∨-complement = ∨-complementˡ , ∨-complementʳ
where
∨-complementˡ : LeftInverse ⊤ ¬_ _∨_
∨-complementˡ x = begin
¬ x ∨ x ≈⟨ ∨-comm _ _ ⟩
x ∨ ¬ x ≈⟨ ∨-complementʳ _ ⟩
⊤ ∎
∧-complement : Inverse ⊥ ¬_ _∧_
∧-complement = ∧-complementˡ , ∧-complementʳ
where
∧-complementˡ : LeftInverse ⊥ ¬_ _∧_
∧-complementˡ x = begin
¬ x ∧ x ≈⟨ ∧-comm _ _ ⟩
x ∧ ¬ x ≈⟨ ∧-complementʳ _ ⟩
⊥ ∎
------------------------------------------------------------------------
-- The dual construction is also a boolean algebra
∧-∨-isBooleanAlgebra : IsBooleanAlgebra _≈_ _∧_ _∨_ ¬_ ⊥ ⊤
∧-∨-isBooleanAlgebra = record
{ isDistributiveLattice = ∧-∨-isDistributiveLattice
; ∨-complementʳ = proj₂ ∧-complement
; ∧-complementʳ = proj₂ ∨-complement
; ¬-cong = ¬-cong
}
∧-∨-booleanAlgebra : BooleanAlgebra _ _
∧-∨-booleanAlgebra = record
{ _∧_ = _∨_
; _∨_ = _∧_
; ⊤ = ⊥
; ⊥ = ⊤
; isBooleanAlgebra = ∧-∨-isBooleanAlgebra
}
------------------------------------------------------------------------
-- (∨, ∧, ⊥, ⊤) is a commutative semiring
private
∧-identity : Identity ⊤ _∧_
∧-identity = (λ _ → ∧-comm _ _ ⟨ trans ⟩ x∧⊤=x _) , x∧⊤=x
where
x∧⊤=x : ∀ x → x ∧ ⊤ ≈ x
x∧⊤=x x = begin
x ∧ ⊤ ≈⟨ refl ⟨ ∧-cong ⟩ sym (proj₂ ∨-complement _) ⟩
x ∧ (x ∨ ¬ x) ≈⟨ proj₂ absorptive _ _ ⟩
x ∎
∨-identity : Identity ⊥ _∨_
∨-identity = (λ _ → ∨-comm _ _ ⟨ trans ⟩ x∨⊥=x _) , x∨⊥=x
where
x∨⊥=x : ∀ x → x ∨ ⊥ ≈ x
x∨⊥=x x = begin
x ∨ ⊥ ≈⟨ refl ⟨ ∨-cong ⟩ sym (proj₂ ∧-complement _) ⟩
x ∨ x ∧ ¬ x ≈⟨ proj₁ absorptive _ _ ⟩
x ∎
∧-zero : Zero ⊥ _∧_
∧-zero = (λ _ → ∧-comm _ _ ⟨ trans ⟩ x∧⊥=⊥ _) , x∧⊥=⊥
where
x∧⊥=⊥ : ∀ x → x ∧ ⊥ ≈ ⊥
x∧⊥=⊥ x = begin
x ∧ ⊥ ≈⟨ refl ⟨ ∧-cong ⟩ sym (proj₂ ∧-complement _) ⟩
x ∧ x ∧ ¬ x ≈⟨ sym $ ∧-assoc _ _ _ ⟩
(x ∧ x) ∧ ¬ x ≈⟨ ∧-idempotent _ ⟨ ∧-cong ⟩ refl ⟩
x ∧ ¬ x ≈⟨ proj₂ ∧-complement _ ⟩
⊥ ∎
∨-∧-isCommutativeSemiring : IsCommutativeSemiring _≈_ _∨_ _∧_ ⊥ ⊤
∨-∧-isCommutativeSemiring = record
{ +-isCommutativeMonoid = record
{ isSemigroup = record
{ isEquivalence = isEquivalence
; assoc = ∨-assoc
; ∙-cong = ∨-cong
}
; identityˡ = proj₁ ∨-identity
; comm = ∨-comm
}
; *-isCommutativeMonoid = record
{ isSemigroup = record
{ isEquivalence = isEquivalence
; assoc = ∧-assoc
; ∙-cong = ∧-cong
}
; identityˡ = proj₁ ∧-identity
; comm = ∧-comm
}
; distribʳ = proj₂ ∧-∨-distrib
; zeroˡ = proj₁ ∧-zero
}
∨-∧-commutativeSemiring : CommutativeSemiring _ _
∨-∧-commutativeSemiring = record
{ _+_ = _∨_
; _*_ = _∧_
; 0# = ⊥
; 1# = ⊤
; isCommutativeSemiring = ∨-∧-isCommutativeSemiring
}
------------------------------------------------------------------------
-- (∧, ∨, ⊤, ⊥) is a commutative semiring
private
∨-zero : Zero ⊤ _∨_
∨-zero = (λ _ → ∨-comm _ _ ⟨ trans ⟩ x∨⊤=⊤ _) , x∨⊤=⊤
where
x∨⊤=⊤ : ∀ x → x ∨ ⊤ ≈ ⊤
x∨⊤=⊤ x = begin
x ∨ ⊤ ≈⟨ refl ⟨ ∨-cong ⟩ sym (proj₂ ∨-complement _) ⟩
x ∨ x ∨ ¬ x ≈⟨ sym $ ∨-assoc _ _ _ ⟩
(x ∨ x) ∨ ¬ x ≈⟨ ∨-idempotent _ ⟨ ∨-cong ⟩ refl ⟩
x ∨ ¬ x ≈⟨ proj₂ ∨-complement _ ⟩
⊤ ∎
∧-∨-isCommutativeSemiring : IsCommutativeSemiring _≈_ _∧_ _∨_ ⊤ ⊥
∧-∨-isCommutativeSemiring = record
{ +-isCommutativeMonoid = record
{ isSemigroup = record
{ isEquivalence = isEquivalence
; assoc = ∧-assoc
; ∙-cong = ∧-cong
}
; identityˡ = proj₁ ∧-identity
; comm = ∧-comm
}
; *-isCommutativeMonoid = record
{ isSemigroup = record
{ isEquivalence = isEquivalence
; assoc = ∨-assoc
; ∙-cong = ∨-cong
}
; identityˡ = proj₁ ∨-identity
; comm = ∨-comm
}
; distribʳ = proj₂ ∨-∧-distrib
; zeroˡ = proj₁ ∨-zero
}
∧-∨-commutativeSemiring : CommutativeSemiring _ _
∧-∨-commutativeSemiring =
record { isCommutativeSemiring = ∧-∨-isCommutativeSemiring }
------------------------------------------------------------------------
-- Some other properties
-- I took the statement of this lemma (called Uniqueness of
-- Complements) from some course notes, "Boolean Algebra", written
-- by Gert Smolka.
private
lemma : ∀ x y → x ∧ y ≈ ⊥ → x ∨ y ≈ ⊤ → ¬ x ≈ y
lemma x y x∧y=⊥ x∨y=⊤ = begin
¬ x ≈⟨ sym $ proj₂ ∧-identity _ ⟩
¬ x ∧ ⊤ ≈⟨ refl ⟨ ∧-cong ⟩ sym x∨y=⊤ ⟩
¬ x ∧ (x ∨ y) ≈⟨ proj₁ ∧-∨-distrib _ _ _ ⟩
¬ x ∧ x ∨ ¬ x ∧ y ≈⟨ proj₁ ∧-complement _ ⟨ ∨-cong ⟩ refl ⟩
⊥ ∨ ¬ x ∧ y ≈⟨ sym x∧y=⊥ ⟨ ∨-cong ⟩ refl ⟩
x ∧ y ∨ ¬ x ∧ y ≈⟨ sym $ proj₂ ∧-∨-distrib _ _ _ ⟩
(x ∨ ¬ x) ∧ y ≈⟨ proj₂ ∨-complement _ ⟨ ∧-cong ⟩ refl ⟩
⊤ ∧ y ≈⟨ proj₁ ∧-identity _ ⟩
y ∎
¬⊥=⊤ : ¬ ⊥ ≈ ⊤
¬⊥=⊤ = lemma ⊥ ⊤ (proj₂ ∧-identity _) (proj₂ ∨-zero _)
¬⊤=⊥ : ¬ ⊤ ≈ ⊥
¬⊤=⊥ = lemma ⊤ ⊥ (proj₂ ∧-zero _) (proj₂ ∨-identity _)
¬-involutive : Involutive ¬_
¬-involutive x = lemma (¬ x) x (proj₁ ∧-complement _) (proj₁ ∨-complement _)
deMorgan₁ : ∀ x y → ¬ (x ∧ y) ≈ ¬ x ∨ ¬ y
deMorgan₁ x y = lemma (x ∧ y) (¬ x ∨ ¬ y) lem₁ lem₂
where
lem₁ = begin
(x ∧ y) ∧ (¬ x ∨ ¬ y) ≈⟨ proj₁ ∧-∨-distrib _ _ _ ⟩
(x ∧ y) ∧ ¬ x ∨ (x ∧ y) ∧ ¬ y ≈⟨ (∧-comm _ _ ⟨ ∧-cong ⟩ refl) ⟨ ∨-cong ⟩ refl ⟩
(y ∧ x) ∧ ¬ x ∨ (x ∧ y) ∧ ¬ y ≈⟨ ∧-assoc _ _ _ ⟨ ∨-cong ⟩ ∧-assoc _ _ _ ⟩
y ∧ (x ∧ ¬ x) ∨ x ∧ (y ∧ ¬ y) ≈⟨ (refl ⟨ ∧-cong ⟩ proj₂ ∧-complement _) ⟨ ∨-cong ⟩
(refl ⟨ ∧-cong ⟩ proj₂ ∧-complement _) ⟩
(y ∧ ⊥) ∨ (x ∧ ⊥) ≈⟨ proj₂ ∧-zero _ ⟨ ∨-cong ⟩ proj₂ ∧-zero _ ⟩
⊥ ∨ ⊥ ≈⟨ proj₂ ∨-identity _ ⟩
⊥ ∎
lem₃ = begin
(x ∧ y) ∨ ¬ x ≈⟨ proj₂ ∨-∧-distrib _ _ _ ⟩
(x ∨ ¬ x) ∧ (y ∨ ¬ x) ≈⟨ proj₂ ∨-complement _ ⟨ ∧-cong ⟩ refl ⟩
⊤ ∧ (y ∨ ¬ x) ≈⟨ proj₁ ∧-identity _ ⟩
y ∨ ¬ x ≈⟨ ∨-comm _ _ ⟩
¬ x ∨ y ∎
lem₂ = begin
(x ∧ y) ∨ (¬ x ∨ ¬ y) ≈⟨ sym $ ∨-assoc _ _ _ ⟩
((x ∧ y) ∨ ¬ x) ∨ ¬ y ≈⟨ lem₃ ⟨ ∨-cong ⟩ refl ⟩
(¬ x ∨ y) ∨ ¬ y ≈⟨ ∨-assoc _ _ _ ⟩
¬ x ∨ (y ∨ ¬ y) ≈⟨ refl ⟨ ∨-cong ⟩ proj₂ ∨-complement _ ⟩
¬ x ∨ ⊤ ≈⟨ proj₂ ∨-zero _ ⟩
⊤ ∎
deMorgan₂ : ∀ x y → ¬ (x ∨ y) ≈ ¬ x ∧ ¬ y
deMorgan₂ x y = begin
¬ (x ∨ y) ≈⟨ ¬-cong $ sym (¬-involutive _) ⟨ ∨-cong ⟩
sym (¬-involutive _) ⟩
¬ (¬ ¬ x ∨ ¬ ¬ y) ≈⟨ ¬-cong $ sym $ deMorgan₁ _ _ ⟩
¬ ¬ (¬ x ∧ ¬ y) ≈⟨ ¬-involutive _ ⟩
¬ x ∧ ¬ y ∎
-- One can replace the underlying equality with an equivalent one.
replace-equality :
{_≈′_ : Rel Carrier b₂} →
(∀ {x y} → x ≈ y ⇔ x ≈′ y) → BooleanAlgebra _ _
replace-equality {_≈′_} ≈⇔≈′ = record
{ _≈_ = _≈′_
; _∨_ = _∨_
; _∧_ = _∧_
; ¬_ = ¬_
; ⊤ = ⊤
; ⊥ = ⊥
; isBooleanAlgebra = record
{ isDistributiveLattice = DistributiveLattice.isDistributiveLattice
(DL.replace-equality ≈⇔≈′)
; ∨-complementʳ = λ x → to ⟨$⟩ ∨-complementʳ x
; ∧-complementʳ = λ x → to ⟨$⟩ ∧-complementʳ x
; ¬-cong = λ i≈j → to ⟨$⟩ ¬-cong (from ⟨$⟩ i≈j)
}
} where open module E {x y} = Equivalence (≈⇔≈′ {x} {y})
------------------------------------------------------------------------
-- (⊕, ∧, id, ⊥, ⊤) is a commutative ring
-- This construction is parameterised over the definition of xor.
module XorRing
(xor : Op₂ Carrier)
(⊕-def : ∀ x y → xor x y ≈ (x ∨ y) ∧ ¬ (x ∧ y))
where
private
infixl 6 _⊕_
_⊕_ : Op₂ Carrier
_⊕_ = xor
private
helper : ∀ {x y u v} → x ≈ y → u ≈ v → x ∧ ¬ u ≈ y ∧ ¬ v
helper x≈y u≈v = x≈y ⟨ ∧-cong ⟩ ¬-cong u≈v
⊕-¬-distribˡ : ∀ x y → ¬ (x ⊕ y) ≈ ¬ x ⊕ y
⊕-¬-distribˡ x y = begin
¬ (x ⊕ y) ≈⟨ ¬-cong $ ⊕-def _ _ ⟩
¬ ((x ∨ y) ∧ (¬ (x ∧ y))) ≈⟨ ¬-cong (proj₂ ∧-∨-distrib _ _ _) ⟩
¬ ((x ∧ ¬ (x ∧ y)) ∨ (y ∧ ¬ (x ∧ y))) ≈⟨ ¬-cong $
refl ⟨ ∨-cong ⟩
(refl ⟨ ∧-cong ⟩
¬-cong (∧-comm _ _)) ⟩
¬ ((x ∧ ¬ (x ∧ y)) ∨ (y ∧ ¬ (y ∧ x))) ≈⟨ ¬-cong $ lem _ _ ⟨ ∨-cong ⟩ lem _ _ ⟩
¬ ((x ∧ ¬ y) ∨ (y ∧ ¬ x)) ≈⟨ deMorgan₂ _ _ ⟩
¬ (x ∧ ¬ y) ∧ ¬ (y ∧ ¬ x) ≈⟨ deMorgan₁ _ _ ⟨ ∧-cong ⟩ refl ⟩
(¬ x ∨ (¬ ¬ y)) ∧ ¬ (y ∧ ¬ x) ≈⟨ helper (refl ⟨ ∨-cong ⟩ ¬-involutive _)
(∧-comm _ _) ⟩
(¬ x ∨ y) ∧ ¬ (¬ x ∧ y) ≈⟨ sym $ ⊕-def _ _ ⟩
¬ x ⊕ y ∎
where
lem : ∀ x y → x ∧ ¬ (x ∧ y) ≈ x ∧ ¬ y
lem x y = begin
x ∧ ¬ (x ∧ y) ≈⟨ refl ⟨ ∧-cong ⟩ deMorgan₁ _ _ ⟩
x ∧ (¬ x ∨ ¬ y) ≈⟨ proj₁ ∧-∨-distrib _ _ _ ⟩
(x ∧ ¬ x) ∨ (x ∧ ¬ y) ≈⟨ proj₂ ∧-complement _ ⟨ ∨-cong ⟩ refl ⟩
⊥ ∨ (x ∧ ¬ y) ≈⟨ proj₁ ∨-identity _ ⟩
x ∧ ¬ y ∎
private
⊕-comm : Commutative _⊕_
⊕-comm x y = begin
x ⊕ y ≈⟨ ⊕-def _ _ ⟩
(x ∨ y) ∧ ¬ (x ∧ y) ≈⟨ helper (∨-comm _ _) (∧-comm _ _) ⟩
(y ∨ x) ∧ ¬ (y ∧ x) ≈⟨ sym $ ⊕-def _ _ ⟩
y ⊕ x ∎
⊕-¬-distribʳ : ∀ x y → ¬ (x ⊕ y) ≈ x ⊕ ¬ y
⊕-¬-distribʳ x y = begin
¬ (x ⊕ y) ≈⟨ ¬-cong $ ⊕-comm _ _ ⟩
¬ (y ⊕ x) ≈⟨ ⊕-¬-distribˡ _ _ ⟩
¬ y ⊕ x ≈⟨ ⊕-comm _ _ ⟩
x ⊕ ¬ y ∎
⊕-annihilates-¬ : ∀ x y → x ⊕ y ≈ ¬ x ⊕ ¬ y
⊕-annihilates-¬ x y = begin
x ⊕ y ≈⟨ sym $ ¬-involutive _ ⟩
¬ ¬ (x ⊕ y) ≈⟨ ¬-cong $ ⊕-¬-distribˡ _ _ ⟩
¬ (¬ x ⊕ y) ≈⟨ ⊕-¬-distribʳ _ _ ⟩
¬ x ⊕ ¬ y ∎
private
⊕-cong : _⊕_ Preserves₂ _≈_ ⟶ _≈_ ⟶ _≈_
⊕-cong {x} {y} {u} {v} x≈y u≈v = begin
x ⊕ u ≈⟨ ⊕-def _ _ ⟩
(x ∨ u) ∧ ¬ (x ∧ u) ≈⟨ helper (x≈y ⟨ ∨-cong ⟩ u≈v)
(x≈y ⟨ ∧-cong ⟩ u≈v) ⟩
(y ∨ v) ∧ ¬ (y ∧ v) ≈⟨ sym $ ⊕-def _ _ ⟩
y ⊕ v ∎
⊕-identity : Identity ⊥ _⊕_
⊕-identity = ⊥⊕x=x , (λ _ → ⊕-comm _ _ ⟨ trans ⟩ ⊥⊕x=x _)
where
⊥⊕x=x : ∀ x → ⊥ ⊕ x ≈ x
⊥⊕x=x x = begin
⊥ ⊕ x ≈⟨ ⊕-def _ _ ⟩
(⊥ ∨ x) ∧ ¬ (⊥ ∧ x) ≈⟨ helper (proj₁ ∨-identity _)
(proj₁ ∧-zero _) ⟩
x ∧ ¬ ⊥ ≈⟨ refl ⟨ ∧-cong ⟩ ¬⊥=⊤ ⟩
x ∧ ⊤ ≈⟨ proj₂ ∧-identity _ ⟩
x ∎
⊕-inverse : Inverse ⊥ id _⊕_
⊕-inverse = x⊕x=⊥ , (λ _ → ⊕-comm _ _ ⟨ trans ⟩ x⊕x=⊥ _)
where
x⊕x=⊥ : ∀ x → x ⊕ x ≈ ⊥
x⊕x=⊥ x = begin
x ⊕ x ≈⟨ ⊕-def _ _ ⟩
(x ∨ x) ∧ ¬ (x ∧ x) ≈⟨ helper (∨-idempotent _)
(∧-idempotent _) ⟩
x ∧ ¬ x ≈⟨ proj₂ ∧-complement _ ⟩
⊥ ∎
distrib-∧-⊕ : _∧_ DistributesOver _⊕_
distrib-∧-⊕ = distˡ , distʳ
where
distˡ : _∧_ DistributesOverˡ _⊕_
distˡ x y z = begin
x ∧ (y ⊕ z) ≈⟨ refl ⟨ ∧-cong ⟩ ⊕-def _ _ ⟩
x ∧ ((y ∨ z) ∧ ¬ (y ∧ z)) ≈⟨ sym $ ∧-assoc _ _ _ ⟩
(x ∧ (y ∨ z)) ∧ ¬ (y ∧ z) ≈⟨ refl ⟨ ∧-cong ⟩ deMorgan₁ _ _ ⟩
(x ∧ (y ∨ z)) ∧
(¬ y ∨ ¬ z) ≈⟨ sym $ proj₁ ∨-identity _ ⟩
⊥ ∨
((x ∧ (y ∨ z)) ∧
(¬ y ∨ ¬ z)) ≈⟨ lem₃ ⟨ ∨-cong ⟩ refl ⟩
((x ∧ (y ∨ z)) ∧ ¬ x) ∨
((x ∧ (y ∨ z)) ∧
(¬ y ∨ ¬ z)) ≈⟨ sym $ proj₁ ∧-∨-distrib _ _ _ ⟩
(x ∧ (y ∨ z)) ∧
(¬ x ∨ (¬ y ∨ ¬ z)) ≈⟨ refl ⟨ ∧-cong ⟩
(refl ⟨ ∨-cong ⟩ sym (deMorgan₁ _ _)) ⟩
(x ∧ (y ∨ z)) ∧
(¬ x ∨ ¬ (y ∧ z)) ≈⟨ refl ⟨ ∧-cong ⟩ sym (deMorgan₁ _ _) ⟩
(x ∧ (y ∨ z)) ∧
¬ (x ∧ (y ∧ z)) ≈⟨ helper refl lem₁ ⟩
(x ∧ (y ∨ z)) ∧
¬ ((x ∧ y) ∧ (x ∧ z)) ≈⟨ proj₁ ∧-∨-distrib _ _ _ ⟨ ∧-cong ⟩
refl ⟩
((x ∧ y) ∨ (x ∧ z)) ∧
¬ ((x ∧ y) ∧ (x ∧ z)) ≈⟨ sym $ ⊕-def _ _ ⟩
(x ∧ y) ⊕ (x ∧ z) ∎
where
lem₂ = begin
x ∧ (y ∧ z) ≈⟨ sym $ ∧-assoc _ _ _ ⟩
(x ∧ y) ∧ z ≈⟨ ∧-comm _ _ ⟨ ∧-cong ⟩ refl ⟩
(y ∧ x) ∧ z ≈⟨ ∧-assoc _ _ _ ⟩
y ∧ (x ∧ z) ∎
lem₁ = begin
x ∧ (y ∧ z) ≈⟨ sym (∧-idempotent _) ⟨ ∧-cong ⟩ refl ⟩
(x ∧ x) ∧ (y ∧ z) ≈⟨ ∧-assoc _ _ _ ⟩
x ∧ (x ∧ (y ∧ z)) ≈⟨ refl ⟨ ∧-cong ⟩ lem₂ ⟩
x ∧ (y ∧ (x ∧ z)) ≈⟨ sym $ ∧-assoc _ _ _ ⟩
(x ∧ y) ∧ (x ∧ z) ∎
lem₃ = begin
⊥ ≈⟨ sym $ proj₂ ∧-zero _ ⟩
(y ∨ z) ∧ ⊥ ≈⟨ refl ⟨ ∧-cong ⟩ sym (proj₂ ∧-complement _) ⟩
(y ∨ z) ∧ (x ∧ ¬ x) ≈⟨ sym $ ∧-assoc _ _ _ ⟩
((y ∨ z) ∧ x) ∧ ¬ x ≈⟨ ∧-comm _ _ ⟨ ∧-cong ⟩ refl ⟩
(x ∧ (y ∨ z)) ∧ ¬ x ∎
distʳ : _∧_ DistributesOverʳ _⊕_
distʳ x y z = begin
(y ⊕ z) ∧ x ≈⟨ ∧-comm _ _ ⟩
x ∧ (y ⊕ z) ≈⟨ distˡ _ _ _ ⟩
(x ∧ y) ⊕ (x ∧ z) ≈⟨ ∧-comm _ _ ⟨ ⊕-cong ⟩ ∧-comm _ _ ⟩
(y ∧ x) ⊕ (z ∧ x) ∎
lemma₂ : ∀ x y u v →
(x ∧ y) ∨ (u ∧ v) ≈
((x ∨ u) ∧ (y ∨ u)) ∧
((x ∨ v) ∧ (y ∨ v))
lemma₂ x y u v = begin
(x ∧ y) ∨ (u ∧ v) ≈⟨ proj₁ ∨-∧-distrib _ _ _ ⟩
((x ∧ y) ∨ u) ∧ ((x ∧ y) ∨ v) ≈⟨ proj₂ ∨-∧-distrib _ _ _
⟨ ∧-cong ⟩
proj₂ ∨-∧-distrib _ _ _ ⟩
((x ∨ u) ∧ (y ∨ u)) ∧
((x ∨ v) ∧ (y ∨ v)) ∎
⊕-assoc : Associative _⊕_
⊕-assoc x y z = sym $ begin
x ⊕ (y ⊕ z) ≈⟨ refl ⟨ ⊕-cong ⟩ ⊕-def _ _ ⟩
x ⊕ ((y ∨ z) ∧ ¬ (y ∧ z)) ≈⟨ ⊕-def _ _ ⟩
(x ∨ ((y ∨ z) ∧ ¬ (y ∧ z))) ∧
¬ (x ∧ ((y ∨ z) ∧ ¬ (y ∧ z))) ≈⟨ lem₃ ⟨ ∧-cong ⟩ lem₄ ⟩
(((x ∨ y) ∨ z) ∧ ((x ∨ ¬ y) ∨ ¬ z)) ∧
(((¬ x ∨ ¬ y) ∨ z) ∧ ((¬ x ∨ y) ∨ ¬ z)) ≈⟨ ∧-assoc _ _ _ ⟩
((x ∨ y) ∨ z) ∧
(((x ∨ ¬ y) ∨ ¬ z) ∧
(((¬ x ∨ ¬ y) ∨ z) ∧ ((¬ x ∨ y) ∨ ¬ z))) ≈⟨ refl ⟨ ∧-cong ⟩ lem₅ ⟩
((x ∨ y) ∨ z) ∧
(((¬ x ∨ ¬ y) ∨ z) ∧
(((x ∨ ¬ y) ∨ ¬ z) ∧ ((¬ x ∨ y) ∨ ¬ z))) ≈⟨ sym $ ∧-assoc _ _ _ ⟩
(((x ∨ y) ∨ z) ∧ ((¬ x ∨ ¬ y) ∨ z)) ∧
(((x ∨ ¬ y) ∨ ¬ z) ∧ ((¬ x ∨ y) ∨ ¬ z)) ≈⟨ lem₁ ⟨ ∧-cong ⟩ lem₂ ⟩
(((x ∨ y) ∧ ¬ (x ∧ y)) ∨ z) ∧
¬ (((x ∨ y) ∧ ¬ (x ∧ y)) ∧ z) ≈⟨ sym $ ⊕-def _ _ ⟩
((x ∨ y) ∧ ¬ (x ∧ y)) ⊕ z ≈⟨ sym $ ⊕-def _ _ ⟨ ⊕-cong ⟩ refl ⟩
(x ⊕ y) ⊕ z ∎
where
lem₁ = begin
((x ∨ y) ∨ z) ∧ ((¬ x ∨ ¬ y) ∨ z) ≈⟨ sym $ proj₂ ∨-∧-distrib _ _ _ ⟩
((x ∨ y) ∧ (¬ x ∨ ¬ y)) ∨ z ≈⟨ (refl ⟨ ∧-cong ⟩ sym (deMorgan₁ _ _))
⟨ ∨-cong ⟩ refl ⟩
((x ∨ y) ∧ ¬ (x ∧ y)) ∨ z ∎
lem₂' = begin
(x ∨ ¬ y) ∧ (¬ x ∨ y) ≈⟨ sym $
proj₁ ∧-identity _
⟨ ∧-cong ⟩
proj₂ ∧-identity _ ⟩
(⊤ ∧ (x ∨ ¬ y)) ∧ ((¬ x ∨ y) ∧ ⊤) ≈⟨ sym $
(proj₁ ∨-complement _ ⟨ ∧-cong ⟩ ∨-comm _ _)
⟨ ∧-cong ⟩
(refl ⟨ ∧-cong ⟩ proj₁ ∨-complement _) ⟩
((¬ x ∨ x) ∧ (¬ y ∨ x)) ∧
((¬ x ∨ y) ∧ (¬ y ∨ y)) ≈⟨ sym $ lemma₂ _ _ _ _ ⟩
(¬ x ∧ ¬ y) ∨ (x ∧ y) ≈⟨ sym $ deMorgan₂ _ _ ⟨ ∨-cong ⟩ ¬-involutive _ ⟩
¬ (x ∨ y) ∨ ¬ ¬ (x ∧ y) ≈⟨ sym (deMorgan₁ _ _) ⟩
¬ ((x ∨ y) ∧ ¬ (x ∧ y)) ∎
lem₂ = begin
((x ∨ ¬ y) ∨ ¬ z) ∧ ((¬ x ∨ y) ∨ ¬ z) ≈⟨ sym $ proj₂ ∨-∧-distrib _ _ _ ⟩
((x ∨ ¬ y) ∧ (¬ x ∨ y)) ∨ ¬ z ≈⟨ lem₂' ⟨ ∨-cong ⟩ refl ⟩
¬ ((x ∨ y) ∧ ¬ (x ∧ y)) ∨ ¬ z ≈⟨ sym $ deMorgan₁ _ _ ⟩
¬ (((x ∨ y) ∧ ¬ (x ∧ y)) ∧ z) ∎
lem₃ = begin
x ∨ ((y ∨ z) ∧ ¬ (y ∧ z)) ≈⟨ refl ⟨ ∨-cong ⟩
(refl ⟨ ∧-cong ⟩ deMorgan₁ _ _) ⟩
x ∨ ((y ∨ z) ∧ (¬ y ∨ ¬ z)) ≈⟨ proj₁ ∨-∧-distrib _ _ _ ⟩
(x ∨ (y ∨ z)) ∧ (x ∨ (¬ y ∨ ¬ z)) ≈⟨ sym (∨-assoc _ _ _) ⟨ ∧-cong ⟩
sym (∨-assoc _ _ _) ⟩
((x ∨ y) ∨ z) ∧ ((x ∨ ¬ y) ∨ ¬ z) ∎
lem₄' = begin
¬ ((y ∨ z) ∧ ¬ (y ∧ z)) ≈⟨ deMorgan₁ _ _ ⟩
¬ (y ∨ z) ∨ ¬ ¬ (y ∧ z) ≈⟨ deMorgan₂ _ _ ⟨ ∨-cong ⟩ ¬-involutive _ ⟩
(¬ y ∧ ¬ z) ∨ (y ∧ z) ≈⟨ lemma₂ _ _ _ _ ⟩
((¬ y ∨ y) ∧ (¬ z ∨ y)) ∧
((¬ y ∨ z) ∧ (¬ z ∨ z)) ≈⟨ (proj₁ ∨-complement _ ⟨ ∧-cong ⟩ ∨-comm _ _)
⟨ ∧-cong ⟩
(refl ⟨ ∧-cong ⟩ proj₁ ∨-complement _) ⟩
(⊤ ∧ (y ∨ ¬ z)) ∧
((¬ y ∨ z) ∧ ⊤) ≈⟨ proj₁ ∧-identity _ ⟨ ∧-cong ⟩
proj₂ ∧-identity _ ⟩
(y ∨ ¬ z) ∧ (¬ y ∨ z) ∎
lem₄ = begin
¬ (x ∧ ((y ∨ z) ∧ ¬ (y ∧ z))) ≈⟨ deMorgan₁ _ _ ⟩
¬ x ∨ ¬ ((y ∨ z) ∧ ¬ (y ∧ z)) ≈⟨ refl ⟨ ∨-cong ⟩ lem₄' ⟩
¬ x ∨ ((y ∨ ¬ z) ∧ (¬ y ∨ z)) ≈⟨ proj₁ ∨-∧-distrib _ _ _ ⟩
(¬ x ∨ (y ∨ ¬ z)) ∧
(¬ x ∨ (¬ y ∨ z)) ≈⟨ sym (∨-assoc _ _ _) ⟨ ∧-cong ⟩
sym (∨-assoc _ _ _) ⟩
((¬ x ∨ y) ∨ ¬ z) ∧
((¬ x ∨ ¬ y) ∨ z) ≈⟨ ∧-comm _ _ ⟩
((¬ x ∨ ¬ y) ∨ z) ∧
((¬ x ∨ y) ∨ ¬ z) ∎
lem₅ = begin
((x ∨ ¬ y) ∨ ¬ z) ∧
(((¬ x ∨ ¬ y) ∨ z) ∧ ((¬ x ∨ y) ∨ ¬ z)) ≈⟨ sym $ ∧-assoc _ _ _ ⟩
(((x ∨ ¬ y) ∨ ¬ z) ∧ ((¬ x ∨ ¬ y) ∨ z)) ∧
((¬ x ∨ y) ∨ ¬ z) ≈⟨ ∧-comm _ _ ⟨ ∧-cong ⟩ refl ⟩
(((¬ x ∨ ¬ y) ∨ z) ∧ ((x ∨ ¬ y) ∨ ¬ z)) ∧
((¬ x ∨ y) ∨ ¬ z) ≈⟨ ∧-assoc _ _ _ ⟩
((¬ x ∨ ¬ y) ∨ z) ∧
(((x ∨ ¬ y) ∨ ¬ z) ∧ ((¬ x ∨ y) ∨ ¬ z)) ∎
isCommutativeRing : IsCommutativeRing _≈_ _⊕_ _∧_ id ⊥ ⊤
isCommutativeRing = record
{ isRing = record
{ +-isAbelianGroup = record
{ isGroup = record
{ isMonoid = record
{ isSemigroup = record
{ isEquivalence = isEquivalence
; assoc = ⊕-assoc
; ∙-cong = ⊕-cong
}
; identity = ⊕-identity
}
; inverse = ⊕-inverse
; ⁻¹-cong = id
}
; comm = ⊕-comm
}
; *-isMonoid = record
{ isSemigroup = record
{ isEquivalence = isEquivalence
; assoc = ∧-assoc
; ∙-cong = ∧-cong
}
; identity = ∧-identity
}
; distrib = distrib-∧-⊕
}
; *-comm = ∧-comm
}
commutativeRing : CommutativeRing _ _
commutativeRing = record
{ _+_ = _⊕_
; _*_ = _∧_
; -_ = id
; 0# = ⊥
; 1# = ⊤
; isCommutativeRing = isCommutativeRing
}
infixl 6 _⊕_
_⊕_ : Op₂ Carrier
x ⊕ y = (x ∨ y) ∧ ¬ (x ∧ y)
module DefaultXorRing = XorRing _⊕_ (λ _ _ → refl)
|
{
"alphanum_fraction": 0.3431307165,
"avg_line_length": 36.7635726795,
"ext": "agda",
"hexsha": "148eb72843f8508bd1411626f2449167585260b5",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "qwe2/try-agda",
"max_forks_repo_path": "agda-stdlib-0.9/src/Algebra/Properties/BooleanAlgebra.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "qwe2/try-agda",
"max_issues_repo_path": "agda-stdlib-0.9/src/Algebra/Properties/BooleanAlgebra.agda",
"max_line_length": 93,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "qwe2/try-agda",
"max_stars_repo_path": "agda-stdlib-0.9/src/Algebra/Properties/BooleanAlgebra.agda",
"max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z",
"num_tokens": 9049,
"size": 20992
}
|
{-# OPTIONS --universe-polymorphism #-}
-- Should fail with S i != i
module Issue216 where
postulate
Level : Set
O : Level
S : Level → Level
{-# BUILTIN LEVEL Level #-}
{-# BUILTIN LEVELZERO O #-}
{-# BUILTIN LEVELSUC S #-}
Foo : {i : Level} → Set i
Foo {i} = (R : Set i) → R
|
{
"alphanum_fraction": 0.5841924399,
"avg_line_length": 17.1176470588,
"ext": "agda",
"hexsha": "7a4f88a77bda637a85b7ac06f37eefc36a000dee",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "np/agda-git-experiment",
"max_forks_repo_path": "test/fail/Issue216.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "np/agda-git-experiment",
"max_issues_repo_path": "test/fail/Issue216.agda",
"max_line_length": 39,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/fail/Issue216.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 91,
"size": 291
}
|
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl)
open import Data.Nat using (ℕ; zero; suc)
open import Relation.Nullary using (¬_; Dec; yes; no)
data _≤_ : ℕ → ℕ → Set where
z≤n : ∀ {n : ℕ} → zero ≤ n
s≤s : ∀ {m n : ℕ} → m ≤ n → suc m ≤ suc n
¬s≤z : ∀ {m : ℕ} → ¬ (suc m ≤ zero)
¬s≤z ()
¬s≤s : ∀ {m n : ℕ} → ¬ (m ≤ n) → ¬ (suc m ≤ suc n)
¬s≤s ¬m≤n (s≤s m≤n) = ¬m≤n m≤n
_≤?_ : ∀ (m n : ℕ) → Dec (m ≤ n)
zero ≤? n = yes z≤n
suc m ≤? zero = no ¬s≤z
suc m ≤? suc n with m ≤? n
... | yes m≤n = yes (s≤s m≤n)
... | no ¬m≤n = no (¬s≤s ¬m≤n)
_ : 2 ≤? 4 ≡ yes (s≤s (s≤s z≤n))
_ = refl
_ : 4 ≤? 2 ≡ no (¬s≤s (¬s≤s ¬s≤z))
_ = refl
|
{
"alphanum_fraction": 0.4749620637,
"avg_line_length": 22.724137931,
"ext": "agda",
"hexsha": "2386f724726d26053dad8dcedd8326775b6f25d4",
"lang": "Agda",
"max_forks_count": 304,
"max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z",
"max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "manikdv/plfa.github.io",
"max_forks_repo_path": "extra/extra/DecidableFixed.agda",
"max_issues_count": 323,
"max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4",
"max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z",
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "manikdv/plfa.github.io",
"max_issues_repo_path": "extra/extra/DecidableFixed.agda",
"max_line_length": 53,
"max_stars_count": 1003,
"max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "manikdv/plfa.github.io",
"max_stars_repo_path": "extra/extra/DecidableFixed.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z",
"num_tokens": 352,
"size": 659
}
|
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module Examples where
data _∨_ (A B : Set) : Set where
inl : A → A ∨ B
inr : B → A ∨ B
postulate commOr : {A B : Set} → A ∨ B → B ∨ A
{-# ATP prove commOr #-}
|
{
"alphanum_fraction": 0.4970414201,
"avg_line_length": 24.1428571429,
"ext": "agda",
"hexsha": "74e8a569de0c9f1b38863fd18162b7c01b787c51",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "notes/papers/fossacs-2012/Examples.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "notes/papers/fossacs-2012/Examples.agda",
"max_line_length": 46,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/papers/fossacs-2012/Examples.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z",
"num_tokens": 101,
"size": 338
}
|
_ : Set₁
_ = Set
_ : Set₁
_ = Set
module _ where
_ : Set₁
_ = Set
|
{
"alphanum_fraction": 0.527027027,
"avg_line_length": 6.1666666667,
"ext": "agda",
"hexsha": "8a7f5e9b0b90cf101364bdc0f5d6d1e97b941462",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/Issue3302.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/Issue3302.agda",
"max_line_length": 14,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue3302.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 33,
"size": 74
}
|
------------------------------------------------------------------------
-- Coinductive "natural" numbers
------------------------------------------------------------------------
module Data.Conat where
open import Coinduction
open import Data.Nat using (ℕ; zero; suc)
------------------------------------------------------------------------
-- The type
data Coℕ : Set where
zero : Coℕ
suc : (n : ∞ Coℕ) → Coℕ
------------------------------------------------------------------------
-- Some operations
fromℕ : ℕ → Coℕ
fromℕ zero = zero
fromℕ (suc n) = suc (♯ fromℕ n)
∞ℕ : Coℕ
∞ℕ = suc (♯ ∞ℕ)
infixl 6 _+_
_+_ : Coℕ → Coℕ → Coℕ
zero + n = n
suc m + n = suc (♯ (♭ m + n))
|
{
"alphanum_fraction": 0.3396226415,
"avg_line_length": 21.53125,
"ext": "agda",
"hexsha": "b54640741ce8877f2642f0f0c29988df310e8c1e",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z",
"max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "isabella232/Lemmachine",
"max_forks_repo_path": "vendor/stdlib/src/Data/Conat.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/Lemmachine",
"max_issues_repo_path": "vendor/stdlib/src/Data/Conat.agda",
"max_line_length": 72,
"max_stars_count": 56,
"max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "isabella232/Lemmachine",
"max_stars_repo_path": "vendor/stdlib/src/Data/Conat.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z",
"num_tokens": 190,
"size": 689
}
|
{-# OPTIONS --safe #-}
module Definition.Typed.Consequences.Equality where
open import Definition.Untyped
open import Definition.Typed
open import Definition.Typed.Properties
open import Definition.Typed.EqRelInstance
open import Definition.LogicalRelation
open import Definition.LogicalRelation.Properties.Escape
open import Definition.LogicalRelation.Irrelevance
open import Definition.LogicalRelation.ShapeView
open import Definition.LogicalRelation.Fundamental.Reducibility
open import Definition.Typed.Consequences.Injectivity
open import Tools.Product
import Tools.PropositionalEquality as PE
{-
-- conversion is cumulative
typeCumul′ : ∀ {A rA lA lA' Γ} → lA ≤∞ lA' → Γ ⊩⟨ ∞ ⟩ A ^ [ rA , lA ] → Γ ⊩⟨ ∞ ⟩ A ^ [ rA , lA' ]
typeCumul′ (≡is≤∞ PE.refl) [A] = [A]
typeCumul′ (<∞is≤∞ emb<) (Uᵣ (Uᵣ r l′ l<₁ eq d)) = emb ∞< (Uᵣ (Uᵣ r ⁰ emb< PE.refl {!!}))
typeCumul′ (<∞is≤∞ ∞<) (Uᵣ (Uᵣ r l′ l<₁ eq d)) = Uᵣ (Uᵣ r ¹ ∞< PE.refl {!!})
typeCumul′ (<∞is≤∞ emb<) (ℕᵣ [[ ⊢A , ⊢B , D ]]) = emb ∞< (emb emb< {!ℕᵣ ?!})
typeCumul′ (<∞is≤∞ l<) (Emptyᵣ x) = {!!}
typeCumul′ (<∞is≤∞ l<) (ne x) = {!!}
typeCumul′ (<∞is≤∞ l<) (Πᵣ x) = {!!}
typeCumul′ (<∞is≤∞ l<) (∃ᵣ x) = {!!}
typeCumul′ (<∞is≤∞ l<) (emb l<₁ [A]) = {!!}
convCumul′ : ∀ {A B rA lA lA' Γ} → (l< : lA ≤∞ lA') → ([A] : Γ ⊩⟨ ∞ ⟩ A ^ [ rA , lA ])
→ Γ ⊩⟨ ∞ ⟩ A ≡ B ^ [ rA , lA ] / [A] → Γ ⊩⟨ ∞ ⟩ A ≡ B ^ [ rA , lA' ] / typeCumul′ l< [A]
convCumul′ (<∞is≤∞ l<) [A] [A≡B] = {!!}
convCumul′ (≡is≤∞ PE.refl) [A] [A≡B] = [A≡B]
convCumul : ∀ {A B rA lA lA' Γ} → lA ≤∞ lA' → Γ ⊢ A ≡ B ^ [ rA , lA ] → Γ ⊢ A ≡ B ^ [ rA , lA' ]
convCumul {A} {B} {rA} {lA} {lA'} {Γ} (<∞is≤∞ l<) A≡B =
let X = reducibleEq A≡B
[A] = proj₁ X
[B] = proj₁ (proj₂ X)
[A≡B] = proj₂ (proj₂ X)
[A]' : Γ ⊩⟨ ∞ ⟩ A ^ [ rA , lA' ]
[A]' = emb l< {!!} -- [A]
in {!escapeEq [A]' [A≡B]!}
-- convCumul (<∞is≤∞ ∞<) A≡B =
-- let X = reducibleEq A≡B
-- [A] = proj₁ X
-- [B] = proj₁ (proj₂ X)
-- [A≡B] = proj₂ (proj₂ X)
-- in {!!}
convCumul (≡is≤∞ PE.refl) A≡B = A≡B
-}
U≡A′ : ∀ {A rU Γ l lU nlU } ([U] : Γ ⊩⟨ l ⟩U Univ rU lU ^ nlU)
→ Γ ⊩⟨ l ⟩ Univ rU lU ≡ A ^ [ ! , nlU ] / (U-intr [U])
→ Γ ⊢ A ⇒* Univ rU lU ^ [ ! , nlU ]
U≡A′ (noemb (Uᵣ r l′ l< eq d)) [U≡A] =
let r≡r , l≡l = Uinjectivity (subset* (red d))
in PE.subst (λ r → _ ⊢ _ ⇒* Univ r _ ^ [ ! , _ ]) (PE.sym r≡r)
(PE.subst (λ l → _ ⊢ _ ⇒* Univ _ l ^ [ ! , _ ]) (PE.sym l≡l) [U≡A])
U≡A′ (emb emb< [U]) [U≡A] = U≡A′ [U] [U≡A]
U≡A′ (emb ∞< [U]) [U≡A] = U≡A′ [U] [U≡A]
-- If A is judgmentally equal to U, then A reduces to U.
U≡A : ∀ {A rU Γ lU nlU }
→ Γ ⊢ Univ rU lU ≡ A ^ [ ! , nlU ]
→ Γ ⊢ A ⇒* Univ rU lU ^ [ ! , nlU ]
U≡A {A} U≡A =
let X = reducibleEq U≡A
[U] = proj₁ X
[A] = proj₁ (proj₂ X)
[U≡A] = proj₂ (proj₂ X)
in U≡A′ (U-elim [U]) (irrelevanceEq [U] (U-intr (U-elim [U])) [U≡A])
-- If A is judgmentally equal to U, then A reduces to U.
U≡A-whnf : ∀ {A rU Γ lU nlU }
→ Γ ⊢ Univ rU lU ≡ A ^ [ ! , nlU ]
→ Whnf A
→ A PE.≡ Univ rU lU
U≡A-whnf {A} X whnfA = whnfRed* (U≡A X) whnfA
ℕ≡A′ : ∀ {A Γ l} ([ℕ] : Γ ⊩⟨ l ⟩ℕ ℕ)
→ Γ ⊩⟨ l ⟩ ℕ ≡ A ^ [ ! , ι ⁰ ] / (ℕ-intr [ℕ])
→ Whnf A
→ A PE.≡ ℕ
ℕ≡A′ (noemb x) [ℕ≡A] whnfA = whnfRed* [ℕ≡A] whnfA
ℕ≡A′ (emb emb< [ℕ]) [ℕ≡A] whnfA = ℕ≡A′ [ℕ] [ℕ≡A] whnfA
ℕ≡A′ (emb ∞< [ℕ]) [ℕ≡A] whnfA = ℕ≡A′ [ℕ] [ℕ≡A] whnfA
-- If A in WHNF is judgmentally equal to ℕ, then A is propsitionally equal to ℕ.
ℕ≡A : ∀ {A Γ}
→ Γ ⊢ ℕ ≡ A ^ [ ! , ι ⁰ ]
→ Whnf A
→ A PE.≡ ℕ
ℕ≡A {A} ℕ≡A whnfA =
let X = reducibleEq ℕ≡A
[ℕ] = proj₁ X
[A] = proj₁ (proj₂ X)
[ℕ≡A] = proj₂ (proj₂ X)
in ℕ≡A′ (ℕ-elim [ℕ]) (irrelevanceEq [ℕ] (ℕ-intr (ℕ-elim [ℕ])) [ℕ≡A]) whnfA
-- If A in WHNF is judgmentally equal to Empty, then A is propositionally equal to Empty.
Empty≡A′ : ∀ {A Γ l ll} ([Empty] : Γ ⊩⟨ l ⟩Empty Empty ll ^ ll)
→ Γ ⊩⟨ l ⟩ Empty ll ≡ A ^ [ % , ι ll ] / (Empty-intr [Empty])
→ Whnf A
→ A PE.≡ Empty ll
Empty≡A′ (noemb x) [Empty≡A] whnfA = whnfRed* [Empty≡A] whnfA
Empty≡A′ (emb emb< [Empty]) [Empty≡A] whnfA = Empty≡A′ [Empty] [Empty≡A] whnfA
Empty≡A′ (emb ∞< [Empty]) [Empty≡A] whnfA = Empty≡A′ [Empty] [Empty≡A] whnfA
Empty≡A : ∀ {A Γ l}
→ Γ ⊢ Empty l ≡ A ^ [ % , ι l ]
→ Whnf A
→ A PE.≡ Empty l
Empty≡A {A} Empty≡A whnfA =
let X = reducibleEq Empty≡A
[Empty] = proj₁ X
[A] = proj₁ (proj₂ X)
[Empty≡A] = proj₂ (proj₂ X)
in Empty≡A′ (Empty-elim [Empty]) (irrelevanceEq [Empty] (Empty-intr (Empty-elim [Empty])) [Empty≡A]) whnfA
ne≡A′ : ∀ {A K r Γ l ll }
→ ([K] : Γ ⊩⟨ l ⟩ne K ^[ r , ll ] )
→ Γ ⊩⟨ l ⟩ K ≡ A ^ [ r , ι ll ] / (ne-intr [K])
→ Whnf A
→ ∃ λ M → Neutral M × A PE.≡ M
ne≡A′ (noemb [K]) (ne₌ M D′ neM K≡M) whnfA =
M , neM , (whnfRed* (red D′) whnfA)
ne≡A′ (emb emb< [K]) [K≡A] whnfA = ne≡A′ [K] [K≡A] whnfA
ne≡A′ (emb ∞< [K]) [K≡A] whnfA = ne≡A′ [K] [K≡A] whnfA
-- If A in WHNF is judgmentally equal to K, then there exists a M such that
-- A is propsitionally equal to M.
ne≡A : ∀ {A K r l Γ}
→ Neutral K
→ Γ ⊢ K ≡ A ^ [ r , ι l ]
→ Whnf A
→ ∃ λ M → Neutral M × A PE.≡ M
ne≡A {A} neK ne≡A whnfA =
let X = reducibleEq ne≡A
[ne] = proj₁ X
[A] = proj₁ (proj₂ X)
[ne≡A] = proj₂ (proj₂ X)
in ne≡A′ (ne-elim neK [ne])
(irrelevanceEq [ne] (ne-intr (ne-elim neK [ne])) [ne≡A]) whnfA
Π≡A′ : ∀ {A F G rF lF lG rΠ lΠ Γ l} ([Π] : Γ ⊩⟨ l ⟩Π Π F ^ rF ° lF ▹ G ° lG ° lΠ ^[ rΠ , lΠ ] )
→ Γ ⊩⟨ l ⟩ Π F ^ rF ° lF ▹ G ° lG ° lΠ ≡ A ^ [ rΠ , ι lΠ ] / (Π-intr [Π])
→ Whnf A
→ ∃₂ λ H E → A PE.≡ Π H ^ rF ° lF ▹ E ° lG ° lΠ
Π≡A′ (noemb (Πᵣ rF′ lF′ lG′ lF≤ lG≤ F G D ⊢F ⊢G A≡A [F] [G] G-ext)) (Π₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) whnfA =
let _ , rF≡rF′ , lF≡lF′ , _ , lG≡lG′ , _ = Π-PE-injectivity (whnfRed* (red D) Πₙ)
X = whnfRed* D′ whnfA
in F′ , G′ ,
PE.subst (λ r → _ PE.≡ Π _ ^ r ° _ ▹ _ ° _ ° _) (PE.sym rF≡rF′)
(PE.subst (λ l → _ PE.≡ Π _ ^ _ ° l ▹ _ ° _ ° _) (PE.sym lF≡lF′)
(PE.subst (λ l → _ PE.≡ Π _ ^ _ ° _ ▹ _ ° l ° _) (PE.sym lG≡lG′) X))
Π≡A′ (emb emb< [Π]) [Π≡A] whnfA = Π≡A′ [Π] [Π≡A] whnfA
Π≡A′ (emb ∞< [Π]) [Π≡A] whnfA = Π≡A′ [Π] [Π≡A] whnfA
-- If A is judgmentally equal to Π F ▹ G, then there exists H and E such that
-- A is propositionally equal to Π H ▹ E.
Π≡A : ∀ {A F G rF lF lG rΠ lΠ Γ}
→ Γ ⊢ Π F ^ rF ° lF ▹ G ° lG ° lΠ ≡ A ^ [ rΠ , ι lΠ ]
→ Whnf A
→ ∃₂ λ H E → A PE.≡ Π H ^ rF ° lF ▹ E ° lG ° lΠ
Π≡A {A} Π≡A whnfA =
let X = reducibleEq Π≡A
[Π] = proj₁ X
[A] = proj₁ (proj₂ X)
[Π≡A] = proj₂ (proj₂ X)
in Π≡A′ (Π-elim [Π]) (irrelevanceEq [Π] (Π-intr (Π-elim [Π])) [Π≡A]) whnfA
|
{
"alphanum_fraction": 0.489196841,
"avg_line_length": 36.8736263736,
"ext": "agda",
"hexsha": "7d686fe1b7c6ae27fe20d7f8507f8dccd2a320b0",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z",
"max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "CoqHott/logrel-mltt",
"max_forks_repo_path": "Definition/Typed/Consequences/Equality.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "CoqHott/logrel-mltt",
"max_issues_repo_path": "Definition/Typed/Consequences/Equality.agda",
"max_line_length": 108,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "CoqHott/logrel-mltt",
"max_stars_repo_path": "Definition/Typed/Consequences/Equality.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z",
"num_tokens": 3526,
"size": 6711
}
|
{-# OPTIONS --without-K #-}
module function.isomorphism.utils where
open import sum
open import equality.core
open import equality.calculus
open import function.core
open import function.overloading
open import function.isomorphism.core
open import function.isomorphism.coherent
open import function.extensionality.proof
open import sets.unit
open import sets.empty
open import sets.fin.core
open import hott.level.core
Σ-split-iso : ∀ {i j}{X : Set i}{Y : X → Set j}
→ {a a' : X}{b : Y a}{b' : Y a'}
→ (Σ (a ≡ a') λ q → subst Y q b ≡ b')
≅ ((a , b) ≡ (a' , b'))
Σ-split-iso {Y = Y}{a}{a'}{b}{b'} = iso unapΣ apΣ H K
where
H : ∀ {a a'}{b : Y a}{b' : Y a'}
→ (p : Σ (a ≡ a') λ q → subst Y q b ≡ b')
→ apΣ (unapΣ {a = a}{a' = a'}{b = b}{b' = b'} p) ≡ p
H (refl , refl) = refl
K : (p : (a , b) ≡ (a' , b')) → unapΣ (apΣ p) ≡ p
K = J (λ u v p → unapΣ (apΣ p) ≡ p)
(λ {(a , b) → refl })
(a , b) (a' , b')
×-split-iso : ∀ {i j}{X : Set i}{Y : Set j}
→ {a a' : X}{b b' : Y}
→ ((a ≡ a') × (b ≡ b'))
≅ ((a , b) ≡ (a' , b'))
×-split-iso {X = X}{Y} = record
{ to = λ { (p , q) → ap₂ _,_ p q }
; from = λ { p → (ap proj₁ p , ap proj₂ p) }
; iso₁ = λ { (p , q) → H p q }
; iso₂ = K }
where
H : {a a' : X}{b b' : Y}(p : a ≡ a')(q : b ≡ b')
→ (ap proj₁ (ap₂ _,_ p q), ap proj₂ (ap₂ _,_ p q)) ≡ (p , q)
H refl refl = refl
K : {a a' : X}{b b' : Y}(p : (a , b) ≡ (a' , b'))
→ ap₂ _,_ (ap proj₁ p) (ap proj₂ p) ≡ p
K refl = refl
×-ap-iso : ∀ {i i' j j'}{X : Set i}{X' : Set i'}
{Y : Set j}{Y' : Set j'}
→ (isom : X ≅ X')
→ (isom' : Y ≅ Y')
→ (X × Y) ≅ (X' × Y')
×-ap-iso isom isom' = record
{ to = λ { (x , y) → (apply isom x , apply isom' y) }
; from = λ { (x' , y') → (invert isom x' , invert isom' y') }
; iso₁ = λ { (x , y) → pair≡ (_≅_.iso₁ isom x) (_≅_.iso₁ isom' y) }
; iso₂ = λ { (x' , y') → pair≡ (_≅_.iso₂ isom x') (_≅_.iso₂ isom' y') } }
Σ-ap-iso₂ : ∀ {i j j'}{X : Set i}
→ {Y : X → Set j}{Y' : X → Set j'}
→ ((x : X) → Y x ≅ Y' x)
→ Σ X Y ≅ Σ X Y'
Σ-ap-iso₂ {X = X}{Y}{Y'} isom = record
{ to = λ { (x , y) → (x , apply (isom x) y) }
; from = λ { (x , y') → (x , invert (isom x) y') }
; iso₁ = λ { (x , y) → unapΣ (refl , _≅_.iso₁ (isom x) y) }
; iso₂ = λ { (x , y') → unapΣ (refl , _≅_.iso₂ (isom x) y') } }
Σ-ap-iso₁ : ∀ {i i' j}{X : Set i}{X' : Set i'}{Y : X' → Set j}
→ (isom : X ≅ X')
→ Σ X (Y ∘ apply isom) ≅ Σ X' Y
Σ-ap-iso₁ {X = X}{X'}{Y} isom = record
{ to = λ { (x , y) → (f x , y) }
; from = λ { (x , y) → (g x , subst Y (sym (K x)) y) }
; iso₁ = λ { (x , y) → unapΣ (H x ,
subst-naturality Y f (H x) _
· (subst-hom Y (sym (K (f x))) (ap f (H x)) y
· ap (λ p → subst Y p y) (lem x) ) ) }
; iso₂ = λ { (x , y) → unapΣ (K x ,
subst-hom Y (sym (K x)) (K x) y
· ap (λ p → subst Y p y) (right-inverse (K x)) ) } }
where
isom-c = ≅⇒≅' isom
γ = proj₂ isom-c
open _≅_ (proj₁ isom-c)
renaming ( to to f ; from to g
; iso₁ to H; iso₂ to K )
lem : (x : X) → sym (K (f x)) · ap f (H x) ≡ refl
lem x = ap (λ z → sym (K (f x)) · z) (γ x)
· right-inverse (K (f x))
Σ-ap-iso : ∀ {i i' j j'}{X : Set i}{X' : Set i'}
{Y : X → Set j}{Y' : X' → Set j'}
→ (isom : X ≅ X')
→ ((x : X) → Y x ≅ Y' (apply isom x))
→ Σ X Y ≅ Σ X' Y'
Σ-ap-iso {X = X}{X'}{Y}{Y'} isom isom' = trans≅
(Σ-ap-iso₂ isom') (Σ-ap-iso₁ isom)
Σ-ap-iso' : ∀ {i i' j j'}{X : Set i}{X' : Set i'}
{Y : X → Set j}{Y' : X' → Set j'}
→ (isom : X ≅ X')
→ ((x : X') → Y (invert isom x) ≅ Y' x)
→ Σ X Y ≅ Σ X' Y'
Σ-ap-iso' {X = X}{X'}{Y}{Y'} isom isom'
= sym≅ (Σ-ap-iso (sym≅ isom) (λ x → sym≅ (isom' x)))
Π-ap-iso : ∀ {i i' j j'}{X : Set i}{X' : Set i'}
{Y : X → Set j}{Y' : X' → Set j'}
→ (isom : X ≅ X')
→ ((x' : X') → Y (invert isom x') ≅ Y' x')
→ ((x : X) → Y x)
≅ ((x' : X') → Y' x')
Π-ap-iso {X = X}{X'}{Y}{Y'} isom isom' =
trans≅ (Π-iso (≅⇒≅' isom)) (Π-iso' isom')
where
Π-iso : (isom : X ≅' X')
→ ((x : X) → Y x)
≅ ((x' : X') → Y (invert (proj₁ isom) x'))
Π-iso (iso f g H K , γ) = record
{ to = λ h x' → h (g x')
; from = λ h' x → subst Y (H x) (h' (f x))
; iso₁ = λ h → funext λ x → ap' h (H x)
; iso₂ = λ h' → funext λ x' →
ap (λ p → subst Y p _) (sym (γ' x'))
· sym (subst-naturality Y g (K x') _)
· ap' h' (K x') }
where γ' = co-coherence (iso f g H K) γ
Π-iso' : ∀ {i j j'}{X : Set i}
{Y : X → Set j}{Y' : X → Set j'}
→ ((x : X) → Y x ≅ Y' x)
→ ((x : X) → Y x)
≅ ((x : X) → Y' x)
Π-iso' isom = record
{ to = λ h x → apply (isom x) (h x)
; from = λ h' x → invert (isom x) (h' x)
; iso₁ = λ h → funext λ x → _≅_.iso₁ (isom x) _
; iso₂ = λ h' → funext λ x → _≅_.iso₂ (isom x) _ }
ΠΣ-swap-iso : ∀ {i j k}{X : Set i}{Y : X → Set j}
→ {Z : (x : X) → Y x → Set k}
→ ((x : X) → Σ (Y x) λ y → Z x y)
≅ (Σ ((x : X) → Y x) λ f → ((x : X) → Z x (f x)))
ΠΣ-swap-iso = record
{ to = λ f → (proj₁ ∘' f , proj₂ ∘' f)
; from = λ { (f , g) x → (f x , g x) }
; iso₁ = λ _ → refl
; iso₂ = λ _ → refl }
curry-iso : ∀ {i j k}{X : Set i}{Y : X → Set j}
(Z : (x : X) → Y x → Set k)
→ ((xy : Σ X Y) → Z (proj₁ xy) (proj₂ xy))
≅ ((x : X) → (y : Y x) → Z x y)
curry-iso _ = record
{ to = λ f x y → f (x , y)
; from = λ { f (x , y) → f x y }
; iso₁ = λ _ → refl
; iso₂ = λ _ → refl }
Π-comm-iso : ∀ {i j k}{X : Set i}{Y : Set j}{Z : X → Y → Set k}
→ ((x : X)(y : Y) → Z x y)
≅ ((y : Y)(x : X) → Z x y)
Π-comm-iso = record
{ to = λ f y x → f x y
; from = λ f x y → f y x
; iso₁ = λ _ → refl
; iso₂ = λ _ → refl }
Σ-comm-iso : ∀ {i j k}{X : Set i}{Y : Set j}{Z : X → Y → Set k}
→ (Σ X λ x → Σ Y λ y → Z x y)
≅ (Σ Y λ y → Σ X λ x → Z x y)
Σ-comm-iso = record
{ to = λ { (x , y , z) → (y , x , z) }
; from = λ { (y , x , z) → (x , y , z) }
; iso₁ = λ _ → refl
; iso₂ = λ _ → refl }
impl-iso : ∀ {i j}{X : Set i}{Y : X → Set j}
→ ((x : X) → Y x) ≅ ({x : X} → Y x)
impl-iso = record
{ to = λ f → f _
; from = λ f _ → f
; iso₁ = λ _ → refl
; iso₂ = λ _ → refl }
Σ-assoc-iso : ∀ {i j k}
{X : Set i}{Y : X → Set j}
{Z : (x : X) → Y x → Set k}
→ Σ (Σ X Y) (λ {(x , y) → Z x y})
≅ Σ X λ x → Σ (Y x) (Z x)
Σ-assoc-iso = record
{ to = λ {((x , y) , z) → (x , y , z) }
; from = λ {(x , y , z) → ((x , y) , z) }
; iso₁ = λ _ → refl
; iso₂ = λ _ → refl }
⊎-Σ-iso : ∀ {i}(X : Fin 2 → Set i)
→ (X zero ⊎ X (suc zero))
≅ Σ (Fin 2) X
⊎-Σ-iso X = record
{ to = λ { (inj₁ x) → zero , x
; (inj₂ x) → suc zero , x }
; from = λ { (zero , x) → inj₁ x
; (suc zero , x) → inj₂ x
; (suc (suc ()) , _) }
; iso₁ = λ { (inj₁ x) → refl
; (inj₂ x) → refl }
; iso₂ = λ { (zero , x) → refl
; (suc zero , x) → refl
; (suc (suc ()) , _) } }
⊎-ap-iso : ∀ {i j i' j'}
→ {X : Set i}{X' : Set i'}
→ {Y : Set j}{Y' : Set j'}
→ X ≅ X'
→ Y ≅ Y'
→ (X ⊎ Y) ≅ (X' ⊎ Y')
⊎-ap-iso (iso f g α β) (iso f' g' α' β') = record
{ to = λ { (inj₁ x) → inj₁ (f x) ; (inj₂ y) → inj₂ (f' y) }
; from = λ { (inj₁ x) → inj₁ (g x) ; (inj₂ y) → inj₂ (g' y) }
; iso₁ = λ { (inj₁ x) → ap inj₁ (α x) ; (inj₂ y) → ap inj₂ (α' y) }
; iso₂ = λ { (inj₁ x) → ap inj₁ (β x) ; (inj₂ y) → ap inj₂ (β' y) } }
⊎-assoc-iso : ∀ {i j k}
→ {X : Set i}{Y : Set j}{Z : Set k}
→ ((X ⊎ Y) ⊎ Z)
≅ (X ⊎ (Y ⊎ Z))
⊎-assoc-iso = record
{ to = λ { (inj₁ (inj₁ x)) → inj₁ x
; (inj₁ (inj₂ y)) → inj₂ (inj₁ y)
; (inj₂ z) → inj₂ (inj₂ z) }
; from = λ { (inj₁ x) → inj₁ (inj₁ x)
; (inj₂ (inj₁ y)) → inj₁ (inj₂ y)
; (inj₂ (inj₂ z)) → inj₂ z }
; iso₁ = λ { (inj₁ (inj₁ x)) → refl
; (inj₁ (inj₂ y)) → refl
; (inj₂ z) → refl }
; iso₂ = λ { (inj₁ x) → refl
; (inj₂ (inj₁ y)) → refl
; (inj₂ (inj₂ z)) → refl } }
⊎×-distr-iso : ∀ {i j k}
→ {X : Set i}{Y : Set j}{Z : Set k}
→ ((X ⊎ Y) × Z)
≅ ((X × Z) ⊎ (Y × Z))
⊎×-distr-iso = record
{ to = λ { (inj₁ x , z) → inj₁ (x , z)
; (inj₂ y , z) → inj₂ (y , z) }
; from = λ { (inj₁ (x , z)) → inj₁ x , z
; (inj₂ (y , z)) → inj₂ y , z }
; iso₁ = λ { (inj₁ x , z) → refl
; (inj₂ y , z) → refl }
; iso₂ = λ { (inj₁ (x , z)) → refl
; (inj₂ (y , z)) → refl } }
⊎-universal : ∀ {i j k}{X : Set i}{Y : Set j}
→ {Z : X ⊎ Y → Set k}
→ ((u : X ⊎ Y) → Z u)
≅ (((x : X) → Z (inj₁ x)) × ((y : Y) → Z (inj₂ y)))
⊎-universal = record
{ to = λ f → (f ∘' inj₁ , f ∘' inj₂)
; from = λ { (g₁ , g₂) (inj₁ x) → g₁ x
; (g₁ , g₂) (inj₂ y) → g₂ y }
; iso₁ = λ f → funext λ
{ (inj₁ x) → refl
; (inj₂ x) → refl }
; iso₂ = λ { (g₁ , g₂) → refl } }
×-left-unit : ∀ {i}{X : Set i} → (⊤ × X) ≅ X
×-left-unit = record
{ to = λ {(tt , x) → x }
; from = λ x → tt , x
; iso₁ = λ _ → refl
; iso₂ = λ _ → refl }
×-right-unit : ∀ {i}{X : Set i} → (X × ⊤) ≅ X
×-right-unit = record
{ to = λ {(x , tt) → x }
; from = λ x → x , tt
; iso₁ = λ _ → refl
; iso₂ = λ _ → refl }
contr-⊤-iso : ∀ {i}{X : Set i}
→ contr X → X ≅ ⊤
contr-⊤-iso hX = record
{ to = λ x → tt
; from = λ { tt → proj₁ hX }
; iso₁ = λ x → proj₂ hX x
; iso₂ = λ { tt → refl } }
empty-⊥-iso : ∀ {i}{X : Set i}
→ (X → ⊥) → X ≅ ⊥
empty-⊥-iso u = record
{ to = u
; from = ⊥-elim
; iso₁ = λ x → ⊥-elim (u x)
; iso₂ = λ () }
×-comm : ∀ {i j}{X : Set i}{Y : Set j}
→ (X × Y) ≅ (Y × X)
×-comm = record
{ to = λ {(x , y) → (y , x)}
; from = λ {(y , x) → (x , y)}
; iso₁ = λ _ → refl
; iso₂ = λ _ → refl }
Π-left-unit : ∀ {i}{X : Set i}
→ (⊤ → X) ≅ X
Π-left-unit = record
{ to = λ f → f tt
; from = λ x _ → x
; iso₁ = λ _ → refl
; iso₂ = λ f → refl }
-- rewriting lemmas for equations on equalities
sym≡-iso : ∀ {i}{X : Set i}(x y : X)
→ (x ≡ y)
≅ (y ≡ x)
sym≡-iso _ _ = iso sym sym double-inverse double-inverse
trans≡-iso : ∀ {i}{X : Set i}{x y z : X}
→ (x ≡ y)
→ (y ≡ z) ≅ (x ≡ z)
trans≡-iso p = record
{ to = λ q → p · q
; from = λ q → sym p · q
; iso₁ = λ q → sym (associativity (sym p) p q)
· ap (λ z → z · q) (right-inverse p)
; iso₂ = λ q → sym (associativity p (sym p) q)
· ap (λ z → z · q) (left-inverse p) }
trans≡-iso' : ∀ {i}{X : Set i}{x y z : X}
→ (y ≡ z)
→ (x ≡ y) ≅ (x ≡ z)
trans≡-iso' q = record
{ to = λ p → p · q
; from = λ p → p · sym q
; iso₁ = λ p → associativity p q (sym q)
· ap (_·_ p) (left-inverse q)
· left-unit p
; iso₂ = λ p → associativity p (sym q) q
· (ap (_·_ p) (right-inverse q)
· left-unit p) }
move-≡-iso : ∀ {i}{X : Set i}{x y z : X}
→ (p : x ≡ y)(q : y ≡ z)(r : x ≡ z)
→ (p · q ≡ r)
≅ (sym p · r ≡ q)
move-≡-iso refl = sym≡-iso
J-iso : ∀ {i j}{X : Set i}{x : X}
→ {P : (y : X) → x ≡ y → Set j}
→ P x refl
≅ ((y : X)(p : x ≡ y) → P y p)
J-iso {X = X}{x}{P} = record
{ to = J' P
; from = λ u → u x refl
; iso₁ = λ _ → refl
; iso₂ = λ u → funext λ y → funext λ p → β u y p }
where
β : (u : (y : X)(p : x ≡ y) → P y p)
→ (y : X)(p : x ≡ y)
→ J' P (u x refl) y p ≡ u y p
β u .x refl = refl
|
{
"alphanum_fraction": 0.3806381557,
"avg_line_length": 32.269541779,
"ext": "agda",
"hexsha": "a17c36720307f71f9fae3718cdb5cfff7fca6137",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z",
"max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "HoTT/M-types",
"max_forks_repo_path": "function/isomorphism/utils.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_issues_repo_issues_event_max_datetime": "2015-02-11T15:20:34.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-11T11:14:59.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "HoTT/M-types",
"max_issues_repo_path": "function/isomorphism/utils.agda",
"max_line_length": 75,
"max_stars_count": 27,
"max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "HoTT/M-types",
"max_stars_repo_path": "function/isomorphism/utils.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z",
"num_tokens": 5379,
"size": 11972
}
|
-- Basic intuitionistic modal logic S4, without ∨, ⊥, or ◇.
-- Basic Kripke-style semantics with abstract worlds, for soundness only.
-- Ono-style conditions.
module BasicIS4.Semantics.BasicKripkeOno where
open import BasicIS4.Syntax.Common public
-- Intuitionistic modal Kripke models, with frame conditions given by Ono.
record Model : Set₁ where
infix 3 _⊩ᵅ_
field
World : Set
-- Intuitionistic accessibility; preorder.
_≤_ : World → World → Set
refl≤ : ∀ {w} → w ≤ w
trans≤ : ∀ {w w′ w″} → w ≤ w′ → w′ ≤ w″ → w ≤ w″
-- Modal accessibility; preorder.
_R_ : World → World → Set
reflR : ∀ {w} → w R w
transR : ∀ {w w′ w″} → w R w′ → w′ R w″ → w R w″
-- Forcing for atomic propositions; monotonic.
_⊩ᵅ_ : World → Atom → Set
mono⊩ᵅ : ∀ {P w w′} → w ≤ w′ → w ⊩ᵅ P → w′ ⊩ᵅ P
-- Composition of accessibility.
_≤⨾R_ : World → World → Set
_≤⨾R_ = _≤_ ⨾ _R_
_R⨾≤_ : World → World → Set
_R⨾≤_ = _R_ ⨾ _≤_
-- Persistence condition.
--
-- w′ v′ → v′
-- ◌───R───● → ●
-- │ → ╱
-- ≤ ξ,ζ → R
-- │ → ╱
-- ● → ●
-- w → w
field
≤⨾R→R : ∀ {v′ w} → w ≤⨾R v′ → w R v′
-- Minor persistence condition.
--
-- w′ v′ → v′
-- ◌───R───● → ●
-- │ → │
-- ≤ ξ,ζ → ≤
-- │ → │
-- ● → ●───R───◌
-- w → w v
--
-- w″ → w″
-- ● → ●
-- │ → │
-- ξ′,ζ′ ≤ → │
-- │ → │
-- ●───R───◌ → ≤
-- │ v′ → │
-- ξ,ζ ≤ → │
-- │ → │
-- ●───R───◌ → ●───────R───────◌
-- w v → w v″
≤⨾R→R⨾≤ : ∀ {v′ w} → w ≤⨾R v′ → w R⨾≤ v′
≤⨾R→R⨾≤ {v′} ξ,ζ = v′ , (≤⨾R→R ξ,ζ , refl≤)
reflR⨾≤ : ∀ {w} → w R⨾≤ w
reflR⨾≤ {w} = w , (reflR , refl≤)
transR⨾≤ : ∀ {w′ w w″} → w R⨾≤ w′ → w′ R⨾≤ w″ → w R⨾≤ w″
transR⨾≤ {w′} (v , (ζ , ξ)) (v′ , (ζ′ , ξ′)) = let v″ , (ζ″ , ξ″) = ≤⨾R→R⨾≤ (w′ , (ξ , ζ′))
in v″ , (transR ζ ζ″ , trans≤ ξ″ ξ′)
≤→R : ∀ {v′ w} → w ≤ v′ → w R v′
≤→R {v′} ξ = ≤⨾R→R (v′ , (ξ , reflR))
open Model {{…}} public
-- Forcing in a particular world of a particular model.
module _ {{_ : Model}} where
infix 3 _⊩_
_⊩_ : World → Ty → Set
w ⊩ α P = w ⊩ᵅ P
w ⊩ A ▻ B = ∀ {w′} → w ≤ w′ → w′ ⊩ A → w′ ⊩ B
w ⊩ □ A = ∀ {v′} → w R v′ → v′ ⊩ A
w ⊩ A ∧ B = w ⊩ A × w ⊩ B
w ⊩ ⊤ = 𝟙
infix 3 _⊩⋆_
_⊩⋆_ : World → Cx Ty → Set
w ⊩⋆ ∅ = 𝟙
w ⊩⋆ Ξ , A = w ⊩⋆ Ξ × w ⊩ A
-- Monotonicity with respect to intuitionistic accessibility.
module _ {{_ : Model}} where
mono⊩ : ∀ {A w w′} → w ≤ w′ → w ⊩ A → w′ ⊩ A
mono⊩ {α P} ξ s = mono⊩ᵅ ξ s
mono⊩ {A ▻ B} ξ s = λ ξ′ a → s (trans≤ ξ ξ′) a
mono⊩ {□ A} ξ s = λ ζ → s (transR (≤→R ξ) ζ)
mono⊩ {A ∧ B} ξ s = mono⊩ {A} ξ (π₁ s) , mono⊩ {B} ξ (π₂ s)
mono⊩ {⊤} ξ s = ∙
mono⊩⋆ : ∀ {Γ w w′} → w ≤ w′ → w ⊩⋆ Γ → w′ ⊩⋆ Γ
mono⊩⋆ {∅} ξ ∙ = ∙
mono⊩⋆ {Γ , A} ξ (γ , a) = mono⊩⋆ {Γ} ξ γ , mono⊩ {A} ξ a
-- Additional useful equipment.
module _ {{_ : Model}} where
_⟪$⟫_ : ∀ {A B w} → w ⊩ A ▻ B → w ⊩ A → w ⊩ B
s ⟪$⟫ a = s refl≤ a
⟪K⟫ : ∀ {A B w} → w ⊩ A → w ⊩ B ▻ A
⟪K⟫ {A} a ξ = K (mono⊩ {A} ξ a)
⟪S⟫ : ∀ {A B C w} → w ⊩ A ▻ B ▻ C → w ⊩ A ▻ B → w ⊩ A → w ⊩ C
⟪S⟫ {A} {B} {C} s₁ s₂ a = _⟪$⟫_ {B} {C} (_⟪$⟫_ {A} {B ▻ C} s₁ a) (_⟪$⟫_ {A} {B} s₂ a)
⟪S⟫′ : ∀ {A B C w} → w ⊩ A ▻ B ▻ C → w ⊩ (A ▻ B) ▻ A ▻ C
⟪S⟫′ {A} {B} {C} s₁ ξ s₂ ξ′ a = let s₁′ = mono⊩ {A ▻ B ▻ C} (trans≤ ξ ξ′) s₁
s₂′ = mono⊩ {A ▻ B} ξ′ s₂
in ⟪S⟫ {A} {B} {C} s₁′ s₂′ a
_⟪D⟫_ : ∀ {A B w} → w ⊩ □ (A ▻ B) → w ⊩ □ A → w ⊩ □ B
_⟪D⟫_ {A} {B} s₁ s₂ ζ = let s₁′ = s₁ ζ
s₂′ = s₂ ζ
in _⟪$⟫_ {A} {B} s₁′ s₂′
_⟪D⟫′_ : ∀ {A B w} → w ⊩ □ (A ▻ B) → w ⊩ □ A ▻ □ B
_⟪D⟫′_ {A} {B} s₁ ξ = _⟪D⟫_ {A} {B} (mono⊩ {□ (A ▻ B)} ξ s₁)
⟪↑⟫ : ∀ {A w} → w ⊩ □ A → w ⊩ □ □ A
⟪↑⟫ s ζ ζ′ = s (transR ζ ζ′)
⟪↓⟫ : ∀ {A w} → w ⊩ □ A → w ⊩ A
⟪↓⟫ s = s reflR
_⟪,⟫′_ : ∀ {A B w} → w ⊩ A → w ⊩ B ▻ A ∧ B
_⟪,⟫′_ {A} {B} a ξ = _,_ (mono⊩ {A} ξ a)
-- Forcing in a particular world of a particular model, for sequents.
module _ {{_ : Model}} where
infix 3 _⊩_⇒_
_⊩_⇒_ : World → Cx Ty → Ty → Set
w ⊩ Γ ⇒ A = w ⊩⋆ Γ → w ⊩ A
infix 3 _⊩_⇒⋆_
_⊩_⇒⋆_ : World → Cx Ty → Cx Ty → Set
w ⊩ Γ ⇒⋆ Ξ = w ⊩⋆ Γ → w ⊩⋆ Ξ
-- Entailment, or forcing in all worlds of all models, for sequents.
infix 3 _⊨_
_⊨_ : Cx Ty → Ty → Set₁
Γ ⊨ A = ∀ {{_ : Model}} {w : World} → w ⊩ Γ ⇒ A
infix 3 _⊨⋆_
_⊨⋆_ : Cx Ty → Cx Ty → Set₁
Γ ⊨⋆ Ξ = ∀ {{_ : Model}} {w : World} → w ⊩ Γ ⇒⋆ Ξ
infix 3 _⁏_⊨_
_⁏_⊨_ : Cx Ty → Cx Ty → Ty → Set₁
Γ ⁏ Δ ⊨ A = ∀ {{_ : Model}} {w : World}
→ w ⊩⋆ Γ → (∀ {v′} → w R v′ → v′ ⊩⋆ Δ) → w ⊩ A
-- Additional useful equipment, for sequents.
module _ {{_ : Model}} where
lookup : ∀ {A Γ w} → A ∈ Γ → w ⊩ Γ ⇒ A
lookup top (γ , a) = a
lookup (pop i) (γ , b) = lookup i γ
|
{
"alphanum_fraction": 0.3525206233,
"avg_line_length": 28.118556701,
"ext": "agda",
"hexsha": "fbba3d868d5d916bc1c56415d41b484f8e9635f4",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/hilbert-gentzen",
"max_forks_repo_path": "BasicIS4/Semantics/BasicKripkeOno.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/hilbert-gentzen",
"max_issues_repo_path": "BasicIS4/Semantics/BasicKripkeOno.agda",
"max_line_length": 93,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/hilbert-gentzen",
"max_stars_repo_path": "BasicIS4/Semantics/BasicKripkeOno.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z",
"num_tokens": 2798,
"size": 5455
}
|
------------------------------------------------------------------------------
-- Agda-Prop Library.
------------------------------------------------------------------------------
open import Data.Nat using ( ℕ )
module Data.PropFormula.Dec ( n : ℕ ) where
------------------------------------------------------------------------------
open import Data.PropFormula.Syntax n
open import Data.Bool.Base using ( Bool; false; true; not; T )
open import Data.Fin using ( Fin; suc; zero )
open import Data.Empty hiding (⊥)
open import Function using ( _$_; _∘_ )
open import Relation.Binary.PropositionalEquality using ( _≡_; refl; cong )
------------------------------------------------------------------------------
data ⊥₂ : Set where
⊥₂-elim : ∀ {Whatever : Set} → ⊥₂ → Whatever
⊥₂-elim ()
infix 3 ¬₂_
¬₂_ : Set → Set
¬₂ P = P → ⊥₂
-- Decidable relations.
data Dec (P : Set) : Set where
yes : ( p : P) → Dec P
no : (¬p : ¬₂ P) → Dec P
⌊_⌋ : {P : Set} → Dec P → Bool
⌊ yes _ ⌋ = true
⌊ no _ ⌋ = false
REL : Set → Set → Set₁
REL A B = A → B → Set
Decidable : {A : Set} {B : Set} → REL A B → Set
Decidable _∼_ = ∀ x y → Dec (x ∼ y)
|
{
"alphanum_fraction": 0.4286934244,
"avg_line_length": 24.914893617,
"ext": "agda",
"hexsha": "9133c2629dadaad37b2a512ce2027e4f0044ecd5",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2017-12-01T17:01:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-03-30T16:41:56.000Z",
"max_forks_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "jonaprieto/agda-prop",
"max_forks_repo_path": "src/Data/PropFormula/Dec.agda",
"max_issues_count": 18,
"max_issues_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae",
"max_issues_repo_issues_event_max_datetime": "2017-12-18T16:34:21.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-03-08T14:33:10.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "jonaprieto/agda-prop",
"max_issues_repo_path": "src/Data/PropFormula/Dec.agda",
"max_line_length": 78,
"max_stars_count": 13,
"max_stars_repo_head_hexsha": "a1730062a6aaced2bb74878c1071db06477044ae",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "jonaprieto/agda-prop",
"max_stars_repo_path": "src/Data/PropFormula/Dec.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-17T03:33:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-05-01T16:45:41.000Z",
"num_tokens": 325,
"size": 1171
}
|
postulate
A : Set
variable
{xx} : A
record R : Set₁ where
field
P : A → Set
a : P xx
b : P xx
c : P xx
d : P xx
e : P xx
f : P xx
g : P xx
h : P xx
i : P xx
j : P xx
k : P xx
l : P xx
m : P xx
n : P xx
o : P xx
p : P xx
q : P xx
r : P xx
s : P xx
t : P xx
u : P xx
v : P xx
w : P xx
x : P xx
y : P xx
z : P xx
|
{
"alphanum_fraction": 0.3606557377,
"avg_line_length": 11.5405405405,
"ext": "agda",
"hexsha": "49284fbb356db5e89bb6377b0eafc794cdf12cd2",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/Issue3306.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/Issue3306.agda",
"max_line_length": 21,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue3306.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 191,
"size": 427
}
|
module BBSTree {A : Set}(_≤_ : A → A → Set) where
open import Bound.Total A
open import Bound.Total.Order _≤_
open import Data.List
open import List.Order.Simple _≤_
data BBSTree : Bound → Bound → Set where
bslf : {b t : Bound}
→ LeB b t
→ BBSTree b t
bsnd : {x : A}{b t : Bound}
→ LeB b (val x)
→ LeB (val x) t
→ BBSTree b (val x)
→ BBSTree (val x) t
→ BBSTree b t
flatten : {b t : Bound} → BBSTree b t → List A
flatten (bslf _) = []
flatten (bsnd {x = x} b≤x x≤t l r) = flatten l ++ (x ∷ flatten r)
|
{
"alphanum_fraction": 0.4830769231,
"avg_line_length": 29.5454545455,
"ext": "agda",
"hexsha": "b7b70eda6385471ab9ed3bbfde55c4dd39ddae8e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bgbianchi/sorting",
"max_forks_repo_path": "agda/BBSTree.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bgbianchi/sorting",
"max_issues_repo_path": "agda/BBSTree.agda",
"max_line_length": 65,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bgbianchi/sorting",
"max_stars_repo_path": "agda/BBSTree.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z",
"num_tokens": 213,
"size": 650
}
|
open import Prelude
open import core
open import contexts
open import weakening
module typed-expansion where
mutual
typed-expansion-synth : ∀{Φ Γ p e τ} →
Φ , Γ ⊢ p ~~> e ⇒ τ →
Γ ⊢ e => τ
typed-expansion-synth SPEConst = SConst
typed-expansion-synth (SPEAsc x) = SAsc (typed-expansion-ana x)
typed-expansion-synth (SPEVar x₁) = SVar x₁
typed-expansion-synth (SPELam x₁ D) = SLam x₁ (typed-expansion-synth D)
typed-expansion-synth (SPEAp D1 x D2 x₂) = SAp x₂ (typed-expansion-synth D1) x (typed-expansion-ana D2)
typed-expansion-synth SPEHole = SEHole
typed-expansion-synth (SPNEHole x D) = SNEHole x (typed-expansion-synth D)
typed-expansion-synth (SPEApLivelit hd fr x x₁ x₂ x₃ x₄ x₅) = SAp (HDAsc hd) (SAsc (weaken-ana-closed fr x₅)) MAArr (typed-expansion-ana x₄)
typed-expansion-synth (SPEFst h x) = SFst (typed-expansion-synth h) x
typed-expansion-synth (SPESnd h x) = SSnd (typed-expansion-synth h) x
typed-expansion-synth (SPEPair h h₁ x) = SPair x (typed-expansion-synth h) (typed-expansion-synth h₁)
typed-expansion-ana : ∀{Φ Γ p e τ} →
Φ , Γ ⊢ p ~~> e ⇐ τ →
Γ ⊢ e <= τ
typed-expansion-ana (APELam x₁ x₂ D) = ALam x₁ x₂ (typed-expansion-ana D)
typed-expansion-ana (APESubsume h ch) = ASubsume (typed-expansion-synth h) ch
|
{
"alphanum_fraction": 0.6205698402,
"avg_line_length": 51.3928571429,
"ext": "agda",
"hexsha": "a804cffa9826384c9279363bd65fc9ba614c53f7",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "hazelgrove/hazelnut-livelits-agda",
"max_forks_repo_path": "typed-expansion.agda",
"max_issues_count": 9,
"max_issues_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a",
"max_issues_repo_issues_event_max_datetime": "2020-10-20T20:44:13.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-09-30T20:27:56.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "hazelgrove/hazel-palette-agda",
"max_issues_repo_path": "typed-expansion.agda",
"max_line_length": 144,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "c3225acc3c94c56376c6842b82b8b5d76912df2a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "hazelgrove/hazel-palette-agda",
"max_stars_repo_path": "typed-expansion.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-19T15:38:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-04T06:45:06.000Z",
"num_tokens": 488,
"size": 1439
}
|
{-# OPTIONS --without-K --safe #-}
open import Categories.Category using (Category; module Commutation)
-- Defines the induced Monoidal structure of a Cartesian Category
module Categories.Category.Cartesian.Monoidal {o ℓ e} {𝒞 : Category o ℓ e} where
open Category 𝒞
open HomReasoning
open import Categories.Category.BinaryProducts 𝒞 using (BinaryProducts; module BinaryProducts)
open import Categories.Category.Cartesian using (Cartesian)
open import Categories.Object.Terminal 𝒞 using (Terminal)
open import Categories.Object.Product.Core 𝒞 using (module Product)
open import Categories.Morphism 𝒞 using (_≅_; module ≅)
open import Categories.Morphism.Reasoning 𝒞 using (cancelˡ; pullʳ; pullˡ)
open import Categories.Category.Monoidal using (Monoidal)
open import Categories.Functor using (Functor) renaming (id to idF)
open import Categories.NaturalTransformation using (ntHelper)
open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism)
private
variable
A B C D W X Y Z : Obj
f f′ g g′ h i : A ⇒ B
-- The cartesian structure induces a monoidal one: 𝒞 is cartesian monoidal.
module CartesianMonoidal (cartesian : Cartesian 𝒞) where
open Commutation 𝒞
open Terminal (Cartesian.terminal cartesian) using (⊤; !; !-unique; !-unique₂)
open BinaryProducts (Cartesian.products cartesian) using (π₁; π₂; ⟨_,_⟩; _×_; _⁂_;
_×-; -×_; ⟨⟩∘; ⟨⟩-cong₂; -×-; ×-assoc; assocˡ∘⁂; assocʳ∘⁂; ⁂∘⟨⟩;
first∘⟨⟩; second∘⟨⟩; ⟨⟩-congˡ; ⟨⟩-congʳ; π₁∘⁂; π₂∘⁂; assocˡ∘⟨⟩;
assocˡ; assocʳ;
η; unique; project₁; project₂)
⊤×A≅A : ⊤ × A ≅ A
⊤×A≅A = record
{ from = π₂
; to = ⟨ ! , id ⟩
; iso = record
{ isoˡ = begin
⟨ ! , id ⟩ ∘ π₂ ≈˘⟨ unique !-unique₂ (cancelˡ project₂) ⟩
⟨ π₁ , π₂ ⟩ ≈⟨ η ⟩
id ∎
; isoʳ = project₂
}
}
A×⊤≅A : A × ⊤ ≅ A
A×⊤≅A = record
{ from = π₁
; to = ⟨ id , ! ⟩
; iso = record
{ isoˡ = begin
⟨ id , ! ⟩ ∘ π₁ ≈˘⟨ unique (cancelˡ project₁) !-unique₂ ⟩
⟨ π₁ , π₂ ⟩ ≈⟨ η ⟩
id ∎
; isoʳ = project₁
}
}
⊤×--id : NaturalIsomorphism (⊤ ×-) idF
⊤×--id = record
{ F⇒G = ntHelper record
{ η = λ _ → π₂
; commute = λ _ → project₂
}
; F⇐G = ntHelper record
{ η = λ _ → ⟨ ! , id ⟩
; commute = λ f → begin
⟨ ! , id ⟩ ∘ f ≈⟨ ⟨⟩∘ ⟩
⟨ ! ∘ f , id ∘ f ⟩ ≈⟨ ⟨⟩-cong₂ (⟺ (!-unique _)) identityˡ ⟩
⟨ ! , f ⟩ ≈˘⟨ ⟨⟩-cong₂ identityˡ identityʳ ⟩
⟨ id ∘ ! , f ∘ id ⟩ ≈˘⟨ ⟨⟩-cong₂ (pullʳ project₁) (pullʳ project₂) ⟩
⟨ (id ∘ π₁) ∘ ⟨ ! , id ⟩ , (f ∘ π₂) ∘ ⟨ ! , id ⟩ ⟩ ≈˘⟨ ⟨⟩∘ ⟩
⟨ id ∘ π₁ , f ∘ π₂ ⟩ ∘ ⟨ ! , id ⟩ ∎
}
; iso = λ _ → _≅_.iso ⊤×A≅A
}
-×⊤-id : NaturalIsomorphism (-× ⊤) idF
-×⊤-id = record
{ F⇒G = ntHelper record
{ η = λ _ → π₁
; commute = λ _ → project₁
}
; F⇐G = ntHelper record
{ η = λ _ → ⟨ id , ! ⟩
; commute = λ f → begin
⟨ id , ! ⟩ ∘ f ≈⟨ ⟨⟩∘ ⟩
⟨ id ∘ f , ! ∘ f ⟩ ≈⟨ ⟨⟩-cong₂ identityˡ (⟺ (!-unique _)) ⟩
⟨ f , ! ⟩ ≈˘⟨ ⟨⟩-cong₂ identityʳ identityˡ ⟩
⟨ f ∘ id , id ∘ ! ⟩ ≈˘⟨ ⟨⟩-cong₂ (pullʳ project₁) (pullʳ project₂) ⟩
⟨ (f ∘ π₁) ∘ ⟨ id , ! ⟩ , (id ∘ π₂) ∘ ⟨ id , ! ⟩ ⟩ ≈˘⟨ ⟨⟩∘ ⟩
⟨ f ∘ π₁ , id ∘ π₂ ⟩ ∘ ⟨ id , ! ⟩ ∎
}
; iso = λ _ → _≅_.iso A×⊤≅A
}
private
infixr 7 _⊗₀_
infixr 8 _⊗₁_
_⊗₀_ = _×_
_⊗₁_ = _⁂_
α⇒ = assocˡ
private
pentagon : [ ((X ⊗₀ Y) ⊗₀ Z) ⊗₀ W ⇒ X ⊗₀ Y ⊗₀ Z ⊗₀ W ]⟨
α⇒ ⊗₁ id ⇒⟨ (X ⊗₀ Y ⊗₀ Z) ⊗₀ W ⟩
α⇒ ⇒⟨ X ⊗₀ (Y ⊗₀ Z) ⊗₀ W ⟩
id ⊗₁ α⇒
≈ α⇒ ⇒⟨ (X ⊗₀ Y) ⊗₀ Z ⊗₀ W ⟩
α⇒
⟩
pentagon = begin
(id ⁂ α⇒) ∘ α⇒ ∘ (α⇒ ⁂ id) ≈⟨ pullˡ second∘⟨⟩ ⟩
⟨ π₁ ∘ π₁ , α⇒ ∘ ⟨ π₂ ∘ π₁ , π₂ ⟩ ⟩ ∘ (α⇒ ⁂ id) ≈⟨ ⟨⟩∘ ⟩
⟨ (π₁ ∘ π₁) ∘ (α⇒ ⁂ id) , (α⇒ ∘ ⟨ π₂ ∘ π₁ , π₂ ⟩) ∘ (α⇒ ⁂ id) ⟩ ≈⟨ ⟨⟩-cong₂ (pullʳ π₁∘⁂) (pullʳ ⟨⟩∘) ⟩
⟨ π₁ ∘ α⇒ ∘ π₁ , α⇒ ∘ ⟨ (π₂ ∘ π₁) ∘ (α⇒ ⁂ id) , π₂ ∘ (α⇒ ⁂ id) ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ (pullˡ project₁) ( refl⟩∘⟨ ⟨⟩-cong₂ (pullʳ π₁∘⁂) π₂∘⁂) ⟩
⟨ (π₁ ∘ π₁) ∘ π₁ , α⇒ ∘ ⟨ π₂ ∘ α⇒ ∘ π₁ , id ∘ π₂ ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ assoc (refl⟩∘⟨ ⟨⟩-cong₂ (pullˡ project₂) identityˡ) ⟩
⟨ π₁₁₁ , α⇒ ∘ ⟨ ⟨ π₂ ∘ π₁ , π₂ ⟩ ∘ π₁ , π₂ ⟩ ⟩ ≈⟨ ⟨⟩-congˡ (refl⟩∘⟨ ⟨⟩-congʳ ⟨⟩∘) ⟩
⟨ π₁₁₁ , α⇒ ∘ ⟨ ⟨ (π₂ ∘ π₁) ∘ π₁ , π₂ ∘ π₁ ⟩ , π₂ ⟩ ⟩ ≈⟨ ⟨⟩-congˡ assocˡ∘⟨⟩ ⟩
⟨ π₁₁₁ , ⟨ (π₂ ∘ π₁) ∘ π₁ , ⟨ π₂ ∘ π₁ , π₂ ⟩ ⟩ ⟩ ≈˘⟨ ⟨⟩-congˡ (⟨⟩-cong₂ (Equiv.trans (pullʳ project₁) sym-assoc) project₂) ⟩
⟨ π₁₁₁ , ⟨ (π₂ ∘ π₁) ∘ α⇒ , π₂ ∘ α⇒ ⟩ ⟩ ≈˘⟨ ⟨⟩-cong₂ (pullʳ project₁) ⟨⟩∘ ⟩
⟨ (π₁ ∘ π₁) ∘ α⇒ , ⟨ π₂ ∘ π₁ , π₂ ⟩ ∘ α⇒ ⟩ ≈˘⟨ ⟨⟩∘ ⟩
α⇒ ∘ α⇒ ∎
where
π₁₁₁ = π₁ ∘ π₁ ∘ π₁
monoidal : Monoidal 𝒞
monoidal = record
{ ⊗ = -×-
; unit = ⊤
; unitorˡ = ⊤×A≅A
; unitorʳ = A×⊤≅A
; associator = ≅.sym ×-assoc
; unitorˡ-commute-from = project₂
; unitorˡ-commute-to = let open NaturalIsomorphism ⊤×--id in ⇐.commute _
; unitorʳ-commute-from = project₁
; unitorʳ-commute-to = let open NaturalIsomorphism -×⊤-id in ⇐.commute _
; assoc-commute-from = assocˡ∘⁂
; assoc-commute-to = assocʳ∘⁂
; triangle = begin
(id ⁂ π₂) ∘ assocˡ ≈⟨ ⁂∘⟨⟩ ⟩
⟨ id ∘ π₁ ∘ π₁ , π₂ ∘ ⟨ π₂ ∘ π₁ , π₂ ⟩ ⟩ ≈⟨ ⟨⟩-cong₂ (pullˡ identityˡ) (project₂ ○ (⟺ identityˡ)) ⟩
π₁ ⁂ id ∎
; pentagon = pentagon
}
|
{
"alphanum_fraction": 0.4230583695,
"avg_line_length": 40.6470588235,
"ext": "agda",
"hexsha": "296616c5a5165f3a1ce24c2f4182f096c80fa623",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Cartesian/Monoidal.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Cartesian/Monoidal.agda",
"max_line_length": 151,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Cartesian/Monoidal.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z",
"num_tokens": 2698,
"size": 6219
}
|
{-# OPTIONS --no-qualified-instances #-}
module NoQualifiedInstances-InAnonymousModule where
postulate
A : Set
f : {{A}} → A
module _ where postulate instance a : A
test : A
test = f
|
{
"alphanum_fraction": 0.6910994764,
"avg_line_length": 14.6923076923,
"ext": "agda",
"hexsha": "9550dad3c0b11ac5f23ba352ff531732c6cba638",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "test/Succeed/NoQualifiedInstances-InAnonymousModule.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/NoQualifiedInstances-InAnonymousModule.agda",
"max_line_length": 51,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/NoQualifiedInstances-InAnonymousModule.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 53,
"size": 191
}
|
open import Relation.Binary.Core
module PLRTree.Everything {A : Set}
(_≤_ : A → A → Set)
(tot≤ : Total _≤_)
(trans≤ : Transitive _≤_) where
open import PLRTree.Complete.Correctness.Base {A}
open import PLRTree.Drop.Complete _≤_ tot≤
open import PLRTree.Drop.Heap _≤_ tot≤ trans≤
open import PLRTree.Drop.Permutation _≤_ tot≤
open import PLRTree.Heap.Correctness _≤_
open import PLRTree.Insert.Complete _≤_ tot≤
open import PLRTree.Insert.Heap _≤_ tot≤ trans≤
open import PLRTree.Insert.Permutation _≤_ tot≤
|
{
"alphanum_fraction": 0.6873889876,
"avg_line_length": 35.1875,
"ext": "agda",
"hexsha": "161a2dbfc04d3d0c710e5ff05448bdaa71e961e7",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bgbianchi/sorting",
"max_forks_repo_path": "agda/PLRTree/Everything.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bgbianchi/sorting",
"max_issues_repo_path": "agda/PLRTree/Everything.agda",
"max_line_length": 49,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bgbianchi/sorting",
"max_stars_repo_path": "agda/PLRTree/Everything.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z",
"num_tokens": 184,
"size": 563
}
|
module Control.Exception.Primitive where
open import IO.Primitive
postulate
bracket : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} → IO A → (A → IO B) → (A → IO C) → IO C
{-# IMPORT Control.Exception #-}
{-# COMPILED bracket (\_ _ _ _ _ _ -> Control.Exception.bracket) #-}
|
{
"alphanum_fraction": 0.6129032258,
"avg_line_length": 27.9,
"ext": "agda",
"hexsha": "72403a9950d6a3f18507d71294d8e9494dad1b94",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c710fde0b0904cb3c02c54142a938d12a4463b0a",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "ilya-fiveisky/agda-exceptions",
"max_forks_repo_path": "src/Control/Exception/Primitive.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c710fde0b0904cb3c02c54142a938d12a4463b0a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "ilya-fiveisky/agda-exceptions",
"max_issues_repo_path": "src/Control/Exception/Primitive.agda",
"max_line_length": 97,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c710fde0b0904cb3c02c54142a938d12a4463b0a",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "ilya-fiveisky/agda-exceptions",
"max_stars_repo_path": "src/Control/Exception/Primitive.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 88,
"size": 279
}
|
open import Data.Nat using (ℕ; suc ; zero; _+_; _≤′_; _<′_; _<_; _≤_;
z≤n; s≤s; ≤′-refl; ≤′-step; _≟_) renaming (_⊔_ to max)
open import Data.Nat.Properties
using (n≤0⇒n≡0; ≤-refl; ≤-trans; m≤m⊔n; n≤m⊔n; ≤-step; ⊔-mono-≤;
+-mono-≤; +-mono-≤-<; +-mono-<-≤; +-comm; +-assoc; n≤1+n;
≤-pred; m≤m+n; n≤m+n; ≤-reflexive; ≤′⇒≤; ≤⇒≤′; +-suc)
open Data.Nat.Properties.≤-Reasoning using (begin_; _≤⟨_⟩_; _∎)
open import Data.Bool using (Bool) renaming (_≟_ to _=?_)
open import Data.Product using (_×_; Σ; Σ-syntax; ∃; ∃-syntax; proj₁; proj₂)
renaming (_,_ to ⟨_,_⟩)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Data.Empty using (⊥-elim) renaming (⊥ to Bot)
open import Data.Unit using (⊤; tt)
open import Data.Maybe
open import Data.List using (List ; _∷_ ; []; _++_)
open import Relation.Nullary using (¬_)
open import Relation.Nullary using (Dec; yes; no)
open import Relation.Nullary.Negation using (contradiction)
open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; cong)
open Relation.Binary.PropositionalEquality.≡-Reasoning renaming (begin_ to start_; _∎ to _□)
module extra.Value where
data Base : Set where
Nat : Base
𝔹 : Base
data Prim : Set where
base : Base → Prim
_⇒_ : Base → Prim → Prim
base-rep : Base → Set
base-rep Nat = ℕ
base-rep 𝔹 = Bool
rep : Prim → Set
rep (base b) = base-rep b
rep (b ⇒ p) = base-rep b → rep p
base-eq? : (B : Base) → (B' : Base) → Dec (B ≡ B')
base-eq? Nat Nat = yes refl
base-eq? Nat 𝔹 = no (λ ())
base-eq? 𝔹 Nat = no (λ ())
base-eq? 𝔹 𝔹 = yes refl
base-rep-eq? : ∀{B} → (k : base-rep B) (k′ : base-rep B) → Dec (k ≡ k′)
base-rep-eq? {Nat} k k′ = k ≟ k′
base-rep-eq? {𝔹} k k′ = k =? k′
infixr 7 _↦_
infixl 6 _⊔_
data Value : Set
data Value where
⊥ : Value
const : {b : Base} → base-rep b → Value
_↦_ : Value → Value → Value
_⊔_ : (u : Value) → (v : Value) → Value
infix 5 _∈_
_∈_ : Value → Value → Set
u ∈ ⊥ = u ≡ ⊥
u ∈ const {B} k = u ≡ const {B} k
u ∈ v ↦ w = u ≡ v ↦ w
u ∈ (v ⊔ w) = u ∈ v ⊎ u ∈ w
infix 5 _⊆_
_⊆_ : Value → Value → Set
v ⊆ w = ∀{u} → u ∈ v → u ∈ w
AllFun : (u : Value) → Set
AllFun ⊥ = Bot
AllFun (const x) = Bot
AllFun (v ↦ w) = ⊤
AllFun (u ⊔ v) = AllFun u × AllFun v
dom : (u : Value) → Value
dom ⊥ = ⊥
dom (const k) = ⊥
dom (v ↦ w) = v
dom (u ⊔ v) = dom u ⊔ dom v
cod : (u : Value) → Value
cod ⊥ = ⊥
cod (const k) = ⊥
cod (v ↦ w) = w
cod (u ⊔ v) = cod u ⊔ cod v
infix 4 _⊑_
data _⊑_ : Value → Value → Set where
⊑-⊥ : ∀ {v} → ⊥ ⊑ v
⊑-const : ∀ {B}{k} → const {B} k ⊑ const {B} k
⊑-conj-L : ∀ {u v w}
→ v ⊑ u
→ w ⊑ u
-----------
→ v ⊔ w ⊑ u
⊑-conj-R1 : ∀ {u v w}
→ u ⊑ v
------------------
→ u ⊑ v ⊔ w
⊑-conj-R2 : ∀ {u v w}
→ u ⊑ w
-----------
→ u ⊑ v ⊔ w
⊑-fun : ∀ {u u′ v w}
→ u′ ⊆ u
→ AllFun u′
→ dom u′ ⊑ v
→ w ⊑ cod u′
-------------------
→ v ↦ w ⊑ u
⊑-refl : ∀{v} → v ⊑ v
⊑-refl {⊥} = ⊑-⊥
⊑-refl {const k} = ⊑-const
⊑-refl {v ↦ w} = ⊑-fun{v ↦ w}{v ↦ w} (λ {u} z → z) tt (⊑-refl{v}) ⊑-refl
⊑-refl {v₁ ⊔ v₂} = ⊑-conj-L (⊑-conj-R1 ⊑-refl) (⊑-conj-R2 ⊑-refl)
factor : (u : Value) → (u′ : Value) → (v : Value) → (w : Value) → Set
factor u u′ v w = AllFun u′ × u′ ⊆ u × dom u′ ⊑ v × w ⊑ cod u′
⊑-fun-inv : ∀{u₁ u₂ v w}
→ u₁ ⊑ u₂
→ v ↦ w ∈ u₁
→ Σ[ u₃ ∈ Value ] factor u₂ u₃ v w
⊑-fun-inv {.⊥} {u₂} {v} {w} ⊑-⊥ ()
⊑-fun-inv {.(const _)} {.(const _)} {v} {w} ⊑-const ()
⊑-fun-inv {u11 ⊔ u12} {u₂} {v} {w} (⊑-conj-L u₁⊑u₂ u₁⊑u₃) (inj₁ x) =
⊑-fun-inv u₁⊑u₂ x
⊑-fun-inv {u11 ⊔ u12} {u₂} {v} {w} (⊑-conj-L u₁⊑u₂ u₁⊑u₃) (inj₂ y) =
⊑-fun-inv u₁⊑u₃ y
⊑-fun-inv {u₁} {u21 ⊔ u22} {v} {w} (⊑-conj-R1 u₁⊑u₂) v↦w∈u₁
with ⊑-fun-inv {u₁} {u21} {v} {w} u₁⊑u₂ v↦w∈u₁
... | ⟨ u₃ , ⟨ afu₃ , ⟨ u3⊆u₁ , ⟨ du₃⊑v , w⊑codu₃ ⟩ ⟩ ⟩ ⟩ =
⟨ u₃ , ⟨ afu₃ , ⟨ (λ {x} x₁ → inj₁ (u3⊆u₁ x₁)) , ⟨ du₃⊑v , w⊑codu₃ ⟩ ⟩ ⟩ ⟩
⊑-fun-inv {u₁} {u21 ⊔ u22} {v} {w} (⊑-conj-R2 u₁⊑u₂) v↦w∈u₁
with ⊑-fun-inv {u₁} {u22} {v} {w} u₁⊑u₂ v↦w∈u₁
... | ⟨ u₃ , ⟨ afu₃ , ⟨ u3⊆u₁ , ⟨ du₃⊑v , w⊑codu₃ ⟩ ⟩ ⟩ ⟩ =
⟨ u₃ , ⟨ afu₃ , ⟨ (λ {x} x₁ → inj₂ (u3⊆u₁ x₁)) , ⟨ du₃⊑v , w⊑codu₃ ⟩ ⟩ ⟩ ⟩
⊑-fun-inv {u11 ↦ u21} {u₂} {v} {w} (⊑-fun{u′ = u′} u′⊆u₂ afu′ du′⊑u11 u21⊑cu′)
refl =
⟨ u′ , ⟨ afu′ , ⟨ u′⊆u₂ , ⟨ du′⊑u11 , u21⊑cu′ ⟩ ⟩ ⟩ ⟩
sub-inv-trans : ∀{u′ u₂ u : Value}
→ AllFun u′ → u′ ⊆ u
→ (∀{v′ w′} → v′ ↦ w′ ∈ u′ → Σ[ u₃ ∈ Value ] factor u₂ u₃ v′ w′)
---------------------------------------------------------------
→ Σ[ u₃ ∈ Value ] factor u₂ u₃ (dom u′) (cod u′)
sub-inv-trans {⊥} {u₂} {u} () u′⊆u IH
sub-inv-trans {const k} {u₂} {u} () u′⊆u IH
sub-inv-trans {u₁′ ↦ u₂′} {u₂} {u} fu′ u′⊆u IH = IH refl
sub-inv-trans {u₁′ ⊔ u₂′} {u₂} {u} ⟨ afu₁′ , afu₂′ ⟩ u′⊆u IH
with sub-inv-trans {u₁′} {u₂} {u} afu₁′
(λ {u₁} z → u′⊆u (inj₁ z)) (λ {v′} {w′} z → IH (inj₁ z))
| sub-inv-trans {u₂′} {u₂} {u} afu₂′
(λ {u₁} z → u′⊆u (inj₂ z)) (λ {v′} {w′} z → IH (inj₂ z))
... | ⟨ u₃ , ⟨ afu₃ , ⟨ u₃⊆ , ⟨ du₃⊑ , ⊑cu₃ ⟩ ⟩ ⟩ ⟩
| ⟨ u₄ , ⟨ afu₄ , ⟨ u₄⊆ , ⟨ du₄⊑ , ⊑cu₄ ⟩ ⟩ ⟩ ⟩ =
⟨ (u₃ ⊔ u₄) , ⟨ ⟨ afu₃ , afu₄ ⟩ , ⟨ G , ⟨ H , I ⟩ ⟩ ⟩ ⟩
where
G : ∀ {u₁} → u₁ ∈ u₃ ⊎ u₁ ∈ u₄ → u₁ ∈ u₂
G {u₁} (inj₁ x) = u₃⊆ x
G {u₁} (inj₂ y) = u₄⊆ y
H : dom u₃ ⊔ dom u₄ ⊑ dom u₁′ ⊔ dom u₂′
H = ⊑-conj-L (⊑-conj-R1 du₃⊑) (⊑-conj-R2 du₄⊑)
I : cod u₁′ ⊔ cod u₂′ ⊑ cod u₃ ⊔ cod u₄
I = ⊑-conj-L (⊑-conj-R1 ⊑cu₃) (⊑-conj-R2 ⊑cu₄)
⊔⊑R : ∀{B C A}
→ B ⊔ C ⊑ A
→ B ⊑ A
⊔⊑R (⊑-conj-L B⊔C⊑A B⊔C⊑A₁) = B⊔C⊑A
⊔⊑R (⊑-conj-R1 B⊔C⊑A) = ⊑-conj-R1 (⊔⊑R B⊔C⊑A)
⊔⊑R (⊑-conj-R2 B⊔C⊑A) = ⊑-conj-R2 (⊔⊑R B⊔C⊑A)
⊔⊑L : ∀{B C A}
→ B ⊔ C ⊑ A
→ C ⊑ A
⊔⊑L (⊑-conj-L B⊔C⊑A B⊔C⊑A₁) = B⊔C⊑A₁
⊔⊑L (⊑-conj-R1 B⊔C⊑A) = ⊑-conj-R1 (⊔⊑L B⊔C⊑A)
⊔⊑L (⊑-conj-R2 B⊔C⊑A) = ⊑-conj-R2 (⊔⊑L B⊔C⊑A)
u∈v⊑w→u⊑w : ∀{B A C} → C ∈ B → B ⊑ A → C ⊑ A
u∈v⊑w→u⊑w {⊥} C∈B B⊑A rewrite C∈B = B⊑A
u∈v⊑w→u⊑w {const k} C∈B B⊑A rewrite C∈B = B⊑A
u∈v⊑w→u⊑w {B₁ ↦ B₂} C∈B B⊑A rewrite C∈B = B⊑A
u∈v⊑w→u⊑w {B₁ ⊔ B₂}{A}{C} (inj₁ C∈B₁) B⊑A = u∈v⊑w→u⊑w {B₁}{A}{C} C∈B₁ (⊔⊑R B⊑A)
u∈v⊑w→u⊑w {B₁ ⊔ B₂}{A}{C} (inj₂ C∈B₂) B⊑A = u∈v⊑w→u⊑w {B₂}{A}{C} C∈B₂ (⊔⊑L B⊑A)
u⊆v⊑w→u⊑w : ∀{u v w} → u ⊆ v → v ⊑ w → u ⊑ w
u⊆v⊑w→u⊑w {⊥} {v} {w} u⊆v v⊑w = ⊑-⊥
u⊆v⊑w→u⊑w {const k} {v} {w} u⊆v v⊑w
with u⊆v refl
... | k∈v = u∈v⊑w→u⊑w k∈v v⊑w
u⊆v⊑w→u⊑w {u₁ ↦ u₂} {v} {w} u⊆v v⊑w
with u⊆v refl
... | u₁↦u₂∈v = u∈v⊑w→u⊑w u₁↦u₂∈v v⊑w
u⊆v⊑w→u⊑w {u₁ ⊔ u₂} {v} {w} u⊆v v⊑w =
⊑-conj-L (u⊆v⊑w→u⊑w u₁⊆v v⊑w) (u⊆v⊑w→u⊑w u₂⊆v v⊑w)
where
u₁⊆v : u₁ ⊆ v
u₁⊆v {u′} u′∈u₁ = u⊆v (inj₁ u′∈u₁)
u₂⊆v : u₂ ⊆ v
u₂⊆v {u′} u′∈u₂ = u⊆v (inj₂ u′∈u₂)
depth : (v : Value) → ℕ
depth ⊥ = zero
depth (const k) = zero
depth (v ↦ w) = suc (max (depth v) (depth w))
depth (v₁ ⊔ v₂) = max (depth v₁) (depth v₂)
size : (v : Value) → ℕ
size ⊥ = zero
size (const k) = zero
size (v ↦ w) = suc (size v + size w)
size (v₁ ⊔ v₂) = suc (size v₁ + size v₂)
∈→depth≤ : ∀{v u : Value} → u ∈ v → depth u ≤ depth v
∈→depth≤ {⊥} {u} u∈v rewrite u∈v = _≤_.z≤n
∈→depth≤ {const x} {u} u∈v rewrite u∈v = _≤_.z≤n
∈→depth≤ {v ↦ w} {u} u∈v rewrite u∈v = ≤-refl
∈→depth≤ {v₁ ⊔ v₂} {u} (inj₁ x) =
≤-trans (∈→depth≤ {v₁} {u} x) (m≤m⊔n (depth v₁) (depth v₂))
∈→depth≤ {v₁ ⊔ v₂} {u} (inj₂ y) =
≤-trans (∈→depth≤ {v₂} {u} y) (n≤m⊔n (depth v₁) (depth v₂))
max-lub : ∀{x y z : ℕ} → x ≤ z → y ≤ z → max x y ≤ z
max-lub {.0} {y} {z} _≤_.z≤n y≤z = y≤z
max-lub {suc x} {.0} {suc z} (_≤_.s≤s x≤z) _≤_.z≤n = _≤_.s≤s x≤z
max-lub {suc x} {suc y} {suc z} (_≤_.s≤s x≤z) (_≤_.s≤s y≤z) =
let max-xy≤z = max-lub {x}{y}{z} x≤z y≤z in
_≤_.s≤s max-xy≤z
⊔⊆-inv : ∀{u v w : Value}
→ (u ⊔ v) ⊆ w
---------------
→ u ⊆ w × v ⊆ w
⊔⊆-inv uvw = ⟨ (λ x → uvw (inj₁ x)) , (λ x → uvw (inj₂ x)) ⟩
⊆→depth≤ : ∀{u v : Value} → u ⊆ v → depth u ≤ depth v
⊆→depth≤ {⊥} {v} u⊆v = _≤_.z≤n
⊆→depth≤ {const x} {v} u⊆v = _≤_.z≤n
⊆→depth≤ {u₁ ↦ u₂} {v} u⊆v = ∈→depth≤ (u⊆v refl)
⊆→depth≤ {u₁ ⊔ u₂} {v} u⊆v
with ⊔⊆-inv u⊆v
... | ⟨ u₁⊆v , u₂⊆v ⟩ =
let u₁≤v = ⊆→depth≤ u₁⊆v in
let u₂≤v = ⊆→depth≤ u₂⊆v in
max-lub u₁≤v u₂≤v
dom-depth-≤ : ∀{u : Value} → depth (dom u) ≤ depth u
dom-depth-≤ {⊥} = _≤_.z≤n
dom-depth-≤ {const k} = _≤_.z≤n
dom-depth-≤ {v ↦ w} = ≤-step (m≤m⊔n (depth v) (depth w))
dom-depth-≤ {u ⊔ v} =
let ih1 = dom-depth-≤ {u} in
let ih2 = dom-depth-≤ {v} in
⊔-mono-≤ ih1 ih2
cod-depth-≤ : ∀{u : Value} → depth (cod u) ≤ depth u
cod-depth-≤ {⊥} = _≤_.z≤n
cod-depth-≤ {const k} = _≤_.z≤n
cod-depth-≤ {v ↦ w} = ≤-step (n≤m⊔n (depth v) (depth w))
cod-depth-≤ {u ⊔ v} =
let ih1 = cod-depth-≤ {u} in
let ih2 = cod-depth-≤ {v} in
⊔-mono-≤ ih1 ih2
≤′-trans : ∀{x y z} → x ≤′ y → y ≤′ z → x ≤′ z
≤′-trans x≤′y y≤′z = ≤⇒≤′ (≤-trans (≤′⇒≤ x≤′y) (≤′⇒≤ y≤′z))
data _<<_ : ℕ × ℕ → ℕ × ℕ → Set where
fst : ∀{x x' y y'} → x <′ x' → ⟨ x , y ⟩ << ⟨ x' , y' ⟩
snd : ∀{x x' y y'} → x ≤′ x' → y <′ y' → ⟨ x , y ⟩ << ⟨ x' , y' ⟩
<<-nat-wf : (P : ℕ → ℕ → Set) →
(∀ x y → (∀ {x' y'} → ⟨ x' , y' ⟩ << ⟨ x , y ⟩ → P x' y') → P x y) →
∀ x y → P x y
<<-nat-wf P ih x y = ih x y (help x y)
where help : (x y : ℕ) → ∀{ x' y'} → ⟨ x' , y' ⟩ << ⟨ x , y ⟩ → P x' y'
help .(suc x') y {x'}{y'} (fst ≤′-refl) =
ih x' y' (help x' y')
help .(suc x) y {x'}{y'} (fst (≤′-step {x} q)) =
help x y {x'}{y'} (fst q)
help x .(suc y) {x'}{y} (snd x'≤x ≤′-refl) =
let h : ∀ {x₁} {x₂} → (⟨ x₁ , x₂ ⟩ << ⟨ x , y ⟩) → P x₁ x₂
h = help x y in
ih x' y G
where
G : ∀ {x'' y'} → ⟨ x'' , y' ⟩ << ⟨ x' , y ⟩ → P x'' y'
G {x''} {y'} (fst x''<x') =
help x y (fst {y = y'}{y' = y} (≤′-trans x''<x' x'≤x))
G {x''} {y'} (snd x''≤x' y'<y) =
help x y {x''}{y'} (snd (≤′-trans x''≤x' x'≤x) y'<y)
help x .(suc y) {x'}{y'} (snd x′≤x (≤′-step {y} q)) =
help x y {x'}{y'} (snd x′≤x q)
⊑-trans-P : ℕ → ℕ → Set
⊑-trans-P d s = ∀{u v w} → d ≡ depth u + depth w → s ≡ size u + size v
→ u ⊑ v → v ⊑ w → u ⊑ w
⊑-trans-rec : ∀ d s → ⊑-trans-P d s
⊑-trans-rec = <<-nat-wf ⊑-trans-P helper
where
helper : ∀ x y
→ (∀ {x' y'} → ⟨ x' , y' ⟩ << ⟨ x , y ⟩ → ⊑-trans-P x' y')
→ ⊑-trans-P x y
helper d s IH {.⊥} {v} {w} d≡ s≡ ⊑-⊥ v⊑w = ⊑-⊥
helper d s IH {.(const _)} {.(const _)} {w} d≡ s≡ ⊑-const v⊑w = v⊑w
helper d s IH {u₁ ⊔ u₂} {v} {w} d≡ s≡ (⊑-conj-L u₁⊑v u₂⊑v) v⊑w
rewrite d≡ | s≡ =
let u₁⊑w = IH M1 {u₁}{v}{w} refl refl u₁⊑v v⊑w in
let u₂⊑w = IH M2 {u₂}{v}{w} refl refl u₂⊑v v⊑w in
⊑-conj-L u₁⊑w u₂⊑w
where
M1a = begin
depth u₁ + depth w
≤⟨ +-mono-≤ (m≤m⊔n (depth u₁) (depth u₂)) ≤-refl ⟩
max (depth u₁) (depth u₂) + depth w
∎
M1b = begin
suc (size u₁ + size v)
≤⟨ s≤s (+-mono-≤ ≤-refl (n≤m+n (size u₂) (size v))) ⟩
suc (size u₁ + (size u₂ + size v))
≤⟨ s≤s (≤-reflexive (sym (+-assoc (size u₁) (size u₂) (size v)))) ⟩
suc (size u₁ + size u₂ + size v)
∎
M1 : ⟨ depth u₁ + depth w , size u₁ + size v ⟩ <<
⟨ max (depth u₁) (depth u₂) + depth w ,
suc (size u₁ + size u₂ + size v) ⟩
M1 = snd (≤⇒≤′ M1a) (≤⇒≤′ M1b)
M2a = begin
depth u₂ + depth w
≤⟨ +-mono-≤ (n≤m⊔n (depth u₁) (depth u₂)) ≤-refl ⟩
max (depth u₁) (depth u₂) + depth w
∎
M2b = begin
suc (size u₂ + size v)
≤⟨ s≤s (+-mono-≤ (n≤m+n (size u₁) (size u₂)) ≤-refl) ⟩
suc ((size u₁ + size u₂) + size v)
∎
M2 : ⟨ depth u₂ + depth w , size u₂ + size v ⟩ <<
⟨ max (depth u₁) (depth u₂) + depth w ,
suc (size u₁ + size u₂ + size v) ⟩
M2 = snd (≤⇒≤′ M2a) (≤⇒≤′ M2b)
helper d s IH {u} {v₁ ⊔ v₂} {w} d≡ s≡ (⊑-conj-R1 u⊑v₁) v₁⊔v₂⊑w
rewrite d≡ | s≡ =
let v₁⊑w = ⊔⊑R v₁⊔v₂⊑w in
IH M {u}{v₁}{w} refl refl u⊑v₁ v₁⊑w
where
Ma = begin
suc (size u + size v₁)
≤⟨ ≤-reflexive (sym (+-suc (size u) (size v₁))) ⟩
size u + suc (size v₁)
≤⟨ +-mono-≤ ≤-refl (s≤s (m≤m+n (size v₁) (size v₂))) ⟩
size u + suc (size v₁ + size v₂)
∎
M : ⟨ depth u + depth w , size u + size v₁ ⟩ <<
⟨ depth u + depth w , size u + suc (size v₁ + size v₂) ⟩
M = snd (≤⇒≤′ ≤-refl) (≤⇒≤′ Ma)
helper d s IH {u} {v₁ ⊔ v₂} {w} d≡ s≡ (⊑-conj-R2 u⊑v₂) v₁⊔v₂⊑w
rewrite d≡ | s≡ =
let v₂⊑w = ⊔⊑L v₁⊔v₂⊑w in
IH M {u}{v₂}{w} refl refl u⊑v₂ v₂⊑w
where
Ma = begin
suc (size u + size v₂)
≤⟨ ≤-reflexive (sym (+-suc (size u) (size v₂))) ⟩
size u + suc (size v₂)
≤⟨ +-mono-≤ ≤-refl (s≤s (n≤m+n (size v₁) (size v₂))) ⟩
size u + suc (size v₁ + size v₂)
∎
M : ⟨ depth u + depth w , size u + size v₂ ⟩ <<
⟨ depth u + depth w , size u + suc (size v₁ + size v₂) ⟩
M = snd (≤⇒≤′ ≤-refl) (≤⇒≤′ Ma)
helper d s IH {u₁ ↦ u₂}{v}{w}d≡ s≡ (⊑-fun{u′ = v′}v′⊆v afv′ dv′⊑u₁ u₂⊑cv′) v⊑w
rewrite d≡ | s≡
with sub-inv-trans afv′ v′⊆v
(λ {v₁}{v₂} v₁↦v₂∈v′ → ⊑-fun-inv {v′} {w} (u⊆v⊑w→u⊑w v′⊆v v⊑w)
v₁↦v₂∈v′)
... | ⟨ w′ , ⟨ afw′ , ⟨ w′⊆w , ⟨ dw′⊑dv′ , cv′⊑cw′ ⟩ ⟩ ⟩ ⟩ =
let dw′⊑u₁ = IH M1 {dom w′}{dom v′}{u₁} refl refl dw′⊑dv′ dv′⊑u₁ in
let u₂⊑cw′ = IH M2 {u₂}{cod v′}{cod w′} refl refl u₂⊑cv′ cv′⊑cw′ in
⊑-fun{u′ = w′} w′⊆w afw′ dw′⊑u₁ u₂⊑cw′
where
dw′≤w : depth (dom w′) ≤ depth w
dw′≤w = ≤-trans (dom-depth-≤{w′}) (⊆→depth≤ w′⊆w)
cw′≤w : depth (cod w′) ≤ depth w
cw′≤w = ≤-trans (cod-depth-≤{w′}) (⊆→depth≤ w′⊆w)
M1a = begin
suc (depth (dom w′) + depth u₁)
≤⟨ s≤s (≤-reflexive (+-comm (depth (dom w′)) (depth u₁))) ⟩
suc (depth u₁ + depth (dom w′))
≤⟨ s≤s (+-mono-≤ (m≤m⊔n (depth u₁) (depth u₂)) dw′≤w) ⟩
suc (max (depth u₁) (depth u₂) + depth w)
∎
M1 : ⟨ depth (dom w′) + depth u₁ , size (dom w′) + size (dom v′) ⟩
<< ⟨ suc (max (depth u₁) (depth u₂) + depth w) ,
suc (size u₁ + size u₂ + size v) ⟩
M1 = fst (≤⇒≤′ M1a)
M2a = begin
suc (depth u₂ + depth (cod w′))
≤⟨ s≤s (+-mono-≤ (n≤m⊔n (depth u₁) (depth u₂)) cw′≤w) ⟩
suc (max (depth u₁) (depth u₂) + depth w)
∎
M2 : ⟨ depth u₂ + depth (cod w′) ,
size u₂ + size (cod v′) ⟩
<< ⟨ suc (max (depth u₁) (depth u₂) + depth w) ,
suc (size u₁ + size u₂ + size v) ⟩
M2 = fst (≤⇒≤′ M2a)
⊑-trans : ∀{u v w} → u ⊑ v → v ⊑ w → u ⊑ w
⊑-trans {u} {v} {w} u⊑v v⊑w =
⊑-trans-rec (depth u + depth w) (size u + size v) refl refl u⊑v v⊑w
|
{
"alphanum_fraction": 0.4287053781,
"avg_line_length": 34.0113895216,
"ext": "agda",
"hexsha": "1c63aa1489bf037972fb4ad77ef350639fce94f1",
"lang": "Agda",
"max_forks_count": 304,
"max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z",
"max_forks_repo_head_hexsha": "5468837f55cbea38d5c5a163e1ea5d48edb92bcc",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "andorp/plfa.github.io",
"max_forks_repo_path": "extra/extra/Value.agda",
"max_issues_count": 323,
"max_issues_repo_head_hexsha": "5468837f55cbea38d5c5a163e1ea5d48edb92bcc",
"max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z",
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "andorp/plfa.github.io",
"max_issues_repo_path": "extra/extra/Value.agda",
"max_line_length": 92,
"max_stars_count": 1003,
"max_stars_repo_head_hexsha": "5468837f55cbea38d5c5a163e1ea5d48edb92bcc",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "andorp/plfa.github.io",
"max_stars_repo_path": "extra/extra/Value.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z",
"num_tokens": 8319,
"size": 14931
}
|
-- Andreas, 2012-09-07
-- {-# OPTIONS -v tc.polarity:10 -v tc.conv.irr:20 -v tc.conv.elim:25 -v tc.conv.term:10 #-}
module Issue691 where
open import Common.Equality
data Bool : Set where
true false : Bool
assert : (A : Set) → A → Bool → Bool
assert _ _ true = true
assert _ _ false = false
g : Bool -> Bool -> Bool
g x true = true
g x false = true
unsolved : Bool -> Bool
unsolved y =
let X : Bool
X = _
in assert (g X y ≡ g true y) refl X
-- X should be left unsolved
istrue : (unsolved false) ≡ true
istrue = refl
|
{
"alphanum_fraction": 0.6351851852,
"avg_line_length": 18.6206896552,
"ext": "agda",
"hexsha": "57c8357726617997acf2be34407a927e1525e58d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/Issue691.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/Issue691.agda",
"max_line_length": 92,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "np/agda-git-experiment",
"max_stars_repo_path": "test/fail/Issue691.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 182,
"size": 540
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Container combinators
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Container.Combinator where
open import Level using (Level; _⊔_; Lift)
open import Data.Empty using (⊥)
open import Data.Product as P using (_,_; proj₁; proj₂; ∃)
open import Data.Sum.Base as S using ([_,_]′)
open import Data.Unit.Base using (⊤)
import Function as F
open import Data.Container.Core
open import Data.Container.Relation.Unary.Any
------------------------------------------------------------------------
-- Combinators
module _ {s p : Level} where
-- Identity.
id : Container s p
id .Shape = Lift s ⊤
id .Position = F.const (Lift p ⊤)
-- Constant.
const : Set s → Container s p
const X .Shape = X
const X .Position = F.const (Lift p ⊥)
-- Composition.
infixr 9 _∘_
_∘_ : ∀ {s₁ s₂ p₁ p₂} → Container s₁ p₁ → Container s₂ p₂ →
Container (s₁ ⊔ s₂ ⊔ p₁) (p₁ ⊔ p₂)
(C₁ ∘ C₂) .Shape = ⟦ C₁ ⟧ (Shape C₂)
(C₁ ∘ C₂) .Position = ◇ C₁ (Position C₂)
-- Product. (Note that, up to isomorphism, this is a special case of
-- indexed product.)
infixr 2 _×_
_×_ : ∀ {s₁ s₂ p₁ p₂} → Container s₁ p₁ → Container s₂ p₂ →
Container (s₁ ⊔ s₂) (p₁ ⊔ p₂)
(C₁ × C₂) .Shape = Shape C₁ P.× Shape C₂
(C₁ × C₂) .Position = P.uncurry λ s₁ s₂ → (Position C₁ s₁) S.⊎ (Position C₂ s₂)
-- Indexed product.
Π : ∀ {i s p} (I : Set i) → (I → Container s p) → Container (i ⊔ s) (i ⊔ p)
Π I C .Shape = ∀ i → Shape (C i)
Π I C .Position = λ s → ∃ λ i → Position (C i) (s i)
-- Constant exponentiation. (Note that this is a special case of
-- indexed product.)
infix 0 const[_]⟶_
const[_]⟶_ : ∀ {i s p} → Set i → Container s p → Container (i ⊔ s) (i ⊔ p)
const[ X ]⟶ C = Π X (F.const C)
-- Sum. (Note that, up to isomorphism, this is a special case of
-- indexed sum.)
infixr 1 _⊎_
_⊎_ : ∀ {s₁ s₂ p} → Container s₁ p → Container s₂ p → Container (s₁ ⊔ s₂) p
(C₁ ⊎ C₂) .Shape = (Shape C₁ S.⊎ Shape C₂)
(C₁ ⊎ C₂) .Position = [ Position C₁ , Position C₂ ]′
-- Indexed sum.
Σ : ∀ {i s p} (I : Set i) → (I → Container s p) → Container (i ⊔ s) p
Σ I C .Shape = ∃ λ i → Shape (C i)
Σ I C .Position = λ s → Position (C (proj₁ s)) (proj₂ s)
|
{
"alphanum_fraction": 0.5505376344,
"avg_line_length": 27.3529411765,
"ext": "agda",
"hexsha": "2d8f8d4034f314af9d3f2e70096e88af96e6f726",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Container/Combinator.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Container/Combinator.agda",
"max_line_length": 79,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Container/Combinator.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 805,
"size": 2325
}
|
{-# OPTIONS --safe --experimental-lossy-unification #-}
{-
This file contains:
1. The iso π₃S²≅ℤ
2. A proof that π₃S² is generated by the Hopf map
-}
module Cubical.Homotopy.Group.Pi3S2 where
open import Cubical.Homotopy.Loopspace
open import Cubical.Homotopy.Group.LES
open import Cubical.Homotopy.Group.PinSn
open import Cubical.Homotopy.Group.Base
open import Cubical.Homotopy.HopfInvariant.HopfMap
open import Cubical.Homotopy.HopfInvariant.Base
open import Cubical.Homotopy.HopfInvariant.Homomorphism
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Isomorphism
open Iso
open import Cubical.Foundations.Equiv
open import Cubical.HITs.SetTruncation renaming (elim to sElim)
open import Cubical.HITs.Sn
open import Cubical.HITs.Susp
open import Cubical.HITs.S1
open import Cubical.Data.Sigma
open import Cubical.Data.Nat
open import Cubical.Data.Int
open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.ZAction
open import Cubical.Algebra.Group.Exact
open import Cubical.Algebra.Group.Morphisms
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.Algebra.Group.Instances.Unit
open import Cubical.Algebra.Group.Instances.Int
TotalHopf→∙S² : (Σ (S₊ 2) S¹Hopf , north , base) →∙ S₊∙ 2
fst TotalHopf→∙S² = fst
snd TotalHopf→∙S² = refl
IsoTotalSpaceJoin' : Iso (Σ (S₊ 2) S¹Hopf) (S₊ 3)
IsoTotalSpaceJoin' = compIso hopfS¹.IsoTotalSpaceJoin (IsoSphereJoin 1 1)
IsoFiberTotalHopfS¹ : Iso (fiber (fst TotalHopf→∙S²) north) S¹
fun IsoFiberTotalHopfS¹ ((x , y) , z) = subst S¹Hopf z y
inv IsoFiberTotalHopfS¹ x = (north , x) , refl
rightInv IsoFiberTotalHopfS¹ x = refl
leftInv IsoFiberTotalHopfS¹ ((x , y) , z) =
ΣPathP
((ΣPathP
(sym z , (λ i → transp (λ j → S¹Hopf (z (~ i ∧ j))) i y)))
, (λ j i → z (i ∨ ~ j)))
IsoFiberTotalHopfS¹∙≡ :
(fiber (fst TotalHopf→∙S²) north , (north , base) , refl) ≡ S₊∙ 1
IsoFiberTotalHopfS¹∙≡ = ua∙ (isoToEquiv IsoFiberTotalHopfS¹) refl
private
transportGroupEquiv : ∀ {ℓ ℓ'} {A : Pointed ℓ} {B : Pointed ℓ'}
(n : ℕ) (f : A →∙ B)
→ isEquiv (fst (πLES.A→B f n))
→ isEquiv (fst (π'∘∙Hom n f))
transportGroupEquiv n f iseq =
transport (λ i → isEquiv (fst (π∘∙A→B-PathP n f i))) iseq
π₃S²≅π₃TotalHopf : GroupEquiv (πGr 2 (Σ (S₊ 2) S¹Hopf , north , base))
(πGr 2 (S₊∙ 2))
fst (fst π₃S²≅π₃TotalHopf) = fst (πLES.A→B TotalHopf→∙S² 2)
snd (fst π₃S²≅π₃TotalHopf) =
SES→isEquiv
(isContr→≡UnitGroup
(subst isContr (cong (π 3) (sym IsoFiberTotalHopfS¹∙≡))
(∣ refl ∣₂ , (sElim (λ _ → isSetPathImplicit)
(λ p → cong ∣_∣₂
(isOfHLevelSuc 3 isGroupoidS¹ _ _ _ _ _ _ refl p))))))
(isContr→≡UnitGroup
(subst isContr (cong (π 2) (sym IsoFiberTotalHopfS¹∙≡))
(∣ refl ∣₂ , (sElim (λ _ → isSetPathImplicit) (λ p
→ cong ∣_∣₂ (isGroupoidS¹ _ _ _ _ refl p))))))
(πLES.fib→A TotalHopf→∙S² 2)
(πLES.A→B TotalHopf→∙S² 2)
(πLES.B→fib TotalHopf→∙S² 1)
(πLES.Ker-A→B⊂Im-fib→A TotalHopf→∙S² 2)
(πLES.Ker-B→fib⊂Im-A→B TotalHopf→∙S² 1)
snd π₃S²≅π₃TotalHopf = snd (πLES.A→B TotalHopf→∙S² 2)
π'₃S²≅π'₃TotalHopf : GroupEquiv (π'Gr 2 (Σ (S₊ 2) S¹Hopf , north , base))
(π'Gr 2 (S₊∙ 2))
fst (fst π'₃S²≅π'₃TotalHopf) = fst (π'∘∙Hom 2 TotalHopf→∙S²)
snd (fst π'₃S²≅π'₃TotalHopf) =
transportGroupEquiv 2 TotalHopf→∙S² (π₃S²≅π₃TotalHopf .fst .snd)
snd π'₃S²≅π'₃TotalHopf = snd (π'∘∙Hom 2 TotalHopf→∙S²)
πS³≅πTotalHopf : (n : ℕ)
→ GroupEquiv (π'Gr n (S₊∙ 3)) (π'Gr n (Σ (S₊ 2) S¹Hopf , north , base))
πS³≅πTotalHopf n =
π'Iso n
((isoToEquiv
(invIso
(compIso
(hopfS¹.IsoTotalSpaceJoin)
(IsoSphereJoin 1 1))))
, refl)
π₃S²≅ℤ : GroupEquiv (π'Gr 2 (S₊∙ 2)) ℤGroup
π₃S²≅ℤ =
compGroupEquiv
(invGroupEquiv
(compGroupEquiv (πS³≅πTotalHopf 2) π'₃S²≅π'₃TotalHopf))
(GroupIso→GroupEquiv (πₙ'Sⁿ≅ℤ 2))
-- We prove that the generator is the Hopf map
π₃TotalHopf-gen' : π' 3 (Σ (Susp S¹) S¹Hopf , north , base)
π₃TotalHopf-gen' =
∣ inv (compIso (hopfS¹.IsoTotalSpaceJoin) (IsoSphereJoin 1 1)) , refl ∣₂
πS³≅πTotalHopf-gen :
fst (fst (πS³≅πTotalHopf 2)) ∣ idfun∙ _ ∣₂ ≡ π₃TotalHopf-gen'
πS³≅πTotalHopf-gen =
cong ∣_∣₂
(∘∙-idʳ (inv (compIso (hopfS¹.IsoTotalSpaceJoin)
(IsoSphereJoin 1 1)) , refl))
πTotalHopf-gen :
gen₁-by (π'Gr 2 (Σ (S₊ 2) S¹Hopf , north , base))
∣ inv (compIso (hopfS¹.IsoTotalSpaceJoin) (IsoSphereJoin 1 1)) , refl ∣₂
πTotalHopf-gen =
subst (gen₁-by (π'Gr 2 (Σ (S₊ 2) S¹Hopf , north , base)))
πS³≅πTotalHopf-gen
(Iso-pres-gen₁ (π'Gr 2 (S₊∙ 3))
(π'Gr 2 (Σ (S₊ 2) S¹Hopf , north , base))
∣ idfun∙ _ ∣₂
(πₙ'Sⁿ-gen-by-idfun 2)
(GroupEquiv→GroupIso (πS³≅πTotalHopf 2)))
πTotalHopf≅πS²-gen :
fst (fst π'₃S²≅π'₃TotalHopf)
π₃TotalHopf-gen'
≡ ∣ HopfMap' , refl ∣₂
πTotalHopf≅πS²-gen =
cong ∣_∣₂ (ΣPathP (refl , (sym (rUnit refl))))
π₂S³-gen-by-HopfMap' : gen₁-by (π'Gr 2 (S₊∙ 2)) ∣ HopfMap' , refl ∣₂
π₂S³-gen-by-HopfMap' =
subst (gen₁-by (π'Gr 2 (S₊∙ 2))) πTotalHopf≅πS²-gen
(Iso-pres-gen₁ (π'Gr 2 (Σ (S₊ 2) S¹Hopf , north , base)) (π'Gr 2 (S₊∙ 2))
∣ inv (compIso (hopfS¹.IsoTotalSpaceJoin) (IsoSphereJoin 1 1)) , refl ∣₂
πTotalHopf-gen
(GroupEquiv→GroupIso π'₃S²≅π'₃TotalHopf))
π₂S³-gen-by-HopfMap : gen₁-by (π'Gr 2 (S₊∙ 2)) ∣ HopfMap ∣₂
π₂S³-gen-by-HopfMap =
subst (gen₁-by (π'Gr 2 (S₊∙ 2)))
(cong ∣_∣₂ (sym hopfMap≡HopfMap'))
π₂S³-gen-by-HopfMap'
-- As a consequence, we also get that the Hopf invariant determines
-- an iso π₃S²≅ℤ
hopfInvariantEquiv : GroupEquiv (π'Gr 2 (S₊∙ 2)) ℤGroup
fst (fst hopfInvariantEquiv) = HopfInvariant-π' 0
snd (fst hopfInvariantEquiv) =
GroupEquivℤ-isEquiv (invGroupEquiv π₃S²≅ℤ) ∣ HopfMap ∣₂
π₂S³-gen-by-HopfMap (GroupHom-HopfInvariant-π' 0)
(abs→⊎ _ _ HopfInvariant-HopfMap)
snd hopfInvariantEquiv = snd (GroupHom-HopfInvariant-π' 0)
|
{
"alphanum_fraction": 0.6522657138,
"avg_line_length": 35.7965116279,
"ext": "agda",
"hexsha": "57f3cef1a7ecdf58f2bc9b2e746589b8bf8f5f06",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/Homotopy/Group/Pi3S2.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/Homotopy/Group/Pi3S2.agda",
"max_line_length": 78,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/Homotopy/Group/Pi3S2.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z",
"num_tokens": 2683,
"size": 6157
}
|
-- Andreas, 2014-01-24, Issue 1411
-- First split might not succeed in the unifier,
-- so try later splits also.
-- {-# OPTIONS -v tc.lhs:10 #-}
open import Common.Prelude
open import Common.Equality
data Fin : Nat → Set where
fzero : (n : Nat) → Fin (suc n)
fsuc : (n : Nat) → (i : Fin n) → Fin (suc n)
data _≅_ {A : Set} (a : A) : {B : Set} (b : B) → Set where
refl : a ≅ a
works : ∀ n m (i : Fin n) (j : Fin m) → n ≡ m → fsuc n i ≅ fsuc m j → i ≅ j
works n .n i .i refl refl = refl
fails : ∀ n m (i : Fin n) (j : Fin m) → fsuc n i ≅ fsuc m j → n ≡ m → i ≅ j
fails n .n i .i refl refl = refl
-- Refuse to solve heterogeneous constraint i : Fin n =?= j : Fin m
-- when checking that the pattern refl has type fsuc n i ≅ fsuc m j
-- Should work now.
|
{
"alphanum_fraction": 0.5816993464,
"avg_line_length": 28.3333333333,
"ext": "agda",
"hexsha": "d09d3232bc18b670ae836d934afdd717a2a86644",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/Issue1411-2.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue1411-2.agda",
"max_line_length": 75,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue1411-2.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 289,
"size": 765
}
|
{-# OPTIONS --without-K #-}
module EnumEquiv where
open import Data.Empty using (⊥; ⊥-elim)
open import Data.Nat using (ℕ; _+_)
open import Data.Fin using (Fin; inject+; raise)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Data.Product using (_,_; proj₁; proj₂)
open import Function using (_∘_)
open import Relation.Binary.PropositionalEquality
using (_≡_; refl; cong; module ≡-Reasoning)
open import Equiv using (_≃_; trans≃; _⊎≃_; iseq; module isequiv)
open import FinEquiv using (Fin0-⊥; module Plus)
open Plus using (+≃⊎; ⊎≃+)
------------------------------------------------------------------------------
-- An equivalence between a set 'A' and a finite set 'Fin n' is an
-- enumeration of A.
Enum : ∀ {ℓ} → (A : Set ℓ) → (n : ℕ) → Set ℓ
Enum A n = A ≃ Fin n
-- We only need some additive equivalences...
0E : Enum ⊥ 0
0E = ⊥-elim , iseq Fin0-⊥ (λ { () }) Fin0-⊥ (λ { () })
_⊕e_ : {A : Set} {B : Set} {n m : ℕ} →
Enum A n → Enum B m → Enum (A ⊎ B) (n + m)
eA ⊕e eB = trans≃ (eA ⊎≃ eB) ⊎≃+
-- shorthand to select the element indexed by i in the enumeration
select : {A B : Set} (eq : A ≃ B) → (B → A)
select (_ , iseq g _ _ _) = g
-- The enumeration of (A ⊎ B) is an enumeration of A followed by an
-- enumeration of B; in other words if we have an equivalence between
-- (A ⊎ B) and Fin (m + n) and we are given an index i < m then this
-- index selects an element of A.
-- evaluating an ⊕e on the left component
eval-left : {A B : Set} {m n : ℕ} {eA : Enum A m} {eB : Enum B n} (i : Fin m) →
select (eA ⊕e eB) (inject+ n i) ≡ inj₁ (select eA i)
eval-left {m = m} {n} {eA} {eB} i =
let (fwd , iseq bwd _ _ bwd∘fwd~id) = ⊎≃+ {m} {n} in
begin (
select (eA ⊕e eB) (inject+ n i)
≡⟨ refl ⟩ -- β reduce ⊕e, reverse-β Plus.fwd
select (trans≃ (eA ⊎≃ eB) ⊎≃+) (fwd (inj₁ i))
≡⟨ refl ⟩ -- expand qinv.g and trans≃
select (eA ⊎≃ eB) (select ⊎≃+ (fwd (inj₁ i)))
≡⟨ refl ⟩ -- expand rhs
select (eA ⊎≃ eB) ((bwd ∘ fwd) (inj₁ i))
≡⟨ cong (select (eA ⊎≃ eB)) (bwd∘fwd~id (inj₁ i)) ⟩
select (eA ⊎≃ eB) (inj₁ i)
≡⟨ refl ⟩ -- by definition of path⊎
inj₁ (select eA i) ∎)
where open ≡-Reasoning
eval-right : {A B : Set} {m n : ℕ} {eA : Enum A m} {eB : Enum B n} →
(i : Fin n) → select (eA ⊕e eB) (raise m i) ≡ inj₂ (select eB i)
eval-right {eA = eA} {eB} i =
cong (select (eA ⊎≃ eB)) (isequiv.β (proj₂ ⊎≃+) (inj₂ i))
------------------------------------------------------------------------------
-- We can also do the same for multiplication but it's not needed
-- _⊛e_ : {A B : Set} {n m : ℕ} → Enum A n → Enum B m → Enum (A × B) (n * m)
-- eA ⊛e eB = trans≃ (path× eA eB) Times.fwd-iso
--
-- etc.
------------------------------------------------------------------------------
|
{
"alphanum_fraction": 0.52629683,
"avg_line_length": 34.7,
"ext": "agda",
"hexsha": "8323d65618d1d2702fc86e5b370955d3fd4ee1df",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z",
"max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "JacquesCarette/pi-dual",
"max_forks_repo_path": "Univalence/EnumEquiv.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "JacquesCarette/pi-dual",
"max_issues_repo_path": "Univalence/EnumEquiv.agda",
"max_line_length": 79,
"max_stars_count": 14,
"max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "JacquesCarette/pi-dual",
"max_stars_repo_path": "Univalence/EnumEquiv.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z",
"num_tokens": 1067,
"size": 2776
}
|
------------------------------------------------------------------------
-- Progress of CBV reductions in Fω with interval kinds
------------------------------------------------------------------------
{-# OPTIONS --safe --without-K #-}
-- This module contains a variant of the "progress" theorem for Fω
-- with interval kinds. Progress says roughly that well-typed terms
-- do not get stuck. I.e. a well-typed term is either a value or it
-- can take a call-by-value (CBV) reduction step. Together with the
-- subject reduction (aka "preservation") theorem from
-- FOmegaInt.Typing.Preservation, progress ensures type safety. For
-- details, see e.g.
--
-- * B. C. Pierce, TAPL (2002), pp. 95.
--
-- * A. Wright and M. Felleisen, "A Syntactic Approach to Type
-- Soundness" (1994).
module FOmegaInt.Typing.Progress where
open import Data.Product using (_,_; ∃)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
open import Relation.Nullary.Negation using (contradiction)
open import FOmegaInt.Syntax
open import FOmegaInt.Typing
open import FOmegaInt.Typing.Inversion
open import FOmegaInt.Reduction.Cbv
open Syntax
open TermCtx
open Substitution using (_[_])
open Typing
-- A canonical forms lemma for universal types: closed values of
-- universal type are type abstractions.
Π-can : ∀ {f k a} → Val f → [] ⊢Tm f ∈ Π k a → ∃ λ k′ →
∃ λ a′ → f ≡ Λ k′ a′
Π-can (Λ k a) (∈-∀-i k-kd a∈b) = k , a , refl
Π-can (Λ k a) (∈-⇑ Λka∈b b<:Πkc) = k , a , refl
Π-can (ƛ a b) (∈-⇑ ƛab∈c c<:Πkd) with Tm∈-gen ƛab∈c
Π-can (ƛ a b) (∈-⇑ ƛab∈c c<:Πkd) | ∈-→-i a∈* b∈e a⇒e<:c =
contradiction (<:-trans a⇒e<:c c<:Πkd) ⇒-≮:-Π
-- A canonical forms lemma for arrow types: closed values of arrow
-- type are term abstractions.
⇒-can : ∀ {f a b} → Val f → [] ⊢Tm f ∈ a ⇒ b → ∃ λ a′ → ∃ λ b′ → f ≡ ƛ a′ b′
⇒-can (Λ k a) (∈-⇑ Λka∈b b<:c⇒d) with Tm∈-gen Λka∈b
⇒-can (Λ k a) (∈-⇑ Λka∈b b<:c⇒d) | ∈-∀-i k-kd a∈e Πke<:b =
contradiction (<:-trans Πke<:b b<:c⇒d) Π-≮:-⇒
⇒-can (ƛ a b) (∈-→-i a∈* b∈c c∈*) = a , b , refl
⇒-can (ƛ a b) (∈-⇑ ƛab∈c c<:d⇒e) = a , b , refl
-- Progress: well-typed terms do not get stuck (under CBV reduction).
prog : ∀ {a b} → [] ⊢Tm a ∈ b → Val a ⊎ (∃ λ a′ → a →v a′)
prog (∈-var () _ _)
prog (∈-∀-i k-kd b∈c) = inj₁ (Λ _ _)
prog (∈-→-i a∈* b∈c c∈*) = inj₁ (ƛ _ _)
prog (∈-∀-e a∈Πkc b∈k) with prog a∈Πkc
prog (∈-∀-e a∈Πkc b∈k) | inj₁ u with Π-can u a∈Πkc
...| k′ , a′ , refl = inj₂ (_ , cont-⊡ k′ a′ _)
prog (∈-∀-e a∈Πkc b∈k) | inj₂ (a′ , a→a′) = inj₂ (_ , a→a′ ⊡ _)
prog (∈-→-e a∈c⇒d b∈c) with prog a∈c⇒d
prog (∈-→-e a∈c⇒d b∈c) | inj₁ u with prog b∈c
prog (∈-→-e a∈c⇒d b∈c) | inj₁ u | inj₁ v with ⇒-can u a∈c⇒d
...| c′ , a′ , refl = inj₂ (_ , cont-· c′ a′ v)
prog (∈-→-e a∈c⇒d b∈c) | inj₁ u | inj₂ (b′ , b→b′) = inj₂ (_ , u ·₂ b→b′)
prog (∈-→-e a∈c⇒d b∈c) | inj₂ (a′ , a→a′) = inj₂ (_ , a→a′ ·₁ _)
prog (∈-⇑ a∈b b<:c) = prog a∈b
|
{
"alphanum_fraction": 0.556352459,
"avg_line_length": 40.6666666667,
"ext": "agda",
"hexsha": "16e2b6e6b4d6b8c35c6faae25dbc3e1f20b2d2ce",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-05-14T10:25:05.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-05-13T22:29:48.000Z",
"max_forks_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Blaisorblade/f-omega-int-agda",
"max_forks_repo_path": "src/FOmegaInt/Typing/Progress.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_issues_repo_issues_event_max_datetime": "2021-05-14T08:54:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-05-14T08:09:40.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Blaisorblade/f-omega-int-agda",
"max_issues_repo_path": "src/FOmegaInt/Typing/Progress.agda",
"max_line_length": 76,
"max_stars_count": 12,
"max_stars_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Blaisorblade/f-omega-int-agda",
"max_stars_repo_path": "src/FOmegaInt/Typing/Progress.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-27T05:53:06.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-06-13T16:05:35.000Z",
"num_tokens": 1338,
"size": 2928
}
|
-- Andreas & James, 2016-04-18 pre-AIM XXIII
-- order of clauses should not matter here!
{-# OPTIONS --exact-split #-}
open import Common.Prelude
record R A : Set where
field out : A
T : (x y : Bool) → Set
T true y = R Bool
T false true = R Nat
T false false = R String
test : (x y : Bool) → T x y
R.out (test true y) = y
R.out (test false true ) = 0
R.out (test false false) = "hallo"
|
{
"alphanum_fraction": 0.6218905473,
"avg_line_length": 20.1,
"ext": "agda",
"hexsha": "cb153e26b65c2e7fd3547e11ed9c32d3a2d32744",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pthariensflame/agda",
"max_forks_repo_path": "test/Succeed/Issue1834c.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "pthariensflame/agda",
"max_issues_repo_path": "test/Succeed/Issue1834c.agda",
"max_line_length": 44,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "222c4c64b2ccf8e0fc2498492731c15e8fef32d4",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pthariensflame/agda",
"max_stars_repo_path": "test/Succeed/Issue1834c.agda",
"max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z",
"num_tokens": 133,
"size": 402
}
|
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
module Haskell.Modules.RWS.RustAnyHow where
open import Haskell.Modules.RWS
open import Haskell.Prelude
private
variable
Ev Wr St : Set
A B C : Set
ok : A → RWS Ev Wr St (Either B A)
ok = pure ∘ Right
bail : B → RWS Ev Wr St (Either B A)
bail = pure ∘ Left
infixl 4 _∙?∙_
_∙?∙_ : RWS Ev Wr St (Either C A) → (A → RWS Ev Wr St (Either C B)) → RWS Ev Wr St (Either C B)
_∙?∙_ = RWS-ebind
infixl 4 _∙^∙_
_∙^∙_ : RWS Ev Wr St (Either B A) → (B → B) → RWS Ev Wr St (Either B A)
m ∙^∙ f = do
x ← m
either (bail ∘ f) ok x
|
{
"alphanum_fraction": 0.6467598475,
"avg_line_length": 23.1470588235,
"ext": "agda",
"hexsha": "94320bf020f9a4cdb77c9f71a279880a7eac2b19",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_forks_repo_path": "src/Haskell/Modules/RWS/RustAnyHow.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_issues_repo_path": "src/Haskell/Modules/RWS/RustAnyHow.agda",
"max_line_length": 111,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_stars_repo_path": "src/Haskell/Modules/RWS/RustAnyHow.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 295,
"size": 787
}
|
module STLC.Type where
open import Data.Fin using (Fin)
open import Data.Fin.Substitution
open import Data.Fin.Substitution.Lemmas using (TermLemmas)
open import Data.Nat using (ℕ; _+_)
open import Relation.Binary.Construct.Closure.ReflexiveTransitive
using (Star; ε; _◅_)
open import Data.Vec using (Vec; []; _∷_; lookup)
open import Relation.Binary.PropositionalEquality as Eq
using (refl; _≡_; sym; cong₂)
open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎)
-- --------------------------------------------------------------------
-- Types
-- --------------------------------------------------------------------
-- Recall that STLC types are defined as:
-- τ ::= α | τ -> τ
-- where α denotes a type variable.
infix 9 `_
infixr 7 _⇒_
data Type (n : ℕ) : Set where
`_ : Fin n -> Type n
_⇒_ : Type n -> Type n -> Type n
-- --------------------------------------------------------------------
module Substitution where
-- This sub module defines application of the subtitution
module Application₀ { T : ℕ -> Set } ( l : Lift T Type ) where
open Lift l hiding (var)
-- Application of substitution to type
infixl 8 _/_
_/_ : ∀ { m n : ℕ } -> Type m -> Sub T m n -> Type n
` x / ρ = lift (lookup ρ x)
(τ₁ ⇒ τ₂) / ρ = (τ₁ / ρ) ⇒ (τ₂ / ρ)
open Application (record { _/_ = _/_ }) using (_/✶_)
-- The application of sequences of substitutions is defined
-- by (_/✶_). We use this to prove some generic lemmas on
-- the lifting of sets
⇒-/✶-lift : ∀ k { m n τ₁ τ₂ } (ρs : Subs T m n) ->
(τ₁ ⇒ τ₂) /✶ ρs ↑✶ k ≡ (τ₁ /✶ ρs ↑✶ k) ⇒ (τ₂ /✶ ρs ↑✶ k)
⇒-/✶-lift k ε = refl
⇒-/✶-lift k (ρ ◅ ρs) = cong₂ _/_ (⇒-/✶-lift k ρs) refl
t = record
{var = `_
; app = Application₀._/_
}
open TermSubst t public hiding (var)
infix 8 _[/_]
-- Shorthand for single-variable type substitutions
_[/_] : ∀ { n } → Type (1 + n) → Type n → Type n
τ₁ [/ τ₂ ] = τ₁ / sub τ₂
module Lemmas where
module Lemmas₀ { T₁ T₂ } { l₁ : Lift T₁ Type} { l₂ : Lift T₂ Type } where
open Substitution
open Lifted l₁ using () renaming (_↑✶_ to _↑✶₁_; _/✶_ to _/✶₁_)
open Lifted l₂ using () renaming (_↑✶_ to _↑✶₂_; _/✶_ to _/✶₂_)
/✶-↑✶ : ∀ {m n} (ρs₁ : Subs T₁ m n) (ρs₂ : Subs T₂ m n)
-> (∀ k x -> ` x /✶₁ ρs₁ ↑✶₁ k ≡ ` x /✶₂ ρs₂ ↑✶₂ k)
-> ∀ k τ -> τ /✶₁ ρs₁ ↑✶₁ k ≡ τ /✶₂ ρs₂ ↑✶₂ k
/✶-↑✶ ρs₁ ρs₂ hyp k (` x) = hyp k x
/✶-↑✶ ρs₁ ρs₂ hyp k (τ₁ ⇒ τ₂) =
begin
(τ₁ ⇒ τ₂) /✶₁ ρs₁ ↑✶₁ k
≡⟨ Application₀.⇒-/✶-lift _ k ρs₁ ⟩
(τ₁ /✶₁ ρs₁ ↑✶₁ k) ⇒ (τ₂ /✶₁ ρs₁ ↑✶₁ k)
≡⟨ cong₂ (_⇒_) (/✶-↑✶ ρs₁ ρs₂ hyp k τ₁) (/✶-↑✶ ρs₁ ρs₂ hyp k τ₂) ⟩
(τ₁ /✶₂ ρs₂ ↑✶₂ k) ⇒ (τ₂ /✶₂ ρs₂ ↑✶₂ k)
≡⟨ sym (Application₀.⇒-/✶-lift _ k ρs₂) ⟩
(τ₁ ⇒ τ₂) /✶₂ ρs₂ ↑✶₂ k
∎
t : TermLemmas Type
t = record
{ termSubst = Substitution.t
; app-var = refl
; /✶-↑✶ = Lemmas₀./✶-↑✶
}
open TermLemmas t public hiding (var)
module Operators where
infixr 7 _⇒ⁿ_
-- n-ary function type
_⇒ⁿ_ : ∀ { n k } -> Vec (Type n) k -> Type n -> Type n
[] ⇒ⁿ τ = τ
(τ ∷ τs) ⇒ⁿ σ = τ ⇒ (τs ⇒ⁿ σ)
|
{
"alphanum_fraction": 0.5011037528,
"avg_line_length": 25.9918032787,
"ext": "agda",
"hexsha": "c46d06890f3961e43281f074dd12e43781b8a4eb",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "aeb2be63381d891fabe5317e3c27553deb6bca6d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "johnyob/agda-types",
"max_forks_repo_path": "src/STLC/Type.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aeb2be63381d891fabe5317e3c27553deb6bca6d",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "johnyob/agda-types",
"max_issues_repo_path": "src/STLC/Type.agda",
"max_line_length": 75,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "aeb2be63381d891fabe5317e3c27553deb6bca6d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "johnyob/agda-types",
"max_stars_repo_path": "src/STLC/Type.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1305,
"size": 3171
}
|
{-# OPTIONS --without-K --safe #-}
open import Categories.Category using (Category; _[_≈_])
-- Karoubi Envelopes. These are the free completions of categories under split idempotents
module Categories.Category.Construction.KaroubiEnvelope {o ℓ e} (𝒞 : Category o ℓ e) where
open import Level
open import Categories.Morphism.Idempotent.Bundles 𝒞
open import Categories.Morphism.Reasoning 𝒞
private
module 𝒞 = Category 𝒞
open 𝒞.HomReasoning
open 𝒞.Equiv
open Idempotent
open Idempotent⇒
KaroubiEnvelope : Category (o ⊔ ℓ ⊔ e) (ℓ ⊔ e) e
KaroubiEnvelope = record
{ Obj = Idempotent
; _⇒_ = Idempotent⇒
; _≈_ = λ f g → 𝒞 [ Idempotent⇒.hom f ≈ Idempotent⇒.hom g ]
; id = id
; _∘_ = _∘_
; assoc = 𝒞.assoc
; sym-assoc = 𝒞.sym-assoc
; identityˡ = λ {I} {J} {f} → absorbˡ f
; identityʳ = λ {I} {J} {f} → absorbʳ f
; identity² = λ {I} → idempotent I
; equiv = record
{ refl = refl
; sym = sym
; trans = trans
}
; ∘-resp-≈ = 𝒞.∘-resp-≈
}
|
{
"alphanum_fraction": 0.6474164134,
"avg_line_length": 24.675,
"ext": "agda",
"hexsha": "ca10eeaab69a1c343b8c5fa2383e903cafa434de",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Construction/KaroubiEnvelope.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Construction/KaroubiEnvelope.agda",
"max_line_length": 90,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Construction/KaroubiEnvelope.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z",
"num_tokens": 390,
"size": 987
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Results concerning function extensionality for propositional equality
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Axiom.Extensionality.Propositional where
open import Function
open import Level using (Level; _⊔_; suc; lift)
open import Relation.Binary.Core
open import Relation.Binary.PropositionalEquality.Core
------------------------------------------------------------------------
-- Function extensionality states that if two functions are
-- propositionally equal for every input, then the functions themselves
-- must be propositionally equal.
Extensionality : (a b : Level) → Set _
Extensionality a b =
{A : Set a} {B : A → Set b} {f g : (x : A) → B x} →
(∀ x → f x ≡ g x) → f ≡ g
------------------------------------------------------------------------
-- Properties
-- If extensionality holds for a given universe level, then it also
-- holds for lower ones.
lower-extensionality : ∀ {a₁ b₁} a₂ b₂ →
Extensionality (a₁ ⊔ a₂) (b₁ ⊔ b₂) →
Extensionality a₁ b₁
lower-extensionality a₂ b₂ ext f≡g = cong (λ h → Level.lower ∘ h ∘ lift) $
ext (cong (lift {ℓ = b₂}) ∘ f≡g ∘ Level.lower {ℓ = a₂})
-- Functional extensionality implies a form of extensionality for
-- Π-types.
∀-extensionality : ∀ {a b} → Extensionality a (suc b) →
{A : Set a} (B₁ B₂ : A → Set b) →
(∀ x → B₁ x ≡ B₂ x) →
(∀ x → B₁ x) ≡ (∀ x → B₂ x)
∀-extensionality ext B₁ B₂ B₁≡B₂ with ext B₁≡B₂
∀-extensionality ext B .B B₁≡B₂ | refl = refl
|
{
"alphanum_fraction": 0.5210280374,
"avg_line_length": 36.4255319149,
"ext": "agda",
"hexsha": "196b6a1ae1e2f5626639ee16cfc3457b087d7ad9",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Axiom/Extensionality/Propositional.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Axiom/Extensionality/Propositional.agda",
"max_line_length": 74,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Axiom/Extensionality/Propositional.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 447,
"size": 1712
}
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.EilenbergMacLane
open import homotopy.EilenbergMacLane1
open import homotopy.EilenbergMacLaneFunctor
module cohomology.CupProduct.OnEM.CommutativityInLowDegrees where
module _ {i} {j} (G : AbGroup i) (H : AbGroup j) where
private
module G = AbGroup G
module H = AbGroup H
module G⊗H = TensorProduct G H
module H⊗G = TensorProduct H G
import cohomology.CupProduct.OnEM.InLowDegrees G H as GH
import cohomology.CupProduct.OnEM.InLowDegrees H G as HG
open EMExplicit
×-cp₀₀-comm : EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap 0 ∘ GH.×-cp₀₀
∼ HG.×-cp₀₀ ∘ ×-swap
×-cp₀₀-comm (g' , h') =
(EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap 0 $
emloop $
(<– (emloop-equiv G.grp) g') G⊗H.⊗ (<– (emloop-equiv H.grp) h'))
=⟨ EM₁-fmap-emloop-β G⊗H.swap $
(<– (emloop-equiv G.grp) g') G⊗H.⊗ (<– (emloop-equiv H.grp) h') ⟩
(emloop $
GroupHom.f G⊗H.swap $
(<– (emloop-equiv G.grp) g') G⊗H.⊗ (<– (emloop-equiv H.grp) h'))
=⟨ ap emloop $ G⊗H.swap-β (<– (emloop-equiv G.grp) g') (<– (emloop-equiv H.grp) h') ⟩
(emloop $
(<– (emloop-equiv H.grp) h') H⊗G.⊗ (<– (emloop-equiv G.grp) g')) =∎
⊙×-cp₀₀-comm :
⊙EM-fmap G⊗H.abgroup H⊗G.abgroup G⊗H.swap 0 ◃⊙∘
GH.⊙×-cp₀₀ ◃⊙idf
=⊙∘
HG.⊙×-cp₀₀ ◃⊙∘
⊙×-swap ◃⊙idf
⊙×-cp₀₀-comm =
⊙seq-λ= ×-cp₀₀-comm $
contr-center $ =ₛ-level {n = -2} $ EM-level H⊗G.abgroup 0
module CP₀₁-comm {i} {j} (G : AbGroup i) (H : AbGroup j) where
private
module G = AbGroup G
module H = AbGroup H
module G⊗H = TensorProduct G H
module H⊗G = TensorProduct H G
import cohomology.CupProduct.OnEM.InLowDegrees G H as GH
import cohomology.CupProduct.OnEM.InLowDegrees H G as HG
private
swap : H⊗G.grp →ᴳ G⊗H.grp
swap = H⊗G.swap
module swap = GroupHom swap
cp₀₁-comm : ∀ g h →
ap (GH.cp₀₁ g) (emloop h) ==
ap (EM₁-fmap swap ∘ HG.cp₀₁ h) (emloop g)
cp₀₁-comm g h =
ap (GH.cp₀₁ g) (emloop h)
=⟨ GH.cp₀₁-emloop-β g h ⟩
emloop (g G⊗H.⊗ h)
=⟨ ap emloop (! (H⊗G.swap-β h g)) ⟩
emloop (swap.f (h H⊗G.⊗ g))
=⟨ ! (EM₁-fmap-emloop-β swap (h H⊗G.⊗ g)) ⟩
ap (EM₁-fmap swap) (emloop (h H⊗G.⊗ g))
=⟨ ap (ap (EM₁-fmap swap)) (! (HG.cp₀₁-emloop-β h g)) ⟩
ap (EM₁-fmap swap) (ap (HG.cp₀₁ h) (emloop g))
=⟨ ∘-ap (EM₁-fmap swap) (HG.cp₀₁ h) (emloop g) ⟩
ap (EM₁-fmap swap ∘ HG.cp₀₁ h) (emloop g) =∎
module CP₁₁-comm {i} {j} (G : AbGroup i) (H : AbGroup j) where
private
module G = AbGroup G
module H = AbGroup H
module G⊗H = TensorProduct G H
module H⊗G = TensorProduct H G
module swap = GroupHom H⊗G.swap
import cohomology.CupProduct.OnEM.InLowDegrees G H as GH
import cohomology.CupProduct.OnEM.InLowDegrees H G as HG
infix 80 _G∪H_
_G∪H_ : EM₁ G.grp → EM₁ H.grp → EMExplicit.EM G⊗H.abgroup 2
_G∪H_ = GH.cp₁₁
infix 80 _H∪G_
_H∪G_ : EM₁ H.grp → EM₁ G.grp → EMExplicit.EM H⊗G.abgroup 2
_H∪G_ = HG.cp₁₁
⊙−₁ : ⊙EM₁ H⊗G.grp ⊙→ ⊙EM₁ G⊗H.grp
⊙−₁ = ⊙EM₁-fmap (inv-hom G⊗H.abgroup) ⊙∘ ⊙EM₁-fmap H⊗G.swap
−₁ : EM₁ H⊗G.grp → EM₁ G⊗H.grp
−₁ = fst ⊙−₁
− : EMExplicit.EM H⊗G.abgroup 2 → EMExplicit.EM G⊗H.abgroup 2
− = Trunc-fmap (Susp-fmap −₁)
⊙− : EMExplicit.⊙EM H⊗G.abgroup 2 ⊙→ EMExplicit.⊙EM G⊗H.abgroup 2
⊙− = ⊙Trunc-fmap (⊙Susp-fmap −₁)
comm-embase-emloop-seq : ∀ h →
ap (λ y → embase G∪H y) (emloop h) =-=
ap (λ y → − (y H∪G embase)) (emloop h)
comm-embase-emloop-seq h =
ap (λ y → embase G∪H y) (emloop h)
=⟪idp⟫
ap (cst [ north ]₂) (emloop h)
=⟪ ap-cst [ north ]₂ (emloop h) ⟫
idp
=⟪idp⟫
ap − (idp {a = [ north ]})
=⟪ ! (ap (ap −) (HG.ap-cp₁₁-embase h)) ⟫
ap − (ap (_H∪G embase) (emloop h))
=⟪ ∘-ap − (_H∪G embase) (emloop h) ⟫
ap (λ y → − (y H∪G embase)) (emloop h) ∎∎
comm-emloop-embase-seq : ∀ g →
ap (_G∪H embase) (emloop g) =-=
ap (λ x → − (embase H∪G x)) (emloop g)
comm-emloop-embase-seq g =
ap (_G∪H embase) (emloop g)
=⟪ GH.ap-cp₁₁-embase g ⟫
idp
=⟪ ! (ap-cst [ north ]₂ (emloop g)) ⟫
ap (cst [ north ]₂) (emloop g)
=⟪idp⟫
ap (λ x → − (embase H∪G x)) (emloop g) ∎∎
comm-embase-emloop' : ∀ h →
ap (embase G∪H_) (emloop h) ==
ap (λ y → − (y H∪G embase)) (emloop h)
comm-embase-emloop' h = ↯ (comm-embase-emloop-seq h)
comm-emloop-embase' : ∀ g →
ap (λ x → GH.cp₁₁ x embase) (emloop g) ==
ap (λ x → − (embase H∪G x)) (emloop g)
comm-emloop-embase' g = ↯ (comm-emloop-embase-seq g)
abstract
comm-embase-emloop-comp' : ∀ h₁ h₂ →
comm-embase-emloop' (H.comp h₁ h₂) ◃∙
ap (ap (λ y → − (y H∪G embase))) (emloop-comp h₁ h₂) ◃∎
=ₛ
ap (ap (embase G∪H_)) (emloop-comp h₁ h₂) ◃∙
ap-∙ (embase G∪H_) (emloop h₁) (emloop h₂) ◃∙
ap2 _∙_ (comm-embase-emloop' h₁) (comm-embase-emloop' h₂) ◃∙
∙-ap (λ y → − (y H∪G embase)) (emloop h₁) (emloop h₂) ◃∎
comm-embase-emloop-comp' h₁ h₂ =
comm-embase-emloop' (H.comp h₁ h₂) ◃∙
ap (ap (λ y → − (y H∪G embase))) (emloop-comp h₁ h₂) ◃∎
=ₛ⟨ 0 & 1 & expand (comm-embase-emloop-seq (H.comp h₁ h₂)) ⟩
ap-cst [ north ] (emloop (H.comp h₁ h₂)) ◃∙
! (ap (ap −) (HG.ap-cp₁₁-embase (H.comp h₁ h₂))) ◃∙
∘-ap − (_H∪G embase) (emloop (H.comp h₁ h₂)) ◃∙
ap (ap (λ y → − (y H∪G embase))) (emloop-comp h₁ h₂) ◃∎
=ₛ⟨ 2 & 2 & !ₛ $
homotopy-naturality (ap − ∘ ap (_H∪G embase))
(ap (λ y → − (y H∪G embase)))
(∘-ap − (_H∪G embase))
(emloop-comp h₁ h₂) ⟩
ap-cst [ north ] (emloop (H.comp h₁ h₂)) ◃∙
! (ap (ap −) (HG.ap-cp₁₁-embase (H.comp h₁ h₂))) ◃∙
ap (ap − ∘ ap (_H∪G embase)) (emloop-comp h₁ h₂) ◃∙
∘-ap − (_H∪G embase) (emloop h₁ ∙ emloop h₂) ◃∎
=ₛ₁⟨ 1 & 1 & !-ap (ap −) (HG.ap-cp₁₁-embase (H.comp h₁ h₂)) ⟩
ap-cst [ north ] (emloop (H.comp h₁ h₂)) ◃∙
ap (ap −) (! (HG.ap-cp₁₁-embase (H.comp h₁ h₂))) ◃∙
ap (ap − ∘ ap (_H∪G embase)) (emloop-comp h₁ h₂) ◃∙
∘-ap − (_H∪G embase) (emloop h₁ ∙ emloop h₂) ◃∎
=ₛ₁⟨ 2 & 1 & ap-∘ (ap −) (ap (_H∪G embase)) (emloop-comp h₁ h₂) ⟩
ap-cst [ north ] (emloop (H.comp h₁ h₂)) ◃∙
ap (ap −) (! (HG.ap-cp₁₁-embase (H.comp h₁ h₂))) ◃∙
ap (ap −) (ap (ap (_H∪G embase)) (emloop-comp h₁ h₂)) ◃∙
∘-ap − (_H∪G embase) (emloop h₁ ∙ emloop h₂) ◃∎
=ₛ⟨ 1 & 2 &
ap-seq-=ₛ (ap −) $
post-rotate-seq-in {p = _ ◃∙ _ ◃∎} $
pre-rotate'-in $
!ₛ $ HG.ap-cp₁₁-embase-coh h₁ h₂ ⟩
ap-cst [ north ] (emloop (H.comp h₁ h₂)) ◃∙
ap (ap −) (! (ap2 _∙_ (HG.ap-cp₁₁-embase h₁) (HG.ap-cp₁₁-embase h₂))) ◃∙
ap (ap −) (! (ap-∙ (_H∪G embase) (emloop h₁) (emloop h₂))) ◃∙
∘-ap − (_H∪G embase) (emloop h₁ ∙ emloop h₂) ◃∎
=ₛ₁⟨ 2 & 1 & ap-! (ap −) (ap-∙ (_H∪G embase) (emloop h₁) (emloop h₂))⟩
ap-cst [ north ] (emloop (H.comp h₁ h₂)) ◃∙
ap (ap −) (! (ap2 _∙_ (HG.ap-cp₁₁-embase h₁) (HG.ap-cp₁₁-embase h₂))) ◃∙
! (ap (ap −) (ap-∙ (_H∪G embase) (emloop h₁) (emloop h₂))) ◃∙
∘-ap − (_H∪G embase) (emloop h₁ ∙ emloop h₂) ◃∎
=ₛ₁⟨ 3 & 1 & ! (!ap-∘=∘-ap − (_H∪G embase) (emloop h₁ ∙ emloop h₂)) ⟩
ap-cst [ north ] (emloop (H.comp h₁ h₂)) ◃∙
ap (ap −) (! (ap2 _∙_ (HG.ap-cp₁₁-embase h₁) (HG.ap-cp₁₁-embase h₂))) ◃∙
! (ap (ap −) (ap-∙ (_H∪G embase) (emloop h₁) (emloop h₂))) ◃∙
! (ap-∘ − (_H∪G embase) (emloop h₁ ∙ emloop h₂)) ◃∎
=ₛ⟨ 2 & 2 &
post-rotate-seq-in {p = _ ◃∙ _ ◃∎} $
pre-rotate'-seq-in {p = _ ◃∙ _ ◃∎} $
ap-∘-∙-coh − (_H∪G embase) (emloop h₁) (emloop h₂) ⟩
ap-cst [ north ] (emloop (H.comp h₁ h₂)) ◃∙
ap (ap −) (! (ap2 _∙_ (HG.ap-cp₁₁-embase h₁) (HG.ap-cp₁₁-embase h₂))) ◃∙
ap-∙ − (ap (_H∪G embase) (emloop h₁)) (ap (_H∪G embase) (emloop h₂)) ◃∙
! (ap2 _∙_ (ap-∘ − (_H∪G embase) (emloop h₁))
(ap-∘ − (_H∪G embase) (emloop h₂))) ◃∙
! (ap-∙ (λ y → − (y H∪G embase)) (emloop h₁) (emloop h₂)) ◃∎
=ₛ₁⟨ 1 & 1 &
ap (ap (ap −)) (!-ap2 _∙_ (HG.ap-cp₁₁-embase h₁) (HG.ap-cp₁₁-embase h₂)) ∙
ap-ap2 (ap −) _∙_ (! (HG.ap-cp₁₁-embase h₁)) (! (HG.ap-cp₁₁-embase h₂)) ⟩
ap-cst [ north ] (emloop (H.comp h₁ h₂)) ◃∙
ap2 (λ p q → ap − (p ∙ q)) (! (HG.ap-cp₁₁-embase h₁)) (! (HG.ap-cp₁₁-embase h₂)) ◃∙
ap-∙ − (ap (_H∪G embase) (emloop h₁)) (ap (_H∪G embase) (emloop h₂)) ◃∙
! (ap2 _∙_ (ap-∘ − (_H∪G embase) (emloop h₁))
(ap-∘ − (_H∪G embase) (emloop h₂))) ◃∙
! (ap-∙ (λ y → − (y H∪G embase)) (emloop h₁) (emloop h₂)) ◃∎
=ₛ⟨ 1 & 2 &
homotopy-naturality2 (λ p q → ap − (p ∙ q))
(λ p q → ap − p ∙ ap − q)
(λ p q → ap-∙ − p q)
(! (HG.ap-cp₁₁-embase h₁))
(! (HG.ap-cp₁₁-embase h₂)) ⟩
ap-cst [ north ] (emloop (H.comp h₁ h₂)) ◃∙
idp ◃∙
ap2 (λ p q → ap − p ∙ ap − q) (! (HG.ap-cp₁₁-embase h₁)) (! (HG.ap-cp₁₁-embase h₂)) ◃∙
! (ap2 _∙_ (ap-∘ − (_H∪G embase) (emloop h₁))
(ap-∘ − (_H∪G embase) (emloop h₂))) ◃∙
! (ap-∙ (λ y → − (y H∪G embase)) (emloop h₁) (emloop h₂)) ◃∎
=ₛ⟨ 1 & 1 & expand [] ⟩
ap-cst [ north ] (emloop (H.comp h₁ h₂)) ◃∙
ap2 (λ p q → ap − p ∙ ap − q) (! (HG.ap-cp₁₁-embase h₁)) (! (HG.ap-cp₁₁-embase h₂)) ◃∙
! (ap2 _∙_ (ap-∘ − (_H∪G embase) (emloop h₁))
(ap-∘ − (_H∪G embase) (emloop h₂))) ◃∙
! (ap-∙ (λ y → − (y H∪G embase)) (emloop h₁) (emloop h₂)) ◃∎
=ₛ₁⟨ 1 & 1 &
! (ap2-ap-lr _∙_ (ap −) (ap −) (! (HG.ap-cp₁₁-embase h₁)) (! (HG.ap-cp₁₁-embase h₂))) ∙
ap2 (ap2 _∙_) (ap-! (ap −) (HG.ap-cp₁₁-embase h₁)) (ap-! (ap −) (HG.ap-cp₁₁-embase h₂)) ⟩
ap-cst [ north ] (emloop (H.comp h₁ h₂)) ◃∙
ap2 _∙_ (! (ap (ap −) (HG.ap-cp₁₁-embase h₁))) (! (ap (ap −) (HG.ap-cp₁₁-embase h₂))) ◃∙
! (ap2 _∙_ (ap-∘ − (_H∪G embase) (emloop h₁))
(ap-∘ − (_H∪G embase) (emloop h₂))) ◃∙
! (ap-∙ (λ y → − (y H∪G embase)) (emloop h₁) (emloop h₂)) ◃∎
=ₛ₁⟨ 2 & 1 &
!-ap2 _∙_ (ap-∘ − (_H∪G embase) (emloop h₁))
(ap-∘ − (_H∪G embase) (emloop h₂)) ∙
ap2 (ap2 _∙_) (!ap-∘=∘-ap − (_H∪G embase) (emloop h₁))
(!ap-∘=∘-ap − (_H∪G embase) (emloop h₂)) ⟩
ap-cst [ north ] (emloop (H.comp h₁ h₂)) ◃∙
ap2 _∙_ (! (ap (ap −) (HG.ap-cp₁₁-embase h₁))) (! (ap (ap −) (HG.ap-cp₁₁-embase h₂))) ◃∙
ap2 _∙_ (∘-ap − (_H∪G embase) (emloop h₁))
(∘-ap − (_H∪G embase) (emloop h₂)) ◃∙
! (ap-∙ (λ y → − (y H∪G embase)) (emloop h₁) (emloop h₂)) ◃∎
=ₛ₁⟨ 3 & 1 & !ap-∙=∙-ap (λ y → − (y H∪G embase)) (emloop h₁) (emloop h₂) ⟩
ap-cst [ north ] (emloop (H.comp h₁ h₂)) ◃∙
ap2 _∙_ (! (ap (ap −) (HG.ap-cp₁₁-embase h₁))) (! (ap (ap −) (HG.ap-cp₁₁-embase h₂))) ◃∙
ap2 _∙_ (∘-ap − (_H∪G embase) (emloop h₁))
(∘-ap − (_H∪G embase) (emloop h₂)) ◃∙
∙-ap (λ y → − (y H∪G embase)) (emloop h₁) (emloop h₂) ◃∎
=ₛ⟨ 0 & 1 &
ap-cst [ north ] (emloop (H.comp h₁ h₂)) ◃∎
=ₛ⟨ 1 & 0 & contract ⟩
ap-cst [ north ] (emloop (H.comp h₁ h₂)) ◃∙
idp ◃∎
=ₛ₁⟨ 1 & 1 & ! (ap-cst idp (emloop-comp h₁ h₂)) ⟩
ap-cst [ north ] (emloop (H.comp h₁ h₂)) ◃∙
ap (λ _ → idp) (emloop-comp h₁ h₂) ◃∎
=ₛ⟨ !ₛ $ homotopy-naturality (ap (embase G∪H_))
(λ _ → idp)
(ap-cst [ north ])
(emloop-comp h₁ h₂) ⟩
ap (ap (embase G∪H_)) (emloop-comp h₁ h₂) ◃∙
ap-cst [ north ] (emloop h₁ ∙ emloop h₂) ◃∎
=ₛ⟨ 1 & 1 & ap-cst-coh [ north ] (emloop h₁) (emloop h₂) ⟩
ap (ap (embase G∪H_)) (emloop-comp h₁ h₂) ◃∙
ap-∙ (cst [ north ]) (emloop h₁) (emloop h₂) ◃∙
ap2 _∙_ (ap-cst [ north ] (emloop h₁)) (ap-cst [ north ] (emloop h₂)) ◃∎ ∎ₛ
⟩
ap (ap (embase G∪H_)) (emloop-comp h₁ h₂) ◃∙
ap-∙ (cst [ north ]) (emloop h₁) (emloop h₂) ◃∙
ap2 _∙_ (ap-cst [ north ] (emloop h₁)) (ap-cst [ north ] (emloop h₂)) ◃∙
ap2 _∙_ (! (ap (ap −) (HG.ap-cp₁₁-embase h₁))) (! (ap (ap −) (HG.ap-cp₁₁-embase h₂))) ◃∙
ap2 _∙_ (∘-ap − (_H∪G embase) (emloop h₁))
(∘-ap − (_H∪G embase) (emloop h₂)) ◃∙
∙-ap (λ y → − (y H∪G embase)) (emloop h₁) (emloop h₂) ◃∎
=ₛ⟨ 2 & 3 & ∙-ap2-seq _∙_ (comm-embase-emloop-seq h₁) (comm-embase-emloop-seq h₂) ⟩
ap (ap (embase G∪H_)) (emloop-comp h₁ h₂) ◃∙
ap-∙ (embase G∪H_) (emloop h₁) (emloop h₂) ◃∙
ap2 _∙_ (comm-embase-emloop' h₁) (comm-embase-emloop' h₂) ◃∙
∙-ap (λ y → − (y H∪G embase)) (emloop h₁) (emloop h₂) ◃∎ ∎ₛ
comm-emloop-comp-embase' : ∀ g₁ g₂ →
comm-emloop-embase' (G.comp g₁ g₂) ◃∙
ap (ap (λ x → − (embase H∪G x))) (emloop-comp g₁ g₂) ◃∎
=ₛ
ap (ap (_G∪H embase)) (emloop-comp g₁ g₂) ◃∙
ap-∙ (_G∪H embase) (emloop g₁) (emloop g₂) ◃∙
ap2 _∙_ (comm-emloop-embase' g₁) (comm-emloop-embase' g₂) ◃∙
∙-ap (λ x → − (embase H∪G x)) (emloop g₁) (emloop g₂) ◃∎
comm-emloop-comp-embase' g₁ g₂ =
comm-emloop-embase' (G.comp g₁ g₂) ◃∙
ap (ap (λ x → − (embase H∪G x))) (emloop-comp g₁ g₂) ◃∎
=ₛ⟨ 0 & 1 & expand (comm-emloop-embase-seq (G.comp g₁ g₂)) ⟩
GH.ap-cp₁₁-embase (G.comp g₁ g₂) ◃∙
! (ap-cst [ north ] (emloop (G.comp g₁ g₂))) ◃∙
ap (ap (λ x → − (embase H∪G x))) (emloop-comp g₁ g₂) ◃∎
=ₛ⟨ 1 & 2 & !ₛ $
homotopy-naturality
(λ _ → idp)
(ap (cst [ north ]))
(λ p → ! (ap-cst [ north ] p))
(emloop-comp g₁ g₂) ⟩
GH.ap-cp₁₁-embase (G.comp g₁ g₂) ◃∙
ap (λ _ → idp) (emloop-comp g₁ g₂) ◃∙
! (ap-cst [ north ] (emloop g₁ ∙ emloop g₂)) ◃∎
=ₛ⟨ 1 & 1 & =ₛ-in {t = []} (ap-cst idp (emloop-comp g₁ g₂)) ⟩
GH.ap-cp₁₁-embase (G.comp g₁ g₂) ◃∙
! (ap-cst [ north ] (emloop g₁ ∙ emloop g₂)) ◃∎
=ₛ⟨ 0 & 1 & GH.ap-cp₁₁-embase-coh g₁ g₂ ⟩
ap (ap (_G∪H embase)) (emloop-comp g₁ g₂) ◃∙
ap-∙ (_G∪H embase) (emloop g₁) (emloop g₂) ◃∙
ap2 _∙_ (GH.ap-cp₁₁-embase g₁) (GH.ap-cp₁₁-embase g₂) ◃∙
! (ap-cst [ north ] (emloop g₁ ∙ emloop g₂)) ◃∎
=ₛ⟨ 3 & 1 & !-=ₛ $ ap-cst-coh [ north ] (emloop g₁) (emloop g₂) ⟩
ap (ap (_G∪H embase)) (emloop-comp g₁ g₂) ◃∙
ap-∙ (_G∪H embase) (emloop g₁) (emloop g₂) ◃∙
ap2 _∙_ (GH.ap-cp₁₁-embase g₁) (GH.ap-cp₁₁-embase g₂) ◃∙
! (ap2 _∙_ (ap-cst [ north ] (emloop g₁)) (ap-cst [ north ] (emloop g₂))) ◃∙
! (ap-∙ (cst [ north ]) (emloop g₁) (emloop g₂)) ◃∎
=ₛ₁⟨ 3 & 1 & ! (ap2-! _∙_ (ap-cst [ north ] (emloop g₁)) (ap-cst [ north ] (emloop g₂))) ⟩
ap (ap (_G∪H embase)) (emloop-comp g₁ g₂) ◃∙
ap-∙ (_G∪H embase) (emloop g₁) (emloop g₂) ◃∙
ap2 _∙_ (GH.ap-cp₁₁-embase g₁) (GH.ap-cp₁₁-embase g₂) ◃∙
ap2 _∙_ (! (ap-cst [ north ] (emloop g₁))) (! (ap-cst [ north ] (emloop g₂))) ◃∙
! (ap-∙ (cst [ north ]) (emloop g₁) (emloop g₂)) ◃∎
=ₛ⟨ 2 & 2 & ∙-ap2-seq _∙_ (comm-emloop-embase-seq g₁) (comm-emloop-embase-seq g₂) ⟩
ap (ap (_G∪H embase)) (emloop-comp g₁ g₂) ◃∙
ap-∙ (_G∪H embase) (emloop g₁) (emloop g₂) ◃∙
ap2 _∙_ (comm-emloop-embase' g₁) (comm-emloop-embase' g₂) ◃∙
! (ap-∙ (cst [ north ]) (emloop g₁) (emloop g₂)) ◃∎
=ₛ₁⟨ 3 & 1 & !ap-∙=∙-ap (cst [ north ]) (emloop g₁) (emloop g₂) ⟩
ap (ap (_G∪H embase)) (emloop-comp g₁ g₂) ◃∙
ap-∙ (_G∪H embase) (emloop g₁) (emloop g₂) ◃∙
ap2 _∙_ (comm-emloop-embase' g₁) (comm-emloop-embase' g₂) ◃∙
∙-ap (cst [ north ]) (emloop g₁) (emloop g₂) ◃∎ ∎ₛ
comm-emloop-emloop' : ∀ g h →
ap-comm _G∪H_ (emloop g) (emloop h) ◃∙
ap2 _∙_ (comm-embase-emloop' h) (comm-emloop-embase' g) ◃∎
=ₛ
ap2 _∙_ (comm-emloop-embase' g) (comm-embase-emloop' h) ◃∙
ap-comm (λ x y → − (y H∪G x)) (emloop g) (emloop h) ◃∎
comm-emloop-emloop' g h =
ap-comm _G∪H_ (emloop g) (emloop h) ◃∙
ap2 _∙_ (comm-embase-emloop' h) (comm-emloop-embase' g) ◃∎
=ₛ⟨ 1 & 1 & ap2-out _∙_ (comm-embase-emloop' h) (comm-emloop-embase' g) ⟩
ap-comm _G∪H_ (emloop g) (emloop h) ◃∙
ap (_∙ ap (_G∪H embase) (emloop g)) (comm-embase-emloop' h) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) (comm-emloop-embase' g) ◃∎
=ₛ⟨ 1 & 1 & ap-seq-=ₛ (_∙ ap (_G∪H embase) (emloop g))
(take-drop-split 1 (comm-embase-emloop-seq h)) ⟩
ap-comm _G∪H_ (emloop g) (emloop h) ◃∙
ap (_∙ ap (_G∪H embase) (emloop g)) (ap-cst [ north ] (emloop h)) ◃∙
ap (_∙ ap (_G∪H embase) (emloop g)) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) (comm-emloop-embase' g) ◃∎
=ₛ⟨ 3 & 1 & ap-seq-∙ (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) (comm-emloop-embase-seq g) ⟩
ap-comm _G∪H_ (emloop g) (emloop h) ◃∙
ap (_∙ ap (_G∪H embase) (emloop g)) (ap-cst [ north ] (emloop h)) ◃∙
ap (_∙ ap (_G∪H embase) (emloop g)) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) (GH.ap-cp₁₁-embase g) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) (! (ap-cst [ north ] (emloop g))) ◃∎
=ₛ⟨ 4 & 1 & ap-seq-=ₛ (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) step₄' ⟩
ap-comm _G∪H_ (emloop g) (emloop h) ◃∙
ap (_∙ ap (_G∪H embase) (emloop g)) (ap-cst [ north ] (emloop h)) ◃∙
ap (_∙ ap (_G∪H embase) (emloop g)) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) (GH.ap-cp₁₁-embase g) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) (↯ h₁'-seq) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) (! (!-inv-r (h₁' embase))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_)
(! (ap-null-homotopic (λ x → [ north ]₂) h₁' (emloop g))) ◃∎
=ₛ⟨ 2 & 2 & ap-comm-=ₛ _∙_ (↯ (tail (comm-embase-emloop-seq h))) (GH.ap-cp₁₁-embase g) ⟩
ap-comm _G∪H_ (emloop g) (emloop h) ◃∙
ap (_∙ ap (_G∪H embase) (emloop g)) (ap-cst [ north ] (emloop h)) ◃∙
ap (idp ∙_) (GH.ap-cp₁₁-embase g) ◃∙
ap (_∙ idp) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) (↯ h₁'-seq) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) (! (!-inv-r (h₁' embase))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_)
(! (ap-null-homotopic (λ x → [ north ]₂) h₁' (emloop g))) ◃∎
=ₛ⟨ 3 & 2 & ap-comm-=ₛ _∙_ (↯ (tail (comm-embase-emloop-seq h))) (↯ h₁'-seq) ⟩
ap-comm _G∪H_ (emloop g) (emloop h) ◃∙
ap (_∙ ap (_G∪H embase) (emloop g)) (ap-cst [ north ] (emloop h)) ◃∙
ap (idp ∙_) (GH.ap-cp₁₁-embase g) ◃∙
ap (idp ∙_) (↯ h₁'-seq) ◃∙
ap (λ a → a ∙ idp) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) (! (!-inv-r (h₁' embase))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_)
(! (ap-null-homotopic (λ x → [ north ]₂) h₁' (emloop g))) ◃∎
=ₛ₁⟨ 3 & 1 & ap (ap (idp ∙_)) (! (=ₛ-out heart))⟩
ap-comm _G∪H_ (emloop g) (emloop h) ◃∙
ap (_∙ ap (_G∪H embase) (emloop g)) (ap-cst [ north ] (emloop h)) ◃∙
ap (idp ∙_) (GH.ap-cp₁₁-embase g) ◃∙
ap (idp ∙_) (↯ h₁-seq) ◃∙
ap (λ a → a ∙ idp) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) (! (!-inv-r (h₁' embase))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_)
(! (ap-null-homotopic (λ x → [ north ]₂) h₁' (emloop g))) ◃∎
=ₛ⟨ 0 & 3 & top-part ⟩
ap (ap (_G∪H embase) (emloop g) ∙_)
(ap-null-homotopic (λ y → [ north ]₂) h₁ (emloop h)) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_) (!-inv-r (h₁ embase)) ◃∙
ap (_∙ idp) (GH.ap-cp₁₁-embase g) ◃∙
ap (idp ∙_) (↯ h₁-seq) ◃∙
ap (λ a → a ∙ idp) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) (! (!-inv-r (h₁' embase))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_)
(! (ap-null-homotopic (λ x → [ north ]₂) h₁' (emloop g))) ◃∎
=ₛ⟨ 4 & 3 & bottom-part ⟩
ap (ap (_G∪H embase) (emloop g) ∙_)
(ap-null-homotopic (λ y → [ north ]₂) h₁ (emloop h)) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_) (!-inv-r (h₁ embase)) ◃∙
ap (_∙ idp) (GH.ap-cp₁₁-embase g) ◃∙
ap (idp ∙_) (↯ h₁-seq) ◃∙
ap (idp ∙_) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap (_∙ ap (λ y → − (y H∪G embase)) (emloop h)) (! (ap-cst [ north ]₂ (emloop g))) ◃∙
ap-comm (λ x y → − (y H∪G x)) (emloop g) (emloop h) ◃∎
=ₛ⟨ 2 & 2 & ap-comm-=ₛ _∙_ (GH.ap-cp₁₁-embase g) (↯ h₁-seq) ⟩
ap (ap (_G∪H embase) (emloop g) ∙_)
(ap-null-homotopic (λ y → [ north ]₂) h₁ (emloop h)) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_) (!-inv-r (h₁ embase)) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_) (↯ h₁-seq) ◃∙
ap (_∙ idp) (GH.ap-cp₁₁-embase g) ◃∙
ap (idp ∙_) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap (_∙ ap (λ y → − (y H∪G embase)) (emloop h)) (! (ap-cst [ north ]₂ (emloop g))) ◃∙
ap-comm (λ x y → − (y H∪G x)) (emloop g) (emloop h) ◃∎
=ₛ⟨ 3 & 2 & ap-comm-=ₛ _∙_ (GH.ap-cp₁₁-embase g) (↯ (tail (comm-embase-emloop-seq h))) ⟩
ap (ap (_G∪H embase) (emloop g) ∙_)
(ap-null-homotopic (λ y → [ north ]₂) h₁ (emloop h)) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_) (!-inv-r (h₁ embase)) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_) (↯ h₁-seq) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap (_∙ ap (λ y → − (y H∪G embase)) (emloop h)) (GH.ap-cp₁₁-embase g) ◃∙
ap (_∙ ap (λ y → − (y H∪G embase)) (emloop h)) (! (ap-cst [ north ]₂ (emloop g))) ◃∙
ap-comm (λ x y → − (y H∪G x)) (emloop g) (emloop h) ◃∎
=ₛ⟨ 4 & 2 & ∙-ap-seq (_∙ ap (λ y → − (y H∪G embase)) (emloop h)) (comm-emloop-embase-seq g) ⟩
ap (ap (_G∪H embase) (emloop g) ∙_)
(ap-null-homotopic (λ y → [ north ]₂) h₁ (emloop h)) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_) (!-inv-r (h₁ embase)) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_) (↯ h₁-seq) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap (_∙ ap (λ y → − (y H∪G embase)) (emloop h)) (comm-emloop-embase' g) ◃∙
ap-comm (λ x y → − (y H∪G x)) (emloop g) (emloop h) ◃∎
=ₛ⟨ 0 & 3 & ap-seq-=ₛ (ap (_G∪H embase) (emloop g) ∙_) step₁₃' ⟩
ap (ap (_G∪H embase) (emloop g) ∙_) (ap-cst [ north ]₂ (emloop h)) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap (_∙ ap (λ y → − (y H∪G embase)) (emloop h)) (comm-emloop-embase' g) ◃∙
ap-comm (λ x y → − (y H∪G x)) (emloop g) (emloop h) ◃∎
=ₛ⟨ 0 & 2 & !ₛ $ ap-seq-=ₛ (ap (_G∪H embase) (emloop g) ∙_) $
take-drop-split 1 (comm-embase-emloop-seq h) ⟩
ap (ap (_G∪H embase) (emloop g) ∙_) (comm-embase-emloop' h) ◃∙
ap (_∙ ap (λ y → − (y H∪G embase)) (emloop h)) (comm-emloop-embase' g) ◃∙
ap-comm (λ x y → − (y H∪G x)) (emloop g) (emloop h) ◃∎
=ₛ⟨ 0 & 2 & !ₛ (ap2-out' _∙_ (comm-emloop-embase' g) (comm-embase-emloop' h)) ⟩
ap2 _∙_ (comm-emloop-embase' g) (comm-embase-emloop' h) ◃∙
ap-comm (λ x y → − (y H∪G x)) (emloop g) (emloop h) ◃∎ ∎ₛ
where
h₀ : ∀ y → embase G∪H y == [ north ]₂
h₀ y = idp
h₁ : ∀ y → embase G∪H y == [ north ]₂
h₁ = transport (λ x → ∀ y → x G∪H y == [ north ]₂) (emloop g) h₀
h₀' : ∀ x → − (embase H∪G x) == [ north ]₂
h₀' x = idp
h₁' : ∀ x → − (embase H∪G x) == [ north ]₂
h₁' = transport (λ y → ∀ x → − (y H∪G x) == [ north ]₂) (emloop h) h₀'
h₁-path : ∀ y → h₁ y == ! (ap [_]₂ (GH.η (GH.cp₀₁ g y)))
h₁-path y =
transport (λ x → ∀ y → x G∪H y == [ north ]₂) (emloop g) h₀ y
=⟨ app= (transp-naturality {B = λ x → ∀ y → x G∪H y == [ north ]₂}
{C = λ x → x G∪H y == [ north ]₂}
(λ k → k y)
(emloop g)) h₀ ⟩
transport (λ x → x G∪H y == [ north ]₂) (emloop g) (h₀ y)
=⟨ to-transp {B = λ x → x G∪H y == [ north ]₂} {p = emloop g} $
↓-app=cst-in {f = _G∪H y}
{p = emloop g} {u = idp}
{v = ! (ap (_G∪H y) (emloop g))} $
! (!-inv-r (ap (_G∪H y) (emloop g))) ⟩
! (ap (_G∪H y) (emloop g))
=⟨ ap ! (GH.ap-cp₁₁ g y) ⟩
! (ap [_] (GH.η (GH.cp₀₁ g y))) =∎
h₁'-path : ∀ x → h₁' x == ! (ap [_]₂ (GH.η (−₁ (HG.cp₀₁ h x))))
h₁'-path x =
transport (λ y → ∀ x → − (y H∪G x) == [ north ]₂) (emloop h) h₀' x
=⟨ app= (transp-naturality {B = λ y → ∀ x → − (y H∪G x) == [ north ]₂}
{C = λ y → − (y H∪G x) == [ north ]₂}
(λ k → k x)
(emloop h)) h₀' ⟩
transport (λ y → − (y H∪G x) == [ north ]₂) (emloop h) (h₀' x)
=⟨ to-transp {B = λ y → − (y H∪G x) == [ north ]₂} {p = emloop h} $
↓-app=cst-in {f = λ y → − (y H∪G x)}
{p = emloop h} {u = idp}
{v = ! (ap (λ y → − (y H∪G x)) (emloop h))} $
! (!-inv-r (ap (λ y → − (y H∪G x)) (emloop h))) ⟩
! (ap (λ y → − (y H∪G x)) (emloop h))
=⟨ ap ! (ap-∘ − (_H∪G x) (emloop h)) ⟩
! (ap − (ap (_H∪G x) (emloop h)))
=⟨ ap (! ∘ ap −) (HG.ap-cp₁₁ h x) ⟩
! (ap − (ap [_]₂ (HG.η (HG.cp₀₁ h x))))
=⟨ ap ! (∘-ap − [_]₂ (HG.η (HG.cp₀₁ h x))) ⟩
! (ap (λ p → [ Susp-fmap −₁ p ]₂) (HG.η (HG.cp₀₁ h x)))
=⟨ ap ! (ap-∘ [_]₂ (Susp-fmap −₁) (HG.η (HG.cp₀₁ h x))) ⟩
! (ap [_]₂ (ap (Susp-fmap −₁) (HG.η (HG.cp₀₁ h x))))
=⟨ ! (ap (! ∘ ap [_]₂) (app= (ap fst (η-natural ⊙−₁)) (HG.cp₀₁ h x))) ⟩
! (ap [_]₂ (GH.η (−₁ (HG.cp₀₁ h x)))) =∎
where open import homotopy.SuspAdjointLoop using (η-natural)
h₁-seq : idp {a = [ north ]₂} =-= idp
h₁-seq = ! (!-inv-r (h₁ embase)) ◃∙
ap (λ v → h₁ v ∙ ! (h₁ embase)) (emloop h) ◃∙
!-inv-r (h₁ embase) ◃∎
h₁'-seq : idp {a = [ north ]₂} =-= idp
h₁'-seq = ! (!-inv-r (h₁' embase)) ◃∙
! (ap (λ v → h₁' v ∙ ! (h₁' embase)) (emloop g)) ◃∙
!-inv-r (h₁' embase) ◃∎
{- the crucial step in the commutative diagram -}
heart : h₁-seq =ₛ h₁'-seq
heart =
! (!-inv-r (h₁ embase)) ◃∙
ap (λ v → h₁ v ∙ ! (h₁ embase)) (emloop h) ◃∙
!-inv-r (h₁ embase) ◃∎
=ₛ⟨ =ₛ-in {t = ! (!-inv-r (! (ap [_]₂ (GH.η embase)))) ◃∙
ap (λ v → ! (ap [_]₂ (GH.η (GH.cp₀₁ g v))) ∙ ! (! (ap [_] (GH.η embase)))) (emloop h) ◃∙
!-inv-r (! (ap [_]₂ (GH.η embase))) ◃∎} $
ap (λ f → ! (!-inv-r (f embase)) ∙
ap (λ v → f v ∙ ! (f embase)) (emloop h) ∙
!-inv-r (f embase))
(λ= h₁-path) ⟩
! (!-inv-r (! (ap [_]₂ (GH.η embase)))) ◃∙
ap (λ v → ! (ap [_]₂ (GH.η (GH.cp₀₁ g v))) ∙ ! (! (ap [_]₂ (GH.η embase)))) (emloop h) ◃∙
!-inv-r (! (ap [_]₂ (GH.η embase))) ◃∎
=ₛ₁⟨ 1 & 1 &
ap (λ v → ! (ap [_]₂ (GH.η (GH.cp₀₁ g v))) ∙ ! (! (ap [_]₂ (GH.η embase)))) (emloop h)
=⟨ ap-∘ (λ w → ! (ap [_]₂ (GH.η w)) ∙ ! (! (ap [_]₂ (GH.η embase)))) (GH.cp₀₁ g) (emloop h) ⟩
ap (λ w → ! (ap [_]₂ (GH.η w)) ∙ ! (! (ap [_]₂ (GH.η embase)))) (ap (GH.cp₀₁ g) (emloop h))
=⟨ ap (ap (λ w → ! (ap [_]₂ (GH.η w)) ∙ ! (! (ap [_]₂ (GH.η embase))))) $
ap (GH.cp₀₁ g) (emloop h)
=⟨ CP₀₁-comm.cp₀₁-comm G H g h ⟩
ap (EM₁-fmap H⊗G.swap ∘ HG.cp₀₁ h) (emloop g)
=⟨ ! (!-! _) ⟩
! (! (ap (EM₁-fmap H⊗G.swap ∘ HG.cp₀₁ h) (emloop g)))
=⟨ ap ! (! (EM₁-neg-! G⊗H.abgroup _)) ⟩
! (ap (EM₁-neg G⊗H.abgroup) (ap (EM₁-fmap H⊗G.swap ∘ HG.cp₀₁ h) (emloop g)))
=⟨ ap ! (∘-ap (EM₁-neg G⊗H.abgroup) (EM₁-fmap H⊗G.swap ∘ HG.cp₀₁ h) (emloop g)) ⟩
! (ap (−₁ ∘ HG.cp₀₁ h) (emloop g)) =∎
-- Yo dawg, I herd you like continued equalities,
-- so we put continued equalities into your continued equalities,
-- so u can reason equationally while u reason equationally.
⟩
ap (λ w → ! (ap [_]₂ (GH.η w)) ∙ ! (! (ap [_]₂ (GH.η embase)))) (! (ap (−₁ ∘ HG.cp₀₁ h) (emloop g)))
=⟨ ap-! (λ w → ! (ap [_]₂ (GH.η w)) ∙ ! (! (ap [_]₂ (GH.η embase)))) (ap (−₁ ∘ HG.cp₀₁ h) (emloop g)) ⟩
! (ap (λ w → ! (ap [_]₂ (GH.η w)) ∙ ! (! (ap [_]₂ (GH.η embase)))) (ap (−₁ ∘ HG.cp₀₁ h) (emloop g)))
=⟨ ap ! (∘-ap (λ w → ! (ap [_]₂ (GH.η w)) ∙ ! (! (ap [_]₂ (GH.η embase)))) (−₁ ∘ HG.cp₀₁ h) (emloop g)) ⟩
! (ap (λ v → ! (ap [_]₂ (GH.η (−₁ (HG.cp₀₁ h v)))) ∙ ! (! (ap [_]₂ (GH.η embase)))) (emloop g)) =∎
⟩
! (!-inv-r (! (ap [_]₂ (GH.η embase)))) ◃∙
! (ap (λ v → ! (ap [_]₂ (GH.η (−₁ (HG.cp₀₁ h v)))) ∙ ! (! (ap [_]₂ (GH.η embase)))) (emloop g)) ◃∙
!-inv-r (! (ap [_]₂ (GH.η embase))) ◃∎
=ₛ⟨ =ₛ-in {t = ! (!-inv-r (h₁' embase)) ◃∙
! (ap (λ v → h₁' v ∙ ! (h₁' embase)) (emloop g)) ◃∙
!-inv-r (h₁' embase) ◃∎} $
ap (λ f → ! (!-inv-r (f embase)) ∙
! (ap (λ v → f v ∙ ! (f embase)) (emloop g)) ∙
!-inv-r (f embase))
(! (λ= h₁'-path)) ⟩
! (!-inv-r (h₁' embase)) ◃∙
! (ap (λ v → h₁' v ∙ ! (h₁' embase)) (emloop g)) ◃∙
!-inv-r (h₁' embase) ◃∎ ∎ₛ
transp-nat-idp : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k} (f : A → B → C)
{a₀ a₁ : A} (p : a₀ == a₁) (b : B)
(c : C) (h₀ : ∀ b' → f a₀ b' == c)
→ app= (transp-naturality {B = λ a → ∀ b → f a b == c} (λ h → h b ∙ ! (h b)) p) h₀ ◃∎
=ₛ
!-inv-r (transport (λ a → ∀ b → f a b == c) p h₀ b) ◃∙
! (transp-idp (λ a → f a b) p) ◃∙
ap (transport (λ a → f a b == f a b) p) (! (!-inv-r (h₀ b))) ◃∎
transp-nat-idp f p@idp b c h₀ = !ₛ $
!-inv-r (h₀ b) ◃∙
idp ◃∙
ap (λ r → r) (! (!-inv-r (h₀ b))) ◃∎
=ₛ⟨ 1 & 1 & expand [] ⟩
!-inv-r (h₀ b) ◃∙
ap (λ r → r) (! (!-inv-r (h₀ b))) ◃∎
=ₛ₁⟨ 1 & 1 & ap-idf (! (!-inv-r (h₀ b))) ⟩
!-inv-r (h₀ b) ◃∙
! (!-inv-r (h₀ b)) ◃∎
=ₛ₁⟨ !-inv-r (!-inv-r (h₀ b)) ⟩
idp ◃∎ ∎ₛ
top-part :
ap-comm _G∪H_ (emloop g) (emloop h) ◃∙
ap (_∙ ap (_G∪H embase) (emloop g)) (ap-cst [ north ] (emloop h)) ◃∙
ap (idp ∙_) (GH.ap-cp₁₁-embase g) ◃∎
=ₛ
ap (ap (_G∪H embase) (emloop g) ∙_)
(ap-null-homotopic (λ y → [ north ]₂) h₁ (emloop h)) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_) (!-inv-r (h₁ embase)) ◃∙
ap (_∙ idp) (GH.ap-cp₁₁-embase g) ◃∎
top-part =
ap-comm _G∪H_ (emloop g) (emloop h) ◃∙
ap (_∙ ap (_G∪H embase) (emloop g))
(ap-null-homotopic (λ y → [ north ]₂) (λ y → idp) (emloop' H.grp h)) ◃∙
ap (idp ∙_) (GH.ap-cp₁₁-embase g) ◃∎
=ₛ⟨ 0 & 2 & post-rotate-out {r = _ ◃∙ _ ◃∙ _ ◃∎} $
ap-comm-cst-coh _G∪H_ (emloop g) (emloop h) [ north ]₂ (λ y → idp) ⟩
ap (ap (_G∪H embase) (emloop g) ∙_)
(ap-null-homotopic (λ y → [ north ]₂) h₁ (emloop h)) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_)
(app= (transp-naturality {B = λ x → ∀ y → x G∪H y == [ north ]₂} {C = λ x → x G∪H embase == x G∪H embase}
(λ h → h embase ∙ ! (h embase)) (emloop g))
(λ y → idp)) ◃∙
! (ap-transp (_G∪H embase) (_G∪H embase) (emloop g) idp) ◃∙
ap (idp ∙_) (GH.ap-cp₁₁-embase g) ◃∎
=ₛ⟨ 1 & 1 & ap-seq-=ₛ (ap (_G∪H embase) (emloop g) ∙_)
(transp-nat-idp _G∪H_ (emloop g) embase [ north ]₂ (λ y → idp)) ⟩
ap (ap (_G∪H embase) (emloop g) ∙_)
(ap-null-homotopic (λ y → [ north ]₂) h₁ (emloop h)) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_) (!-inv-r (h₁ embase)) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_)
(! (transp-idp (_G∪H embase) (emloop g))) ◃∙
idp ◃∙
! (ap-transp (_G∪H embase) (_G∪H embase) (emloop g) idp) ◃∙
ap (idp ∙_) (GH.ap-cp₁₁-embase g) ◃∎
=ₛ⟨ 3 & 1 & expand [] ⟩
ap (ap (_G∪H embase) (emloop g) ∙_)
(ap-null-homotopic (λ y → [ north ]₂) h₁ (emloop h)) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_) (!-inv-r (h₁ embase)) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_)
(! (transp-idp (_G∪H embase) (emloop g))) ◃∙
! (ap-transp (_G∪H embase) (_G∪H embase) (emloop g) idp) ◃∙
ap (idp ∙_) (GH.ap-cp₁₁-embase g) ◃∎
=ₛ₁⟨ 2 & 1 & ap-! (ap (_G∪H embase) (emloop g) ∙_) (transp-idp (_G∪H embase) (emloop g)) ⟩
ap (ap (_G∪H embase) (emloop g) ∙_)
(ap-null-homotopic (λ y → [ north ]₂) h₁ (emloop h)) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_) (!-inv-r (h₁ embase)) ◃∙
! (ap (ap (_G∪H embase) (emloop g) ∙_)
(transp-idp (_G∪H embase) (emloop g))) ◃∙
! (ap-transp (_G∪H embase) (_G∪H embase) (emloop g) idp) ◃∙
ap (idp ∙_) (GH.ap-cp₁₁-embase g) ◃∎
=ₛ⟨ 2 & 2 & pre-rotate'-seq-in {p = _ ◃∙ _ ◃∎} {r = []} $
!ₛ $ ap-transp-idp (_G∪H embase) (emloop g) ⟩
ap (ap (_G∪H embase) (emloop g) ∙_)
(ap-null-homotopic (λ y → [ north ]₂) h₁ (emloop h)) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_) (!-inv-r (h₁ embase)) ◃∙
∙-unit-r (ap (_G∪H embase) (emloop g)) ◃∙
ap (idp ∙_) (GH.ap-cp₁₁-embase g) ◃∎
=ₛ⟨ 2 & 2 & !ₛ $ homotopy-naturality (_∙ idp) (idp ∙_) ∙-unit-r (GH.ap-cp₁₁-embase g) ⟩
ap (ap (_G∪H embase) (emloop g) ∙_)
(ap-null-homotopic (λ y → [ north ]₂) h₁ (emloop h)) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_) (!-inv-r (h₁ embase)) ◃∙
ap (_∙ idp) (GH.ap-cp₁₁-embase g) ◃∙
idp ◃∎
=ₛ⟨ 3 & 1 & expand [] ⟩
ap (ap (_G∪H embase) (emloop g) ∙_)
(ap-null-homotopic (λ y → [ north ]₂) h₁ (emloop h)) ◃∙
ap (ap (_G∪H embase) (emloop g) ∙_) (!-inv-r (h₁ embase)) ◃∙
ap (_∙ idp) (GH.ap-cp₁₁-embase g) ◃∎ ∎ₛ
bottom-part :
ap (_∙ idp) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) (! (!-inv-r (h₁' embase))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_)
(! (ap-null-homotopic (λ x → [ north ]₂) h₁' (emloop g))) ◃∎
=ₛ
ap (idp ∙_) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap (_∙ ap (λ y → − (y H∪G embase)) (emloop h)) (! (ap-cst [ north ]₂ (emloop g))) ◃∙
ap-comm (λ x y → − (y H∪G x)) (emloop g) (emloop h) ◃∎
bottom-part =
ap (_∙ idp) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) (! (!-inv-r (h₁' embase))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_)
(! (ap-null-homotopic (λ x → [ north ]₂) h₁' (emloop g))) ◃∎
=ₛ⟨ 0 & 0 & contract ⟩
idp ◃∙
ap (_∙ idp) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) (! (!-inv-r (h₁' embase))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_)
(! (ap-null-homotopic (λ x → [ north ]₂) h₁' (emloop g))) ◃∎
=ₛ⟨ 0 & 2 & !ₛ (homotopy-naturality (idp ∙_) (_∙ idp) (! ∘ ∙-unit-r) (↯ (tail (comm-embase-emloop-seq h)))) ⟩
ap (idp ∙_) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
! (∙-unit-r (ap (λ y → − (y H∪G embase)) (emloop h))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) (! (!-inv-r (h₁' embase))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_)
(! (ap-null-homotopic (λ x → [ north ]₂) h₁' (emloop g))) ◃∎
=ₛ⟨ 1 & 1 & !ₛ $ post-rotate-in {p = _ ◃∙ _ ◃∎} $
ap-transp-idp (λ y → − (y H∪G embase)) (emloop h) ⟩
ap (idp ∙_) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap-transp (λ y → − (y H∪G embase)) (λ y → − (y H∪G embase)) (emloop h) idp ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) (transp-idp (λ y → − (y H∪G embase)) (emloop h)) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) (! (!-inv-r (h₁' embase))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_)
(! (ap-null-homotopic (λ x → [ north ]₂) h₁' (emloop g))) ◃∎
=ₛ⟨ 2 & 2 & ap-seq-=ₛ (ap (λ y → − (y H∪G embase)) (emloop h) ∙_) $
transp-idp (λ y → − (y H∪G embase)) (emloop h) ◃∙
! (!-inv-r (h₁' embase)) ◃∎
=ₛ⟨ pre-rotate-out $ pre-rotate'-in $ post-rotate-in {p = []} $
transp-nat-idp (λ y x → − (y H∪G x)) (emloop h) embase [ north ]₂ (λ x → idp) ⟩
idp ◃∙
! (app= (transp-naturality {B = λ y → ∀ x → − (y H∪G x) == [ north ]₂}
(λ h → h embase ∙ ! (h embase)) (emloop h))
(λ x → idp)) ◃∎
=ₛ⟨ 0 & 1 & expand [] ⟩
! (app= (transp-naturality {B = λ y → ∀ x → − (y H∪G x) == [ north ]₂}
(λ h → h embase ∙ ! (h embase)) (emloop h))
(λ x → idp)) ◃∎ ∎ₛ
⟩
ap (idp ∙_) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap-transp (λ y → − (y H∪G embase)) (λ y → − (y H∪G embase)) (emloop h) idp ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_)
(! (app= (transp-naturality {B = λ y → ∀ x → − (y H∪G x) == [ north ]₂}
(λ h → h embase ∙ ! (h embase)) (emloop h))
(λ x → idp))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_)
(! (ap-null-homotopic (λ x → [ north ]₂) h₁' (emloop g))) ◃∎
=ₛ₁⟨ 2 & 1 & ap-! (ap (λ y → − (y H∪G embase)) (emloop h) ∙_)
(app= (transp-naturality {B = λ y → ∀ x → − (y H∪G x) == [ north ]₂}
(λ h → h embase ∙ ! (h embase)) (emloop h))
(λ x → idp)) ⟩
ap (idp ∙_) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap-transp (λ y → − (y H∪G embase)) (λ y → − (y H∪G embase)) (emloop h) idp ◃∙
! (ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_)
(app= (transp-naturality {B = λ y → ∀ x → − (y H∪G x) == [ north ]₂}
(λ h → h embase ∙ ! (h embase)) (emloop h))
(λ x → idp))) ◃∙
ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_)
(! (ap-null-homotopic (λ x → [ north ]₂) h₁' (emloop g))) ◃∎
=ₛ₁⟨ 3 & 1 & ap-! (ap (λ y → − (y H∪G embase)) (emloop h) ∙_)
(ap-null-homotopic (λ x → [ north ]₂) h₁' (emloop g)) ⟩
ap (idp ∙_) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap-transp (λ y → − (y H∪G embase)) (λ y → − (y H∪G embase)) (emloop h) idp ◃∙
! (ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_)
(app= (transp-naturality {B = λ y → ∀ x → − (y H∪G x) == [ north ]₂}
(λ h → h embase ∙ ! (h embase)) (emloop h))
(λ x → idp))) ◃∙
! (ap (ap (λ y → − (y H∪G embase)) (emloop h) ∙_)
(ap-null-homotopic (λ x → [ north ]₂) h₁' (emloop g))) ◃∎
=ₛ⟨ 1 & 3 & pre-rotate-out $
pre-rotate'-seq-in {p = _ ◃∙ _ ◃∎} $
post-rotate-in {p = []} $
ap-comm-cst-coh (λ y x → − (y H∪G x))
(emloop h) (emloop g) [ north ]₂ (λ x → idp) ⟩
ap (idp ∙_) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
! (ap (_∙ ap (λ y → − (y H∪G embase)) (emloop h))
(ap-null-homotopic (λ x → − (embase H∪G x)) (λ x → idp) (emloop g))) ◃∙
! (ap-comm (λ y x → − (y H∪G x)) (emloop h) (emloop g)) ◃∎
=ₛ₁⟨ 2 & 1 & ! (ap-comm-comm (λ x y → − (y H∪G x)) (emloop g) (emloop h)) ⟩
ap (idp ∙_) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
! (ap (_∙ ap (λ y → − (y H∪G embase)) (emloop h))
(ap-null-homotopic (λ x → − (embase H∪G x)) (λ x → idp) (emloop g))) ◃∙
ap-comm (λ x y → − (y H∪G x)) (emloop g) (emloop h) ◃∎
=ₛ₁⟨ 1 & 1 &
!-ap (_∙ ap (λ y → − (y H∪G embase)) (emloop h))
(ap-null-homotopic (λ x → − (embase H∪G x)) (λ x → idp) (emloop g)) ⟩
ap (idp ∙_) (↯ (tail (comm-embase-emloop-seq h))) ◃∙
ap (_∙ ap (λ y → − (y H∪G embase)) (emloop h)) (! (ap-cst [ north ]₂ (emloop g))) ◃∙
ap-comm (λ x y → − (y H∪G x)) (emloop g) (emloop h) ◃∎ ∎ₛ
step₄' : ! (ap-cst [ north ] (emloop g)) ◃∎
=ₛ
↯ h₁'-seq ◃∙
! (!-inv-r (h₁' embase)) ◃∙
! (ap-null-homotopic (λ x → [ north ]₂) h₁' (emloop g)) ◃∎
step₄' = pre-rotate'-in $ post-rotate-seq-in {p = []} $ !ₛ $
ap-cst [ north ]₂ (emloop g) ◃∙
↯ h₁'-seq ◃∎
=ₛ⟨ 1 & 1 & expand h₁'-seq ⟩
ap-cst [ north ] (emloop g) ◃∙
! (!-inv-r (h₁' embase)) ◃∙
! (ap (λ v → h₁' v ∙ ! (h₁' embase)) (emloop g)) ◃∙
!-inv-r (h₁' embase) ◃∎
=ₛ⟨ 0 & 2 & !ₛ $ post-rotate-in {p = _ ◃∙ _ ◃∎} $
ap-null-homotopic-cst [ north ]₂ [ north ]₂ h₁' (emloop g) ⟩
ap-null-homotopic (cst [ north ]₂) h₁' (emloop g) ◃∙
ap (λ v → h₁' v ∙ ! (h₁' embase)) (emloop g) ◃∙
! (ap (λ v → h₁' v ∙ ! (h₁' embase)) (emloop g)) ◃∙
!-inv-r (h₁' embase) ◃∎
=ₛ⟨ 1 & 2 & seq-!-inv-r (ap (λ v → h₁' v ∙ ! (h₁' embase)) (emloop g) ◃∎) ⟩
ap-null-homotopic (cst [ north ]₂) h₁' (emloop g) ◃∙
!-inv-r (h₁' embase) ◃∎ ∎ₛ
step₁₃' :
ap-null-homotopic (λ y → [ north ]₂) h₁ (emloop h) ◃∙
!-inv-r (h₁ embase) ◃∙
↯ h₁-seq ◃∎
=ₛ
ap-cst [ north ]₂ (emloop h) ◃∎
step₁₃' =
ap-null-homotopic (λ y → [ north ]₂) h₁ (emloop h) ◃∙
!-inv-r (h₁ embase) ◃∙
↯ h₁-seq ◃∎
=ₛ⟨ 2 & 1 & expand h₁-seq ⟩
ap-null-homotopic (λ y → [ north ]₂) h₁ (emloop h) ◃∙
!-inv-r (h₁ embase) ◃∙
! (!-inv-r (h₁ embase)) ◃∙
ap (λ v → h₁ v ∙ ! (h₁ embase)) (emloop h) ◃∙
!-inv-r (h₁ embase) ◃∎
=ₛ⟨ 1 & 2 & seq-!-inv-r (!-inv-r (h₁ embase) ◃∎) ⟩
ap-null-homotopic (λ y → [ north ]₂) h₁ (emloop h) ◃∙
ap (λ v → h₁ v ∙ ! (h₁ embase)) (emloop h) ◃∙
!-inv-r (h₁ embase) ◃∎
=ₛ⟨ ap-null-homotopic-cst [ north ]₂ [ north ]₂ h₁ (emloop h) ⟩
ap-cst [ north ]₂ (emloop h) ◃∎ ∎ₛ
comm-embase-emloop : ∀ h →
Square idp
(ap (embase G∪H_) (emloop h))
(ap (λ y → − (y H∪G embase)) (emloop h))
idp
comm-embase-emloop h = vert-degen-square (comm-embase-emloop' h)
comm-emloop-embase : ∀ g →
Square idp
(ap (_G∪H embase) (emloop g))
(ap (λ x → − (embase H∪G x)) (emloop g))
idp
comm-emloop-embase g = vert-degen-square (comm-emloop-embase' g)
abstract
square-helper : ∀ {i} {A : Type i}
{a a' a'' : A}
{p₀ : a == a'} {q₀ : a' == a''} {r₀ : a == a''}
{p₁ : a == a'} {q₁ : a' == a''} {r₁ : a == a''}
(s : r₀ == p₀ ∙ q₀)
(p : p₀ == p₁)
(q : q₀ == q₁)
(t : p₁ ∙ q₁ == r₁)
→ s ∙v⊡ (vert-degen-square p ⊡h vert-degen-square q) ⊡v∙ t ==
vert-degen-square (s ∙ ap2 _∙_ p q ∙ t)
square-helper s p q t =
s ∙v⊡ (vert-degen-square p ⊡h vert-degen-square q) ⊡v∙ t
=⟨ ap (λ u → s ∙v⊡ u ⊡v∙ t) (vert-degen-square-⊡h p q) ⟩
s ∙v⊡ vert-degen-square (ap2 _∙_ p q) ⊡v∙ t
=⟨ ap (s ∙v⊡_) (vert-degen-square-⊡v∙ (ap2 _∙_ p q) t) ⟩
s ∙v⊡ vert-degen-square (ap2 _∙_ p q ∙ t)
=⟨ vert-degen-square-∙v⊡ s (ap2 _∙_ p q ∙ t) ⟩
vert-degen-square (s ∙ ap2 _∙_ p q ∙ t) =∎
comm-embase-emloop-comp : ∀ h₁ h₂ →
comm-embase-emloop (H.comp h₁ h₂) ⊡v∙
ap (ap (λ y → − (y H∪G embase))) (emloop-comp h₁ h₂)
==
ap (ap (embase G∪H_)) (emloop-comp h₁ h₂) ∙v⊡
↓-='-square-comp (comm-embase-emloop h₁) (comm-embase-emloop h₂)
comm-embase-emloop-comp h₁ h₂ =
comm-embase-emloop (H.comp h₁ h₂) ⊡v∙
ap (ap (λ y → − (y H∪G embase))) (emloop-comp h₁ h₂)
=⟨ vert-degen-square-⊡v∙
(comm-embase-emloop' (H.comp h₁ h₂))
(ap (ap (λ y → − (y H∪G embase))) (emloop-comp h₁ h₂)) ⟩
vert-degen-square
(comm-embase-emloop' (H.comp h₁ h₂) ∙
ap (ap (λ y → − (y H∪G embase))) (emloop-comp h₁ h₂))
=⟨ ap vert-degen-square (=ₛ-out (comm-embase-emloop-comp' h₁ h₂)) ⟩
vert-degen-square
(ap (ap (embase G∪H_)) (emloop-comp h₁ h₂) ∙
ap-∙ (embase G∪H_) (emloop h₁) (emloop h₂) ∙
ap2 _∙_ (comm-embase-emloop' h₁) (comm-embase-emloop' h₂) ∙
∙-ap (λ y → − (y H∪G embase)) (emloop h₁) (emloop h₂))
=⟨ ! $ vert-degen-square-∙v⊡ (ap (ap (embase G∪H_)) (emloop-comp h₁ h₂)) _ ⟩
ap (ap (embase G∪H_)) (emloop-comp h₁ h₂) ∙v⊡
vert-degen-square
(ap-∙ (embase G∪H_) (emloop h₁) (emloop h₂) ∙
ap2 _∙_ (comm-embase-emloop' h₁) (comm-embase-emloop' h₂) ∙
∙-ap (λ y → − (y H∪G embase)) (emloop h₁) (emloop h₂))
=⟨ ap (ap (ap (embase G∪H_)) (emloop-comp h₁ h₂) ∙v⊡_) $ ! $
square-helper (ap-∙ (embase G∪H_) (emloop h₁) (emloop h₂))
(comm-embase-emloop' h₁) (comm-embase-emloop' h₂)
(∙-ap (λ y → − (y H∪G embase)) (emloop h₁) (emloop h₂)) ⟩
ap (ap (embase G∪H_)) (emloop-comp h₁ h₂) ∙v⊡
↓-='-square-comp' (comm-embase-emloop h₁) (comm-embase-emloop h₂)
=⟨ ap (ap (ap (embase G∪H_)) (emloop-comp h₁ h₂) ∙v⊡_) $
↓-='-square-comp'=↓-='-square-comp (comm-embase-emloop h₁)
(comm-embase-emloop h₂) ⟩
ap (ap (embase G∪H_)) (emloop-comp h₁ h₂) ∙v⊡
↓-='-square-comp (comm-embase-emloop h₁) (comm-embase-emloop h₂) =∎
comm-emloop-comp-embase : ∀ g₁ g₂ →
comm-emloop-embase (G.comp g₁ g₂) ⊡v∙
ap (ap (λ x → − (embase H∪G x))) (emloop-comp g₁ g₂)
==
ap (ap (_G∪H embase)) (emloop-comp g₁ g₂) ∙v⊡
↓-='-square-comp (comm-emloop-embase g₁) (comm-emloop-embase g₂)
comm-emloop-comp-embase g₁ g₂ =
comm-emloop-embase (G.comp g₁ g₂) ⊡v∙
ap (ap (λ x → − (embase H∪G x))) (emloop-comp g₁ g₂)
=⟨ vert-degen-square-⊡v∙
(comm-emloop-embase' (G.comp g₁ g₂))
(ap (ap (λ x → − (embase H∪G x))) (emloop-comp g₁ g₂)) ⟩
vert-degen-square
(comm-emloop-embase' (G.comp g₁ g₂) ∙
ap (ap (λ x → − (embase H∪G x))) (emloop-comp g₁ g₂))
=⟨ ap vert-degen-square (=ₛ-out (comm-emloop-comp-embase' g₁ g₂)) ⟩
vert-degen-square
(ap (ap (_G∪H embase)) (emloop-comp g₁ g₂) ∙
ap-∙ (_G∪H embase) (emloop g₁) (emloop g₂) ∙
ap2 _∙_ (comm-emloop-embase' g₁) (comm-emloop-embase' g₂) ∙
∙-ap (λ x → − (embase H∪G x)) (emloop g₁) (emloop g₂))
=⟨ ! $ vert-degen-square-∙v⊡ (ap (ap (_G∪H embase)) (emloop-comp g₁ g₂)) _ ⟩
ap (ap (_G∪H embase)) (emloop-comp g₁ g₂) ∙v⊡
vert-degen-square
(ap-∙ (_G∪H embase) (emloop g₁) (emloop g₂) ∙
ap2 _∙_ (comm-emloop-embase' g₁) (comm-emloop-embase' g₂) ∙
∙-ap (λ x → − (embase H∪G x)) (emloop g₁) (emloop g₂))
=⟨ ap (ap (ap (_G∪H embase)) (emloop-comp g₁ g₂) ∙v⊡_) $ ! $
square-helper
(ap-∙ (_G∪H embase) (emloop g₁) (emloop g₂))
(comm-emloop-embase' g₁) (comm-emloop-embase' g₂)
(∙-ap (λ x → − (embase H∪G x)) (emloop g₁) (emloop g₂)) ⟩
ap (ap (_G∪H embase)) (emloop-comp g₁ g₂) ∙v⊡
↓-='-square-comp' (comm-emloop-embase g₁) (comm-emloop-embase g₂)
=⟨ ap (ap (ap (_G∪H embase)) (emloop-comp g₁ g₂) ∙v⊡_) $
↓-='-square-comp'=↓-='-square-comp
(comm-emloop-embase g₁) (comm-emloop-embase g₂) ⟩
ap (ap (_G∪H embase)) (emloop-comp g₁ g₂) ∙v⊡
↓-='-square-comp (comm-emloop-embase g₁) (comm-emloop-embase g₂) =∎
comm-emloop-emloop : ∀ g h →
ap-comm _G∪H_ (emloop g) (emloop h) ∙v⊡
comm-embase-emloop h ⊡h comm-emloop-embase g
==
(comm-emloop-embase g ⊡h comm-embase-emloop h) ⊡v∙
ap-comm (λ x y → − (y H∪G x)) (emloop g) (emloop h)
comm-emloop-emloop g h =
ap-comm _G∪H_ (emloop g) (emloop h) ∙v⊡
comm-embase-emloop h ⊡h comm-emloop-embase g
=⟨ ap (ap-comm _G∪H_ (emloop g) (emloop h) ∙v⊡_) $
vert-degen-square-⊡h (comm-embase-emloop' h) (comm-emloop-embase' g) ⟩
ap-comm _G∪H_ (emloop g) (emloop h) ∙v⊡
vert-degen-square (ap2 _∙_ (comm-embase-emloop' h) (comm-emloop-embase' g))
=⟨ vert-degen-square-∙v⊡ (ap-comm _G∪H_ (emloop g) (emloop h)) _ ⟩
vert-degen-square
(ap-comm _G∪H_ (emloop g) (emloop h) ∙
ap2 _∙_ (comm-embase-emloop' h) (comm-emloop-embase' g))
=⟨ ap vert-degen-square (=ₛ-out (comm-emloop-emloop' g h)) ⟩
vert-degen-square
(ap2 _∙_ (comm-emloop-embase' g) (comm-embase-emloop' h) ∙
ap-comm (λ x y → − (y H∪G x)) (emloop g) (emloop h))
=⟨ ! $ vert-degen-square-⊡v∙ _ (ap-comm (λ x y → − (y H∪G x)) (emloop g) (emloop h)) ⟩
vert-degen-square (ap2 _∙_ (comm-emloop-embase' g) (comm-embase-emloop' h)) ⊡v∙
ap-comm (λ x y → − (y H∪G x)) (emloop g) (emloop h)
=⟨ ap (_⊡v∙ ap-comm (λ x y → − (y H∪G x)) (emloop g) (emloop h)) $ ! $
vert-degen-square-⊡h (comm-emloop-embase' g) (comm-embase-emloop' h) ⟩
(comm-emloop-embase g ⊡h comm-embase-emloop h) ⊡v∙
ap-comm (λ x y → − (y H∪G x)) (emloop g) (emloop h) =∎
module CP₁₁Comm =
EM₁Level₂DoublePathElim G.grp H.grp {C = EMExplicit.EM G⊗H.abgroup 2} {{Trunc-level}}
_G∪H_
(λ x y → − (y H∪G x))
idp
comm-embase-emloop
comm-emloop-embase
comm-embase-emloop-comp
comm-emloop-comp-embase
comm-emloop-emloop
abstract
cp₁₁-comm : ∀ x y → x G∪H y == − (y H∪G x)
cp₁₁-comm = CP₁₁Comm.f
|
{
"alphanum_fraction": 0.4541751127,
"avg_line_length": 52.3305870237,
"ext": "agda",
"hexsha": "057438c70b95713f6d3e69e7790e650cf10ced25",
"lang": "Agda",
"max_forks_count": 50,
"max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z",
"max_forks_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "AntoineAllioux/HoTT-Agda",
"max_forks_repo_path": "theorems/cohomology/CupProduct/OnEM/CommutativityInLowDegrees.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "AntoineAllioux/HoTT-Agda",
"max_issues_repo_path": "theorems/cohomology/CupProduct/OnEM/CommutativityInLowDegrees.agda",
"max_line_length": 123,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "1037d82edcf29b620677a311dcfd4fc2ade2faa6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "AntoineAllioux/HoTT-Agda",
"max_stars_repo_path": "theorems/cohomology/CupProduct/OnEM/CommutativityInLowDegrees.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z",
"num_tokens": 23601,
"size": 50813
}
|
module EqBase where
import PolyDepPrelude
open PolyDepPrelude using
( Bool; true; false; _&&_
; Unit; unit
; Pair; pair
; Either; left; right
; Absurd
; Datoid; datoid; pElem
; True )
-- import And
And = Pair
-- import Sigma
data Sigma (A : Set)(B : A -> Set) : Set where
si : (a : A) -> (b : B a) -> Sigma A B
Eq : Set -> Set -> Set
Eq a b = a -> b -> Bool
eqEmpty : Eq Absurd Absurd
eqEmpty () -- empty
eqUnit : Eq Unit Unit
eqUnit unit unit = true
eqPair : {A1 A2 B1 B2 : Set} ->
(Eq A1 A2) ->
(Eq B1 B2) ->
Eq (And A1 B1) (And A2 B2)
eqPair ea eb (pair a b) (pair a' b') = ea a a' && eb b b'
caseOn : (D : Datoid)
{B1 B2 : pElem D -> Set}
(ifTrue : (b : pElem D) -> B1 b -> B2 b -> Bool)
(a b : pElem D)
(pa : B1 a)
(pb : B2 b)
(e : Bool)
(cast : True e -> B1 a -> B1 b)
-> Bool
caseOn D ifTrue a b pa pb (false) cast = false
caseOn D ifTrue a b pa pb (true) cast = ifTrue b (cast unit pa) pb
eqEither : {A1 A2 B1 B2 : Set}
(eq1 : A1 -> B1 -> Bool)
(eq2 : A2 -> B2 -> Bool)
-> Either A1 A2 -> Either B1 B2 -> Bool
eqEither eq1 eq2 (left a1) (left b1) = eq1 a1 b1
eqEither eq1 eq2 (right a2) (right b2) = eq2 a2 b2
eqEither eq1 eq2 _ _ = false
{-
case x of {
(inl x') ->
case y of {
(inl x0) -> eq1 x' x0;
(inr y') -> false@_;};
(inr y') ->
case y of {
(inl x') -> false@_;
(inr y0) -> eq2 y' y0;};}
-}
{-
eqSigma2 (D : Datoid)
(|B1 |B2 : pElem D -> Set)
(ifTrue : (b : pElem D) -> Eq (B1 b) (B2 b))
(x : Sigma pElem D B1)
(y : Sigma pElem D B2)
: Bool
= case x of {
(si a pa) ->
case y of {
(si b pb) ->
caseOn D ifTrue a b pa pb (D.eq a b) (D.subst B1);};}
eqSigma (D : Datoid)(|B1 : (a : pElem D) -> Set)(|B2 : (a : pElem D) -> Set)
: ((a : pElem D) -> Eq (B1 a) (B2 a)) ->
Eq (Sigma pElem D B1) (Sigma pElem D B2)
= eqSigma2 D
-- More readable but less useful definition of eqSigma :
eqSigmaLocalLet (D : Datoid)
(|B1 |B2 : pElem D -> Set)
(ifTrue : (b : pElem D) -> Eq (B1 b) (B2 b))
(x : Sigma pElem D B1)
(y : Sigma pElem D B2)
: Bool
= case x of {
(si a pa) ->
case y of {
(si b pb) ->
let caseOn (e : Bool)(cast : True e -> B1 a -> B1 b) : Bool
= case e of {
(false) -> false@_;
(true) -> ifTrue b (cast tt@_ pa) pb;}
in caseOn (D.eq a b) (D.subst B1);};}
eqSum' (D : Datoid)
(|B1 |B2 : (a : pElem D) -> Set)
: ((a : pElem D) -> Eq (B1 a) (B2 a)) ->
Eq (Sum pElem D B1) (Sum pElem D B2)
= \(e : (a : pElem D) -> Eq (B1 a) (B2 a)) ->
\(p1 : Sum pElem D B1) ->
\(p2 : Sum pElem D B2) ->
caseOn D e p1.fst p2.fst p1.snd p2.snd (D.eq p1.fst p2.fst)
(D.subst B1)
eqSum : (D : Datoid)
{B1 B2 : (a : pElem D) -> Set}
-> ((a : pElem D) -> Eq (B1 a) (B2 a)) ->
Eq (Sum pElem D B1) (Sum pElem D B2)
eqSum e p1 p2 =
caseOn D e p1.fst p2.fst p1.snd p2.snd (D.eq p1.fst p2.fst)
(D.subst B1)
-}
|
{
"alphanum_fraction": 0.4492882562,
"avg_line_length": 27.6393442623,
"ext": "agda",
"hexsha": "42b3a0ad353652ce5968a53664713b71ac2e4331",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "examples/AIM5/PolyDep/EqBase.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "examples/AIM5/PolyDep/EqBase.agda",
"max_line_length": 76,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "examples/AIM5/PolyDep/EqBase.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 1260,
"size": 3372
}
|
open import Data.Nat hiding (_^_)
open import Data.List as List hiding (null)
open import Data.List.Membership.Propositional
open import Data.List.Relation.Unary.Any
open import Data.List.Relation.Unary.All
open import Data.List.Prefix
open import Data.Product hiding (map)
open import Data.Unit
open import Relation.Binary.PropositionalEquality hiding ([_])
open ≡-Reasoning
-- This file contains the definition of monads used for computation in
-- the definitional interpreter for MJ using scopes and frames,
-- described in Section 5 of the paper.
module MJSF.Monad (k : ℕ) where
open import MJSF.Syntax k
open import MJSF.Values k
open import ScopesFrames.ScopesFrames k Ty
module MonadG (g : Graph) where
open SyntaxG g
open ValuesG g
open UsesVal Valᵗ valᵗ-weaken renaming (getFrame to getFrame')
open import Common.Weakening
-- Computations may either time out, raise a null-pointer exception,
-- or successfully terminate to produce a result:
data Res (a : Set) : Set where
timeout : Res a
nullpointer : Res a
ok : (x : a) → Res a
-- The monad is similar to the monad used for STLCSF, except it uses
-- `Res` instead of `Maybe`:
M : (s : Scope) → (List Scope → Set) → List Scope → Set
M s p Σ = Frame s Σ → Heap Σ → Res (∃ λ Σ' → (Heap Σ' × p Σ' × Σ ⊑ Σ'))
-- We define some usual monad operations:
return : ∀ {s Σ}{p : List Scope → Set} → p Σ → M s p Σ
return v f h = ok (_ , h , v , ⊑-refl)
fmap : ∀ {A B : List Scope → Set}{Γ Σ} → (∀ {Σ} → A Σ → B Σ) → M Γ A Σ → M Γ B Σ
fmap g m f h
with (m f h)
... | timeout = timeout
... | nullpointer = nullpointer
... | ok (Σ' , h' , v' , ext') = ok (Σ' , h' , g v' , ext')
join : ∀ {A : List Scope → Set}{Γ Σ} → M Γ (M Γ A) Σ → M Γ A Σ
join m f h
with (m f h)
... | timeout = timeout
... | nullpointer = nullpointer
... | ok (Σ' , h' , m' , ext')
with (m' (wk ext' f) h')
... | timeout = timeout
... | nullpointer = nullpointer
... | ok (Σ'' , h'' , v'' , ext'') = ok ((Σ'' , h'' , v'' , ext' ⊚ ext''))
_>>=_ : ∀ {s Σ}{p q : List Scope → Set} →
M s p Σ → (∀ {Σ'} → p Σ' → M s q Σ') → M s q Σ
(a >>= b) = join (fmap b a)
-- To program in dependent-passing style, we use the variant of
-- monadic strength also used for STLCSF.
_^_ : ∀ {Σ Γ}{p q : List Scope → Set} ⦃ w : Weakenable q ⦄ →
M Γ p Σ → q Σ → M Γ (p ⊗ q) Σ
(a ^ x) f h
with (a f h)
... | timeout = timeout
... | nullpointer = nullpointer
... | ok (Σ , h' , v , ext) = ok (Σ , h' , (v , wk ext x) , ext)
-- The remaining definitions in this file are straightforward
-- monadic liftings of the coercion function from `MJSF.Values` and
-- of the frame operations.
getFrame : ∀ {s Σ} → M s (Frame s) Σ
getFrame f = return f f
usingFrame : ∀ {s s' Σ}{p : List Scope → Set} → Frame s Σ → M s p Σ → M s' p Σ
usingFrame f a _ = a f
timeoutᴹ : ∀ {s Σ}{p : List Scope → Set} → M s p Σ
timeoutᴹ _ _ = timeout
raise : ∀ {s Σ}{p : List Scope → Set} → M s p Σ
raise _ _ = nullpointer
init : ∀ {Σ s' ds es} → (s : Scope) → ⦃ shape : g s ≡ (ds , es) ⦄ →
Slots ds Σ → Links es Σ → M s' (Frame s) Σ
init {Σ} s slots links _ h
with (initFrame s slots links h)
... | (f' , h') = ok (_ , h' , f' , ∷ʳ-⊒ s Σ)
initι : ∀ {Σ s' ds es} → (s : Scope) → ⦃ shape : g s ≡ (ds , es) ⦄ →
(Frame s (Σ ∷ʳ s) → Slots ds (Σ ∷ʳ s)) → Links es Σ → M s' (Frame s) Σ
initι {Σ} s slots links _ h
with (initFrameι s slots links h)
... | (f' , h') = ok (_ , h' , f' , ∷ʳ-⊒ s Σ)
getv : ∀ {s t Σ} → (s ↦ t) → M s (Valᵗ t) Σ
getv p f h = return (getVal p f h) f h
getf : ∀ {s s' Σ} → (s ⟶ s') → M s (Frame s') Σ
getf p f h = return (getFrame' p f h) f h
getd : ∀ {s t Σ} → t ∈ declsOf s → M s (Valᵗ t) Σ
getd d f h = return (getSlot d f h) f h
getl : ∀ {s s' Σ} → s' ∈ edgesOf s → M s (Frame s') Σ
getl e f h = return (getLink e f h) f h
setd : ∀ {s t Σ} → t ∈ declsOf s → Valᵗ t Σ → M s (λ _ → ⊤) Σ
setd d v f h with (setSlot d v f h)
... | h' = return tt f h'
setv : ∀ {s t Σ} → (s ↦ t) → Valᵗ t Σ → M s (λ _ → ⊤) Σ
setv p v f h with (setVal p v f h)
... | h' = return tt f h'
|
{
"alphanum_fraction": 0.5460926533,
"avg_line_length": 33.390625,
"ext": "agda",
"hexsha": "d2c89a2e632b649cc310182622bf5720c6464005",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "metaborg/mj.agda",
"max_forks_repo_path": "src/MJSF/Monad.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z",
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "metaborg/mj.agda",
"max_issues_repo_path": "src/MJSF/Monad.agda",
"max_line_length": 85,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "metaborg/mj.agda",
"max_stars_repo_path": "src/MJSF/Monad.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z",
"num_tokens": 1686,
"size": 4274
}
|
module Haskell.RangedSetsProp.RangedSetProperties where
open import Haskell.RangedSetsProp.library
open import Haskell.RangedSetsProp.RangesProperties
open import Agda.Builtin.Equality
open import Agda.Builtin.Bool
open import Haskell.Prim
open import Haskell.Prim.Ord
open import Haskell.Prim.Bool
open import Haskell.Prim.Maybe
open import Haskell.Prim.Enum
open import Haskell.Prim.Eq
open import Haskell.Prim.List
open import Haskell.Prim.Integer
open import Haskell.Prim.Double
open import Haskell.Prim.Foldable
open import Haskell.RangedSets.Boundaries
open import Haskell.RangedSets.Ranges
open import Haskell.RangedSets.RangedSet
prop_empty : ⦃ o : Ord a ⦄ → ⦃ d : DiscreteOrdered a ⦄ → (v : a)
→ (not (rSetHas rSetEmpty {empty ⦃ o ⦄ ⦃ d ⦄} v)) ≡ true
prop_empty v = refl
prop_full : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (v : a) → (rSetHas rSetFull {full0 ⦃ o ⦄ ⦃ dio ⦄} v) ≡ true
prop_full v = refl
prop_validNormalised : ⦃ o : Ord a ⦄ → ⦃ d : DiscreteOrdered a ⦄ → (ls : List (Range a))
→ (validRangeList (normaliseRangeList ls)) ≡ true
prop_validNormalised ⦃ o ⦄ ⦃ dio ⦄ [] = refl
prop_validNormalised ⦃ o ⦄ ⦃ dio ⦄ ls@(r1 ∷ rs) =
begin
(validRangeList (normaliseRangeList ls))
=⟨⟩
(validRangeList (normalise (sort (filter (λ r → (rangeIsEmpty r) == false) ls)) ⦃ sortedList ls ⦄ ⦃ validRangesList ls ⦄))
=⟨ propIsTrue (validRangeList (normalise (sort (filter (λ r → (rangeIsEmpty r) == false) ls)) ⦃ sortedList ls ⦄ ⦃ validRangesList ls ⦄))
(normalisedSortedList (sort (filter (λ r → (rangeIsEmpty r) == false) ls)) (sortedList ls) (validRangesList ls)) ⟩
true
end
postulate
rangeSetCreation : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs : RSet a)
→ {prf : IsTrue (validRangeList (rSetRanges rs))} → (RS ⦃ o ⦄ ⦃ dio ⦄ (rSetRanges rs) {prf}) ≡ rs
rangesEqiv : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄
→ {rs1 rs2 : RSet a} → rSetRanges rs1 ≡ rSetRanges rs2 → rs1 ≡ rs2
rangesEqiv2 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄
→ {rs1 rs2 : List (Range a)}
→ (prf1 : IsTrue (sortedRangeList rs1)) → (prf2 : IsTrue (validRanges rs1))
→ (prf3 : IsTrue (sortedRangeList rs2)) → (prf4 : IsTrue (validRanges rs2))
→ rs1 ≡ rs2 → normalise rs1 ⦃ prf1 ⦄ ⦃ prf2 ⦄ ≡ normalise rs2 ⦃ prf3 ⦄ ⦃ prf4 ⦄
singletonRangeSetHas : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (r : Range a) → (v : a)
→ {prf : IsTrue (validRangeList (r ∷ []))}
→ (rSetHas (RS (r ∷ []) {prf}) {prf} v) ≡ rangeHas r v
singletonRangeSetHas r v {prf} =
begin
(rSetHas (RS (r ∷ []) {prf}) {prf} v)
=⟨⟩
rangeHas r v
end
rSetHasHelper : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → a → (rs : List (Range a)) → {prf : IsTrue (validRangeList rs)} → Bool
rSetHasHelper ⦃ o ⦄ ⦃ dio ⦄ value rs {prf} = rSetHas ⦃ o ⦄ ⦃ dio ⦄ (RS rs {prf}) {prf} value
-- rangeHasSym : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (r : Range a) → (rs : RSet a) → (v : a)
-- → {prf1 : IsTrue (validRangeList (r ∷ (rSetRanges rs)))}
-- → (rSetHas (RS (r ∷ (rSetRanges rs)) {prf1}) {prf1} v) ≡
-- ((rangeHas r v) || (rSetHas rs {headandtail (RS (r ∷ (rSetRanges rs)) {prf1}) prf1} v))
-- rangeHasSym ⦃ o ⦄ ⦃ dio ⦄ r rs@(RS []) v {prf1} =
-- begin
-- (rSetHas (RS (r ∷ []) {prf1}) {prf1} v)
-- =⟨⟩
-- (rangeHas r v)
-- =⟨ sym (prop_or_false2 (rangeHas r v)) ⟩
-- ((rangeHas r v) || false)
-- =⟨⟩
-- ((rangeHas r v) || (rSetHas (RS [] {empty ⦃ o ⦄ ⦃ dio ⦄}) {empty ⦃ o ⦄ ⦃ dio ⦄} v))
-- end
-- rangeHasSym ⦃ o ⦄ ⦃ d ⦄ r rs@(RS ranges@(r1 ∷ r2) {prf}) v {prf1} =
-- begin
-- ((RS (r ∷ (rSetRanges rs)) {prf1}) -?- v)
-- =⟨⟩
-- ((rangeHas r v) || (rSetHas (RS (rSetRanges rs) {headandtail (RS (r ∷ (rSetRanges rs)) {prf1}) prf1}) v))
-- =⟨ cong ((rangeHas r v) ||_) (cong (rSetHasHelper v) (rangesEqiv refl)) ⟩
-- ((rangeHas r v) || (rSetHas rs v))
-- end
postulate
-- the following postulates hold when the boundaries are ordered
emptyIntersection : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (b1 b2 b3 : Boundary a)
→ IsFalse (rangeIsEmpty (rangeIntersection (Rg b2 b3) (Rg b1 b2)) == false)
emptyIntersection2 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (b1 b2 b3 : Boundary a)
→ IsFalse (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 b3)) == false)
orderedBoundaries2 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (b1 b2 : Boundary a)
→ IsFalse (b2 < b1)
-- used for easing the proofs, the true value should be IsTrue (b1 <= b2)
orderedBoundaries3 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (b1 b2 : Boundary a)
→ IsTrue (b1 < b2)
{-# TERMINATING #-}
lemma0 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs : RSet a)
→ {prf : IsTrue (validRangeList (rSetRanges rs))}
→ (ranges1 (bounds1 (rSetRanges rs))) ≡ (rSetRanges rs)
lemma0 ⦃ o ⦄ ⦃ dio ⦄ rs@(RS []) {_} =
begin
(ranges1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ (rSetRanges rs)))
=⟨⟩
(ranges1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ []))
=⟨⟩
(ranges1 ⦃ o ⦄ ⦃ dio ⦄ [])
=⟨⟩
[]
=⟨⟩
rSetRanges rs
end
lemma0 ⦃ o ⦄ ⦃ dio ⦄ rs@(RS (r@(Rg l u) ∷ rgs)) {prf} =
begin
(ranges1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ (rSetRanges rs)))
=⟨⟩
(ranges1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ (r ∷ rgs)))
=⟨⟩
(ranges1 ⦃ o ⦄ ⦃ dio ⦄ ((rangeLower ⦃ o ⦄ ⦃ dio ⦄ r) ∷ ((rangeUpper ⦃ o ⦄ ⦃ dio ⦄ r) ∷ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ rgs))))
=⟨⟩
((Rg l u) ∷ ranges1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ rgs))
=⟨⟩
(r ∷ ranges1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ rgs))
=⟨ cong (r ∷_) (lemma0 ⦃ o ⦄ ⦃ dio ⦄ (RS rgs {headandtail rs prf}) {headandtail rs prf}) ⟩
(r ∷ rgs)
=⟨⟩
rSetRanges rs
end
rangeEmpty : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (x : Boundary a) → rangeIsEmpty (Rg x x) ≡ true
rangeEmpty ⦃ o ⦄ ⦃ dio ⦄ BoundaryBelowAll = refl
rangeEmpty ⦃ o ⦄ ⦃ dio ⦄ BoundaryAboveAll = refl
rangeEmpty ⦃ o ⦄ ⦃ dio ⦄ b@(BoundaryBelow m) =
begin
rangeIsEmpty (Rg b b)
=⟨⟩
((BoundaryBelow m) <= (BoundaryBelow m))
=⟨⟩
((compare b b == LT) || (compare b b == EQ))
=⟨⟩
((compare m m == LT) || (compare m m == EQ))
=⟨ cong ((compare m m == LT) ||_) (eq4 ⦃ o ⦄ refl) ⟩
((compare m m == LT) || true)
=⟨⟩
((compare m m == LT) || true)
=⟨ prop_or_false3 (compare m m == LT) ⟩
true
end
rangeEmpty ⦃ o ⦄ ⦃ dio ⦄ b@(BoundaryAbove m) =
begin
rangeIsEmpty (Rg b b)
=⟨⟩
((BoundaryBelow m) <= (BoundaryBelow m))
=⟨⟩
((compare b b == LT) || (compare b b == EQ))
=⟨⟩
((compare m m == LT) || (compare m m == EQ))
=⟨ cong ((compare m m == LT) ||_) (eq4 ⦃ o ⦄ refl) ⟩
((compare m m == LT) || true)
=⟨⟩
((compare m m == LT) || true)
=⟨ prop_or_false3 (compare m m == LT) ⟩
true
end
merge2Empty : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (bs : List (Boundary a)) → ⦃ ne : NonEmpty bs ⦄
→ filter (λ x → rangeIsEmpty x == false) (merge2 (ranges1 (tail bs ⦃ ne ⦄)) (ranges1 bs)) ≡ []
merge2Empty2 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (bs : List (Boundary a)) → ⦃ ne : NonEmpty bs ⦄
→ filter (λ x → rangeIsEmpty x == false) (merge2 (ranges1 bs) (ranges1 (tail bs ⦃ ne ⦄))) ≡ []
merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b@(BoundaryAboveAll) ∷ []) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b ∷ [])) (ranges1 []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 [] [])
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []
=⟨⟩
[]
end
merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b@(BoundaryAbove x) ∷ []) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b ∷ [])) (ranges1 []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b BoundaryAboveAll) ∷ []) [])
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []
=⟨⟩
[]
end
merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b@(BoundaryBelow x) ∷ []) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b ∷ [])) (ranges1 []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b BoundaryAboveAll) ∷ []) [])
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []
=⟨⟩
[]
end
merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b@(BoundaryBelowAll) ∷ []) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b ∷ [])) (ranges1 []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b BoundaryAboveAll) ∷ []) [])
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []
=⟨⟩
[]
end
merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryAboveAll) ∷ []) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b1 ∷ b2 ∷ [])) (ranges1 (b2 ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ (ranges1 [])) [])
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []
=⟨⟩
[]
end
merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryAboveAll) ∷ bs@(b3 ∷ bss)) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b1 ∷ b2 ∷ bs)) (ranges1 (b2 ∷ bs)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ (ranges1 bs)) ((Rg b2 b3) ∷ (ranges1 bss)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3))
∷ (if_then_else_ (b2 < b3) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))) (merge2 (ranges1 bounds) (ranges1 bss))))
=⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷_)
(propIf2 (b2 < b3) (orderedBoundaries3 ⦃ o ⦄ ⦃ dio ⦄ b2 b3))) ⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3))
∷ (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))))
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 b3)) == false)
((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs)))))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))))
=⟨ propIf3' ⦃ o ⦄ {((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs)))))}
{(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))))}
(rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 b3)) == false) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ b1 b2 b3) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))))
=⟨ merge2Empty ⦃ o ⦄ ⦃ dio ⦄ (b2 ∷ bs) ⟩ -- induction here!!!! merge2Empty ..
[]
end
merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryBelowAll) ∷ []) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b1 ∷ b2 ∷ [])) (ranges1 (b2 ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ (ranges1 [])) ((Rg b2 BoundaryAboveAll) ∷ []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ []) ((Rg b2 BoundaryAboveAll) ∷ []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll))
∷ (if_then_else_ (b2 < BoundaryAboveAll) (merge2 [] ((Rg b2 BoundaryAboveAll) ∷ [])) (merge2 ((Rg b1 b2) ∷ []) [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll))
∷ (if_then_else_ false (merge2 [] ((Rg b2 BoundaryAboveAll) ∷ [])) (merge2 ((Rg b1 b2) ∷ []) [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll))
∷ (merge2 ((Rg b1 b2) ∷ []) []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll))
∷ [])
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) == false)
((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨ propIf3 ((rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) == false)) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ b1 b2 BoundaryAboveAll) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨⟩
[]
end
merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryBelowAll) ∷ bs@(b3 ∷ bss)) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b1 ∷ b2 ∷ bs)) (ranges1 (b2 ∷ bs)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ (ranges1 bs)) ((Rg b2 b3) ∷ (ranges1 bss)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3))
∷ (if_then_else_ (b2 < b3) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))) (merge2 ((Rg b1 b2) ∷ (ranges1 bs)) (ranges1 bss) )))
=⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷_)
(propIf2 (b2 < b3) (orderedBoundaries3 ⦃ o ⦄ ⦃ dio ⦄ b2 b3))) ⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3))
∷ (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))))
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 b3)) == false)
((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs)))))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))))
=⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 b3)) == false) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ b1 b2 b3) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))))
=⟨ merge2Empty ⦃ o ⦄ ⦃ dio ⦄ (b2 ∷ bs) ⟩ -- induction here!!!! merge2Empty ..
[]
end
merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryAbove x) ∷ []) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b1 ∷ b2 ∷ [])) (ranges1 (b2 ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ (ranges1 [])) ((Rg b2 BoundaryAboveAll) ∷ []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ []) ((Rg b2 BoundaryAboveAll) ∷ []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll))
∷ (if_then_else_ (b2 < BoundaryAboveAll) (merge2 [] ((Rg b2 BoundaryAboveAll) ∷ [])) (merge2 ((Rg b1 b2) ∷ []) [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll))
∷ (if_then_else_ true (merge2 [] ((Rg b2 BoundaryAboveAll) ∷ [])) (merge2 ((Rg b1 b2) ∷ []) [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll))
∷ (merge2 [] ((Rg b2 BoundaryAboveAll) ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll))
∷ [])
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) == false)
((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨ propIf3 ((rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) == false)) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ b1 b2 BoundaryAboveAll) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨⟩
[]
end
merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryAbove x) ∷ bs@(b3 ∷ bss)) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b1 ∷ b2 ∷ bs)) (ranges1 (b2 ∷ bs)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ (ranges1 bs)) ((Rg b2 b3) ∷ (ranges1 bss)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3))
∷ (if_then_else_ (b2 < b3) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))) (merge2 ((Rg b1 b2) ∷ (ranges1 bs)) (ranges1 bss))))
=⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷_)
(propIf2 (b2 < b3) (orderedBoundaries3 ⦃ o ⦄ ⦃ dio ⦄ b2 b3))) ⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3))
∷ (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))))
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 b3)) == false)
((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs)))))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))))
=⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 b3)) == false) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ b1 b2 b3) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))))
=⟨ merge2Empty ⦃ o ⦄ ⦃ dio ⦄ (b2 ∷ bs) ⟩ -- induction here!!!! merge2Empty ..
[]
end
merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryBelow x) ∷ []) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b1 ∷ b2 ∷ [])) (ranges1 (b2 ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ (ranges1 [])) ((Rg b2 BoundaryAboveAll) ∷ []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ []) ((Rg b2 BoundaryAboveAll) ∷ []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll))
∷ (if_then_else_ (b2 < BoundaryAboveAll) (merge2 [] ((Rg b2 BoundaryAboveAll) ∷ [])) (merge2 ((Rg b1 b2) ∷ []) [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll))
∷ (if_then_else_ true (merge2 [] ((Rg b2 BoundaryAboveAll) ∷ [])) (merge2 ((Rg b1 b2) ∷ []) [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll))
∷ (merge2 [] ((Rg b2 BoundaryAboveAll) ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll))
∷ [])
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) == false)
((rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨ propIf3 ((rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 BoundaryAboveAll)) == false)) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ b1 b2 BoundaryAboveAll) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨⟩
[]
end
merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryBelow x) ∷ bs@(b3 ∷ bss)) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bounds) (ranges1 (tail bounds ⦃ ne ⦄)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b1 ∷ b2 ∷ bs)) (ranges1 (b2 ∷ bs)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b1 b2) ∷ (ranges1 bs)) ((Rg b2 b3) ∷ (ranges1 bss)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3))
∷ (if_then_else_ (b2 < b3) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))) (merge2 ((Rg b1 b2) ∷ (ranges1 bs)) (ranges1 bss))))
=⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷_)
(propIf2 (b2 < b3) (orderedBoundaries3 ⦃ o ⦄ ⦃ dio ⦄ b2 b3))) ⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b1 b2) (Rg b2 b3))
∷ (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))))
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 b3)) == false)
((rangeIntersection (Rg b1 b2) (Rg b2 b3)) ∷
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs)))))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))))
=⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg b1 b2) (Rg b2 b3)) == false) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ b1 b2 b3) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b2 ∷ bs))))
=⟨ merge2Empty ⦃ o ⦄ ⦃ dio ⦄ (b2 ∷ bs) ⟩ -- induction here!!!! merge2Empty ..
[]
end
merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b@(BoundaryBelowAll) ∷ []) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 []) (ranges1 (b ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 [] (ranges1 (b ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []
=⟨⟩
[]
end
merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b@(BoundaryBelow x) ∷ []) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 []) (ranges1 (b ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 [] (ranges1 (b ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []
=⟨⟩
[]
end
merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b@(BoundaryAbove x) ∷ []) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 []) (ranges1 (b ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 [] (ranges1 (b ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []
=⟨⟩
[]
end
merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b@(BoundaryAboveAll) ∷ []) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 []) (ranges1 (b ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 [] (ranges1 (b ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []
=⟨⟩
[]
end
merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryAboveAll) ∷ []) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ [])) (ranges1 (b1 ∷ b2 ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 [] ((Rg b1 b2) ∷ (ranges1 [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []
=⟨⟩
[]
end
merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryAboveAll) ∷ bs@(b3 ∷ bss)) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 (b1 ∷ b2 ∷ bs)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 b3) ∷ (ranges1 bss)) ((Rg b1 b2) ∷ (ranges1 bs)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2))
∷ (if_then_else_ (b3 < b2) (merge2 (ranges1 bss) ((Rg b1 b2) ∷ (ranges1 bs))) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))))
=⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷_)
(propIf3 (b3 < b2) (orderedBoundaries2 ⦃ o ⦄ ⦃ dio ⦄ b2 b3))) ⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2))
∷ (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b2 b3) (Rg b1 b2)) == false)
((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))
=⟨ propIf3' ⦃ o ⦄ {((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))))}
{(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))}
(rangeIsEmpty (rangeIntersection (Rg b2 b3) (Rg b1 b2)) == false) (emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ b1 b2 b3) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))
=⟨ merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ (b2 ∷ bs) ⟩ -- induction here!!!! merge2Empty ..
[]
end
merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryBelowAll) ∷ []) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ [])) (ranges1 (b1 ∷ b2 ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) ((Rg b1 b2) ∷ (ranges1 [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) ((Rg b1 b2) ∷ []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2))
∷ (if_then_else_ (BoundaryAboveAll < b2) (merge2 [] ((Rg b1 b2) ∷ [])) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2))
∷ (if_then_else_ false (merge2 [] ((Rg b1 b2) ∷ [])) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2))
∷ (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2))
∷ [])
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) == false)
((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨ propIf3 ((rangeIsEmpty (rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) == false)) (emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ b1 b2 BoundaryAboveAll) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨⟩
[]
end
merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryBelowAll) ∷ bs@(b3 ∷ bss)) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 (b1 ∷ b2 ∷ bs)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 b3) ∷ (ranges1 bss)) ((Rg b1 b2) ∷ (ranges1 bs)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2))
∷ (if_then_else_ (b3 < b2) (merge2 (ranges1 bss) ((Rg b1 b2) ∷ (ranges1 bs))) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))))
=⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷_)
(propIf3 (b3 < b2) (orderedBoundaries2 ⦃ o ⦄ ⦃ dio ⦄ b2 b3))) ⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2))
∷ (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b2 b3) (Rg b1 b2)) == false)
((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))
=⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg b2 b3) (Rg b1 b2)) == false)(emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ b1 b2 b3) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))
=⟨ merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ (b2 ∷ bs) ⟩ -- induction here!!!! merge2Empty ..
[]
end
merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryAbove x) ∷ []) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ [])) (ranges1 (b1 ∷ b2 ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) ((Rg b1 b2) ∷ (ranges1 [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) ((Rg b1 b2) ∷ []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2))
∷ (if_then_else_ (BoundaryAboveAll < b2) (merge2 [] ((Rg b1 b2) ∷ [])) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2))
∷ (if_then_else_ false (merge2 [] ((Rg b1 b2) ∷ [])) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2))
∷ (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2))
∷ [])
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) == false)
((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨ propIf3 ((rangeIsEmpty (rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) == false)) (emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ b1 b2 BoundaryAboveAll) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨⟩
[]
end
merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryAbove x) ∷ bs@(b3 ∷ bss)) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 (b1 ∷ b2 ∷ bs)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 b3) ∷ (ranges1 bss)) ((Rg b1 b2) ∷ (ranges1 bs)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2))
∷ (if_then_else_ (b3 < b2) (merge2 (ranges1 bss) ((Rg b1 b2) ∷ (ranges1 bs))) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))))
=⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷_)
(propIf3 (b3 < b2) (orderedBoundaries2 ⦃ o ⦄ ⦃ dio ⦄ b2 b3))) ⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2))
∷ (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b2 b3) (Rg b1 b2)) == false)
((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))
=⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg b2 b3) (Rg b1 b2)) == false)(emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ b1 b2 b3) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))
=⟨ merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ (b2 ∷ bs) ⟩ -- induction here!!!! merge2Empty ..
[]
end
merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryBelow x) ∷ []) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ [])) (ranges1 (b1 ∷ b2 ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) ((Rg b1 b2) ∷ (ranges1 [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) ((Rg b1 b2) ∷ []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2))
∷ (if_then_else_ (BoundaryAboveAll < b2) (merge2 [] ((Rg b1 b2) ∷ [])) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2))
∷ (if_then_else_ false (merge2 [] ((Rg b1 b2) ∷ [])) (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2))
∷ (merge2 ((Rg b2 BoundaryAboveAll) ∷ []) []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2))
∷ [])
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) == false)
((rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨ propIf3 ((rangeIsEmpty (rangeIntersection (Rg b2 BoundaryAboveAll) (Rg b1 b2)) == false)) (emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ b1 b2 BoundaryAboveAll) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨⟩
[]
end
merge2Empty ⦃ o ⦄ ⦃ dio ⦄ bounds@(b1 ∷ b2@(BoundaryBelow x) ∷ bs@(b3 ∷ bss)) ⦃ ne ⦄ =
begin
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (tail bounds ⦃ ne ⦄)) (ranges1 bounds))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 (b1 ∷ b2 ∷ bs)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b2 b3) ∷ (ranges1 bss)) ((Rg b1 b2) ∷ (ranges1 bs)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2))
∷ (if_then_else_ (b3 < b2) (merge2 (ranges1 bss) ((Rg b1 b2) ∷ (ranges1 bs))) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))))
=⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (cong ((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷_)
(propIf3 (b3 < b2) (orderedBoundaries2 ⦃ o ⦄ ⦃ dio ⦄ b2 b3))) ⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b2 b3) (Rg b1 b2))
∷ (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b2 b3) (Rg b1 b2)) == false)
((rangeIntersection (Rg b2 b3) (Rg b1 b2)) ∷
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs))))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))
=⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg b2 b3) (Rg b1 b2)) == false)(emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ b1 b2 b3) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 (b2 ∷ bs)) (ranges1 bs)))
=⟨ merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ (b2 ∷ bs) ⟩ -- induction here!!!! merge2Empty ..
[]
end
lemma2 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (bs : List (Boundary a))
→ (filter (λ x → rangeIsEmpty x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs)))) ≡ []
lemma2 ⦃ o ⦄ ⦃ dio ⦄ [] =
begin
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 []) (ranges1 (setBounds1 []))))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 [] (ranges1 (BoundaryBelowAll ∷ []))))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 [] ((Rg BoundaryBelowAll BoundaryAboveAll) ∷ [])))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨⟩
[]
end
lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(BoundaryBelowAll ∷ []) =
begin
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs))))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg BoundaryBelowAll BoundaryAboveAll) ∷ []) (ranges1 (setBounds1 (BoundaryBelowAll ∷ [])))))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg BoundaryBelowAll BoundaryAboveAll) ∷ []) (ranges1 [])))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg BoundaryBelowAll BoundaryAboveAll) ∷ []) []))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨⟩
[]
end
lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(BoundaryAboveAll ∷ []) =
begin
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)(merge2 (ranges1 bs) (ranges1 (setBounds1 bs))))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 [] (ranges1 (setBounds1 (BoundaryAboveAll ∷ [])))))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨⟩
[]
end
lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(b@(BoundaryBelow x) ∷ []) =
begin
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs))))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b BoundaryAboveAll) ∷ []) (ranges1 (setBounds1 ((BoundaryBelow x) ∷ [])))))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b BoundaryAboveAll) ∷ []) (ranges1 (BoundaryBelowAll ∷ (b ∷ [])))))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b BoundaryAboveAll) ∷ []) ((Rg BoundaryBelowAll b) ∷ [])))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ (if_then_else_ (BoundaryAboveAll < b) (merge2 [] ((Rg BoundaryBelowAll b) ∷ [])) (merge2 ((Rg b BoundaryAboveAll) ∷ []) []))))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ (if_then_else_ false (merge2 [] ((Rg BoundaryBelowAll b) ∷ [])) (merge2 ((Rg b BoundaryAboveAll) ∷ []) []))))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ (merge2 ((Rg b BoundaryAboveAll) ∷ []) [])))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ []))
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) == false)
((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) == false) (emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ BoundaryBelowAll b BoundaryAboveAll) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨⟩
[]
end
lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(b@(BoundaryAbove x) ∷ []) =
begin
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs))))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b BoundaryAboveAll) ∷ []) (ranges1 (setBounds1 (b ∷ [])))))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b BoundaryAboveAll) ∷ []) (ranges1 (BoundaryBelowAll ∷ (b ∷ [])))))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg b BoundaryAboveAll) ∷ []) ((Rg BoundaryBelowAll b) ∷ [])))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ (if_then_else_ (BoundaryAboveAll < b) (merge2 [] ((Rg BoundaryBelowAll b) ∷ [])) (merge2 ((Rg b BoundaryAboveAll) ∷ []) []))))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ (if_then_else_ false (merge2 [] ((Rg BoundaryBelowAll b) ∷ [])) (merge2 ((Rg b BoundaryAboveAll) ∷ []) []))))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ (merge2 ((Rg b BoundaryAboveAll) ∷ []) [])))
=⟨⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ []))
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) == false)
((rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg b BoundaryAboveAll) (Rg BoundaryBelowAll b)) == false) (emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ BoundaryBelowAll b BoundaryAboveAll) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨⟩
[]
end
lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(a@(BoundaryAboveAll) ∷ (b ∷ bss)) =
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bss)) (ranges1 (setBounds1 (a ∷ (b ∷ bss)))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bss)) (ranges1 (BoundaryBelowAll ∷ (a ∷ (b ∷ bss)))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bss)) ((Rg BoundaryBelowAll a) ∷ ranges1 (b ∷ bss)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a))
∷ (if_then_else_ (b < a) (merge2 (ranges1 bss) (ranges1 (setBounds1 bs))) (merge2 (ranges1 bs) (ranges1 (b ∷ bss)))))
=⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false))
(cong ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) ∷_) (propIf3 (b < a) (orderedBoundaries2 ⦃ o ⦄ ⦃ dio ⦄ a b))) ⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a))
∷ (merge2 (ranges1 bs) (ranges1 (b ∷ bss))))
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) == false)
((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a))
∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss)))))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss))))
=⟨ propIf3' ⦃ o ⦄
{((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a))
∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss)))))}
{(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss))))}
(rangeIsEmpty (rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) == false)
(emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ BoundaryBelowAll a b) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss))))
=⟨ merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bs ⟩
[]
end
lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(a@(BoundaryBelow x) ∷ (b ∷ bss)) =
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bss)) (ranges1 (setBounds1 (a ∷ (b ∷ bss)))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bss)) (ranges1 (BoundaryBelowAll ∷ (a ∷ (b ∷ bss)))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bss)) ((Rg BoundaryBelowAll a) ∷ ranges1 (b ∷ bss)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a))
∷ (if_then_else_ (b < a) (merge2 (ranges1 bss) (ranges1 (setBounds1 bs))) (merge2 (ranges1 bs) (ranges1 (b ∷ bss)))))
=⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false))
(cong ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) ∷_) (propIf3 (b < a) (orderedBoundaries2 ⦃ o ⦄ ⦃ dio ⦄ a b))) ⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a))
∷ (merge2 (ranges1 bs) (ranges1 (b ∷ bss))))
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) == false)
((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a))
∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss)))))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss))))
=⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) == false)
(emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ BoundaryBelowAll a b) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss))))
=⟨ merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bs ⟩
[]
end
lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(a@(BoundaryAbove x) ∷ (b ∷ bss)) =
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bss)) (ranges1 (setBounds1 (a ∷ (b ∷ bss)))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bss)) (ranges1 (BoundaryBelowAll ∷ (a ∷ (b ∷ bss)))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bss)) ((Rg BoundaryBelowAll a) ∷ ranges1 (b ∷ bss)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a))
∷ (if_then_else_ (b < a) (merge2 (ranges1 bss) (ranges1 (setBounds1 bs))) (merge2 (ranges1 bs) (ranges1 (b ∷ bss)))))
=⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false))
(cong ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) ∷_) (propIf3 (b < a) (orderedBoundaries2 ⦃ o ⦄ ⦃ dio ⦄ a b))) ⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a))
∷ (merge2 (ranges1 bs) (ranges1 (b ∷ bss))))
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) == false)
((rangeIntersection (Rg a b) (Rg BoundaryBelowAll a))
∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss)))))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss))))
=⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg a b) (Rg BoundaryBelowAll a)) == false)
(emptyIntersection ⦃ o ⦄ ⦃ dio ⦄ BoundaryBelowAll a b) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (b ∷ bss))))
=⟨ merge2Empty2 ⦃ o ⦄ ⦃ dio ⦄ bs ⟩
[]
end
lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(a@(BoundaryBelowAll) ∷ b ∷ bs2@(c ∷ bss)) =
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bs2)) (ranges1 (b ∷ bs2)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 bs2)) ((Rg b c) ∷ (ranges1 bss)))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b c))
∷ (if_then_else_ (b < c) (merge2 (ranges1 bs2) (ranges1 (b ∷ bs2))) (merge2 (ranges1 bs) (ranges1 bss))))
=⟨ cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false))
(cong ((rangeIntersection (Rg a b) (Rg b c)) ∷_) (propIf2 (b < c) (orderedBoundaries3 ⦃ o ⦄ ⦃ dio ⦄ b c))) ⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b c))
∷ (merge2 (ranges1 bs2) (ranges1 (b ∷ bs2))))
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg a b) (Rg b c)) == false)
((rangeIntersection (Rg a b) (Rg b c)) ∷
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs2) (ranges1 (b ∷ bs2)))))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs2) (ranges1 (b ∷ bs2))))
=⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg a b) (Rg b c)) == false) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ a b c) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs2) (ranges1 (b ∷ bs2))))
=⟨ merge2Empty ⦃ o ⦄ ⦃ dio ⦄ (b ∷ bs2) ⟩
[]
end
lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(a@(BoundaryBelowAll) ∷ b@(BoundaryAboveAll) ∷ []) =
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 [])) (ranges1 (setBounds1 (a ∷ b ∷ []))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)(merge2 ((Rg a b) ∷ []) (ranges1 (b ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ []) [])
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []
=⟨⟩
[]
end
lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(a@(BoundaryBelowAll) ∷ b@(BoundaryBelowAll) ∷ []) =
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 [])) (ranges1 (setBounds1 (a ∷ b ∷ []))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ []) (ranges1 (b ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ []) ((Rg b BoundaryAboveAll) ∷ []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll))
∷ (if_then_else_ (b < BoundaryAboveAll) (merge2 [] (ranges1 (setBounds1 bs))) (merge2 (ranges1 bs) [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll))
∷ (if_then_else_ true (merge2 [] (ranges1 (setBounds1 bs))) (merge2 (ranges1 bs) [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll))
∷ (merge2 [] (ranges1 (setBounds1 bs))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ [])
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) == false)
((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨ propIf3' ⦃ o ⦄
{((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []))}
{(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []) }
(rangeIsEmpty (rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) == false) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ a b BoundaryAboveAll) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨⟩
[]
end
lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(a@(BoundaryBelowAll) ∷ b@(BoundaryAbove x) ∷ []) =
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 [])) (ranges1 (setBounds1 (a ∷ b ∷ []))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ []) (ranges1 (b ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ []) ((Rg b BoundaryAboveAll) ∷ []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll))
∷ (if_then_else_ (b < BoundaryAboveAll) (merge2 [] (ranges1 (setBounds1 bs))) (merge2 (ranges1 bs) [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll))
∷ (if_then_else_ true (merge2 [] (ranges1 (setBounds1 bs))) (merge2 (ranges1 bs) [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll))
∷ (merge2 [] (ranges1 (setBounds1 bs))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ [])
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) == false)
((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) == false) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ a b BoundaryAboveAll) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨⟩
[]
end
lemma2 ⦃ o ⦄ ⦃ dio ⦄ bs@(a@(BoundaryBelowAll) ∷ b@(BoundaryBelow x) ∷ []) =
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 bs) (ranges1 (setBounds1 bs))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ (ranges1 [])) (ranges1 (setBounds1 (a ∷ b ∷ []))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ []) (ranges1 (b ∷ [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ((Rg a b) ∷ []) ((Rg b BoundaryAboveAll) ∷ []))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll))
∷ (if_then_else_ (b < BoundaryAboveAll) (merge2 [] (ranges1 (setBounds1 bs))) (merge2 (ranges1 bs) [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll))
∷ (if_then_else_ true (merge2 [] (ranges1 (setBounds1 bs))) (merge2 (ranges1 bs) [])))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll))
∷ (merge2 [] (ranges1 (setBounds1 bs))))
=⟨⟩
filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) ((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ [])
=⟨⟩
if_then_else_ (rangeIsEmpty (rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) == false)
((rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) ∷ (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) []))
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨ propIf3 (rangeIsEmpty (rangeIntersection (Rg a b) (Rg b BoundaryAboveAll)) == false) (emptyIntersection2 ⦃ o ⦄ ⦃ dio ⦄ a b BoundaryAboveAll) ⟩
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) [])
=⟨⟩
[]
end
merge2' : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → List (Range a) → List (Range a) → List (Range a)
merge2' ms1 ms2 = merge2 ms2 ms1
prop_empty_intersection : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs : RSet a)
→ {prf : IsTrue (validRangeList (rSetRanges rs))} →
rSetIsEmpty (rSetIntersection rs {prf} (rSetNegation rs {prf}) {negation2 rs (negation rs prf)}) ≡ true
prop_empty_intersection ⦃ o ⦄ ⦃ dio ⦄ rs@(RS ranges) {prf} =
begin
rSetIsEmpty (rSetIntersection rs {prf} (rSetNegation rs {prf}) {negation2 rs {prf} (negation rs prf)})
=⟨⟩
rSetIsEmpty (rSetIntersection rs {prf}
(RS (ranges1 ⦃ o ⦄ ⦃ dio ⦄ (setBounds1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ ranges))) {negation rs prf})
{negation2 rs {prf} (negation rs prf)} )
=⟨⟩
rSetIsEmpty (RS (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)
(merge2 ranges (ranges1 ⦃ o ⦄ ⦃ dio ⦄ (setBounds1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ ranges)))))
{intersection0 rs (RS (ranges1 (setBounds1 (bounds1 ranges))) {negation rs prf}) prf (negation rs prf)})
=⟨⟩
rangesAreEmpty (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ranges (ranges1 ⦃ o ⦄ ⦃ dio ⦄ (setBounds1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ ranges)))))
=⟨ cong rangesAreEmpty (cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false))
(cong (merge2' (ranges1 ⦃ o ⦄ ⦃ dio ⦄ (setBounds1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ ranges)))) (sym (lemma0 rs {prf})))) ⟩
rangesAreEmpty (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 (ranges1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ ranges))
(ranges1 ⦃ o ⦄ ⦃ dio ⦄ (setBounds1 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ ranges)))))
=⟨ cong rangesAreEmpty (lemma2 ⦃ o ⦄ ⦃ dio ⦄ (bounds1 ⦃ o ⦄ ⦃ dio ⦄ ranges)) ⟩
rangesAreEmpty ⦃ o ⦄ ⦃ dio ⦄ []
=⟨⟩
true
end
prop_subset : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs : RSet a)
→ {prf : IsTrue (validRangeList (rSetRanges rs))} → rSetIsSubset rs {prf} rs {prf} ≡ true
prop_subset ⦃ o ⦄ ⦃ dio ⦄ rs {prf} =
begin
rSetIsSubset rs {prf} rs {prf}
=⟨⟩
rSetIsEmpty (rSetDifference rs {prf} rs {prf})
=⟨⟩
rSetIsEmpty (rSetIntersection rs {prf} (rSetNegation rs {prf}) {negation2 rs (negation rs prf)})
=⟨ prop_empty_intersection ⦃ o ⦄ ⦃ dio ⦄ rs {prf} ⟩
true
end
prop_strictSubset : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs : RSet a)
→ {prf : IsTrue (validRangeList (rSetRanges rs))} → rSetIsSubsetStrict rs {prf} rs {prf} ≡ false
prop_strictSubset ⦃ o ⦄ ⦃ dio ⦄ rs {prf} =
begin
rSetIsSubsetStrict rs {prf} rs {prf}
=⟨⟩
rSetIsEmpty (rSetDifference rs {prf} rs {prf}) && (not (rSetIsEmpty (rSetDifference rs {prf} rs {prf})))
=⟨⟩
rSetIsEmpty (rSetIntersection rs {prf} (rSetNegation rs {prf}) {negation2 rs (negation rs prf)})
&& (not (rSetIsEmpty (rSetDifference rs {prf} rs {prf})))
=⟨ cong (_&& (not (rSetIsEmpty (rSetDifference rs {prf} rs {prf})))) (prop_empty_intersection ⦃ o ⦄ ⦃ dio ⦄ rs {prf}) ⟩
true && (not (rSetIsEmpty (rSetIntersection rs {prf} (rSetNegation rs {prf}) {negation2 rs (negation rs prf)})))
=⟨⟩
(not (rSetIsEmpty (rSetIntersection rs {prf} (rSetNegation rs {prf}) {negation2 rs (negation rs prf)})))
=⟨ cong not (prop_empty_intersection ⦃ o ⦄ ⦃ dio ⦄ rs {prf}) ⟩
not true
=⟨⟩
false
end
-- prop_union : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 : RSet a) → (rs2 : RSet a)
-- → {prf1 : IsTrue (validRangeList (rSetRanges rs1))} → {prf2 : IsTrue (validRangeList (rSetRanges rs2))}
-- → (v : a) → (rSetHas rs1 {prf1} v || rSetHas rs2 {prf2} v) ≡
-- (rSetHas (rSetUnion rs1 {prf1} rs2 {prf2}) {union2 rs1 rs2 prf1 prf2 (unionn rs1 rs2 prf1 prf2)} v)
-- prop_union ⦃ o ⦄ ⦃ dio ⦄ rs1@(RS []) rs2@(RS []) {prf1} {prf2} v =
-- begin
-- (rSetHas rs1 {prf1} v || rSetHas rs2 {prf2} v)
-- =⟨⟩
-- (false || false)
-- =⟨⟩
-- false
-- =⟨⟩
-- (rSetHas (RS [] {empty ⦃ o ⦄ ⦃ dio ⦄}) {empty ⦃ o ⦄ ⦃ dio ⦄} v)
-- =⟨⟩
-- (rSetHas (rSetUnion rs1 {prf1} rs2 {prf2}) {unionn rs1 rs2 prf1 prf2} v)
-- end
-- prop_union ⦃ o ⦄ ⦃ dio ⦄ rs1@(RS []) rs2@(RS rg1@(r1 ∷ rss1)) {prf1} {prf2} v =
-- begin
-- (rSetHas rs1 {prf1} v || rSetHas rs2 {prf2} v)
-- =⟨⟩
-- (false || rSetHas rs2 {prf2} v)
-- =⟨⟩
-- rSetHas rs2 {prf2} v
-- =⟨⟩
-- (rSetHas (rSetUnion rs1 {prf1} rs2 {prf2}) {unionn rs1 rs2 prf1 prf2} v)
-- end
-- prop_union ⦃ o ⦄ ⦃ dio ⦄ rs1@(RS rg@(r1 ∷ rss1)) rs2@(RS []) {prf1} {prf2} v =
-- begin
-- (rSetHas rs1 {prf1} v || rSetHas rs2 {prf2} v)
-- =⟨⟩
-- (rSetHas rs1 {prf1} v || false)
-- =⟨ prop_or_false2 (rSetHas rs1 {prf1} v) ⟩
-- (rSetHas rs1 {prf1} v)
-- =⟨⟩
-- (rSetHas (rSetUnion rs1 {prf1} rs2 {prf2}) {unionn rs1 rs2 prf1 prf2} v)
-- end
-- prop_union ⦃ o ⦄ ⦃ dio ⦄ rs1@(RS rg1@(r1 ∷ rss1)) rs2@(RS rg2@(r2 ∷ rss2)) {prf1} {prf2} v =
-- begin
-- (rSetHas rs1 {prf1} v || rSetHas rs2 {prf2} v)
-- =⟨ cong (_|| (rSetHas rs2 {prf2} v)) (rangeHasSym r1 (RS rss1 {headandtail rs1 prf1}) v {prf1}) ⟩
-- (((rangeHas r1 v) || (rSetHas (RS rss1 {headandtail rs1 prf1}) {headandtail rs1 prf1} v)) || (rSetHas rs2 {prf2} v))
-- =⟨ prop_or_assoc (rangeHas r1 v) (rSetHas (RS rss1 {headandtail rs1 prf1}) {headandtail rs1 prf1} v) (rSetHas rs2 {prf2} v) ⟩
-- ((rangeHas r1 v) || (rSetHas (RS rss1 {headandtail rs1 prf1}) {headandtail rs1 prf1} v) || (rSetHas rs2 {prf2} v))
-- =⟨ cong ((rangeHas r1 v) ||_) (prop_union (RS rss1) rs2 {headandtail rs1 prf1} {prf2} v) ⟩
-- ((rangeHas r1 v) ||
-- (rSetHas (rSetUnion (RS rss1) {headandtail rs1 prf1} rs2 {prf2})
-- {(union2 (RS rss1) rs2 (headandtail rs1 prf1) prf2 (unionn (RS rss1) rs2 (headandtail rs1 prf1) prf2))} v))
-- =⟨ sym (rangeHasSym r1 (rSetUnion (RS rss1) {headandtail rs1 prf1} rs2 {prf2}) v
-- {union2 (RS rss1) rs2 (headandtail rs1 prf1) prf2 (unionn (RS rss1) rs2 (headandtail rs1 prf1) prf2)}) ⟩
-- RS (r1 ∷ (rSetRanges ((RS rss1) -\/- rs2))) -?- v
-- =⟨ cong (_-?- v) (cong RS (union0 r1 (RS rss1) rs2)) ⟩
-- RS (rSetRanges ((RS (r1 ∷ rss1)) -\/- rs2)) -?- v
-- =⟨ cong (_-?- v) (sym (rangeSetCreation ((RS (r1 ∷ rss1)) -\/- rs2))) ⟩
-- (rSetHas (rSetUnion rs1 {prf1} rs2 {prf2}) {union2 rs1 rs2 prf1 prf2 (unionn rs1 rs2 prf1 prf2)} v)
-- end
-- prop_union_has_sym : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄
-- → (rs1 : RSet a) → (rs2 : RSet a) → (v : a)
-- → ((rs1 -\/- rs2) -?- v) ≡ ((rs2 -\/- rs1) -?- v)
-- prop_union_has_sym ⦃ o ⦄ ⦃ dio ⦄ rs1@(RS ranges1) rs2@(RS ranges2) v =
-- begin
-- ((rs1 -\/- rs2) -?- v)
-- =⟨ sym (prop_union rs1 rs2 v) ⟩
-- ((rs1 -?- v) || (rs2 -?- v))
-- =⟨ prop_or_sym (rs1 -?- v) (rs2 -?- v) ⟩
-- ((rs2 -?- v) || (rs1 -?- v))
-- =⟨ prop_union rs2 rs1 v ⟩
-- ((rs2 -\/- rs1) -?- v)
-- end
-- prop_union_same_set : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 : RSet a) → (v : a) → ((rs1 -\/- rs1) -?- v) ≡ (rs1 -?- v)
-- prop_union_same_set ⦃ o ⦄ ⦃ dio ⦄ rs1@(RS ranges1) v =
-- begin
-- ((rs1 -\/- rs1) -?- v)
-- =⟨ sym (prop_union rs1 rs1 v) ⟩
-- ((rs1 -?- v) || (rs1 -?- v))
-- =⟨ prop_or_same_value (rs1 -?- v) ⟩
-- (rs1 -?- v)
-- end
prop_validNormalisedEmpty : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → validRangeList ⦃ o ⦄ ⦃ dio ⦄ (normaliseRangeList ⦃ o ⦄ ⦃ dio ⦄ []) ≡ true
prop_validNormalisedEmpty ⦃ o ⦄ ⦃ dio ⦄ =
begin
validRangeList ⦃ o ⦄ ⦃ dio ⦄ (normaliseRangeList ⦃ o ⦄ ⦃ dio ⦄ [])
=⟨⟩
validRangeList ⦃ o ⦄ ⦃ dio ⦄ []
=⟨⟩
true
end
postulate
-- these postulates hold when r1 == r2 does not hold, used for easing the proofs for union/intersection commutes
equalityRanges : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (r1 : Range a) → (r2 : Range a)
→ (r1 < r2) ≡ (not (r2 < r1))
equalityRanges2 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (r1 : Range a) → (r2 : Range a)
→ (rangeUpper r1 < rangeUpper r2) ≡ (not (rangeUpper r2 < rangeUpper r1))
prop_sym_merge1' : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 : List (Range a)) → (rs2 : List (Range a))
→ ⦃ ne1 : NonEmpty rs1 ⦄ → ⦃ ne2 : NonEmpty rs2 ⦄ → (b : Bool)
→ if_then_else_ b ((head rs1 ⦃ ne1 ⦄) ∷ (merge1 (tail rs1 ⦃ ne1 ⦄) rs2)) ((head rs2 ⦃ ne2 ⦄) ∷ (merge1 rs1 (tail rs2 ⦃ ne2 ⦄))) ≡
if_then_else_ (not b) ((head rs2 ⦃ ne2 ⦄) ∷ (merge1 (tail rs2 ⦃ ne2 ⦄) rs1)) ((head rs1 ⦃ ne1 ⦄) ∷ (merge1 rs2 (tail rs1 ⦃ ne1 ⦄)))
prop_sym_merge1 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 : List (Range a)) → (rs2 : List (Range a))
→ merge1 rs1 rs2 ≡ merge1 rs2 rs1
prop_sym_merge1 ⦃ o ⦄ ⦃ dio ⦄ [] [] = refl
prop_sym_merge1 ⦃ o ⦄ ⦃ dio ⦄ ms1@(h1 ∷ t1) [] = refl
prop_sym_merge1 ⦃ o ⦄ ⦃ dio ⦄ [] ms2@(h2 ∷ t2) = refl
prop_sym_merge1 ⦃ o ⦄ ⦃ dio ⦄ ms1@(h1 ∷ t1) ms2@(h2 ∷ t2) =
begin
merge1 ms1 ms2
=⟨⟩
if_then_else_ (h1 < h2) (h1 ∷ (merge1 t1 ms2)) (h2 ∷ (merge1 ms1 t2))
=⟨ prop_sym_merge1' ⦃ o ⦄ ⦃ dio ⦄ ms1 ms2 (h1 < h2) ⟩
if_then_else_ (not (h1 < h2)) (h2 ∷ (merge1 t2 ms1)) (h1 ∷ (merge1 ms2 t1))
=⟨ cong (ifThenElseHelper (h2 ∷ (merge1 t2 ms1)) (h1 ∷ (merge1 ms2 t1))) (sym (equalityRanges h2 h1)) ⟩
if_then_else_ (h2 < h1) (h2 ∷ (merge1 t2 ms1)) (h1 ∷ (merge1 ms2 t1))
=⟨⟩
merge1 ms2 ms1
end
prop_sym_merge1' ⦃ o ⦄ ⦃ dio ⦄ ms1@(h1 ∷ t1) ms2@(h2 ∷ t2) true =
begin
if_then_else_ true (h1 ∷ (merge1 t1 ms2)) (h2 ∷ (merge1 ms1 t2))
=⟨⟩
(h1 ∷ (merge1 t1 ms2))
=⟨ cong (h1 ∷_) (prop_sym_merge1 ⦃ o ⦄ ⦃ dio ⦄ t1 ms2) ⟩
(h1 ∷ (merge1 ms2 t1))
=⟨⟩
if_then_else_ false (h2 ∷ (merge1 t2 ms1)) (h1 ∷ (merge1 ms2 t1))
end
prop_sym_merge1' ⦃ o ⦄ ⦃ dio ⦄ ms1@(h1 ∷ t1) ms2@(h2 ∷ t2) false =
begin
if_then_else_ false (h1 ∷ (merge1 t1 ms2)) (h2 ∷ (merge1 ms1 t2))
=⟨⟩
(h2 ∷ (merge1 ms1 t2))
=⟨ cong (h2 ∷_) (prop_sym_merge1 ⦃ o ⦄ ⦃ dio ⦄ ms1 t2) ⟩
(h2 ∷ (merge1 t2 ms1))
=⟨⟩
if_then_else_ true (h2 ∷ (merge1 t2 ms1)) (h1 ∷ (merge1 ms2 t1))
end
prop_sym_sortedRangeList : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (ls1 ls2 : List (Range a))
→ (sortedRangeList (merge1 ls1 ls2)) ≡ (sortedRangeList (merge1 ls2 ls1))
prop_sym_sortedRangeList ⦃ o ⦄ ⦃ dio ⦄ ls1 ls2 = (cong sortedRangeList (prop_sym_merge1 ls1 ls2))
prop_sym_validRanges : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (ls1 ls2 : List (Range a))
→ (validRanges (merge1 ls1 ls2)) ≡ (validRanges (merge1 ls2 ls1))
prop_sym_validRanges ⦃ o ⦄ ⦃ dio ⦄ ls1 ls2 = (cong validRanges (prop_sym_merge1 ls1 ls2))
prop_union_commutes : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 : RSet a) → (rs2 : RSet a)
→ {prf1 : IsTrue (validRangeList (rSetRanges rs1))} → {prf2 : IsTrue (validRangeList (rSetRanges rs2))}
→ (rSetUnion rs1 {prf1} rs2 {prf2}) ≡ (rSetUnion rs2 {prf2} rs1 {prf1})
prop_union_commutes (RS []) (RS []) = refl
prop_union_commutes (RS ranges@(r ∷ rs)) (RS []) = refl
prop_union_commutes (RS []) (RS ranges@(r ∷ rs)) = refl
prop_union_commutes ⦃ o ⦄ ⦃ dio ⦄ RS1@(RS ls1@(r1 ∷ rs1)) RS2@(RS ls2@(r2 ∷ rs2)) {prf1} {prf2} =
begin
(rSetUnion RS1 {prf1} RS2 {prf2})
=⟨⟩
RS ⦃ o ⦄ ⦃ dio ⦄ (normalise ⦃ o ⦄ ⦃ dio ⦄ (merge1 ⦃ o ⦄ ⦃ dio ⦄ ls1 ls2) ⦃ merge1Sorted RS1 RS2 prf1 prf2 ⦄
⦃ merge1HasValidRanges RS1 RS2 prf1 prf2 ⦄) {unionHolds RS1 RS2 prf1 prf2}
=⟨ rangesEqiv (rangesEqiv2 (merge1Sorted RS1 RS2 prf1 prf2) (merge1HasValidRanges RS1 RS2 prf1 prf2)
(merge1Sorted RS2 RS1 prf2 prf1) (merge1HasValidRanges RS2 RS1 prf2 prf1) (prop_sym_merge1 ls1 ls2)) ⟩
RS ⦃ o ⦄ ⦃ dio ⦄ (normalise ⦃ o ⦄ ⦃ dio ⦄ (merge1 ⦃ o ⦄ ⦃ dio ⦄ ls2 ls1) ⦃ merge1Sorted RS2 RS1 prf2 prf1 ⦄
⦃ merge1HasValidRanges RS2 RS1 prf2 prf1 ⦄) {unionHolds RS2 RS1 prf2 prf1}
=⟨⟩
(rSetUnion RS2 {prf2} RS1 {prf1})
end
prop_sym_merge2 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 : List (Range a)) → (rs2 : List (Range a))
→ merge2 rs1 rs2 ≡ merge2 rs2 rs1
prop_sym_merge2' : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 : List (Range a)) → (rs2 : List (Range a))
→ ⦃ ne1 : NonEmpty rs1 ⦄ → ⦃ ne2 : NonEmpty rs2 ⦄ → (b : Bool)
→ (if_then_else_ b (merge2 (tail rs1 ⦃ ne1 ⦄) rs2) (merge2 rs1 (tail rs2 ⦃ ne2 ⦄))) ≡
(if_then_else_ (not b) (merge2 (tail rs2 ⦃ ne2 ⦄) rs1) (merge2 rs2 (tail rs1 ⦃ ne1 ⦄)))
prop_sym_merge2' ⦃ o ⦄ ⦃ dio ⦄ ms1@(h1 ∷ t1) ms2@(h2 ∷ t2) true =
begin
(if_then_else_ true (merge2 t1 ms2) (merge2 ms1 t2))
=⟨⟩
(merge2 t1 ms2)
=⟨ prop_sym_merge2 t1 ms2 ⟩
(merge2 ms2 t1)
=⟨⟩
if_then_else_ false (merge2 t2 ms1) (merge2 ms2 t1)
end
prop_sym_merge2' ⦃ o ⦄ ⦃ dio ⦄ ms1@(h1 ∷ t1) ms2@(h2 ∷ t2) false =
begin
(if_then_else_ false (merge2 t1 ms2) (merge2 ms1 t2))
=⟨⟩
(merge2 ms1 t2)
=⟨ prop_sym_merge2 ms1 t2 ⟩
(merge2 t2 ms1)
=⟨⟩
if_then_else_ true (merge2 t2 ms1) (merge2 ms2 t1)
end
prop_sym_merge2 ⦃ o ⦄ ⦃ dio ⦄ [] [] = refl
prop_sym_merge2 ⦃ o ⦄ ⦃ dio ⦄ ms1@(h1 ∷ t1) [] = refl
prop_sym_merge2 ⦃ o ⦄ ⦃ dio ⦄ [] ms2@(h2 ∷ t2) = refl
prop_sym_merge2 ⦃ o ⦄ ⦃ dio ⦄ ms1@(h1 ∷ t1) ms2@(h2 ∷ t2) =
begin
merge2 ms1 ms2
=⟨⟩
(rangeIntersection h1 h2) ∷ (if_then_else_ (rangeUpper h1 < rangeUpper h2) (merge2 t1 ms2) (merge2 ms1 t2))
=⟨ cong ((rangeIntersection h1 h2) ∷_) (prop_sym_merge2' ⦃ o ⦄ ⦃ dio ⦄ ms1 ms2 (rangeUpper h1 < rangeUpper h2)) ⟩
(rangeIntersection h1 h2) ∷ (if_then_else_ (not (rangeUpper h1 < rangeUpper h2)) (merge2 t2 ms1) (merge2 ms2 t1))
=⟨ cong ((rangeIntersection h1 h2) ∷_) (cong (ifThenElseHelper (merge2 t2 ms1) (merge2 ms2 t1)) (sym (equalityRanges2 h2 h1))) ⟩
((rangeIntersection h1 h2) ∷ (if_then_else_ (rangeUpper h2 < rangeUpper h1) (merge2 t2 ms1) (merge2 ms2 t1)))
=⟨ cong (_∷ (if_then_else_ (rangeUpper h2 < rangeUpper h1) (merge2 t2 ms1) (merge2 ms2 t1))) (prop_intersection_sym h1 h2) ⟩
((rangeIntersection h2 h1) ∷ (if_then_else_ (rangeUpper h2 < rangeUpper h1) (merge2 t2 ms1) (merge2 ms2 t1)))
=⟨⟩
merge2 ms2 ms1
end
prop_intersection_commutes : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 : RSet a) → (rs2 : RSet a)
→ {prf1 : IsTrue (validRangeList (rSetRanges rs1))} → {prf2 : IsTrue (validRangeList (rSetRanges rs2))}
→ (rSetIntersection rs1 {prf1} rs2 {prf2}) ≡ (rSetIntersection rs2 {prf2} rs1 {prf1})
prop_intersection_commutes (RS []) (RS []) = refl
prop_intersection_commutes (RS ranges@(r ∷ rs)) (RS []) = refl
prop_intersection_commutes (RS []) (RS ranges@(r ∷ rs)) = refl
prop_intersection_commutes ⦃ o ⦄ ⦃ dio ⦄ rs1@(RS ls1@(r1 ∷ rss1)) rs2@(RS ls2@(r2 ∷ rss2)) {prf1} {prf2} =
begin
(rSetIntersection rs1 {prf1} rs2 {prf2})
=⟨⟩
RS ⦃ o ⦄ ⦃ dio ⦄
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ⦃ o ⦄ ⦃ dio ⦄ ls1 ls2))
{intersection0 rs1 rs2 prf1 prf2}
=⟨ rangesEqiv (cong (filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false)) (prop_sym_merge2 ls1 ls2)) ⟩
RS ⦃ o ⦄ ⦃ dio ⦄
(filter (λ x → rangeIsEmpty ⦃ o ⦄ ⦃ dio ⦄ x == false) (merge2 ⦃ o ⦄ ⦃ dio ⦄ ls2 ls1))
{intersection0 rs2 rs1 prf2 prf1}
=⟨⟩
(rSetIntersection rs2 {prf2} rs1 {prf1})
end
-- if x is strict subset of y, y is not strict subset of x
-- prop_subset_not1 asserts that rSetIsSubstrict x y is true
-- this means that rSetIsEmpty (rSetDifference x y) is true
-- and rSetEmpty (rSetDifference x y) is false
prop_subset_not1 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 rs2 : RSet a)
→ {prf1 : IsTrue (validRangeList (rSetRanges rs1))}
→ {prf2 : IsTrue (validRangeList (rSetRanges rs2))}
-> (a1 : IsTrue (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2})))
-> (a2 : IsTrue (not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))))
→ (rSetIsSubsetStrict rs1 {prf1} rs2 {prf2}) ≡ (not (rSetIsSubsetStrict rs2 {prf2} rs1 {prf1}))
prop_subset_not1 {{ o }} {{ dio }} rs1 rs2 {prf1} {prf2} a1 a2 =
begin
rSetIsSubsetStrict rs1 {prf1} rs2 {prf2}
=⟨⟩
(rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}) && not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1})))
=⟨ not-not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}) && not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))) ⟩
not (not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}) && not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))))
=⟨ cong not (prop_demorgan (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2})) (not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1})))) ⟩
not ((not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) || (not (not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1})))))
=⟨ cong not (cong ((not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) ||_) (sym (not-not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))))) ⟩
not ((not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) || (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1})))
=⟨ cong not (prop_or_sym (not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))) ⟩
not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}) || not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2})))
=⟨ cong not (prop_or_and_eqiv_false (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))
(not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2})))
(isTrueAndIsFalse2 a2)
(isTrueAndIsFalse1 a1)) ⟩
not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}) && not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2})))
=⟨⟩
not (rSetIsSubsetStrict rs2 {prf2} rs1 {prf1})
end
-- if x is strict subset of y, y is not strict subset of x
-- prop_subset_not2 asserts that rSetIsSubstrict x y is false
-- this means that rSetIsEmpty (rSetDifference x y) is false
-- and rSetEmpty (rSetDifference x y) is true
prop_subset_not2 : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 rs2 : RSet a)
→ {prf1 : IsTrue (validRangeList (rSetRanges rs1))}
→ {prf2 : IsTrue (validRangeList (rSetRanges rs2))}
-> (a1 : IsFalse (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2})))
-> (a2 : IsFalse (not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))))
→ (rSetIsSubsetStrict rs1 {prf1} rs2 {prf2}) ≡ (not (rSetIsSubsetStrict rs2 {prf2} rs1 {prf1}))
prop_subset_not2 {{ o }} {{ dio }} rs1 rs2 {prf1} {prf2} a1 a2 =
begin
rSetIsSubsetStrict rs1 {prf1} rs2 {prf2}
=⟨⟩
(rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}) && not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1})))
=⟨ not-not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}) && not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))) ⟩
not (not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}) && not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))))
=⟨ cong not (prop_demorgan (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2})) (not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1})))) ⟩
not ((not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) || (not (not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1})))))
=⟨ cong not (cong ((not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) ||_) (sym (not-not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))))) ⟩
not ((not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) || (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1})))
=⟨ cong not (prop_or_sym (not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2}))) (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))) ⟩
not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}) || not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2})))
=⟨ cong not (prop_or_and_eqiv_true (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}))
(not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2})))
(isTrueAndIsFalse3 a2)
(isTrueAndIsFalse4 a1)) ⟩
not (rSetIsEmpty (rSetDifference rs2 {prf2} rs1 {prf1}) && not (rSetIsEmpty (rSetDifference rs1 {prf1} rs2 {prf2})))
=⟨⟩
not (rSetIsSubsetStrict rs2 {prf2} rs1 {prf1})
end
prop_strictSubset_means_subset : ⦃ o : Ord a ⦄ → ⦃ dio : DiscreteOrdered a ⦄ → (rs1 rs2 : RSet a)
→ {prf1 : IsTrue (validRangeList (rSetRanges rs1))}
→ {prf2 : IsTrue (validRangeList (rSetRanges rs2))}
→ IsTrue (rSetIsSubsetStrict rs1 {prf1} rs2 {prf2}) -> IsTrue (rSetIsSubset rs1 {prf1} rs2 {prf2})
prop_strictSubset_means_subset {{ o }} {{ dio }} rs1 rs2 {prf1} {prf2} prf = isTrue&&₁ {(rSetIsSubset rs1 {prf1} rs2 {prf2})} prf
|
{
"alphanum_fraction": 0.5479842407,
"avg_line_length": 57.0014124294,
"ext": "agda",
"hexsha": "fdc64be9acc5d83cca96acca233d29ebd776c972",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "17cdbeb36af3d0b735c5db83bb811034c39a19cd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "ioanasv/agda2hs",
"max_forks_repo_path": "lib/Haskell/RangedSetsProp/RangedSetProperties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "17cdbeb36af3d0b735c5db83bb811034c39a19cd",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "ioanasv/agda2hs",
"max_issues_repo_path": "lib/Haskell/RangedSetsProp/RangedSetProperties.agda",
"max_line_length": 257,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "17cdbeb36af3d0b735c5db83bb811034c39a19cd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "ioanasv/agda2hs",
"max_stars_repo_path": "lib/Haskell/RangedSetsProp/RangedSetProperties.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-25T09:41:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-05-25T09:41:34.000Z",
"num_tokens": 34758,
"size": 80714
}
|
module _ where
module A where
data D₁ : Set where
a : D₁
c : D₁ → D₁
module B where
data D₂ : Set where
b : D₂
c : D₂ → D₂
syntax c x = ⟦ x ⟧
open A
open B
test : D₁
test = ⟦ a ⟧ -- The syntax declaration applies to B.c, not A.c.
|
{
"alphanum_fraction": 0.5615384615,
"avg_line_length": 11.8181818182,
"ext": "agda",
"hexsha": "b65ba7430a8ad073cd06b024ba5b16afe2fe6c01",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue1194j.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue1194j.agda",
"max_line_length": 64,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue1194j.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 101,
"size": 260
}
|
module Logic.DiagonalProof {ℓ₁} {ℓ₂} where
import Lvl
open import Logic.Propositional{ℓ₁ Lvl.⊔ ℓ₂}
open import Logic.Predicate{ℓ₁}{ℓ₂}
open import Functional
open import Relator.Equals{ℓ₁}{ℓ₂}
open import Relator.Equals.Proofs{ℓ₁}{ℓ₂}
open import Type{ℓ₂}
diagonal-proof : ∀{T₁ T₂ : Type}(diff-oper : T₂ → T₂) → (∀{x} → (x ≢ diff-oper(x))) → (ff : T₁ → T₁ → T₂) → ∃{T₁ → T₂}(f ↦ (∀{a : T₁} → ¬(ff(a)(a) ≡ f(a))))
diagonal-proof(diff-oper)(diff-proof)(ff) = [∃]-intro (a ↦ diff-oper(ff(a)(a))) ⦃ \{a} → diff-proof{ff(a)(a)} ⦄
|
{
"alphanum_fraction": 0.6221804511,
"avg_line_length": 40.9230769231,
"ext": "agda",
"hexsha": "172b0f8c6e4408996b3a782e4f153b710412a086",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "old/Logic/DiagonalProof.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "old/Logic/DiagonalProof.agda",
"max_line_length": 156,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "old/Logic/DiagonalProof.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 229,
"size": 532
}
|
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Monoidal.Instance.One where
open import Level
open import Data.Unit using (⊤; tt)
open import Categories.Category
open import Categories.Category.Instance.One
open import Categories.Category.Monoidal
open import Categories.Functor.Bifunctor
open import Categories.Morphism using (_≅_)
-- That One is monoidal is so easy to prove that Agda can do it all on its own!
One-Monoidal : {o ℓ e : Level} → Monoidal (One {o} {ℓ} {e})
One-Monoidal = _
|
{
"alphanum_fraction": 0.7559055118,
"avg_line_length": 29.8823529412,
"ext": "agda",
"hexsha": "79d52e636ecd294ac28776a22f174ff819ffdd84",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Monoidal/Instance/One.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Monoidal/Instance/One.agda",
"max_line_length": 79,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Monoidal/Instance/One.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z",
"num_tokens": 130,
"size": 508
}
|
module CoinductiveBuiltinNatural where
open import Common.Coinduction
data ℕ : Set where
zero : ℕ
suc : (n : ∞ ℕ) → ℕ
{-# BUILTIN NATURAL ℕ #-}
|
{
"alphanum_fraction": 0.6580645161,
"avg_line_length": 15.5,
"ext": "agda",
"hexsha": "ad7ee2c8d4911597360fde81f08e2aabbc4e0769",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/CoinductiveBuiltinNatural.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/CoinductiveBuiltinNatural.agda",
"max_line_length": 38,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/CoinductiveBuiltinNatural.agda",
"max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z",
"num_tokens": 49,
"size": 155
}
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import Functions.Definition
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import LogicalFormulae
open import Setoids.Subset
open import Setoids.Setoids
open import Setoids.Orders.Partial.Definition
open import Fields.Fields
open import Rings.Orders.Total.Definition
open import Rings.Orders.Total.Lemmas
open import Rings.Orders.Partial.Definition
open import Rings.Definition
module Fields.Orders.LeastUpperBounds.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {c : _} {_<_ : Rel {_} {c} A} (pOrder : SetoidPartialOrder S _<_) where
UpperBound : {d : _} {pred : A → Set d} (sub : subset S pred) (x : A) → Set _
UpperBound {pred = pred} sub x = (y : A) → pred y → (y < x) || (Setoid._∼_ S y x)
record LeastUpperBound {d : _} {pred : A → Set d} (sub : subset S pred) (x : A) : Set (a ⊔ b ⊔ c ⊔ d) where
field
upperBound : UpperBound sub x
leastUpperBound : (y : A) → UpperBound sub y → (x < y) || (Setoid._∼_ S x y)
|
{
"alphanum_fraction": 0.6808300395,
"avg_line_length": 42.1666666667,
"ext": "agda",
"hexsha": "3eb62dc681e6af431bbef6c4925b25412057b20c",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Fields/Orders/LeastUpperBounds/Definition.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Fields/Orders/LeastUpperBounds/Definition.agda",
"max_line_length": 165,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Fields/Orders/LeastUpperBounds/Definition.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z",
"num_tokens": 327,
"size": 1012
}
|
{-# OPTIONS --safe #-}
module Cubical.Algebra.NatSolver.EvalHom where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Nat
open import Cubical.Data.FinData
open import Cubical.Data.Vec
open import Cubical.Algebra.NatSolver.HornerForms
private
variable
ℓ : Level
module HomomorphismProperties where
open IteratedHornerOperations
evalHom+0 : {n : ℕ} (P : IteratedHornerForms n) (xs : Vec ℕ n)
→ eval (0ₕ +ₕ P) xs ≡ eval P xs
evalHom+0 (const x) [] = refl
evalHom+0 _ (x ∷ xs) = refl
eval0H : {n : ℕ} (xs : Vec ℕ n)
→ eval 0ₕ xs ≡ 0
eval0H [] = refl
eval0H (x ∷ xs) = refl
eval1ₕ : {n : ℕ} (xs : Vec ℕ n)
→ eval 1ₕ xs ≡ 1
eval1ₕ [] = refl
eval1ₕ (x ∷ xs) =
eval 1ₕ (x ∷ xs) ≡⟨ refl ⟩
eval (0H ·X+ 1ₕ) (x ∷ xs) ≡⟨ refl ⟩
eval 0H (x ∷ xs) · x + eval 1ₕ xs ≡⟨ cong (λ u → u · x + eval 1ₕ xs)
(eval0H (x ∷ xs)) ⟩
0 · x + eval 1ₕ xs ≡⟨ cong (λ u → 0 · x + u)
(eval1ₕ xs) ⟩
1 ∎
+ShufflePairs : (a b c d : ℕ)
→ (a + b) + (c + d) ≡ (a + c) + (b + d)
+ShufflePairs a b c d =
(a + b) + (c + d) ≡⟨ +-assoc (a + b) c d ⟩
((a + b) + c) + d ≡⟨ cong (λ u → u + d) (sym (+-assoc a b c)) ⟩
(a + (b + c)) + d ≡⟨ cong (λ u → (a + u) + d) (+-comm b c) ⟩
(a + (c + b)) + d ≡⟨ cong (λ u → u + d) (+-assoc a c b) ⟩
((a + c) + b) + d ≡⟨ sym (+-assoc (a + c) b d) ⟩
(a + c) + (b + d) ∎
+Homeval :
{n : ℕ} (P Q : IteratedHornerForms n) (xs : Vec ℕ n)
→ eval (P +ₕ Q) xs ≡ (eval P xs) + (eval Q xs)
+Homeval (const x) (const y) [] = refl
+Homeval 0H Q xs =
eval (0H +ₕ Q) xs ≡⟨ refl ⟩
0 + eval Q xs ≡⟨ cong (λ u → u + eval Q xs) (sym (eval0H xs)) ⟩
eval 0H xs + eval Q xs ∎
+Homeval (P ·X+ Q) 0H xs =
eval ((P ·X+ Q) +ₕ 0H) xs ≡⟨ refl ⟩
eval (P ·X+ Q) xs ≡⟨ sym (+-zero _) ⟩
eval (P ·X+ Q) xs + 0 ≡⟨ cong (λ u → eval (P ·X+ Q) xs + u)
(sym (eval0H xs)) ⟩
eval (P ·X+ Q) xs + eval 0H xs ∎
+Homeval (P ·X+ Q) (S ·X+ T) (x ∷ xs) =
eval ((P ·X+ Q) +ₕ (S ·X+ T)) (x ∷ xs)
≡⟨ refl ⟩
eval ((P +ₕ S) ·X+ (Q +ₕ T)) (x ∷ xs)
≡⟨ refl ⟩
(eval (P +ₕ S) (x ∷ xs)) · x + eval (Q +ₕ T) xs
≡⟨ cong (λ u → (eval (P +ₕ S) (x ∷ xs)) · x + u) (+Homeval Q T xs) ⟩
(eval (P +ₕ S) (x ∷ xs)) · x + (eval Q xs + eval T xs)
≡⟨ cong (λ u → u · x + (eval Q xs + eval T xs)) (+Homeval P S (x ∷ xs)) ⟩
(eval P (x ∷ xs) + eval S (x ∷ xs)) · x
+ (eval Q xs + eval T xs)
≡⟨ cong (λ u → u + (eval Q xs + eval T xs))
(sym (·-distribʳ (eval P (x ∷ xs)) (eval S (x ∷ xs)) x)) ⟩
(eval P (x ∷ xs)) · x + (eval S (x ∷ xs)) · x
+ (eval Q xs + eval T xs)
≡⟨ +ShufflePairs ((eval P (x ∷ xs)) · x) ((eval S (x ∷ xs)) · x) (eval Q xs) (eval T xs) ⟩
((eval P (x ∷ xs)) · x + eval Q xs)
+ ((eval S (x ∷ xs)) · x + eval T xs)
∎
⋆Homeval : {n : ℕ}
(r : IteratedHornerForms n)
(P : IteratedHornerForms (ℕ.suc n)) (x : ℕ) (xs : Vec ℕ n)
→ eval (r ⋆ P) (x ∷ xs) ≡ eval r xs · eval P (x ∷ xs)
⋆0LeftAnnihilates :
{n : ℕ} (P : IteratedHornerForms (ℕ.suc n)) (xs : Vec ℕ (ℕ.suc n))
→ eval (0ₕ ⋆ P) xs ≡ 0
·Homeval : {n : ℕ} (P Q : IteratedHornerForms n) (xs : Vec ℕ n)
→ eval (P ·ₕ Q) xs ≡ (eval P xs) · (eval Q xs)
⋆0LeftAnnihilates 0H xs = eval0H xs
⋆0LeftAnnihilates (P ·X+ Q) (x ∷ xs) =
eval (0ₕ ⋆ (P ·X+ Q)) (x ∷ xs) ≡⟨ refl ⟩
eval ((0ₕ ⋆ P) ·X+ (0ₕ ·ₕ Q)) (x ∷ xs) ≡⟨ refl ⟩
(eval (0ₕ ⋆ P) (x ∷ xs)) · x + eval (0ₕ ·ₕ Q) xs
≡⟨ cong (λ u → (u · x) + eval (0ₕ ·ₕ Q) _) (⋆0LeftAnnihilates P (x ∷ xs)) ⟩
0 · x + eval (0ₕ ·ₕ Q) xs
≡⟨ ·Homeval 0ₕ Q _ ⟩
eval 0ₕ xs · eval Q xs
≡⟨ cong (λ u → u · eval Q xs) (eval0H xs) ⟩
0 · eval Q xs ∎
⋆Homeval r 0H x xs =
eval (r ⋆ 0H) (x ∷ xs) ≡⟨ refl ⟩
0 ≡⟨ 0≡m·0 (eval r xs) ⟩
eval r xs · 0 ≡⟨ refl ⟩
eval r xs · eval 0H (x ∷ xs) ∎
⋆Homeval r (P ·X+ Q) x xs =
eval (r ⋆ (P ·X+ Q)) (x ∷ xs) ≡⟨ refl ⟩
eval ((r ⋆ P) ·X+ (r ·ₕ Q)) (x ∷ xs) ≡⟨ refl ⟩
(eval (r ⋆ P) (x ∷ xs)) · x + eval (r ·ₕ Q) xs
≡⟨ cong (λ u → u · x + eval (r ·ₕ Q) xs) (⋆Homeval r P x xs) ⟩
(eval r xs · eval P (x ∷ xs)) · x + eval (r ·ₕ Q) xs
≡⟨ cong (λ u → (eval r xs · eval P (x ∷ xs)) · x + u) (·Homeval r Q xs) ⟩
(eval r xs · eval P (x ∷ xs)) · x + eval r xs · eval Q xs
≡⟨ cong (λ u → u + eval r xs · eval Q xs) (sym (·-assoc (eval r xs) (eval P (x ∷ xs)) x)) ⟩
eval r xs · (eval P (x ∷ xs) · x) + eval r xs · eval Q xs
≡⟨ ·-distribˡ (eval r xs) ((eval P (x ∷ xs) · x)) (eval Q xs) ⟩
eval r xs · ((eval P (x ∷ xs) · x) + eval Q xs)
≡⟨ refl ⟩
eval r xs · eval (P ·X+ Q) (x ∷ xs) ∎
combineCases :
{n : ℕ} (Q : IteratedHornerForms n) (P S : IteratedHornerForms (ℕ.suc n))
(xs : Vec ℕ (ℕ.suc n))
→ eval ((P ·X+ Q) ·ₕ S) xs ≡ eval (((P ·ₕ S) ·X+ 0ₕ) +ₕ (Q ⋆ S)) xs
combineCases Q P S (x ∷ xs) with (P ·ₕ S)
... | 0H =
eval (Q ⋆ S) (x ∷ xs) ≡⟨ refl ⟩
0 + eval (Q ⋆ S) (x ∷ xs) ≡⟨ cong (λ u → u + eval (Q ⋆ S) (x ∷ xs)) lemma ⟩
eval (0H ·X+ 0ₕ) (x ∷ xs)
+ eval (Q ⋆ S) (x ∷ xs) ≡⟨ sym (+Homeval
(0H ·X+ 0ₕ) (Q ⋆ S) (x ∷ xs)) ⟩
eval ((0H ·X+ 0ₕ) +ₕ (Q ⋆ S)) (x ∷ xs) ∎
where lemma : 0 ≡ eval (0H ·X+ 0ₕ) (x ∷ xs)
lemma = 0
≡⟨ refl ⟩
0 + 0
≡⟨ cong (λ u → u + 0) refl ⟩
0 · x + 0
≡⟨ cong (λ u → 0 · x + u) (sym (eval0H xs)) ⟩
0 · x + eval 0ₕ xs
≡⟨ cong (λ u → u · x + eval 0ₕ xs) (sym (eval0H (x ∷ xs))) ⟩
eval 0H (x ∷ xs) · x + eval 0ₕ xs
≡⟨ refl ⟩
eval (0H ·X+ 0ₕ) (x ∷ xs) ∎
... | (_ ·X+ _) = refl
·Homeval (const x) (const y) [] = refl
·Homeval 0H Q xs =
eval (0H ·ₕ Q) xs ≡⟨ eval0H xs ⟩
0 ≡⟨ refl ⟩
0 · eval Q xs ≡⟨ cong (λ u → u · eval Q xs) (sym (eval0H xs)) ⟩
eval 0H xs · eval Q xs ∎
·Homeval (P ·X+ Q) S (x ∷ xs) =
eval ((P ·X+ Q) ·ₕ S) (x ∷ xs)
≡⟨ combineCases Q P S (x ∷ xs) ⟩
eval (((P ·ₕ S) ·X+ 0ₕ) +ₕ (Q ⋆ S)) (x ∷ xs)
≡⟨ +Homeval ((P ·ₕ S) ·X+ 0ₕ) (Q ⋆ S) (x ∷ xs) ⟩
eval ((P ·ₕ S) ·X+ 0ₕ) (x ∷ xs) + eval (Q ⋆ S) (x ∷ xs)
≡⟨ refl ⟩
(eval (P ·ₕ S) (x ∷ xs) · x + eval 0ₕ xs)
+ eval (Q ⋆ S) (x ∷ xs)
≡⟨ cong (λ u → u + eval (Q ⋆ S) (x ∷ xs))
((eval (P ·ₕ S) (x ∷ xs) · x + eval 0ₕ xs)
≡⟨ cong (λ u → eval (P ·ₕ S) (x ∷ xs) · x + u) (eval0H xs) ⟩
(eval (P ·ₕ S) (x ∷ xs) · x + 0)
≡⟨ +-zero _ ⟩
(eval (P ·ₕ S) (x ∷ xs) · x)
≡⟨ cong (λ u → u · x) (·Homeval P S (x ∷ xs)) ⟩
((eval P (x ∷ xs) · eval S (x ∷ xs)) · x)
≡⟨ sym (·-assoc (eval P (x ∷ xs)) (eval S (x ∷ xs)) x) ⟩
(eval P (x ∷ xs) · (eval S (x ∷ xs) · x))
≡⟨ cong (λ u → eval P (x ∷ xs) · u) (·-comm _ x) ⟩
(eval P (x ∷ xs) · (x · eval S (x ∷ xs)))
≡⟨ ·-assoc (eval P (x ∷ xs)) x (eval S (x ∷ xs)) ⟩
(eval P (x ∷ xs) · x) · eval S (x ∷ xs)
∎) ⟩
(eval P (x ∷ xs) · x) · eval S (x ∷ xs)
+ eval (Q ⋆ S) (x ∷ xs)
≡⟨ cong (λ u → (eval P (x ∷ xs) · x) · eval S (x ∷ xs) + u)
(⋆Homeval Q S x xs) ⟩
(eval P (x ∷ xs) · x) · eval S (x ∷ xs)
+ eval Q xs · eval S (x ∷ xs)
≡⟨ ·-distribʳ (eval P (x ∷ xs) · x) (eval Q xs) (eval S (x ∷ xs)) ⟩
((eval P (x ∷ xs) · x) + eval Q xs) · eval S (x ∷ xs)
≡⟨ refl ⟩
eval (P ·X+ Q) (x ∷ xs) · eval S (x ∷ xs) ∎
|
{
"alphanum_fraction": 0.3945858283,
"avg_line_length": 40.6903553299,
"ext": "agda",
"hexsha": "40a7184e492fd53d2e0ff9c35c0add130455f00c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Seanpm2001-web/cubical",
"max_forks_repo_path": "Cubical/Algebra/NatSolver/EvalHom.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Seanpm2001-web/cubical",
"max_issues_repo_path": "Cubical/Algebra/NatSolver/EvalHom.agda",
"max_line_length": 96,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "FernandoLarrain/cubical",
"max_stars_repo_path": "Cubical/Algebra/NatSolver/EvalHom.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-05T00:30:17.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-03-05T00:30:17.000Z",
"num_tokens": 3754,
"size": 8016
}
|
------------------------------------------------------------------------------
-- Testing Agsy arithmetic properties used by the McCarthy 91 function
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- Tested with the development version of the Agda standard library on
-- 02 February 2012.
module Agsy.McCarthy91.Arithmetic where
open import Data.Nat
open import Relation.Binary.PropositionalEquality
------------------------------------------------------------------------------
91≡[100+11∸10]∸10 : (100 + 11 ∸ 10) ∸ 10 ≡ 91
91≡[100+11∸10]∸10 = refl
20>19 : 20 > 19 -- via Agsy
20>19 = s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s (s≤s (s≤s (s≤s (s≤s (s≤s (s≤s (s≤s (s≤s z≤n)))))))))))))))))))
50>49 : 50 > 49 -- via Agsy {-t 30}
50>49 = s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
z≤n)))))))))))))))))))))))))))))))))))))))))))))))))
75>74 : 75 > 74 -- via Agsy {-t 180}
75>74 = s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
z≤n))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
101>100 : 101 > 100 -- via Agsy {-t 600}
101>100 = s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
(s≤s
z≤n))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
|
{
"alphanum_fraction": 0.0673235992,
"avg_line_length": 51.3025830258,
"ext": "agda",
"hexsha": "20038931de22af6fa5969c81c558b28ec514bd53",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "src/fot/Agsy/McCarthy91/Arithmetic.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "src/fot/Agsy/McCarthy91/Arithmetic.agda",
"max_line_length": 213,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "src/fot/Agsy/McCarthy91/Arithmetic.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z",
"num_tokens": 2042,
"size": 13903
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Integer Literals
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Integer.Literals where
open import Agda.Builtin.FromNat
open import Agda.Builtin.FromNeg
open import Data.Unit
open import Data.Integer
number : Number ℤ
number = record
{ Constraint = λ _ → ⊤
; fromNat = λ n → + n
}
negative : Negative ℤ
negative = record
{ Constraint = λ _ → ⊤
; fromNeg = λ n → - (+ n)
}
|
{
"alphanum_fraction": 0.4878472222,
"avg_line_length": 21.3333333333,
"ext": "agda",
"hexsha": "1de609373ec8e653c3a77ffbf75e55d319b1519d",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Integer/Literals.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Integer/Literals.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Integer/Literals.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 129,
"size": 576
}
|
module TelescopingLet where
module Star where
★ : Set₁
★ = Set
★₁ : Set₂
★₁ = Set₁
module MEndo (open Star) (A : ★) where
Endo : ★
Endo = A → A
module Batch1 where
f : (let ★ = Set) (A : ★) → A → A
f A x = x
g : (let ★ = Set
Endo = λ A → A → A) (A : ★) → Endo A
g = f
h : (open Star) (A : ★) → A → A
h = g
module N (open Star) (A : ★) (open MEndo A) (f : Endo) where
B : ★
B = A
f' : Endo
f' = f
-- module N can be desugared as follows:
module _ where
open Star
module _ (A : ★) where
open MEndo A
module N' (f : Endo) where
B : ★
B = A
f' : Endo
f' = f
-- Here are instantiations of N and its desugaring:
f'1 = f'
where
postulate A : Set
f : A → A
open N A f
f'2 = f'
where
postulate A : Set
f : A → A
open N' A f
data ⊥ : Set where
module Batch2 where
f = λ (let ★ = Set) (A : ★) (x : A) → x
g = λ (open Star) (A : ★) (x : A) → x
h0 = let open Star in
λ (A : ★) →
let module MA = MEndo A in
let open MA in
λ (f : Endo) →
f
h1 = let open Star in
λ (A : ★) →
let open MEndo A in
λ (f : Endo) →
f
h = λ (open Star) (A : ★) (open MEndo A) (f : Endo) → f
module Batch3 where
e1 : (let ★ = Set) → ★
e1 = ⊥
e2 = λ (let ★ = Set) → ★
e3 = λ (open Star) → ★
-- "λ (open M es) → e" is an edge case which behaves like "let open M es in e"
|
{
"alphanum_fraction": 0.4654346338,
"avg_line_length": 16.6022727273,
"ext": "agda",
"hexsha": "203a6d2bb61fc92a9aabf8b2979038f2351bfff7",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2015-09-15T14:36:15.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-09-15T14:36:15.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/TelescopingLet.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/TelescopingLet.agda",
"max_line_length": 80,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/TelescopingLet.agda",
"max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z",
"num_tokens": 596,
"size": 1461
}
|
-- The purpose of this universe construction is to get some definitional
-- equalities in the model. Specifically, if we define ⟦σ⟧ : ⟦Δ⟧ → ⟦Ω⟧
-- (a functor) for the "canonical" notion of subsitution, then we have
-- ⟦Wk⟧ (δ , m) ≡ δ propositionally, but *not* definitionally. This then
-- complicates proofs involving ⟦Wk⟧, and similar for the other substitutions.
{-# OPTIONS --without-K --safe #-}
module Source.Size.Substitution.Universe where
open import Relation.Binary using (IsEquivalence ; Setoid)
open import Source.Size
open import Source.Size.Substitution.Canonical as Can using (Sub⊢)
open import Util.Prelude
import Relation.Binary.Reasoning.Setoid as SetoidReasoning
infix 4 _≈_
infixl 5 _>>_
data Sub : (Δ Ω : Ctx) → Set where
Id : Sub Δ Δ
_>>_ : (σ : Sub Δ Δ′) (τ : Sub Δ′ Ω) → Sub Δ Ω
Wk : Sub (Δ ∙ n) Δ
Lift : (σ : Sub Δ Ω) → Sub (Δ ∙ m) (Ω ∙ n)
Sing : (n : Size Δ) → Sub Δ (Δ ∙ m)
Skip : Sub (Δ ∙ n ∙ v0) (Δ ∙ n)
⟨_⟩ : Sub Δ Ω → Can.Sub Δ Ω
⟨ Id ⟩ = Can.Id
⟨ σ >> τ ⟩ = ⟨ σ ⟩ Can.>> ⟨ τ ⟩
⟨ Wk ⟩ = Can.Wk
⟨ Lift σ ⟩ = Can.Lift ⟨ σ ⟩
⟨ Sing n ⟩ = Can.Sing n
⟨ Skip ⟩ = Can.Skip
subV : (σ : Sub Δ Ω) (x : Var Ω) → Size Δ
subV σ = Can.subV ⟨ σ ⟩
sub : (σ : Sub Δ Ω) (n : Size Ω) → Size Δ
sub σ = Can.sub ⟨ σ ⟩
pattern Lift′ σ ⊢n = Lift σ ⊢n refl
variable σ τ ι : Sub Δ Ω
data Sub⊢ᵤ : ∀ Δ Ω → Sub Δ Ω → Set where
Id : Sub⊢ᵤ Δ Δ Id
comp : (⊢σ : Sub⊢ᵤ Δ Δ′ σ) (⊢τ : Sub⊢ᵤ Δ′ Δ″ τ) → Sub⊢ᵤ Δ Δ″ (σ >> τ)
Wk : Sub⊢ᵤ (Δ ∙ n) Δ Wk
Lift : (⊢σ : Sub⊢ᵤ Δ Ω σ) (m≡n[σ] : m ≡ sub σ n)
→ Sub⊢ᵤ (Δ ∙ m) (Ω ∙ n) (Lift σ)
Sing : (n<m : n < m) → Sub⊢ᵤ Δ (Δ ∙ m) (Sing n)
Skip : Sub⊢ᵤ (Δ ∙ n ∙ v0) (Δ ∙ n) Skip
syntax Sub⊢ᵤ Δ Ω σ = σ ∶ Δ ⇒ᵤ Ω
⟨⟩-resp-⊢ : σ ∶ Δ ⇒ᵤ Ω → ⟨ σ ⟩ ∶ Δ ⇒ Ω
⟨⟩-resp-⊢ Id = Can.Id⊢
⟨⟩-resp-⊢ (comp ⊢σ ⊢τ) = Can.>>⊢ (⟨⟩-resp-⊢ ⊢σ) (⟨⟩-resp-⊢ ⊢τ)
⟨⟩-resp-⊢ Wk = Can.Wk⊢
⟨⟩-resp-⊢ (Lift ⊢σ m≡n[σ]) = Can.Lift⊢ (⟨⟩-resp-⊢ ⊢σ) m≡n[σ]
⟨⟩-resp-⊢ (Sing n<m) = Can.Sing⊢ n<m
⟨⟩-resp-⊢ Skip = Can.Skip⊢
record _≈_ (σ τ : Sub Δ Ω) : Set where
constructor ≈⁺
field ≈⁻ : ⟨ σ ⟩ ≡ ⟨ τ ⟩
open _≈_ public
≈-refl : σ ≈ σ
≈-refl = ≈⁺ refl
≈-sym : σ ≈ τ → τ ≈ σ
≈-sym (≈⁺ p) = ≈⁺ (sym p)
≈-trans : σ ≈ τ → τ ≈ ι → σ ≈ ι
≈-trans (≈⁺ p) (≈⁺ q) = ≈⁺ (trans p q)
≈-isEquivalence : IsEquivalence (_≈_ {Δ} {Ω})
≈-isEquivalence = record { refl = ≈-refl ; sym = ≈-sym ; trans = ≈-trans }
Sub-setoid : (Δ Ω : Ctx) → Setoid 0ℓ 0ℓ
Sub-setoid Δ Ω = record
{ Carrier = Sub Δ Ω
; _≈_ = _≈_
; isEquivalence = ≈-isEquivalence
}
module ≈-Reasoning {Δ} {Ω} = SetoidReasoning (Sub-setoid Δ Ω)
abstract
>>-resp-≈ : {σ σ′ : Sub Δ Δ′} {τ τ′ : Sub Δ′ Δ″}
→ σ ≈ σ′ → τ ≈ τ′ → σ >> τ ≈ σ′ >> τ′
>>-resp-≈ (≈⁺ p) (≈⁺ q) = ≈⁺ (cong₂ Can._>>_ p q)
Lift-resp-≈ : σ ≈ τ → Lift {m = m} {n} σ ≈ Lift τ
Lift-resp-≈ (≈⁺ p) = ≈⁺ (cong Can.Lift p)
sub-resp-< : σ ∶ Δ ⇒ᵤ Ω → n < m → sub σ n < sub σ m
sub-resp-< ⊢σ = Can.sub-resp-< (⟨⟩-resp-⊢ ⊢σ)
mutual
subV′ : Sub Δ Ω → Var Ω → Size Δ
subV′ Id x = var x
subV′ (σ >> τ) x = sub′ σ (subV′ τ x)
subV′ Wk x = var (suc x)
subV′ (Lift σ) zero = var zero
subV′ (Lift σ) (suc x) = wk (subV′ σ x)
subV′ (Sing n) zero = n
subV′ (Sing n) (suc x) = var x
subV′ Skip zero = var zero
subV′ Skip (suc x) = var (suc (suc x))
sub′ : Sub Δ Ω → Size Ω → Size Δ
sub′ σ (var x) = subV′ σ x
sub′ σ ∞ = ∞
sub′ σ zero = zero
sub′ σ (suc n) = suc (sub′ σ n)
abstract
subV′≡subV : ∀ (σ : Sub Δ Ω) x → subV′ σ x ≡ subV σ x
subV′≡subV Id x = sym (Can.subV-Id x)
subV′≡subV (σ >> τ) x
= trans (sub′≡sub σ (subV′ τ x))
(trans (cong (sub σ) (subV′≡subV τ x))
(sym (Can.subV->> ⟨ σ ⟩ ⟨ τ ⟩ x)))
subV′≡subV Wk x = sym (Can.sub-Wk (var x))
subV′≡subV (Lift σ) zero = refl
subV′≡subV (Lift σ) (suc x)
= trans (cong wk (subV′≡subV σ x)) (sym (Can.subV-Weaken ⟨ σ ⟩ x))
subV′≡subV (Sing n) zero = refl
subV′≡subV (Sing n) (suc x) = sym (Can.subV-Id x)
subV′≡subV Skip zero = refl
subV′≡subV Skip (suc x) = sym
(trans (Can.subV-Weaken (Can.Weaken Can.Id) x) (cong wk (Can.sub-Wk (var x))))
sub′≡sub : ∀ (σ : Sub Δ Ω) n → sub′ σ n ≡ sub σ n
sub′≡sub σ (var x) = subV′≡subV σ x
sub′≡sub σ ∞ = refl
sub′≡sub σ zero = refl
sub′≡sub σ (suc n) = cong suc (sub′≡sub σ n)
|
{
"alphanum_fraction": 0.5240317312,
"avg_line_length": 25.5119047619,
"ext": "agda",
"hexsha": "5d38e48cd8bd09216274e5bd85c27f66bb093207",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JLimperg/msc-thesis-code",
"max_forks_repo_path": "src/Source/Size/Substitution/Universe.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JLimperg/msc-thesis-code",
"max_issues_repo_path": "src/Source/Size/Substitution/Universe.agda",
"max_line_length": 84,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JLimperg/msc-thesis-code",
"max_stars_repo_path": "src/Source/Size/Substitution/Universe.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-26T06:37:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-04-13T21:31:17.000Z",
"num_tokens": 2156,
"size": 4286
}
|
{-# OPTIONS --safe #-}
module Cubical.Algebra.DirectSum.DirectSumHIT.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Empty as ⊥
open import Cubical.Data.Sigma
open import Cubical.Relation.Nullary
open import Cubical.Algebra.Group
open import Cubical.Algebra.AbGroup
open import Cubical.Algebra.DirectSum.DirectSumHIT.Base
private variable
ℓ ℓ' : Level
module AbGroupProperties
(Idx : Type ℓ)
(P : Idx → Type ℓ')
(AGP : (r : Idx) → AbGroupStr (P r))
where
inv : ⊕HIT Idx P AGP → ⊕HIT Idx P AGP
inv = DS-Rec-Set.f Idx P AGP (⊕HIT Idx P AGP) trunc
-- elements
neutral
(λ r a → base r (AbGroupStr.-_ (AGP r) a))
(λ xs ys → xs add ys)
-- eq group
(λ xs ys zs → addAssoc xs ys zs)
(λ xs → addRid xs)
(λ xs ys → addComm xs ys)
-- eq base
(λ r → let open AbGroupStr (AGP r) in
let open GroupTheory (P r , AbGroupStr→GroupStr (AGP r)) in
(cong (base r) inv1g) ∙ (base-neutral r))
(λ r a b → let open AbGroupStr (AGP r) in
let open GroupTheory (P r , AbGroupStr→GroupStr (AGP r)) in
((base r (- a) add base r (- b)) ≡⟨ (base-add r (- a) (- b)) ⟩
base r ((- a) + (- b)) ≡⟨ (cong (base r) (sym (invDistr b a))) ⟩
base r (- (b + a)) ≡⟨ cong (base r) (cong (-_) (+Comm b a)) ⟩
base r (- (a + b)) ∎))
rinv : (z : ⊕HIT Idx P AGP) → z add (inv z) ≡ neutral
rinv = DS-Ind-Prop.f Idx P AGP (λ z → z add (inv z) ≡ neutral) (λ _ → trunc _ _)
-- elements
(addRid neutral)
(λ r a → let open AbGroupStr (AGP r) in
((base r a add base r (- a)) ≡⟨ base-add r a (- a) ⟩
base r (a + - a) ≡⟨ cong (base r) (+InvR a) ⟩
base r 0g ≡⟨ base-neutral r ⟩
neutral ∎))
(λ {x} {y} p q →
(((x add y) add ((inv x) add (inv y))) ≡⟨ cong (λ X → X add ((inv x) add (inv y))) (addComm x y) ⟩
((y add x) add (inv x add inv y)) ≡⟨ sym (addAssoc y x (inv x add inv y)) ⟩
(y add (x add (inv x add inv y))) ≡⟨ cong (λ X → y add X) (addAssoc x (inv x) (inv y)) ⟩
(y add ((x add inv x) add inv y)) ≡⟨ cong (λ X → y add (X add (inv y))) (p) ⟩
(y add (neutral add inv y)) ≡⟨ cong (λ X → y add X) (addComm neutral (inv y)) ⟩
(y add (inv y add neutral)) ≡⟨ cong (λ X → y add X) (addRid (inv y)) ⟩
(y add inv y) ≡⟨ q ⟩
neutral ∎))
module SubstLemma
(Idx : Type ℓ)
(G : Idx → Type ℓ')
(Gstr : (r : Idx) → AbGroupStr (G r))
where
open AbGroupStr
subst0g : {l k : Idx} → (p : l ≡ k) → subst G p (0g (Gstr l)) ≡ 0g (Gstr k)
subst0g {l} {k} p = J (λ k p → subst G p (0g (Gstr l)) ≡ 0g (Gstr k)) (transportRefl _) p
subst+ : {l : Idx} → (a b : G l) → {k : Idx} → (p : l ≡ k) →
Gstr k ._+_ (subst G p a) (subst G p b) ≡ subst G p (Gstr l ._+_ a b)
subst+ {l} a b {k} p = J (λ k p → Gstr k ._+_ (subst G p a) (subst G p b) ≡ subst G p (Gstr l ._+_ a b))
(cong₂ (Gstr l ._+_) (transportRefl _) (transportRefl _) ∙ sym (transportRefl _))
p
module DecIndec-BaseProperties
(Idx : Type ℓ)
(decIdx : Discrete Idx)
(G : Idx → Type ℓ')
(Gstr : (r : Idx) → AbGroupStr (G r))
where
open AbGroupStr
open SubstLemma Idx G Gstr
πₖ : (k : Idx) → ⊕HIT Idx G Gstr → G k
πₖ k = DS-Rec-Set.f _ _ _ _ (is-set (Gstr k))
(0g (Gstr k))
base-trad
(_+_ (Gstr k))
(+Assoc (Gstr k))
(+IdR (Gstr k))
(+Comm (Gstr k))
base-neutral-eq
base-add-eq
where
base-trad : (l : Idx) → (a : G l) → G k
base-trad l a with decIdx l k
... | yes p = subst G p a
... | no ¬p = 0g (Gstr k)
base-neutral-eq : _
base-neutral-eq l with decIdx l k
... | yes p = subst0g p
... | no ¬p = refl
base-add-eq : _
base-add-eq l a b with decIdx l k
... | yes p = subst+ a b p
... | no ¬p = +IdR (Gstr k) _
πₖ-id : {k : Idx} → (a : G k) → πₖ k (base k a) ≡ a
πₖ-id {k} a with decIdx k k
... | yes p = cong (λ X → subst G X a) (Discrete→isSet decIdx _ _ _ _) ∙ transportRefl _
... | no ¬p = rec (¬p refl)
πₖ-0g : {k l : Idx} → (a : G l) → (p : k ≡ l → ⊥) → πₖ k (base l a) ≡ 0g (Gstr k)
πₖ-0g {k} {l} a ¬q with decIdx l k
... | yes p = rec (¬q (sym p))
... | no ¬p = refl
base-inj : {k : Idx} → {a b : G k} → base {AGP = Gstr} k a ≡ base k b → a ≡ b
base-inj {k} {a} {b} p = sym (πₖ-id a) ∙ cong (πₖ k) p ∙ πₖ-id b
base-≢ : {k : Idx} → {a : G k} → {l : Idx} → {b : G l} → (p : k ≡ l → ⊥) →
base {AGP = Gstr} k a ≡ base {AGP = Gstr} l b → (a ≡ 0g (Gstr k)) × (b ≡ 0g (Gstr l))
base-≢ {k} {a} {l} {b} ¬p q = helper1 , helper2
where
helper1 : a ≡ 0g (Gstr k)
helper1 = sym (πₖ-id a) ∙ cong (πₖ k) q ∙ πₖ-0g b ¬p
helper2 : b ≡ 0g (Gstr l)
helper2 = sym (πₖ-id b) ∙ cong (πₖ l) (sym q) ∙ πₖ-0g a (λ x → ¬p (sym x))
|
{
"alphanum_fraction": 0.4574606117,
"avg_line_length": 38.2624113475,
"ext": "agda",
"hexsha": "38f6a06370610af26b0777e5ed5f4221debf43f8",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/Algebra/DirectSum/DirectSumHIT/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/Algebra/DirectSum/DirectSumHIT/Properties.agda",
"max_line_length": 124,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/Algebra/DirectSum/DirectSumHIT/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2065,
"size": 5395
}
|
-- Check that unquoted functions are termination checked.
module _ where
open import Common.Prelude hiding (_>>=_)
open import Common.Reflection
`⊥ : Type
`⊥ = def (quote ⊥) []
{-
Generate
aux : ⊥
aux = aux
loop : ⊥
loop = aux
-}
makeLoop : QName → TC ⊤
makeLoop loop =
freshName "aux" >>= λ aux →
declareDef (vArg aux) `⊥ >>= λ _ →
defineFun aux (clause [] (def aux []) ∷ []) >>= λ _ →
declareDef (vArg loop) `⊥ >>= λ _ →
defineFun loop (clause [] (def aux []) ∷ [])
unquoteDecl loop = makeLoop loop
|
{
"alphanum_fraction": 0.6030534351,
"avg_line_length": 19.4074074074,
"ext": "agda",
"hexsha": "72b2382f7bb7a41f02d8d7408a6158ca80113e0c",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/TerminationCheckUnquoteDecl.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "hborum/agda",
"max_issues_repo_path": "test/Fail/TerminationCheckUnquoteDecl.agda",
"max_line_length": 57,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "hborum/agda",
"max_stars_repo_path": "test/Fail/TerminationCheckUnquoteDecl.agda",
"max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z",
"num_tokens": 176,
"size": 524
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Definitions for types of functions that only require an equality
-- relation over the domain.
------------------------------------------------------------------------
-- The contents of this file should usually be accessed from `Function`.
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary
module Function.Definitions.Core1
{a ℓ₁} {A : Set a} (_≈₁_ : Rel A ℓ₁)
where
open import Level using (_⊔_)
------------------------------------------------------------------------
-- Definitions
-- (Note the name `RightInverse` is used for the bundle)
Inverseʳ : ∀ {b} {B : Set b} → (A → B) → (B → A) → Set (a ⊔ ℓ₁)
Inverseʳ f g = ∀ x → g (f x) ≈₁ x
|
{
"alphanum_fraction": 0.4702072539,
"avg_line_length": 29.6923076923,
"ext": "agda",
"hexsha": "a84dc37db4a11c8249f03d5fc93ba6287e87a919",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Function/Definitions/Core1.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Function/Definitions/Core1.agda",
"max_line_length": 72,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Function/Definitions/Core1.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 178,
"size": 772
}
|
------------------------------------------------------------------------
-- Parsers containing non-terminals, and grammars using such parsers
------------------------------------------------------------------------
module StructurallyRecursiveDescentParsing.Grammar where
open import Data.Bool
open import Data.Empty
open import Data.Product
open import Relation.Binary.PropositionalEquality
open import Codata.Musical.Notation
open import Level
open import StructurallyRecursiveDescentParsing.Index
import StructurallyRecursiveDescentParsing.Simplified as Simplified
open Simplified hiding (Parser; module Parser; ⟦_⟧)
infixl 10 _!>>=_ _?>>=_
infixl 5 _∣_
-- The parsers are parameterised on a type of nonterminals.
data Parser (NT : NonTerminalType) (Tok : Set) : NonTerminalType where
return : ∀ {R} (x : R) → Parser NT Tok (true ◇ ε) R
fail : ∀ {R} → Parser NT Tok (false ◇ ε) R
token : Parser NT Tok (false ◇ ε) Tok
_∣_ : ∀ {e₁ e₂ c₁ c₂ R}
(p₁ : Parser NT Tok (e₁ ◇ c₁ ) R)
(p₂ : Parser NT Tok ( e₂ ◇ c₂) R) →
Parser NT Tok (e₁ ∨ e₂ ◇ c₁ ∪ c₂) R
_?>>=_ : ∀ {e₂ c₁ c₂ R₁ R₂}
(p₁ : Parser NT Tok (true ◇ c₁ ) R₁)
(p₂ : R₁ → Parser NT Tok (e₂ ◇ c₂) R₂) →
Parser NT Tok (e₂ ◇ c₁ ∪ c₂) R₂
_!>>=_ : ∀ {c₁ R₁ R₂} {i₂ : R₁ → Index}
(p₁ : Parser NT Tok (false ◇ c₁) R₁)
(p₂ : (x : R₁) → ∞ (Parser NT Tok (i₂ x) R₂)) →
Parser NT Tok (false ◇ c₁) R₂
! : ∀ {e c R} (nt : NT (e ◇ c) R) → Parser NT Tok (e ◇ c ∪ ε) R
-- Grammars.
Grammar : NonTerminalType → Set → Set1
Grammar NT Tok = ∀ {i R} → NT i R → Parser NT Tok i R
-- An empty non-terminal type.
EmptyNT : NonTerminalType
EmptyNT _ _ = Lift _ ⊥
-- An empty grammar.
emptyGrammar : ∀ {Tok} → Grammar EmptyNT Tok
emptyGrammar (lift ())
-- The semantics of grammar-based parsers is defined in terms of their
-- translation into "plain" parsers. The translation instantiates all
-- non-terminals corecursively.
⟦_⟧ : ∀ {Tok NT e c R} →
Parser NT Tok (e ◇ c) R → Grammar NT Tok →
Simplified.Parser Tok e R
⟦ return x ⟧ g = return x
⟦ fail ⟧ g = fail
⟦ token ⟧ g = token
⟦ p₁ ∣ p₂ ⟧ g = ⟦ p₁ ⟧ g ∣ ⟦ p₂ ⟧ g
⟦ p₁ ?>>= p₂ ⟧ g = ⟦ p₁ ⟧ g ?>>= λ x → ⟦ p₂ x ⟧ g
⟦ p₁ !>>= p₂ ⟧ g = ⟦ p₁ ⟧ g !>>= λ x → ♯ ⟦ ♭ (p₂ x) ⟧ g
⟦ ! nt ⟧ g = ⟦ g nt ⟧ g
-- Note that some "plain" parsers cannot be directly rewritten using
-- the parser type in this module (although there may be /equivalent/
-- parsers):
private
only-plain : Simplified.Parser Bool false Bool
only-plain = return true ?>>= λ x →
if x then token else token ∣ token
-- The following code does not type-check.
-- doesnt-work : Parser EmptyNT Bool (false ◇ _) Bool
-- doesnt-work = return true ?>>= λ x →
-- if x then token else token ∣ token
-- A map function which can be useful when combining grammars.
mapNT : ∀ {NT₁ NT₂ Tok i R} →
(∀ {i R} → NT₁ i R → NT₂ i R) →
Parser NT₁ Tok i R → Parser NT₂ Tok i R
mapNT f (return x) = return x
mapNT f fail = fail
mapNT f token = token
mapNT f (p₁ ∣ p₂) = mapNT f p₁ ∣ mapNT f p₂
mapNT f (p₁ ?>>= p₂) = mapNT f p₁ ?>>= λ x → mapNT f (p₂ x)
mapNT f (p₁ !>>= p₂) = mapNT f p₁ !>>= λ x → ♯ mapNT f (♭ (p₂ x))
mapNT f (! nt) = ! (f nt)
|
{
"alphanum_fraction": 0.5481244548,
"avg_line_length": 32.7523809524,
"ext": "agda",
"hexsha": "cbceeedbfd9d2a6315f30d3f9cbfe42bd0c3e187",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/parser-combinators",
"max_forks_repo_path": "StructurallyRecursiveDescentParsing/Grammar.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/parser-combinators",
"max_issues_repo_path": "StructurallyRecursiveDescentParsing/Grammar.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/parser-combinators",
"max_stars_repo_path": "StructurallyRecursiveDescentParsing/Grammar.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z",
"num_tokens": 1152,
"size": 3439
}
|
{-# OPTIONS --universe-polymorphism #-}
module Categories.Square where
open import Level
open import Function renaming (id to idᶠ; _∘_ to _©_)
open import Categories.Support.PropositionalEquality
open import Categories.Category
import Categories.Morphisms as Mor
open import Relation.Binary hiding (_⇒_)
module GlueSquares {o ℓ e} (C : Category o ℓ e) where
private module C = Category C
open C
open Mor C
module Pulls {X Y Z} {a : Y ⇒ Z} {b : X ⇒ Y} {c : X ⇒ Z} (ab≡c : a ∘ b ≡ c) where
.pullʳ : ∀ {W} {f : Z ⇒ W} → (f ∘ a) ∘ b ≡ f ∘ c
pullʳ {f = f} =
begin
(f ∘ a) ∘ b
↓⟨ assoc ⟩
f ∘ (a ∘ b)
↓⟨ ∘-resp-≡ʳ ab≡c ⟩
f ∘ c
∎
where open HomReasoning
.pullˡ : ∀ {W} {f : W ⇒ X} → a ∘ (b ∘ f) ≡ c ∘ f
pullˡ {f = f} =
begin
a ∘ (b ∘ f)
↑⟨ assoc ⟩
(a ∘ b) ∘ f
↓⟨ ∘-resp-≡ˡ ab≡c ⟩
c ∘ f
∎
where open HomReasoning
open Pulls public
module Pushes {X Y Z} {a : Y ⇒ Z} {b : X ⇒ Y} {c : X ⇒ Z} (c≡ab : c ≡ a ∘ b) where
.pushʳ : ∀ {W} {f : Z ⇒ W} → f ∘ c ≡ (f ∘ a) ∘ b
pushʳ {f = f} =
begin
f ∘ c
↓⟨ ∘-resp-≡ʳ c≡ab ⟩
f ∘ (a ∘ b)
↑⟨ assoc ⟩
(f ∘ a) ∘ b
∎
where open HomReasoning
.pushˡ : ∀ {W} {f : W ⇒ X} → c ∘ f ≡ a ∘ (b ∘ f)
pushˡ {f = f} =
begin
c ∘ f
↓⟨ ∘-resp-≡ˡ c≡ab ⟩
(a ∘ b) ∘ f
↓⟨ assoc ⟩
a ∘ (b ∘ f)
∎
where open HomReasoning
open Pushes public
module IntroElim {X} {a : X ⇒ X} (a≡id : a ≡ id) where
.elimʳ : ∀ {W} {f : X ⇒ W} → (f ∘ a) ≡ f
elimʳ {f = f} =
begin
f ∘ a
↓⟨ ∘-resp-≡ʳ a≡id ⟩
f ∘ id
↓⟨ identityʳ ⟩
f
∎
where
open HomReasoning
.introʳ : ∀ {W} {f : X ⇒ W} → f ≡ f ∘ a
introʳ = Equiv.sym elimʳ
.elimˡ : ∀ {W} {f : W ⇒ X} → (a ∘ f) ≡ f
elimˡ {f = f} =
begin
a ∘ f
↓⟨ ∘-resp-≡ˡ a≡id ⟩
id ∘ f
↓⟨ identityˡ ⟩
f
∎
where
open HomReasoning
.introˡ : ∀ {W} {f : W ⇒ X} → f ≡ a ∘ f
introˡ = Equiv.sym elimˡ
open IntroElim public
module Extends {X Y Z W} {f : X ⇒ Y} {g : X ⇒ Z} {h : Y ⇒ W} {i : Z ⇒ W} (s : CommutativeSquare f g h i) where
.extendˡ : ∀ {A} {a : W ⇒ A} → CommutativeSquare f g (a ∘ h) (a ∘ i)
extendˡ {a = a} =
begin
(a ∘ h) ∘ f
↓⟨ pullʳ s ⟩
a ∘ i ∘ g
↑⟨ assoc ⟩
(a ∘ i) ∘ g
∎
where
open HomReasoning
.extendʳ : ∀ {A} {a : A ⇒ X} → CommutativeSquare (f ∘ a) (g ∘ a) h i
extendʳ {a = a} =
begin
h ∘ (f ∘ a)
↓⟨ pullˡ s ⟩
(i ∘ g) ∘ a
↓⟨ assoc ⟩
i ∘ (g ∘ a)
∎
where
open HomReasoning
.extend² : ∀ {A B} {a : W ⇒ A} {b : B ⇒ X} → CommutativeSquare (f ∘ b) (g ∘ b) (a ∘ h) (a ∘ i)
extend² {a = a} {b} =
begin
(a ∘ h) ∘ (f ∘ b)
↓⟨ pullʳ extendʳ ⟩
a ∘ (i ∘ (g ∘ b))
↑⟨ assoc ⟩
(a ∘ i) ∘ (g ∘ b)
∎
where
open HomReasoning
open Extends public
-- essentially composition in the arrow category
.glue : {X Y Y′ Z Z′ W : Obj} {a : Z ⇒ W} {a′ : Y′ ⇒ Z′} {b : Y ⇒ Z} {b′ : X ⇒ Y′} {c : X ⇒ Y} {c′ : Y′ ⇒ Z} {c″ : Z′ ⇒ W} → CommutativeSquare c′ a′ a c″ → CommutativeSquare c b′ b c′ → CommutativeSquare c (a′ ∘ b′) (a ∘ b) c″
glue {a = a} {a′} {b} {b′} {c} {c′} {c″} sq-a sq-b =
begin
(a ∘ b) ∘ c
↓⟨ pullʳ sq-b ⟩
a ∘ (c′ ∘ b′)
↓⟨ pullˡ sq-a ⟩
(c″ ∘ a′) ∘ b′
↓⟨ assoc ⟩
c″ ∘ (a′ ∘ b′)
∎
where
open HomReasoning
.glue◃◽ : {X Y Y′ Z W : Obj} {a : Z ⇒ W} {b : Y ⇒ Z} {b′ : X ⇒ Y′} {c : X ⇒ Y} {c′ : Y′ ⇒ Z} {c″ : Y′ ⇒ W} → a ∘ c′ ≡ c″ → CommutativeSquare c b′ b c′ → CommutativeSquare c b′ (a ∘ b) c″
glue◃◽ {a = a} {b} {b′} {c} {c′} {c″} tri-a sq-b =
begin
(a ∘ b) ∘ c
↓⟨ pullʳ sq-b ⟩
a ∘ (c′ ∘ b′)
↓⟨ pullˡ tri-a ⟩
c″ ∘ b′
∎
where
open HomReasoning
-- essentially composition in the over category
.glueTrianglesʳ : ∀ {X X′ X″ Y} {a : X ⇒ Y} {b : X′ ⇒ X} {a′ : X′ ⇒ Y} {b′ : X″ ⇒ X′} {a″ : X″ ⇒ Y}
→ a ∘ b ≡ a′ → a′ ∘ b′ ≡ a″ → a ∘ (b ∘ b′) ≡ a″
glueTrianglesʳ {a = a} {b} {a′} {b′} {a″} a∘b≡a′ a′∘b′≡a″ =
begin
a ∘ (b ∘ b′)
↓⟨ pullˡ a∘b≡a′ ⟩
a′ ∘ b′
↓⟨ a′∘b′≡a″ ⟩
a″
∎
where open HomReasoning
-- essentially composition in the under category
.glueTrianglesˡ : ∀ {X Y Y′ Y″} {b : X ⇒ Y} {a : Y ⇒ Y′} {b′ : X ⇒ Y′} {a′ : Y′ ⇒ Y″} {b″ : X ⇒ Y″} → a′ ∘ b′ ≡ b″ → a ∘ b ≡ b′ → (a′ ∘ a) ∘ b ≡ b″
glueTrianglesˡ {b = b} {a} {b′} {a′} {b″} a′∘b′≡b″ a∘b≡b′ =
begin
(a′ ∘ a) ∘ b
↓⟨ pullʳ a∘b≡b′ ⟩
a′ ∘ b′
↓⟨ a′∘b′≡b″ ⟩
b″
∎
where open HomReasoning
module Cancellers {Y Y′ : Obj} {h : Y′ ⇒ Y} {i : Y ⇒ Y′} (inv : h ∘ i ≡ id) where
.cancelRight : ∀ {Z} {f : Y ⇒ Z} → (f ∘ h) ∘ i ≡ f
cancelRight {f = f} =
begin
(f ∘ h) ∘ i
↓⟨ pullʳ inv ⟩
f ∘ id
↓⟨ identityʳ ⟩
f
∎
where open HomReasoning
.cancelLeft : ∀ {X} {f : X ⇒ Y} → h ∘ (i ∘ f) ≡ f
cancelLeft {f = f} =
begin
h ∘ (i ∘ f)
↓⟨ pullˡ inv ⟩
id ∘ f
↓⟨ identityˡ ⟩
f
∎
where open HomReasoning
.cancelInner : ∀ {X Z} {f : Y ⇒ Z} {g : X ⇒ Y} → (f ∘ h) ∘ (i ∘ g) ≡ f ∘ g
cancelInner {f = f} {g} =
begin
(f ∘ h) ∘ (i ∘ g)
↓⟨ pullˡ cancelRight ⟩
f ∘ g
∎
where open HomReasoning
open Cancellers public
module Switch {X Y} (i : X ≅ Y) where
open _≅_ i
.switch-fgˡ : ∀ {W} {h : W ⇒ X} {k : W ⇒ Y} → (f ∘ h ≡ k) → (h ≡ g ∘ k)
switch-fgˡ {h = h} {k} pf =
begin
h
↑⟨ cancelLeft isoˡ ⟩
g ∘ (f ∘ h)
↓⟨ ∘-resp-≡ʳ pf ⟩
g ∘ k
∎
where open HomReasoning
.switch-gfˡ : ∀ {W} {h : W ⇒ Y} {k : W ⇒ X} → (g ∘ h ≡ k) → (h ≡ f ∘ k)
switch-gfˡ {h = h} {k} pf =
begin
h
↑⟨ cancelLeft isoʳ ⟩
f ∘ (g ∘ h)
↓⟨ ∘-resp-≡ʳ pf ⟩
f ∘ k
∎
where open HomReasoning
.switch-fgʳ : ∀ {W} {h : Y ⇒ W} {k : X ⇒ W} → (h ∘ f ≡ k) → (h ≡ k ∘ g)
switch-fgʳ {h = h} {k} pf =
begin
h
↑⟨ cancelRight isoʳ ⟩
(h ∘ f) ∘ g
↓⟨ ∘-resp-≡ˡ pf ⟩
k ∘ g
∎
where open HomReasoning
.switch-gfʳ : ∀ {W} {h : X ⇒ W} {k : Y ⇒ W} → (h ∘ g ≡ k) → (h ≡ k ∘ f)
switch-gfʳ {h = h} {k} pf =
begin
h
↑⟨ cancelRight isoˡ ⟩
(h ∘ g) ∘ f
↓⟨ ∘-resp-≡ˡ pf ⟩
k ∘ f
∎
where open HomReasoning
open Switch public
module Yon-Eda {o ℓ e} (C : Category o ℓ e) where
private module C = Category C
open C
open Equiv
record Yon (X Y : Obj) : Set (o ⊔ ℓ ⊔ e) where
field
arr : X ⇒ Y
fun : ∀ {W} (f : W ⇒ X) → (W ⇒ Y)
.ok : ∀ {W} (f : W ⇒ X) → fun f ≡ arr ∘ f
norm : X ⇒ Y
norm = fun id
.norm≡arr : norm ≡ arr
norm≡arr = trans (ok id) identityʳ
record _≡′_ {X Y : Obj} (f g : Yon X Y) : Set (o ⊔ ℓ ⊔ e) where
constructor yeq
field
arr-≡ : Yon.arr f ≡ Yon.arr g
open _≡′_ public using (arr-≡)
module _ {X Y} where
.Yon-refl : Reflexive (_≡′_ {X} {Y})
Yon-refl = yeq refl
.Yon-sym : Symmetric (_≡′_ {X} {Y})
Yon-sym = yeq © sym © arr-≡
.Yon-trans : Transitive (_≡′_ {X} {Y})
Yon-trans eq eq′ = yeq (trans (arr-≡ eq) (arr-≡ eq′))
Yon-id : ∀ {X} → Yon X X
Yon-id = record
{ arr = id
; fun = idᶠ
; ok = λ _ → sym identityˡ
}
Yon-inject : ∀ {X Y} → (X ⇒ Y) → Yon X Y
Yon-inject f = record { arr = f; fun = _∘_ f; ok = λ _ → refl }
Yon-compose : ∀ {X Y Z} → (Yon Y Z) → (Yon X Y) → (Yon X Z)
Yon-compose g f = record
{ arr = g.fun f.arr
; fun = g.fun © f.fun
; ok = λ h → trans (g.ok (f.fun h)) (trans (∘-resp-≡ʳ (f.ok h)) (trans (sym assoc) (sym (∘-resp-≡ˡ (g.ok f.arr)))))
}
where
module g = Yon g
module f = Yon f
.Yon-assoc : ∀ {X Y Z W} (f : Yon Z W) (g : Yon Y Z) (h : Yon X Y) → Yon-compose f (Yon-compose g h) ≣ Yon-compose (Yon-compose f g) h
Yon-assoc f g h = ≣-refl
.Yon-identityˡ : ∀ {X Y} (f : Yon X Y) → Yon-compose Yon-id f ≣ f
Yon-identityˡ f = ≣-refl
.Yon-identityʳ : ∀ {X Y} (f : Yon X Y) → Yon-compose f Yon-id ≡′ f
Yon-identityʳ f = yeq (Yon.norm≡arr f)
.Yon-compose-resp-≡′ : ∀ {X Y Z} {f f′ : Yon Y Z} {g g′ : Yon X Y}
→ f ≡′ f′ → g ≡′ g′
→ Yon-compose f g ≡′ Yon-compose f′ g′
Yon-compose-resp-≡′ {f = f} {f′} {g} {g′} f≡′f′ g≡′g′
= yeq (trans (Yon.ok f (Yon.arr g))
(trans (∘-resp-≡ (arr-≡ f≡′f′) (arr-≡ g≡′g′))
(sym (Yon.ok f′ (Yon.arr g′)))))
record Eda (X Y : Obj) : Set (o ⊔ ℓ ⊔ e) where
field
yon : Yon X Y
fun : ∀ {Z} (f : Yon Y Z) → Yon X Z
.ok : ∀ {Z} (f : Yon Y Z) → fun f ≡′ Yon-compose f yon
norm : Yon X Y
norm = fun Yon-id
open Yon yon public using (arr)
Eda-id : ∀ {X} → Eda X X
Eda-id = record
{ yon = Yon-id
; fun = idᶠ
; ok = yeq © sym © arr-≡ © Yon-identityʳ
}
Eda-inject : ∀ {X Y} → Yon X Y → Eda X Y
Eda-inject f = record { yon = f; fun = flip Yon-compose f; ok = λ _ → yeq refl }
Eda-compose : ∀ {X Y Z} → (Eda Y Z) → (Eda X Y) → (Eda X Z)
Eda-compose {X} {Y} {Z} g f = record
{ yon = f.fun g.yon
; fun = f.fun © g.fun
; ok = λ {W} h → Yon-trans {X} {W} {f.fun (g.fun h)} (f.ok (g.fun h))
(Yon-trans (Yon-compose-resp-≡′ (g.ok h) (Yon-refl {x = f.yon}))
(Yon-sym (Yon-compose-resp-≡′ (Yon-refl {x = h}) (f.ok g.yon))))
}
where
module g = Eda g
module f = Eda f
.Eda-assoc : ∀ {X Y Z W} (f : Eda Z W) (g : Eda Y Z) (h : Eda X Y) → Eda-compose f (Eda-compose g h) ≣ Eda-compose (Eda-compose f g) h
Eda-assoc f g h = ≣-refl
-- .Eda-identityˡ : ∀ {X Y} (f : Eda X Y) → Eda-compose Eda-id f ≣ f
-- Eda-identityˡ f = {!!}
.Eda-identityʳ : ∀ {X Y} (f : Eda X Y) → Eda-compose f Eda-id ≣ f
Eda-identityʳ f = ≣-refl
record NormReasoning {o ℓ e} (C : Category o ℓ e) (o′ ℓ′ : _) : Set (suc o′ ⊔ o ⊔ ℓ ⊔ e ⊔ suc ℓ′) where
private module C = Category C
field
U : Set o′
T : U -> C.Obj
_#⇒_ : U -> U -> Set ℓ′
eval : ∀ {A B} -> A #⇒ B -> T A C.⇒ T B
norm : ∀ {A B} -> A #⇒ B -> T A C.⇒ T B
.norm≡eval : ∀ {A B} (f : A #⇒ B) -> norm f C.≡ eval f
open C.Equiv
open C
infix 4 _IsRelatedTo_
infix 1 begin_
infixr 2 _≈⟨_⟩_ _↓⟨_⟩_ _↑⟨_⟩_ _↓≡⟨_⟩_ _↑≡⟨_⟩_ _↕_
infix 3 _∎
data _IsRelatedTo_ {X Y} (f g : _#⇒_ X Y) : Set e where
relTo : (f∼g : norm f ≡ norm g) → f IsRelatedTo g
.begin_ : ∀ {X Y} {f g : _#⇒_ X Y} → f IsRelatedTo g → eval f ≡ eval g
begin_ {f = f} {g} (relTo f∼g) = trans (sym (norm≡eval f)) (trans f∼g (norm≡eval g))
._↓⟨_⟩_ : ∀ {X Y} (f : _#⇒_ X Y) {g h} → (norm f ≡ norm g) → g IsRelatedTo h → f IsRelatedTo h
_ ↓⟨ f∼g ⟩ relTo g∼h = relTo (trans f∼g g∼h)
._↑⟨_⟩_ : ∀ {X Y} (f : _#⇒_ X Y) {g h} → (norm g ≡ norm f) → g IsRelatedTo h → f IsRelatedTo h
_ ↑⟨ g∼f ⟩ relTo g∼h = relTo (trans (sym g∼f) g∼h)
-- the syntax of the ancients, for compatibility
._≈⟨_⟩_ : ∀ {X Y} (f : _#⇒_ X Y) {g h} → (norm f ≡ norm g) → g IsRelatedTo h → f IsRelatedTo h
_ ≈⟨ f∼g ⟩ relTo g∼h = relTo (trans f∼g g∼h)
._↓≡⟨_⟩_ : ∀ {X Y} (f : _#⇒_ X Y) {g h} → eval f ≡ eval g → g IsRelatedTo h → f IsRelatedTo h
_↓≡⟨_⟩_ f {g} f∼g (relTo g∼h) = relTo (trans (norm≡eval f) (trans f∼g (trans (sym (norm≡eval g)) g∼h)))
._↑≡⟨_⟩_ : ∀ {X Y} (f : _#⇒_ X Y) {g h} → eval g ≡ eval f → g IsRelatedTo h → f IsRelatedTo h
_↑≡⟨_⟩_ f {g} g∼f (relTo g∼h) = relTo (trans (norm≡eval f) (trans (sym g∼f) (trans (sym (norm≡eval g)) g∼h)))
._↕_ : ∀ {X Y} (f : _#⇒_ X Y) {h} → f IsRelatedTo h → f IsRelatedTo h
_ ↕ f∼h = f∼h
._∎ : ∀ {X Y} (f : _#⇒_ X Y) → f IsRelatedTo f
_∎ _ = relTo refl
.by_ : ∀ {X Y} {f g h : X ⇒ Y} -> ((h ≡ h) -> f ≡ g) -> f ≡ g
by eq = eq refl
.computation : ∀ {X Y} (f g : X #⇒ Y) -> norm f ≡ norm g → eval f ≡ eval g
computation f g eq = begin f ↓⟨ eq ⟩ g ∎
module AUReasoning {o ℓ e} (C : Category o ℓ e) where
private module C = Category C
open C
open Equiv
{-
infix 4 _IsRelatedTo_
infix 2 _∎
infixr 2 _≈⟨_⟩_
infixr 2 _↓⟨_⟩_
infixr 2 _↑⟨_⟩_
infixr 2 _↓≡⟨_⟩_
infixr 2 _↑≡⟨_⟩_
infixr 2 _↕_
infix 1 begin_
-}
infixr 8 _∙_
open Yon-Eda C public
data Climb : Rel Obj (o ⊔ ℓ) where
ID : ∀ {X} → Climb X X
leaf : ∀ {X Y} → (X ⇒ Y) → Climb X Y
_branch_ : ∀ {X Y Z} (l : Climb Y Z) (r : Climb X Y) → Climb X Z
interp : ∀ {p} (P : Rel Obj p)
(f-id : ∀ {X} → P X X)
(f-leaf : ∀ {X Y} → X ⇒ Y → P X Y)
(f-branch : ∀ {X Y Z} → P Y Z → P X Y → P X Z)
→ ∀ {X Y} → Climb X Y → P X Y
interp P f-id f-leaf f-branch ID = f-id
interp P f-id f-leaf f-branch (leaf y) = f-leaf y
interp P f-id f-leaf f-branch (l branch r) = f-branch
(interp P f-id f-leaf f-branch l)
(interp P f-id f-leaf f-branch r)
eval : ∀ {X Y} → Climb X Y → X ⇒ Y
eval = interp _⇒_ id idᶠ _∘_
yeval : ∀ {X Y} → Climb X Y → Yon X Y
yeval = interp Yon Yon-id Yon-inject Yon-compose
.yarr : ∀ {X Y} → (t : Climb X Y) → Yon.arr (yeval t) ≡ eval t
yarr ID = refl
yarr (leaf y) = refl
yarr (t branch t1) = trans (Yon.ok (yeval t) (Yon.arr (yeval t1))) (∘-resp-≡ (yarr t) (yarr t1))
eeval : ∀ {X Y} → Climb X Y → Eda X Y
eeval = interp Eda Eda-id (Eda-inject © Yon-inject) Eda-compose
.eyon : ∀ {X Y} → (t : Climb X Y) → Eda.yon (eeval t) ≡′ yeval t
eyon ID = Yon-refl
eyon (leaf y) = Yon-refl
eyon (t branch t1) = Yon-trans (Eda.ok (eeval t1) (Eda.yon (eeval t)))
(Yon-compose-resp-≡′ (eyon t) (eyon t1))
.earr : ∀ {X Y} → (t : Climb X Y) → Eda.arr (eeval t) ≡ eval t
earr t = trans (arr-≡ (eyon t)) (yarr t)
yyeval : ∀ {X Y} → (t : Climb X Y) → (X ⇒ Y)
yyeval = Eda.arr © eeval
record ClimbBuilder (X Y : Obj) {t} (T : Set t) : Set (o ⊔ ℓ ⊔ t) where
field build : T → Climb X Y
instance
leafBuilder : ∀ {X Y} → ClimbBuilder X Y (X ⇒ Y)
leafBuilder = record { build = leaf }
idBuilder : ∀ {X Y} → ClimbBuilder X Y (Climb X Y)
idBuilder = record { build = idᶠ }
_∙_ : ∀ {X Y Z} {s} {S : Set s} {{Sb : ClimbBuilder Y Z S}} (f : S) {t} {T : Set t} {{Tb : ClimbBuilder X Y T}} (g : T) → Climb X Z
_∙_ {{Sb}} f {{Tb}} g = ClimbBuilder.build Sb f branch ClimbBuilder.build Tb g
aureasoning : NormReasoning C o (ℓ ⊔ o)
aureasoning = record
{ U = Obj
; T = λ A → A
; _#⇒_ = Climb
; eval = eval
; norm = yyeval
; norm≡eval = earr
}
open NormReasoning aureasoning public hiding (eval)
{-
data _IsRelatedTo_ {X Y} (f g : Climb X Y) : Set e where
relTo : (f∼g : yyeval f ≡ yyeval g) → f IsRelatedTo g
.begin_ : ∀ {X Y} {f g : Climb X Y} → f IsRelatedTo g → eval f ≡ eval g
begin_ {f = f} {g} (relTo f∼g) = trans (sym (earr f)) (trans f∼g (earr g))
._↓⟨_⟩_ : ∀ {X Y} (f : Climb X Y) {g h} → (yyeval f ≡ yyeval g) → g IsRelatedTo h → f IsRelatedTo h
_ ↓⟨ f∼g ⟩ relTo g∼h = relTo (trans f∼g g∼h)
._↑⟨_⟩_ : ∀ {X Y} (f : Climb X Y) {g h} → (yyeval g ≡ yyeval f) → g IsRelatedTo h → f IsRelatedTo h
_ ↑⟨ g∼f ⟩ relTo g∼h = relTo (trans (sym g∼f) g∼h)
-- the syntax of the ancients, for compatibility
._≈⟨_⟩_ : ∀ {X Y} (f : Climb X Y) {g h} → (yyeval f ≡ yyeval g) → g IsRelatedTo h → f IsRelatedTo h
_ ≈⟨ f∼g ⟩ relTo g∼h = relTo (trans f∼g g∼h)
._↓≡⟨_⟩_ : ∀ {X Y} (f : Climb X Y) {g h} → eval f ≡ eval g → g IsRelatedTo h → f IsRelatedTo h
_↓≡⟨_⟩_ f {g} f∼g (relTo g∼h) = relTo (trans (earr f) (trans f∼g (trans (sym (earr g)) g∼h)))
._↑≡⟨_⟩_ : ∀ {X Y} (f : Climb X Y) {g h} → eval g ≡ eval f → g IsRelatedTo h → f IsRelatedTo h
_↑≡⟨_⟩_ f {g} g∼f (relTo g∼h) = relTo (trans (earr f) (trans (sym g∼f) (trans (sym (earr g)) g∼h)))
{-
-- XXX i want this to work whenever the Edas are equal -- but that probably
-- requires Climb to be indexed by yyeval! oh, for cheap ornamentation.
._↕_ : ∀ {X Y} (f : Climb X Y) {h} → f IsRelatedTo h → f IsRelatedTo h
_ ↕ f∼h = f∼h
-}
._∎ : ∀ {X Y} (f : Climb X Y) → f IsRelatedTo f
_∎ _ = relTo refl
-}
|
{
"alphanum_fraction": 0.4637299351,
"avg_line_length": 29.3561151079,
"ext": "agda",
"hexsha": "39937c3f6f68622cac23bd72579f0dce65493869",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "p-pavel/categories",
"max_forks_repo_path": "Categories/Square.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "p-pavel/categories",
"max_issues_repo_path": "Categories/Square.agda",
"max_line_length": 228,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "p-pavel/categories",
"max_stars_repo_path": "Categories/Square.agda",
"max_stars_repo_stars_event_max_datetime": "2018-12-29T21:51:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-12-29T21:51:57.000Z",
"num_tokens": 7701,
"size": 16322
}
|
-- Andreas, 2016-06-09 issue during refactoring for #1963
-- Shrunk this issue with projection-like functions from std-lib
-- {-# OPTIONS --show-implicit #-}
-- {-# OPTIONS -v tc.proj.like:10 #-}
open import Common.Level
open import Common.Nat renaming ( Nat to ℕ )
data ⊥ : Set where
record ⊤ : Set where
constructor tt
postulate anything : ∀{A : Set} → A
data _≤_ : (m n : ℕ) → Set where
z≤n : ∀ {n} → zero ≤ n
s≤s : ∀ {m n} (m≤n : m ≤ n) → suc m ≤ suc n
≤-refl : ∀{n} → n ≤ n
≤-refl {zero} = z≤n
≤-refl {suc n} = s≤s ≤-refl
≤-trans : ∀{k l m} → k ≤ l → l ≤ m → k ≤ m
≤-trans z≤n q = z≤n
≤-trans (s≤s p) (s≤s q) = s≤s (≤-trans p q)
n≤m+n : ∀ m n → n ≤ (m + n)
n≤m+n zero zero = z≤n
n≤m+n zero (suc n) = s≤s (n≤m+n zero n)
n≤m+n (suc m) zero = z≤n
n≤m+n (suc m) (suc n) = s≤s anything
record Preord c ℓ₁ : Set (lsuc (c ⊔ ℓ₁)) where
infix 4 _∼_
field
Carrier : Set c
_∼_ : (x y : Carrier) → Set ℓ₁ -- The relation.
refl : ∀{x} → x ∼ x
trans : ∀{x y z} → x ∼ y → y ∼ z → x ∼ z
Npreord : Preord _ _
Npreord = record { Carrier = ℕ ; _∼_ = _≤_ ; refl = ≤-refl; trans = ≤-trans }
module Pre {p₁ p₂} (P : Preord p₁ p₂) where
open Preord P
infix 4 _IsRelatedTo_
infix 3 _∎
infixr 2 _≤⟨_⟩_
infix 1 begin_
data _IsRelatedTo_ (x y : Carrier) : Set p₂ where
relTo : (x≤y : x ∼ y) → x IsRelatedTo y
begin_ : ∀ {x y} → x IsRelatedTo y → x ∼ y
begin relTo x≤y = x≤y
_≤⟨_⟩_ : ∀ x {y z} → x ∼ y → y IsRelatedTo z → x IsRelatedTo z
_ ≤⟨ x≤y ⟩ relTo y≤z = relTo (trans x≤y y≤z)
_∎ : ∀ x → x IsRelatedTo x
_∎ _ = relTo refl
-- begin_ : {p₁ p₂ : Level} (P : Preord p₁ p₂)
-- {x y : Preord.Carrier P} →
-- x IsRelatedTo y → (P Preord.∼ x) y
-- is projection like in argument 5 for type ProjectionLike1963.Pre._IsRelatedTo_
-- _∎ : {p₁ p₂ : Level} (P : Preord p₁ p₂) (x : Preord.Carrier P) →
-- x IsRelatedTo x
-- is projection like in argument 2 for type ProjectionLike1963.Preord
open Pre Npreord
_+-mono_ : ∀{m₁ m₂ n₁ n₂} → m₁ ≤ m₂ → n₁ ≤ n₂ → (m₁ + n₁) ≤ (m₂ + n₂)
_+-mono_ {zero} {m₂} {n₁} {n₂} z≤n n₁≤n₂ = begin
n₁ ≤⟨ n₁≤n₂ ⟩
n₂ ≤⟨ n≤m+n m₂ n₂ ⟩
m₂ + n₂ ∎
s≤s m₁≤m₂ +-mono n₁≤n₂ = s≤s (m₁≤m₂ +-mono n₁≤n₂)
ISS : ∀ {n m} (p : n ≤ m) → Set
ISS z≤n = ⊥
ISS (s≤s p) = ⊤
test : ISS ((z≤n {0}) +-mono (s≤s (z≤n {0})))
test = tt
-- Goal display:
-- C-u C-c C-, ISS (z≤n +-mono s≤s z≤n)
-- C-c C-, ISS (begin 1 ≤⟨ s≤s z≤n ⟩ 1 ≤⟨ s≤s z≤n ⟩ 1 ∎)
-- C-u C-u C-c C-, ISS (λ {y} → Pre.begin _)
|
{
"alphanum_fraction": 0.5262128326,
"avg_line_length": 26.625,
"ext": "agda",
"hexsha": "604b01ddce6698987183f8d03c8d67383bb258f3",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/ProjectionLike1963.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/ProjectionLike1963.agda",
"max_line_length": 82,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/ProjectionLike1963.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 1219,
"size": 2556
}
|
open import Level using (_⊔_; suc; Lift; lift)
open import Function using (_$_; _∘_; _⤖_)
open import Relation.Nullary using (¬_)
open import Relation.Nullary.Decidable using (False)
open import Relation.Binary using (Rel; Decidable; Setoid; DecSetoid; IsEquivalence; IsDecEquivalence)
open import Data.Empty using (⊥)
open import Data.Product using (∃-syntax; _,_)
open import Data.Sum using (_⊎_)
module AKS.Algebra.Structures {c ℓ} (C : Set c) (_≈_ : Rel C ℓ) where
open import Data.Unit using (⊤; tt)
open import Agda.Builtin.FromNat using (Number)
open import AKS.Nat using (ℕ; _<_; _≟_)
open import AKS.Fin using (Fin)
open import Algebra.Core using (Op₂; Op₁)
open import Algebra.Structures _≈_ using (IsCommutativeRing; IsAbelianGroup)
infix 4 _≉_
_≉_ : Rel C ℓ
x ≉ y = x ≈ y → ⊥
record IsNonZeroCommutativeRing (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) : Set (c ⊔ ℓ) where
field
isCommutativeRing : IsCommutativeRing _+_ _*_ -_ 0# 1#
0#≉1# : 0# ≉ 1#
open IsCommutativeRing isCommutativeRing public
open import Relation.Binary.Reasoning.Setoid setoid
open import Algebra.Properties.Ring (record { isRing = isRing }) using (-‿distribˡ-*; -‿involutive)
1#≉0# : 1# ≉ 0#
1#≉0# = 0#≉1# ∘ sym
0#≉-1# : 0# ≉ - 1#
0#≉-1# 0#≈-1# = 0#≉1# $ begin
0# ≈⟨ sym (zeroʳ 0#) ⟩
0# * 0# ≈⟨ *-cong 0#≈-1# 0#≈-1# ⟩
(- 1#) * (- 1#) ≈⟨ sym (-‿distribˡ-* 1# (- 1#)) ⟩
- (1# * (- 1#)) ≈⟨ -‿cong (*-identityˡ (- 1#)) ⟩
- (- 1#) ≈⟨ -‿involutive 1# ⟩
1# ∎
-1#≉0# : - 1# ≉ 0#
-1#≉0# = 0#≉-1# ∘ sym
C/0 : Set (c ⊔ ℓ)
C/0 = ∃[ x ] (x ≉ 0#)
1#-nonzero : C/0
1#-nonzero = 1# , 1#≉0#
-1#-nonzero : C/0
-1#-nonzero = - 1# , -1#≉0#
fromNat : ℕ → C
fromNat ℕ.zero = 0#
fromNat (ℕ.suc ℕ.zero) = 1#
fromNat (ℕ.suc (ℕ.suc n)) = 1# + fromNat (ℕ.suc n)
instance
C-number : Number C
C-number = record
{ Constraint = λ _ → Lift c ⊤
; fromNat = λ n → fromNat n
}
record IsIntegralDomain (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) : Set (c ⊔ ℓ) where
field
isNonZeroCommutativeRing : IsNonZeroCommutativeRing _+_ _*_ -_ 0# 1#
*-cancelˡ : ∀ x {y z} → x ≉ 0# → (x * y) ≈ (x * z) → y ≈ z
open IsNonZeroCommutativeRing isNonZeroCommutativeRing public
open import Relation.Binary.Reasoning.Setoid setoid
*-cancelʳ : ∀ x {y z} → x ≉ 0# → (y * x) ≈ (z * x) → y ≈ z
*-cancelʳ x {y} {z} x≉0 y*x≈z*x = *-cancelˡ x x≉0 $ begin
(x * y) ≈⟨ *-comm x y ⟩
(y * x) ≈⟨ y*x≈z*x ⟩
(z * x) ≈⟨ *-comm z x ⟩
(x * z) ∎
*≉0 : ∀ {c₁ c₂} → c₁ ≉ 0# → c₂ ≉ 0# → c₁ * c₂ ≉ 0#
*≉0 {c₁} {c₂} c₁≉0 c₂≉0 c₁*c₂≈0 = c₂≉0 $ *-cancelˡ c₁ c₁≉0 $ begin
(c₁ * c₂) ≈⟨ c₁*c₂≈0 ⟩
(0#) ≈⟨ sym (zeroʳ c₁) ⟩
(c₁ * 0#) ∎
infixl 7 _*-nonzero_
_*-nonzero_ : C/0 → C/0 → C/0
(c₁ , c₁≉0) *-nonzero (c₂ , c₂≉0) = c₁ * c₂ , *≉0 c₁≉0 c₂≉0
module Divisibility (_*_ : Op₂ C) where
infix 4 _∣_
record _∣_ (d : C) (a : C) : Set (c ⊔ ℓ) where
constructor divides
field
quotient : C
equality : a ≈ (quotient * d)
infix 4 _∤_
_∤_ : C → C → Set (c ⊔ ℓ)
d ∤ a = ¬ (d ∣ a)
record IsGCD (gcd : Op₂ C) : Set (c ⊔ ℓ) where
field
gcd[a,b]∣a : ∀ a b → gcd a b ∣ a
gcd[a,b]∣b : ∀ a b → gcd a b ∣ b
gcd-greatest : ∀ {c a b} → c ∣ a → c ∣ b → c ∣ gcd a b
record IsGCDDomain (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) (gcd : Op₂ C) : Set (c ⊔ ℓ) where
open Divisibility _*_ public
field
isIntegralDomain : IsIntegralDomain _+_ _*_ -_ 0# 1#
gcd-isGCD : IsGCD gcd
open IsIntegralDomain isIntegralDomain public
record IsUniqueFactorizationDomain (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) (gcd : Op₂ C) : Set (c ⊔ ℓ) where
field
isGCDDomain : IsGCDDomain _+_ _*_ -_ 0# 1# gcd
-- TODO define factorization
open IsGCDDomain isGCDDomain public
module Modulus
(0# : C) (∣_∣ : ∀ n {n≉0 : n ≉ 0#} → ℕ) (_mod_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C)
where
data Remainder (n : C) (m : C) {m≉0 : m ≉ 0#} : Set (c ⊔ ℓ) where
0≈ : (r≈0 : (n mod m) {m≉0} ≈ 0#) → Remainder n m
0≉ : (r≉0 : (n mod m) {m≉0} ≉ 0#) → ∣ n mod m ∣ {r≉0} < ∣ m ∣ {m≉0} → Remainder n m
module _
(_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) (∣_∣ : ∀ n {n≉0 : n ≉ 0#} → ℕ)
(_div_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C) (_mod_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C)
(gcd : Op₂ C)
where
record IsEuclideanDomain : Set (c ⊔ ℓ) where
open Modulus 0# ∣_∣ _mod_ public
field
isUniqueFactorizationDomain : IsUniqueFactorizationDomain _+_ _*_ -_ 0# 1# gcd
division : ∀ n m {m≉0 : m ≉ 0#} → n ≈ ((m * (n div m) {m≉0}) + (n mod m) {m≉0})
modulus : ∀ n m {m≉0 : m ≉ 0#} → Remainder n m {m≉0}
div-cong : ∀ {x₁ x₂} {y₁ y₂} → x₁ ≈ x₂ → y₁ ≈ y₂ → ∀ {y₁≉0 y₂≉0} → (x₁ div y₁) {y₁≉0} ≈ (x₂ div y₂) {y₂≉0}
mod-cong : ∀ {x₁ x₂} {y₁ y₂} → x₁ ≈ x₂ → y₁ ≈ y₂ → ∀ {y₁≉0 y₂≉0} → (x₁ mod y₁) {y₁≉0} ≈ (x₂ mod y₂) {y₂≉0}
open IsUniqueFactorizationDomain isUniqueFactorizationDomain public
record IsField (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C) (_/_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C) (gcd : Op₂ C) : Set (c ⊔ ℓ) where
field
isEuclideanDomain : IsEuclideanDomain _+_ _*_ -_ 0# 1# (λ _ → 0) _/_ (λ _ _ → 0#) gcd
open IsEuclideanDomain isEuclideanDomain public renaming (div-cong to /-cong)
open import Relation.Binary.Reasoning.Setoid setoid
m*[n/m]≈n : ∀ n m {m≉0 : m ≉ 0#} → (m * (n / m) {m≉0}) ≈ n
m*[n/m]≈n n m {m≉0} = begin
(m * (n / m) {m≉0}) ≈⟨ sym (+-identityʳ (m * (n / m) {m≉0})) ⟩
((m * (n / m) {m≉0}) + 0#) ≈⟨ sym (division n m) ⟩
n ∎
[n/m]*m≈n : ∀ n m {m≉0 : m ≉ 0#} → ((n / m) {m≉0} * m) ≈ n
[n/m]*m≈n n m {m≉0} = begin
((n / m) * m) ≈⟨ *-comm (n / m) m ⟩
(m * (n / m)) ≈⟨ m*[n/m]≈n n m ⟩
n ∎
/≉0 : ∀ {c₁ c₂} → c₁ ≉ 0# → (c₂≉0 : c₂ ≉ 0#) → (c₁ / c₂) {c₂≉0} ≉ 0#
/≉0 {c₁} {c₂} c₁≉0 c₂≉0 c₁/c₂≈0 = 0#≉1# $ *-cancelˡ c₂ c₂≉0 $ begin
c₂ * 0# ≈⟨ *-congˡ (sym (zeroˡ ((c₂ / c₁) {c₁≉0}))) ⟩
c₂ * (0# * (c₂ / c₁)) ≈⟨ *-congˡ (*-congʳ (sym (c₁/c₂≈0))) ⟩
c₂ * ((c₁ / c₂) * (c₂ / c₁)) ≈⟨ sym (*-assoc c₂ (c₁ / c₂) (c₂ / c₁)) ⟩
(c₂ * (c₁ / c₂)) * (c₂ / c₁) ≈⟨ *-congʳ (m*[n/m]≈n c₁ c₂) ⟩
c₁ * (c₂ / c₁) ≈⟨ m*[n/m]≈n c₂ c₁ ⟩
c₂ ≈⟨ sym (*-identityʳ c₂) ⟩
c₂ * 1# ∎
infixl 7 _/-nonzero_
_/-nonzero_ : C/0 → C/0 → C/0
(c₁ , c₁≉0) /-nonzero (c₂ , c₂≉0) = (c₁ / c₂) {c₂≉0} , /≉0 c₁≉0 c₂≉0
infix 8 _⁻¹
_⁻¹ : ∀ x {x≉0 : x ≉ 0#} → C
_⁻¹ x {x≉0} = (1# / x) {x≉0}
⁻¹-inverseʳ : ∀ x {x≉0 : x ≉ 0#} → (x * (x ⁻¹) {x≉0}) ≈ 1#
⁻¹-inverseʳ = m*[n/m]≈n 1#
⁻¹-inverseˡ : ∀ x {x≉0 : x ≉ 0#} → ((x ⁻¹) {x≉0} * x) ≈ 1#
⁻¹-inverseˡ = [n/m]*m≈n 1#
x⁻¹≉0 : ∀ x {x≉0 : x ≉ 0#} → (x ⁻¹) {x≉0} ≉ 0#
x⁻¹≉0 x {x≉0} = /≉0 1#≉0# x≉0
-- 0#≉1# $ begin
-- 0# ≈⟨ sym (zeroʳ x) ⟩
-- x * 0# ≈⟨ *-congˡ (sym x⁻¹≈0) ⟩
-- x * (x ⁻¹) {x≉0} ≈⟨ ⁻¹-inverseʳ x ⟩
-- 1# ∎
⁻¹-cong : ∀ {x y} {x≉0 : x ≉ 0#} {y≉0 : y ≉ 0#} → x ≈ y → (x ⁻¹) {x≉0} ≈ (y ⁻¹) {y≉0}
⁻¹-cong {x} {y} {x≉0} {y≉0} x≈y = *-cancelˡ x x≉0 $ begin
(x * (x ⁻¹)) ≈⟨ ⁻¹-inverseʳ x ⟩
1# ≈⟨ sym (⁻¹-inverseʳ y {y≉0}) ⟩
(y * (y ⁻¹)) ≈⟨ *-congʳ (sym x≈y) ⟩
(x * (y ⁻¹)) ∎
record IsDecField
(_≈?_ : Decidable _≈_) (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C)
(_/_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C) (gcd : Op₂ C) : Set (c ⊔ ℓ) where
field
isField : IsField _+_ _*_ -_ 0# 1# _/_ gcd
open IsField isField public
isDecEquivalence : IsDecEquivalence _≈_
isDecEquivalence = record
{ isEquivalence = isEquivalence
; _≟_ = _≈?_
}
record IsFiniteField
(_≈?_ : Decidable _≈_) (_+_ _*_ : Op₂ C) (-_ : Op₁ C) (0# 1# : C)
(_/_ : ∀ (n m : C) {m≉0 : m ≉ 0#} → C) (gcd : Op₂ C)
(cardinality : ℕ) : Set (suc c ⊔ ℓ) where
field
isDecField : IsDecField _≈?_ _+_ _*_ -_ 0# 1# _/_ gcd
C↦Fin[cardinality] : C ⤖ Fin cardinality
open IsDecField isDecField public
|
{
"alphanum_fraction": 0.4936373945,
"avg_line_length": 34.0643776824,
"ext": "agda",
"hexsha": "540820cf21cf6a86b6b2baa400b95275bfc95e7b",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mckeankylej/thesis",
"max_forks_repo_path": "proofs/AKS/Algebra/Structures.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mckeankylej/thesis",
"max_issues_repo_path": "proofs/AKS/Algebra/Structures.agda",
"max_line_length": 130,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ddad4c0d5f384a0219b2177461a68dae06952dde",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mckeankylej/thesis",
"max_stars_repo_path": "proofs/AKS/Algebra/Structures.agda",
"max_stars_repo_stars_event_max_datetime": "2020-12-01T22:38:27.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-12-01T22:38:27.000Z",
"num_tokens": 4168,
"size": 7937
}
|
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
record Eq (A : Set) : Set₁ where
field
_≈_ : A → A → Set
open Eq {{...}} public
record Setoid : Set₁ where
field
∣_∣ : Set
{{eq}} : Eq ∣_∣
open Setoid public
-- instance
-- EqNat : Eq Nat
-- _≈_ {{EqNat}} = _≡_
NatSetoid : Setoid
∣ NatSetoid ∣ = Nat
-- Should give: No instance of type Eq Nat
|
{
"alphanum_fraction": 0.6062176166,
"avg_line_length": 15.44,
"ext": "agda",
"hexsha": "80ee8855487acece6d9629f0356b3be9f95054ae",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Fail/Issue2288.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Fail/Issue2288.agda",
"max_line_length": 42,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Issue2288.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 145,
"size": 386
}
|
open import Data.Bool
module GUIgeneric.GUIExample where
open import GUIgeneric.Prelude renaming (inj₁ to secondBtn; inj₂ to firstBtn; WxColor to Color) hiding (addButton; _>>_)
open import GUIgeneric.GUIDefinitions renaming (add to add'; add' to add)
open import GUIgeneric.GUI
open import GUIgeneric.GUIExampleLib renaming (addButton to addButton')
open import Data.Product
addButton : String → Frame → Frame
addButton str fr = addButton' str fr optimized
addTxtBox : String → Frame → Frame
addTxtBox str fr = addTxtBox' str fr optimized
oneBtnGUI : Frame
oneBtnGUI = addButton "OK" create-frame
twoBtnGUI : Frame
twoBtnGUI = addButton "Cancel" oneBtnGUI
-- Attributes
--
Cols = ℕ
Margin = ℕ
HSpace = ℕ
VSpace = ℕ
oneColumnLayout : Cols × Margin × HSpace × VSpace
oneColumnLayout = (1 , 10 , 2 , 2)
black : Color
black = rgb 0 0 0
propOneBtn : properties oneBtnGUI
propOneBtn = black , oneColumnLayout
propTwoBtn : properties twoBtnGUI
propTwoBtn = black , black , oneColumnLayout
putStr' : {A : Set} → String → (f : IO GuiLev1Interface ∞ A) →
IO GuiLev1Interface ∞ A
putStr' s f = do (putStrLn s) (λ _ → f)
syntax putStr' s f = putStrLn s >> f
keepGUI : {j : Size} → HandlerObject j twoBtnGUI →
IO GuiLev1Interface ∞
(Σ-syntax (returnType twoBtnGUI)
(λ r →
IOObjectˢ GuiLev1Interface handlerInterface j
(nextStateFrame twoBtnGUI r)))
keepGUI = λ obj → return (noChange , obj)
changeGUI : ∀ {j} (g : CompEls frame) {g'} (prop : properties g) obj →
IO GuiLev1Interface ∞ (Σ (returnType g') (\r -> IOObjectˢ GuiLev1Interface handlerInterface j (nextStateFrame g' r)))
changeGUI = λ g prop obj → return (changedGUI g prop , obj)
mutual
objTwoBtnGUI' : ∀ i → HandlerObject i twoBtnGUI
objTwoBtnGUI' i .method {j} (secondBtn bt) =
putStrLn "Cancel Fired! NO GUI Change." >>
keepGUI (objTwoBtnGUI' j)
objTwoBtnGUI' i .method {j} (firstBtn bt) =
putStrLn "OK Fired! Redefining GUI." >>
changeGUI oneBtnGUI propOneBtn (objOneBtnGUI' j)
objOneBtnGUI' : ∀ i → HandlerObject i oneBtnGUI
objOneBtnGUI' i .method {j} bt =
putStrLn "OK Fired! Redefining GUI." >>
changeGUI twoBtnGUI propTwoBtn (objTwoBtnGUI' j)
obj2Btn : ∀ {i} → HandlerObject i twoBtnGUI
obj2Btn .method (firstBtn bt) =
putStrLn "OK fired! Redefining GUI." >>
changeGUI oneBtnGUI propOneBtn obj1Btn
obj2Btn .method (secondBtn bt) =
putStrLn "Cancel fired! No GUI change." >>
keepGUI obj2Btn
obj1Btn : ∀ {i} → HandlerObject i oneBtnGUI
obj1Btn .method bt =
putStrLn "OK fired! Redefining GUI." >>
changeGUI twoBtnGUI propTwoBtn obj2Btn
main : NativeIO Unit
main = compileProgram twoBtnGUI propTwoBtn
(obj2Btn {∞})
|
{
"alphanum_fraction": 0.6935074356,
"avg_line_length": 25.5277777778,
"ext": "agda",
"hexsha": "98b6f366f0e14e9afd46cfbb601e1fb11e582f5e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "stephanadls/state-dependent-gui",
"max_forks_repo_path": "examples/GUIgeneric/GUIExample.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "stephanadls/state-dependent-gui",
"max_issues_repo_path": "examples/GUIgeneric/GUIExample.agda",
"max_line_length": 131,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "2bc84cb14a568b560acb546c440cbe0ddcbb2a01",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "stephanadls/state-dependent-gui",
"max_stars_repo_path": "examples/GUIgeneric/GUIExample.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-31T17:20:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-31T15:37:39.000Z",
"num_tokens": 842,
"size": 2757
}
|
-- {-# OPTIONS -v tc.conv.level:60 #-}
-- {-# OPTIONS -v tc.conv:30 #-}
{- Agda development version: Wed Oct 30 16:30:06 GMT 2013
The last line of code triggers the following error,
but replacing '_' with 'a' typechecks just fine.
Bug.agda:32,8-11
tt != a of type ⊤
when checking that the expression s _ has type P tt → P a
Changing 'Set (q a)' to 'Set' in line 26 suppresses the error.
-}
-- Andreas, 2013-10-31 Fixed by retrying sort comparison after
-- successful type comparison (which might have solve the missing level metas).
module Issue930 where
open import Common.Level
data ⊤ : Set where
tt : ⊤
postulate
q : ⊤ → Level
P : (a : ⊤) → Set (q a)
s : (a : ⊤) → P tt → P a
a : ⊤
g : (P tt → P a) → ⊤
v : ⊤
v = g (s _)
{-
coerce term v = s ?1
from type t1 = P tt → P ?1
to type t2 = P tt → P a
equalSort
Set (q tt ⊔ q ?1) == Set (q a ⊔ q tt)
compareAtom q tt == q a : Level
compareTerm tt == a : ⊤
sort comparison failed -- THIS ERROR IS CAUGHT, BUT RETHROWN AT THE END
compareTerm P tt → P ?1 =< P tt → P a : Set (q tt ⊔ q ?1)
compare function types
t1 = P tt → P ?1
t2 = P tt → P a
equalSort
Set (q ?1) == Set (q a)
compareTerm ?1 == a : ⊤
attempting shortcut ?1 := a
solving _13 := a
-}
|
{
"alphanum_fraction": 0.5957446809,
"avg_line_length": 22.6607142857,
"ext": "agda",
"hexsha": "f1ff8f5b2fda1c842a2af126b2ece0d275044909",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/Issue930.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue930.agda",
"max_line_length": 79,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue930.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 453,
"size": 1269
}
|
module x01-842Naturals where
-- This is a comment.
{-
This is a multi-line comment
-}
-- Definition of datatype representing natural numbers. ♭
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
-- A couple of definitions using this datatype.
one : ℕ
one = suc zero
two : ℕ
two = suc (suc zero)
-- I could have also said two = suc one.
-- PLFA exercise: write out seven.
-- Pragma to use decimal notation as shorthand.
{-# BUILTIN NATURAL ℕ #-}
-- Some useful imports from the standard library:
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl)
open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎)
-- Addition on naturals.
_+_ : ℕ → ℕ → ℕ
zero + n = n
suc m + n = suc {!m + n!}
-- Agda normalization; proof of equality.
_ : 2 + 3 ≡ 5
_ = refl
-- Equational reasoning.
_ : 2 + 3 ≡ 5
_ =
begin
2 + 3
≡⟨⟩ -- is shorthand for
(suc (suc zero)) + (suc (suc (suc zero)))
≡⟨⟩ -- many steps condensed
5
∎
-- PLFA shows longhand and shorthand are interchangeable.
-- PLFA exercise: write out the reduction for 3+4 equationally.
-- Multiplication.
_*_ : ℕ → ℕ → ℕ
m * n = {!!}
_ =
begin
2 * 3
≡⟨⟩ -- many steps condensed
6
∎
-- PLFA exercise: write out 3*4.
-- 842 exercise: Exponentiation (1 point)
-- Define exponentiation (m raised to the power n).
_^_ : ℕ → ℕ → ℕ
m ^ n = {!!}
-- One test for exponentiation (you should write others).
_ : 2 ^ 3 ≡ 8
_ = refl
-- Monus (subtraction for naturals, bottoms out at zero).
_∸_ : ℕ → ℕ → ℕ
m ∸ n = {!!}
_ =
begin
3 ∸ 2
≡⟨⟩ -- many steps condensed
1
∎
_ =
begin
2 ∸ 3
≡⟨⟩ -- many steps condensed
0
∎
-- PLFA exercise: write out 5 ∸ 3 and 3 ∸ 5.
infixl 6 _+_ _∸_
infixl 7 _*_
-- These pragmas will register our operations, if we want,
-- so that they work with decimal notation.
-- {-# BUILTIN NATPLUS _+_ #-}
-- {-# BUILTIN NATTIMES _*_ #-}
-- {-# BUILTIN NATMINUS _∸_ #-}
-- Binary representation.
-- Modified from PLFA exercise (thanks to David Darais).
data Bin-ℕ : Set where
bits : Bin-ℕ
_x0 : Bin-ℕ → Bin-ℕ
_x1 : Bin-ℕ → Bin-ℕ
-- Our representation of zero is different from PLFA.
-- We use the empty sequence of bits (more consistent).
bin-zero : Bin-ℕ
bin-zero = bits
bin-one : Bin-ℕ
bin-one = bits x1 -- 1 in binary
bin-two : Bin-ℕ
bin-two = bits x1 x0 -- 10 in binary
-- 842 exercise: Increment (1 point)
-- Define increment (add one).
inc : Bin-ℕ → Bin-ℕ
inc m = {!!}
-- An example/test of increment (you should create others).
_ : inc (bits x1 x0 x1 x1) ≡ bits x1 x1 x0 x0
_ = refl
-- 842 exercise: To/From (2 points)
-- Define 'tob' and 'fromb' operations
-- to convert between unary (ℕ) and binary (Bin-ℕ) notation.
-- Hint: avoid addition and multiplication,
-- and instead use the provided dbl (double) function.
-- This will make later proofs easier.
-- I've put 'b' on the end of the operations to
-- avoid a name clash in a later file.
-- It also makes the direction clear when using them.
dbl : ℕ → ℕ
dbl zero = zero
dbl (suc m) = suc (suc (dbl m))
tob : ℕ → Bin-ℕ
tob m = {!!}
fromb : Bin-ℕ → ℕ
fromb n = {!!}
-- A couple of examples/tests (you should create others).
_ : tob 6 ≡ bits x1 x1 x0
_ = refl
_ : fromb (bits x1 x1 x0) ≡ 6
_ = refl
-- 842 exercise: BinAdd (2 points)
-- Write the addition function for binary notation.
-- Do NOT use 'to' and 'from'. Work with Bin-ℕ as if ℕ did not exist.
-- Hint: use recursion on both m and n.
_bin-+_ : Bin-ℕ → Bin-ℕ → Bin-ℕ
m bin-+ n = {!!}
-- Tests can use to/from, or write out binary constants as below.
-- Again: write more tests!
_ : (bits x1 x0) bin-+ (bits x1 x1) ≡ (bits x1 x0 x1)
_ = refl
-- That's it for now, but we will return to binary notation later.
-- Many definitions from above are also in the standard library.
-- open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _^_; _∸_)
-- Unicode used in this chapter:
{-
ℕ U+2115 DOUBLE-STRUCK CAPITAL N (\bN)
→ U+2192 RIGHTWARDS ARROW (\to, \r, \->)
∸ U+2238 DOT MINUS (\.-)
≡ U+2261 IDENTICAL TO (\==)
⟨ U+27E8 MATHEMATICAL LEFT ANGLE BRACKET (\<)
⟩ U+27E9 MATHEMATICAL RIGHT ANGLE BRACKET (\>)
∎ U+220E END OF PROOF (\qed)
-}
|
{
"alphanum_fraction": 0.6249405045,
"avg_line_length": 19.9146919431,
"ext": "agda",
"hexsha": "56e2faf5012a0310a8a214a0b3932203ce1abe85",
"lang": "Agda",
"max_forks_count": 8,
"max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z",
"max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc",
"max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x01-842Naturals.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc",
"max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x01-842Naturals.agda",
"max_line_length": 69,
"max_stars_count": 36,
"max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc",
"max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x01-842Naturals.agda",
"max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z",
"num_tokens": 1442,
"size": 4202
}
|
-- Andreas, 2018-05-28, issue #3095, fail on attempt to make hidden parent variable visible
data Nat : Set where
suc : {n : Nat} → Nat
data IsSuc : Nat → Set where
isSuc : ∀{n} → IsSuc (suc {n})
test : ∀{m} → IsSuc m → Set
test p = aux p
where
aux : ∀{n} → IsSuc n → Set
aux isSuc = {!.m!} -- Split on .m here
-- Context:
-- p : IsSuc .m
-- .m : Nat
-- .n : Nat
-- Expected error:
-- Cannot split on module parameter .m
-- when checking that the expression ? has type Set
|
{
"alphanum_fraction": 0.6032719836,
"avg_line_length": 21.2608695652,
"ext": "agda",
"hexsha": "dce10ae403b7b2e782498e896631ca4a4111ae49",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/interaction/Issue3095-fail.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/interaction/Issue3095-fail.agda",
"max_line_length": 91,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/interaction/Issue3095-fail.agda",
"max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z",
"num_tokens": 171,
"size": 489
}
|
{-# OPTIONS --without-K --safe #-}
module Categories.Minus2-Category.Properties where
-- All -2-Categories are equivalent to One
open import Level
open import Data.Product using (Σ; _,_; proj₁; proj₂)
open import Data.Unit using (⊤; tt)
open import Categories.Minus2-Category
open import Categories.Category
import Categories.Morphism as M
open import Categories.Category.Monoidal
open import Categories.Category.Instance.One
open import Categories.Category.Equivalence hiding (refl)
open import Categories.NaturalTransformation using (ntHelper)
private
variable
o ℓ e : Level
shrink-them-all : (X : -2-Category {o} {ℓ} {e}) → StrongEquivalence (-2-Category.cat X) (One {o} {ℓ} {e})
shrink-them-all X = record
{ F = record
{ F₀ = λ _ → lift tt
; F₁ = λ _ → lift tt
}
; G = record
{ F₀ = λ _ → proj₁ Obj-Contr
; F₁ = λ _ → M._≅_.from (proj₂ Obj-Contr (proj₁ Obj-Contr))
; identity = Hom-Conn
; homomorphism = Hom-Conn
; F-resp-≈ = λ _ → Hom-Conn
}
; weak-inverse = record
{ F∘G≈id = _
; G∘F≈id = record
{ F⇒G = ntHelper (record
{ η = λ y → M._≅_.from (proj₂ Obj-Contr y)
; commute = λ _ → Hom-Conn
})
; F⇐G = ntHelper (record
{ η = λ y → M._≅_.to (proj₂ Obj-Contr y)
; commute = λ _ → Hom-Conn
})
; iso = λ Z → record
{ isoˡ = M._≅_.isoˡ (proj₂ Obj-Contr Z)
; isoʳ = M._≅_.isoʳ (proj₂ Obj-Contr Z)
}
}
}
}
where
open -2-Category X
open Category cat
|
{
"alphanum_fraction": 0.6044678055,
"avg_line_length": 26.701754386,
"ext": "agda",
"hexsha": "23def69502ccde6368272f5648a846a698a23454",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Minus2-Category/Properties.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Minus2-Category/Properties.agda",
"max_line_length": 105,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Minus2-Category/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z",
"num_tokens": 504,
"size": 1522
}
|
module gc where
open import lib
-- we will model addresses in memory as just natural numbers
Address : Set
Address = ℕ
-- a value of type (Bounded n) is an address a together with a proof that a is less than n
Bounded : Address → Set
Bounded n = Σ Address (λ a → a < n ≡ tt)
-- a (Cell a) models an addressable cell of memory
data Cell(bound : Address) : Set where
Scalar : ℕ → Cell bound -- this represents a cell with no outgoing pointers, just a natural number value
Pointers : ∀ (p1 p2 : Bounded bound) → Cell bound -- this cell has exactly two outgoing pointers
{- a (well-formed) memory is a vector of m cells, where all pointers in those cells are bounded by n.
This is just a way of expressing that the memory does not have any pointers heading off to some
illegal locations (outside the allocated memory). -}
Memory : Address → Set
Memory m = 𝕍 (Cell m) m
-- return a list of natural numbers from n-1 down to 0. [5 points]
nats : ∀(n : ℕ) → 𝕍 ℕ n
nats zero = []
nats (suc n) = n :: (nats n)
-- when the definition of nats is correct, the highlighting will disappear from refl below:
test-nats : nats 3 ≡ 2 :: 1 :: 0 :: []
test-nats = refl
{- (outgoingPointers m mem b) returns the list of outgoing pointers at the location
given by b in the Memory m. This is either empty (for Scalar) or a list of length
two (for Pointers).
Hint: there is already a function in vector.agda in the IAL that can find the Cell
for you from mem and b.
[10 points] -}
outgoingPointers : ∀ (m : Address) → Memory m → Bounded m → 𝕃 (Bounded m)
outgoingPointers n mem (j , k) with (nth𝕍 j k mem)
... | Scalar c = []
... | Pointers x y = x :: y :: []
{- (doMark u unmarked m b) is supposed to return (just v) if the address
given by b is a member of unmarked, and v is the result of removing that
address from unmarked. If the address given by b is not in unmarked,
then return none. This function simulates marking a cell by removing
it (if it is there) from the vector of unmarked cells. Because the
length of the vector decreases, we can recurse in markh on the result
if we need to.
[17 points]
-}
doMark : ∀(u : ℕ)(unmarked : 𝕍 Address (suc u)) → (m : Address) → Bounded m → maybe (𝕍 Address u)
doMark u ( x :: unmarked ) m ( a , b ) with ( a =ℕ x )
... | tt = just unmarked
doMark 0 ( x :: [] ) m ( a , b ) | ff = nothing
doMark ( suc u ) ( x :: x1 :: unmarked ) m ( a , b ) | ff with ( doMark u ( x1 :: unmarked ) m ( a , b ) )
... | nothing = nothing
... | just unmarked1 = just ( x :: unmarked1 )
{- given a list of unmarked addresses and a Memory m, and a worklist of addresses, return the
list of all unmarked addresses that are not reachable in the memory from an address in the
worklist. So this is basically implementing mark and sweep gc, where addresses are considered
marked if they do not appear in unmarked, and you use outgoingPointers to update the worklist
when it is time to recurse.
[18 points]
-}
markh : ∀(u : ℕ)(unmarked : 𝕍 Address u) → (m : Address) → Memory m → (worklist : 𝕃 (Bounded m)) → 𝕃 Address
markh u [] m x worklist = []
markh u unmarked m x [] = 𝕍-to-𝕃 unmarked
markh ( suc u ) unmarked m x ( x1 :: worklist ) with ( doMark u unmarked m x1 )
... | nothing = markh ( suc u ) unmarked m x worklist
... | just something = markh u something m x ( worklist ++ ( outgoingPointers m x x1 ) )
{- the final mark-and-sweep function, which just takes in a memory and list of roots, and
returns the addresses not reachable in that memory from one of the roots. -}
mark : ∀(m : Address) → Memory m → (roots : 𝕃 (Bounded m)) → 𝕃 Address
mark m memory roots = markh m (nats m) m memory roots
----------------------------------------------------------------------
-- a test case:
test-memory : Memory 3
test-memory = Pointers (0 , refl) (2 , refl) :: Pointers (0 , refl) (2 , refl) :: Pointers (0 , refl) (0 , refl) :: []
test-roots : 𝕃 (Bounded 3)
test-roots = [ (0 , refl) ]
-- the addresses not reachable from address 0 by following pointers in test-memory
test-garbage : 𝕃 Address
test-garbage = mark 3 test-memory test-roots
-- if the implementation above is correct, highlighting on refl below will disappear
test-check : test-garbage ≡ 1 :: []
test-check = refl
|
{
"alphanum_fraction": 0.6487414188,
"avg_line_length": 43.7,
"ext": "agda",
"hexsha": "84629b4eed5c63a441fbf9526a4303a37aebaa15",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c2da60d7becdbb809aae20e7a6df6ea509b991c5",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout8",
"max_forks_repo_path": "gc.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c2da60d7becdbb809aae20e7a6df6ea509b991c5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout8",
"max_issues_repo_path": "gc.agda",
"max_line_length": 119,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c2da60d7becdbb809aae20e7a6df6ea509b991c5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DTMcNamara/CS3820-ProgrammingLanguageConcepts-Workout8",
"max_stars_repo_path": "gc.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1255,
"size": 4370
}
|
{-
In this file we apply the cubical machinery to Martin Hötzel-Escardó's
structure identity principle:
https://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html#sns
-}
{-# OPTIONS --cubical --safe #-}
module Cubical.Foundations.SIP where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Univalence renaming (ua-pathToEquiv to ua-pathToEquiv')
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Path
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.Properties renaming (cong≃ to _⋆_)
open import Cubical.Foundations.HAEquiv
open import Cubical.Data.Prod.Base hiding (_×_) renaming (_×Σ_ to _×_)
open import Cubical.Foundations.Structure public
private
variable
ℓ₁ ℓ₂ ℓ₃ ℓ₄ ℓ₅ : Level
S : Type ℓ₁ → Type ℓ₂
-- For technical reasons we reprove ua-pathToEquiv using the
-- particular proof constructed by iso→HAEquiv. The reason is that we
-- want to later be able to extract
--
-- eq : ua-au (ua e) ≡ cong ua (au-ua e)
--
uaHAEquiv : (A B : Type ℓ₁) → HAEquiv (A ≃ B) (A ≡ B)
uaHAEquiv A B = iso→HAEquiv (iso ua pathToEquiv ua-pathToEquiv' pathToEquiv-ua)
open isHAEquiv
-- We now extract the particular proof constructed from iso→HAEquiv
-- for reasons explained above.
ua-pathToEquiv : {A B : Type ℓ₁} (e : A ≡ B) → ua (pathToEquiv e) ≡ e
ua-pathToEquiv e = uaHAEquiv _ _ .snd .ret e
-- Note that for any equivalence (f , e) : X ≃ Y the type ι (X , s) (Y , t) (f , e) need not to be
-- a proposition. Indeed this type should correspond to the ways s and t can be identified
-- as S-structures. This we call a standard notion of structure or SNS.
-- We will use a different definition, but the two definitions are interchangeable.
SNS-≡ : (S : Type ℓ₁ → Type ℓ₂) (ι : StrIso S ℓ₃) → Type (ℓ-max (ℓ-max (ℓ-suc ℓ₁) ℓ₂) ℓ₃)
SNS-≡ {ℓ₁} S ι = ∀ {X : Type ℓ₁} (s t : S X) → ι (X , s) (X , t) (idEquiv X) ≃ (s ≡ t)
-- We introduce the notation for structure preserving equivalences a
-- bit differently, but this definition doesn't actually change from
-- Escardó's notes.
_≃[_]_ : (A : TypeWithStr ℓ₁ S) (ι : StrIso S ℓ₂) (B : TypeWithStr ℓ₁ S) → Type (ℓ-max ℓ₁ ℓ₂)
A ≃[ ι ] B = Σ[ e ∈ typ A ≃ typ B ] (ι A B e)
-- The following PathP version of SNS-≡ is a bit easier to work with
-- for the proof of the SIP
SNS-PathP : (S : Type ℓ₁ → Type ℓ₂) (ι : StrIso S ℓ₃) → Type (ℓ-max (ℓ-max (ℓ-suc ℓ₁) ℓ₂) ℓ₃)
SNS-PathP {ℓ₁} S ι = {A B : TypeWithStr ℓ₁ S} (e : typ A ≃ typ B)
→ ι A B e ≃ PathP (λ i → S (ua e i)) (str A) (str B)
-- A quick sanity-check that our definition is interchangeable with
-- Escardó's. The direction SNS-≡→SNS-PathP corresponds more or less
-- to a dependent EquivJ formulation of Escardó's homomorphism-lemma.
SNS-PathP→SNS-≡ : (S : Type ℓ₁ → Type ℓ₂) (ι : StrIso S ℓ₃) → SNS-PathP S ι → SNS-≡ S ι
SNS-PathP→SNS-≡ S ι θ {X = X} s t = ι (X , s) (X , t) (idEquiv X) ≃⟨ θ (idEquiv X) ⟩
PathP (λ i → S (ua (idEquiv X) i)) s t ≃⟨ φ ⟩
s ≡ t ■
where
φ = transportEquiv (λ j → PathP (λ i → S (uaIdEquiv {A = X} j i)) s t)
SNS-≡→SNS-PathP : (ι : StrIso S ℓ₃) → SNS-≡ S ι → SNS-PathP S ι
SNS-≡→SNS-PathP {S = S} ι θ {A = A} {B = B} e = EquivJ P C e (str A) (str B)
where
Y = typ B
P : (X : Type _) → X ≃ Y → Type _
P X e' = (s : S X) (t : S Y) → ι (X , s) (Y , t) e' ≃ PathP (λ i → S (ua e' i)) s t
C : (s t : S Y) → ι (Y , s) (Y , t) (idEquiv Y) ≃ PathP (λ i → S (ua (idEquiv Y) i)) s t
C s t = ι (Y , s) (Y , t) (idEquiv Y) ≃⟨ θ s t ⟩
s ≡ t ≃⟨ ψ ⟩
PathP (λ i → S (ua (idEquiv Y) i)) s t ■
where
ψ = transportEquiv λ j → PathP (λ i → S (uaIdEquiv {A = Y} (~ j) i)) s t
-- We can now directly define an invertible function
--
-- sip : A ≃[ ι ] B → A ≡ B
--
sip : (S : Type ℓ₁ → Type ℓ₂) (ι : StrIso S ℓ₃) (θ : SNS-PathP S ι)
(A B : TypeWithStr ℓ₁ S) → A ≃[ ι ] B → A ≡ B
sip S ι θ A B (e , p) i = ua e i , θ e .fst p i
-- The inverse to sip uses the following little lemma
private
lem : (S : Type ℓ₁ → Type ℓ₂) (A B : TypeWithStr ℓ₁ S) (e : typ A ≡ typ B)
→ PathP (λ i → S (ua (pathToEquiv e) i)) (A .snd) (B .snd) ≡
PathP (λ i → S (e i)) (A .snd) (B .snd)
lem S A B e i = PathP (λ j → S (ua-pathToEquiv e i j)) (A .snd) (B .snd)
-- The inverse
sip⁻ : (S : Type ℓ₁ → Type ℓ₂) (ι : StrIso S ℓ₃) (θ : SNS-PathP S ι)
(A B : TypeWithStr ℓ₁ S) → A ≡ B → A ≃[ ι ] B
sip⁻ S ι θ A B r = pathToEquiv p , invEq (θ (pathToEquiv p)) q
where
p : typ A ≡ typ B
p = cong fst r
q : PathP (λ i → S (ua (pathToEquiv p) i)) (A .snd) (B .snd)
q = transport⁻ (lem S A B p) (cong snd r)
-- We can rather directly show that sip and sip⁻ are mutually inverse:
sip-sip⁻ : (S : Type ℓ₁ → Type ℓ₂) (ι : StrIso S ℓ₃) (θ : SNS-PathP S ι)
(A B : TypeWithStr ℓ₁ S) (r : A ≡ B)
→ sip S ι θ A B (sip⁻ S ι θ A B r) ≡ r
sip-sip⁻ S ι θ A B r =
let p : typ A ≡ typ B
p = cong fst r
q : PathP (λ i → S (p i)) (str A) (str B)
q = cong snd r
in sip S ι θ A B (sip⁻ S ι θ A B r)
≡⟨ refl ⟩
(λ i → ( ua (pathToEquiv p) i)
, θ (pathToEquiv p) .fst
(invEq (θ (pathToEquiv p))
(transport⁻ (lem S A B p) q)) i)
≡⟨ (λ i j → ( ua (pathToEquiv p) j
, retEq (θ (pathToEquiv p))
(transport⁻ (lem S A B p) q) i j)) ⟩
(λ i → ( ua (pathToEquiv p) i
, transport⁻ (lem S A B p) q i))
≡⟨ (λ i j → ( ua-pathToEquiv p i j
, transp (λ k → PathP (λ j → S (ua-pathToEquiv p (i ∧ k) j)) (str A) (str B))
(~ i) (transport⁻ (lem S A B p) q) j)) ⟩
(λ i → ( p i
, transport (λ i → lem S A B p i) (transport⁻ (lem S A B p) q) i))
≡⟨ (λ i j → ( p j
, transportTransport⁻ (lem S A B p) q i j)) ⟩
r ∎
-- The trickier direction:
sip⁻-sip : (S : Type ℓ₁ → Type ℓ₂) (ι : StrIso S ℓ₃) (θ : SNS-PathP S ι)
(A B : TypeWithStr ℓ₁ S) (r : A ≃[ ι ] B)
→ sip⁻ S ι θ A B (sip S ι θ A B r) ≡ r
sip⁻-sip S ι θ A B (e , p) =
sip⁻ S ι θ A B (sip S ι θ A B (e , p))
≡⟨ refl ⟩
pathToEquiv (ua e) , invEq (θ (pathToEquiv (ua e))) (f⁺ p')
≡⟨ (λ i → pathToEquiv-ua e i , invEq (θ (pathToEquiv-ua e i)) (pth' i)) ⟩
e , invEq (θ e) (f⁻ (f⁺ p'))
≡⟨ (λ i → e , invEq (θ e) (transportTransport⁻ (lem S A B (ua e)) p' i)) ⟩
e , invEq (θ e) (θ e .fst p)
≡⟨ (λ i → e , (secEq (θ e) p i)) ⟩
e , p ∎
where
p' : PathP (λ i → S (ua e i)) (str A) (str B)
p' = θ e .fst p
f⁺ : PathP (λ i → S (ua e i)) (str A) (str B)
→ PathP (λ i → S (ua (pathToEquiv (ua e)) i)) (str A) (str B)
f⁺ = transport (λ i → PathP (λ j → S (ua-pathToEquiv (ua e) (~ i) j)) (str A) (str B))
f⁻ : PathP (λ i → S (ua (pathToEquiv (ua e)) i)) (str A) (str B)
→ PathP (λ i → S (ua e i)) (str A) (str B)
f⁻ = transport (λ i → PathP (λ j → S (ua-pathToEquiv (ua e) i j)) (str A) (str B))
-- We can prove the following as in sip∘pis-id, but the type is not
-- what we want as it should be "cong ua (pathToEquiv-ua e)"
pth : PathP (λ j → PathP (λ k → S (ua-pathToEquiv (ua e) j k)) (str A) (str B))
(f⁺ p') (f⁻ (f⁺ p'))
pth i = transp (λ k → PathP (λ j → S (ua-pathToEquiv (ua e) (i ∧ k) j)) (str A) (str B))
(~ i) (f⁺ p')
-- So we build an equality that we want to cast the types with
casteq : PathP (λ j → PathP (λ k → S (ua-pathToEquiv (ua e) j k)) (str A) (str B))
(f⁺ p') (f⁻ (f⁺ p'))
≡ PathP (λ j → PathP (λ k → S (cong ua (pathToEquiv-ua e) j k)) (str A) (str B))
(f⁺ p') (f⁻ (f⁺ p'))
casteq i = PathP (λ j → PathP (λ k → S (eq i j k)) (str A) (str B)) (f⁺ p') (f⁻ (f⁺ p'))
where
-- This is where we need the half-adjoint equivalence property
eq : ua-pathToEquiv (ua e) ≡ cong ua (pathToEquiv-ua e)
eq = sym (uaHAEquiv (typ A) (typ B) .snd .com e)
-- We then get a term of the type we need
pth' : PathP (λ j → PathP (λ k → S (cong ua (pathToEquiv-ua e) j k)) (str A) (str B))
(f⁺ p') (f⁻ (f⁺ p'))
pth' = transport (λ i → casteq i) pth
-- Finally package everything up to get the cubical SIP
SIP : (S : Type ℓ₁ → Type ℓ₂) (ι : StrIso S ℓ₃)
(θ : SNS-PathP S ι) (A B : TypeWithStr ℓ₁ S)
→ A ≃[ ι ] B ≃ (A ≡ B)
SIP S ι θ A B = isoToEquiv (iso (sip S ι θ A B) (sip⁻ S ι θ A B)
(sip-sip⁻ S ι θ A B) (sip⁻-sip S ι θ A B))
-- Now, we want to add axioms (i.e. propositions) to our Structure S that don't affect the ι.
-- We use a lemma due to Zesen Qian, which can now be found in Foundations.Prelude:
-- https://github.com/riaqn/cubical/blob/hgroup/Cubical/Data/Group/Properties.agda#L83
add-to-structure : (S : Type ℓ₁ → Type ℓ₂)
(axioms : (X : Type ℓ₁) → S X → Type ℓ₄)
→ Type ℓ₁ → Type (ℓ-max ℓ₂ ℓ₄)
add-to-structure S axioms X = Σ[ s ∈ S X ] (axioms X s)
add-to-iso : (S : Type ℓ₁ → Type ℓ₂) (ι : StrIso S ℓ₃)
(axioms : (X : Type ℓ₁) → S X → Type ℓ₄)
→ StrIso (add-to-structure S axioms) ℓ₃
add-to-iso S ι axioms (X , (s , a)) (Y , (t , b)) f = ι (X , s) (Y , t) f
add-ax-lemma : (S : Type ℓ₁ → Type ℓ₂)
(axioms : (X : Type ℓ₁) → S X → Type ℓ₄)
(axioms-are-Props : (X : Type ℓ₁) (s : S X) → isProp (axioms X s))
{X Y : Type ℓ₁} {s : S X} {t : S Y} {a : axioms X s} {b : axioms Y t}
(f : X ≃ Y)
→ PathP (λ i → S (ua f i)) s t ≃
PathP (λ i → add-to-structure S axioms (ua f i)) (s , a) (t , b)
add-ax-lemma S axioms axioms-are-Props {s = s} {t = t} {a = a} {b = b} f = isoToEquiv (iso φ ψ η ε)
where
φ : PathP (λ i → S (ua f i)) s t → PathP (λ i → add-to-structure S axioms (ua f i)) (s , a) (t , b)
φ p i = p i , isProp→PathP (λ i → axioms-are-Props (ua f i) (p i)) a b i
ψ : PathP (λ i → add-to-structure S axioms (ua f i)) (s , a) (t , b) → PathP (λ i → S (ua f i)) s t
ψ r i = r i .fst
η : section φ ψ
η r i j = r j .fst , isProp→isSet-PathP (λ k → axioms-are-Props (ua f k) (r k .fst)) _ _
(isProp→PathP (λ k → axioms-are-Props (ua f k) (r k .fst)) a b)
(λ k → r k .snd) i j
ε : retract φ ψ
ε p = refl
add-axioms-SNS : (S : Type ℓ₁ → Type ℓ₂)
(ι : (A B : Σ[ X ∈ (Type ℓ₁) ] (S X)) → A .fst ≃ B .fst → Type ℓ₃)
(axioms : (X : Type ℓ₁) → S X → Type ℓ₄)
(axioms-are-Props : (X : Type ℓ₁) (s : S X) → isProp (axioms X s))
(θ : SNS-PathP S ι)
→ SNS-PathP (add-to-structure S axioms) (add-to-iso S ι axioms)
add-axioms-SNS S ι axioms axioms-are-Props θ {X , s , a} {Y , t , b} f =
add-to-iso S ι axioms (X , s , a) (Y , t , b) f ≃⟨ θ f ⟩
PathP (λ i → S (ua f i)) s t ≃⟨ add-ax-lemma S axioms axioms-are-Props f ⟩
PathP (λ i → (add-to-structure S axioms) (ua f i)) (s , a) (t , b) ■
-- Now, we want to join two structures. Together with the adding of
-- axioms this will allow us to prove that a lot of mathematical
-- structures are a standard notion of structure
join-structure : (S₁ : Type ℓ₁ → Type ℓ₂) (S₂ : Type ℓ₁ → Type ℓ₄)
→ Type ℓ₁ → Type (ℓ-max ℓ₂ ℓ₄)
join-structure S₁ S₂ X = S₁ X × S₂ X
join-iso : {S₁ : Type ℓ₁ → Type ℓ₂} (ι₁ : StrIso S₁ ℓ₃)
{S₂ : Type ℓ₁ → Type ℓ₄} (ι₂ : StrIso S₂ ℓ₅)
→ StrIso (join-structure S₁ S₂) (ℓ-max ℓ₃ ℓ₅)
join-iso ι₁ ι₂ (X , s₁ , s₂) (Y , t₁ , t₂) f = (ι₁ (X , s₁) (Y , t₁) f) × (ι₂ (X , s₂) (Y , t₂) f)
join-SNS : (S₁ : Type ℓ₁ → Type ℓ₂) (ι₁ : StrIso S₁ ℓ₃) (θ₁ : SNS-PathP S₁ ι₁)
(S₂ : Type ℓ₁ → Type ℓ₄) (ι₂ : StrIso S₂ ℓ₅) (θ₂ : SNS-PathP S₂ ι₂)
→ SNS-PathP (join-structure S₁ S₂) (join-iso ι₁ ι₂)
join-SNS S₁ ι₁ θ₁ S₂ ι₂ θ₂ {X , s₁ , s₂} {Y , t₁ , t₂} e = isoToEquiv (iso φ ψ η ε)
where
φ : join-iso ι₁ ι₂ (X , s₁ , s₂) (Y , t₁ , t₂) e
→ PathP (λ i → join-structure S₁ S₂ (ua e i)) (s₁ , s₂) (t₁ , t₂)
φ (p , q) i = (θ₁ e .fst p i) , (θ₂ e .fst q i)
ψ : PathP (λ i → join-structure S₁ S₂ (ua e i)) (s₁ , s₂) (t₁ , t₂)
→ join-iso ι₁ ι₂ (X , s₁ , s₂) (Y , t₁ , t₂) e
ψ p = invEq (θ₁ e) (λ i → p i .fst) , invEq (θ₂ e) (λ i → p i .snd)
η : section φ ψ
η p i j = retEq (θ₁ e) (λ k → p k .fst) i j , retEq (θ₂ e) (λ k → p k .snd) i j
ε : retract φ ψ
ε (p , q) i = secEq (θ₁ e) p i , secEq (θ₂ e) q i
|
{
"alphanum_fraction": 0.5245040383,
"avg_line_length": 43.5255972696,
"ext": "agda",
"hexsha": "c050225019f62a2f8c3aa3d32df21357171b5d12",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "borsiemir/cubical",
"max_forks_repo_path": "Cubical/Foundations/SIP.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "borsiemir/cubical",
"max_issues_repo_path": "Cubical/Foundations/SIP.agda",
"max_line_length": 115,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "cefeb3669ffdaea7b88ae0e9dd258378418819ca",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "borsiemir/cubical",
"max_stars_repo_path": "Cubical/Foundations/SIP.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5403,
"size": 12753
}
|
------------------------------------------------------------------------
-- Validity of canonical kinding in Fω with interval kinds
------------------------------------------------------------------------
{-# OPTIONS --safe --without-K #-}
module FOmegaInt.Kinding.Canonical.Validity where
open import Data.Product using (∃; _,_; _×_; proj₁; proj₂)
open import Relation.Binary.PropositionalEquality
open import FOmegaInt.Syntax
open import FOmegaInt.Syntax.HereditarySubstitution
open import FOmegaInt.Syntax.Normalization
open import FOmegaInt.Kinding.Canonical
open import FOmegaInt.Kinding.Canonical.HereditarySubstitution
open Syntax
open ElimCtx
open Substitution hiding (subst)
open Kinding
open WfCtxOps
open ContextNarrowing
private module TK = TrackSimpleKindsSubst
------------------------------------------------------------------------
-- Validity of canonical kinding, subkinding and subtyping.
-- Validity of spine kinding: the kind of an elimination is
-- well-formed, provided that the spine is well-kinded and the kind of
-- the head is well-formed.
Sp⇉-valid : ∀ {n} {Γ : Ctx n} {as j k} → Γ ⊢ j kd → Γ ⊢ j ⇉∙ as ⇉ k → Γ ⊢ k kd
Sp⇉-valid j-kd ⇉-[] = j-kd
Sp⇉-valid (kd-Π j-kd k-kd) (⇉-∷ a⇇j _ k[a]⇉as⇉l) =
Sp⇉-valid (TK.kd-/⟨⟩ k-kd (⇇-hsub a⇇j j-kd (⌊⌋-⌊⌋≡ _))) k[a]⇉as⇉l
-- Validity of kinding for neutral types: the kinds of neutral types
-- are well-formed.
Ne∈-valid : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Ne a ∈ k → Γ ⊢ k kd
Ne∈-valid (∈-∙ x∈j j⇉as⇉k) = Sp⇉-valid (Var∈-valid x∈j) j⇉as⇉k
-- Validity of spine equality.
Sp≃-valid : ∀ {n} {Γ : Ctx n} {as bs j₁ j₂ k₂} →
Γ ⊢ j₁ <∷ j₂ → Γ ⊢ j₂ ⇉∙ as ≃ bs ⇉ k₂ →
∃ λ k₁ → Γ ⊢ j₂ ⇉∙ as ⇉ k₂ × Γ ⊢ j₁ ⇉∙ bs ⇉ k₁ × Γ ⊢ k₁ <∷ k₂
Sp≃-valid k₁<∷k₂ ≃-[] = _ , ⇉-[] , ⇉-[] , k₁<∷k₂
Sp≃-valid (<∷-Π j₂<∷j₁ k₁<∷k₂ (kd-Π j₁-kd k₁-kd))
(≃-∷ a≃b⇇j₂ k₂[a]⇉as≃bs⇉l₂) =
let j₂-kd = ≃-valid-kd a≃b⇇j₂
a⇇j₂ , b⇇j₂ = ≃-valid a≃b⇇j₂
b⇇j₁ = Nf⇇-⇑ b⇇j₂ j₂<∷j₁
k₁[b]<∷k₂[a] = TK.<∷-/⟨⟩≃ k₁<∷k₂ (≃-hsub (≃-sym a≃b⇇j₂) (⌊⌋-⌊⌋≡ _))
l₁ , k₂[a]⇉as⇉l₂ , k₁[b]⇉bs⇉l₁ , l₁<∷l₂ = Sp≃-valid k₁[b]<∷k₂[a]
k₂[a]⇉as≃bs⇉l₂
in l₁ ,
⇉-∷ a⇇j₂ j₂-kd k₂[a]⇉as⇉l₂ ,
⇉-∷ b⇇j₁ j₁-kd (subst (λ k → _ ⊢ _ Kind[ _ ∈ k ] ⇉∙ _ ⇉ l₁)
(<∷-⌊⌋ j₂<∷j₁) k₁[b]⇉bs⇉l₁) ,
l₁<∷l₂
-- Validity of subkinding and subtyping: well-formed subkinds
-- resp. well-kinded subtypes are also well-formed resp. well-kinded.
mutual
<∷-valid : ∀ {n} {Γ : Ctx n} {j k} →
Γ ⊢ j <∷ k → Γ ⊢ j kd × Γ ⊢ k kd
<∷-valid (<∷-⋯ a₂<:a₁ b₁<:b₂) =
let a₂⇉a₂⋯a₂ , a₁⇉a₁⋯a₁ = <:-valid a₂<:a₁
b₁⇉b₁⋯b₁ , b₂⇉b₂⋯b₂ = <:-valid b₁<:b₂
in kd-⋯ a₁⇉a₁⋯a₁ b₁⇉b₁⋯b₁ , kd-⋯ a₂⇉a₂⋯a₂ b₂⇉b₂⋯b₂
<∷-valid (<∷-Π j₂<∷j₁ k₁<∷k₂ Πj₁k₁-kd) =
let j₂-kd , j₁-kd = <∷-valid j₂<∷j₁
k₁-kd , k₂-kd = <∷-valid k₁<∷k₂
in Πj₁k₁-kd , kd-Π j₂-kd k₂-kd
<:-valid : ∀ {n} {Γ : Ctx n} {a b} → Γ ⊢ a <: b →
Γ ⊢Nf a ⇉ a ⋯ a × Γ ⊢Nf b ⇉ b ⋯ b
<:-valid (<:-trans a<:b b<:c) =
proj₁ (<:-valid a<:b) , proj₂ (<:-valid b<:c)
<:-valid (<:-⊥ a⇉a⋯a) = ⇉-⊥-f (Nf⇉-ctx a⇉a⋯a) , a⇉a⋯a
<:-valid (<:-⊤ a⇉a⋯a) = a⇉a⋯a , ⇉-⊤-f (Nf⇉-ctx a⇉a⋯a)
<:-valid (<:-∀ k₂<∷k₁ a₁<:a₂ Πk₁a₁⇉Πk₁a₁⋯Πk₁a₁) =
let k₂-kd , k₁-kd = <∷-valid k₂<∷k₁
a₁⇉a₁⋯a₁ , a₂⇉a₂⋯a₂ = <:-valid a₁<:a₂
in Πk₁a₁⇉Πk₁a₁⋯Πk₁a₁ , ⇉-∀-f k₂-kd a₂⇉a₂⋯a₂
<:-valid (<:-→ a₂<:a₁ b₁<:b₂) =
let a₂⇉a₂⋯a₂ , a₁⇉a₁⋯a₁ = <:-valid a₂<:a₁
b₁⇉b₁⋯b₁ , b₂⇉b₂⋯b₂ = <:-valid b₁<:b₂
in ⇉-→-f a₁⇉a₁⋯a₁ b₁⇉b₁⋯b₁ , ⇉-→-f a₂⇉a₂⋯a₂ b₂⇉b₂⋯b₂
<:-valid (<:-∙ x∈j j⇉as≃bs⇉c⋯d)
with Sp≃-valid (<∷-refl (Var∈-valid x∈j)) j⇉as≃bs⇉c⋯d
<:-valid (<:-∙ x∈j j⇉as≃bs⇉c₂⋯d₂)
| _ , j⇉as⇉c₂⋯d₂ , j⇉bs⇉c₁⋯d₁ , <∷-⋯ c₂<:c₁ d₁<:d₂ =
⇉-s-i (∈-∙ x∈j j⇉as⇉c₂⋯d₂) , ⇉-s-i (∈-∙ x∈j j⇉bs⇉c₁⋯d₁)
<:-valid (<:-⟨| a∈b⋯c) with Ne∈-valid a∈b⋯c
<:-valid (<:-⟨| a∈b⋯c) | kd-⋯ b⇉b⋯b _ = b⇉b⋯b , ⇉-s-i a∈b⋯c
<:-valid (<:-|⟩ a∈b⋯c) with Ne∈-valid a∈b⋯c
<:-valid (<:-|⟩ a∈b⋯c) | kd-⋯ _ c⇉c⋯c = ⇉-s-i a∈b⋯c , c⇉c⋯c
-- Validity of kind checking: if a normal type checks against a kind,
-- then that kind is well-formed.
Nf⇇-valid : ∀ {n} {Γ : Ctx n} {a k} → Γ ⊢Nf a ⇇ k → Γ ⊢ k kd
Nf⇇-valid (⇇-⇑ a⇉j j<∷k) = proj₂ (<∷-valid j<∷k)
-- Some corollaries.
-- The checked kinds of subtypes are well-formed.
<:⇇-valid-kd : ∀ {n} {Γ : Ctx n} {a b k} → Γ ⊢ a <: b ⇇ k → Γ ⊢ k kd
<:⇇-valid-kd a<:b⇇k = Nf⇇-valid (proj₁ (<:⇇-valid a<:b⇇k))
-- Canonical kinding of applications is admissible.
Nf⇇-Π-e : ∀ {n} {Γ : Ctx n} {a b j k} →
Γ ⊢Nf a ⇇ Π j k → Γ ⊢Nf b ⇇ j →
Γ ⊢Nf a ⌜·⌝⟨ ⌊ Π j k ⌋ ⟩ b ⇇ k Kind[ b ∈ ⌊ j ⌋ ]
Nf⇇-Π-e a⇇Πjk b⇇j = TK.Nf⇇-Π-e a⇇Πjk b⇇j (Nf⇇-valid b⇇j) (⌊⌋-⌊⌋≡ _)
-- Canonical subtyping of applications is admissible.
<:-⌜·⌝ : ∀ {n} {Γ : Ctx n} {a₁ a₂ b₁ b₂ j k} →
Γ ⊢ a₁ <: a₂ ⇇ Π j k → Γ ⊢ b₁ ≃ b₂ ⇇ j →
Γ ⊢ a₁ ⌜·⌝⟨ ⌊ Π j k ⌋ ⟩ b₁ <: a₂ ⌜·⌝⟨ ⌊ Π j k ⌋ ⟩ b₂ ⇇
k Kind[ b₁ ∈ ⌊ j ⌋ ]
<:-⌜·⌝ a₁<:a₂⇇Πjk b₁≃b₂⇇j with <:⇇-valid-kd a₁<:a₂⇇Πjk
<:-⌜·⌝ (<:-λ a₁<:a₂⇇k Λj₁a₁⇇Πjk Λj₂a₂⇇Πjk) b₁≃b₂⇇j | (kd-Π _ k-kd) =
TK.<:⇇-/⟨⟩≃ a₁<:a₂⇇k k-kd (≃-hsub b₁≃b₂⇇j (⌊⌋-⌊⌋≡ _))
-- Subtyping of proper types checks against the kind of proper types.
<:-⋯-* : ∀ {n} {Γ : Ctx n} {a b} → Γ ⊢ a <: b → Γ ⊢ a <: b ⇇ ⌜*⌝
<:-⋯-* a<:b with <:-valid a<:b
<:-⋯-* a<:b | a⇉a⋯a , b⇉b⋯b = <:-⇇ (Nf⇉-⋯-* a⇉a⋯a) (Nf⇉-⋯-* b⇉b⋯b) a<:b
-- Some commonly used (hereditary) substitution lemmas.
kd-[] : ∀ {n} {Γ : Ctx n} {a j k} →
kd k ∷ Γ ⊢ j kd → Γ ⊢Nf a ⇇ k → Γ ⊢ j Kind[ a ∈ ⌊ k ⌋ ] kd
kd-[] j-kd a⇇k = TK.kd-/⟨⟩ j-kd (⇇-hsub a⇇k (Nf⇇-valid a⇇k) (⌊⌋-⌊⌋≡ _))
Nf⇇-[] : ∀ {n} {Γ : Ctx n} {a b j k} →
kd j ∷ Γ ⊢Nf a ⇇ k → Γ ⊢Nf b ⇇ j →
Γ ⊢Nf a [ b ∈ ⌊ j ⌋ ] ⇇ k Kind[ b ∈ ⌊ j ⌋ ]
Nf⇇-[] a⇇k b⇇j = TK.Nf⇇-/⟨⟩ a⇇k (⇇-hsub b⇇j (Nf⇇-valid b⇇j) (⌊⌋-⌊⌋≡ _))
<∷-[≃] : ∀ {n} {Γ : Ctx n} {j k₁ k₂ a₁ a₂} →
kd j ∷ Γ ⊢ k₁ <∷ k₂ → Γ ⊢ a₁ ≃ a₂ ⇇ j →
Γ ⊢ k₁ Kind[ a₁ ∈ ⌊ j ⌋ ] <∷ k₂ Kind[ a₂ ∈ ⌊ j ⌋ ]
<∷-[≃] k₁<∷k₂ a₁≃a₂⇇j =
TK.<∷-/⟨⟩≃ k₁<∷k₂ (≃-hsub a₁≃a₂⇇j (⌊⌋-⌊⌋≡ _))
<:-[≃] : ∀ {n} {Γ : Ctx n} {a₁ a₂ b₁ b₂ j k} →
kd j ∷ Γ ⊢ a₁ <: a₂ ⇇ k → Γ ⊢ b₁ ≃ b₂ ⇇ j →
Γ ⊢ a₁ [ b₁ ∈ ⌊ j ⌋ ] <: a₂ [ b₂ ∈ ⌊ j ⌋ ] ⇇ k Kind[ b₁ ∈ ⌊ j ⌋ ]
<:-[≃] a₁<:a₂⇇k b₁≃b₂⇇j =
TK.<:⇇-/⟨⟩≃ a₁<:a₂⇇k (<:⇇-valid-kd a₁<:a₂⇇k) (≃-hsub b₁≃b₂⇇j (⌊⌋-⌊⌋≡ _))
-- Another admissible kinding rule for applications.
Nf⇇-Π-e′ : ∀ {n} {Γ : Ctx n} {a b j k} →
Γ ⊢Nf a ⇇ Π j k → Γ ⊢Nf b ⇇ j →
Γ ⊢Nf a ↓⌜·⌝ b ⇇ k Kind[ b ∈ ⌊ j ⌋ ]
Nf⇇-Π-e′ {b = b} (⇇-⇑ (⇉-Π-i {_} {a₁} j₁-kd a⇉k₁) (<∷-Π j₂<∷j₁ k₁<∷k₂ Πj₁k₁-kd))
b⇇j₂ =
subst (_ ⊢Nf_⇇ _) (cong (a₁ [ b ∈_]) (<∷-⌊⌋ j₂<∷j₁))
(Nf⇇-[] (⇇-⇑ (⇓-Nf⇉ (Nf⇇-valid b⇇j₂) j₂<∷j₁ a⇉k₁) k₁<∷k₂) b⇇j₂)
-- Another admissible subtyping rule for applications.
<:-↓⌜·⌝ : ∀ {n} {Γ : Ctx n} {a₁ a₂ b₁ b₂ j k} →
Γ ⊢ a₁ <: a₂ ⇇ Π j k → Γ ⊢ b₁ ≃ b₂ ⇇ j →
Γ ⊢ a₁ ↓⌜·⌝ b₁ <: a₂ ↓⌜·⌝ b₂ ⇇ k Kind[ b₁ ∈ ⌊ j ⌋ ]
<:-↓⌜·⌝ {b₁ = b₁} {b₂}
(<:-λ a₁<:a₂⇇k (⇇-⇑ (⇉-Π-i {_} {a₁} _ _) (<∷-Π j₁<∷j _ _))
(⇇-⇑ (⇉-Π-i {_} {a₂} _ _) (<∷-Π j₂<∷j _ _))) b₁≃b₂⇇j =
subst₂ (_ ⊢_<:_⇇ _)
(cong (a₁ [ b₁ ∈_]) (<∷-⌊⌋ j₁<∷j)) (cong (a₂ [ b₂ ∈_]) (<∷-⌊⌋ j₂<∷j))
(<:-[≃] a₁<:a₂⇇k b₁≃b₂⇇j)
|
{
"alphanum_fraction": 0.4544581619,
"avg_line_length": 41.4204545455,
"ext": "agda",
"hexsha": "a99b864c82492163697b9c5964ef29ca8fc90cd0",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Blaisorblade/f-omega-int-agda",
"max_forks_repo_path": "src/FOmegaInt/Kinding/Canonical/Validity.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Blaisorblade/f-omega-int-agda",
"max_issues_repo_path": "src/FOmegaInt/Kinding/Canonical/Validity.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Blaisorblade/f-omega-int-agda",
"max_stars_repo_path": "src/FOmegaInt/Kinding/Canonical/Validity.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4595,
"size": 7290
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of the extensional sublist relation over setoid equality.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary hiding (Decidable)
module Data.List.Relation.Binary.Subset.Setoid.Properties where
open import Data.Bool using (Bool; true; false)
open import Data.List
open import Data.List.Relation.Unary.Any using (here; there)
import Data.List.Membership.Setoid as Membership
open import Data.List.Membership.Setoid.Properties
import Data.List.Relation.Binary.Subset.Setoid as Sublist
import Data.List.Relation.Binary.Equality.Setoid as Equality
open import Relation.Nullary using (¬_; yes; no)
open import Relation.Unary using (Pred; Decidable)
import Relation.Binary.Reasoning.Preorder as PreorderReasoning
open Setoid using (Carrier)
------------------------------------------------------------------------
-- Relational properties
module _ {a ℓ} (S : Setoid a ℓ) where
open Equality S
open Sublist S
open Membership S
⊆-reflexive : _≋_ ⇒ _⊆_
⊆-reflexive xs≋ys = ∈-resp-≋ S xs≋ys
⊆-refl : Reflexive _⊆_
⊆-refl x∈xs = x∈xs
⊆-trans : Transitive _⊆_
⊆-trans xs⊆ys ys⊆zs x∈xs = ys⊆zs (xs⊆ys x∈xs)
⊆-isPreorder : IsPreorder _≋_ _⊆_
⊆-isPreorder = record
{ isEquivalence = ≋-isEquivalence
; reflexive = ⊆-reflexive
; trans = ⊆-trans
}
⊆-preorder : Preorder _ _ _
⊆-preorder = record
{ isPreorder = ⊆-isPreorder
}
-- Reasoning over subsets
module ⊆-Reasoning where
open PreorderReasoning ⊆-preorder public
renaming
( _∼⟨_⟩_ to _⊆⟨_⟩_
; _≈⟨_⟩_ to _≋⟨_⟩_
; _≈˘⟨_⟩_ to _≋˘⟨_⟩_
; _≈⟨⟩_ to _≋⟨⟩_
)
infix 1 _∈⟨_⟩_
_∈⟨_⟩_ : ∀ x {xs ys} → x ∈ xs → xs IsRelatedTo ys → x ∈ ys
x ∈⟨ x∈xs ⟩ xs⊆ys = (begin xs⊆ys) x∈xs
------------------------------------------------------------------------
-- filter
module _ {a p ℓ} (S : Setoid a ℓ)
{P : Pred (Carrier S) p} (P? : Decidable P) where
open Setoid S renaming (Carrier to A)
open Sublist S
filter⁺ : ∀ xs → filter P? xs ⊆ xs
filter⁺ [] ()
filter⁺ (x ∷ xs) y∈f[x∷xs] with P? x
... | no _ = there (filter⁺ xs y∈f[x∷xs])
... | yes _ with y∈f[x∷xs]
... | here y≈x = here y≈x
... | there y∈f[xs] = there (filter⁺ xs y∈f[xs])
|
{
"alphanum_fraction": 0.5566502463,
"avg_line_length": 28.3255813953,
"ext": "agda",
"hexsha": "b24c92f8c15cf8aef9312167e7e3baae4a65eafb",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Subset/Setoid/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Subset/Setoid/Properties.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/List/Relation/Binary/Subset/Setoid/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 823,
"size": 2436
}
|
-- Andreas, 2013-10-26
-- What if user tried to eliminate function type by copattern?
{-# OPTIONS --copatterns #-}
-- {-# OPTIONS -v tc.lhs.split:30 #-}
module CopatternsSplitErrorWithUnboundDBIndex where
import Common.Level
record _×_ (A B : Set) : Set where
constructor _,_
field
fst : A
snd : B
open _×_
-- pair defined by copatterns
test : {A B : Set} → A → A → A × A
fst test a = a
snd test a = a
-- Bad error WAS:
-- An internal error has occurred. Please report this as a bug.
-- Location of the error: src/full/Agda/TypeChecking/Rules/LHS.hs:250
-- Correct error:
-- Cannot eliminate type A → A → A × A with projection pattern fst
-- when checking that the clause fst test a = a has type
-- {A : Set} → {Set} → A → A → A × A
--
-- pair defined by copatterns
pair : {A B : Set} → A → B → A × B
fst pair a b = a
snd pair a b = b
-- Bad error WAS: Unbound index in error message:
--
-- Cannot eliminate type @3 × A with pattern b (did you supply too many arguments?)
-- when checking that the clause fst pair a b = a has type
-- {A B : Set} → A → B → A × B
|
{
"alphanum_fraction": 0.6485239852,
"avg_line_length": 24.6363636364,
"ext": "agda",
"hexsha": "606dbc8cd7a68d24f1abcb771090c549adbddc23",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Fail/CopatternsSplitErrorWithUnboundDBIndex.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Fail/CopatternsSplitErrorWithUnboundDBIndex.agda",
"max_line_length": 83,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/CopatternsSplitErrorWithUnboundDBIndex.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 330,
"size": 1084
}
|
-- This file is imported by other tests, can't just remove (Andreas, 2015-07-15).
module Nat where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
|
{
"alphanum_fraction": 0.6709677419,
"avg_line_length": 19.375,
"ext": "agda",
"hexsha": "740439e99187f9ae3f0a6e337d221802e2ca5e5d",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/Nat.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/Nat.agda",
"max_line_length": 81,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Nat.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 48,
"size": 155
}
|
module Function.Domains.Id where
import Lvl
open import Functional using (_∘_)
open import Type
open import Type.Dependent
private variable ℓₒ₁ ℓₒ₂ ℓₑ₁ ℓₑ₂ : Lvl.Level
module _ {X : Type{ℓₒ₁}} {Y : Type{ℓₒ₂}} where
data Image (f : X → Y) : Y → Type{ℓₒ₁ Lvl.⊔ ℓₒ₂} where
intro : (x : X) → Image f (f(x))
-- The image/range of a function.
-- Represents the "set" of values of a function.
-- Note: An element of Y and a proof that this element is the value of the function f is included so that (⊶ f) does not become injective when f is not.
-- Note: A construction of this implies that X is non-empty.
⊶ : (X → Y) → Type{ℓₒ₁ Lvl.⊔ ℓₒ₂}
⊶ = Σ(Y) ∘ Image
-- Represents the "set" of objects pointing to the value y of the function f.
-- ∃(Fiber f(y)) is also called "the fiber of the element y under the map f".
-- Fiber(f) is similar to the inverse image or the preimage of f when their argument is a singleton set.
data Fiber (f : X → Y) : Y → X → Type{ℓₒ₁ Lvl.⊔ ℓₒ₂} where
intro : (x : X) → Fiber f (f(x)) x
|
{
"alphanum_fraction": 0.6567877629,
"avg_line_length": 40.2307692308,
"ext": "agda",
"hexsha": "0ab6656c7984b6699d37421d34dc89fc10eb50aa",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Function/Domains/Id.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Function/Domains/Id.agda",
"max_line_length": 154,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Function/Domains/Id.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 374,
"size": 1046
}
|
{- Example by Andrew Pitts, 2016-05-23 -}
{-# OPTIONS --rewriting --cubical-compatible #-}
open import Agda.Builtin.Equality public
infix 6 I─_
postulate
𝕀 : Set
O : 𝕀
I : 𝕀
I─_ : 𝕀 → 𝕀
{-# BUILTIN REWRITE _≡_ #-}
postulate
I─O≡I : I─ O ≡ I
{-# REWRITE I─O≡I #-}
data Pth (A : Set) : A → A → Set where
path : (f : 𝕀 → A) → Pth A (f O) (f I)
infix 6 _at_
_at_ : {A : Set}{x y : A} → Pth A x y → 𝕀 → A
path f at i = f i
record Path (A : Set)(x y : A) : Set where
field
pth : Pth A x y
feq : pth at O ≡ x
seq : pth at I ≡ y
open Path public
{-# REWRITE feq #-}
{-# REWRITE seq #-}
infix 6 _′_
_′_ : {A : Set}{x y : A} → Path A x y → 𝕀 → A
p ′ i = pth p at i
fun2path : {A : Set}(f : 𝕀 → A) → Path A (f O) (f I)
pth (fun2path f) = path f
feq (fun2path f) = refl
seq (fun2path f) = refl
inv : {A : Set}{x y : A} → Path A x y → Path A y x
inv p = fun2path (λ i → p ′ (I─ i))
|
{
"alphanum_fraction": 0.5132837407,
"avg_line_length": 18.82,
"ext": "agda",
"hexsha": "84fdfd676197b8c65f8cb94a116143ea845f6a55",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "KDr2/agda",
"max_forks_repo_path": "test/Fail/Issue1994.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "KDr2/agda",
"max_issues_repo_path": "test/Fail/Issue1994.agda",
"max_line_length": 52,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "KDr2/agda",
"max_stars_repo_path": "test/Fail/Issue1994.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 420,
"size": 941
}
|
-- The Agda primitives (preloaded).
{-# OPTIONS --without-K --no-subtyping --no-import-sorts #-}
module Agda.Primitive where
------------------------------------------------------------------------
-- Universe levels
------------------------------------------------------------------------
infixl 6 _⊔_
{-# BUILTIN TYPE Set #-}
{-# BUILTIN PROP Prop #-}
{-# BUILTIN SETOMEGA Setω #-}
-- Level is the first thing we need to define.
-- The other postulates can only be checked if built-in Level is known.
postulate
Level : Set
-- MAlonzo compiles Level to (). This should be safe, because it is
-- not possible to pattern match on levels.
{-# BUILTIN LEVEL Level #-}
postulate
lzero : Level
lsuc : (ℓ : Level) → Level
_⊔_ : (ℓ₁ ℓ₂ : Level) → Level
{-# BUILTIN LEVELZERO lzero #-}
{-# BUILTIN LEVELSUC lsuc #-}
{-# BUILTIN LEVELMAX _⊔_ #-}
|
{
"alphanum_fraction": 0.5462962963,
"avg_line_length": 24,
"ext": "agda",
"hexsha": "2c0f1a6334015faedfd3419ca9de81e2f0db0056",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "8fb548356b275c7a1e79b768b64511ae937c738b",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "mdimjasevic/agda",
"max_forks_repo_path": "src/data/lib/prim/Agda/Primitive.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "8fb548356b275c7a1e79b768b64511ae937c738b",
"max_issues_repo_issues_event_max_datetime": "2020-05-29T19:45:38.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-05-29T19:45:38.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "mdimjasevic/agda",
"max_issues_repo_path": "src/data/lib/prim/Agda/Primitive.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "8fb548356b275c7a1e79b768b64511ae937c738b",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "mdimjasevic/agda",
"max_stars_repo_path": "src/data/lib/prim/Agda/Primitive.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 215,
"size": 864
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Indexed unary relations
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Relation.Unary.Indexed where
open import Data.Product using (∃; _×_)
open import Level
open import Relation.Nullary using (¬_)
IPred : ∀ {i a} {I : Set i} → (I → Set a) → (ℓ : Level) → Set _
IPred A ℓ = ∀ {i} → A i → Set ℓ
module _ {i a} {I : Set i} {A : I → Set a} where
_∈_ : ∀ {ℓ} → (∀ i → A i) → IPred A ℓ → Set _
x ∈ P = ∀ i → P (x i)
_∉_ : ∀ {ℓ} → (∀ i → A i) → IPred A ℓ → Set _
t ∉ P = ¬ (t ∈ P)
|
{
"alphanum_fraction": 0.4152923538,
"avg_line_length": 26.68,
"ext": "agda",
"hexsha": "8ce3622ce364fc09c886d3820890d841e0c66596",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Unary/Indexed.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Unary/Indexed.agda",
"max_line_length": 72,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Unary/Indexed.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 211,
"size": 667
}
|
{-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.NType2
open import lib.types.Group
open import lib.types.Sigma
open import lib.types.Truncation
open import lib.groups.Homomorphisms
module lib.groups.PropSubgroup where
module _ {i} (G : Group i) where
private
module G = Group G
module PropSubgroup {j} (P : G.El → Type j)
(P-level : ∀ g → has-level -1 (P g))
(P-ident : P G.ident) (P-inv : ∀ {g} → P g → P (G.inv g))
(P-comp : ∀ {g₁ g₂} → P g₁ → P g₂ → P (G.comp g₁ g₂)) where
struct : GroupStructure (Σ G.El P)
struct = record {
ident = (G.ident , P-ident);
inv = λ {(g , p) → (G.inv g , P-inv p)};
comp = λ {(g₁ , p₁) (g₂ , p₂) → (G.comp g₁ g₂ , P-comp p₁ p₂)};
unitl = λ {(g , _) →
pair= (G.unitl g) (prop-has-all-paths-↓ (P-level _))};
unitr = λ {(g , _) →
pair= (G.unitr g) (prop-has-all-paths-↓ (P-level _))};
assoc = λ {(g₁ , _) (g₂ , _) (g₃ , _) →
pair= (G.assoc g₁ g₂ g₃) (prop-has-all-paths-↓ (P-level _))};
invl = λ {(g , _) →
pair= (G.invl g) (prop-has-all-paths-↓ (P-level _))};
invr = λ {(g , _) →
pair= (G.invr g) (prop-has-all-paths-↓ (P-level _))}}
Subgroup : Group (lmax i j)
Subgroup = group _ (Σ-level G.El-level (raise-level _ ∘ P-level)) struct
inj : Subgroup →ᴳ G
inj = record {
f = λ {(g , _) → g};
pres-comp = λ _ _ → idp}
module _ {j} {H : Group j} (φ : H →ᴳ G) where
private
module H = Group H
module φ = GroupHom φ
prop-hom : Π H.El (P ∘ φ.f) → (H →ᴳ Subgroup)
prop-hom p = record {
f = λ g → (φ.f g , p g);
pres-comp = λ g₁ g₂ →
pair= (φ.pres-comp g₁ g₂) (prop-has-all-paths-↓ (P-level _))}
module _ {i} {j} {G : Group i} {H : Group j} (φ : G →ᴳ H) where
private
module G = Group G
module H = Group H
module φ = GroupHom φ
module Ker = PropSubgroup G (λ g → φ.f g == H.ident)
(λ g → H.El-level _ _) φ.pres-ident
(λ p → φ.pres-inv _ ∙ ap H.inv p ∙ group-inv-ident H)
(λ p₁ p₂ → φ.pres-comp _ _ ∙ ap2 H.comp p₁ p₂ ∙ H.unitl _)
module Im = PropSubgroup H (λ h → Trunc -1 (Σ G.El (λ g → φ.f g == h)))
(λ h → Trunc-level) ([ G.ident , φ.pres-ident ])
(Trunc-fmap (λ {(g , p) →
(G.inv g , φ.pres-inv g ∙ ap H.inv p)}))
(Trunc-fmap2 (λ {(g₁ , p₁) (g₂ , p₂) →
(G.comp g₁ g₂ , φ.pres-comp g₁ g₂ ∙ ap2 H.comp p₁ p₂)}))
open Ker public renaming
(struct to ker-struct; Subgroup to Ker;
inj to ker-inj; prop-hom to ker-hom)
open Im public renaming
(struct to im-struct; Subgroup to Im;
inj to im-inj; prop-hom to im-out-hom)
im-in-hom : G →ᴳ Im
im-in-hom = record {
f = λ g → (φ.f g , [ g , idp ]);
pres-comp = λ g₁ g₂ →
pair= (φ.pres-comp g₁ g₂) (prop-has-all-paths-↓ Trunc-level)}
im-in-surj : (h : Group.El Im)
→ Trunc -1 (Σ G.El (λ g → GroupHom.f im-in-hom g == h))
im-in-surj (_ , s) = Trunc-fmap (λ {(g , p) →
(g , pair= p (prop-has-all-paths-↓ Trunc-level))}) s
|
{
"alphanum_fraction": 0.5281229562,
"avg_line_length": 31.8541666667,
"ext": "agda",
"hexsha": "f61360ad081b4a59d2a0ed5c871a167ab09698c1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cmknapp/HoTT-Agda",
"max_forks_repo_path": "core/lib/groups/PropSubgroup.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cmknapp/HoTT-Agda",
"max_issues_repo_path": "core/lib/groups/PropSubgroup.agda",
"max_line_length": 76,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cmknapp/HoTT-Agda",
"max_stars_repo_path": "core/lib/groups/PropSubgroup.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1147,
"size": 3058
}
|
{-
This second-order equational theory was created from the following second-order syntax description:
syntax Naturals | Nat
type
N : 0-ary
term
ze : N
su : N -> N
nrec : N α (α,N).α -> α
theory
(zeβ) z : α s : (α,N).α |> nrec (ze, z, r m. s[r,m]) = z
(suβ) z : α s : (α,N).α n : N |> nrec (su (n), z, r m. s[r,m]) = s[nrec (n, z, r m. s[r,m]), n]
-}
module Naturals.Equality where
open import SOAS.Common
open import SOAS.Context
open import SOAS.Variable
open import SOAS.Families.Core
open import SOAS.Families.Build
open import SOAS.ContextMaps.Inductive
open import Naturals.Signature
open import Naturals.Syntax
open import SOAS.Metatheory.SecondOrder.Metasubstitution Nat:Syn
open import SOAS.Metatheory.SecondOrder.Equality Nat:Syn
private
variable
α β γ τ : NatT
Γ Δ Π : Ctx
infix 1 _▹_⊢_≋ₐ_
-- Axioms of equality
data _▹_⊢_≋ₐ_ : ∀ 𝔐 Γ {α} → (𝔐 ▷ Nat) α Γ → (𝔐 ▷ Nat) α Γ → Set where
zeβ : ⁅ α ⁆ ⁅ α · N ⊩ α ⁆̣ ▹ ∅ ⊢ nrec ze 𝔞 (𝔟⟨ x₀ ◂ x₁ ⟩) ≋ₐ 𝔞
suβ : ⁅ α ⁆ ⁅ α · N ⊩ α ⁆ ⁅ N ⁆̣ ▹ ∅ ⊢ nrec (su 𝔠) 𝔞 (𝔟⟨ x₀ ◂ x₁ ⟩) ≋ₐ 𝔟⟨ (nrec 𝔠 𝔞 (𝔟⟨ x₀ ◂ x₁ ⟩)) ◂ 𝔠 ⟩
open EqLogic _▹_⊢_≋ₐ_
open ≋-Reasoning
|
{
"alphanum_fraction": 0.5981308411,
"avg_line_length": 24.5208333333,
"ext": "agda",
"hexsha": "285aa4132da76121ad42dc2ba15173c052b52c8d",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z",
"max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JoeyEremondi/agda-soas",
"max_forks_repo_path": "out/Naturals/Equality.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JoeyEremondi/agda-soas",
"max_issues_repo_path": "out/Naturals/Equality.agda",
"max_line_length": 107,
"max_stars_count": 39,
"max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JoeyEremondi/agda-soas",
"max_stars_repo_path": "out/Naturals/Equality.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z",
"num_tokens": 539,
"size": 1177
}
|
module DuplicateBuiltinBinding where
postulate Int : Set
{-# BUILTIN INTEGER Int #-}
{-# BUILTIN INTEGER Int #-}
|
{
"alphanum_fraction": 0.7155172414,
"avg_line_length": 14.5,
"ext": "agda",
"hexsha": "b5262f0d5154f5c2096b0085dd159683e2bce4bb",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/DuplicateBuiltinBinding.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/DuplicateBuiltinBinding.agda",
"max_line_length": 36,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/fail/DuplicateBuiltinBinding.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 25,
"size": 116
}
|
module HiddenLambda where
postulate
A : Set
T : A -> Set
H : Set
H = {x : A} -> T x -> T x
-- H doesn't reduce when checking the body of h
h : H
h = \tx -> tx
|
{
"alphanum_fraction": 0.5595238095,
"avg_line_length": 11.2,
"ext": "agda",
"hexsha": "10c8352ebfa0bf59d7abfd7b8e7e38851d0f6207",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/bugs/fixed/HiddenLambda.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/bugs/fixed/HiddenLambda.agda",
"max_line_length": 47,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/bugs/fixed/HiddenLambda.agda",
"max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z",
"num_tokens": 62,
"size": 168
}
|
import Lvl
-- TODO: Just testing how it goes with creating an axiomatic system
module Geometry.Test3 (Point : Set(Lvl.𝟎)) where
open import Functional
open import Logic.Propositional{Lvl.𝟎}
open import Logic.Predicate{Lvl.𝟎}{Lvl.𝟎}
open import Relator.Equals{Lvl.𝟎}{Lvl.𝟎} renaming (_≡_ to _≡ₚ_ ; _≢_ to _≢ₚ_)
open import Sets.PredicateSet
open import Sets.PredicateSet.Proofs
open import Structure.Relator.Equivalence{Lvl.𝟎}{Lvl.𝟎}
open import Structure.Relator.Ordering{Lvl.𝟎}{Lvl.𝟎}
-- A line of infinite length
record Line : Set(Lvl.𝟎) where
constructor line
field
a : Point
b : Point
field
different : (a ≢ₚ b)
-- A circle
record Circle : Set(Lvl.𝟎) where
constructor circle
field
middle : Point
outer : Point
record Theory : Set(Lvl.𝐒(Lvl.𝐒(Lvl.𝟎))) where
-- Symbols
field
-- CirclesIntersectionPoint : Circle → Circle → Point → Set(Lvl.𝟎)
_∈ᶜ_ : Point → Circle → Stmt
_∈ˡ_ : Point → Line → Stmt
-- circleIntersectionPoint : (a : Circle) → (b : Circle) → ⦃ _ : CircleIntersect a b ⦄ → Point
CircleBoundary : Circle → Point → Stmt
CircleBoundary c p = (p ∈ᶜ c) ∧ (∀{outer a : Point} → (a ∈ᶜ circle p outer) → ⊥)
LineIntersection : Line → Line → Point → Stmt
LineIntersection a b p = (p ∈ˡ a) ∧ (p ∈ˡ b)
-- Axioms
-- field
-- circle-boundary-eq : ∀{a b} → ((_∈ᶜ a) ≡ (_∈ᶜ b)) ↔ (CircleBoundaryPoint a ≡ᵖ CircleBoundaryPoint b)
-- circle-either : ∀{middle outer₁ outer₂} → ((_∈ᶜ circle middle outer₁) ⊆ (_∈ᶜ circle middle outer₂)) ∨ ((_∈ᶜ circle middle outer₂) ⊆ (_∈ᶜ circle middle outer₁))
-- circleOuterIs Circle.outer
module Theorems ⦃ _ : Theory ⦄ where
open Theory ⦃ ... ⦄
-- perpendicularLine : CirclesIntersectionPoint
-- middlepoint : Line → Point
-- middlepoint(line(a)(b)) =
|
{
"alphanum_fraction": 0.6653587444,
"avg_line_length": 29.7333333333,
"ext": "agda",
"hexsha": "914e6aab4c53fbff5a58f161a5e52814268f204c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "old/Geometry/Test3.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "old/Geometry/Test3.agda",
"max_line_length": 166,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "old/Geometry/Test3.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 649,
"size": 1784
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- An either-or-both data type, basic type and operations
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.These.Base where
open import Level
open import Data.Sum.Base using (_⊎_; [_,_]′)
open import Function.Base
private
variable
a b c d e f : Level
A : Set a
B : Set b
C : Set c
D : Set d
E : Set e
F : Set f
data These {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where
this : A → These A B
that : B → These A B
these : A → B → These A B
------------------------------------------------------------------------
-- Operations
-- injection
fromSum : A ⊎ B → These A B
fromSum = [ this , that ]′
-- map
map : (f : A → B) (g : C → D) → These A C → These B D
map f g (this a) = this (f a)
map f g (that b) = that (g b)
map f g (these a b) = these (f a) (g b)
map₁ : (f : A → B) → These A C → These B C
map₁ f = map f id
map₂ : (g : B → C) → These A B → These A C
map₂ = map id
-- fold
fold : (A → C) → (B → C) → (A → B → C) → These A B → C
fold l r lr (this a) = l a
fold l r lr (that b) = r b
fold l r lr (these a b) = lr a b
foldWithDefaults : A → B → (A → B → C) → These A B → C
foldWithDefaults a b lr = fold (flip lr b) (lr a) lr
-- swap
swap : These A B → These B A
swap = fold that this (flip these)
-- align
alignWith : (These A C → E) → (These B D → F) → These A B → These C D → These E F
alignWith f g (this a) (this c) = this (f (these a c))
alignWith f g (this a) (that d) = these (f (this a)) (g (that d))
alignWith f g (this a) (these c d) = these (f (these a c)) (g (that d))
alignWith f g (that b) (this c) = these (f (that c)) (g (this b))
alignWith f g (that b) (that d) = that (g (these b d))
alignWith f g (that b) (these c d) = these (f (that c)) (g (these b d))
alignWith f g (these a b) (this c) = these (f (these a c)) (g (this b))
alignWith f g (these a b) (that d) = these (f (this a)) (g (these b d))
alignWith f g (these a b) (these c d) = these (f (these a c)) (g (these b d))
align : These A B → These C D → These (These A C) (These B D)
align = alignWith id id
|
{
"alphanum_fraction": 0.4997806055,
"avg_line_length": 28.1358024691,
"ext": "agda",
"hexsha": "863523c6d1cabf226846e4dd36e06ddf586e38da",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/These/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/These/Base.agda",
"max_line_length": 81,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/These/Base.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 778,
"size": 2279
}
|
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import Optics.All
open import LibraBFT.Prelude
open import LibraBFT.Lemmas
open import LibraBFT.Base.KVMap
open import LibraBFT.Base.PKCS
open import LibraBFT.Hash
open import LibraBFT.Impl.Base.Types
open import LibraBFT.Impl.Consensus.Types
open import LibraBFT.Impl.Util.Crypto
open import LibraBFT.Impl.Handle
open import LibraBFT.Concrete.System.Parameters
open EpochConfig
open import LibraBFT.Concrete.System
open import LibraBFT.Yasm.Yasm ℓ-RoundManager ℓ-VSFP ConcSysParms PeerCanSignForPK (λ {st} {part} {pk} → PeerCanSignForPK-stable {st} {part} {pk})
-- This module contains placeholders for the future analog of the
-- corresponding VotesOnce property. Defining the implementation
-- obligation and proving that it is an invariant of an implementation
-- is a substantial undertaking. We are working first on proving the
-- simpler VotesOnce property to settle down the structural aspects
-- before tackling the harder semantic issues.
module LibraBFT.Concrete.Properties.PreferredRound where
-- TODO-3: define the implementation obligation
ImplObligation₁ : Set
ImplObligation₁ = Unit
-- Next, we prove that given the necessary obligations,
module Proof
(sps-corr : StepPeerState-AllValidParts)
(Impl-PR1 : ImplObligation₁)
where
-- Any reachable state satisfies the PR rule for any epoch in the system.
module _ (st : SystemState)(r : ReachableSystemState st)(𝓔 : EpochConfig) where
-- Bring in 'unwind', 'ext-unforgeability' and friends
open Structural sps-corr
-- Bring in IntSystemState
open WithSPS sps-corr
open PerState st r
open PerEpoch 𝓔
open import LibraBFT.Concrete.Obligations.PreferredRound 𝓔 (ConcreteVoteEvidence 𝓔) as PR
postulate -- TODO-3: prove it
prr : PR.Type IntSystemState
|
{
"alphanum_fraction": 0.773797841,
"avg_line_length": 41.5918367347,
"ext": "agda",
"hexsha": "2c8525c2f08856f1812092b788f9af047d026dda",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "cwjnkins/bft-consensus-agda",
"max_forks_repo_path": "LibraBFT/Concrete/Properties/PreferredRound.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "cwjnkins/bft-consensus-agda",
"max_issues_repo_path": "LibraBFT/Concrete/Properties/PreferredRound.agda",
"max_line_length": 146,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "71aa2168e4875ffdeece9ba7472ee3cee5fa9084",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "cwjnkins/bft-consensus-agda",
"max_stars_repo_path": "LibraBFT/Concrete/Properties/PreferredRound.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 558,
"size": 2038
}
|
{-# OPTIONS --rewriting --confluence-check #-}
open import Agda.Builtin.Bool
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
{-# BUILTIN REWRITE _≡_ #-}
record R : Set₁ where
constructor c
field unD : Set
open R
id : unD (c (Nat → Nat))
id x = x
postulate rew : c (Nat → Nat) ≡ c (Nat → Bool)
{-# REWRITE rew #-}
|
{
"alphanum_fraction": 0.6568047337,
"avg_line_length": 16.9,
"ext": "agda",
"hexsha": "15bd500cf81d05b178ef22c855b06151f10b8133",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Fail/Issue3538-2-record.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Fail/Issue3538-2-record.agda",
"max_line_length": 46,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Issue3538-2-record.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 106,
"size": 338
}
|
open import Data.Nat using ( ℕ ; zero ; suc )
open import Data.Product using ( ∃ ; _×_ ; _,_ )
open import Data.Sum using ( _⊎_ ; inj₁ ; inj₂ )
open import Relation.Binary.PropositionalEquality using ( _≡_ ; _≢_ ; refl ; cong )
open import Relation.Nullary using ( ¬_ )
open import FRP.LTL.Time using
( Time ; _<_ ; _≤_ ; _≥_ ; ≤-refl ; _≤-trans_ ; _≤-asym_ ; _≤-total_ ; ≤-proof-irrel ; ≡-impl-≥
; _∸_ ; _+_ ; t≤u+t∸u ; +-unit ; +-assoc ; +-resp-≤ ; <-impl-+1≤ ; t<t+1
; _≤-case_ ; lt ; eq ; gt )
open import FRP.LTL.Util using ( ⊥-elim )
module FRP.LTL.Time.Bound where
infixr 2 _≼_ _≺_ _⋠_
infixr 4 _,_
infixr 5 _≼-trans_ _≼-asym_ _≼-total_ _≺-transˡ_ _≺-transʳ_ _≺-trans_
-- Time bounds, which extend Time with least and greatest elements
data Time∞ : Set where
+∞ : Time∞
fin : Time → Time∞
-- Order on time, generated by s ≺ t ≺ +∞ when s < t
data _≼_ : Time∞ → Time∞ → Set where
+∞-top : ∀ {t} → (t ≼ +∞)
≤-impl-≼ : ∀ {t u} → (t ≤ u) → (fin t ≼ fin u)
_⋠_ : Time∞ → Time∞ → Set
s ⋠ t = ¬(s ≼ t)
_≺_ : Time∞ → Time∞ → Set
s ≺ t = (s ≼ t) × (t ⋠ s)
≼-impl-≤ : ∀ {t u} → (fin t ≼ fin u) → (t ≤ u)
≼-impl-≤ (≤-impl-≼ t≤u) = t≤u
-- Axioms for ≺
t≺+∞ : ∀ {t} → fin t ≺ +∞
t≺+∞ = (+∞-top , λ ())
<-impl-≺ : ∀ {t u} → (t < u) → (fin t ≺ fin u)
<-impl-≺ (t≤u , u≰t) = (≤-impl-≼ t≤u , λ u≼t → u≰t (≼-impl-≤ u≼t))
≺-impl-< : ∀ {t u} → (fin t ≺ fin u) → (t < u)
≺-impl-< (t≼u , u⋠t) = (≼-impl-≤ t≼u , λ u≤t → u⋠t (≤-impl-≼ u≤t))
t≺t+1 : ∀ {t} → (fin t ≺ fin (t + 1))
t≺t+1 = <-impl-≺ t<t+1
-- ≼ is a decidable total order
≼-refl : ∀ {t} → (t ≼ t)
≼-refl {+∞} = +∞-top
≼-refl {fin t} = ≤-impl-≼ ≤-refl
_≼-trans_ : ∀ {s t u} → (s ≼ t) → (t ≼ u) → (s ≼ u)
s≼t ≼-trans +∞-top = +∞-top
≤-impl-≼ s≤t ≼-trans ≤-impl-≼ t≤u = ≤-impl-≼ (s≤t ≤-trans t≤u)
_≼-asym_ : ∀ {s t} → (s ≼ t) → (t ≼ s) → (s ≡ t)
+∞-top ≼-asym +∞-top = refl
≤-impl-≼ s≤t ≼-asym ≤-impl-≼ t≤s = cong fin (s≤t ≤-asym t≤s)
_≼-total_ : ∀ s t → (s ≼ t) ⊎ (t ≺ s)
+∞ ≼-total +∞ = inj₁ +∞-top
+∞ ≼-total fin t = inj₂ t≺+∞
fin s ≼-total +∞ = inj₁ +∞-top
fin s ≼-total fin t with s ≤-total t
... | inj₁ s≤t = inj₁ (≤-impl-≼ s≤t)
... | inj₂ t<s = inj₂ (<-impl-≺ t<s)
data _≼-Case_ (t u : Time∞) : Set where
lt : .(t ≺ u) → (t ≼-Case u)
eq : .(t ≡ u) → (t ≼-Case u)
gt : .(u ≺ t) → (t ≼-Case u)
_≼-case_ : ∀ t u → (t ≼-Case u)
+∞ ≼-case +∞ = eq refl
+∞ ≼-case fin u = gt t≺+∞
fin t ≼-case +∞ = lt t≺+∞
fin t ≼-case fin u with t ≤-case u
fin t ≼-case fin u | lt t<u = lt (<-impl-≺ t<u)
fin t ≼-case fin u | eq t≡u = eq (cong fin t≡u)
fin t ≼-case fin u | gt t>u = gt (<-impl-≺ t>u)
≡-impl-≼ : ∀ {s t} → (s ≡ t) → (s ≼ t)
≡-impl-≼ refl = ≼-refl
≡-impl-≽ : ∀ {s t} → (s ≡ t) → (t ≼ s)
≡-impl-≽ refl = ≼-refl
≼-proof-irrel : ∀ {t u} → (p q : t ≼ u) → (p ≡ q)
≼-proof-irrel +∞-top +∞-top = refl
≼-proof-irrel (≤-impl-≼ t≤₁u) (≤-impl-≼ t≤₂u) = cong ≤-impl-≼ (≤-proof-irrel t≤₁u t≤₂u)
≺-impl-≼ : ∀ {t u} → (t ≺ u) → (t ≼ u)
≺-impl-≼ (t≼u , u⋠t) = t≼u
≺-impl-⋡ : ∀ {t u} → (t ≺ u) → (u ⋠ t)
≺-impl-⋡ (t≼u , u⋠t) = u⋠t
≺-impl-≢ : ∀ {t u} → (t ≺ u) → (t ≢ u)
≺-impl-≢ (t≼u , u⋠t) refl = u⋠t ≼-refl
_≺-transˡ_ : ∀ {t u v} → (t ≺ u) → (u ≼ v) → (t ≺ v)
(t≼u , u⋠t) ≺-transˡ u≼v = (t≼u ≼-trans u≼v , λ v≼t → u⋠t (u≼v ≼-trans v≼t))
_≺-transʳ_ : ∀ {t u v} → (t ≼ u) → (u ≺ v) → (t ≺ v)
t≼u ≺-transʳ (u≼v , v⋠u) = (t≼u ≼-trans u≼v , λ v≼t → v⋠u (v≼t ≼-trans t≼u))
_≺-trans_ : ∀ {t u v} → (t ≺ u) → (u ≺ v) → (t ≺ v)
(t≼u , u⋠t) ≺-trans (u≼v , v⋠u) = (t≼u ≼-trans u≼v , λ v≼t → v⋠u (v≼t ≼-trans t≼u))
∞≼-impl-≡∞ : ∀ {t} → (+∞ ≼ t) → (t ≡ +∞)
∞≼-impl-≡∞ +∞-top = refl
src : ∀ {s t} → .(s ≼ t) → Time∞
src {s} {t} s≼t = s
tgt : ∀ {s t} → .(s ≼ t) → Time∞
tgt {s} {t} s≼t = t
-- An induction scheme for time bounds
_+_≻_ : Time∞ → ℕ → Time∞ → Set
s + zero ≻ u = u ≺ s
s + suc n ≻ u = ∀ {t} → (s ≺ t) → (t + n ≻ u)
data ≺-Indn (s u : Time∞) : Set where
_,_ : ∀ n → .(s + n ≻ u) → ≺-Indn s u
≺-indn : ∀ {s u} → .(u ≺ +∞) → ≺-Indn s u
≺-indn {s} {+∞} u≺∞ = ⊥-elim (≺-impl-≢ u≺∞ refl)
≺-indn {+∞} {fin u} u≺∞ = (zero , t≺+∞)
≺-indn {fin s} {fin u} u≺∞ = (suc (u ∸ s) , lemma s u (u ∸ s) t≤u+t∸u) where
lemma : ∀ s u n → (s + n ≥ u) → (fin s + suc n ≻ fin u)
lemma s u zero s+0≥u s≺t =
(≤-impl-≼ s+0≥u ≼-trans ≡-impl-≼ (cong fin (+-unit s))) ≺-transʳ s≺t
lemma s u (suc n) s+1+n≥u {fin t} s≺t = lemma t u n
(s+1+n≥u ≤-trans ≡-impl-≥ (+-assoc s 1 n) ≤-trans +-resp-≤ (<-impl-+1≤ (≺-impl-< s≺t)) n)
lemma s u (suc n) s+1+n≥u {+∞} s≺t =
λ ∞≺v → ⊥-elim (≺-impl-⋡ ∞≺v +∞-top)
|
{
"alphanum_fraction": 0.4396514161,
"avg_line_length": 31.2244897959,
"ext": "agda",
"hexsha": "1d3254a1b1c7631e1c1d0de4294470d51e6f507d",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:04.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-03-01T07:33:00.000Z",
"max_forks_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/agda-frp-ltl",
"max_forks_repo_path": "src/FRP/LTL/Time/Bound.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5",
"max_issues_repo_issues_event_max_datetime": "2015-03-02T15:23:53.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-01T07:01:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "agda/agda-frp-ltl",
"max_issues_repo_path": "src/FRP/LTL/Time/Bound.agda",
"max_line_length": 97,
"max_stars_count": 21,
"max_stars_repo_head_hexsha": "e88107d7d192cbfefd0a94505e6a5793afe1a7a5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/agda-frp-ltl",
"max_stars_repo_path": "src/FRP/LTL/Time/Bound.agda",
"max_stars_repo_stars_event_max_datetime": "2020-06-15T02:51:13.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-07-02T20:25:05.000Z",
"num_tokens": 2737,
"size": 4590
}
|
-- Andreas, 2019-03-28, issue #3600
--
-- Problem WAS: The size conversion checker produced invalid
-- constraints when getting stuck during checking, e.g., a <= max b a'.
-- The failing attempt of a <= b would produce constraints, which is unsound.
-- Now, we fail hard if a <= b gets stuck; this gives us a chance to succeed
-- on a <= a' instead.
{-# OPTIONS --sized-types #-}
{-# OPTIONS --show-implicit #-}
-- {-# OPTIONS -v tc.conv.size:60 -v tc.conv:10 #-}
-- {-# OPTIONS -v tc.meta.assign:10 #-}
open import Agda.Builtin.Size
data Type : (i : Size) → Set where
_⇒_ : ∀ {i j}
→ Type i
→ Type j
→ Type (↑ (i ⊔ˢ j))
Unit : ∀ {i} → Type (↑ i)
data Ty : ∀ {i} → Type i → Set where
_⇒_ : ∀ {i j} {A : Type i} {B : Type j}
→ Ty A
→ Ty B
→ Ty {↑ (i ⊔ˢ j)} (A ⇒ B)
Arr : ∀ {i j} {A : Type i} {B : Type j}
→ Ty A
→ Ty B
→ Ty (A ⇒ B)
-- Should succeed.
|
{
"alphanum_fraction": 0.5321199143,
"avg_line_length": 23.9487179487,
"ext": "agda",
"hexsha": "63d2287dd1943fb280311a5eac7df907ad10e2ba",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/Issue3600.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/Issue3600.agda",
"max_line_length": 77,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue3600.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 314,
"size": 934
}
|
{-# OPTIONS --cubical --safe #-}
module Data.Empty.Base where
open import Cubical.Data.Empty
using (⊥; isProp⊥)
public
open import Level
infix 4.5 ¬_
¬_ : Type a → Type a
¬ A = A → ⊥
⊥-elim : ⊥ → A
⊥-elim ()
|
{
"alphanum_fraction": 0.6018518519,
"avg_line_length": 13.5,
"ext": "agda",
"hexsha": "0293fdccd55c08593bd2b84ce3901ef07ae43861",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_head_hexsha": "9c5e8b6f546bee952e92db0b73bfc12592bf3152",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/masters-thesis",
"max_forks_repo_path": "agda/Data/Empty/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9c5e8b6f546bee952e92db0b73bfc12592bf3152",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/masters-thesis",
"max_issues_repo_path": "agda/Data/Empty/Base.agda",
"max_line_length": 32,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "9c5e8b6f546bee952e92db0b73bfc12592bf3152",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/masters-thesis",
"max_stars_repo_path": "agda/Data/Empty/Base.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z",
"num_tokens": 84,
"size": 216
}
|
open import Oscar.Prelude
open import Oscar.Class
open import Oscar.Class.Reflexivity
open import Oscar.Class.Symmetry
open import Oscar.Class.Transitivity
open import Oscar.Class.IsEquivalence
open import Oscar.Class.Setoid
open import Oscar.Data.Proposequality
module Oscar.Property.Setoid.Proposequality where
module _ {𝔬} {𝔒 : Ø 𝔬} where
instance
𝓡eflexivityProposequality : Reflexivity.class Proposequality⟦ 𝔒 ⟧
𝓡eflexivityProposequality .⋆ = !
𝓢ymmetryProposequality : Symmetry.class Proposequality⟦ 𝔒 ⟧
𝓢ymmetryProposequality .⋆ ∅ = !
𝓣ransitivityProposequality : Transitivity.class Proposequality⟦ 𝔒 ⟧
𝓣ransitivityProposequality .⋆ ∅ y∼z = y∼z
IsEquivalenceProposequality : IsEquivalence Proposequality⟦ 𝔒 ⟧
IsEquivalenceProposequality = ∁
module _ {𝔬} (𝔒 : Ø 𝔬) where
SetoidProposequality : Setoid _ _
SetoidProposequality = ∁ Proposequality⟦ 𝔒 ⟧
|
{
"alphanum_fraction": 0.7688053097,
"avg_line_length": 27.3939393939,
"ext": "agda",
"hexsha": "c4ee9314c5f021d633f07b99b69f766be3c27d0c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-3/src/Oscar/Property/Setoid/Proposequality.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-3/src/Oscar/Property/Setoid/Proposequality.agda",
"max_line_length": 71,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-3/src/Oscar/Property/Setoid/Proposequality.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 304,
"size": 904
}
|
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
{-# OPTIONS --allow-unsolved-metas #-}
open import LibraBFT.Base.Types
open import LibraBFT.ImplShared.Base.Types
open import LibraBFT.ImplShared.Consensus.Types.EpochIndep
open import LibraBFT.ImplShared.NetworkMsg
open import LibraBFT.ImplShared.Util.Crypto
open import Optics.All
open import Util.Hash
open import Util.KVMap
open import Util.Lemmas
open import Util.PKCS
open import Util.Prelude
open import LibraBFT.Abstract.Types.EpochConfig UID NodeId
open WithAbsVote
-- Here we have the abstraction functions that connect
-- the datatypes defined in LibraBFT.ImplFake.Consensus.Types
-- to the abstract records from LibraBFT.Abstract.Records
-- for a given EpochConfig.
--
module LibraBFT.Concrete.Records where
------------ properties relating the ids of (Executed)Blocks to hashes of their BlockData
BlockHash≡ : Block → HashValue → Set
BlockHash≡ b hv = hashBlock b ≡ hv
BlockId-correct : Block → Set
BlockId-correct b = BlockHash≡ b (b ^∙ bId)
BlockId-correct? : (b : Block) → Dec (BlockId-correct b)
BlockId-correct? b = hashBlock b ≟Hash (b ^∙ bId)
ExecutedBlockId-correct : ExecutedBlock → Set
ExecutedBlockId-correct = BlockId-correct ∘ (_^∙ ebBlock)
module WithEC (𝓔 : EpochConfig) where
open import LibraBFT.ImplShared.Consensus.Types.EpochDep
open WithEC 𝓔
open import LibraBFT.Abstract.Abstract UID _≟UID_ NodeId 𝓔 ConcreteVoteEvidence as Abs hiding (bId; qcVotes; Block)
open EpochConfig 𝓔
--------------------------------
-- Abstracting Blocks and QCs --
--------------------------------
α-Block : Block → Abs.Block
α-Block b with _bdBlockType (_bBlockData b)
...| NilBlock = record
{ bId = _bId b
; bPrevQC = just (b ^∙ bBlockData ∙ bdQuorumCert ∙ qcVoteData ∙ vdParent ∙ biId)
; bRound = b ^∙ bBlockData ∙ bdRound
}
...| Genesis = record
{ bId = b ^∙ bId
; bPrevQC = nothing
; bRound = b ^∙ bBlockData ∙ bdRound
}
...| Proposal cmd α = record
{ bId = b ^∙ bId
; bPrevQC = just (b ^∙ bBlockData ∙ bdQuorumCert ∙ qcVoteData ∙ vdParent ∙ biId)
; bRound = b ^∙ bBlockData ∙ bdRound
}
α-Block-bid≡ : (b : Block) → b ^∙ bId ≡ Abs.bId (α-Block b)
α-Block-bid≡ b
with _bdBlockType (_bBlockData b)
... | Proposal _ _ = refl
... | NilBlock = refl
... | Genesis = refl
α-Block-rnd≡ : (b : Block) → b ^∙ bBlockData ∙ bdRound ≡ Abs.bRound (α-Block b)
α-Block-rnd≡ b
with _bdBlockType (_bBlockData b)
... | Proposal _ _ = refl
... | NilBlock = refl
... | Genesis = refl
α-Block-prevqc≡-Prop : ∀ {b tx auth} → b ^∙ bBlockData ∙ bdBlockType ≡ Proposal tx auth
→ Abs.bPrevQC (α-Block b) ≡ just (b ^∙ bBlockData ∙ bdQuorumCert ∙ qcVoteData ∙ vdParent ∙ biId)
α-Block-prevqc≡-Prop {b} refl = refl
α-Block-prevqc≡-Gen : ∀ {b} → b ^∙ bBlockData ∙ bdBlockType ≡ Genesis → Abs.bPrevQC (α-Block b) ≡ nothing
α-Block-prevqc≡-Gen refl = refl
α-Block-prevqc≡-Nil : ∀ {b} → b ^∙ bBlockData ∙ bdBlockType ≡ NilBlock
→ Abs.bPrevQC (α-Block b) ≡ just (b ^∙ bBlockData ∙ bdQuorumCert ∙ qcVoteData ∙ vdParent ∙ biId)
α-Block-prevqc≡-Nil {b} refl = refl
α-VoteData-Block : VoteData → Abs.Block
α-VoteData-Block vd = record
{ bId = vd ^∙ vdProposed ∙ biId
; bPrevQC = just (vd ^∙ vdParent ∙ biId)
; bRound = vd ^∙ vdProposed ∙ biRound
}
α-Vote : (qc : QuorumCert)(valid : MetaIsValidQC qc) → ∀ {as} → as ∈ qcVotes qc → Abs.Vote
α-Vote qc v {as} as∈QC = α-ValidVote (rebuildVote qc as)
(_ivvMember (All-lookup (_ivqcMetaVotesValid v) as∈QC))
-- Abstraction of votes produce votes that carry evidence
-- they have been cast.
α-Vote-evidence : (qc : QuorumCert)(valid : MetaIsValidQC qc)
→ ∀{vs} (prf : vs ∈ qcVotes qc)
→ ConcreteVoteEvidence (α-Vote qc valid prf)
α-Vote-evidence qc valid {as} v∈qc
= record { _cveVote = rebuildVote qc as
; _cveIsValidVote = All-lookup (_ivqcMetaVotesValid valid) v∈qc
; _cveIsAbs = refl
}
α-QC : Σ QuorumCert MetaIsValidQC → Abs.QC
α-QC (qc , valid) = record
{ qCertBlockId = qc ^∙ qcVoteData ∙ vdProposed ∙ biId
; qRound = qc ^∙ qcVoteData ∙ vdProposed ∙ biRound
; qVotes = All-reduce (α-Vote qc valid) All-self
; qVotes-C1 = subst IsQuorum {! !} (MetaIsValidQC._ivqcMetaIsQuorum valid)
; qVotes-C2 = All-reduce⁺ (α-Vote qc valid) (λ _ → refl) All-self
; qVotes-C3 = All-reduce⁺ (α-Vote qc valid) (λ _ → refl) All-self
; qVotes-C4 = All-reduce⁺ (α-Vote qc valid) (α-Vote-evidence qc valid) All-self
}
-- What does it mean for an (abstract) Block or QC to be represented in a NetworkMsg?
data _α-∈NM_ : Abs.Record → NetworkMsg → Set where
qc∈NM : ∀ {cqc nm}
→ (valid : MetaIsValidQC cqc)
→ cqc QC∈NM nm
→ Abs.Q (α-QC (cqc , valid)) α-∈NM nm
b∈NM : ∀ {cb pm nm}
→ nm ≡ P pm
→ pm ^∙ pmProposal ≡ cb
→ BlockId-correct cb -- We should not consider just any message to be "InSys": an honest peer will reject a Block whose hash is incorrect.
→ Abs.B (α-Block cb) α-∈NM nm
-- Our system model contains a message pool, which is a list of NodeId-NetworkMsg pairs. The
-- following relation expresses that an abstract record r is represented in a given message pool
-- sm.
data _α-Sent_ (r : Abs.Record) (sm : List (NodeId × NetworkMsg)) : Set where
ws : ∀ {p nm} → getEpoch nm ≡ epoch → (p , nm) ∈ sm → r α-∈NM nm → r α-Sent sm
|
{
"alphanum_fraction": 0.6153589872,
"avg_line_length": 40.5608108108,
"ext": "agda",
"hexsha": "5408b50a306f8c9d30452621244522346318afdd",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_forks_repo_path": "src/LibraBFT/Concrete/Records.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_issues_repo_path": "src/LibraBFT/Concrete/Records.agda",
"max_line_length": 153,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_stars_repo_path": "src/LibraBFT/Concrete/Records.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1955,
"size": 6003
}
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import cw.CW
open import cw.DegreeByProjection
open import cohomology.ChainComplex
module cw.cohomology.cellular.ChainComplex {i : ULevel} where
chain-template : ∀ {n} (skel : Skeleton {i} n) {m}
→ Dec (m ≤ n) → AbGroup i
chain-template skel (inl m≤n) = FreeAbGroup (cells-nth m≤n skel)
chain-template skel (inr _) = Lift-abgroup {j = i} Unit-abgroup
abstract
boundary-nth-template : ∀ {n} (skel : Skeleton {i} n) dec
→ has-degrees-with-finite-support skel dec
→ {m : ℕ} (m≤n : m ≤ n) (Sm≤n : S m ≤ n)
→ cw-init (cw-take Sm≤n skel) == cw-take (≤-trans lteS Sm≤n) skel
→ cw-take (≤-trans lteS Sm≤n) skel == cw-take m≤n skel
→ FreeAbGroup.grp (cells-nth Sm≤n skel)
→ᴳ FreeAbGroup.grp (cells-nth m≤n skel)
boundary-nth-template skel dec fin-sup m≤n Sm≤n path₀ path₁ =
transportᴳ (λ lower-skel → FreeAbGroup.grp (cells-last lower-skel)) (path₀ ∙ path₁)
∘ᴳ boundary-nth Sm≤n skel dec fin-sup
boundary-template : ∀ {n} (skel : Skeleton {i} n) dec
→ has-degrees-with-finite-support skel dec
→ {m : ℕ} (m≤n? : Dec (m ≤ n)) (Sm≤n? : Dec (S m ≤ n))
→ AbGroup.grp (chain-template skel Sm≤n?)
→ᴳ AbGroup.grp (chain-template skel m≤n?)
boundary-template skel dec fin-sup _ (inr _) = cst-hom
boundary-template skel dec fin-sup (inr m≰n) (inl Sm≤n) = ⊥-rec $ m≰n (≤-trans lteS Sm≤n)
boundary-template skel dec fin-sup (inl m≤n) (inl Sm≤n) =
boundary-nth-template skel dec fin-sup m≤n Sm≤n (cw-init-take Sm≤n skel)
(ap (λ m≤n → cw-take m≤n skel) (≤-has-all-paths (≤-trans lteS Sm≤n) m≤n))
chain-complex : ∀ {n} (skel : Skeleton {i} n) dec
→ has-degrees-with-finite-support skel dec
→ ChainComplex i
chain-complex {n} skel dec fin-sup = record {M} where
module M where
head : AbGroup i
head = Lift-abgroup {j = i} ℤ-abgroup
chain : ℕ → AbGroup i
chain m = chain-template skel (≤-dec m n)
augment : AbGroup.grp (chain 0) →ᴳ AbGroup.grp head
augment = FreeAbGroup-extend head λ _ → lift 1
boundary : ∀ m → (AbGroup.grp (chain (S m)) →ᴳ AbGroup.grp (chain m))
boundary m = boundary-template skel dec fin-sup (≤-dec m n) (≤-dec (S m) n)
cochain-complex : ∀ {j} {n} (skel : Skeleton {i} n) dec
→ has-degrees-with-finite-support skel dec
→ AbGroup j → CochainComplex (lmax i j)
cochain-complex skel dec fin-sup G = complex-dualize
(chain-complex skel dec fin-sup) G
{- properties of coboundaries -}
abstract
private
path-lemma₀ : ∀ {n} (skel : Skeleton {i} (S n)) {m} (m<n : m < n) (Sm<n : S m < n)
→ ap (λ m≤Sn → cw-take m≤Sn skel) (≤-has-all-paths (≤-trans lteS (lteSR (inr Sm<n))) (lteSR (inr m<n)))
== ap (λ m≤n → cw-take m≤n (cw-init skel)) (≤-has-all-paths (≤-trans lteS (inr Sm<n)) (inr m<n))
path-lemma₀ skel m<n Sm<n =
ap (λ m≤Sn → cw-take m≤Sn skel) (≤-has-all-paths (≤-trans lteS (lteSR (inr Sm<n))) (lteSR (inr m<n)))
=⟨ ap (ap (λ m≤Sn → cw-take m≤Sn skel)) (contr-has-all-paths _ _) ⟩
ap (λ m≤Sn → cw-take m≤Sn skel) (ap (lteSR ∘ inr) (<-has-all-paths (<-trans ltS Sm<n) m<n))
=⟨ ∘-ap (λ m≤Sn → cw-take m≤Sn skel) (lteSR ∘ inr) _ ⟩
ap (λ Sm<n → cw-take (lteSR (inr Sm<n)) skel) (<-has-all-paths (<-trans ltS Sm<n) m<n)
=⟨ ap-∘ (λ m≤n → cw-take m≤n (cw-init skel)) inr _ ⟩
ap (λ m≤n → cw-take m≤n (cw-init skel)) (ap inr (<-has-all-paths (<-trans ltS Sm<n) m<n))
=⟨ ap (ap (λ m≤n → cw-take m≤n (cw-init skel))) (contr-has-all-paths _ _) ⟩
ap (λ m≤n → cw-take m≤n (cw-init skel)) (≤-has-all-paths (≤-trans lteS (inr Sm<n)) (inr m<n))
=∎
path-lemma₁ : ∀ {n} (skel : Skeleton {i} (S (S n)))
→ ap (λ n≤SSn → cw-take n≤SSn skel) (≤-has-all-paths (lteSR lteS) (lteSR lteS))
== ap (λ n≤Sn → cw-take n≤Sn (cw-init skel)) (≤-has-all-paths lteS lteS)
path-lemma₁ skel =
ap (λ n≤SSn → cw-take n≤SSn skel) (≤-has-all-paths (lteSR lteS) (lteSR lteS))
=⟨ ap (ap (λ n≤SSn → cw-take n≤SSn skel)) (contr-has-all-paths _ _) ⟩
idp
=⟨ ap (ap (λ n≤Sn → cw-take n≤Sn (cw-init skel))) (contr-has-all-paths _ _) ⟩
ap (λ n≤Sn → cw-take n≤Sn (cw-init skel)) (≤-has-all-paths lteS lteS)
=∎
path-lemma₂ : ∀ {n} (skel : Skeleton {i} (S n))
→ ap (λ n≤Sn → cw-take n≤Sn skel) (≤-has-all-paths lteS lteS) == idp
path-lemma₂ skel =
ap (λ n≤Sn → cw-take n≤Sn skel) (≤-has-all-paths lteS lteS)
=⟨ ap (ap (λ n≤Sn → cw-take n≤Sn skel)) (contr-has-all-paths _ _) ⟩
idp
=∎
abstract
boundary-template-descend-from-far : ∀ {n} (skel : Skeleton {i} (S n)) dec fin-sup {m} m<n Sm<n
→ boundary-template {n = S n} skel dec fin-sup {m} (inl (lteSR (inr m<n))) (inl (lteSR (inr Sm<n)))
== boundary-template {n = n} (cw-init skel)
(init-has-cells-with-dec-eq skel dec)
(init-has-degrees-with-finite-support skel dec fin-sup)
(inl (inr m<n)) (inl (inr Sm<n))
boundary-template-descend-from-far skel dec fin-sup m<n Sm<n =
ap (boundary-nth-template skel dec fin-sup (lteSR (inr m<n)) (lteSR (inr Sm<n)) (cw-init-take (lteSR (inr Sm<n)) skel))
(path-lemma₀ skel m<n Sm<n)
boundary-template-descend-from-two-above : ∀ {n} (skel : Skeleton {i} (S (S n))) dec fin-sup
→ boundary-template {n = S (S n)} skel dec fin-sup (inl (lteSR lteS)) (inl lteS)
== boundary-template {n = (S n)} (cw-init skel)
(init-has-cells-with-dec-eq skel dec)
(init-has-degrees-with-finite-support skel dec fin-sup)
(inl lteS) (inl lteE)
boundary-template-descend-from-two-above skel dec fin-sup =
ap (boundary-nth-template skel dec fin-sup (lteSR lteS) lteS idp) (path-lemma₁ skel)
boundary-template-β : ∀ {n} (skel : Skeleton {i} (S n)) dec fin-sup
→ boundary-template {n = S n} skel dec fin-sup (inl lteS) (inl lteE)
== FreeAbGroup-extend
(FreeAbGroup (cells-last (cw-init skel)))
(boundary'-last skel dec fin-sup)
boundary-template-β skel dec fin-sup = group-hom= $
ap (GroupHom.f ∘ boundary-nth-template skel dec fin-sup lteS lteE idp) (path-lemma₂ skel)
|
{
"alphanum_fraction": 0.5838509317,
"avg_line_length": 49.8333333333,
"ext": "agda",
"hexsha": "5060e93c2fc3eba349b83f5433ef299093820dca",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "theorems/cw/cohomology/cellular/ChainComplex.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "theorems/cw/cohomology/cellular/ChainComplex.agda",
"max_line_length": 125,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "theorems/cw/cohomology/cellular/ChainComplex.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2462,
"size": 6279
}
|
module Data.Maybe.Properties where
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
open import Data.Maybe
just-not-nothing : ∀ {ℓ}{A : Set ℓ}{x : Maybe A}{y : A} → x ≡ just y → ¬ (x ≡ nothing)
just-not-nothing refl = λ ()
|
{
"alphanum_fraction": 0.7098039216,
"avg_line_length": 28.3333333333,
"ext": "agda",
"hexsha": "02850af78de92f618ab3044fe4a49314464cd2e0",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "metaborg/mj.agda",
"max_forks_repo_path": "src/Data/Maybe/Properties.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z",
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "metaborg/mj.agda",
"max_issues_repo_path": "src/Data/Maybe/Properties.agda",
"max_line_length": 86,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "metaborg/mj.agda",
"max_stars_repo_path": "src/Data/Maybe/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z",
"num_tokens": 73,
"size": 255
}
|
{-# OPTIONS --no-termination-check #-}
module Data.Real.CReal where
import Prelude
import Data.Bool
import Data.String
import Data.Real.Complete
import Data.Real.Base
import Data.Nat
import Data.Integer
import Data.Rational as Rational
import Data.Interval
import Data.Real.Gauge
import Data.Show
import Data.List
import Data.Tuple
open Prelude
open Data.Real.Base
open Data.Real.Complete
open Data.Integer using (Int; pos) renaming (_-_ to _-i_; _<_ to _<i_)
open Rational hiding (fromInt)
open Data.Bool
open Data.String
open Data.Interval
open Data.Real.Gauge
open Data.Nat using (Nat)
open Data.Tuple
data CReal : Set where
cReal : Complete Base -> CReal
approx : CReal -> Complete Base
approx (cReal f) ε = f ε
inject : Base -> CReal
inject x = cReal (unit x)
data BoundedCReal : Set where
_∈_ : CReal -> Interval Base -> BoundedCReal
around : CReal -> Int
around (cReal f) = round (f (pos 1 % pos 2))
integerInterval : CReal -> Interval Base
integerInterval f = [ i - fromNat 1 ▻ i + fromNat 1 ]
where
i = Rational.fromInt (around f)
compact : CReal -> BoundedCReal
compact x = x ∈ integerInterval x
choke : BoundedCReal -> CReal
choke (cReal x ∈ [ lb ▻ ub ]) = cReal f
where
f : Complete Base
f ε = ! y < lb => lb
! ub < y => ub
! otherwise y
where
y = x ε
compress : Complete Base -> Complete Base
compress x ε = approxBase (x ε2) ε2
where
ε2 = ε / fromNat 2
mapCR : (Base ==> Base) -> CReal -> CReal
mapCR f (cReal x) = cReal $ mapC f (compress x)
mapCR2 : (Base ==> Base ==> Base) -> CReal -> CReal -> CReal
mapCR2 f (cReal x) (cReal y) = cReal $ mapC2 f (compress x) (compress y)
bindR : (Base ==> Complete Base) -> CReal -> CReal
bindR f (cReal x) = cReal $ bind f (compress x)
approxRange : CReal -> Gauge -> Interval Base
approxRange x ε = [ r - ε ▻ r + ε ]
where
r = approx x ε
-- non-terminates for 0
proveNonZeroFrom : Gauge -> CReal -> Base
proveNonZeroFrom g r =
! high < fromNat 0 => high
! fromNat 0 < low => low
! otherwise proveNonZeroFrom (g / fromNat 2) r
where
i = approxRange r g
low = lowerBound i
high = upperBound i
proveNonZero : CReal -> Base
proveNonZero = proveNonZeroFrom (fromNat 1)
-- Negation
negateCts : Base ==> Base
negateCts = uniformCts id -_
realNegate : CReal -> CReal
realNegate = mapCR negateCts
-- Addition
plusBaseCts : Base -> Base ==> Base
plusBaseCts a = uniformCts id (_+_ a)
plusCts : Base ==> Base ==> Base
plusCts = uniformCts id plusBaseCts
realPlus : CReal -> CReal -> CReal
realPlus = mapCR2 plusCts
realTranslate : Base -> CReal -> CReal
realTranslate a = mapCR (plusBaseCts a)
-- Multiplication
multBaseCts : Base -> Base ==> Base
multBaseCts (pos 0 %' _) = constCts (fromNat 0)
multBaseCts a = uniformCts μ (_*_ a)
where
μ = \ε -> ε / ! a !
-- First argument must be ≠ 0
multCts : Base -> Base ==> Base ==> Base
multCts maxy = uniformCts μ multBaseCts
where
μ = \ε -> ε / maxy
realScale : Base -> CReal -> CReal
realScale a = mapCR (multBaseCts a)
bound : Interval Base -> Base
bound [ lb ▻ ub ] = max ub (- lb)
realMultBound : BoundedCReal -> CReal -> CReal
realMultBound (x ∈ i) y = mapCR2 (multCts b) y (choke (x ∈ i))
where
b = bound i
realMult : CReal -> CReal -> CReal
realMult x y = realMultBound (compact x) y
-- Absolute value
absCts : Base ==> Base
absCts = uniformCts id !_!
realAbs : CReal -> CReal
realAbs = mapCR absCts
fromInt : Int -> CReal
fromInt x = inject (Rational.fromInt x)
fromRational : Rational -> CReal
fromRational = inject
-- Reciprocal
recipCts : Base -> Base ==> Base
recipCts nz = uniformCts μ f
where
f : Base -> Base
f a = ! fromNat 0 ≤ nz => recip (max nz a)
! otherwise recip (min a nz)
μ = \ε -> ε * nz ^ pos 2
realRecipWitness : Base -> CReal -> CReal
realRecipWitness nz = mapCR (recipCts nz)
realRecip : CReal -> CReal
realRecip x = realRecipWitness (proveNonZero x) x
-- Exponentiation
intPowerCts : Gauge -> Int -> Base ==> Base
intPowerCts _ (pos 0) = constCts (fromNat 1)
intPowerCts maxx n = uniformCts μ (flip _^_ n)
where
μ = \ε -> ε / (Rational.fromInt n * maxx ^ (n -i pos 1))
realPowerIntBound : BoundedCReal -> Int -> CReal
realPowerIntBound (x ∈ i) n = mapCR (intPowerCts b n) (choke (x ∈ i))
where
b = bound i
realPowerInt : CReal -> Int -> CReal
realPowerInt = realPowerIntBound ∘ compact
showReal : Nat -> CReal -> String
showReal n x =
! len ≤' n => sign ++ "0." ++ fromList (replicate (n -' len) '0') ++ s
! otherwise sign ++ i ++ "." ++ f
where
open Data.Nat using () renaming
( _^_ to _^'_
; div to div'; mod to mod'
; _==_ to _=='_; _≤_ to _≤'_
; _-_ to _-'_
)
open Data.Show
open Data.List hiding (_++_)
open Data.Integer using () renaming (-_ to -i_)
k = 10 ^' n
m = around $ realScale (fromNat k) x
m' = if m <i pos 0 then -i m else m
s = showInt m'
sign = if m <i pos 0 then "-" else ""
len = length (toList s)
p = splitAt (len -' n) $ toList s
i = fromList $ fst p
f = fromList $ snd p
|
{
"alphanum_fraction": 0.6314567615,
"avg_line_length": 23.3891402715,
"ext": "agda",
"hexsha": "05d0a6baa55f80930e8698ab60ab76673613b9c0",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "examples/lib/Data/Real/CReal.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "examples/lib/Data/Real/CReal.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "examples/lib/Data/Real/CReal.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z",
"num_tokens": 1694,
"size": 5169
}
|
module agda where
open import IO
main = run (putStrLn "Hello, World!")
|
{
"alphanum_fraction": 0.7222222222,
"avg_line_length": 14.4,
"ext": "agda",
"hexsha": "b568181c247121a8960984fd7d37e5a1ab921e3f",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-09T20:47:54.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-09T20:47:54.000Z",
"max_forks_repo_head_hexsha": "2ddfc606b8bee23bcfb7ea4226fb034b67ef15a9",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thevkrant/hello-world",
"max_forks_repo_path": "a/Agda.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2ddfc606b8bee23bcfb7ea4226fb034b67ef15a9",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thevkrant/hello-world",
"max_issues_repo_path": "a/Agda.agda",
"max_line_length": 37,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "2ddfc606b8bee23bcfb7ea4226fb034b67ef15a9",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thevkrant/hello-world",
"max_stars_repo_path": "a/Agda.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 20,
"size": 72
}
|
module Spire.Operational where
----------------------------------------------------------------------
data Level : Set where
zero : Level
suc : Level → Level
----------------------------------------------------------------------
data Context : Set
data Type (Γ : Context) : Set
data Value (Γ : Context) : Type Γ → Set
data Neutral (Γ : Context) : Type Γ → Set
----------------------------------------------------------------------
data Context where
∅ : Context
_,_ : (Γ : Context) → Type Γ → Context
data Type Γ where
`⊥ `⊤ `Bool : Type Γ
`Desc `Type : (ℓ : Level) → Type Γ
`Π `Σ : (A : Type Γ) (B : Type (Γ , A)) → Type Γ
`μ : ∀{ℓ} → Value Γ (`Desc ℓ) → Type Γ
`⟦_⟧ : ∀{ℓ} → Neutral Γ (`Type ℓ) → Type Γ
`⟦_⟧ᵈ : ∀{ℓ} → Neutral Γ (`Desc ℓ) → Type Γ → Type Γ
----------------------------------------------------------------------
⟦_⟧ : ∀{Γ ℓ} → Value Γ (`Type ℓ) → Type Γ
⟦_⟧ᵈ : ∀{Γ ℓ} → Value Γ (`Desc ℓ) → Type Γ → Type Γ
postulate
wknT : ∀{Γ A} → Type Γ → Type (Γ , A)
subT : ∀{Γ A} → Type (Γ , A) → Value Γ A → Type Γ
subV : ∀{Γ A B} → Value (Γ , A) B → (x : Value Γ A) → Value Γ (subT B x)
data Var : (Γ : Context) (A : Type Γ) → Set where
here : ∀{Γ A} → Var (Γ , A) (wknT A)
there : ∀{Γ A B} → Var Γ A → Var (Γ , B) (wknT A)
----------------------------------------------------------------------
data Value Γ where
{- Type introduction -}
`⊥ `⊤ `Bool `Desc `Type : ∀{ℓ} → Value Γ (`Type ℓ)
`Π `Σ : ∀{ℓ} (A : Value Γ (`Type ℓ)) (B : Value (Γ , ⟦ A ⟧) (`Type ℓ)) → Value Γ (`Type ℓ)
`μ : ∀{ℓ} → Value Γ (`Desc ℓ) → Value Γ (`Type ℓ)
`⟦_⟧ : ∀{ℓ} → Value Γ (`Type ℓ) → Value Γ (`Type (suc ℓ))
`⟦_⟧ᵈ : ∀{ℓ} → Value Γ (`Desc ℓ) → Value Γ (`Type ℓ) → Value Γ (`Type ℓ)
{- Desc introduction -}
`⊤ᵈ `Xᵈ : ∀{ℓ} → Value Γ (`Desc ℓ)
`Πᵈ `Σᵈ : ∀{ℓ}
(A : Value Γ (`Type ℓ))
(B : Value (Γ , ⟦ A ⟧) (`Desc (suc ℓ)))
→ Value Γ (`Desc (suc ℓ))
{- Value introduction -}
`tt : Value Γ `⊤
`true `false : Value Γ `Bool
_`,_ : ∀{A B} (a : Value Γ A) (b : Value Γ (subT B a)) → Value Γ (`Σ A B)
`λ : ∀{A B} → Value (Γ , A) B → Value Γ (`Π A B)
`con : ∀{ℓ} {D : Value Γ (`Desc ℓ)} → Value Γ (⟦ D ⟧ᵈ (`μ D)) → Value Γ (`μ D)
`neut : ∀{A} → Neutral Γ A → Value Γ A
----------------------------------------------------------------------
data Neutral Γ where
{- Value elimination -}
`var : ∀{A} → Var Γ A → Neutral Γ A
`if_`then_`else_ : ∀{C} (b : Neutral Γ `Bool) (c₁ c₂ : Value Γ C) → Neutral Γ C
`elim⊥ : ∀{A} → Neutral Γ `⊥ → Neutral Γ A
`elimBool : ∀{ℓ} (P : Value (Γ , `Bool) (`Type ℓ))
(pt : Value Γ (subT ⟦ P ⟧ `true))
(pf : Value Γ (subT ⟦ P ⟧ `false))
(b : Neutral Γ `Bool) → Neutral Γ (subT ⟦ P ⟧ (`neut b))
`proj₁ : ∀{A B} → Neutral Γ (`Σ A B) → Neutral Γ A
`proj₂ : ∀{A B} (ab : Neutral Γ (`Σ A B)) → Neutral Γ (subT B (`neut (`proj₁ ab)))
_`$_ : ∀{A B} (f : Neutral Γ (`Π A B)) (a : Value Γ A) → Neutral Γ (subT B a)
`des : ∀{ℓ} {D : Value Γ (`Desc ℓ)} → Neutral Γ (`μ D) → Neutral Γ (⟦ D ⟧ᵈ (`μ D))
----------------------------------------------------------------------
⟦ `Π A B ⟧ = `Π ⟦ A ⟧ ⟦ B ⟧
⟦ `Σ A B ⟧ = `Σ ⟦ A ⟧ ⟦ B ⟧
⟦ `⊥ ⟧ = `⊥
⟦ `⊤ ⟧ = `⊤
⟦ `Bool ⟧ = `Bool
⟦ `μ D ⟧ = `μ D
⟦ `Type {zero} ⟧ = `⊥
⟦ `Type {suc ℓ} ⟧ = `Type ℓ
⟦ `⟦ A ⟧ ⟧ = ⟦ A ⟧
⟦ `Desc {ℓ} ⟧ = `Desc ℓ
⟦ `⟦ D ⟧ᵈ X ⟧ = ⟦ D ⟧ᵈ ⟦ X ⟧
⟦ `neut A ⟧ = `⟦ A ⟧
----------------------------------------------------------------------
⟦ `⊤ᵈ ⟧ᵈ X = `⊤
⟦ `Xᵈ ⟧ᵈ X = X
⟦ `Πᵈ A D ⟧ᵈ X = `Π ⟦ A ⟧ (⟦ D ⟧ᵈ (wknT X))
⟦ `Σᵈ A D ⟧ᵈ X = `Σ ⟦ A ⟧ (⟦ D ⟧ᵈ (wknT X))
⟦ `neut D ⟧ᵈ X = `⟦ D ⟧ᵈ X
----------------------------------------------------------------------
elim⊥ : ∀{Γ A} → Value Γ `⊥ → Value Γ A
elim⊥ (`neut bot) = `neut (`elim⊥ bot)
----------------------------------------------------------------------
if_then_else_ : ∀{Γ C} (b : Value Γ `Bool) (c₁ c₂ : Value Γ C) → Value Γ C
if `true then c₁ else c₂ = c₁
if `false then c₁ else c₂ = c₂
if `neut b then c₁ else c₂ = `neut (`if b `then c₁ `else c₂)
elimBool : ∀{Γ ℓ} (P : Value (Γ , `Bool) (`Type ℓ))
(pt : Value Γ (subT ⟦ P ⟧ `true))
(pf : Value Γ (subT ⟦ P ⟧ `false))
(b : Value Γ `Bool)
→ Value Γ (subT ⟦ P ⟧ b)
elimBool P pt pf `true = pt
elimBool P pt pf `false = pf
elimBool P pt pf (`neut b) = `neut (`elimBool P pt pf b)
----------------------------------------------------------------------
proj₁ : ∀{Γ A B} → Value Γ (`Σ A B) → Value Γ A
proj₁ (a `, b) = a
proj₁ (`neut ab) = `neut (`proj₁ ab)
proj₂ : ∀{Γ A B} (ab : Value Γ (`Σ A B)) → Value Γ (subT B (proj₁ ab))
proj₂ (a `, b) = b
proj₂ (`neut ab) = `neut (`proj₂ ab)
----------------------------------------------------------------------
des : ∀{Γ ℓ} {D : Value Γ (`Desc ℓ)} → Value Γ (`μ D) → Value Γ (⟦ D ⟧ᵈ (`μ D))
des (`con x) = x
des (`neut x) = `neut (`des x)
----------------------------------------------------------------------
_$_ : ∀{Γ A B} → Value Γ (`Π A B) → (a : Value Γ A) → Value Γ (subT B a)
`λ b $ a = subV b a
`neut f $ a = `neut (f `$ a)
----------------------------------------------------------------------
data Term (Γ : Context) : Type Γ → Set
eval : ∀{Γ A} → Term Γ A → Value Γ A
data Term Γ where
{- Type introduction -}
`⊥ `⊤ `Bool `Type : ∀{ℓ} → Term Γ (`Type ℓ)
`Π `Σ : ∀{ℓ} (A : Term Γ (`Type ℓ)) (B : Term (Γ , ⟦ eval A ⟧) (`Type ℓ)) → Term Γ (`Type ℓ)
`μ : ∀{ℓ} → Term Γ (`Desc ℓ) → Term Γ (`Type ℓ)
`⟦_⟧ : ∀{ℓ} → Term Γ (`Type ℓ) → Term Γ (`Type (suc ℓ))
`⟦_⟧ᵈ : ∀{ℓ} → Term Γ (`Desc ℓ) → Term Γ (`Type ℓ) → Term Γ (`Type ℓ)
{- Desc introduction -}
`⊤ᵈ `Xᵈ : ∀{ℓ} → Term Γ (`Desc ℓ)
`Πᵈ `Σᵈ : ∀{ℓ}
(A : Term Γ (`Type ℓ))
(D : Term (Γ , ⟦ eval A ⟧) (`Desc (suc ℓ)))
→ Term Γ (`Desc (suc ℓ))
{- Value introduction -}
`tt : Term Γ `⊤
`true `false : Term Γ `Bool
_`,_ : ∀{A B}
(a : Term Γ A) (b : Term Γ (subT B (eval a)))
→ Term Γ (`Σ A B)
`λ : ∀{A B}
(b : Term (Γ , A) B)
→ Term Γ (`Π A B)
`con : ∀{ℓ} {D : Value Γ (`Desc ℓ)} → Term Γ (⟦ D ⟧ᵈ (`μ D)) → Term Γ (`μ D)
{- Value elimination -}
`var : ∀{A} → Var Γ A → Term Γ A
`if_`then_`else_ : ∀{C}
(b : Term Γ `Bool)
(c₁ c₂ : Term Γ C)
→ Term Γ C
_`$_ : ∀{A B} (f : Term Γ (`Π A B)) (a : Term Γ A) → Term Γ (subT B (eval a))
`proj₁ : ∀{A B} → Term Γ (`Σ A B) → Term Γ A
`proj₂ : ∀{A B} (ab : Term Γ (`Σ A B)) → Term Γ (subT B (proj₁ (eval ab)))
`elim⊥ : ∀{A} → Term Γ `⊥ → Term Γ A
`elimBool : ∀{ℓ} (P : Term (Γ , `Bool) (`Type ℓ))
(pt : Term Γ (subT ⟦ eval P ⟧ `true))
(pf : Term Γ (subT ⟦ eval P ⟧ `false))
(b : Term Γ `Bool)
→ Term Γ (subT ⟦ eval P ⟧ (eval b))
`des : ∀{ℓ} {D : Value Γ (`Desc ℓ)} → Term Γ (`μ D) → Term Γ (⟦ D ⟧ᵈ (`μ D))
----------------------------------------------------------------------
{- Type introduction -}
eval `⊥ = `⊥
eval `⊤ = `⊤
eval `Bool = `Bool
eval `Type = `Type
eval (`Π A B) = `Π (eval A) (eval B)
eval (`Σ A B) = `Σ (eval A) (eval B)
eval (`μ D) = `μ (eval D)
eval `⟦ A ⟧ = `⟦ eval A ⟧
eval (`⟦ D ⟧ᵈ X) = `⟦ eval D ⟧ᵈ (eval X)
{- Desc introduction -}
eval `⊤ᵈ = `⊤ᵈ
eval `Xᵈ = `Xᵈ
eval (`Πᵈ A D) = `Πᵈ (eval A) (eval D)
eval (`Σᵈ A D) = `Σᵈ (eval A) (eval D)
{- Value introduction -}
eval `tt = `tt
eval `true = `true
eval `false = `false
eval (a `, b) = eval a `, eval b
eval (`λ b) = `λ (eval b)
eval (`con x) = `con (eval x)
{- Value elimination -}
eval (`var i) = `neut (`var i)
eval (`if b `then c₁ `else c₂) = if eval b then eval c₁ else eval c₂
eval (f `$ a) = eval f $ eval a
eval (`proj₁ ab) = proj₁ (eval ab)
eval (`proj₂ ab) = proj₂ (eval ab)
eval (`elim⊥ bot) = elim⊥ (eval bot)
eval (`elimBool P pt pf b) = elimBool (eval P) (eval pt) (eval pf) (eval b)
eval (`des x) = des (eval x)
----------------------------------------------------------------------
|
{
"alphanum_fraction": 0.4144983819,
"avg_line_length": 32.4579831933,
"ext": "agda",
"hexsha": "33ff6bf36b8c707691d5af2ddd887af57a8f94f3",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2015-08-17T21:00:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-08-17T21:00:07.000Z",
"max_forks_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "spire/spire",
"max_forks_repo_path": "formalization/agda/Spire/Operational.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "spire/spire",
"max_issues_repo_path": "formalization/agda/Spire/Operational.agda",
"max_line_length": 94,
"max_stars_count": 43,
"max_stars_repo_head_hexsha": "3d67f137ee9423b7e6f8593634583998cd692353",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "spire/spire",
"max_stars_repo_path": "formalization/agda/Spire/Operational.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-08T17:10:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-28T23:25:33.000Z",
"num_tokens": 3270,
"size": 7725
}
|
open import Type
module Relator.Equals.Proofs.Equiv {ℓ} {T : Type{ℓ}} where
import Relator.Equals.Proofs.Equivalence
open Relator.Equals.Proofs.Equivalence.One {T = T} public
open Relator.Equals.Proofs.Equivalence.Two {A = T} public
open Relator.Equals.Proofs.Equivalence.Three {A = T} public
open Relator.Equals.Proofs.Equivalence.Four {A = T} public
instance [≡]-unary-relator-instance = [≡]-unary-relator
instance [≡]-binary-relator-instance = [≡]-binary-relator
instance [≡]-binary-operator-instance = [≡]-binary-operator
instance [≡]-trinary-operator-instance = [≡]-trinary-operator
instance [≡]-to-function-instance = [≡]-to-function
instance [≡]-equiv-instance = [≡]-equiv
|
{
"alphanum_fraction": 0.7158931083,
"avg_line_length": 39.5,
"ext": "agda",
"hexsha": "993f61cd196e2d1371bd71a284d35ef096cee4ce",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Relator/Equals/Proofs/Equiv.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Relator/Equals/Proofs/Equiv.agda",
"max_line_length": 61,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Relator/Equals/Proofs/Equiv.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 217,
"size": 711
}
|
{-# OPTIONS --rewriting --confluence-check #-}
open import Agda.Builtin.Bool
open import Agda.Builtin.Equality
open import Agda.Builtin.Equality.Rewrite
data Unit : Set where
unit : Unit
Foo : Unit → Set
Foo unit = Unit
Bar : Unit → Unit → Set
Bar unit = Foo
bar : ∀ x y → Bar x y ≡ Unit
bar unit unit = refl
{-# REWRITE bar #-}
test : ∀ x y → Bar x y
test _ _ = unit
works : ∀ x → Foo x
works x = test unit x
|
{
"alphanum_fraction": 0.6547619048,
"avg_line_length": 16.1538461538,
"ext": "agda",
"hexsha": "52399363274a264466d29c9337e9b631a5c71160",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Fail/Issue1445-3.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Fail/Issue1445-3.agda",
"max_line_length": 46,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Issue1445-3.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 129,
"size": 420
}
|
module Imports.Issue5357-C where
import Imports.Issue5357-D
|
{
"alphanum_fraction": 0.85,
"avg_line_length": 20,
"ext": "agda",
"hexsha": "d6a087a7432e9a70ee4b5cce9a2fcd5dae0024f5",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "cagix/agda",
"max_forks_repo_path": "test/interaction/Imports/Issue5357-C.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "cagix/agda",
"max_issues_repo_path": "test/interaction/Imports/Issue5357-C.agda",
"max_line_length": 32,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "cagix/agda",
"max_stars_repo_path": "test/interaction/Imports/Issue5357-C.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 17,
"size": 60
}
|
module Selective.Examples.Chat where
open import Selective.ActorMonad
open import Selective.Libraries.Call
open import Prelude
hiding (Maybe)
open import Data.Maybe as Maybe
hiding (map)
open import Data.Maybe.Categorical as CMaybe
open import Data.List.Properties
open import Category.Monad
open import Debug
open import Data.Nat.Show using (show)
RoomName = ℕ
ClientName = ℕ
ClientInterface : InboxShape
Client-to-Room : InboxShape
Room-to-Client : InboxShape
-- =============
-- JOIN ROOM
-- =============
data JoinRoomSuccess : Set where
JR-SUCCESS : RoomName → JoinRoomSuccess
data JoinRoomFail : Set where
JR-FAIL : RoomName → JoinRoomFail
data JoinRoomStatus : Set where
JRS-SUCCESS JRS-FAIL : RoomName → JoinRoomStatus
JoinRoomSuccessReply : MessageType
JoinRoomSuccessReply = ValueType UniqueTag ∷ ValueType JoinRoomSuccess ∷ [ ReferenceType Client-to-Room ]ˡ
JoinRoomFailReply : MessageType
JoinRoomFailReply = ValueType UniqueTag ∷ [ ValueType JoinRoomFail ]ˡ
JoinRoomReplyInterface : InboxShape
JoinRoomReplyInterface = JoinRoomSuccessReply ∷ JoinRoomFailReply ∷ Room-to-Client
JoinRoom : MessageType
JoinRoom = ValueType UniqueTag ∷ ReferenceType JoinRoomReplyInterface ∷ ValueType RoomName ∷ [ ValueType ClientName ]ˡ
-- =============
-- CREATE ROOM
-- =============
data CreateRoomResult : Set where
CR-SUCCESS CR-EXISTS : RoomName → CreateRoomResult
CreateRoomReply : MessageType
CreateRoomReply = ValueType UniqueTag ∷ [ ValueType CreateRoomResult ]ˡ
CreateRoom : MessageType
CreateRoom = ValueType UniqueTag ∷ ReferenceType [ CreateRoomReply ]ˡ ∷ [ ValueType RoomName ]ˡ
-- ============
-- LIST ROOMS
-- ============
RoomList : Set
RoomList = List RoomName
ListRoomsReply : MessageType
ListRoomsReply = ValueType UniqueTag ∷ [ ValueType RoomList ]ˡ
ListRooms : MessageType
ListRooms = ValueType UniqueTag ∷ [ ReferenceType [ ListRoomsReply ]ˡ ]ˡ
-- ===
--
-- ===
Client-to-RoomManager : InboxShape
Client-to-RoomManager = JoinRoom ∷ CreateRoom ∷ [ ListRooms ]ˡ
RoomManagerInterface : InboxShape
RoomManagerInterface = Client-to-RoomManager
GetRoomManagerReply : MessageType
GetRoomManagerReply = ValueType UniqueTag ∷ [ ReferenceType RoomManagerInterface ]ˡ
GetRoomManager : MessageType
GetRoomManager = ValueType UniqueTag ∷ [ ReferenceType [ GetRoomManagerReply ]ˡ ]ˡ
RoomSupervisorInterface : InboxShape
RoomSupervisorInterface = [ GetRoomManager ]ˡ
ClientSupervisorInterface : InboxShape
ClientSupervisorInterface =
[ ReferenceType RoomSupervisorInterface ]ˡ ∷ [ GetRoomManagerReply ]ˡ
--
--
--
record ChatMessageContent : Set where
constructor chat-from_message:_
field
sender : ClientName
message : String
ChatMessage : MessageType
ChatMessage = [ ValueType ChatMessageContent ]ˡ
LeaveRoom : MessageType
LeaveRoom = [ ValueType ClientName ]ˡ
Client-to-Room = ChatMessage ∷ [ LeaveRoom ]ˡ
Room-to-Client = [ ChatMessage ]ˡ
AddToRoom : MessageType
AddToRoom = ValueType ClientName ∷ [ ReferenceType Room-to-Client ]ˡ
RoomManager-to-Room : InboxShape
RoomManager-to-Room = [ AddToRoom ]ˡ
RoomInstanceInterface : InboxShape
RoomInstanceInterface = Client-to-Room ++ RoomManager-to-Room
ClientInterface = [ ReferenceType RoomManagerInterface ]ˡ ∷ CreateRoomReply ∷ ListRoomsReply ∷ JoinRoomReplyInterface
-- ======
-- ROOM
-- ======
ClientList : Set
ClientList = List ClientName
record RoomState : Set₁ where
field
clients : ClientList
cl-to-context : ClientList → TypingContext
cl-to-context = map λ _ → Room-to-Client
rs-to-context : RoomState → TypingContext
rs-to-context rs = let open RoomState
in cl-to-context (rs .clients)
record RoomLeave (rs : ClientList) (name : ClientName) : Set₁ where
field
filtered : ClientList
subs : (cl-to-context filtered) ⊆ (cl-to-context rs)
++-temp-fix : (l r : ClientList) → (x : ClientName) → (l ++ (x ∷ r)) ≡ ((l ∷ʳ x) ++ r)
++-temp-fix [] r x = refl
++-temp-fix (x₁ ∷ l) r x = cong (_∷_ x₁) (++-temp-fix l r x)
room-instance : ∀ {i} → ActorM i RoomInstanceInterface RoomState [] rs-to-context
room-instance = begin (loop (record { clients = [] }))
where
-- only removes first occurance...
leave-room : (cl : ClientList) → (name : ClientName) → RoomLeave cl name
leave-room [] name = record { filtered = [] ; subs = [] }
leave-room (x ∷ cl) name with (x ≟ name)
... | (yes _) = record { filtered = cl ; subs = ⊆-suc ⊆-refl }
... | (no _) = let
rl = leave-room cl name
open RoomLeave
in record { filtered = x ∷ rl .filtered ; subs = Z ∷ ⊆-suc (rl .subs) }
send-to-others : ∀ {i} → (cl : ClientList) →
ClientName →
String →
∞ActorM i RoomInstanceInterface ⊤₁ (cl-to-context cl) (λ _ → cl-to-context cl)
send-to-others [] _ _ = return _
send-to-others cl@(_ ∷ _) name message = send-loop [] cl
where
build-pointer : (l r : ClientList) →
cl-to-context r ⊢ Room-to-Client →
(cl-to-context (l ++ r)) ⊢ Room-to-Client
build-pointer [] r p = p
build-pointer (x ∷ l) r p = S (build-pointer l r p)
recurse : ∀ {i} → (l r : ClientList) → (x : ClientName) →
∞ActorM i RoomInstanceInterface ⊤₁ (cl-to-context (l ++ (x ∷ r))) (λ _ → (cl-to-context (l ++ (x ∷ r))))
send-loop : ∀ {i} → (l r : ClientList) →
∞ActorM i RoomInstanceInterface ⊤₁ (cl-to-context (l ++ r)) (λ _ → cl-to-context (l ++ r))
send-loop l [] = return _
send-loop l (x ∷ r) with (x ≟ name)
... | (yes _) = recurse l r x
... | (no _) = let p = build-pointer l (x ∷ r) Z
in debug ("Sending to " || show x || ": " || message) (p ![t: Z ] [ lift (chat-from name message: message) ]ᵃ ) >> recurse l r x
recurse l r x rewrite ++-temp-fix l r x = send-loop (l ∷ʳ x) r
handle-message : ∀ {i} → (rs : RoomState) →
(m : Message RoomInstanceInterface) →
∞ActorM i RoomInstanceInterface RoomState (add-references (rs-to-context rs) m) rs-to-context
-- chat message
handle-message rs (Msg Z (chat-from client-name message: message ∷ [])) = do
let open RoomState
debug ("room sending " || show (pred (length (rs .clients))) || " messages from " || show client-name || ": " || message) (send-to-others (rs .clients) client-name message)
(return₁ rs)
-- leave room
handle-message rs (Msg (S Z) (client-name ∷ [])) = do
let
open RoomState
open RoomLeave
rl = leave-room (rs .clients) client-name
debug ("client#" || show client-name || " left the room") (strengthen (rl .subs))
(return₁ (record { clients = rl .filtered }))
-- add to room
handle-message rs (Msg (S (S Z)) (client-name ∷ _ ∷ [])) = do
let open RoomState
return₁ (record { clients = client-name ∷ rs .clients })
handle-message rs (Msg (S (S (S ()))) _)
loop : ∀ {i} →
(rs : RoomState) →
∞ActorM i RoomInstanceInterface RoomState (rs-to-context rs) rs-to-context
loop state .force = begin do
m ← debug ("ROOM LOOP") receive
state' ← (handle-message state m)
loop state'
-- ==============
-- ROOM MANAGER
-- ==============
record RoomManagerState : Set₁ where
field
rooms : RoomList
rms-to-context : RoomManagerState → TypingContext
rms-to-context rms = rl-to-context (rms .rooms)
where
open RoomManagerState
rl-to-context : RoomList → TypingContext
rl-to-context = map λ _ → RoomInstanceInterface
lookup-room : ∀ {i} → {Γ : TypingContext} →
(rms : RoomManagerState) →
RoomName →
∞ActorM i RoomManagerInterface (Maybe ((Γ ++ (rms-to-context rms)) ⊢ RoomInstanceInterface)) (Γ ++ (rms-to-context rms)) (λ _ → Γ ++ (rms-to-context rms))
lookup-room rms name =
let open RoomManagerState
in return₁ (loop _ (rms .rooms))
where
rl-to-context : RoomList → TypingContext
rl-to-context = map λ _ → RoomInstanceInterface
loop : (Γ : TypingContext) → (rl : RoomList) → Maybe ((Γ ++ rl-to-context rl) ⊢ RoomInstanceInterface)
loop [] [] = nothing
loop [] (x ∷ xs) with (x ≟ name)
... | (yes p) = just Z
... | (no _) = RawMonad._>>=_ CMaybe.monad (loop [] xs) λ p → just (S p)
loop (x ∷ Γ) rl = RawMonad._>>=_ CMaybe.monad (loop Γ rl) (λ p → just (S p))
room-manager : ∀ {i} → ActorM i RoomManagerInterface RoomManagerState [] rms-to-context
room-manager = begin (loop (record { rooms = [] }))
where
handle-room-join : ∀ {i} → {Γ : TypingContext} →
UniqueTag →
RoomName →
ClientName →
(Γ ⊢ JoinRoomReplyInterface) →
(Maybe (Γ ⊢ RoomInstanceInterface)) →
∞ActorM i RoomManagerInterface ⊤₁ Γ (λ _ → Γ)
handle-room-join tag room-name client-name cp (just rp) = do
cp ![t: Z ] ((lift tag) ∷ (lift (JR-SUCCESS room-name)) ∷ [ [ rp ]>: (Z ∷ [ S Z ]ᵐ) ]ᵃ)
rp ![t: S (S Z) ] ((lift client-name) ∷ [ [ cp ]>: [ S (S Z) ]ᵐ ]ᵃ)
handle-room-join tag room-name client-name p nothing =
p ![t: S Z ] (lift tag ∷ [ lift (JR-FAIL room-name) ]ᵃ)
handle-create-room : ∀ {i} →
(rms : RoomManagerState) →
UniqueTag →
RoomName →
Maybe (([ CreateRoomReply ]ˡ ∷ rms-to-context rms) ⊢ RoomInstanceInterface) →
∞ActorM i RoomManagerInterface RoomManagerState ([ CreateRoomReply ]ˡ ∷ rms-to-context rms) rms-to-context
handle-create-room rms tag name (just x) = do
Z ![t: Z ] ((lift tag) ∷ [ lift (CR-EXISTS name) ]ᵃ)
strengthen (⊆-suc ⊆-refl)
return₁ rms
handle-create-room rms tag name nothing = do
Z ![t: Z ] ((lift tag) ∷ [ lift (CR-SUCCESS name) ]ᵃ)
strengthen (⊆-suc ⊆-refl)
spawn room-instance
let
rms' : RoomManagerState
rms' = (record { rooms = name ∷ RoomManagerState.rooms rms })
(return₁ rms')
handle-message : ∀ {i} → (rms : RoomManagerState) →
(m : Message RoomManagerInterface) →
∞ActorM i RoomManagerInterface RoomManagerState (add-references (rms-to-context rms) m) rms-to-context
-- Jooin room
handle-message state (Msg Z (tag ∷ _ ∷ room-name ∷ client-name ∷ [])) = do
p ← (lookup-room state room-name)
handle-room-join tag room-name client-name Z p
(strengthen (⊆-suc ⊆-refl))
(return₁ state)
-- Create room
handle-message state (Msg (S Z) (tag ∷ _ ∷ name ∷ [])) = do
p ← lookup-room state name
handle-create-room state tag name p
-- List rooms
handle-message state (Msg (S (S Z)) (tag ∷ _ ∷ [])) = do
(Z ![t: Z ] ((lift tag) ∷ [(lift (RoomManagerState.rooms state) )]ᵃ))
(strengthen (⊆-suc ⊆-refl))
(return₁ state)
handle-message state (Msg (S (S (S ()))) _)
loop : ∀ {i} →
(rms : RoomManagerState) →
∞ActorM i RoomManagerInterface RoomManagerState (rms-to-context rms) rms-to-context
loop state .force = begin do
m ← receive
state' ← handle-message state m
loop state'
-- =================
-- ROOM SUPERVISOR
-- =================
rs-context : TypingContext
rs-context = [ RoomManagerInterface ]ˡ
-- room-supervisor spawns the room-manager
-- and provides an interface for getting a reference to the current room-manager
-- we don't ever change that instance, but we could if we want
room-supervisor : ∀ {i} → ActorM i RoomSupervisorInterface ⊤₁ [] (λ _ → rs-context)
room-supervisor = begin do
(spawn room-manager)
provide-manager-instance
where
provide-manager-instance : ∀ {i} → ∞ActorM i RoomSupervisorInterface ⊤₁ rs-context (λ _ → rs-context)
provide-manager-instance .force = begin do
(Msg Z (tag ∷ _ ∷ [])) ← receive
where (Msg (S ()) _)
Z ![t: Z ] (lift tag ∷ [ [ S Z ]>: ⊆-refl ]ᵃ)
(strengthen (⊆-suc ⊆-refl))
provide-manager-instance
-- ================
-- CLIENT GENERAL
-- ================
busy-wait : ∀ {i IS Γ} → ℕ → ∞ActorM i IS ⊤₁ Γ (λ _ → Γ)
busy-wait zero = return _
busy-wait (suc n) = return tt >> busy-wait n
client-get-room-manager : ∀ {i} → ∞ActorM i ClientInterface ⊤₁ [] (λ _ → [ RoomManagerInterface ]ˡ)
client-get-room-manager = do
record { msg = Msg Z _} ← (selective-receive (λ {
(Msg Z x₁) → true
; (Msg (S _) _) → false
}))
where
record { msg = (Msg (S _) _) ; msg-ok = ()}
return _
client-create-room : ∀ {i } →
{Γ : TypingContext} →
Γ ⊢ RoomManagerInterface →
UniqueTag →
RoomName →
∞ActorM i ClientInterface (Lift (lsuc lzero) CreateRoomResult) Γ (λ _ → Γ)
client-create-room p tag name = do
record { msg = (Msg (S Z) (_ ∷ cr ∷ [])) } ← (call p (S Z) tag [ lift name ]ᵃ [ S Z ]ᵐ Z)
where
record { msg = (Msg Z (_ ∷ _)) ; msg-ok = () }
record { msg = (Msg (S (S _)) _) ; msg-ok = () }
return cr
add-if-join-success : TypingContext →
Lift (lsuc lzero) JoinRoomStatus →
TypingContext
add-if-join-success Γ (lift (JRS-SUCCESS x)) = Client-to-Room ∷ Γ
add-if-join-success Γ (lift (JRS-FAIL x)) = Γ
client-join-room : ∀ {i Γ} →
Γ ⊢ RoomManagerInterface →
UniqueTag →
RoomName →
ClientName →
∞ActorM i ClientInterface (Lift (lsuc lzero) JoinRoomStatus) Γ (add-if-join-success Γ)
client-join-room p tag room-name client-name = do
self
S p ![t: Z ] (lift tag ∷ (([ Z ]>: ⊆-suc (⊆-suc (⊆-suc ⊆-refl))) ∷ (lift room-name) ∷ [ lift client-name ]ᵃ))
(strengthen (⊆-suc ⊆-refl))
m ← (selective-receive (select-join-reply tag))
handle-message m
where
select-join-reply : UniqueTag → MessageFilter ClientInterface
select-join-reply tag (Msg Z _) = false
select-join-reply tag (Msg (S Z) _) = false
select-join-reply tag (Msg (S (S Z)) _) = false
select-join-reply tag (Msg (S (S (S Z))) (tag' ∷ _)) = ⌊ tag ≟ tag' ⌋
select-join-reply tag (Msg (S (S (S (S Z)))) (tag' ∷ _)) = ⌊ tag ≟ tag' ⌋
select-join-reply tag (Msg (S (S (S (S (S Z))))) x₁) = false
select-join-reply tag (Msg (S (S (S (S (S (S ())))))) _)
handle-message : ∀ {tag i Γ} → (m : SelectedMessage (select-join-reply tag)) →
∞ActorM i ClientInterface (Lift (lsuc lzero) JoinRoomStatus)
(add-selected-references Γ m) (add-if-join-success Γ)
handle-message record { msg = (Msg Z _) ; msg-ok = () }
handle-message record { msg = (Msg (S Z) _) ; msg-ok = () }
handle-message record { msg = (Msg (S (S Z)) _) ; msg-ok = () }
handle-message record { msg = (Msg (S (S (S Z))) (_ ∷ JR-SUCCESS room-name ∷ _ ∷ [])) } = return (JRS-SUCCESS room-name)
handle-message record { msg = (Msg (S (S (S (S Z)))) (_ ∷ JR-FAIL room-name ∷ [])) } = return (JRS-FAIL room-name)
handle-message record { msg = (Msg (S (S (S (S (S Z))))) _) ; msg-ok = () }
handle-message record { msg = (Msg (S (S (S (S (S (S ())))))) _) }
client-send-message : ∀ {i Γ} →
Γ ⊢ Client-to-Room →
ClientName →
String →
∞ActorM i ClientInterface ⊤₁ Γ (λ _ → Γ)
client-send-message p client-name message = p ![t: Z ] [ lift (chat-from client-name message: message) ]ᵃ
client-receive-message : ∀ {i Γ} →
∞ActorM i ClientInterface (Lift (lsuc lzero) ChatMessageContent) Γ (λ _ → Γ)
client-receive-message = do
m ← (selective-receive select-message)
handle-message m
where
select-message : MessageFilter ClientInterface
select-message (Msg (S (S (S (S (S Z))))) _) = true
select-message (Msg _ _) = false
handle-message : ∀ {i Γ} → (m : SelectedMessage select-message) →
∞ActorM i ClientInterface (Lift (lsuc lzero) ChatMessageContent) (add-selected-references Γ m) (λ _ → Γ)
handle-message record { msg = (Msg Z _) ; msg-ok = () }
handle-message record { msg = (Msg (S Z) _) ; msg-ok = () }
handle-message record { msg = (Msg (S (S Z)) _) ; msg-ok = () }
handle-message record { msg = (Msg (S (S (S Z))) x₁) ; msg-ok = () }
handle-message record { msg = (Msg (S (S (S (S Z)))) _) ; msg-ok = () }
handle-message record { msg = (Msg (S (S (S (S (S Z))))) (m ∷ [])) ; msg-ok = _ } = return m
handle-message record { msg = (Msg (S (S (S (S (S (S ())))))) _) }
client-leave-room : ∀ {i Γ} →
Γ ⊢ Client-to-Room →
ClientName →
∞ActorM i ClientInterface ⊤₁ Γ (λ _ → Γ)
client-leave-room p name = p ![t: S Z ] [ lift name ]ᵃ
debug-chat : {a : Level} {A : Set a} → ClientName → ChatMessageContent → A → A
debug-chat client-name content = let open ChatMessageContent
in debug ("client#" || show client-name || " received \"" || content .message || "\" from client#" || show (content .sender))
-- ==========
-- CLIENT 1
-- ==========
room1-2 = 1
room2-3 = 2
room3-1 = 3
room1-2-3 = 4
name1 = 1
client1 : ∀ {i} → ActorM i ClientInterface ⊤₁ [] (λ _ → [])
client1 = begin do
client-get-room-manager
_ ← (client-create-room Z 0 room1-2)
_ ← (client-create-room Z 1 room3-1)
_ ← (client-create-room Z 2 room1-2-3)
lift (JRS-SUCCESS joined-room) ← (client-join-room Z 3 room3-1 name1)
where
(lift (JRS-FAIL failed-room)) → strengthen []
lift (JRS-SUCCESS joined-room) ← (client-join-room (S Z) 4 room1-2 name1)
where
(lift (JRS-FAIL failed-room)) → strengthen []
lift (JRS-SUCCESS joined-room) ← (client-join-room (S (S Z)) 5 room1-2-3 name1)
where
(lift (JRS-FAIL failed-room)) → strengthen []
busy-wait 100
(client-send-message (S Z) name1 "hi from 1 to 2")
(client-send-message Z name1 "hi from 1 to 2-3")
let open ChatMessageContent
lift m1 ← client-receive-message
lift m2 ← debug-chat name1 m1 client-receive-message
lift m3 ← debug-chat name1 m2 client-receive-message
debug-chat name1 m3 (client-send-message Z name1 "hi1 from 1 to 2-3")
(client-send-message Z name1 "hi2 from 1 to 2-3")
(client-send-message Z name1 "hi3 from 1 to 2-3")
client-leave-room (S Z) name1
client-leave-room (Z) name1
(strengthen [])
-- ==========
-- CLIENT 2
-- ==========
name2 = 2
client2 : ∀ {i} → ActorM i ClientInterface ⊤₁ [] (λ _ → [])
client2 = begin do
client-get-room-manager
_ ← (client-create-room Z 0 room1-2)
_ ← (client-create-room Z 1 room2-3)
_ ← (client-create-room Z 2 room1-2-3)
lift (JRS-SUCCESS joined-room) ← (client-join-room Z 3 room1-2 name2)
where
(lift (JRS-FAIL failed-room)) → strengthen []
lift (JRS-SUCCESS joined-room) ← (client-join-room (S Z) 4 room2-3 name2)
where
(lift (JRS-FAIL failed-room)) → strengthen []
lift (JRS-SUCCESS joined-room) ← (client-join-room (S (S Z)) 5 room1-2-3 name2)
where
(lift (JRS-FAIL failed-room)) → strengthen []
busy-wait 100
debug "client2 send message" (client-send-message (S Z) name2 "hi from 2 to 3")
debug "client2 send message" (client-send-message Z name2 "hi from 2 to 1-3")
let open ChatMessageContent
lift m1 ← client-receive-message
lift m2 ← debug-chat name2 m1 client-receive-message
lift m3 ← debug-chat name2 m2 client-receive-message
client-leave-room (S Z) name2
client-leave-room (Z) name2
debug-chat name2 m3 (strengthen [])
-- ==========
-- CLIENT 3
-- ==========
name3 = 3
client3 : ∀ {i} → ActorM i ClientInterface ⊤₁ [] (λ _ → [])
client3 = begin do
client-get-room-manager
_ ← (client-create-room Z 0 room2-3)
_ ← (client-create-room Z 1 room3-1)
_ ← (client-create-room Z 2 room1-2-3)
lift (JRS-SUCCESS joined-room) ← (client-join-room Z 3 room2-3 name3)
where
(lift (JRS-FAIL failed-room)) → strengthen []
lift (JRS-SUCCESS joined-room) ← (client-join-room (S Z) 4 room3-1 name3)
where
(lift (JRS-FAIL failed-room)) → strengthen []
lift (JRS-SUCCESS joined-room) ← (client-join-room (S (S Z)) 5 room1-2-3 name3)
where
(lift (JRS-FAIL failed-room)) → strengthen []
busy-wait 100
debug "client3 send message" (client-send-message (S Z) name3 "hi from 3 to 1")
debug "client3 send message" (client-send-message Z name3 "hi from 3 to 1-2")
let open ChatMessageContent
lift m1 ← client-receive-message
lift m2 ← debug-chat name3 m1 client-receive-message
lift m3 ← debug-chat name3 m2 client-receive-message
debug-chat name3 m3 (client-leave-room Z name3)
client-leave-room (S Z) name3
client-leave-room Z name3
(strengthen [])
-- ===================
-- CLIENT SUPERVISOR
-- ===================
cs-context : TypingContext
cs-context = RoomManagerInterface ∷ RoomSupervisorInterface ∷ []
client-supervisor : ∀ {i} → ActorM i ClientSupervisorInterface ⊤₁ [] (λ _ → cs-context)
client-supervisor = begin do
wait-for-room-supervisor
(get-room-manager Z 0)
spawn-clients
where
wait-for-room-supervisor : ∀ {i Γ} → ∞ActorM i ClientSupervisorInterface ⊤₁ Γ (λ _ → RoomSupervisorInterface ∷ Γ)
wait-for-room-supervisor = do
record { msg = Msg Z f } ← (selective-receive (λ {
(Msg Z _) → true
; (Msg (S _) _) → false
}))
where
record { msg = (Msg (S _) _) ; msg-ok = () }
return _
get-room-manager : ∀ {i Γ} →
Γ ⊢ RoomSupervisorInterface →
UniqueTag →
∞ActorM i ClientSupervisorInterface ⊤₁ Γ (λ _ → RoomManagerInterface ∷ Γ)
get-room-manager p tag = do
record { msg = Msg (S Z) (_ ∷ _ ∷ []) } ← (call p Z tag [] (⊆-suc ⊆-refl) Z)
where
record { msg = (Msg Z (_ ∷ _)) ; msg-ok = () }
record { msg = (Msg (S (S ())) _) }
return _
spawn-clients : ∀ {i} → ∞ActorM i ClientSupervisorInterface ⊤₁ cs-context (λ _ → cs-context)
spawn-clients = do
spawn client1
Z ![t: Z ] [ [ S Z ]>: ⊆-refl ]ᵃ
(strengthen (⊆-suc ⊆-refl))
(spawn client2)
Z ![t: Z ] [ [ S Z ]>: ⊆-refl ]ᵃ
(strengthen (⊆-suc ⊆-refl))
(spawn client3)
Z ![t: Z ] [ [ S Z ]>: ⊆-refl ]ᵃ
(strengthen (⊆-suc ⊆-refl))
-- chat-supervisor is the top-most actor
-- it spawns and connects the ClientRegistry to the RoomRegistry
chat-supervisor : ∀ {i} → ∞ActorM i [] ⊤₁ [] (λ _ → [])
chat-supervisor = do
spawn room-supervisor
spawn client-supervisor
Z ![t: Z ] [ [ S Z ]>: ⊆-refl ]ᵃ
strengthen []
|
{
"alphanum_fraction": 0.5835342749,
"avg_line_length": 38.9011725293,
"ext": "agda",
"hexsha": "d2d3be2824a7153872b9230a48a6e35bcf892406",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Zalastax/singly-typed-actors",
"max_forks_repo_path": "src/Selective/Examples/Chat.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Zalastax/singly-typed-actors",
"max_issues_repo_path": "src/Selective/Examples/Chat.agda",
"max_line_length": 180,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "ae541df13d069df4eb1464f29fbaa9804aad439f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Zalastax/singly-typed-actors",
"max_stars_repo_path": "src/Selective/Examples/Chat.agda",
"max_stars_repo_stars_event_max_datetime": "2019-10-29T09:30:26.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-10-29T09:30:26.000Z",
"num_tokens": 6891,
"size": 23224
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Reflection utilities for ℕ
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Nat.Reflection where
open import Data.Nat.Base as ℕ
open import Data.Fin.Base as Fin
open import Data.List.Base using ([])
open import Reflection.Term
open import Reflection.Argument
------------------------------------------------------------------------
-- Term
toTerm : ℕ → Term
toTerm zero = con (quote ℕ.zero) []
toTerm (suc i) = con (quote ℕ.suc) (toTerm i ⟨∷⟩ [])
toFinTerm : ℕ → Term
toFinTerm zero = con (quote Fin.zero) (1 ⋯⟅∷⟆ [])
toFinTerm (suc i) = con (quote Fin.suc) (1 ⋯⟅∷⟆ toFinTerm i ⟨∷⟩ [])
|
{
"alphanum_fraction": 0.4736842105,
"avg_line_length": 28.8518518519,
"ext": "agda",
"hexsha": "4d069d3b10beb1f0b58008d3800cd378a715c8b3",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/Nat/Reflection.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/Nat/Reflection.agda",
"max_line_length": 72,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/Nat/Reflection.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 187,
"size": 779
}
|
-- 2012-01-17 Bug found by Rob Simmons, example simplified by Nisse
-- {-# OPTIONS -v tc.proj.like:50 #-}
-- {-# OPTIONS -v tc.conv.atom:50 #-}
module Issue553b where
data E : Set where
module M (A : Set) where
data D : Set where
d₁ d₂ : D
data B : Set where
b : D → B
-- T must not be classified as projection-like, because of deep matching
T : B → Set
T (b d₁) = E
T (b d₂) = E
data P : B → Set where
p : (b : B) → T b → P b
pb : (d : D) → T (b d) → P (b d)
pb d t = p (b d) t
|
{
"alphanum_fraction": 0.5531914894,
"avg_line_length": 19.8846153846,
"ext": "agda",
"hexsha": "07eb28eeda950dd8e6a7443141941d39c7f41f09",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cruhland/agda",
"max_forks_repo_path": "test/Succeed/Issue553b.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cruhland/agda",
"max_issues_repo_path": "test/Succeed/Issue553b.agda",
"max_line_length": 74,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue553b.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 194,
"size": 517
}
|
-- This test case was reported by Andrea Vezzosi.
{-# OPTIONS --no-guardedness #-}
open import Agda.Builtin.Size
data Σ (A : Set) (B : A → Set) : Set where
_,_ : (x : A) → B x → Σ A B
data ⊥ : Set where
record T (i : Size) : Set where
constructor con
coinductive
field
force : Σ (Size< i) λ{ j → T j }
open T public
empty : ∀ i → T i → ⊥
empty i x with force x
... | j , y = empty j y
inh : T ∞
inh = λ{ .force → ∞ , inh } -- using ∞ < ∞ here
false : ⊥
false = empty ∞ inh
|
{
"alphanum_fraction": 0.5647773279,
"avg_line_length": 17.0344827586,
"ext": "agda",
"hexsha": "3c26b288a92ab3adf3b4838c008b687a084e0982",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "test/Fail/Issue1946-5.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue1946-5.agda",
"max_line_length": 49,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue1946-5.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 184,
"size": 494
}
|
{-# OPTIONS --without-K --safe #-}
-- Some properties of 'heterogeneous' identity morphisms
module Categories.Morphism.HeterogeneousIdentity.Properties where
open import Level
open import Data.Product using (curry) renaming (_,_ to _,,_)
open import Relation.Binary.PropositionalEquality
open import Categories.Category using (Category; _[_,_]; _[_≈_])
open import Categories.Category.Product
open import Categories.Functor using (Functor) renaming (id to idF)
open import Categories.Functor.Bifunctor
open import Categories.Morphism.HeterogeneousIdentity
private
variable
o ℓ e o′ ℓ′ e′ o″ ℓ″ e″ o‴ ℓ‴ e‴ : Level
open Category using (Obj; id)
-- Functor identity laws lifted to heterogeneous identities.
hid-identity : (C : Category o ℓ e) (D : Category o′ ℓ′ e′)
{F₀ : Obj C → Obj D}
(F₁ : ∀ {A B} → C [ A , B ] → D [ F₀ A , F₀ B ]) →
(∀ {A} → D [ F₁ (id C {A}) ≈ id D ]) →
∀ {A B} (p : A ≡ B) → D [ F₁ (hid C p) ≈ hid D (cong F₀ p) ]
hid-identity C D F₁ hyp refl = hyp
hid-identity₂ : (C₁ : Category o ℓ e) (C₂ : Category o′ ℓ′ e′)
(D : Category o″ ℓ″ e″)
{F₀ : Obj C₁ → Obj C₂ → Obj D}
(F₁ : ∀ {A₁ A₂ B₁ B₂} → C₁ [ A₁ , B₁ ] → C₂ [ A₂ , B₂ ] →
D [ F₀ A₁ A₂ , F₀ B₁ B₂ ]) →
(∀ {A₁ A₂} → D [ F₁ (id C₁ {A₁}) (id C₂ {A₂}) ≈ id D ]) →
∀ {A₁ A₂ B₁ B₂} (p : A₁ ≡ B₁) (q : A₂ ≡ B₂) →
D [ F₁ (hid C₁ p) (hid C₂ q) ≈ hid D (cong₂ F₀ p q) ]
hid-identity₂ C₁ C₂ D F₁ hyp refl refl = hyp
module _ {C : Category o ℓ e} {D : Category o′ ℓ′ e′}
(F : Functor C D) where
open Category D
open Functor F
-- functors preserve heterogeneous identities
F-hid : ∀ {A B} (p : A ≡ B) → F₁ (hid C p) ≈ hid D (cong F₀ p)
F-hid = hid-identity C D F₁ identity
module _ {C₁ : Category o ℓ e} {C₂ : Category o′ ℓ′ e′}
{D : Category o″ ℓ″ e″} (F : Bifunctor C₁ C₂ D) where
open Category D
open Functor F
-- bifunctors preserve heterogeneous identities
BF-hid : ∀ {A₁ A₂ B₁ B₂} (p : A₁ ≡ B₁) (q : A₂ ≡ B₂) →
F₁ (hid C₁ p ,, hid C₂ q) ≈ hid D (cong₂ (curry F₀) p q)
BF-hid = hid-identity₂ C₁ C₂ D (curry F₁) identity
module _ (C : Category o ℓ e) (D : Category o′ ℓ′ e′) where
open Category (Product C D)
-- products preserve heterogeneous identities
×-hid : ∀ {A₁ A₂ B₁ B₂} (p : A₁ ≡ B₁) (q : A₂ ≡ B₂) →
(hid C p ,, hid D q) ≈ hid (Product C D) (cong₂ _,,_ p q)
×-hid p q = BF-hid {C₁ = C} {C₂ = D} (idF ⁂ idF) p q
|
{
"alphanum_fraction": 0.5616438356,
"avg_line_length": 35.985915493,
"ext": "agda",
"hexsha": "e85a06d0a135a1cd6951607af94833af1a795a31",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Morphism/HeterogeneousIdentity/Properties.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Morphism/HeterogeneousIdentity/Properties.agda",
"max_line_length": 75,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Morphism/HeterogeneousIdentity/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z",
"num_tokens": 953,
"size": 2555
}
|
module PrintFloat where
import AlonzoPrelude
import PreludeShow
import PreludeList
import PreludeString
import PreludeNat
open AlonzoPrelude
open PreludeShow
open PreludeList, hiding(_++_)
open PreludeString
open PreludeNat
typeS : Char -> Set
typeS 'f' = Float
show : (c : Char) -> (typeS c) -> String
show 'f' f = showFloat f
data Unit : Set where
unit : Unit
data Format : Set where
stringArg : Format
natArg : Format
intArg : Format
floatArg : Format
charArg : Format
litChar : Char -> Format
badFormat : Char -> Format
data BadFormat (c:Char) : Set where
format' : List Char -> List Format
format' ('%' :: 's' :: fmt) = stringArg :: format' fmt
format' ('%' :: 'n' :: fmt) = natArg :: format' fmt
-- format' ('%' :: 'd' :: fmt) = intArg :: format' fmt
format' ('%' :: 'f' :: fmt) = floatArg :: format' fmt
format' ('%' :: 'c' :: fmt) = charArg :: format' fmt
format' ('%' :: '%' :: fmt) = litChar '%' :: format' fmt
format' ('%' :: c :: fmt) = badFormat c :: format' fmt
format' (c :: fmt) = litChar c :: format' fmt
format' [] = []
format : String -> List Format
format s = format' (toList s)
-- Printf1 : Format -> Set
-- Printf1 floatArg = Float
Printf' : List Format -> Set
Printf' (stringArg :: fmt) = String × Printf' fmt
Printf' (natArg :: fmt) = Nat × Printf' fmt
Printf' (intArg :: fmt) = Int × Printf' fmt
Printf' (floatArg :: fmt) = Float × Printf' fmt
Printf' (charArg :: fmt) = Char × Printf' fmt
Printf' (badFormat c :: fmt) = BadFormat c
Printf' (litChar _ :: fmt) = Printf' fmt
Printf' [] = Unit × Unit
Printf : String -> Set
Printf fmt = Printf' (format fmt)
printf' : (fmt : List Format) -> Printf' fmt -> String
printf' (stringArg :: fmt) < s | args > = s ++ printf' fmt args
printf' (natArg :: fmt) < n | args > = showNat n ++ printf' fmt args
printf' (intArg :: fmt) < n | args > = showInt n ++ printf' fmt args
printf' (floatArg :: fmt) < x | args > = showFloat x ++ printf' fmt args
printf' (charArg :: fmt) < c | args > = showChar c ++ printf' fmt args
printf' (litChar c :: fmt) args = fromList (c :: []) ++ printf' fmt args
printf' (badFormat _ :: fmt) ()
printf' [] < unit | unit > = ""
printf : (fmt : String) -> Printf fmt -> String
printf fmt = printf' (format fmt)
-- mainS = show 'f' 3.14
-- mainS = printf' (format "%f") < 3.14 | < unit | unit > >
mainS = printf "pi = %f" < 3.14159 | < unit | unit > >
-- mainS = fromList ( 'p' :: [] )
|
{
"alphanum_fraction": 0.5865499403,
"avg_line_length": 30.6463414634,
"ext": "agda",
"hexsha": "7ce23621f54753a491c719b9d935132bc9ed6f55",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "larrytheliquid/agda",
"max_forks_repo_path": "examples/outdated-and-incorrect/Alonzo/PrintFloat.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/agda",
"max_issues_repo_path": "examples/outdated-and-incorrect/Alonzo/PrintFloat.agda",
"max_line_length": 75,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "examples/outdated-and-incorrect/Alonzo/PrintFloat.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 805,
"size": 2513
}
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
module homotopy.CoHSpace where
record CoHSpaceStructure {i} (X : Ptd i) : Type i where
constructor coHSpaceStructure
field
⊙coμ : X ⊙→ X ⊙∨ X
coμ : de⊙ X → X ∨ X
coμ = fst ⊙coμ
field
⊙unit-l : ⊙projr ⊙∘ ⊙coμ ⊙∼ ⊙idf X
⊙unit-r : ⊙projl ⊙∘ ⊙coμ ⊙∼ ⊙idf X
{-
module _ {i j : ULevel} {X : Ptd i} (CHSS : CoHSpaceStructure X) where
open CoHSpaceStructure CHSS
private
lemma-l : ⊙projr ⊙∘ ⊙∨-fmap (⊙lift {j = j}) (⊙lift {j = j}) ⊙∘ ⊙coμ ⊙∘ ⊙lower {j = j}
== ⊙idf _
abstract
lemma-l =
! (⊙λ= (⊙∘-assoc ⊙projr (⊙∨-fmap (⊙lift {j = j}) (⊙lift {j = j})) (⊙coμ ⊙∘ ⊙lower {j = j})))
∙ ap (_⊙∘ ⊙coμ ⊙∘ ⊙lower) (⊙λ= (⊙Wedge-rec-fmap ⊙cst (⊙idf _) (⊙lift {j = j}) (⊙lift {j = j})))
∙ ap (_⊙∘ ⊙coμ ⊙∘ ⊙lower) (! (⊙λ= (⊙Wedge-rec-post∘ (⊙lift {j = j}) ⊙cst (⊙idf _))))
∙ ⊙λ= (⊙∘-assoc (⊙lift {j = j}) ⊙projr (⊙coμ ⊙∘ ⊙lower {j = j}))
∙ ap (λ f → ⊙lift {j = j} ⊙∘ f ⊙∘ ⊙lower {j = j}) (⊙λ= ⊙unit-l)
private
lemma-r : ⊙projl ⊙∘ ⊙∨-fmap (⊙lift {j = j}) (⊙lift {j = j}) ⊙∘ ⊙coμ ⊙∘ ⊙lower {j = j}
== ⊙idf _
abstract
lemma-r =
! (⊙λ= (⊙∘-assoc ⊙projl (⊙∨-fmap (⊙lift {j = j}) (⊙lift {j = j})) (⊙coμ ⊙∘ ⊙lower {j = j})))
∙ ap (_⊙∘ ⊙coμ ⊙∘ ⊙lower) (⊙λ= (⊙Wedge-rec-fmap (⊙idf _) ⊙cst (⊙lift {j = j}) (⊙lift {j = j})))
∙ ap (_⊙∘ ⊙coμ ⊙∘ ⊙lower) (! (⊙λ= (⊙Wedge-rec-post∘ (⊙lift {j = j}) (⊙idf _) ⊙cst)))
∙ ⊙λ= (⊙∘-assoc (⊙lift {j = j}) ⊙projl (⊙coμ ⊙∘ ⊙lower {j = j}))
∙ ap (λ f → ⊙lift {j = j} ⊙∘ f ⊙∘ ⊙lower {j = j}) (⊙λ= ⊙unit-r)
Lift-co-h-space-structure : CoHSpaceStructure (⊙Lift {j = j} X)
Lift-co-h-space-structure = record
{ ⊙coμ = ⊙∨-fmap ⊙lift ⊙lift ⊙∘ ⊙coμ ⊙∘ ⊙lower
; ⊙unit-l = ⊙app= lemma-l
; ⊙unit-r = ⊙app= lemma-r
}
-}
|
{
"alphanum_fraction": 0.4664117968,
"avg_line_length": 34.5471698113,
"ext": "agda",
"hexsha": "b75c49af972d681587a7cf0b1c1caa297d6c5472",
"lang": "Agda",
"max_forks_count": 50,
"max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z",
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "theorems/homotopy/CoHSpace.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "theorems/homotopy/CoHSpace.agda",
"max_line_length": 101,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "theorems/homotopy/CoHSpace.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z",
"num_tokens": 1018,
"size": 1831
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.