Search is not available for this dataset
text
string | meta
dict |
---|---|
{-
This second-order term syntax was created from the following second-order syntax description:
syntax Sub | S
type
L : 0-ary
T : 0-ary
term
vr : L -> T
sb : L.T T -> T
theory
(C) x y : T |> sb (a. x[], y[]) = x[]
(L) x : T |> sb (a. vr(a), x[]) = x[]
(R) a : L x : L.T |> sb (b. x[b], vr(a[])) = x[a[]]
(A) x : (L,L).T y : L.T z : T |> sb (a. sb (b. x[a,b], y[a]), z[]) = sb (b. sb (a. x[a, b], z[]), sb (a. y[a], z[]))
-}
module Sub.Syntax where
open import SOAS.Common
open import SOAS.Context
open import SOAS.Variable
open import SOAS.Families.Core
open import SOAS.Construction.Structure
open import SOAS.ContextMaps.Inductive
open import SOAS.Metatheory.Syntax
open import Sub.Signature
private
variable
Γ Δ Π : Ctx
α : ST
𝔛 : Familyₛ
-- Inductive term declaration
module S:Terms (𝔛 : Familyₛ) where
data S : Familyₛ where
var : ℐ ⇾̣ S
mvar : 𝔛 α Π → Sub S Π Γ → S α Γ
vr : S L Γ → S T Γ
sb : S T (L ∙ Γ) → S T Γ → S T Γ
open import SOAS.Metatheory.MetaAlgebra ⅀F 𝔛
Sᵃ : MetaAlg S
Sᵃ = record
{ 𝑎𝑙𝑔 = λ where
(vrₒ ⋮ a) → vr a
(sbₒ ⋮ a , b) → sb a b
; 𝑣𝑎𝑟 = var ; 𝑚𝑣𝑎𝑟 = λ 𝔪 mε → mvar 𝔪 (tabulate mε) }
module Sᵃ = MetaAlg Sᵃ
module _ {𝒜 : Familyₛ}(𝒜ᵃ : MetaAlg 𝒜) where
open MetaAlg 𝒜ᵃ
𝕤𝕖𝕞 : S ⇾̣ 𝒜
𝕊 : Sub S Π Γ → Π ~[ 𝒜 ]↝ Γ
𝕊 (t ◂ σ) new = 𝕤𝕖𝕞 t
𝕊 (t ◂ σ) (old v) = 𝕊 σ v
𝕤𝕖𝕞 (mvar 𝔪 mε) = 𝑚𝑣𝑎𝑟 𝔪 (𝕊 mε)
𝕤𝕖𝕞 (var v) = 𝑣𝑎𝑟 v
𝕤𝕖𝕞 (vr a) = 𝑎𝑙𝑔 (vrₒ ⋮ 𝕤𝕖𝕞 a)
𝕤𝕖𝕞 (sb a b) = 𝑎𝑙𝑔 (sbₒ ⋮ 𝕤𝕖𝕞 a , 𝕤𝕖𝕞 b)
𝕤𝕖𝕞ᵃ⇒ : MetaAlg⇒ Sᵃ 𝒜ᵃ 𝕤𝕖𝕞
𝕤𝕖𝕞ᵃ⇒ = record
{ ⟨𝑎𝑙𝑔⟩ = λ{ {t = t} → ⟨𝑎𝑙𝑔⟩ t }
; ⟨𝑣𝑎𝑟⟩ = refl
; ⟨𝑚𝑣𝑎𝑟⟩ = λ{ {𝔪 = 𝔪}{mε} → cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-tab mε)) } }
where
open ≡-Reasoning
⟨𝑎𝑙𝑔⟩ : (t : ⅀ S α Γ) → 𝕤𝕖𝕞 (Sᵃ.𝑎𝑙𝑔 t) ≡ 𝑎𝑙𝑔 (⅀₁ 𝕤𝕖𝕞 t)
⟨𝑎𝑙𝑔⟩ (vrₒ ⋮ _) = refl
⟨𝑎𝑙𝑔⟩ (sbₒ ⋮ _) = refl
𝕊-tab : (mε : Π ~[ S ]↝ Γ)(v : ℐ α Π) → 𝕊 (tabulate mε) v ≡ 𝕤𝕖𝕞 (mε v)
𝕊-tab mε new = refl
𝕊-tab mε (old v) = 𝕊-tab (mε ∘ old) v
module _ (g : S ⇾̣ 𝒜)(gᵃ⇒ : MetaAlg⇒ Sᵃ 𝒜ᵃ g) where
open MetaAlg⇒ gᵃ⇒
𝕤𝕖𝕞! : (t : S α Γ) → 𝕤𝕖𝕞 t ≡ g t
𝕊-ix : (mε : Sub S Π Γ)(v : ℐ α Π) → 𝕊 mε v ≡ g (index mε v)
𝕊-ix (x ◂ mε) new = 𝕤𝕖𝕞! x
𝕊-ix (x ◂ mε) (old v) = 𝕊-ix mε v
𝕤𝕖𝕞! (mvar 𝔪 mε) rewrite cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-ix mε))
= trans (sym ⟨𝑚𝑣𝑎𝑟⟩) (cong (g ∘ mvar 𝔪) (tab∘ix≈id mε))
𝕤𝕖𝕞! (var v) = sym ⟨𝑣𝑎𝑟⟩
𝕤𝕖𝕞! (vr a) rewrite 𝕤𝕖𝕞! a = sym ⟨𝑎𝑙𝑔⟩
𝕤𝕖𝕞! (sb a b) rewrite 𝕤𝕖𝕞! a | 𝕤𝕖𝕞! b = sym ⟨𝑎𝑙𝑔⟩
-- Syntax instance for the signature
S:Syn : Syntax
S:Syn = record
{ ⅀F = ⅀F
; ⅀:CS = ⅀:CompatStr
; mvarᵢ = S:Terms.mvar
; 𝕋:Init = λ 𝔛 → let open S:Terms 𝔛 in record
{ ⊥ = S ⋉ Sᵃ
; ⊥-is-initial = record { ! = λ{ {𝒜 ⋉ 𝒜ᵃ} → 𝕤𝕖𝕞 𝒜ᵃ ⋉ 𝕤𝕖𝕞ᵃ⇒ 𝒜ᵃ }
; !-unique = λ{ {𝒜 ⋉ 𝒜ᵃ} (f ⋉ fᵃ⇒) {x = t} → 𝕤𝕖𝕞! 𝒜ᵃ f fᵃ⇒ t } } } }
-- Instantiation of the syntax and metatheory
open Syntax S:Syn public
open S:Terms public
open import SOAS.Families.Build public
open import SOAS.Syntax.Shorthands Sᵃ public
open import SOAS.Metatheory S:Syn public
| {
"alphanum_fraction": 0.5202182285,
"avg_line_length": 24.7301587302,
"ext": "agda",
"hexsha": "fb7b6ee2e28e1fd84140703524de1f167455ca62",
"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/Sub/Syntax.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/Sub/Syntax.agda",
"max_line_length": 120,
"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/Sub/Syntax.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": 1927,
"size": 3116
} |
{-# OPTIONS --without-K --allow-unsolved-metas --exact-split #-}
module 16-pushouts where
import 15-pullbacks
open 15-pullbacks public
-- Section 14.1
{- We define the type of cocones with vertex X on a span. Since we will use it
later on, we will also characterize the identity type of the type of cocones
with a given vertex X. -}
cocone :
{l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) → UU l4 → UU _
cocone {A = A} {B = B} f g X =
Σ (A → X) (λ i → Σ (B → X) (λ j → (i ∘ f) ~ (j ∘ g)))
{- We characterize the identity type of the type of cocones with vertex C. -}
coherence-htpy-cocone :
{l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c c' : cocone f g X) →
(K : (pr1 c) ~ (pr1 c')) (L : (pr1 (pr2 c)) ~ (pr1 (pr2 c'))) → UU (l1 ⊔ l4)
coherence-htpy-cocone f g c c' K L =
((pr2 (pr2 c)) ∙h (L ·r g)) ~ ((K ·r f) ∙h (pr2 (pr2 c')))
htpy-cocone :
{l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} →
cocone f g X → cocone f g X → UU (l1 ⊔ (l2 ⊔ (l3 ⊔ l4)))
htpy-cocone f g c c' =
Σ ((pr1 c) ~ (pr1 c'))
( λ K → Σ ((pr1 (pr2 c)) ~ (pr1 (pr2 c')))
( coherence-htpy-cocone f g c c' K))
reflexive-htpy-cocone :
{l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) →
htpy-cocone f g c c
reflexive-htpy-cocone f g (pair i (pair j H)) =
pair htpy-refl (pair htpy-refl htpy-right-unit)
htpy-cocone-eq :
{l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c c' : cocone f g X) →
Id c c' → htpy-cocone f g c c'
htpy-cocone-eq f g c .c refl = reflexive-htpy-cocone f g c
is-contr-total-htpy-cocone :
{l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) →
is-contr (Σ (cocone f g X) (htpy-cocone f g c))
is-contr-total-htpy-cocone f g c =
is-contr-total-Eq-structure
( λ i' jH' K → Σ ((pr1 (pr2 c)) ~ (pr1 jH'))
( coherence-htpy-cocone f g c (pair i' jH') K))
( is-contr-total-htpy (pr1 c))
( pair (pr1 c) htpy-refl)
( is-contr-total-Eq-structure
( λ j' H' → coherence-htpy-cocone f g c
( pair (pr1 c) (pair j' H'))
( htpy-refl))
( is-contr-total-htpy (pr1 (pr2 c)))
( pair (pr1 (pr2 c)) htpy-refl)
( is-contr-is-equiv'
( Σ (((pr1 c) ∘ f) ~ ((pr1 (pr2 c)) ∘ g)) (λ H' → (pr2 (pr2 c)) ~ H'))
( tot (λ H' M → htpy-right-unit ∙h M))
( is-equiv-tot-is-fiberwise-equiv (λ H' → is-equiv-htpy-concat _ _))
( is-contr-total-htpy (pr2 (pr2 c)))))
is-equiv-htpy-cocone-eq :
{l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c c' : cocone f g X) →
is-equiv (htpy-cocone-eq f g c c')
is-equiv-htpy-cocone-eq f g c =
fundamental-theorem-id c
( reflexive-htpy-cocone f g c)
( is-contr-total-htpy-cocone f g c)
( htpy-cocone-eq f g c)
eq-htpy-cocone :
{l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c c' : cocone f g X) →
htpy-cocone f g c c' → Id c c'
eq-htpy-cocone f g c c' = inv-is-equiv (is-equiv-htpy-cocone-eq f g c c')
{- Given a cocone c on a span S with vertex X, and a type Y, the function
cocone-map sends a function X → Y to a new cocone with vertex Y. -}
cocone-map :
{l1 l2 l3 l4 l5 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} {Y : UU l5} →
cocone f g X → (X → Y) → cocone f g Y
cocone-map f g (pair i (pair j H)) h =
pair (h ∘ i) (pair (h ∘ j) (h ·l H))
cocone-map-id :
{l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) →
Id (cocone-map f g c id) c
cocone-map-id f g (pair i (pair j H)) =
eq-pair refl (eq-pair refl (eq-htpy (λ s → ap-id (H s))))
cocone-map-comp :
{l1 l2 l3 l4 l5 l6 : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X)
{Y : UU l5} (h : X → Y) {Z : UU l6} (k : Y → Z) →
Id (cocone-map f g c (k ∘ h)) ((cocone-map f g (cocone-map f g c h) k))
cocone-map-comp f g (pair i (pair j H)) h k =
eq-pair refl (eq-pair refl (eq-htpy (λ s → ap-comp k h (H s))))
{- A cocone c on a span S is said to satisfy the universal property of the
pushout of S if the function cocone-map is an equivalence for every type Y.
-}
universal-property-pushout :
{l1 l2 l3 l4 : Level} (l : Level) {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} →
cocone f g X → UU _
universal-property-pushout l f g c =
(Y : UU l) → is-equiv (cocone-map f g {Y = Y} c)
-- Section 14.2 Suspensions
suspension-structure :
{l1 l2 : Level} (X : UU l1) (Y : UU l2) → UU (l1 ⊔ l2)
suspension-structure X Y = Σ Y (λ N → Σ Y (λ S → (x : X) → Id N S))
suspension-cocone' :
{l1 l2 : Level} (X : UU l1) (Y : UU l2) → UU (l1 ⊔ l2)
suspension-cocone' X Y = cocone (const X unit star) (const X unit star) Y
cocone-suspension-structure :
{l1 l2 : Level} (X : UU l1) (Y : UU l2) →
suspension-structure X Y → suspension-cocone' X Y
cocone-suspension-structure X Y (pair N (pair S merid)) =
pair
( const unit Y N)
( pair
( const unit Y S)
( merid))
universal-property-suspension' :
(l : Level) {l1 l2 : Level} (X : UU l1) (Y : UU l2)
(susp-str : suspension-structure X Y) → UU (lsuc l ⊔ l1 ⊔ l2)
universal-property-suspension' l X Y susp-str-Y =
universal-property-pushout l
( const X unit star)
( const X unit star)
( cocone-suspension-structure X Y susp-str-Y)
is-suspension :
(l : Level) {l1 l2 : Level} (X : UU l1) (Y : UU l2) → UU (lsuc l ⊔ l1 ⊔ l2)
is-suspension l X Y =
Σ (suspension-structure X Y) (universal-property-suspension' l X Y)
{- We define the type of suspensions at universe level l, for any type X. Since
we would like to define type families over a suspension by the universal
property of the suspension, we assume that the universal property of a
suspension holds for at least level (lsuc l ⊔ l1). This is the level that
contains both X and the suspension itself. -}
UU-Suspensions :
(l : Level) {l1 : Level} (X : UU l1) → UU (lsuc (lsuc l) ⊔ lsuc l1)
UU-Suspensions l {l1} X = Σ (UU l) (is-suspension (lsuc l ⊔ l1) X)
{- We now work towards Lemma 17.2.2. -}
suspension-cocone :
{l1 l2 : Level} (X : UU l1) (Z : UU l2) → UU _
suspension-cocone X Z = Σ Z (λ z1 → Σ Z (λ z2 → (x : X) → Id z1 z2))
ev-suspension :
{l1 l2 l3 : Level} {X : UU l1} {Y : UU l2} →
(susp-str-Y : suspension-structure X Y) →
(Z : UU l3) → (Y → Z) → suspension-cocone X Z
ev-suspension (pair N (pair S merid)) Z h =
pair (h N) (pair (h S) (h ·l merid))
universal-property-suspension :
(l : Level) {l1 l2 : Level} (X : UU l1) (Y : UU l2) →
suspension-structure X Y → UU (lsuc l ⊔ l1 ⊔ l2)
universal-property-suspension l X Y susp-str-Y =
(Z : UU l) → is-equiv (ev-suspension susp-str-Y Z)
comparison-suspension-cocone :
{l1 l2 : Level} (X : UU l1) (Z : UU l2) →
suspension-cocone' X Z ≃ suspension-cocone X Z
comparison-suspension-cocone X Z =
equiv-toto
( λ z1 → Σ Z (λ z2 → (x : X) → Id z1 z2))
( equiv-ev-star' Z)
( λ z1 →
equiv-toto
( λ z2 → (x : X) → Id (z1 star) z2)
( equiv-ev-star' Z)
( λ z2 → equiv-id ((x : X) → Id (z1 star) (z2 star))))
map-comparison-suspension-cocone :
{l1 l2 : Level} (X : UU l1) (Z : UU l2) →
suspension-cocone' X Z → suspension-cocone X Z
map-comparison-suspension-cocone X Z =
map-equiv (comparison-suspension-cocone X Z)
is-equiv-map-comparison-suspension-cocone :
{l1 l2 : Level} (X : UU l1) (Z : UU l2) →
is-equiv (map-comparison-suspension-cocone X Z)
is-equiv-map-comparison-suspension-cocone X Z =
is-equiv-map-equiv (comparison-suspension-cocone X Z)
triangle-ev-suspension :
{l1 l2 l3 : Level} {X : UU l1} {Y : UU l2} →
(susp-str-Y : suspension-structure X Y) →
(Z : UU l3) →
( ( map-comparison-suspension-cocone X Z) ∘
( cocone-map
( const X unit star)
( const X unit star)
( cocone-suspension-structure X Y susp-str-Y))) ~
( ev-suspension susp-str-Y Z)
triangle-ev-suspension (pair N (pair S merid)) Z h = refl
is-equiv-ev-suspension :
{ l1 l2 l3 : Level} {X : UU l1} {Y : UU l2} →
( susp-str-Y : suspension-structure X Y) →
( up-Y : universal-property-suspension' l3 X Y susp-str-Y) →
( Z : UU l3) → is-equiv (ev-suspension susp-str-Y Z)
is-equiv-ev-suspension {X = X} susp-str-Y up-Y Z =
is-equiv-comp
( ev-suspension susp-str-Y Z)
( map-comparison-suspension-cocone X Z)
( cocone-map
( const X unit star)
( const X unit star)
( cocone-suspension-structure X _ susp-str-Y))
( htpy-inv (triangle-ev-suspension susp-str-Y Z))
( up-Y Z)
( is-equiv-map-comparison-suspension-cocone X Z)
{- Pointed maps and pointed homotopies. -}
pointed-fam :
{l1 : Level} (l : Level) (X : UU-pt l1) → UU (lsuc l ⊔ l1)
pointed-fam l (pair X x) = Σ (X → UU l) (λ P → P x)
pointed-Π :
{l1 l2 : Level} (X : UU-pt l1) (P : pointed-fam l2 X) → UU (l1 ⊔ l2)
pointed-Π (pair X x) (pair P p) = Σ ((x' : X) → P x') (λ f → Id (f x) p)
pointed-htpy :
{l1 l2 : Level} (X : UU-pt l1) (P : pointed-fam l2 X) →
(f g : pointed-Π X P) → UU (l1 ⊔ l2)
pointed-htpy (pair X x) (pair P p) (pair f α) g =
pointed-Π (pair X x) (pair (λ x' → Id (f x') (pr1 g x')) (α ∙ (inv (pr2 g))))
pointed-htpy-refl :
{l1 l2 : Level} (X : UU-pt l1) (P : pointed-fam l2 X) →
(f : pointed-Π X P) → pointed-htpy X P f f
pointed-htpy-refl (pair X x) (pair P p) (pair f α) =
pair htpy-refl (inv (right-inv α))
pointed-htpy-eq :
{l1 l2 : Level} (X : UU-pt l1) (P : pointed-fam l2 X) →
(f g : pointed-Π X P) → Id f g → pointed-htpy X P f g
pointed-htpy-eq X P f .f refl = pointed-htpy-refl X P f
is-contr-total-pointed-htpy :
{l1 l2 : Level} (X : UU-pt l1) (P : pointed-fam l2 X) (f : pointed-Π X P) →
is-contr (Σ (pointed-Π X P) (pointed-htpy X P f))
is-contr-total-pointed-htpy (pair X x) (pair P p) (pair f α) =
is-contr-total-Eq-structure
( λ g β (H : f ~ g) → Id (H x) (α ∙ (inv β)))
( is-contr-total-htpy f)
( pair f htpy-refl)
( is-contr-equiv'
( Σ (Id (f x) p) (λ β → Id β α))
( equiv-tot (λ β → equiv-con-inv refl β α))
( is-contr-total-path' α))
is-equiv-pointed-htpy-eq :
{l1 l2 : Level} (X : UU-pt l1) (P : pointed-fam l2 X) →
(f g : pointed-Π X P) → is-equiv (pointed-htpy-eq X P f g)
is-equiv-pointed-htpy-eq X P f =
fundamental-theorem-id f
( pointed-htpy-refl X P f)
( is-contr-total-pointed-htpy X P f)
( pointed-htpy-eq X P f)
eq-pointed-htpy :
{l1 l2 : Level} (X : UU-pt l1) (P : pointed-fam l2 X) →
(f g : pointed-Π X P) → (pointed-htpy X P f g) → Id f g
eq-pointed-htpy X P f g = inv-is-equiv (is-equiv-pointed-htpy-eq X P f g)
-- Section 14.3 Duality of pushouts and pullbacks
{- The universal property of the pushout of a span S can also be stated as a
pullback-property: a cocone c = (pair i (pair j H)) with vertex X
satisfies the universal property of the pushout of S if and only if the
square
Y^X -----> Y^B
| |
| |
V V
Y^A -----> Y^S
is a pullback square for every type Y. Below, we first define the cone of
this commuting square, and then we introduce the type
pullback-property-pushout, which states that the above square is a pullback.
-}
htpy-precomp :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2}
{f g : A → B} (H : f ~ g) (C : UU l3) →
(precomp f C) ~ (precomp g C)
htpy-precomp H C h = eq-htpy (h ·l H)
compute-htpy-precomp :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} (f : A → B) (C : UU l3) →
(htpy-precomp (htpy-refl' f) C) ~ htpy-refl
compute-htpy-precomp f C h = eq-htpy-htpy-refl (h ∘ f)
cone-pullback-property-pushout :
{l1 l2 l3 l4 l : Level} {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) (Y : UU l) →
cone (λ (h : A → Y) → h ∘ f) (λ (h : B → Y) → h ∘ g) (X → Y)
cone-pullback-property-pushout f g {X} c Y =
pair
( precomp (pr1 c) Y)
( pair
( precomp (pr1 (pr2 c)) Y)
( htpy-precomp (pr2 (pr2 c)) Y))
pullback-property-pushout :
{l1 l2 l3 l4 : Level} (l : Level) {S : UU l1} {A : UU l2} {B : UU l3}
(f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) →
UU (l1 ⊔ (l2 ⊔ (l3 ⊔ (l4 ⊔ lsuc l))))
pullback-property-pushout l {S} {A} {B} f g {X} c =
(Y : UU l) → is-pullback
( precomp f Y)
( precomp g Y)
( cone-pullback-property-pushout f g c Y)
{- In order to show that the universal property of pushouts is equivalent to
the pullback property, we show that the maps cocone-map and the gap map fit
in a commuting triangle, where the third map is an equivalence. The claim
then follows from the 3-for-2 property of equivalences. -}
triangle-pullback-property-pushout-universal-property-pushout :
{l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2}
{B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) →
{l : Level} (Y : UU l) →
( cocone-map f g c) ~
( ( tot (λ i' → tot (λ j' p → htpy-eq p))) ∘
( gap (λ h → h ∘ f) (λ h → h ∘ g) (cone-pullback-property-pushout f g c Y)))
triangle-pullback-property-pushout-universal-property-pushout
{S = S} {A = A} {B = B} f g (pair i (pair j H)) Y h =
eq-pair refl (eq-pair refl (inv (issec-eq-htpy (h ·l H))))
pullback-property-pushout-universal-property-pushout :
{l1 l2 l3 l4 : Level} (l : Level) {S : UU l1} {A : UU l2}
{B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) →
universal-property-pushout l f g c → pullback-property-pushout l f g c
pullback-property-pushout-universal-property-pushout
l f g (pair i (pair j H)) up-c Y =
let c = (pair i (pair j H)) in
is-equiv-right-factor
( cocone-map f g c)
( tot (λ i' → tot (λ j' p → htpy-eq p)))
( gap (λ h → h ∘ f) (λ h → h ∘ g) (cone-pullback-property-pushout f g c Y))
( triangle-pullback-property-pushout-universal-property-pushout f g c Y)
( is-equiv-tot-is-fiberwise-equiv
( λ i' → is-equiv-tot-is-fiberwise-equiv
( λ j' → funext (i' ∘ f) (j' ∘ g))))
( up-c Y)
universal-property-pushout-pullback-property-pushout :
{l1 l2 l3 l4 : Level} (l : Level) {S : UU l1} {A : UU l2}
{B : UU l3} (f : S → A) (g : S → B) {X : UU l4} (c : cocone f g X) →
pullback-property-pushout l f g c → universal-property-pushout l f g c
universal-property-pushout-pullback-property-pushout
l f g (pair i (pair j H)) pb-c Y =
let c = (pair i (pair j H)) in
is-equiv-comp
( cocone-map f g c)
( tot (λ i' → tot (λ j' p → htpy-eq p)))
( gap (λ h → h ∘ f) (λ h → h ∘ g) (cone-pullback-property-pushout f g c Y))
( triangle-pullback-property-pushout-universal-property-pushout f g c Y)
( pb-c Y)
( is-equiv-tot-is-fiberwise-equiv
( λ i' → is-equiv-tot-is-fiberwise-equiv
( λ j' → funext (i' ∘ f) (j' ∘ g))))
cocone-compose-horizontal :
{ l1 l2 l3 l4 l5 l6 : Level}
{ A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4} {Y : UU l5} {Z : UU l6}
( f : A → X) (i : A → B) (k : B → C) →
( c : cocone f i Y) (d : cocone (pr1 (pr2 c)) k Z) →
cocone f (k ∘ i) Z
cocone-compose-horizontal f i k (pair j (pair g H)) (pair l (pair h K)) =
pair
( l ∘ j)
( pair
( h)
( (l ·l H) ∙h (K ·r i)))
{-
is-pushout-rectangle-is-pushout-right-square :
( l : Level) { l1 l2 l3 l4 l5 l6 : Level}
{ A : UU l1} {B : UU l2} {C : UU l3} {X : UU l4} {Y : UU l5} {Z : UU l6}
( f : A → X) (i : A → B) (k : B → C) →
( c : cocone f i Y) (d : cocone (pr1 (pr2 c)) k Z) →
universal-property-pushout l f i c →
universal-property-pushout l (pr1 (pr2 c)) k d →
universal-property-pushout l f (k ∘ i) (cocone-compose-horizontal f i k c d)
is-pushout-rectangle-is-pushout-right-square l f i k c d up-Y up-Z =
universal-property-pushout-pullback-property-pushout l f (k ∘ i)
( cocone-compose-horizontal f i k c d)
( λ T → is-pullback-htpy {!!} {!!} {!!} {!!} {!!} {!!} {!!})
-}
-- Exercises
-- Exercise 13.1
-- Exercise 13.2
is-equiv-universal-property-pushout :
{l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3} {C : UU l4}
(f : S → A) (g : S → B) (c : cocone f g C) →
is-equiv f →
((l : Level) → universal-property-pushout l f g c) → is-equiv (pr1 (pr2 c))
is-equiv-universal-property-pushout
{A = A} {B} f g (pair i (pair j H)) is-equiv-f up-c =
is-equiv-is-equiv-precomp j
( λ l T →
is-equiv-is-pullback'
( λ (h : A → T) → h ∘ f)
( λ (h : B → T) → h ∘ g)
( cone-pullback-property-pushout f g (pair i (pair j H)) T)
( is-equiv-precomp-is-equiv f is-equiv-f T)
( pullback-property-pushout-universal-property-pushout
l f g (pair i (pair j H)) (up-c l) T))
universal-property-pushout-is-equiv :
{l1 l2 l3 l4 : Level} {S : UU l1} {A : UU l2} {B : UU l3} {C : UU l4}
(f : S → A) (g : S → B) (c : cocone f g C) →
is-equiv f → is-equiv (pr1 (pr2 c)) →
((l : Level) → universal-property-pushout l f g c)
universal-property-pushout-is-equiv f g (pair i (pair j H)) is-equiv-f is-equiv-j l =
let c = (pair i (pair j H)) in
universal-property-pushout-pullback-property-pushout l f g c
( λ T → is-pullback-is-equiv'
( λ h → h ∘ f)
( λ h → h ∘ g)
( cone-pullback-property-pushout f g c T)
( is-equiv-precomp-is-equiv f is-equiv-f T)
( is-equiv-precomp-is-equiv j is-equiv-j T))
| {
"alphanum_fraction": 0.571102488,
"avg_line_length": 37.9307359307,
"ext": "agda",
"hexsha": "553e1704f980e02d2c5200529c99216d790f3e3f",
"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": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "tadejpetric/HoTT-Intro",
"max_forks_repo_path": "Agda/16-pushouts.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "tadejpetric/HoTT-Intro",
"max_issues_repo_path": "Agda/16-pushouts.agda",
"max_line_length": 85,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f4228d6ecfc6cdb119c6e8b0e711fea05b98b2d5",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "tadejpetric/HoTT-Intro",
"max_stars_repo_path": "Agda/16-pushouts.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 7209,
"size": 17524
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of unique lists (setoid equality)
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Relation.Unary.Unique.Setoid.Properties where
open import Data.Fin.Base using (Fin)
open import Data.List.Base
open import Data.List.Relation.Binary.Disjoint.Setoid
open import Data.List.Relation.Binary.Disjoint.Setoid.Properties
open import Data.List.Relation.Unary.All as All using (All; []; _∷_)
open import Data.List.Relation.Unary.AllPairs as AllPairs using (AllPairs)
open import Data.List.Relation.Unary.Unique.Setoid
import Data.List.Relation.Unary.AllPairs.Properties as AllPairs
open import Data.Nat.Base
open import Function using (_∘_)
open import Relation.Binary using (Rel; Setoid)
open import Relation.Binary.PropositionalEquality using (_≡_)
open import Relation.Unary using (Pred; Decidable)
open import Relation.Nullary using (¬_)
open import Relation.Nullary.Negation using (contraposition)
------------------------------------------------------------------------
-- Introduction (⁺) and elimination (⁻) rules for list operations
------------------------------------------------------------------------
-- map
module _ {a b ℓ₁ ℓ₂} (S : Setoid a ℓ₁) (R : Setoid b ℓ₂) where
open Setoid S renaming (Carrier to A; _≈_ to _≈₁_)
open Setoid R renaming (Carrier to B; _≈_ to _≈₂_)
map⁺ : ∀ {f} → (∀ {x y} → f x ≈₂ f y → x ≈₁ y) →
∀ {xs} → Unique S xs → Unique R (map f xs)
map⁺ inj xs! = AllPairs.map⁺ (AllPairs.map (contraposition inj) xs!)
------------------------------------------------------------------------
-- ++
module _ {a ℓ} (S : Setoid a ℓ) where
++⁺ : ∀ {xs ys} → Unique S xs → Unique S ys → Disjoint S xs ys → Unique S (xs ++ ys)
++⁺ xs! ys! xs#ys = AllPairs.++⁺ xs! ys! (Disjoint⇒AllAll S xs#ys)
------------------------------------------------------------------------
-- concat
module _ {a ℓ} (S : Setoid a ℓ) where
concat⁺ : ∀ {xss} → All (Unique S) xss → AllPairs (Disjoint S) xss → Unique S (concat xss)
concat⁺ xss! xss# = AllPairs.concat⁺ xss! (AllPairs.map (Disjoint⇒AllAll S) xss#)
------------------------------------------------------------------------
-- take & drop
module _ {a ℓ} (S : Setoid a ℓ) where
drop⁺ : ∀ {xs} n → Unique S xs → Unique S (drop n xs)
drop⁺ = AllPairs.drop⁺
take⁺ : ∀ {xs} n → Unique S xs → Unique S (take n xs)
take⁺ = AllPairs.take⁺
------------------------------------------------------------------------
-- applyUpTo
module _ {a ℓ} (S : Setoid a ℓ) where
open Setoid S using (_≈_; _≉_) renaming (Carrier to A)
applyUpTo⁺₁ : ∀ f n → (∀ {i j} → i < j → j < n → f i ≉ f j) →
Unique S (applyUpTo f n)
applyUpTo⁺₁ = AllPairs.applyUpTo⁺₁
applyUpTo⁺₂ : ∀ f n → (∀ i j → f i ≉ f j) →
Unique S (applyUpTo f n)
applyUpTo⁺₂ = AllPairs.applyUpTo⁺₂
------------------------------------------------------------------------
-- applyDownFrom
module _ {a ℓ} (S : Setoid a ℓ) where
open Setoid S using (_≈_; _≉_) renaming (Carrier to A)
applyDownFrom⁺₁ : ∀ f n → (∀ {i j} → j < i → i < n → f i ≉ f j) →
Unique S (applyDownFrom f n)
applyDownFrom⁺₁ = AllPairs.applyDownFrom⁺₁
applyDownFrom⁺₂ : ∀ f n → (∀ i j → f i ≉ f j) →
Unique S (applyDownFrom f n)
applyDownFrom⁺₂ = AllPairs.applyDownFrom⁺₂
------------------------------------------------------------------------
-- tabulate
module _ {a ℓ} (S : Setoid a ℓ) where
open Setoid S renaming (Carrier to A)
tabulate⁺ : ∀ {n} {f : Fin n → A} → (∀ {i j} → f i ≈ f j → i ≡ j) →
Unique S (tabulate f)
tabulate⁺ f-inj = AllPairs.tabulate⁺ (_∘ f-inj)
------------------------------------------------------------------------
-- filter
module _ {a ℓ} (S : Setoid a ℓ) {p} {P : Pred _ p} (P? : Decidable P) where
open Setoid S renaming (Carrier to A)
filter⁺ : ∀ {xs} → Unique S xs → Unique S (filter P? xs)
filter⁺ = AllPairs.filter⁺ P?
| {
"alphanum_fraction": 0.5086775849,
"avg_line_length": 34.6694915254,
"ext": "agda",
"hexsha": "ee52f14e66c0f7d020d50968d74b806b5d3418d5",
"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/List/Relation/Unary/Unique/Setoid/Properties.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/List/Relation/Unary/Unique/Setoid/Properties.agda",
"max_line_length": 92,
"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/List/Relation/Unary/Unique/Setoid/Properties.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": 1188,
"size": 4091
} |
{-# OPTIONS --no-positivity-check #-}
module Section5 where
open import Section4b public
-- 5. Normal form
-- ==============
--
-- As we have seen above it is not necessary to know that `nf` actually gives a proof tree in
-- η-normal form for the results above. This is however the case. We can mutually inductively
-- define when a proof tree is in long η-normal form, `enf`, and in applicative normal form, `anf`. (…)
mutual
data enf : ∀ {Γ A} → Γ ⊢ A → Set where
ƛ : ∀ {Γ A B}
(x : Name) {{_ : T (fresh x Γ)}} → {M : [ Γ , x ∷ A ] ⊢ B} → enf M →
enf (ƛ x M)
α : ∀ {Γ} {M : Γ ⊢ •} →
anf M →
enf M
data anf : ∀ {Γ A} → Γ ⊢ A → Set where
ν : ∀ {Γ A} →
(x : Name) (i : Γ ∋ x ∷ A) →
anf (ν x i)
_∙_ : ∀ {Γ A B} {M : Γ ⊢ A ⊃ B} {N : Γ ⊢ A} →
anf M → enf N →
anf (M ∙ N)
-- We prove that `nf M` is in long η-normal form. For this we define a Kripke logical
-- predicate, `𝒩`, such that `𝒩 ⟦ M ⟧` and if `𝒩 a`, then `enf (reify a)`.
data 𝒩 : ∀ {Γ A} → Γ ⊩ A → Set where
𝓃• : ∀ {Γ} {f : Γ ⊩ •} →
(∀ {Δ} →
(c : Δ ⊇ Γ) →
anf (f ⟦g⟧⟨ c ⟩)) →
𝒩 f
𝓃⊃ : ∀ {Γ A B} {f : Γ ⊩ A ⊃ B} →
(∀ {Δ} {a : Δ ⊩ A} →
(c : Δ ⊇ Γ) → 𝒩 a →
𝒩 (f ⟦∙⟧⟨ c ⟩ a)) →
𝒩 f
-- For base type we intuitively define `𝒩 f` to hold if `anf f`.
--
-- If `f : Γ ⊩ A ⊃ B`, then `𝒩 f` is defined to hold if `𝒩 (f ∙ a)` holds for all `a : Γ ⊩ A`
-- such that `𝒩 a`.
--
-- We also define `𝒩⋆ ρ`, `ρ : Γ ⊩⋆ Δ`, to hold if every value, `a`, in `ρ` has the property `𝒩 a`.
data 𝒩⋆ : ∀ {Γ Δ} → Δ ⊩⋆ Γ → Set where
𝓃⋆[] : ∀ {Δ} →
𝒩⋆ ([] {w = Δ})
𝓃⋆≔ : ∀ {Γ Δ A x} {{_ : T (fresh x Γ)}} {ρ : Δ ⊩⋆ Γ} {a : Δ ⊩ A} →
𝒩⋆ ρ → 𝒩 a →
𝒩⋆ [ ρ , x ≔ a ]
-- We prove the following lemmas which are used to prove Lemma 10.
cong↑⟨_⟩𝒩 : ∀ {Γ Δ A} →
(c : Δ ⊇ Γ) → {a : Γ ⊩ A} → 𝒩 a →
𝒩 (↑⟨ c ⟩ a)
cong↑⟨ c ⟩𝒩 (𝓃• h) = 𝓃• (λ c′ → h (c ○ c′))
cong↑⟨ c ⟩𝒩 (𝓃⊃ h) = 𝓃⊃ (λ c′ nₐ → h (c ○ c′) nₐ)
conglookup𝒩 : ∀ {Γ Δ A x} {ρ : Δ ⊩⋆ Γ} →
𝒩⋆ ρ → (i : Γ ∋ x ∷ A) →
𝒩 (lookup ρ i)
conglookup𝒩 (𝓃⋆≔ n⋆ n) zero = n
conglookup𝒩 (𝓃⋆≔ n⋆ n) (suc i) = conglookup𝒩 n⋆ i
cong↑⟨_⟩𝒩⋆ : ∀ {Γ Δ Θ} {ρ : Δ ⊩⋆ Γ} →
(c : Θ ⊇ Δ) → 𝒩⋆ ρ →
𝒩⋆ (↑⟨ c ⟩ ρ)
cong↑⟨ c ⟩𝒩⋆ 𝓃⋆[] = 𝓃⋆[]
cong↑⟨ c ⟩𝒩⋆ (𝓃⋆≔ n⋆ n) = 𝓃⋆≔ (cong↑⟨ c ⟩𝒩⋆ n⋆) (cong↑⟨ c ⟩𝒩 n)
cong↓⟨_⟩𝒩⋆ : ∀ {Γ Δ Θ} {ρ : Δ ⊩⋆ Γ} →
(c : Γ ⊇ Θ) → 𝒩⋆ ρ →
𝒩⋆ (↓⟨ c ⟩ ρ)
cong↓⟨ done ⟩𝒩⋆ n⋆ = 𝓃⋆[]
cong↓⟨ step c i ⟩𝒩⋆ n⋆ = 𝓃⋆≔ (cong↓⟨ c ⟩𝒩⋆ n⋆) (conglookup𝒩 n⋆ i)
-- The lemma is proved together with a corresponding lemma for substitutions:
-- Lemma 10.
mutual
postulate
lem₁₀ : ∀ {Γ Δ A} →
(M : Γ ⊢ A) → {ρ : Δ ⊩⋆ Γ} → 𝒩⋆ ρ →
𝒩 (⟦ M ⟧ ρ)
postulate
lem₁₀ₛ : ∀ {Γ Δ Θ} →
(γ : Γ ⋙ Θ) → {ρ : Δ ⊩⋆ Γ} → 𝒩⋆ ρ →
𝒩⋆ (⟦ γ ⟧ₛ ρ)
-- The main lemma is that for all values, `a`, such that `𝒩 a`, `reify a` returns a proof tree in
-- η-normal form, which is intuitively proved together with a proof that for all proof trees in
-- applicative normal form we can find a value, `a`, such that `𝒩 a`. (…)
-- Lemma 11.
mutual
postulate
lem₁₁ : ∀ {Γ A} →
{a : Γ ⊩ A} → 𝒩 a →
enf (reify a)
postulate
lem₁₁ₛ : ∀ {Γ A} →
(f : ∀ {Δ} → Δ ⊇ Γ → Δ ⊢ A) → (h : ∀ {Δ} → (c : Δ ⊇ Γ) → anf (f c)) →
𝒩 (val f)
-- The proofs are by induction on the types.
--
-- It is straightforward to prove that `𝒩⋆ proj⟨ c ⟩⊩⋆` and then by Lemma 11 and Lemma 10 we get
-- that `nf M` is in long η-normal form. (…)
⟦ν⟧𝒩 : ∀ {x A Γ} → (i : Γ ∋ x ∷ A) → 𝒩 (⟦ν⟧ i)
⟦ν⟧𝒩 {x} i = lem₁₁ₛ (λ c → ν x (↑⟨ c ⟩ i))
(λ c → ν x (↑⟨ c ⟩ i))
proj⟨_⟩𝒩⋆ : ∀ {Γ Δ} → (c : Δ ⊇ Γ) → 𝒩⋆ proj⟨ c ⟩⊩⋆
proj⟨ done ⟩𝒩⋆ = 𝓃⋆[]
proj⟨ step c i ⟩𝒩⋆ = 𝓃⋆≔ proj⟨ c ⟩𝒩⋆ (⟦ν⟧𝒩 i)
refl𝒩⋆ : ∀ {Γ} → 𝒩⋆ (refl⊩⋆ {Γ})
refl𝒩⋆ = proj⟨ refl⊇ ⟩𝒩⋆
-- Theorem 7.
thm₇ : ∀ {Γ A} → (M : Γ ⊢ A) → enf (nf M)
thm₇ M = lem₁₁ (lem₁₀ M refl𝒩⋆)
-- Hence a proof tree is convertible with its normal form.
--
-- We can also use the results above to prove that if `ƛ(x : A).M ≅ ƛ(y : A).N`, then
-- `M(x = z) ≅ N(y = z)` where `z` is a fresh variable. Hence we have that `ƛ` is one-to-one up to
-- α-conversion.
-- TODO: What to do about the above paragraph?
| {
"alphanum_fraction": 0.4403485255,
"avg_line_length": 31.0833333333,
"ext": "agda",
"hexsha": "c27f6a459e1e8e4a361fa8e838a1ed2f0ede1338",
"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": "7c000654c4f97024d2939c412702f64dc821d4ec",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/coquand",
"max_forks_repo_path": "src/Section5.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/coquand",
"max_issues_repo_path": "src/Section5.agda",
"max_line_length": 104,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/coquand",
"max_stars_repo_path": "src/Section5.agda",
"max_stars_repo_stars_event_max_datetime": "2017-09-07T12:44:40.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-03-27T01:29:58.000Z",
"num_tokens": 2290,
"size": 4476
} |
{-# OPTIONS --no-positivity-check #-}
module Section4b where
open import Section4a public
-- 4.4. The inversion function
-- ---------------------------
--
-- It is possible to go from the semantics back to the proof trees by an inversion function, `reify`
-- that, given a semantic object in a particular Kripke model, returns a proof tree. The particular
-- Kripke model that we choose has contexts as possible worlds, the order on contexts as the
-- order on worlds, and `_⊢ •` as `𝒢`. (…)
instance
canon : Model
canon = record
{ 𝒲 = 𝒞
; _⊒_ = _⊇_
; refl⊒ = refl⊇
; _◇_ = _○_
; uniq⊒ = uniq⊇
; 𝒢 = _⊢ •
}
-- In order to define the inversion function we need to be able to choose a unique fresh
-- name given a context. We suppose a function `gensym : 𝒞 → Name` and a proof of
-- `T (fresh (gensym Γ) Γ)` which proves that `gensym` returns a fresh variable. Note that `gensym`
-- is a function taking a context as an argument and it hence always returns the same variable
-- for a given context.
-- TODO: Can we do better than this?
postulate
gensym : (Γ : 𝒞) → Σ Name (λ x → T (fresh x Γ))
-- The function `reify` is quite intricate. (…)
--
-- The function `reify` is mutually defined with `val`, which given a function from a context
-- extension to a proof tree returns a semantic object as result.
--
-- We define an abbreviation for the semantic object corresponding to a variable, `⟦ν⟧`.
--
-- The functions `reify` and `val` are both defined by induction on the type:
mutual
reify : ∀ {A Γ} → Γ ⊩ A → Γ ⊢ A
reify {•} {Γ} f = f ⟦g⟧⟨ refl⊇ ⟩
reify {A ⊃ B} {Γ} f = let x , φ = gensym Γ in
let instance _ = φ in
ƛ x (reify (f ⟦∙⟧⟨ weak⊇ ⟩ ⟦ν⟧ zero))
val : ∀ {A Γ} → (∀ {Δ} → Δ ⊇ Γ → Δ ⊢ A) → Γ ⊩ A
val {•} f = ⟦𝒢⟧ f
val {A ⊃ B} f = ⟦ƛ⟧ (λ c a → val (λ c′ → f (c ○ c′) ∙ reify (↑⟨ c′ ⟩ a)))
⟦ν⟧ : ∀ {x Γ A} → Γ ∋ x ∷ A → Γ ⊩ A
⟦ν⟧ {x} i = val (λ c → ν x (↑⟨ c ⟩ i))
-- We also have that if two semantic objects in a Kripke model are extensionally equal, then
-- the result of applying the inversion function to them is intensionally equal. To prove this
-- we first have to show the following two lemmas:
aux₄₄₁ : ∀ {A Γ} →
(f f′ : ∀ {Δ} → Δ ⊇ Γ → Δ ⊢ A) → (∀ {Δ} → (c : Δ ⊇ Γ) → f c ≡ f′ c) →
Eq (val f) (val f′)
aux₄₄₁ {•} f f′ h = eq• (λ c → h c)
aux₄₄₁ {A ⊃ B} f f′ h = eq⊃ (λ c {a} uₐ → aux₄₄₁ (λ c′ → f (c ○ c′) ∙ reify (↑⟨ c′ ⟩ a))
(λ c′ → f′ (c ○ c′) ∙ reify (↑⟨ c′ ⟩ a))
(λ c′ → cong (_∙ reify (↑⟨ c′ ⟩ a))
(h (c ○ c′))))
aux₄₄₂⟨_⟩ : ∀ {A Γ Δ} →
(c : Δ ⊇ Γ) (f : (∀ {Δ} → Δ ⊇ Γ → Δ ⊢ A)) →
Eq (↑⟨ c ⟩ (val f)) (val (λ c′ → f (c ○ c′)))
aux₄₄₂⟨_⟩ {•} c f = eq• (λ c′ → cong f refl)
aux₄₄₂⟨_⟩ {A ⊃ B} c f = eq⊃ (λ c′ {a} uₐ → aux₄₄₁ (λ c″ → f ((c ○ c′) ○ c″) ∙ reify (↑⟨ c″ ⟩ a))
(λ c″ → f (c ○ (c′ ○ c″)) ∙ reify (↑⟨ c″ ⟩ a))
(λ c″ → cong (_∙ reify (↑⟨ c″ ⟩ a))
(cong f
(sym (assoc○ c c′ c″)))))
-- Both lemmas are proved by induction on the type and they are used in order to prove the
-- following theorem,
-- which is shown mutually with a lemma
-- which states that `val` returns a uniform semantic object. Both the theorem and the lemma
-- are proved by induction on the type.
-- Theorem 1.
mutual
thm₁ : ∀ {Γ A} {a a′ : Γ ⊩ A} → Eq a a′ → reify a ≡ reify a′
thm₁ {Γ} (eq• h) = h refl⊇
thm₁ {Γ} (eq⊃ h) = let x , φ = gensym Γ in
let instance _ = φ in
cong (ƛ x)
(thm₁ (h weak⊇ (⟦ν⟧𝒰 zero)))
⟦ν⟧𝒰 : ∀ {x Γ A} → (i : Γ ∋ x ∷ A) → 𝒰 (⟦ν⟧ i)
⟦ν⟧𝒰 {x} i = aux₄₄₃ (λ c → ν x (↑⟨ c ⟩ i))
aux₄₄₃ : ∀ {A Γ} → (f : ∀ {Δ} → Δ ⊇ Γ → Δ ⊢ A) → 𝒰 (val f)
aux₄₄₃ {•} f = 𝓊•
aux₄₄₃ {A ⊃ B} f =
𝓊⊃ (λ c {a} uₐ → aux₄₄₃ (λ c′ → f (c ○ c′) ∙ reify (↑⟨ c′ ⟩ a)))
(λ c {a} {a′} eqₐ uₐ uₐ′ → aux₄₄₁ (λ c′ → f (c ○ c′) ∙ reify (↑⟨ c′ ⟩ a))
(λ c′ → f (c ○ c′) ∙ reify (↑⟨ c′ ⟩ a′))
(λ c′ → cong (f (c ○ c′) ∙_)
(thm₁ (cong↑⟨ c′ ⟩Eq eqₐ))))
(λ c c′ c″ {a} uₐ →
transEq (aux₄₄₂⟨ c′ ⟩ (λ c‴ → f (c ○ c‴) ∙ reify (↑⟨ c‴ ⟩ a)))
(aux₄₄₁ (λ c‴ → f (c ○ (c′ ○ c‴)) ∙ reify (↑⟨ c′ ○ c‴ ⟩ a))
(λ c‴ → f (c″ ○ c‴) ∙ reify (↑⟨ c‴ ⟩ (↑⟨ c′ ⟩ a)))
(λ c‴ → cong² _∙_
(cong f
(trans (assoc○ c c′ c‴)
(comp○ (c ○ c′) c‴ (c″ ○ c‴))))
(thm₁ (symEq (aux₄₁₂ c′ c‴ (c′ ○ c‴) uₐ))))))
-- We are now ready to define the function that given a proof tree computes its normal form.
-- For this we define the identity environment `proj⟨_⟩⊩⋆` which to each variable
-- in the context `Γ` associates the corresponding value of the variable in `Δ` (`⟦ν⟧` gives the
-- value of this variable). The normalisation function, `nf`, is defined as the composition of the
-- evaluation function and `reify`. This function is similar to the normalisation algorithm given
-- by Berger [3]; one difference is our use of Kripke models to deal with reduction under `λ`.
-- One other difference is that, since we use explicit contexts, we can use the context to find
-- the fresh names in the `reify` function.
proj⟨_⟩⊩⋆ : ∀ {Γ Δ} → Δ ⊇ Γ → Δ ⊩⋆ Γ
proj⟨ done ⟩⊩⋆ = []
proj⟨ step {x = x} c i ⟩⊩⋆ = [ proj⟨ c ⟩⊩⋆ , x ≔ ⟦ν⟧ i ]
refl⊩⋆ : ∀ {Γ} → Γ ⊩⋆ Γ
refl⊩⋆ = proj⟨ refl⊇ ⟩⊩⋆
-- The computation of the normal form is done by computing the semantics of the proof
-- tree in the identity environment and then inverting the result:
nf : ∀ {Γ A} → Γ ⊢ A → Γ ⊢ A
nf M = reify (⟦ M ⟧ refl⊩⋆)
-- We know by Theorem 1 that `nf` returns the same result when applied to two proof trees
-- having the same semantics:
-- Corollary 1.
cor₁ : ∀ {Γ A} → (M M′ : Γ ⊢ A) → Eq (⟦ M ⟧ refl⊩⋆) (⟦ M′ ⟧ refl⊩⋆) →
nf M ≡ nf M′
cor₁ M M′ = thm₁
-- 4.5. Soundness and completeness of proof trees
-- ----------------------------------------------
--
-- We have in fact already shown soundness and completeness of the calculus of proof trees.
--
-- The evaluation function, `⟦_⟧`, for proof trees corresponds via the Curry-Howard isomorphism
-- to a proof of the soundness theorem of minimal logic with respect to Kripke models.
-- The function is defined by pattern matching which corresponds to a proof by case analysis
-- of the proof trees.
--
-- The inversion function `reify` is, again via the Curry-Howard isomorphism, a proof of the
-- completeness theorem of minimal logic with respect to a particular Kripke model where
-- the worlds are contexts.
-- 4.6. Completeness of the conversion rules for proof trees
-- ---------------------------------------------------------
--
-- In order to prove that the set of conversion rules is complete, i.e.,
-- `Eq (⟦ M ⟧ refl⊩⋆) (⟦ M′ ⟧ refl⊩⋆)` implies `M ≅ M′`, we must first prove Theorem 2: `M ≅ nf M`.
--
-- To prove the theorem we define a Kripke logical relation [15, 18]
-- which corresponds to Tait’s computability predicate.
--
-- A proof tree of base type is intuitively `CV`-related to a semantic object of base type if
-- they are convertible with each other. (…)
--
-- A proof tree of function type, `A ⊃ B`, is intuitively `CV`-related to a semantic object of the
-- same type if they send `CV`-related proof trees and objects of type `A` to `CV`-related proof
-- trees and objects of type `B`. (…)
data CV : ∀ {Γ A} → Γ ⊢ A → Γ ⊩ A → Set where
cv• : ∀ {Γ} {M : Γ ⊢ •} {f : Γ ⊩ •} →
(∀ {Δ} → (c : Δ ⊇ Γ) → M ▶ π⟨ c ⟩ ≅ f ⟦g⟧⟨ c ⟩) →
CV M f
cv⊃ : ∀ {Γ A B} {M : Γ ⊢ A ⊃ B} {f : Γ ⊩ A ⊃ B} →
(∀ {Δ N a} → (c : Δ ⊇ Γ) → CV N a → CV ((M ▶ π⟨ c ⟩) ∙ N) (f ⟦∙⟧⟨ c ⟩ a)) →
CV M f
-- The idea of this predicate is that we can show that if `CV M a` then `M ≅ reify a`, hence
-- if we show that `CV M (⟦ M ⟧ refl⊩⋆)`, we have a proof of Theorem 2.
--
-- Correspondingly for the environment we define: (…)
data CV⋆ : ∀ {Γ Δ} → Δ ⋙ Γ → Δ ⊩⋆ Γ → Set where
cv⋆[] : ∀ {Γ} →
{γ : Γ ⋙ []} →
CV⋆ γ []
cv⋆≔ : ∀ {Γ Δ A x} {{_ : T (fresh x Γ)}}
{γ : Δ ⋙ [ Γ , x ∷ A ]} {c : [ Γ , x ∷ A ] ⊇ Γ} {ρ : Δ ⊩⋆ Γ} {a : Δ ⊩ A} →
CV⋆ (π⟨ c ⟩ ● γ) ρ → CV (ν x zero ▶ γ) a →
CV⋆ γ [ ρ , x ≔ a ]
-- In order to prove Lemma 8 below we need to prove the following properties about `CV`:
cong≅CV : ∀ {Γ A} {M M′ : Γ ⊢ A} {a : Γ ⊩ A} →
M ≅ M′ → CV M′ a →
CV M a
cong≅CV p (cv• h) = cv• (λ c → trans≅ (cong▶≅ p refl≅ₛ)
(h c))
cong≅CV p (cv⊃ h) = cv⊃ (λ c cvₐ → cong≅CV (cong∙≅ (cong▶≅ p refl≅ₛ) refl≅)
(h c cvₐ))
cong≅ₛCV⋆ : ∀ {Γ Δ} {γ γ′ : Δ ⋙ Γ} {ρ : Δ ⊩⋆ Γ} →
γ ≅ₛ γ′ → CV⋆ γ′ ρ →
CV⋆ γ ρ
cong≅ₛCV⋆ p cv⋆[] = cv⋆[]
cong≅ₛCV⋆ p (cv⋆≔ cv⋆ cv) = cv⋆≔ (cong≅ₛCV⋆ (cong●≅ₛ refl≅ₛ p) cv⋆)
(cong≅CV (cong▶≅ refl≅ p) cv)
cong↑⟨_⟩CV : ∀ {Γ Δ A} {M : Γ ⊢ A} {a : Γ ⊩ A} →
(c : Δ ⊇ Γ) → CV M a →
CV (M ▶ π⟨ c ⟩) (↑⟨ c ⟩ a)
cong↑⟨ c ⟩CV (cv• h) = cv• (λ c′ → trans≅ (trans≅ (conv₇≅ _ _ _)
(cong▶≅ refl≅ (conv₄≅ₛ _ _ _)))
(h (c ○ c′)))
cong↑⟨ c ⟩CV (cv⊃ h) = cv⊃ (λ c′ cvₐ → cong≅CV (cong∙≅ (trans≅ (conv₇≅ _ _ _)
(cong▶≅ refl≅ (conv₄≅ₛ _ _ _)))
refl≅)
(h (c ○ c′) cvₐ))
conglookupCV : ∀ {Γ Δ A x} {γ : Δ ⋙ Γ} {ρ : Δ ⊩⋆ Γ} →
CV⋆ γ ρ → (i : Γ ∋ x ∷ A) →
CV (ν x i ▶ γ) (lookup ρ i)
conglookupCV cv⋆[] ()
conglookupCV (cv⋆≔ cv⋆ cv) zero = cv
conglookupCV (cv⋆≔ cv⋆ cv) (suc i) = cong≅CV (trans≅ (cong▶≅ (sym≅ (conv₄≅ _ _ _)) refl≅ₛ)
(conv₇≅ _ _ _))
(conglookupCV cv⋆ i)
cong↑⟨_⟩CV⋆ : ∀ {Γ Δ Θ} {γ : Δ ⋙ Γ} {ρ : Δ ⊩⋆ Γ} →
(c : Θ ⊇ Δ) → CV⋆ γ ρ →
CV⋆ (γ ● π⟨ c ⟩) (↑⟨ c ⟩ ρ)
cong↑⟨ c ⟩CV⋆ cv⋆[] = cv⋆[]
cong↑⟨ c ⟩CV⋆ (cv⋆≔ cv⋆ cv) = cv⋆≔ (cong≅ₛCV⋆ (sym≅ₛ (conv₁≅ₛ _ _ _)) (cong↑⟨ c ⟩CV⋆ cv⋆))
(cong≅CV (sym≅ (conv₇≅ _ _ _)) (cong↑⟨ c ⟩CV cv))
cong↓⟨_⟩CV⋆ : ∀ {Γ Δ Θ} {γ : Δ ⋙ Γ} {ρ : Δ ⊩⋆ Γ} →
(c : Γ ⊇ Θ) → CV⋆ γ ρ →
CV⋆ (π⟨ c ⟩ ● γ) (↓⟨ c ⟩ ρ)
cong↓⟨ done ⟩CV⋆ cv⋆ = cv⋆[]
cong↓⟨ step c i ⟩CV⋆ cv⋆ = cv⋆≔ {c = weak⊇}
(cong≅ₛCV⋆ (trans≅ₛ (sym≅ₛ (conv₁≅ₛ _ _ _))
(cong●≅ₛ (conv₄≅ₛ _ _ _) refl≅ₛ))
(cong↓⟨ c ⟩CV⋆ cv⋆))
(cong≅CV (trans≅ (sym≅ (conv₇≅ _ _ _))
(cong▶≅ (conv₄≅ _ _ _) refl≅ₛ))
(conglookupCV cv⋆ i))
-- Now we are ready to prove that if `γ` and `ρ` are `CV`-related, then `M ▶ γ` and `⟦ M ⟧ ρ` are
-- `CV`-related. This lemma corresponds to Tait’s lemma saying that each term is computable
-- under substitution. We prove the lemma
-- mutually with a corresponding lemma for substitutions.
-- Lemma 8.
mutual
CV⟦_⟧ : ∀ {Γ Δ A} {γ : Δ ⋙ Γ} {ρ : Δ ⊩⋆ Γ} →
(M : Γ ⊢ A) → CV⋆ γ ρ →
CV (M ▶ γ) (⟦ M ⟧ ρ)
CV⟦ ν x i ⟧ cv⋆ = conglookupCV cv⋆ i
CV⟦ ƛ x M ⟧ cv⋆ = cv⊃ (λ c cvₐ → cong≅CV (trans≅ (cong∙≅ (conv₇≅ _ _ _) refl≅)
(conv₁≅ _ _ _))
(CV⟦ M ⟧ (cv⋆≔ {c = weak⊇}
(cong≅ₛCV⋆ (conv₃≅ₛ _ _ _)
(cong↑⟨ c ⟩CV⋆ cv⋆))
(cong≅CV (conv₃≅ _ _) cvₐ))))
CV⟦ M ∙ N ⟧ cv⋆ with CV⟦ M ⟧ cv⋆
CV⟦ M ∙ N ⟧ cv⋆ | (cv⊃ h) = cong≅CV (trans≅ (conv₆≅ _ _ _)
(cong∙≅ (sym≅ (conv₅≅ _ _)) refl≅))
(h refl⊇ (CV⟦ N ⟧ cv⋆))
CV⟦ M ▶ γ ⟧ cv⋆ = cong≅CV (conv₇≅ _ _ _)
(CV⟦ M ⟧ (CV⋆⟦ γ ⟧ₛ cv⋆))
CV⋆⟦_⟧ₛ : ∀ {Γ Δ Θ} {δ : Θ ⋙ Δ} {ρ : Θ ⊩⋆ Δ} →
(γ : Δ ⋙ Γ) → CV⋆ δ ρ →
CV⋆ (γ ● δ) (⟦ γ ⟧ₛ ρ)
CV⋆⟦ π⟨ c ⟩ ⟧ₛ cv⋆ = cong↓⟨ c ⟩CV⋆ cv⋆
CV⋆⟦ γ ● γ′ ⟧ₛ cv⋆ = cong≅ₛCV⋆ (conv₁≅ₛ _ _ _)
(CV⋆⟦ γ ⟧ₛ (CV⋆⟦ γ′ ⟧ₛ cv⋆))
CV⋆⟦ [ γ , x ≔ M ] ⟧ₛ cv⋆ = cv⋆≔ {c = weak⊇}
(cong≅ₛCV⋆ (trans≅ₛ (sym≅ₛ (conv₁≅ₛ _ _ _))
(cong●≅ₛ (conv₃≅ₛ _ _ _) refl≅ₛ))
(CV⋆⟦ γ ⟧ₛ cv⋆))
(cong≅CV (trans≅ (sym≅ (conv₇≅ _ _ _))
(cong▶≅ (conv₃≅ _ _) refl≅ₛ))
(CV⟦ M ⟧ cv⋆))
-- Both lemmas are proved by induction on the proof trees using the lemmas above.
--
-- Lemma 9 is shown mutually with a corresponding lemma for `val`:
-- Lemma 9.
mutual
lem₉ : ∀ {Γ A} {M : Γ ⊢ A} {a : Γ ⊩ A} →
CV M a →
M ≅ reify a
lem₉ (cv• h) = trans≅ (sym≅ (conv₅≅ _ _))
(h refl⊇)
lem₉ (cv⊃ h) = trans≅ (conv₂≅ _ _)
(congƛ≅ (lem₉ (h weak⊇ (aux₄₆₈ (λ c → conv₄≅ _ _ _)))))
aux₄₆₈ : ∀ {A Γ} {M : Γ ⊢ A} {f : ∀ {Δ} → Δ ⊇ Γ → Δ ⊢ A} →
(∀ {Δ} → (c : Δ ⊇ Γ) → M ▶ π⟨ c ⟩ ≅ f c) →
CV M (val f)
aux₄₆₈ {•} h = cv• (λ c → h c)
aux₄₆₈ {A ⊃ B} {M = M} {f} h = cv⊃ (λ {_} {N} {a} c cvₐ →
aux₄₆₈ (λ {Δ′} c′ →
begin
((M ▶ π⟨ c ⟩) ∙ N) ▶ π⟨ c′ ⟩
≅⟨ conv₆≅ _ _ _ ⟩
((M ▶ π⟨ c ⟩) ▶ π⟨ c′ ⟩) ∙ (N ▶ π⟨ c′ ⟩)
≅⟨ cong∙≅ (conv₇≅ _ _ _) refl≅ ⟩
(M ▶ (π⟨ c ⟩ ● π⟨ c′ ⟩)) ∙ (N ▶ π⟨ c′ ⟩)
≅⟨ cong∙≅ (cong▶≅ refl≅ (conv₄≅ₛ _ _ _)) refl≅ ⟩
(M ▶ π⟨ c ○ c′ ⟩) ∙ (N ▶ π⟨ c′ ⟩)
≅⟨ cong∙≅ (h (c ○ c′)) refl≅ ⟩
f (c ○ c′) ∙ (N ▶ π⟨ c′ ⟩)
≅⟨ cong∙≅ refl≅ (lem₉ (cong↑⟨ c′ ⟩CV cvₐ)) ⟩
f (c ○ c′) ∙ reify (↑⟨ c′ ⟩ a)
∎))
where
open ≅-Reasoning
-- In order to prove Theorem 2 we also prove that `CV⋆ π⟨ c ⟩ proj⟨ c ⟩⊩⋆`; then by this, Lemma 8
-- and Lemma 9 we get that `M ▶ π⟨ c ⟩ ≅ nf M`, where `c : Γ ⊇ Γ`. Using the conversion rule
-- `M ≅ M ▶ π⟨ c ⟩` for `c : Γ ⊇ Γ` we get by transitivity of conversion of `_≅_` that `M ≅ nf M`.
proj⟨_⟩CV⋆ : ∀ {Γ Δ} →
(c : Δ ⊇ Γ) →
CV⋆ π⟨ c ⟩ proj⟨ c ⟩⊩⋆
proj⟨ done ⟩CV⋆ = cv⋆[]
proj⟨ step {x = x} c i ⟩CV⋆ = cv⋆≔ {c = weak⊇}
(cong≅ₛCV⋆ (conv₄≅ₛ _ _ _) (proj⟨ c ⟩CV⋆))
(aux₄₆₈ (λ c′ →
begin
(ν x zero ▶ π⟨ step c i ⟩) ▶ π⟨ c′ ⟩
≅⟨ cong▶≅ (conv₄≅ _ _ _) refl≅ₛ ⟩
ν x i ▶ π⟨ c′ ⟩
≅⟨ conv₄≅ _ _ _ ⟩
ν x (↑⟨ c′ ⟩ i)
∎))
where
open ≅-Reasoning
reflCV⋆ : ∀ {Γ} → CV⋆ π⟨ refl⊇ ⟩ (refl⊩⋆ {Γ})
reflCV⋆ = proj⟨ refl⊇ ⟩CV⋆
aux₄₆₉⟨_⟩ : ∀ {Γ A} →
(c : Γ ⊇ Γ) (M : Γ ⊢ A) →
M ▶ π⟨ c ⟩ ≅ nf M
aux₄₆₉⟨ c ⟩ M rewrite uniq⊇ refl⊇ c
= lem₉ (CV⟦ M ⟧ proj⟨ c ⟩CV⋆)
-- Theorem 2.
thm₂ : ∀ {Γ A} → (M : Γ ⊢ A) →
M ≅ nf M
thm₂ M = trans≅ (sym≅ (conv₅≅ _ _))
(aux₄₆₉⟨ refl⊇ ⟩ M)
-- It is now easy to prove the completeness theorem:
-- Theorem 3.
thm₃ : ∀ {Γ A} → (M M′ : Γ ⊢ A) → Eq (⟦ M ⟧ refl⊩⋆) (⟦ M′ ⟧ refl⊩⋆) →
M ≅ M′
thm₃ M M′ eq = begin
M
≅⟨ thm₂ M ⟩
nf M
≡⟨ cor₁ M M′ eq ⟩
nf M′
≅⟨ sym≅ (thm₂ M′) ⟩
M′
∎
where
open ≅-Reasoning
-- 4.7. Completeness of the conversion rules for substitutions
-- -----------------------------------------------------------
--
-- The proof of completeness above does not imply that the set of conversion rules for substitutions
-- is complete. In order to prove the completeness of conversion rules for the substitutions
-- we define an inversion function for semantic environments: (…)
reify⋆ : ∀ {Γ Δ} → Δ ⊩⋆ Γ → Δ ⋙ Γ
reify⋆ [] = π⟨ done ⟩
reify⋆ [ ρ , x ≔ a ] = [ reify⋆ ρ , x ≔ reify a ]
-- The normalisation function on substitutions is defined as the inversion of the semantics
-- of the substitution in the identity environment.
nf⋆ : ∀ {Δ Γ} → Δ ⋙ Γ → Δ ⋙ Γ
nf⋆ γ = reify⋆ (⟦ γ ⟧ₛ refl⊩⋆)
-- The completeness result for substitutions follows in the same way as for proof trees, i.e.,
-- we must prove that `γ ≅ₛ nf⋆ γ`.
thm₁ₛ : ∀ {Γ Δ} {ρ ρ′ : Δ ⊩⋆ Γ} → Eq⋆ ρ ρ′ → reify⋆ ρ ≡ reify⋆ ρ′
thm₁ₛ eq⋆[] = refl
thm₁ₛ (eq⋆≔ eq⋆ eq) = cong² (λ γ M → [ γ , _ ≔ M ]) (thm₁ₛ eq⋆) (thm₁ eq)
cor₁ₛ : ∀ {Γ Δ} → (γ γ′ : Δ ⋙ Γ) → Eq⋆ (⟦ γ ⟧ₛ refl⊩⋆) (⟦ γ′ ⟧ₛ refl⊩⋆) →
nf⋆ γ ≡ nf⋆ γ′
cor₁ₛ γ γ′ = thm₁ₛ
lem₉ₛ : ∀ {Γ Δ} {γ : Δ ⋙ Γ} {ρ : Δ ⊩⋆ Γ} →
CV⋆ γ ρ →
γ ≅ₛ reify⋆ ρ
lem₉ₛ cv⋆[] = conv₆≅ₛ _ _
lem₉ₛ (cv⋆≔ cv⋆ cv) = trans≅ₛ (conv₇≅ₛ _ _ _)
(cong≔≅ₛ (lem₉ₛ cv⋆) (lem₉ cv))
aux₄₆₉ₛ⟨_⟩ : ∀ {Γ Δ} →
(c : Δ ⊇ Δ) (γ : Δ ⋙ Γ) →
γ ● π⟨ c ⟩ ≅ₛ nf⋆ γ
aux₄₆₉ₛ⟨ c ⟩ γ rewrite uniq⊇ refl⊇ c
= lem₉ₛ (CV⋆⟦ γ ⟧ₛ proj⟨ c ⟩CV⋆)
thm₂ₛ : ∀ {Γ Δ} → (γ : Δ ⋙ Γ) →
γ ≅ₛ nf⋆ γ
thm₂ₛ γ = trans≅ₛ (sym≅ₛ (conv₅≅ₛ _ _))
(aux₄₆₉ₛ⟨ refl⊇ ⟩ γ)
thm₃ₛ : ∀ {Γ Δ} → (γ γ′ : Δ ⋙ Γ) → Eq⋆ (⟦ γ ⟧ₛ refl⊩⋆) (⟦ γ′ ⟧ₛ refl⊩⋆) →
γ ≅ₛ γ′
thm₃ₛ γ γ′ eq⋆ = begin
γ
≅ₛ⟨ thm₂ₛ γ ⟩
nf⋆ γ
≡⟨ cor₁ₛ γ γ′ eq⋆ ⟩
nf⋆ γ′
≅ₛ⟨ sym≅ₛ (thm₂ₛ γ′) ⟩
γ′
∎
where
open ≅ₛ-Reasoning
-- 4.8. Soundness of the conversion rules
-- --------------------------------------
--
-- In order to prove the soundness of the conversion rules we first have to show:
-- NOTE: Added missing uniformity assumptions.
mutual
𝒰⟦_⟧ : ∀ {A Γ Δ} {ρ : Δ ⊩⋆ Γ} →
(M : Γ ⊢ A) → 𝒰⋆ ρ →
𝒰 (⟦ M ⟧ ρ)
𝒰⟦ ν x i ⟧ u⋆ = conglookup𝒰 u⋆ i
𝒰⟦ ƛ x M ⟧ u⋆ = 𝓊⊃ (λ c uₐ → 𝒰⟦ M ⟧ (𝓊⋆≔ (cong↑⟨ c ⟩𝒰⋆ u⋆) uₐ))
(λ c eqₐ uₐ uₐ′ → Eq⟦ M ⟧ (eq⋆≔ (cong↑⟨ c ⟩Eq⋆ (reflEq⋆ u⋆)) eqₐ)
(𝓊⋆≔ (cong↑⟨ c ⟩𝒰⋆ u⋆) uₐ)
(𝓊⋆≔ (cong↑⟨ c ⟩𝒰⋆ u⋆) uₐ′))
(λ c c′ c″ uₐ → transEq (↑⟨ c′ ⟩Eq⟦ M ⟧ (𝓊⋆≔ (cong↑⟨ c ⟩𝒰⋆ u⋆) uₐ))
(Eq⟦ M ⟧ (eq⋆≔ (aux₄₂₇ c c′ c″ u⋆)
(reflEq (cong↑⟨ c′ ⟩𝒰 uₐ)))
(𝓊⋆≔ (cong↑⟨ c′ ⟩𝒰⋆ (cong↑⟨ c ⟩𝒰⋆ u⋆))
(cong↑⟨ c′ ⟩𝒰 uₐ))
(𝓊⋆≔ (cong↑⟨ c″ ⟩𝒰⋆ u⋆)
(cong↑⟨ c′ ⟩𝒰 uₐ))))
𝒰⟦ M ∙ N ⟧ u⋆ with 𝒰⟦ M ⟧ u⋆
𝒰⟦ M ∙ N ⟧ u⋆ | (𝓊⊃ h₀ h₁ h₂) = h₀ refl⊇ (𝒰⟦ N ⟧ u⋆)
𝒰⟦ M ▶ γ ⟧ u⋆ = 𝒰⟦ M ⟧ (𝒰⋆⟦ γ ⟧ₛ u⋆)
𝒰⋆⟦_⟧ₛ : ∀ {Γ Δ Θ} {ρ : Θ ⊩⋆ Δ} →
(γ : Δ ⋙ Γ) → 𝒰⋆ ρ →
𝒰⋆ (⟦ γ ⟧ₛ ρ)
𝒰⋆⟦ π⟨ c ⟩ ⟧ₛ u⋆ = cong↓⟨ c ⟩𝒰⋆ u⋆
𝒰⋆⟦ γ ● γ′ ⟧ₛ u⋆ = 𝒰⋆⟦ γ ⟧ₛ (𝒰⋆⟦ γ′ ⟧ₛ u⋆)
𝒰⋆⟦ [ γ , x ≔ M ] ⟧ₛ u⋆ = 𝓊⋆≔ (𝒰⋆⟦ γ ⟧ₛ u⋆) (𝒰⟦ M ⟧ u⋆)
Eq⟦_⟧ : ∀ {Γ Δ A} {ρ ρ′ : Δ ⊩⋆ Γ} →
(M : Γ ⊢ A) → Eq⋆ ρ ρ′ → 𝒰⋆ ρ → 𝒰⋆ ρ′ →
Eq (⟦ M ⟧ ρ) (⟦ M ⟧ ρ′)
Eq⟦ ν x i ⟧ eq⋆ u⋆ u⋆′ = conglookupEq eq⋆ i
Eq⟦ ƛ x M ⟧ eq⋆ u⋆ u⋆′ = eq⊃ (λ c uₐ → Eq⟦ M ⟧ (eq⋆≔ (cong↑⟨ c ⟩Eq⋆ eq⋆) (reflEq uₐ))
(𝓊⋆≔ (cong↑⟨ c ⟩𝒰⋆ u⋆) uₐ)
(𝓊⋆≔ (cong↑⟨ c ⟩𝒰⋆ u⋆′) uₐ))
Eq⟦ M ∙ N ⟧ eq⋆ u⋆ u⋆′ = cong⟦∙⟧⟨ refl⊇ ⟩Eq (Eq⟦ M ⟧ eq⋆ u⋆ u⋆′) (𝒰⟦ M ⟧ u⋆) (𝒰⟦ M ⟧ u⋆′)
(Eq⟦ N ⟧ eq⋆ u⋆ u⋆′) (𝒰⟦ N ⟧ u⋆) (𝒰⟦ N ⟧ u⋆′)
Eq⟦ M ▶ γ ⟧ eq⋆ u⋆ u⋆′ = Eq⟦ M ⟧ (Eq⋆⟦ γ ⟧ₛ eq⋆ u⋆ u⋆′) (𝒰⋆⟦ γ ⟧ₛ u⋆) (𝒰⋆⟦ γ ⟧ₛ u⋆′)
Eq⋆⟦_⟧ₛ : ∀ {Γ Δ Θ} {ρ ρ′ : Θ ⊩⋆ Δ} →
(γ : Δ ⋙ Γ) → Eq⋆ ρ ρ′ → 𝒰⋆ ρ → 𝒰⋆ ρ′ →
Eq⋆ (⟦ γ ⟧ₛ ρ) (⟦ γ ⟧ₛ ρ′)
Eq⋆⟦ π⟨ c ⟩ ⟧ₛ eq⋆ u⋆ u⋆′ = cong↓⟨ c ⟩Eq⋆ eq⋆
Eq⋆⟦ γ ● γ′ ⟧ₛ eq⋆ u⋆ u⋆′ = Eq⋆⟦ γ ⟧ₛ (Eq⋆⟦ γ′ ⟧ₛ eq⋆ u⋆ u⋆′) (𝒰⋆⟦ γ′ ⟧ₛ u⋆) (𝒰⋆⟦ γ′ ⟧ₛ u⋆′)
Eq⋆⟦ [ γ , x ≔ M ] ⟧ₛ eq⋆ u⋆ u⋆′ = eq⋆≔ (Eq⋆⟦ γ ⟧ₛ eq⋆ u⋆ u⋆′)
(Eq⟦ M ⟧ eq⋆ u⋆ u⋆′)
↑⟨_⟩Eq⟦_⟧ : ∀ {Γ Δ Θ A} {ρ : Δ ⊩⋆ Γ} →
(c : Θ ⊇ Δ) (M : Γ ⊢ A) → 𝒰⋆ ρ →
Eq (↑⟨ c ⟩ (⟦ M ⟧ ρ)) (⟦ M ⟧ (↑⟨ c ⟩ ρ))
↑⟨ c ⟩Eq⟦ ν x i ⟧ u⋆ = conglookup↑⟨ c ⟩Eq u⋆ i
↑⟨ c ⟩Eq⟦ ƛ x M ⟧ u⋆ = eq⊃ (λ c′ uₐ → Eq⟦ M ⟧ (eq⋆≔ (symEq⋆ (aux₄₂₇ c c′ (c ○ c′) u⋆)) (reflEq uₐ))
(𝓊⋆≔ (cong↑⟨ c ○ c′ ⟩𝒰⋆ u⋆) uₐ)
(𝓊⋆≔ (cong↑⟨ c′ ⟩𝒰⋆ (cong↑⟨ c ⟩𝒰⋆ u⋆)) uₐ))
↑⟨ c ⟩Eq⟦ M ∙ N ⟧ u⋆ with 𝒰⟦ M ⟧ u⋆
↑⟨ c ⟩Eq⟦ M ∙ N ⟧ u⋆ | (𝓊⊃ h₀ h₁ h₂) = transEq (h₂ refl⊇ c c (𝒰⟦ N ⟧ u⋆))
(transEq (aux₄₁₃ c refl⊇ (𝒰⟦ M ⟧ u⋆) (cong↑⟨ c ⟩𝒰 (𝒰⟦ N ⟧ u⋆)))
(cong⟦∙⟧⟨ refl⊇ ⟩Eq (↑⟨ c ⟩Eq⟦ M ⟧ u⋆)
(cong↑⟨ c ⟩𝒰 (𝒰⟦ M ⟧ u⋆))
(𝒰⟦ M ⟧ (cong↑⟨ c ⟩𝒰⋆ u⋆))
(↑⟨ c ⟩Eq⟦ N ⟧ u⋆)
(cong↑⟨ c ⟩𝒰 (𝒰⟦ N ⟧ u⋆))
(𝒰⟦ N ⟧ (cong↑⟨ c ⟩𝒰⋆ u⋆))))
↑⟨ c ⟩Eq⟦ M ▶ γ ⟧ u⋆ = transEq (↑⟨ c ⟩Eq⟦ M ⟧ (𝒰⋆⟦ γ ⟧ₛ u⋆))
(Eq⟦ M ⟧ (↑⟨ c ⟩Eq⋆⟦ γ ⟧ₛ u⋆)
(cong↑⟨ c ⟩𝒰⋆ (𝒰⋆⟦ γ ⟧ₛ u⋆))
(𝒰⋆⟦ γ ⟧ₛ (cong↑⟨ c ⟩𝒰⋆ u⋆)))
↑⟨_⟩Eq⋆⟦_⟧ₛ : ∀ {Γ Δ Θ Ω} {ρ : Θ ⊩⋆ Δ} →
(c : Ω ⊇ Θ) (γ : Δ ⋙ Γ) → 𝒰⋆ ρ →
Eq⋆ (↑⟨ c ⟩ (⟦ γ ⟧ₛ ρ)) (⟦ γ ⟧ₛ (↑⟨ c ⟩ ρ))
↑⟨ c ⟩Eq⋆⟦ π⟨ c′ ⟩ ⟧ₛ u⋆ = aux₄₂₈ c′ c u⋆
↑⟨ c ⟩Eq⋆⟦ γ ● γ′ ⟧ₛ u⋆ = transEq⋆ (↑⟨ c ⟩Eq⋆⟦ γ ⟧ₛ (𝒰⋆⟦ γ′ ⟧ₛ u⋆))
(Eq⋆⟦ γ ⟧ₛ (↑⟨ c ⟩Eq⋆⟦ γ′ ⟧ₛ u⋆)
(cong↑⟨ c ⟩𝒰⋆ (𝒰⋆⟦ γ′ ⟧ₛ u⋆))
(𝒰⋆⟦ γ′ ⟧ₛ (cong↑⟨ c ⟩𝒰⋆ u⋆)))
↑⟨ c ⟩Eq⋆⟦ [ γ , x ≔ M ] ⟧ₛ u⋆ = eq⋆≔ (↑⟨ c ⟩Eq⋆⟦ γ ⟧ₛ u⋆) (↑⟨ c ⟩Eq⟦ M ⟧ u⋆)
-- NOTE: Added missing lemmas.
module _ where
aux₄₈₁⟨_⟩ : ∀ {Γ Δ A x} {{_ : T (fresh x Γ)}} {ρ : Δ ⊩⋆ Γ} {a : Δ ⊩ A} →
(c : [ Γ , x ∷ A ] ⊇ Γ) → 𝒰⋆ ρ →
Eq⋆ (↓⟨ c ⟩ [ ρ , x ≔ a ]) ρ
aux₄₈₁⟨ c ⟩ u⋆ = transEq⋆ (aux₄₂₃ refl⊇ c u⋆) (aux₄₂₄⟨ refl⊇ ⟩ u⋆)
aux₄₈₂⟨_⟩ : ∀ {Γ Δ} {ρ : Δ ⊩⋆ Γ} →
(c : Γ ⊇ []) → 𝒰⋆ ρ →
↓⟨ c ⟩ ρ ≡ []
aux₄₈₂⟨ done ⟩ u⋆ = refl
aux₄₈₃ : ∀ {Γ Δ} {ρ : Δ ⊩⋆ Γ} →
(γ : Γ ⋙ []) → 𝒰⋆ ρ →
Eq⋆ (⟦ γ ⟧ₛ ρ) []
aux₄₈₃ π⟨ c ⟩ u⋆ rewrite aux₄₈₂⟨ c ⟩ u⋆ = reflEq⋆ 𝓊⋆[]
aux₄₈₃ (γ ● γ′) u⋆ = aux₄₈₃ γ (𝒰⋆⟦ γ′ ⟧ₛ u⋆)
aux₄₈₄ : ∀ {Γ Δ A x} {{_ : T (fresh x Γ)}} {ρ : Δ ⊩⋆ Γ} {a : Δ ⊩ A} →
(i : [ Γ , x ∷ A ] ∋ x ∷ A) → 𝒰 a →
Eq (lookup [ ρ , x ≔ a ] i) a
aux₄₈₄ i uₐ rewrite uniq∋ i zero = reflEq uₐ
conv₆Eq⋆⟨_⟩ : ∀ {Γ Δ} {ρ : Δ ⊩⋆ Γ} →
(c : Γ ⊇ []) (γ : Γ ⋙ []) → 𝒰⋆ ρ →
Eq⋆ (⟦ γ ⟧ₛ ρ) (↓⟨ c ⟩⊩⋆ ρ)
conv₆Eq⋆⟨ c ⟩ γ u⋆ rewrite aux₄₈₂⟨ c ⟩ u⋆ = aux₄₈₃ γ u⋆
conv₇Eq⋆⟨_⟩ : ∀ {Γ Δ Θ A x} {{_ : T (fresh x Γ)}} {ρ : Θ ⊩⋆ Δ} →
(c : [ Γ , x ∷ A ] ⊇ Γ) (γ : Δ ⋙ [ Γ , x ∷ A ]) (i : [ Γ , x ∷ A ] ∋ x ∷ A) → 𝒰⋆ ρ →
Eq⋆ (⟦ γ ⟧ₛ ρ) [ ↓⟨ c ⟩ (⟦ γ ⟧ₛ ρ) , x ≔ lookup (⟦ γ ⟧ₛ ρ) i ]
conv₇Eq⋆⟨_⟩ {x = x} {ρ = ρ} c γ i u⋆ with ⟦ γ ⟧ₛ ρ | 𝒰⋆⟦ γ ⟧ₛ u⋆
conv₇Eq⋆⟨_⟩ {x = x} {ρ = ρ} c γ i u⋆ | [ ρ′ , .x ≔ a ] | 𝓊⋆≔ u⋆′ uₐ =
begin
[ ρ′ , x ≔ a ]
Eq⋆⟨ eq⋆≔ (symEq⋆ (aux₄₈₁⟨ c ⟩ u⋆′)) (symEq (aux₄₈₄ i uₐ)) ⟩
[ ↓⟨ c ⟩⊩⋆ [ ρ′ , x ≔ a ] , x ≔ lookup [ ρ′ , x ≔ a ] i ]
∎⟨ 𝓊⋆≔ (cong↓⟨ c ⟩𝒰⋆ (𝓊⋆≔ u⋆′ uₐ)) (conglookup𝒰 (𝓊⋆≔ u⋆′ uₐ) i) ⟩
where
open Eq⋆Reasoning
-- The soundness theorem is shown mutually with a corresponding lemma for substitutions:
-- Theorem 4.
-- NOTE: Added missing uniformity assumptions.
module _ {{_ : Model}} where
mutual
Eq⟦_⟧≅ : ∀ {Γ A w} {M M′ : Γ ⊢ A} {ρ : w ⊩⋆ Γ} →
M ≅ M′ → 𝒰⋆ ρ →
Eq (⟦ M ⟧ ρ) (⟦ M′ ⟧ ρ)
Eq⟦ refl≅ {M = M} ⟧≅ u⋆ = reflEq (𝒰⟦ M ⟧ u⋆)
Eq⟦ sym≅ p ⟧≅ u⋆ = symEq (Eq⟦ p ⟧≅ u⋆)
Eq⟦ trans≅ p p′ ⟧≅ u⋆ = transEq (Eq⟦ p ⟧≅ u⋆) (Eq⟦ p′ ⟧≅ u⋆)
Eq⟦ congƛ≅ {M = M} {M′} p ⟧≅ u⋆ = eq⊃ (λ c uₐ → Eq⟦ p ⟧≅ (𝓊⋆≔ (cong↑⟨ c ⟩𝒰⋆ u⋆) uₐ))
Eq⟦ cong∙≅ {M = M} {M′} {N} {N′} p p′ ⟧≅ u⋆ = cong⟦∙⟧⟨ refl⊇ ⟩Eq (Eq⟦ p ⟧≅ u⋆)
(𝒰⟦ M ⟧ u⋆)
(𝒰⟦ M′ ⟧ u⋆)
(Eq⟦ p′ ⟧≅ u⋆)
(𝒰⟦ N ⟧ u⋆)
(𝒰⟦ N′ ⟧ u⋆)
Eq⟦ cong▶≅ {M = M} {M′} {γ} {γ′} p pₛ ⟧≅ u⋆ = transEq (Eq⟦ M ⟧ (Eq⋆⟦ pₛ ⟧≅ₛ u⋆) (𝒰⋆⟦ γ ⟧ₛ u⋆) (𝒰⋆⟦ γ′ ⟧ₛ u⋆))
(transEq (Eq⟦ p ⟧≅ (𝒰⋆⟦ γ′ ⟧ₛ u⋆))
(reflEq (𝒰⟦ M′ ⟧ (𝒰⋆⟦ γ′ ⟧ₛ u⋆))))
Eq⟦ conv₁≅ M N γ ⟧≅ u⋆ = Eq⟦ M ⟧ (eq⋆≔ (aux₄₂₅⟨ refl⊇ ⟩ (𝒰⋆⟦ γ ⟧ₛ u⋆))
(reflEq (𝒰⟦ N ⟧ u⋆)))
(𝓊⋆≔ (cong↑⟨ refl⊇ ⟩𝒰⋆ (𝒰⋆⟦ γ ⟧ₛ u⋆))
(𝒰⟦ N ⟧ u⋆))
(𝓊⋆≔ (𝒰⋆⟦ γ ⟧ₛ u⋆)
(𝒰⟦ N ⟧ u⋆))
Eq⟦_⟧≅ {ρ = ρ} (conv₂≅ {x = x} c M) u⋆ =
eq⊃ (λ c′ {a} uₐ →
begin
⟦ M ⟧ ρ ⟦∙⟧⟨ c′ ⟩ a
Eq⟨ aux₄₁₃ c′ refl⊇ (𝒰⟦ M ⟧ u⋆) uₐ ⟩
(↑⟨ c′ ⟩ (⟦ M ⟧ ρ) ⟦∙⟧⟨ refl⊇ ⟩ a)
Eq⟨ cong⟦∙⟧⟨ refl⊇ ⟩Eq (↑⟨ c′ ⟩Eq⟦ M ⟧ u⋆)
(cong↑⟨ c′ ⟩𝒰 (𝒰⟦ M ⟧ u⋆))
(𝒰⟦ M ⟧ (cong↑⟨ c′ ⟩𝒰⋆ u⋆))
(reflEq uₐ) uₐ uₐ ⟩
⟦ M ⟧ (↑⟨ c′ ⟩ ρ) ⟦∙⟧⟨ refl⊇ ⟩ a
Eq⟨ cong⟦∙⟧⟨ refl⊇ ⟩Eq (Eq⟦ M ⟧ (symEq⋆ (aux₄₈₁⟨ c ⟩ (cong↑⟨ c′ ⟩𝒰⋆ u⋆)))
(cong↑⟨ c′ ⟩𝒰⋆ u⋆)
(cong↓⟨ c ⟩𝒰⋆ (𝓊⋆≔ (cong↑⟨ c′ ⟩𝒰⋆ u⋆) uₐ)))
(𝒰⟦ M ⟧ (cong↑⟨ c′ ⟩𝒰⋆ u⋆))
(𝒰⟦ M ⟧ (cong↓⟨ c ⟩𝒰⋆ (𝓊⋆≔ (cong↑⟨ c′ ⟩𝒰⋆ u⋆) uₐ)))
(reflEq uₐ) uₐ uₐ ⟩
⟦ M ⟧ (↓⟨ c ⟩ [ ↑⟨ c′ ⟩ ρ , x ≔ a ]) ⟦∙⟧⟨ refl⊇ ⟩ a
∎⟨ case (𝒰⟦ M ⟧ (cong↓⟨ c ⟩𝒰⋆ (𝓊⋆≔ (cong↑⟨ c′ ⟩𝒰⋆ u⋆) uₐ))) of
(λ { (𝓊⊃ h₀ h₁ h₂) → h₀ refl⊇ uₐ }) ⟩)
where
open EqReasoning
Eq⟦ conv₃≅ M γ ⟧≅ u⋆ = reflEq (𝒰⟦ M ⟧ u⋆)
Eq⟦ conv₄≅ c i j ⟧≅ u⋆ = symEq (aux₄₂₁⟨ c ⟩ u⋆ j i)
Eq⟦ conv₅≅ c M ⟧≅ u⋆ = Eq⟦ M ⟧ (aux₄₂₄⟨ c ⟩ u⋆) (cong↓⟨ c ⟩𝒰⋆ u⋆) u⋆
Eq⟦ conv₆≅ M N γ ⟧≅ u⋆ = cong⟦∙⟧⟨ refl⊇ ⟩Eq (reflEq (𝒰⟦ M ⟧ (𝒰⋆⟦ γ ⟧ₛ u⋆)))
(𝒰⟦ M ⟧ (𝒰⋆⟦ γ ⟧ₛ u⋆))
(𝒰⟦ M ⟧ (𝒰⋆⟦ γ ⟧ₛ u⋆))
(reflEq (𝒰⟦ N ⟧ (𝒰⋆⟦ γ ⟧ₛ u⋆)))
(𝒰⟦ N ⟧ (𝒰⋆⟦ γ ⟧ₛ u⋆))
(𝒰⟦ N ⟧ (𝒰⋆⟦ γ ⟧ₛ u⋆))
Eq⟦ conv₇≅ M γ δ ⟧≅ u⋆ = reflEq (𝒰⟦ M ⟧ (𝒰⋆⟦ γ ⟧ₛ (𝒰⋆⟦ δ ⟧ₛ u⋆)))
Eq⋆⟦_⟧≅ₛ : ∀ {Γ Δ w} {γ γ′ : Γ ⋙ Δ} {ρ : w ⊩⋆ Γ} →
γ ≅ₛ γ′ → 𝒰⋆ ρ →
Eq⋆ (⟦ γ ⟧ₛ ρ) (⟦ γ′ ⟧ₛ ρ)
Eq⋆⟦ refl≅ₛ {γ = γ} ⟧≅ₛ u⋆ = reflEq⋆ (𝒰⋆⟦ γ ⟧ₛ u⋆)
Eq⋆⟦ sym≅ₛ pₛ ⟧≅ₛ u⋆ = symEq⋆ (Eq⋆⟦ pₛ ⟧≅ₛ u⋆)
Eq⋆⟦ trans≅ₛ pₛ pₛ′ ⟧≅ₛ u⋆ = transEq⋆ (Eq⋆⟦ pₛ ⟧≅ₛ u⋆) (Eq⋆⟦ pₛ′ ⟧≅ₛ u⋆)
Eq⋆⟦ cong●≅ₛ {γ′ = γ′} {δ} {δ′} pₛ pₛ′ ⟧≅ₛ u⋆ = transEq⋆ (Eq⋆⟦ pₛ ⟧≅ₛ (𝒰⋆⟦ δ ⟧ₛ u⋆))
(Eq⋆⟦ γ′ ⟧ₛ (Eq⋆⟦ pₛ′ ⟧≅ₛ u⋆)
(𝒰⋆⟦ δ ⟧ₛ u⋆)
(𝒰⋆⟦ δ′ ⟧ₛ u⋆))
Eq⋆⟦ cong≔≅ₛ pₛ p ⟧≅ₛ u⋆ = eq⋆≔ (Eq⋆⟦ pₛ ⟧≅ₛ u⋆) (Eq⟦ p ⟧≅ u⋆)
Eq⋆⟦ conv₁≅ₛ γ δ θ ⟧≅ₛ u⋆ = reflEq⋆ (𝒰⋆⟦ γ ⟧ₛ (𝒰⋆⟦ δ ⟧ₛ (𝒰⋆⟦ θ ⟧ₛ u⋆)))
Eq⋆⟦ conv₂≅ₛ M γ δ ⟧≅ₛ u⋆ = reflEq⋆ (𝓊⋆≔ (𝒰⋆⟦ γ ⟧ₛ (𝒰⋆⟦ δ ⟧ₛ u⋆))
(𝒰⟦ M ⟧ (𝒰⋆⟦ δ ⟧ₛ u⋆)))
Eq⋆⟦ conv₃≅ₛ c M γ ⟧≅ₛ u⋆ = transEq⋆ (aux₄₂₃ refl⊇ c (𝒰⋆⟦ γ ⟧ₛ u⋆))
(aux₄₂₄⟨ refl⊇ ⟩ (𝒰⋆⟦ γ ⟧ₛ u⋆))
Eq⋆⟦ conv₄≅ₛ c c′ c″ ⟧≅ₛ u⋆ = aux₄₂₆ c′ c″ c u⋆
Eq⋆⟦ conv₅≅ₛ c γ ⟧≅ₛ u⋆ = Eq⋆⟦ γ ⟧ₛ (aux₄₂₄⟨ c ⟩ u⋆) (cong↓⟨ c ⟩𝒰⋆ u⋆) u⋆
Eq⋆⟦ conv₆≅ₛ c γ ⟧≅ₛ u⋆ = conv₆Eq⋆⟨ c ⟩ γ u⋆
Eq⋆⟦ conv₇≅ₛ c γ i ⟧≅ₛ u⋆ = conv₇Eq⋆⟨ c ⟩ γ i u⋆
-- They are both shown by induction on the rules of conversion. Notice that the soundness
-- result holds in any Kripke model.
-- 4.9. Decision algorithm for conversion
-- --------------------------------------
--
-- We now have a decision algorithm for testing convertibility between proof trees: compute
-- the normal form and check if they are exactly the same. This decision algorithm is correct,
-- since by Theorem 2 we have `M ≅ nf M` and `M′ ≅ nf M′` and, by hypothesis, `nf M ≡ nf M′`,
-- we get by transitivity of `_≅_`, that `M ≅ M′`.
-- Theorem 5.
thm₅ : ∀ {Γ A} → (M M′ : Γ ⊢ A) → nf M ≡ nf M′ → M ≅ M′
thm₅ M M′ p = begin
M
≅⟨ thm₂ M ⟩
nf M
≡⟨ p ⟩
nf M′
≅⟨ sym≅ (thm₂ M′) ⟩
M′
∎
where
open ≅-Reasoning
-- The decision algorithm is also complete since by Theorem 4 and the hypothesis, `M ≅ M′`, we get
-- `Eq (⟦ M ⟧ refl⊩⋆) (⟦ N ⟧ refl⊩⋆)` and by Corollary 1 we get `nf M ≡ nf N`.
-- NOTE: Added missing lemmas.
module _ where
proj⟨_⟩𝒰⋆ : ∀ {Γ Δ} →
(c : Δ ⊇ Γ) →
𝒰⋆ proj⟨ c ⟩⊩⋆
proj⟨ done ⟩𝒰⋆ = 𝓊⋆[]
proj⟨ step c i ⟩𝒰⋆ = 𝓊⋆≔ proj⟨ c ⟩𝒰⋆ (⟦ν⟧𝒰 i)
refl𝒰⋆ : ∀ {Γ} → 𝒰⋆ (refl⊩⋆ {Γ})
refl𝒰⋆ = proj⟨ refl⊇ ⟩𝒰⋆
-- Theorem 6.
thm₆ : ∀ {Γ A} → (M M′ : Γ ⊢ A) → M ≅ M′ → nf M ≡ nf M′
thm₆ M M′ p = cor₁ M M′ (Eq⟦ p ⟧≅ refl𝒰⋆)
| {
"alphanum_fraction": 0.3496977025,
"avg_line_length": 47.3247496423,
"ext": "agda",
"hexsha": "9f7173baedb929096792eb042414f7773e80c5b6",
"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": "7c000654c4f97024d2939c412702f64dc821d4ec",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/coquand",
"max_forks_repo_path": "src/Section4b.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/coquand",
"max_issues_repo_path": "src/Section4b.agda",
"max_line_length": 113,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "7c000654c4f97024d2939c412702f64dc821d4ec",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/coquand",
"max_stars_repo_path": "src/Section4b.agda",
"max_stars_repo_stars_event_max_datetime": "2017-09-07T12:44:40.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-03-27T01:29:58.000Z",
"num_tokens": 15691,
"size": 33080
} |
module CombinatoryLogic.Forest where
open import Data.Product using (_,_)
open import Function using (_$_)
open import Mockingbird.Forest using (Forest)
open import CombinatoryLogic.Equality as Equality using (isEquivalence; cong)
open import CombinatoryLogic.Semantics as ⊢ using (_≈_)
open import CombinatoryLogic.Syntax as Syntax using (Combinator)
forest : Forest
forest = record
{ Bird = Combinator
; _≈_ = _≈_
; _∙_ = Syntax._∙_
; isForest = record
{ isEquivalence = isEquivalence
; cong = cong
}
}
open Forest forest
open import Mockingbird.Forest.Birds forest
open import Mockingbird.Forest.Extensionality forest
import Mockingbird.Problems.Chapter11 forest as Chapter₁₁
import Mockingbird.Problems.Chapter12 forest as Chapter₁₂
instance
hasWarbler : HasWarbler
hasWarbler = record
{ W = Syntax.W
; isWarbler = λ _ _ → ⊢.W
}
hasKestrel : HasKestrel
hasKestrel = record
{ K = Syntax.K
; isKestrel = λ _ _ → ⊢.K
}
hasBluebird : HasBluebird
hasBluebird = record
{ B = Syntax.B
; isBluebird = λ _ _ _ → ⊢.B
}
hasIdentity : HasIdentity
hasIdentity = record
{ I = Syntax.I
; isIdentity = λ _ → Equality.prop₉
}
hasMockingbird : HasMockingbird
hasMockingbird = Chapter₁₁.problem₁₄
hasLark : HasLark
hasLark = Chapter₁₂.problem₃
hasComposition : HasComposition
hasComposition = Chapter₁₁.problem₁
| {
"alphanum_fraction": 0.7142857143,
"avg_line_length": 22.6935483871,
"ext": "agda",
"hexsha": "6acdd070baa2207c0ab8078ff0e9931248687e94",
"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": "df8bf877e60b3059532c54a247a36a3d83cd55b0",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "splintah/combinatory-logic",
"max_forks_repo_path": "CombinatoryLogic/Forest.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0",
"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": "splintah/combinatory-logic",
"max_issues_repo_path": "CombinatoryLogic/Forest.agda",
"max_line_length": 77,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "df8bf877e60b3059532c54a247a36a3d83cd55b0",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "splintah/combinatory-logic",
"max_stars_repo_path": "CombinatoryLogic/Forest.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-28T23:44:42.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-02-28T23:44:42.000Z",
"num_tokens": 433,
"size": 1407
} |
{-# OPTIONS --cubical --safe #-}
module Cubical.Foundations.TotalFiber where
open import Cubical.Core.Everything
open import Cubical.Data.Prod
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Surjection
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.HITs.PropositionalTruncation
private
variable
ℓ ℓ' : Level
module _ {A : Type ℓ} {B : Type ℓ'} (f : A → B) where
private
ℓ'' : Level
ℓ'' = ℓ-max ℓ ℓ'
LiftA : Type ℓ''
LiftA = Lift {j = ℓ'} A
Total-fiber : Type ℓ''
Total-fiber = Σ B \ b → fiber f b
A→Total-fiber : A → Total-fiber
A→Total-fiber a = f a , a , refl
Total-fiber→A : Total-fiber → A
Total-fiber→A (b , a , p) = a
Total-fiber→A→Total-fiber : ∀ t → A→Total-fiber (Total-fiber→A t) ≡ t
Total-fiber→A→Total-fiber (b , a , p) i = p i , a , λ j → p (i ∧ j)
A→Total-fiber→A : ∀ a → Total-fiber→A (A→Total-fiber a) ≡ a
A→Total-fiber→A a = refl
LiftA→Total-fiber : LiftA → Total-fiber
LiftA→Total-fiber x = A→Total-fiber (lower x)
Total-fiber→LiftA : Total-fiber → LiftA
Total-fiber→LiftA x = lift (Total-fiber→A x)
Total-fiber→LiftA→Total-fiber : ∀ t → LiftA→Total-fiber (Total-fiber→LiftA t) ≡ t
Total-fiber→LiftA→Total-fiber (b , a , p) i = p i , a , λ j → p (i ∧ j)
LiftA→Total-fiber→LiftA : ∀ a → Total-fiber→LiftA (LiftA→Total-fiber a) ≡ a
LiftA→Total-fiber→LiftA a = refl
A≡Total : Lift A ≡ Total-fiber
A≡Total = isoToPath (iso
LiftA→Total-fiber
Total-fiber→LiftA
Total-fiber→LiftA→Total-fiber
LiftA→Total-fiber→LiftA)
-- HoTT Lemma 4.8.2
A≃Total : Lift A ≃ Total-fiber
A≃Total = isoToEquiv (iso
LiftA→Total-fiber
Total-fiber→LiftA
Total-fiber→LiftA→Total-fiber
LiftA→Total-fiber→LiftA)
| {
"alphanum_fraction": 0.6621179039,
"avg_line_length": 27.7575757576,
"ext": "agda",
"hexsha": "ef5d768eb2cd9fcfe60d005935789bb126d4e11c",
"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": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "limemloh/cubical",
"max_forks_repo_path": "Cubical/Foundations/TotalFiber.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1",
"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": "limemloh/cubical",
"max_issues_repo_path": "Cubical/Foundations/TotalFiber.agda",
"max_line_length": 83,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "df4ef7edffd1c1deb3d4ff342c7178e9901c44f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "limemloh/cubical",
"max_stars_repo_path": "Cubical/Foundations/TotalFiber.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 711,
"size": 1832
} |
module LC.Simultanuous where
open import LC.Base
open import LC.Subst
open import LC.Reduction
open import Data.Nat
open import Relation.Binary.Construct.Closure.ReflexiveTransitive
-- open import Relation.Binary.PropositionalEquality hiding ([_]; preorder)
-- infixl 4 _*
-- data _* : Term → Set where
-- *-var : (M : Term) → M *
-- *-ƛ : ∀ {M} → ƛ M * → M *
-- *-∙ : ∀ {M N} → M ∙ N * → M * ∙ N * | {
"alphanum_fraction": 0.623501199,
"avg_line_length": 26.0625,
"ext": "agda",
"hexsha": "d7c824ef135157786c03c387a8aee4f3e2a0c555",
"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": "0c9a6e79c23192b28ddb07315b200a94ee900ca6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/bidirectional",
"max_forks_repo_path": "LC/Simultanuous.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6",
"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": "banacorn/bidirectional",
"max_issues_repo_path": "LC/Simultanuous.agda",
"max_line_length": 75,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/bidirectional",
"max_stars_repo_path": "LC/Simultanuous.agda",
"max_stars_repo_stars_event_max_datetime": "2020-08-25T14:05:01.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-08-25T07:34:40.000Z",
"num_tokens": 136,
"size": 417
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Categories.Sets where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Categories.Category
open import Cubical.Categories.Functor
open import Cubical.Categories.NaturalTransformation
open Precategory
module _ ℓ where
SET : Precategory (ℓ-suc ℓ) ℓ
SET .ob = Σ (Type ℓ) isSet
SET .Hom[_,_] (A , _) (B , _) = A → B
SET .id _ = λ x → x
SET ._⋆_ f g = λ x → g (f x)
SET .⋆IdL f = refl
SET .⋆IdR f = refl
SET .⋆Assoc f g h = refl
module _ {ℓ} where
isSetExpIdeal : {A B : Type ℓ} → isSet B → isSet (A → B)
isSetExpIdeal B/set = isSetΠ λ _ → B/set
isSetLift : {A : Type ℓ} → isSet A → isSet (Lift {ℓ} {ℓ-suc ℓ} A)
isSetLift = isOfHLevelLift 2
module _ {A B : SET ℓ .ob} where
-- monic/surjectiveness
open import Cubical.Categories.Morphism
isSurjSET : (f : SET ℓ [ A , B ]) → Type _
isSurjSET f = ∀ (b : fst B) → Σ[ a ∈ fst A ] f a ≡ b
-- isMonic→isSurjSET : {f : SET ℓ [ A , B ]}
-- → isEpic {C = SET ℓ} {x = A} {y = B} f
-- → isSurjSET f
-- isMonic→isSurjSET ism b = {!!} , {!!}
instance
SET-category : isCategory (SET ℓ)
SET-category .isSetHom {_} {B , B/set} = isSetExpIdeal B/set
private
variable
ℓ ℓ' : Level
open Functor
-- Hom functors
_[-,_] : (C : Precategory ℓ ℓ') → (c : C .ob) → ⦃ isCat : isCategory C ⦄ → Functor (C ^op) (SET _)
(C [-, c ]) ⦃ isCat ⦄ .F-ob x = (C [ x , c ]) , isCat .isSetHom
(C [-, c ]) .F-hom f k = f ⋆⟨ C ⟩ k
(C [-, c ]) .F-id = funExt λ _ → C .⋆IdL _
(C [-, c ]) .F-seq _ _ = funExt λ _ → C .⋆Assoc _ _ _
_[_,-] : (C : Precategory ℓ ℓ') → (c : C .ob) → ⦃ isCat : isCategory C ⦄ → Functor C (SET _)
(C [ c ,-]) ⦃ isCat ⦄ .F-ob x = (C [ c , x ]) , isCat .isSetHom
(C [ c ,-]) .F-hom f k = k ⋆⟨ C ⟩ f
(C [ c ,-]) .F-id = funExt λ _ → C .⋆IdR _
(C [ c ,-]) .F-seq _ _ = funExt λ _ → sym (C .⋆Assoc _ _ _)
module _ {C : Precategory ℓ ℓ'} ⦃ _ : isCategory C ⦄ {F : Functor C (SET ℓ')} where
open NatTrans
-- natural transformations by pre/post composition
preComp : {x y : C .ob}
→ (f : C [ x , y ])
→ C [ x ,-] ⇒ F
→ C [ y ,-] ⇒ F
preComp f α .N-ob c k = (α ⟦ c ⟧) (f ⋆⟨ C ⟩ k)
preComp f α .N-hom {x = c} {d} k
= (λ l → (α ⟦ d ⟧) (f ⋆⟨ C ⟩ (l ⋆⟨ C ⟩ k)))
≡[ i ]⟨ (λ l → (α ⟦ d ⟧) (⋆Assoc C f l k (~ i))) ⟩
(λ l → (α ⟦ d ⟧) (f ⋆⟨ C ⟩ l ⋆⟨ C ⟩ k))
≡[ i ]⟨ (λ l → (α .N-hom k) i (f ⋆⟨ C ⟩ l)) ⟩
(λ l → (F ⟪ k ⟫) ((α ⟦ c ⟧) (f ⋆⟨ C ⟩ l)))
∎
-- properties
-- TODO: move to own file
open CatIso renaming (inv to cInv)
open Iso
Iso→CatIso : ∀ {A B : (SET ℓ) .ob}
→ Iso (fst A) (fst B)
→ CatIso {C = SET ℓ} A B
Iso→CatIso is .mor = is .fun
Iso→CatIso is .cInv = is .inv
Iso→CatIso is .sec = funExt λ b → is .rightInv b -- is .rightInv
Iso→CatIso is .ret = funExt λ b → is .leftInv b -- is .rightInv
| {
"alphanum_fraction": 0.5158860138,
"avg_line_length": 32.4787234043,
"ext": "agda",
"hexsha": "0007b441a6e07f044c0619a5cc2b12ca486fb40c",
"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": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Categories/Sets.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"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": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Categories/Sets.agda",
"max_line_length": 98,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/Categories/Sets.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1295,
"size": 3053
} |
module Relator.Equals where
import Lvl
open import Logic
open import Logic.Propositional
open import Type
infixl 15 _≢_
open import Type.Identity public
using()
renaming(Id to infixl 15 _≡_ ; intro to [≡]-intro)
_≢_ : ∀{ℓ}{T} → T → T → Stmt{ℓ}
a ≢ b = ¬(a ≡ b)
| {
"alphanum_fraction": 0.6642335766,
"avg_line_length": 17.125,
"ext": "agda",
"hexsha": "8e579682f098ff1743a96ff931d5951f84a4032f",
"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.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.agda",
"max_line_length": 52,
"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.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": 99,
"size": 274
} |
------------------------------------------------------------------------
-- Strictly descending lists
------------------------------------------------------------------------
{-# OPTIONS --cubical --no-import-sorts --safe #-}
open import Cubical.Core.Everything
module Cubical.Data.DescendingList.Strict
(A : Type₀)
(_>_ : A → A → Type₀)
where
open import Cubical.Data.DescendingList.Base A _>_ renaming (_≥ᴴ_ to _>ᴴ_; ≥ᴴ[] to >ᴴ[]; ≥ᴴcons to >ᴴcons; DL to SDL) using ([]; cons) public
| {
"alphanum_fraction": 0.4827586207,
"avg_line_length": 32.8666666667,
"ext": "agda",
"hexsha": "5e22508c80d5506148d86b788a80d372bba99d0f",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Data/DescendingList/Strict.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Data/DescendingList/Strict.agda",
"max_line_length": 141,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/Data/DescendingList/Strict.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 122,
"size": 493
} |
-- Andreas, 2019-12-08, issue #4267, reported and test case by csattler
-- Problem: definitions from files (A1) imported by a module
-- (Issue4267) may leak into the handling of an independent module
-- (B).
-- The root issue here is that having a signature stImports that
-- simply accumulates the signatures of all visited modules is
-- unhygienic.
module Issue4267 where
open import Issue4267.A0
open import Issue4267.A1 -- importing A1 here (in main) affects how B is type-checked
open import Issue4267.B
-- After the fix of #4267, these imports should succeed without unsolved metas.
| {
"alphanum_fraction": 0.7626262626,
"avg_line_length": 33,
"ext": "agda",
"hexsha": "75911295e1cfee03ff98c4a0dde8d5254a1dce8d",
"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/Issue4267.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/Issue4267.agda",
"max_line_length": 85,
"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/Issue4267.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": 155,
"size": 594
} |
------------------------------------------------------------------------
-- Some results related to the For-iterated-equality predicate
-- transformer
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Equality
module For-iterated-equality
{c⁺} (eq : ∀ {a p} → Equality-with-J a p c⁺) where
open Derived-definitions-and-properties eq
open import Logical-equivalence using (_⇔_)
open import Prelude
open import Bijection eq as Bijection using (_↔_)
open import Equivalence eq as Eq using (_≃_)
open import Equivalence.Erased eq as EEq using (_≃ᴱ_)
open import Function-universe eq as F hiding (id; _∘_)
open import H-level eq
open import List eq
open import Nat eq
open import Surjection eq as Surj using (_↠_)
private
variable
a b ℓ p q : Level
A B : Type a
P Q R : Type p → Type p
x y : A
k : Kind
n : ℕ
------------------------------------------------------------------------
-- Some lemmas related to nested occurrences of For-iterated-equality
-- Nested uses of For-iterated-equality can be merged.
For-iterated-equality-For-iterated-equality′ :
{A : Type a} →
∀ m n →
For-iterated-equality m (For-iterated-equality n P) A ↝[ a ∣ a ]
For-iterated-equality (m + n) P A
For-iterated-equality-For-iterated-equality′ zero _ _ = F.id
For-iterated-equality-For-iterated-equality′ {P = P} {A = A}
(suc m) n ext =
((x y : A) →
For-iterated-equality m (For-iterated-equality n P) (x ≡ y)) ↝⟨ (∀-cong ext λ _ → ∀-cong ext λ _ →
For-iterated-equality-For-iterated-equality′ m n ext) ⟩□
((x y : A) → For-iterated-equality (m + n) P (x ≡ y)) □
-- A variant of the previous result.
For-iterated-equality-For-iterated-equality :
{A : Type a} →
∀ m n →
For-iterated-equality m (For-iterated-equality n P) A ↝[ a ∣ a ]
For-iterated-equality (n + m) P A
For-iterated-equality-For-iterated-equality {P = P} {A = A}
m n ext =
For-iterated-equality m (For-iterated-equality n P) A ↝⟨ For-iterated-equality-For-iterated-equality′ m n ext ⟩
For-iterated-equality (m + n) P A ↝⟨ ≡⇒↝ _ $ cong (λ n → For-iterated-equality n P A) (+-comm m) ⟩□
For-iterated-equality (n + m) P A □
------------------------------------------------------------------------
-- Preservation lemmas for For-iterated-equality
-- A preservation lemma for the predicate.
For-iterated-equality-cong₁ :
{P Q : Type ℓ → Type ℓ} →
Extensionality? k ℓ ℓ →
∀ n →
(∀ {A} → P A ↝[ k ] Q A) →
For-iterated-equality n P A ↝[ k ] For-iterated-equality n Q A
For-iterated-equality-cong₁ _ zero P↝Q = P↝Q
For-iterated-equality-cong₁ {A = A} {P = P} {Q = Q} ext (suc n) P↝Q =
((x y : A) → For-iterated-equality n P (x ≡ y)) ↝⟨ (∀-cong ext λ _ → ∀-cong ext λ _ →
For-iterated-equality-cong₁ ext n P↝Q) ⟩□
((x y : A) → For-iterated-equality n Q (x ≡ y)) □
-- A variant of For-iterated-equality-cong₁.
For-iterated-equality-cong₁ᴱ-→ :
{@0 A : Type ℓ} {@0 P Q : Type ℓ → Type ℓ} →
∀ n →
(∀ {@0 A} → P A → Q A) →
For-iterated-equality n P A → For-iterated-equality n Q A
For-iterated-equality-cong₁ᴱ-→ zero P→Q = P→Q
For-iterated-equality-cong₁ᴱ-→ {A = A} {P = P} {Q = Q} (suc n) P→Q =
((x y : A) → For-iterated-equality n P (x ≡ y)) →⟨ For-iterated-equality-cong₁ᴱ-→ n (λ {A} → P→Q {A = A}) ∘_ ∘_ ⟩□
((x y : A) → For-iterated-equality n Q (x ≡ y)) □
-- Preservation lemmas for both the predicate and the type.
For-iterated-equality-cong-→ :
∀ n →
(∀ {A B} → A ↠ B → P A → Q B) →
A ↠ B →
For-iterated-equality n P A → For-iterated-equality n Q B
For-iterated-equality-cong-→ zero P↝Q A↠B = P↝Q A↠B
For-iterated-equality-cong-→ {P = P} {Q = Q} {A = A} {B = B}
(suc n) P↝Q A↠B =
((x y : A) → For-iterated-equality n P (x ≡ y)) ↝⟨ (Π-cong-contra-→ (_↠_.from A↠B) λ _ → Π-cong-contra-→ (_↠_.from A↠B) λ _ →
For-iterated-equality-cong-→ n P↝Q $ Surj.↠-≡ A↠B) ⟩□
((x y : B) → For-iterated-equality n Q (x ≡ y)) □
For-iterated-equality-cong :
{P : Type p → Type p} {Q : Type q → Type q} →
Extensionality? k (p ⊔ q) (p ⊔ q) →
∀ n →
(∀ {A B} → A ↔ B → P A ↝[ k ] Q B) →
A ↔ B →
For-iterated-equality n P A ↝[ k ] For-iterated-equality n Q B
For-iterated-equality-cong _ zero P↝Q A↔B = P↝Q A↔B
For-iterated-equality-cong {A = A} {B = B} {P = P} {Q = Q}
ext (suc n) P↝Q A↔B =
((x y : A) → For-iterated-equality n P (x ≡ y)) ↝⟨ (Π-cong ext A↔B λ _ → Π-cong ext A↔B λ _ →
For-iterated-equality-cong ext n P↝Q $ inverse $ _≃_.bijection $
Eq.≃-≡ $ from-isomorphism A↔B) ⟩□
((x y : B) → For-iterated-equality n Q (x ≡ y)) □
------------------------------------------------------------------------
-- Some "closure properties" for the type
private
-- A lemma.
lift≡lift↔ : lift {ℓ = ℓ} x ≡ lift y ↔ x ≡ y
lift≡lift↔ = inverse $ _≃_.bijection $ Eq.≃-≡ $ Eq.↔⇒≃ Bijection.↑↔
-- Closure properties for ⊤.
For-iterated-equality-↑-⊤ :
Extensionality? k ℓ ℓ →
∀ n →
(∀ {A B} → A ↔ B → P A ↝[ k ] P B) →
P (↑ ℓ ⊤) ↝[ k ] For-iterated-equality n P (↑ ℓ ⊤)
For-iterated-equality-↑-⊤ _ zero _ = F.id
For-iterated-equality-↑-⊤ {P = P} ext (suc n) resp =
P (↑ _ ⊤) ↝⟨ For-iterated-equality-↑-⊤ ext n resp ⟩
For-iterated-equality n P (↑ _ ⊤) ↝⟨ For-iterated-equality-cong ext n resp $
inverse lift≡lift↔ F.∘ inverse tt≡tt↔⊤ F.∘ Bijection.↑↔ ⟩
For-iterated-equality n P (lift tt ≡ lift tt) ↝⟨ inverse-ext? (λ ext → drop-⊤-left-Π ext Bijection.↑↔) ext ⟩
((y : ↑ _ ⊤) → For-iterated-equality n P (lift tt ≡ y)) ↝⟨ inverse-ext? (λ ext → drop-⊤-left-Π ext Bijection.↑↔) ext ⟩□
((x y : ↑ _ ⊤) → For-iterated-equality n P (x ≡ y)) □
For-iterated-equality-⊤ :
Extensionality? k lzero lzero →
∀ n →
(∀ {A B} → A ↔ B → P A ↝[ k ] P B) →
P ⊤ ↝[ k ] For-iterated-equality n P ⊤
For-iterated-equality-⊤ {P = P} ext n resp =
P ⊤ ↝⟨ resp (inverse Bijection.↑↔) ⟩
P (↑ _ ⊤) ↝⟨ For-iterated-equality-↑-⊤ ext n resp ⟩
For-iterated-equality n P (↑ _ ⊤) ↝⟨ For-iterated-equality-cong ext n resp Bijection.↑↔ ⟩□
For-iterated-equality n P ⊤ □
-- Closure properties for ⊥.
For-iterated-equality-suc-⊥ :
{P : Type p → Type p} →
∀ n → ⊤ ↝[ p ∣ p ] For-iterated-equality (suc n) P ⊥
For-iterated-equality-suc-⊥ {P = P} n ext =
⊤ ↝⟨ inverse-ext? Π⊥↔⊤ ext ⟩□
((x y : ⊥) → For-iterated-equality n P (x ≡ y)) □
For-iterated-equality-⊥ :
{P : Type p → Type p} →
Extensionality? k p p →
∀ n →
⊤ ↝[ k ] P ⊥ →
⊤ ↝[ k ] For-iterated-equality n P ⊥
For-iterated-equality-⊥ _ zero = id
For-iterated-equality-⊥ ext (suc n) _ =
For-iterated-equality-suc-⊥ n ext
-- A closure property for Π.
For-iterated-equality-Π :
{A : Type a} {B : A → Type b} →
Extensionality a b →
∀ n →
(∀ {A B} → A ↔ B → Q A → Q B) →
({A : Type a} {B : A → Type b} →
(∀ x → P (B x)) → Q (∀ x → B x)) →
(∀ x → For-iterated-equality n P (B x)) →
For-iterated-equality n Q (∀ x → B x)
For-iterated-equality-Π _ zero _ hyp = hyp
For-iterated-equality-Π {Q = Q} {P = P} {B = B} ext (suc n) resp hyp =
(∀ x (y z : B x) → For-iterated-equality n P (y ≡ z)) ↝⟨ (λ hyp _ _ _ → hyp _ _ _) ⟩
(∀ (f g : ∀ x → B x) x → For-iterated-equality n P (f x ≡ g x)) ↝⟨ (∀-cong _ λ _ → ∀-cong _ λ _ → For-iterated-equality-Π ext n resp hyp) ⟩
((f g : ∀ x → B x) → For-iterated-equality n Q (∀ x → f x ≡ g x)) ↝⟨ (∀-cong _ λ _ → ∀-cong _ λ _ → For-iterated-equality-cong _ n resp $
from-isomorphism $ Eq.extensionality-isomorphism ext) ⟩□
((f g : ∀ x → B x) → For-iterated-equality n Q (f ≡ g)) □
-- A closure property for Σ.
For-iterated-equality-Σ :
{A : Type a} {B : A → Type b} →
∀ n →
(∀ {A B} → A ↔ B → R A → R B) →
({A : Type a} {B : A → Type b} →
P A → (∀ x → Q (B x)) → R (Σ A B)) →
For-iterated-equality n P A →
(∀ x → For-iterated-equality n Q (B x)) →
For-iterated-equality n R (Σ A B)
For-iterated-equality-Σ zero _ hyp = hyp
For-iterated-equality-Σ {R = R} {P = P} {Q = Q} {A = A} {B = B}
(suc n) resp hyp = curry (
((x y : A) → For-iterated-equality n P (x ≡ y)) ×
((x : A) (y z : B x) → For-iterated-equality n Q (y ≡ z)) ↝⟨ (λ (hyp₁ , hyp₂) _ _ → hyp₁ _ _ , λ _ → hyp₂ _ _ _) ⟩
(((x₁ , x₂) (y₁ , y₂) : Σ A B) →
For-iterated-equality n P (x₁ ≡ y₁) ×
(∀ p → For-iterated-equality n Q (subst B p x₂ ≡ y₂))) ↝⟨ (∀-cong _ λ _ → ∀-cong _ λ _ → uncurry $
For-iterated-equality-Σ n resp hyp) ⟩
(((x₁ , x₂) (y₁ , y₂) : Σ A B) →
For-iterated-equality n R (∃ λ (p : x₁ ≡ y₁) → subst B p x₂ ≡ y₂)) ↝⟨ (∀-cong _ λ _ → ∀-cong _ λ _ →
For-iterated-equality-cong _ n resp Bijection.Σ-≡,≡↔≡) ⟩□
((x y : Σ A B) → For-iterated-equality n R (x ≡ y)) □)
-- A closure property for _×_.
For-iterated-equality-× :
{A : Type a} {B : Type b} →
∀ n →
(∀ {A B} → A ↔ B → R A → R B) →
({A : Type a} {B : Type b} → P A → Q B → R (A × B)) →
For-iterated-equality n P A →
For-iterated-equality n Q B →
For-iterated-equality n R (A × B)
For-iterated-equality-× zero _ hyp = hyp
For-iterated-equality-× {R = R} {P = P} {Q = Q} {A = A} {B = B}
(suc n) resp hyp = curry (
((x y : A) → For-iterated-equality n P (x ≡ y)) ×
((x y : B) → For-iterated-equality n Q (x ≡ y)) ↝⟨ (λ (hyp₁ , hyp₂) _ _ → hyp₁ _ _ , hyp₂ _ _) ⟩
(((x₁ , x₂) (y₁ , y₂) : A × B) →
For-iterated-equality n P (x₁ ≡ y₁) ×
For-iterated-equality n Q (x₂ ≡ y₂)) ↝⟨ (∀-cong _ λ _ → ∀-cong _ λ _ → uncurry $
For-iterated-equality-× n resp hyp) ⟩
(((x₁ , x₂) (y₁ , y₂) : A × B) →
For-iterated-equality n R (x₁ ≡ y₁ × x₂ ≡ y₂)) ↝⟨ (∀-cong _ λ _ → ∀-cong _ λ _ →
For-iterated-equality-cong _ n resp ≡×≡↔≡) ⟩□
((x y : A × B) → For-iterated-equality n R (x ≡ y)) □)
-- A closure property for ↑.
For-iterated-equality-↑ :
{A : Type a} {Q : Type (a ⊔ ℓ) → Type (a ⊔ ℓ)} →
Extensionality? k (a ⊔ ℓ) (a ⊔ ℓ) →
∀ n →
(∀ {A B} → A ↔ B → P A ↝[ k ] Q B) →
For-iterated-equality n P A ↝[ k ]
For-iterated-equality n Q (↑ ℓ A)
For-iterated-equality-↑ ext n resp =
For-iterated-equality-cong ext n resp (inverse Bijection.↑↔)
-- Closure properties for W.
For-iterated-equality-W-suc :
{A : Type a} {B : A → Type b} →
Extensionality b (a ⊔ b) →
∀ n →
(∀ {A B} → A ↔ B → Q A → Q B) →
({A : Type b} {B : A → Type (a ⊔ b)} →
(∀ x → Q (B x)) → Q (∀ x → B x)) →
({A : Type a} {B : A → Type (a ⊔ b)} →
P A → (∀ x → Q (B x)) → Q (Σ A B)) →
For-iterated-equality (suc n) P A →
For-iterated-equality (suc n) Q (W A B)
For-iterated-equality-W-suc {Q = Q} {P = P} {B = B}
ext n resp hyp-Π hyp-Σ fie = lemma
where
lemma : ∀ x y → For-iterated-equality n Q (x ≡ y)
lemma (sup x f) (sup y g) = $⟨ (λ p i → lemma (f i) _) ⟩
(∀ p i → For-iterated-equality n Q (f i ≡ g (subst B p i))) ↝⟨ (∀-cong _ λ _ → For-iterated-equality-Π ext n resp hyp-Π) ⟩
(∀ p → For-iterated-equality n Q (∀ i → f i ≡ g (subst B p i))) ↝⟨ fie _ _ ,_ ⟩
For-iterated-equality n P (x ≡ y) ×
(∀ p → For-iterated-equality n Q (∀ i → f i ≡ g (subst B p i))) ↝⟨ uncurry $ For-iterated-equality-Σ n resp hyp-Σ ⟩
For-iterated-equality n Q
(∃ λ (p : x ≡ y) → ∀ i → f i ≡ g (subst B p i)) ↝⟨ For-iterated-equality-cong _ n resp $ _≃_.bijection $ Eq.W-≡,≡≃≡ ext ⟩□
For-iterated-equality n Q (sup x f ≡ sup y g) □
For-iterated-equality-W :
{A : Type a} {B : A → Type b} →
Extensionality b (a ⊔ b) →
∀ n →
(∀ {A B} → A ↔ B → Q A → Q B) →
({A : Type b} {B : A → Type (a ⊔ b)} →
(∀ x → Q (B x)) → Q (∀ x → B x)) →
({A : Type a} {B : A → Type (a ⊔ b)} →
P A → (∀ x → Q (B x)) → Q (Σ A B)) →
(P A → Q (W A B)) →
For-iterated-equality n P A →
For-iterated-equality n Q (W A B)
For-iterated-equality-W _ zero _ _ _ hyp-W = hyp-W
For-iterated-equality-W ext (suc n) resp hyp-Π hyp-Σ _ =
For-iterated-equality-W-suc ext n resp hyp-Π hyp-Σ
-- Closure properties for _⊎_.
For-iterated-equality-⊎-suc :
{A : Type a} {B : Type b} →
∀ n →
(∀ {A B} → A ↔ B → P A → P B) →
P ⊥ →
For-iterated-equality (suc n) P (↑ b A) →
For-iterated-equality (suc n) P (↑ a B) →
For-iterated-equality (suc n) P (A ⊎ B)
For-iterated-equality-⊎-suc {P = P} n resp hyp-⊥ fie-A fie-B = λ where
(inj₁ x) (inj₁ y) → $⟨ fie-A (lift x) (lift y) ⟩
For-iterated-equality n P (lift x ≡ lift y) ↝⟨ For-iterated-equality-cong _ n resp (Bijection.≡↔inj₁≡inj₁ F.∘ lift≡lift↔) ⟩□
For-iterated-equality n P (inj₁ x ≡ inj₁ y) □
(inj₂ x) (inj₂ y) → $⟨ fie-B (lift x) (lift y) ⟩
For-iterated-equality n P (lift x ≡ lift y) ↝⟨ For-iterated-equality-cong _ n resp (Bijection.≡↔inj₂≡inj₂ F.∘ lift≡lift↔) ⟩□
For-iterated-equality n P (inj₂ x ≡ inj₂ y) □
(inj₁ x) (inj₂ y) → $⟨ hyp-⊥ ⟩
P ⊥ ↝⟨ (λ hyp → For-iterated-equality-⊥ _ n (λ _ → hyp) _) ⟩
For-iterated-equality n P ⊥ ↝⟨ For-iterated-equality-cong _ n resp (inverse Bijection.≡↔⊎) ⟩□
For-iterated-equality n P (inj₁ x ≡ inj₂ y) □
(inj₂ x) (inj₁ y) → $⟨ hyp-⊥ ⟩
P ⊥ ↝⟨ (λ hyp → For-iterated-equality-⊥ _ n (λ _ → hyp) _) ⟩
For-iterated-equality n P ⊥ ↝⟨ For-iterated-equality-cong _ n resp (inverse Bijection.≡↔⊎) ⟩□
For-iterated-equality n P (inj₂ x ≡ inj₁ y) □
For-iterated-equality-⊎ :
{A : Type a} {B : Type b} →
∀ n →
(∀ {A B} → A ↔ B → P A → P B) →
P ⊥ →
(P (↑ b A) → P (↑ a B) → P (A ⊎ B)) →
For-iterated-equality n P (↑ b A) →
For-iterated-equality n P (↑ a B) →
For-iterated-equality n P (A ⊎ B)
For-iterated-equality-⊎ zero _ _ hyp-⊎ = hyp-⊎
For-iterated-equality-⊎ (suc n) resp hyp-⊥ _ =
For-iterated-equality-⊎-suc n resp hyp-⊥
-- Closure properties for List.
For-iterated-equality-List-suc :
{A : Type a} →
∀ n →
(∀ {A B} → A ↔ B → P A → P B) →
P (↑ a ⊤) →
P ⊥ →
(∀ {A B} → P A → P B → P (A × B)) →
For-iterated-equality (suc n) P A →
For-iterated-equality (suc n) P (List A)
For-iterated-equality-List-suc {P = P} n resp hyp-⊤ hyp-⊥ hyp-× fie = λ where
[] [] → $⟨ hyp-⊤ ⟩
P (↑ _ ⊤) ↝⟨ For-iterated-equality-↑-⊤ _ n resp ⟩
For-iterated-equality n P (↑ _ ⊤) ↝⟨ For-iterated-equality-cong _ n resp (inverse []≡[]↔⊤ F.∘ Bijection.↑↔) ⟩□
For-iterated-equality n P ([] ≡ []) □
(x ∷ xs) (y ∷ ys) → $⟨ For-iterated-equality-List-suc n resp hyp-⊤ hyp-⊥ hyp-× fie xs ys ⟩
For-iterated-equality n P (xs ≡ ys) ↝⟨ fie _ _ ,_ ⟩
For-iterated-equality n P (x ≡ y) ×
For-iterated-equality n P (xs ≡ ys) ↝⟨ uncurry $ For-iterated-equality-× n resp hyp-× ⟩
For-iterated-equality n P (x ≡ y × xs ≡ ys) ↝⟨ For-iterated-equality-cong _ n resp (inverse ∷≡∷↔≡×≡) ⟩□
For-iterated-equality n P (x ∷ xs ≡ y ∷ ys) □
[] (y ∷ ys) → $⟨ hyp-⊥ ⟩
P ⊥ ↝⟨ (λ hyp → For-iterated-equality-⊥ _ n (λ _ → hyp) _) ⟩
For-iterated-equality n P ⊥ ↝⟨ For-iterated-equality-cong _ n resp (inverse []≡∷↔⊥) ⟩□
For-iterated-equality n P ([] ≡ y ∷ ys) □
(x ∷ xs) [] → $⟨ hyp-⊥ ⟩
P ⊥ ↝⟨ (λ hyp → For-iterated-equality-⊥ _ n (λ _ → hyp) _) ⟩
For-iterated-equality n P ⊥ ↝⟨ For-iterated-equality-cong _ n resp (inverse ∷≡[]↔⊥) ⟩□
For-iterated-equality n P (x ∷ xs ≡ []) □
For-iterated-equality-List :
{A : Type a} →
∀ n →
(∀ {A B} → A ↔ B → P A → P B) →
P (↑ a ⊤) →
P ⊥ →
(∀ {A B} → P A → P B → P (A × B)) →
(P A → P (List A)) →
For-iterated-equality n P A →
For-iterated-equality n P (List A)
For-iterated-equality-List zero _ _ _ _ hyp-List = hyp-List
For-iterated-equality-List (suc n) resp hyp-⊤ hyp-⊥ hyp-× _ =
For-iterated-equality-List-suc n resp hyp-⊤ hyp-⊥ hyp-×
------------------------------------------------------------------------
-- Some "closure properties" for the predicate
-- For-iterated-equality commutes with certain type constructors
-- (assuming extensionality).
For-iterated-equality-commutes :
Extensionality? k ℓ ℓ →
(F : Type ℓ → Type ℓ) →
∀ n →
({A : Type ℓ} {P : A → Type ℓ} →
F (∀ x → P x) ↝[ k ] ∀ x → F (P x)) →
F (For-iterated-equality n P A) ↝[ k ]
For-iterated-equality n (F ∘ P) A
For-iterated-equality-commutes _ _ zero _ = F.id
For-iterated-equality-commutes {P = P} {A = A} ext F (suc n) hyp =
F ((x y : A) → For-iterated-equality n P (x ≡ y)) ↝⟨ hyp ⟩
((x : A) → F ((y : A) → For-iterated-equality n P (x ≡ y))) ↝⟨ (∀-cong ext λ _ → hyp) ⟩
((x y : A) → F (For-iterated-equality n P (x ≡ y))) ↝⟨ (∀-cong ext λ _ → ∀-cong ext λ _ → For-iterated-equality-commutes ext F n hyp) ⟩□
((x y : A) → For-iterated-equality n (F ∘ P) (x ≡ y)) □
-- A variant of For-iterated-equality-commutes.
For-iterated-equality-commutesᴱ-→ :
{@0 A : Type ℓ} {@0 P : Type ℓ → Type ℓ}
(@0 F : Type ℓ → Type ℓ) →
∀ n →
({@0 A : Type ℓ} {@0 P : A → Type ℓ} →
F (∀ x → P x) → ∀ x → F (P x)) →
F (For-iterated-equality n P A) →
For-iterated-equality n (F ∘ P) A
For-iterated-equality-commutesᴱ-→ _ zero _ = id
For-iterated-equality-commutesᴱ-→ {A = A} {P = P} F (suc n) hyp =
F ((x y : A) → For-iterated-equality n P (x ≡ y)) →⟨ hyp ⟩
((x : A) → F ((y : A) → For-iterated-equality n P (x ≡ y))) →⟨ hyp ∘_ ⟩
((x y : A) → F (For-iterated-equality n P (x ≡ y))) →⟨ For-iterated-equality-commutesᴱ-→ F n hyp ∘_ ∘_ ⟩□
((x y : A) → For-iterated-equality n (F ∘ P) (x ≡ y)) □
-- Another variant of For-iterated-equality-commutes.
For-iterated-equality-commutes-← :
Extensionality? k ℓ ℓ →
(F : Type ℓ → Type ℓ) →
∀ n →
({A : Type ℓ} {P : A → Type ℓ} →
(∀ x → F (P x)) ↝[ k ] F (∀ x → P x)) →
For-iterated-equality n (F ∘ P) A ↝[ k ]
F (For-iterated-equality n P A)
For-iterated-equality-commutes-← _ _ zero _ = F.id
For-iterated-equality-commutes-← {P = P} {A = A} ext F (suc n) hyp =
((x y : A) → For-iterated-equality n (F ∘ P) (x ≡ y)) ↝⟨ (∀-cong ext λ _ → ∀-cong ext λ _ → For-iterated-equality-commutes-← ext F n hyp) ⟩
((x y : A) → F (For-iterated-equality n P (x ≡ y))) ↝⟨ (∀-cong ext λ _ → hyp) ⟩
((x : A) → F ((y : A) → For-iterated-equality n P (x ≡ y))) ↝⟨ hyp ⟩□
F ((x y : A) → For-iterated-equality n P (x ≡ y)) □
-- A variant of For-iterated-equality-commutes-←.
For-iterated-equality-commutesᴱ-← :
{@0 A : Type ℓ} {@0 P : Type ℓ → Type ℓ}
(@0 F : Type ℓ → Type ℓ) →
∀ n →
({@0 A : Type ℓ} {@0 P : A → Type ℓ} →
(∀ x → F (P x)) → F (∀ x → P x)) →
For-iterated-equality n (F ∘ P) A →
F (For-iterated-equality n P A)
For-iterated-equality-commutesᴱ-← _ zero _ = id
For-iterated-equality-commutesᴱ-← {A = A} {P = P} F (suc n) hyp =
((x y : A) → For-iterated-equality n (F ∘ P) (x ≡ y)) →⟨ For-iterated-equality-commutesᴱ-← F n hyp ∘_ ∘_ ⟩
((x y : A) → F (For-iterated-equality n P (x ≡ y))) →⟨ hyp ∘_ ⟩
((x : A) → F ((y : A) → For-iterated-equality n P (x ≡ y))) →⟨ hyp ⟩□
F ((x y : A) → For-iterated-equality n P (x ≡ y)) □
-- For-iterated-equality commutes with certain binary type
-- constructors (assuming extensionality).
For-iterated-equality-commutes₂ :
Extensionality? k ℓ ℓ →
(F : Type ℓ → Type ℓ → Type ℓ) →
∀ n →
({A : Type ℓ} {P Q : A → Type ℓ} →
F (∀ x → P x) (∀ x → Q x) ↝[ k ] ∀ x → F (P x) (Q x)) →
F (For-iterated-equality n P A) (For-iterated-equality n Q A) ↝[ k ]
For-iterated-equality n (λ A → F (P A) (Q A)) A
For-iterated-equality-commutes₂ _ _ zero _ = F.id
For-iterated-equality-commutes₂ {P = P} {A = A} {Q = Q}
ext F (suc n) hyp =
F ((x y : A) → For-iterated-equality n P (x ≡ y))
((x y : A) → For-iterated-equality n Q (x ≡ y)) ↝⟨ hyp ⟩
((x : A) → F ((y : A) → For-iterated-equality n P (x ≡ y))
((y : A) → For-iterated-equality n Q (x ≡ y))) ↝⟨ (∀-cong ext λ _ → hyp) ⟩
((x y : A) → F (For-iterated-equality n P (x ≡ y))
(For-iterated-equality n Q (x ≡ y))) ↝⟨ (∀-cong ext λ _ → ∀-cong ext λ _ →
For-iterated-equality-commutes₂ ext F n hyp) ⟩□
((x y : A) → For-iterated-equality n (λ A → F (P A) (Q A)) (x ≡ y)) □
-- A variant of For-iterated-equality-commutes₂.
For-iterated-equality-commutes₂ᴱ-→ :
{@0 A : Type ℓ} {@0 P Q : Type ℓ → Type ℓ}
(@0 F : Type ℓ → Type ℓ → Type ℓ) →
∀ n →
({@0 A : Type ℓ} {@0 P Q : A → Type ℓ} →
F (∀ x → P x) (∀ x → Q x) → ∀ x → F (P x) (Q x)) →
F (For-iterated-equality n P A) (For-iterated-equality n Q A) →
For-iterated-equality n (λ A → F (P A) (Q A)) A
For-iterated-equality-commutes₂ᴱ-→ _ zero _ = id
For-iterated-equality-commutes₂ᴱ-→ {A = A} {P = P} {Q = Q}
F (suc n) hyp =
F ((x y : A) → For-iterated-equality n P (x ≡ y))
((x y : A) → For-iterated-equality n Q (x ≡ y)) →⟨ hyp ⟩
((x : A) → F ((y : A) → For-iterated-equality n P (x ≡ y))
((y : A) → For-iterated-equality n Q (x ≡ y))) →⟨ hyp ∘_ ⟩
((x y : A) → F (For-iterated-equality n P (x ≡ y))
(For-iterated-equality n Q (x ≡ y))) →⟨ For-iterated-equality-commutes₂ᴱ-→ F n hyp ∘_ ∘_ ⟩□
((x y : A) → For-iterated-equality n (λ A → F (P A) (Q A)) (x ≡ y)) □
-- Another variant of For-iterated-equality-commutes₂.
For-iterated-equality-commutes₂-← :
Extensionality? k ℓ ℓ →
(F : Type ℓ → Type ℓ → Type ℓ) →
∀ n →
({A : Type ℓ} {P Q : A → Type ℓ} →
(∀ x → F (P x) (Q x)) ↝[ k ] F (∀ x → P x) (∀ x → Q x)) →
For-iterated-equality n (λ A → F (P A) (Q A)) A ↝[ k ]
F (For-iterated-equality n P A) (For-iterated-equality n Q A)
For-iterated-equality-commutes₂-← _ _ zero _ = F.id
For-iterated-equality-commutes₂-← {P = P} {Q = Q} {A = A}
ext F (suc n) hyp =
((x y : A) → For-iterated-equality n (λ A → F (P A) (Q A)) (x ≡ y)) ↝⟨ (∀-cong ext λ _ → ∀-cong ext λ _ →
For-iterated-equality-commutes₂-← ext F n hyp) ⟩
((x y : A) → F (For-iterated-equality n P (x ≡ y))
(For-iterated-equality n Q (x ≡ y))) ↝⟨ (∀-cong ext λ _ → hyp) ⟩
((x : A) → F ((y : A) → For-iterated-equality n P (x ≡ y))
((y : A) → For-iterated-equality n Q (x ≡ y))) ↝⟨ hyp ⟩□
F ((x y : A) → For-iterated-equality n P (x ≡ y))
((x y : A) → For-iterated-equality n Q (x ≡ y)) □
-- A variant of For-iterated-equality-commutes₂-←.
For-iterated-equality-commutes₂ᴱ-← :
{@0 A : Type ℓ} {@0 P Q : Type ℓ → Type ℓ}
(@0 F : Type ℓ → Type ℓ → Type ℓ) →
∀ n →
({@0 A : Type ℓ} {@0 P Q : A → Type ℓ} →
(∀ x → F (P x) (Q x)) → F (∀ x → P x) (∀ x → Q x)) →
For-iterated-equality n (λ A → F (P A) (Q A)) A →
F (For-iterated-equality n P A) (For-iterated-equality n Q A)
For-iterated-equality-commutes₂ᴱ-← _ zero _ = id
For-iterated-equality-commutes₂ᴱ-← {A = A} {P = P} {Q = Q}
F (suc n) hyp =
((x y : A) → For-iterated-equality n (λ A → F (P A) (Q A)) (x ≡ y)) →⟨ For-iterated-equality-commutes₂ᴱ-← F n hyp ∘_ ∘_ ⟩
((x y : A) → F (For-iterated-equality n P (x ≡ y))
(For-iterated-equality n Q (x ≡ y))) →⟨ hyp ∘_ ⟩
((x : A) → F ((y : A) → For-iterated-equality n P (x ≡ y))
((y : A) → For-iterated-equality n Q (x ≡ y))) →⟨ hyp ⟩□
F ((x y : A) → For-iterated-equality n P (x ≡ y))
((x y : A) → For-iterated-equality n Q (x ≡ y)) □
-- A corollary of For-iterated-equality-commutes₂.
For-iterated-equality-commutes-× :
{A : Type a} →
∀ n →
For-iterated-equality n P A × For-iterated-equality n Q A ↝[ a ∣ a ]
For-iterated-equality n (λ A → P A × Q A) A
For-iterated-equality-commutes-× n ext =
For-iterated-equality-commutes₂ ext _×_ n
(from-isomorphism $ inverse ΠΣ-comm)
-- Some corollaries of For-iterated-equality-commutes₂ᴱ-→.
For-iterated-equality-commutesᴱ-×-→ :
{@0 A : Type ℓ} {@0 P Q : Type ℓ → Type ℓ} →
∀ n →
For-iterated-equality n P A × For-iterated-equality n Q A →
For-iterated-equality n (λ A → P A × Q A) A
For-iterated-equality-commutesᴱ-×-→ n =
For-iterated-equality-commutes₂ᴱ-→ _×_ n
(λ (f , g) x → f x , g x)
For-iterated-equality-commutes-⊎ :
{@0 A : Type ℓ} {@0 P Q : Type ℓ → Type ℓ} →
∀ n →
For-iterated-equality n P A ⊎ For-iterated-equality n Q A →
For-iterated-equality n (λ A → P A ⊎ Q A) A
For-iterated-equality-commutes-⊎ n =
For-iterated-equality-commutes₂ᴱ-→ _⊎_ n
[ (λ f x → inj₁ (f x)) , (λ f x → inj₂ (f x)) ]
| {
"alphanum_fraction": 0.495924331,
"avg_line_length": 41.9483870968,
"ext": "agda",
"hexsha": "9c377d872563096bdbb90aa74aaf7d21d349c333",
"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": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/equality",
"max_forks_repo_path": "src/For-iterated-equality.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"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/equality",
"max_issues_repo_path": "src/For-iterated-equality.agda",
"max_line_length": 148,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/equality",
"max_stars_repo_path": "src/For-iterated-equality.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z",
"num_tokens": 10321,
"size": 26008
} |
{-# OPTIONS --sized-types --without-K #-}
module DepM where
open import Level using (Level)
open import Data.Product
open import Data.Nat
open import Data.Fin
open import Data.Unit
open import Data.Empty
open import Data.Vec hiding (_∈_; [_])
open import Relation.Binary.PropositionalEquality
open import Function
open import Data.Sum
open import Size
Fam : Set → Set₁
Fam I = I → Set
Fam₂ : {I : Set} → (I → Set) → Set₁
Fam₂ {I} J = (i : I) → J i → Set
-- | Morphisms between families
MorFam : {I : Set} (P₁ P₂ : Fam I) → Set
MorFam {I} P₁ P₂ = (x : I) → P₁ x → P₂ x
_⇒_ = MorFam
compMorFam : {I : Set} {P₁ P₂ P₃ : Fam I} →
MorFam P₁ P₂ → MorFam P₂ P₃ → MorFam P₁ P₃
compMorFam f₁ f₂ a = f₂ a ∘ f₁ a
_⊚_ = compMorFam
-- | Reindexing of families
_* : {I J : Set} → (I → J) → Fam J → Fam I
(u *) P = P ∘ u
-- | Reindexing on morphisms of families
_*₁ : {I J : Set} → (u : I → J) →
{P₁ P₂ : Fam J} → (P₁ ⇒ P₂) → (u *) P₁ ⇒ (u *) P₂
(u *₁) f i = f (u i)
-- | This notation for Π-types is more useful for our purposes here.
Π : (A : Set) (P : Fam A) → Set
Π A P = (x : A) → P x
-- | Fully general Σ-type, which we need to interpret the interpretation
-- of families of containers as functors for inductive types.
data Σ' {A B : Set} (f : A → B) (P : Fam A) : B → Set where
ins : (a : A) → P a → Σ' f P (f a)
p₁' : {A B : Set} {u : A → B} {P : Fam A} {b : B} →
Σ' u P b → A
p₁' (ins a _) = a
p₂' : {A B : Set} {u : A → B} {P : Fam A} {b : B} →
(x : Σ' u P b) → P (p₁' x)
p₂' (ins _ x) = x
p₌' : {A B : Set} {u : A → B} {P : Fam A} {b : B} →
(x : Σ' u P b) → u (p₁' x) ≡ b
p₌' (ins _ _) = refl
ins' : {A B : Set} {u : A → B} {P : Fam A} →
(a : A) → (b : B) → u a ≡ b → P a → Σ' u P b
ins' a ._ refl x = ins a x
Σ'-eq : {A B : Set} {f : A → B} {P : Fam A} →
(a a' : A) (x : P a) (x' : P a')
(a≡a' : a ≡ a') (x≡x' : subst P a≡a' x ≡ x') →
subst (Σ' f P) (cong f a≡a') (ins a x) ≡ ins a' x'
Σ'-eq a .a x .x refl refl = refl
Σ-eq : {a b : Level} {A : Set a} {B : A → Set b} →
(a a' : A) (x : B a) (x' : B a')
(a≡a' : a ≡ a') (x≡x' : subst B a≡a' x ≡ x') →
(a , x) ≡ (a' , x')
Σ-eq a .a x .x refl refl = refl
×-eq : {ℓ : Level} {A : Set ℓ} {B : Set ℓ} →
(a a' : A) (b b' : B) →
a ≡ a' → b ≡ b' → (a , b) ≡ (a' , b')
×-eq a .a b .b refl refl = refl
×-eqˡ : {A B : Set} {a a' : A} {b b' : B} → (a , b) ≡ (a' , b') → a ≡ a'
×-eqˡ refl = refl
×-eqʳ : {A B : Set} {a a' : A} {b b' : B} → (a , b) ≡ (a' , b') → b ≡ b'
×-eqʳ refl = refl
-- | Comprehension
⟪_⟫ : {I : Set} → Fam I → Set
⟪_⟫ {I} B = Σ I B
⟪_⟫² : {I J : Set} → (J → Fam I) → Fam J
⟪_⟫² {I} B j = Σ I (B j)
π : {I : Set} → (B : Fam I) → ⟪ B ⟫ → I
π B = proj₁
_⊢₁_ : {I : Set} {A : Fam I} → (i : I) → A i → ⟪ A ⟫
i ⊢₁ a = (i , a)
_,_⊢₂_ : {I : Set} {A : Fam I} {B : Fam ⟪ A ⟫} →
(i : I) → (a : A i) → B (i , a) → ⟪ B ⟫
i , a ⊢₂ b = ((i , a) , b)
-- Not directly definable...
-- record Π' {A B : Set} (u : A → B) (P : A → Set) : B → Set where
-- field
-- app : (a : A) → Π' u P (u a) → P a
-- | ... but this does the job.
Π' : {I J : Set} (u : I → J) (P : Fam I) → Fam J
Π' {I} u P j = Π (∃ λ i → u i ≡ j) (λ { (i , _) → P i})
Π'' : {I J : Set} (u : I → J) (j : J) (P : Fam (∃ λ i → u i ≡ j)) → Set
Π'' {I} u j P = Π (∃ λ i → u i ≡ j) P
-- | Application for fully general Π-types.
app : {I J : Set} {u : I → J} {P : Fam I} →
(u *) (Π' u P) ⇒ P
app i f = f (i , refl)
-- | Abstraction for fully general Π-types.
abs : {I J : Set} {u : I → J} {P : Fam I} →
((i : I) → P i) → ((j : J) → Π' u P j)
abs {u = u} f .(u i) (i , refl) = f i
-- | Abstraction for fully general Π-types.
abs' : {I J : Set} {u : I → J} {P : Fam I} {X : Fam J} →
((u *) X ⇒ P) → (X ⇒ Π' u P)
abs' {u = u} f .(u i) x (i , refl) = f i x
-- | Abstraction for fully general Π-types.
abs'' : {I J : Set} {u : I → J} {P : Fam I} →
(j : J) → ((i : I) → u i ≡ j → P i) → Π' u P j
abs'' j f (i , p) = f i p
abs₃ : {I J : Set} {u : I → J} (j : J) {P : Fam (Σ I (λ i → u i ≡ j))} →
((i : I) → (p : u i ≡ j) → P (i , p)) → Π'' u j P
abs₃ j f (i , p) = f i p
-- | Functorial action of Π'
Π'₁ : {I J : Set} {u : I → J} {P Q : Fam I} →
(f : P ⇒ Q) → (Π' u P ⇒ Π' u Q)
Π'₁ {u = u} f .(u i) g (i , refl) = f i (app i g)
-- | Dependent polynomials
record DPoly
{I : Set} -- ^ Outer index
{J : Set} -- ^ Inner index
: Set₁ where
constructor dpoly
field
-- J ←t- E -p→ A -s→ I
A : Set -- ^ Labels
s : A → I
E : Set
p : E → A
t : E → J
-- | Interpretation of polynomial as functor
⟦_⟧ : {I : Set} {J : Set} →
DPoly {I} {J} →
(X : Fam J) → -- ^ Parameter
(Fam I)
⟦_⟧ {I} {N} (dpoly A s E p t) X =
Σ' s (λ a →
Π' p (λ e →
X (t e)
) a )
-- | Functorial action of T
⟦_⟧₁ : {I : Set} {J : Set} →
(P : DPoly {I} {J}) →
{X Y : J → Set} →
(f : (j : J) → X j → Y j)
(i : I) → ⟦ P ⟧ X i → ⟦ P ⟧ Y i
⟦_⟧₁ {I} {J} (dpoly A s E p t) {X} {Y} f .(s a) (ins a v) =
ins a (Π'₁ ((t *₁) f) a v)
-- | Final coalgebras for dependent polynomials
record M {a : Size} {I} (P : DPoly {I} {I}) (i : I) : Set where
coinductive
field
ξ : ∀ {b : Size< a} → ⟦ P ⟧ (M {b} P) i
open M
ξ' : ∀ {I P} → {i : I} → M P i → ⟦ P ⟧ (M P) i
ξ' x = ξ x
Rel₂ : {I : Set} → (X Y : I → Set) → Set₁
Rel₂ {I} X Y = (i : I) → X i → Y i → Set
-- | Lifting to relations
⟦_⟧'' : ∀ {I} (P : DPoly {I} {I}) {X Y} → Rel₂ X Y → Rel₂ (⟦ P ⟧ X) (⟦ P ⟧ Y)
⟦ dpoly A s E p t ⟧'' {X} {Y} R i x y =
∃ λ a → ∃ λ α → ∃ λ β → Σ[ q ∈ (i ≡ s a) ]
(subst (⟦ dpoly A s E p t ⟧ X) q x ≡ ins a α
× (subst (⟦ dpoly A s E p t ⟧ Y) q y) ≡ ins a β
× ∀ u → R (t (proj₁ u)) (α u) (β u))
[_]_≡₂_ : ∀{I} {X : I → Set} → Rel₂ X X
[ i ] x ≡₂ y = x ≡ y
eq-preserving : ∀ {I P X} (i : I) (x y : ⟦ P ⟧ X i) →
x ≡ y → ⟦ P ⟧'' (λ i → _≡_) i x y
eq-preserving i x y x≡y = {!!}
mutual
-- | Equality for M types is given by bisimilarity
record Bisim {I} {P : DPoly {I} {I}} (i : I) (x y : M P i) : Set where
coinductive
field
~pr : ⟦ P ⟧'' Bisim i (ξ' x) (ξ' y)
open Bisim public
| {
"alphanum_fraction": 0.4372244898,
"avg_line_length": 27.9680365297,
"ext": "agda",
"hexsha": "7c1fea9aabf445bcf5a708b5644777a4dd67865f",
"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/Container/DepM.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/Container/DepM.agda",
"max_line_length": 77,
"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/Container/DepM.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2984,
"size": 6125
} |
{-# OPTIONS --without-K --safe #-}
module Util.Vec where
open import Data.Vec public
open import Data.Vec.Relation.Unary.All as All public using (All ; [] ; _∷_)
open import Data.Vec.Relation.Unary.Any as Any public using (Any ; here ; there)
open import Data.Vec.Membership.Propositional public using (_∈_)
open import Data.Nat as ℕ using (_≤_)
open import Level using (_⊔_)
open import Relation.Binary using (Rel)
open import Util.Prelude
import Data.Nat.Properties as ℕ
max : ∀ {n} → Vec ℕ n → ℕ
max = foldr _ ℕ._⊔_ 0
max-weaken : ∀ {n} x (xs : Vec ℕ n) → max xs ≤ max (x ∷ xs)
max-weaken _ _ = ℕ.n≤m⊔n _ _
max-maximal : ∀ {n} (xs : Vec ℕ n) → All (_≤ max xs) xs
max-maximal [] = []
max-maximal (x ∷ xs)
= ℕ.m≤m⊔n _ _
∷ All.map (λ x≤max → ℕ.≤-trans x≤max (max-weaken x xs)) (max-maximal xs)
All→∈→P : ∀ {α β} {A : Set α} {P : A → Set β} {n} {xs : Vec A n}
→ All P xs
→ ∀ {x}
→ x ∈ xs
→ P x
All→∈→P (px ∷ allP) (here refl) = px
All→∈→P (px ∷ allP) (there x∈xs) = All→∈→P allP x∈xs
max-maximal-∈ : ∀ {n x} {xs : Vec ℕ n} → x ∈ xs → x ≤ max xs
max-maximal-∈ = All→∈→P (max-maximal _)
data All₂ {α} {A : Set α} {ρ} (R : Rel A ρ)
: ∀ {n} → Vec A n → Vec A n → Set (α ⊔ ρ) where
[] : All₂ R [] []
_∷_ : ∀ {n x y} {xs ys : Vec A n}
→ R x y
→ All₂ R xs ys
→ All₂ R (x ∷ xs) (y ∷ ys)
All₂-tabulate⁺ : ∀ {α} {A : Set α} {ρ} {R : Rel A ρ} {n} {f g : Fin n → A}
→ (∀ x → R (f x) (g x))
→ All₂ R (tabulate f) (tabulate g)
All₂-tabulate⁺ {n = zero} p = []
All₂-tabulate⁺ {n = suc n} p = p zero ∷ All₂-tabulate⁺ (λ x → p (suc x))
All₂-tabulate⁻ : ∀ {α} {A : Set α} {ρ} {R : Rel A ρ} {n} {f g : Fin n → A}
→ All₂ R (tabulate f) (tabulate g)
→ ∀ x → R (f x) (g x)
All₂-tabulate⁻ [] ()
All₂-tabulate⁻ (fzRgz ∷ all) zero = fzRgz
All₂-tabulate⁻ (fzRgz ∷ all) (suc x) = All₂-tabulate⁻ all x
| {
"alphanum_fraction": 0.5548880393,
"avg_line_length": 26.9264705882,
"ext": "agda",
"hexsha": "21a35f0732321cf595522119889a1247d8086286",
"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/Util/Vec.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/Util/Vec.agda",
"max_line_length": 80,
"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/Util/Vec.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": 799,
"size": 1831
} |
{-# OPTIONS --safe #-}
module Cubical.Functions.Implicit where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
implicit≃Explicit : ∀ {ℓ ℓ'} {A : Type ℓ} {B : A → Type ℓ'}
→ ({a : A} → B a) ≃ ((a : A) → B a)
implicit≃Explicit = isoToEquiv isom
where
isom : Iso _ _
Iso.fun isom f a = f
Iso.inv isom f = f _
Iso.rightInv isom f = funExt λ _ → refl
Iso.leftInv isom f = implicitFunExt refl
| {
"alphanum_fraction": 0.6757322176,
"avg_line_length": 26.5555555556,
"ext": "agda",
"hexsha": "a98a2d3a6599ae9865ec5d68cfe5016a214e8421",
"lang": "Agda",
"max_forks_count": 134,
"max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z",
"max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "marcinjangrzybowski/cubical",
"max_forks_repo_path": "Cubical/Functions/Implicit.agda",
"max_issues_count": 584,
"max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "marcinjangrzybowski/cubical",
"max_issues_repo_path": "Cubical/Functions/Implicit.agda",
"max_line_length": 59,
"max_stars_count": 301,
"max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "marcinjangrzybowski/cubical",
"max_stars_repo_path": "Cubical/Functions/Implicit.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z",
"num_tokens": 164,
"size": 478
} |
module hello-world-dep where
open import Data.Nat using (ℕ; zero; suc)
data Vec (A : Set) : ℕ → Set where
[] : Vec A zero
_∷_ : ∀ {n} (x : A) (xs : Vec A n) → Vec A (suc n)
infixr 5 _∷_
| {
"alphanum_fraction": 0.5721649485,
"avg_line_length": 19.4,
"ext": "agda",
"hexsha": "d6ab1df4c839fb2531f7a66cd08a2c78b280d4d8",
"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": "3f6ea9a742135007ccb2b5f820147a7fc9472b9d",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "avieor/agda-demos",
"max_forks_repo_path": "hello-world-dep.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3f6ea9a742135007ccb2b5f820147a7fc9472b9d",
"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": "avieor/agda-demos",
"max_issues_repo_path": "hello-world-dep.agda",
"max_line_length": 52,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "3f6ea9a742135007ccb2b5f820147a7fc9472b9d",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "avieor/agda-demos",
"max_stars_repo_path": "hello-world-dep.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 81,
"size": 194
} |
{-# OPTIONS --without-K #-}
open import Base
module Homotopy.PushoutDef where
record pushout-diag (i : Level) : Set (suc i) where
constructor diag_,_,_,_,_
field
A : Set i
B : Set i
C : Set i
f : C → A
g : C → B
pushout-diag-raw-eq : ∀ {i} {A A' : Set i} (p : A ≡ A')
{B B' : Set i} (q : B ≡ B') {C C' : Set i} (r : C ≡ C')
{f : C → A} {f' : C' → A'} (s : f' ◯ transport _ r ≡ transport _ p ◯ f)
{g : C → B} {g' : C' → B'} (t : transport _ q ◯ g ≡ g' ◯ transport _ r)
→ (diag A , B , C , f , g) ≡ (diag A' , B' , C' , f' , g')
pushout-diag-raw-eq refl refl refl refl refl = refl
pushout-diag-eq : ∀ {i} {A A' : Set i} (p : A ≃ A')
{B B' : Set i} (q : B ≃ B') {C C' : Set i} (r : C ≃ C')
{f : C → A} {f' : C' → A'} (s : (a : C) → f' (π₁ r a) ≡ (π₁ p) (f a))
{g : C → B} {g' : C' → B'} (t : (b : C) → (π₁ q) (g b) ≡ g' (π₁ r b))
→ (diag A , B , C , f , g) ≡ (diag A' , B' , C' , f' , g')
pushout-diag-eq p q r {f} {f'} s {g} {g'} t = pushout-diag-raw-eq
(eq-to-path p)
(eq-to-path q)
(eq-to-path r)
(funext (λ a → ap f' (trans-id-eq-to-path r a)
∘ (s a ∘ ! (trans-id-eq-to-path p (f a)))))
(funext (λ b → trans-id-eq-to-path q (g b)
∘ (t b ∘ ap g' (! (trans-id-eq-to-path r b)))))
module Pushout {i} {d : pushout-diag i} where
open pushout-diag d
private
data #pushout : Set i where
#left : A → #pushout
#right : B → #pushout
pushout : Set _
pushout = #pushout
left : A → pushout
left = #left
right : B → pushout
right = #right
postulate -- HIT
glue : (c : C) → left (f c) ≡ right (g c)
pushout-rec : ∀ {l} (P : pushout → Set l) (left* : (a : A) → P (left a))
(right* : (b : B) → P (right b))
(glue* : (c : C) → transport P (glue c) (left* (f c)) ≡ right* (g c))
→ (x : pushout) → P x
pushout-rec P left* right* glue* (#left y) = left* y
pushout-rec P left* right* glue* (#right y) = right* y
postulate -- HIT
pushout-β-glue : ∀ {l} (P : pushout → Set l) (left* : (a : A) → P (left a))
(right* : (b : B) → P (right b))
(glue* : (c : C) → transport P (glue c) (left* (f c)) ≡ right* (g c))
(c : C)
→ apd (pushout-rec {l} P left* right* glue*) (glue c) ≡ glue* c
pushout-rec-nondep : ∀ {l} (D : Set l) (left* : A → D) (right* : B → D)
(glue* : (c : C) → left* (f c) ≡ right* (g c)) → (pushout → D)
pushout-rec-nondep D left* right* glue* (#left y) = left* y
pushout-rec-nondep D left* right* glue* (#right y) = right* y
postulate -- HIT
pushout-β-glue-nondep : ∀ {l} (D : Set l) (left* : A → D) (right* : B → D)
(glue* : (c : C) → left* (f c) ≡ right* (g c)) (c : C)
→ ap (pushout-rec-nondep D left* right* glue*) (glue c) ≡ glue* c
open Pushout public hiding (pushout)
pushout : ∀ {i} (d : pushout-diag i) → Set i
pushout d = Pushout.pushout {_} {d}
| {
"alphanum_fraction": 0.4848800834,
"avg_line_length": 33.4534883721,
"ext": "agda",
"hexsha": "f1821c1c21491bf5a630d268d7b35abfb9e072bb",
"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": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nicolaikraus/HoTT-Agda",
"max_forks_repo_path": "old/Homotopy/PushoutDef.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"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": "nicolaikraus/HoTT-Agda",
"max_issues_repo_path": "old/Homotopy/PushoutDef.agda",
"max_line_length": 79,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda",
"max_stars_repo_path": "old/Homotopy/PushoutDef.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": 1228,
"size": 2877
} |
-- {-# OPTIONS -v tc.term.exlam:100 -v extendedlambda:100 -v int2abs.reifyterm:100 -v tc.with:100 -v tc.mod.apply:100 #-}
module Issue778b (Param : Set) where
open import Issue778M Param
data D : (Nat → Nat) → Set where
d : D pred → D pred
-- Ulf, 2013-11-11: With the fix to issue 59 that inlines with functions,
-- this no longer termination checks. The problem is having a termination
-- path going through a with-expression (the variable x in this case).
{-# TERMINATING #-}
test : (f : Nat → Nat) → D f → Nat
test .pred (d x) = bla
where bla : Nat
bla with (d x) -- Andreas, 2014-11-06 "with x" has been outlawed.
... | (d (d y)) = test pred y
| {
"alphanum_fraction": 0.6523031204,
"avg_line_length": 37.3888888889,
"ext": "agda",
"hexsha": "4493bbede19e56f291ef8581e0d553b16ec530de",
"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": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "test/Succeed/Issue778b.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"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": "redfish64/autonomic-agda",
"max_issues_repo_path": "test/Succeed/Issue778b.agda",
"max_line_length": 121,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/Succeed/Issue778b.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 211,
"size": 673
} |
{-# OPTIONS --exact-split #-}
module ExactSplitParity where
data Bool : Set where
true false : Bool
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
parity : ℕ → ℕ → Bool
parity zero zero = true
parity zero (suc zero) = false
parity zero (suc (suc n)) = parity zero n
parity (suc zero) zero = false
parity (suc (suc m)) zero = parity m zero
parity (suc m) (suc n) = parity m n
| {
"alphanum_fraction": 0.5498891353,
"avg_line_length": 23.7368421053,
"ext": "agda",
"hexsha": "906b4b79abb4f93731d0172ac8acb87ff8b08c14",
"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/Fail/ExactSplitParity.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/Fail/ExactSplitParity.agda",
"max_line_length": 50,
"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/Fail/ExactSplitParity.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": 134,
"size": 451
} |
module Data.Fin.Subset.Disjoint.Properties where
open import Data.Nat
open import Data.Vec as Vec hiding (_++_; _∈_)
open import Data.List as List hiding (zipWith; foldr)
open import Data.Bool
open import Data.Bool.Properties
open import Data.Product
open import Data.Sum
open import Data.Empty hiding (⊥)
open import Relation.Binary.PropositionalEquality
open import Data.Fin hiding (_-_)
open import Data.Fin.Subset
open import Data.Fin.Subset.Properties
open import Data.Fin.Subset.Disjoint
module _ where
_-_ : ∀ {n} → (l r : Subset n) → Subset n
l - r = zipWith _⊝_ l r
module Subtract where
_⊝_ = (λ l r → if r then false else l)
q-p∪p : ∀ {n}{p q : Subset n} → q ⊆ p → (p - q) ∪ q ≡ p
q-p∪p {p = []} {[]} s = refl
q-p∪p {p = x ∷ p} {outside ∷ q} s rewrite ∨-identityʳ x =
cong₂ _∷_ refl (q-p∪p (drop-∷-⊆ s))
q-p∪p {p = outside ∷ p} {true ∷ q} s with s here
... | ()
q-p∪p {p = true ∷ p} {true ∷ q} s = cong₂ _∷_ refl (q-p∪p (drop-∷-⊆ s))
⊆-∪-cong : ∀ {n}{x y x' y' : Subset n} → x ⊆ x' → y ⊆ y' → (x ∪ y) ⊆ (x' ∪ y')
⊆-∪-cong p q t with x∈p∪q⁻ _ _ t
... | inj₁ z = p⊆p∪q _ (p z)
... | inj₂ z = q⊆p∪q _ _ (q z)
-- properties of disjoint subsets x ◆ y
module _ where
◆-tail : ∀ {n} x y {xs ys : Subset n} → (x ∷ xs) ◆ (y ∷ ys) → xs ◆ ys
◆-tail _ _ p (x , x∈xs) = p (suc x , there x∈xs)
◆-comm : ∀ {n} {x y : Subset n} → x ◆ y → y ◆ x
◆-comm {x = x}{y} = subst Empty (∩-comm x y)
◆-⊆-left : ∀ {n}{x y z : Subset n} → x ⊆ y → y ◆ z → x ◆ z
◆-⊆-left w d (e , e∈x∩z) = let (e∈x , e∈z) = (x∈p∩q⁻ _ _ e∈x∩z) in d (e , x∈p∩q⁺ ((w e∈x) , e∈z))
◆-⊆-right : ∀ {n}{x y z : Subset n} → x ⊆ z → y ◆ z → y ◆ x
◆-⊆-right w d = ◆-comm (◆-⊆-left w (◆-comm d))
◆-∉ : ∀ {n}{x y : Subset n}{i} → x ◆ y → i ∈ x → i ∉ y
◆-∉ {y = outside ∷ y} p here = λ ()
◆-∉ {y = inside ∷ y} p here = λ _ → p (zero , here)
◆-∉ {y = _ ∷ ys} p (there {y = y} q) (there z) =
◆-∉ (λ where (i , i∈ys) → p (suc i , there i∈ys)) q z
⊆-◆ : ∀ {n}{x y z : Subset n} → x ⊆ y → x ◆ z → x ⊆ y - z
⊆-◆ {x = .(true ∷ _)} {_ ∷ _} {outside ∷ zs} p x◆z here with p here
... | here = here
⊆-◆ {x = .(true ∷ _)} {_ ∷ _} {inside ∷ zs} p x◆z here = ⊥-elim (◆-∉ x◆z here here)
⊆-◆ {x = .(_ ∷ _)} {y ∷ ys} {z ∷ zs} p x◆z (there i∈x) =
there (⊆-◆ (drop-∷-⊆ p) (◆-tail _ z x◆z) i∈x)
◆-∪ : ∀ {n}{x y z : Subset n} → x ◆ y → x ◆ z → x ◆ (y ∪ z)
◆-∪ x◆y x◆z (i , i∈x∩y∪z) with x∈p∪q⁻ _ _ (proj₂ (x∈p∩q⁻ _ _ i∈x∩y∪z))
... | inj₁ i∈y = x◆y (i , (x∈p∩q⁺ (proj₁ (x∈p∩q⁻ _ _ i∈x∩y∪z) , i∈y)))
... | inj₂ i∈z = x◆z (i , (x∈p∩q⁺ (proj₁ (x∈p∩q⁻ _ _ i∈x∩y∪z) , i∈z)))
◆-- : ∀ {n}(x y : Subset n) → x ◆ (y - x)
◆-- xs ys (zero , p) with x∈p∩q⁻ _ _ p
◆-- (.true ∷ _) (outside ∷ _) (zero , p) | here , ()
◆-- (.true ∷ _) (true ∷ _) (zero , p) | here , ()
◆-- (_ ∷ xs) (_ ∷ ys) (suc e , there p) = ◆-- xs ys (e , p)
◆-⊥ : ∀ {n} {x : Subset n} → x ◆ ⊥
◆-⊥ (i , snd) = ∉⊥ (subst (λ s → i ∈ s) (proj₂ ∩-zero _) snd)
-- properties of disjoint unions z of xs (xs ⨄ z)
module _ where
-- append for disjoint disjoint-unions of subsets
++-⨄ : ∀ {n}{xs ys}{x y : Subset n} → xs ⨄ x → ys ⨄ y → (x ◆ y) → (xs ++ ys) ⨄ (x ∪ y)
++-⨄ {x = x}{y} [] q d rewrite ∪-identityˡ y = q
++-⨄ {y = y} (_∷_ {x = x}{z} x◆z xs⊎y) ys⊎z x∪z⊎y rewrite ∪-assoc x z y =
(◆-∪ x◆z (◆-⊆-left (p⊆p∪q z) x∪z⊎y)) ∷ (++-⨄ xs⊎y ys⊎z (◆-⊆-left (q⊆p∪q x z) x∪z⊎y))
⨄-trans : ∀ {n}{xs ys}{x y : Subset n} → xs ⨄ x → (x ∷ ys) ⨄ y → (xs ++ ys) ⨄ (x ∪ y)
⨄-trans {x = x}{y} xs▰x (_∷_ {y = z} x◆y ys▰y) rewrite sym (∪-assoc x x z) =
subst (λ x → _ ⨄ (x ∪ z)) (sym (∪-idem x)) (++-⨄ xs▰x ys▰y x◆y)
| {
"alphanum_fraction": 0.4672742336,
"avg_line_length": 39.3586956522,
"ext": "agda",
"hexsha": "d134a1de2f7df1aba67c1e3b5685f38783562600",
"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/Fin/Subset/Disjoint/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/Fin/Subset/Disjoint/Properties.agda",
"max_line_length": 99,
"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/Fin/Subset/Disjoint/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": 1966,
"size": 3621
} |
------------------------------------------------------------------------------
-- The FOTC streams of total natural numbers type
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- N.B. This module is re-exported by FOTC.Data.Stream.
module FOT.FOTC.Data.Nat.Stream.Type where
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Data.Nat.Type
------------------------------------------------------------------------------
-- The FOTC streams type (co-inductive predicate for total streams).
-- Functional for the StreamN predicate.
-- StreamNF : (D → Set) → D → Set
-- StreamNF P ns = ∃[ n' ] ∃[ ns' ] N n' ∧ P ns' ∧ ns ≡ n' ∷ ns'
-- Stream is the greatest fixed-point of StreamF (by Stream-out and
-- Stream-coind).
postulate StreamN : D → Set
postulate
-- StreamN is a post-fixed point of StreamNF, i.e.
--
-- StreamN ≤ StreamNF StreamN.
StreamN-out : ∀ {ns} → StreamN ns →
∃[ n' ] ∃[ ns' ] N n' ∧ StreamN ns' ∧ ns ≡ n' ∷ ns'
{-# ATP axiom StreamN-out #-}
-- StreamN is the greatest post-fixed point of StreamNF, i.e.
--
-- ∀ P. P ≤ StreamNF P ⇒ P ≤ StreamN.
--
-- N.B. This is an axiom schema. Because in the automatic proofs we
-- *must* use an instance, we do not add this postulate as an ATP
-- axiom.
postulate
StreamN-coind :
∀ (A : D → Set) {ns} →
-- A is post-fixed point of StreamNF.
(A ns → ∃[ n' ] ∃[ ns' ] N n' ∧ A ns' ∧ ns ≡ n' ∷ ns') →
-- StreamN is greater than A.
A ns → StreamN ns
-- Because a greatest post-fixed point is a fixed-point, then the
-- StreamN predicate is also a pre-fixed point of the functional
-- StreamNF, i.e.
--
-- StreamNF StreamN ≤ StreamN.
StreamN-in : ∀ {ns} →
∃[ n' ] ∃[ ns' ] N n' ∧ StreamN ns' ∧ ns ≡ n' ∷ ns' →
StreamN ns
StreamN-in {ns} h = StreamN-coind A h' h
where
A : D → Set
A ns = ∃[ n' ] ∃[ ns' ] N n' ∧ StreamN ns' ∧ ns ≡ n' ∷ ns'
h' : A ns → ∃[ n' ] ∃[ ns' ] N n' ∧ A ns' ∧ ns ≡ n' ∷ ns'
h' (_ , _ , Nn' , SNns' , prf) = _ , _ , Nn' , (StreamN-out SNns') , prf
| {
"alphanum_fraction": 0.514619883,
"avg_line_length": 32.6911764706,
"ext": "agda",
"hexsha": "39b954bb8596d00d37af8282d318962ef7498f20",
"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/Nat/Stream/Type.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/Nat/Stream/Type.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/Nat/Stream/Type.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": 677,
"size": 2223
} |
{-# OPTIONS --without-K --safe #-}
module Data.Bool.Truth where
open import Data.Empty
open import Data.Unit
open import Level
open import Data.Bool.Base
T : Bool → Type
T true = ⊤
T false = ⊥
| {
"alphanum_fraction": 0.6954314721,
"avg_line_length": 15.1538461538,
"ext": "agda",
"hexsha": "5e5b881e35232863c05deade2b1283c23ea8acb5",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-playground",
"max_forks_repo_path": "Data/Bool/Truth.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"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/agda-playground",
"max_issues_repo_path": "Data/Bool/Truth.agda",
"max_line_length": 34,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-playground",
"max_stars_repo_path": "Data/Bool/Truth.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z",
"num_tokens": 54,
"size": 197
} |
------------------------------------------------------------------------
-- Examples involving simple λ-calculi
------------------------------------------------------------------------
{-# OPTIONS --cubical --sized-types #-}
module README.Lambda where
------------------------------------------------------------------------
-- An untyped λ-calculus with constants
-- Some developments from "Operational Semantics Using the Partiality
-- Monad" by Danielsson, implemented using both the quotient
-- inductive-inductive partiality monad, and the delay monad.
--
-- These developments to a large extent mirror developments in
-- "Coinductive big-step operational semantics" by Leroy and Grall.
-- The syntax of, and a type system for, the untyped λ-calculus with
-- constants.
import Lambda.Syntax
-- Most of a virtual machine.
import Lambda.Virtual-machine
-- A compiler.
import Lambda.Compiler
-- A definitional interpreter.
import Lambda.Partiality-monad.Inductive.Interpreter
import Lambda.Delay-monad.Interpreter
-- A type soundness result.
import Lambda.Partiality-monad.Inductive.Type-soundness
import Lambda.Delay-monad.Type-soundness
-- A virtual machine.
import Lambda.Partiality-monad.Inductive.Virtual-machine
import Lambda.Delay-monad.Virtual-machine
-- Compiler correctness.
import Lambda.Partiality-monad.Inductive.Compiler-correctness
import Lambda.Delay-monad.Compiler-correctness
------------------------------------------------------------------------
-- An untyped λ-calculus without constants
-- A variant of the development above. The development above uses a
-- well-scoped variant of the untyped λ-calculus with constants. This
-- development does not use constants. This means that the interpreter
-- cannot crash, so the type soundness result has been omitted.
import Lambda.Simplified.Syntax
import Lambda.Simplified.Virtual-machine
import Lambda.Simplified.Compiler
import Lambda.Simplified.Partiality-monad.Inductive.Interpreter
import Lambda.Simplified.Delay-monad.Interpreter
import Lambda.Simplified.Partiality-monad.Inductive.Virtual-machine
import Lambda.Simplified.Delay-monad.Virtual-machine
import Lambda.Simplified.Partiality-monad.Inductive.Compiler-correctness
import Lambda.Simplified.Delay-monad.Compiler-correctness
| {
"alphanum_fraction": 0.7067603161,
"avg_line_length": 33.0144927536,
"ext": "agda",
"hexsha": "54c0675472d7b001d0685a0d2e7e7408c20fab68",
"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": "f69749280969f9093e5e13884c6feb0ad2506eae",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/partiality-monad",
"max_forks_repo_path": "README/Lambda.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae",
"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/partiality-monad",
"max_issues_repo_path": "README/Lambda.agda",
"max_line_length": 72,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "f69749280969f9093e5e13884c6feb0ad2506eae",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/partiality-monad",
"max_stars_repo_path": "README/Lambda.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:59:18.000Z",
"num_tokens": 442,
"size": 2278
} |
module powerset where
open import level
open import list
open import bool
open import product
open import empty
open import unit
open import sum
open import eq
open import functions renaming (id to id-set) public
-- Extensionality will be used when proving equivalences of morphisms.
postulate ext-set : ∀{l1 l2 : level} → extensionality {l1} {l2}
-- These are isomorphisms, but Agda has no way to prove these as
-- equivalences. They are consistent to adopt as equivalences by
-- univalence:
postulate ⊎-unit-r : ∀{X : Set} → (X ⊎ ⊥) ≡ X
postulate ⊎-unit-l : ∀{X : Set} → (⊥ ⊎ X) ≡ X
postulate ∧-unit : ∀{ℓ}{A : Set ℓ} → A ≡ ((⊤ {ℓ}) ∧ A)
postulate ∧-sym : ∀{ℓ}{A B : Set ℓ} → (A ∧ B) ≡ (B ∧ A)
postulate ∧-unit-r : ∀{ℓ}{A : Set ℓ} → A ≡ (A ∧ (⊤ {ℓ}))
postulate ∧-assoc : ∀{ℓ}{A B C : Set ℓ} → (A ∧ (B ∧ C)) ≡ ((A ∧ B) ∧ C)
ℙ : {X : Set} → (X → 𝔹) → Set
ℙ {X} S = (X → 𝔹) → 𝔹
_∪_ : {X : Set}{S : X → 𝔹} → ℙ S → ℙ S → ℙ S
(s₁ ∪ s₂) x = (s₁ x) || (s₂ x)
_∩_ : {X : Set}{S : X → 𝔹} → ℙ S → ℙ S → ℙ S
(s₁ ∩ s₂) x = (s₁ x) && (s₂ x)
_×S_ : {X Y : Set} → (S₁ : X → 𝔹) → (S₂ : Y → 𝔹) → (X × Y) → 𝔹
_×S_ S₁ S₂ (a , b) = (S₁ a) && (S₂ b)
π₁ : ∀{X Y : Set} → ((Σ X (λ x → Y) → 𝔹) → 𝔹) → ((X → 𝔹) → 𝔹)
π₁ P S = P (λ x → S (fst x))
π₂ : ∀{X Y : Set} → ((Σ X (λ x → Y) → 𝔹) → 𝔹) → ((Y → 𝔹) → 𝔹)
π₂ P S = P (λ x → S (snd x))
i₁ : {X Y : Set}{S₁ : X → 𝔹}{S₂ : Y → 𝔹} → ℙ S₁ → (((X × Y) → 𝔹) → 𝔹)
i₁ {X}{Y}{S₁}{S₂} P S = {!!}
i₂ : {X Y : Set}{S₁ : X → 𝔹}{S₂ : Y → 𝔹} → ℙ S₂ → ℙ (S₁ ×S S₂)
i₂ {X}{Y}{S₁}{S₂} P _ = P S₂
cp-ar : {X Y Z : Set}{S₁ : X → 𝔹}{S₂ : Y → 𝔹}{S₃ : Z → 𝔹} → (ℙ S₁ → ℙ S₃) → (ℙ S₂ → ℙ S₃) → ℙ (S₁ ×S S₂) → ℙ S₃
cp-ar {X}{Y}{Z}{S₁}{S₂}{S₃} f g P S = (f (π₁ P) S) || (g (π₂ P) S)
cp-diag₁ : {X Y Z : Set}{S₁ : X → 𝔹}{S₂ : Y → 𝔹}{S₃ : Z → 𝔹}{f : ℙ S₁ → ℙ S₃}{g : ℙ S₂ → ℙ S₃} → cp-ar {X}{Y}{Z}{S₁}{S₂}{S₃ = S₃} f g ∘ (i₁ {X}{Y}{S₁}{S₂}) ≡ f
cp-diag₁ {X}{Y}{Z}{S₁}{S₂}{S₃}{f}{g} = ext-set (λ {x} → ext-set (λ {S} → {!!}))
-- cp-diag₂ : {X Y Z : Set}{f : Z → X}{g : Z → Y} → cp-ar f g ∘ i₂ ≡ ℙₐ g
-- cp-diag₂ {X}{Y}{Z}{f}{g} = refl
-- co-curry : {A B C : Set} → ((A × B) → C) → ℙ (B → C) → ℙ A
-- co-curry {A}{B}{C} f = ℙₐ {A}{B → C} (curry f)
-- co-uncurry : {A B C : Set} → (A → B → C) → ℙ C → ℙ (A × B)
-- co-uncurry {A}{B}{C} f = ℙₐ {A × B} {C} (uncurry f)
-- liftℙ : {A B : Set} → (A → ℙ B) → ℙ A → ℙ B
-- liftℙ {A} f s b = ∀(a : A) → (s a) × (f a b)
| {
"alphanum_fraction": 0.45898191,
"avg_line_length": 36.0151515152,
"ext": "agda",
"hexsha": "a3b82bcb99a4341b54781e26331f65237219e9b0",
"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": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "heades/AUGL",
"max_forks_repo_path": "power-set-algebra/powerset.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"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": "heades/AUGL",
"max_issues_repo_path": "power-set-algebra/powerset.agda",
"max_line_length": 159,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "heades/AUGL",
"max_stars_repo_path": "power-set-algebra/powerset.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1297,
"size": 2377
} |
module Numeral.Integer.Relation.Order where
open import Functional
import Lvl
import Numeral.Natural.Relation.Order as ℕ
open import Numeral.Integer
open import Numeral.Integer.Oper
open import Relator.Ordering
open import Type
-- Inequalities/Comparisons
data _≤_ : ℤ → ℤ → Type{Lvl.𝟎} where
neg-neg : ∀{a b} → (a ℕ.≤ b) → (−𝐒ₙ(b)) ≤ (−𝐒ₙ(a))
neg-pos : ∀{a b} → (−𝐒ₙ(a)) ≤ (+ₙ b)
pos-pos : ∀{a b} → (a ℕ.≤ b) → (+ₙ a) ≤ (+ₙ b)
_<_ : ℤ → ℤ → Type
_<_ = (_≤_) ∘ 𝐒
open From-[≤][<] (_≤_)(_<_) public
module _ where
open import Structure.Relator.Properties
instance
[≤][−𝐒ₙ]-sub : (swap(_≤_) on₂ (−𝐒ₙ_)) ⊆₂ (ℕ._≤_)
_⊆₂_.proof [≤][−𝐒ₙ]-sub (neg-neg p) = p
instance
[≤][+ₙ]-sub : ((_≤_) on₂ (+ₙ_)) ⊆₂ (ℕ._≤_)
_⊆₂_.proof [≤][+ₙ]-sub (pos-pos p) = p
| {
"alphanum_fraction": 0.5759493671,
"avg_line_length": 24.6875,
"ext": "agda",
"hexsha": "69422c66b1f82f49aa0f6ab04f019b3f699af8a5",
"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": "Numeral/Integer/Relation/Order.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": "Numeral/Integer/Relation/Order.agda",
"max_line_length": 52,
"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": "Numeral/Integer/Relation/Order.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": 367,
"size": 790
} |
module Data.Real.Base where
import Prelude
import Data.Rational
import Data.Nat as Nat
import Data.Bits
import Data.Bool
import Data.Maybe
import Data.Integer
import Data.List
import Data.Real.Gauge
open Prelude
open Data.Rational hiding (_-_; !_!)
open Data.Bits
open Data.Bool
open Data.List
open Data.Integer
hiding (-_; _+_; _≥_; _≤_; _>_; _<_; _==_)
renaming ( _*_ to _*'_ )
open Nat using (Nat; zero; suc)
open Data.Real.Gauge using (Gauge)
Base = Rational
bitLength : Int -> Int
bitLength x = pos (nofBits ! x !) - pos 1
approxBase : Base -> Gauge -> Base
approxBase x e = help err
where
num = numerator e
den = denominator e
err = bitLength (den - pos 1) - bitLength num
help : Int -> Base
help (pos (suc n)) = round (x * fromNat k) % pos k
where
k = shiftL 1 (suc n)
help (pos zero) = x
help (neg n) = fromInt $ (round $ x / fromInt k) *' k
where
k = pos (shiftL 1 ! neg n !)
powers : Nat -> Base -> List Base
powers n x = iterate n (_*_ x) x
sumBase : List Base -> Base
sumBase xs = foldr _+_ (fromNat 0) xs
| {
"alphanum_fraction": 0.630198915,
"avg_line_length": 20.8679245283,
"ext": "agda",
"hexsha": "cabd1742673706b2de24f7fd394732b19c60dabc",
"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": "examples/lib/Data/Real/Base.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": "examples/lib/Data/Real/Base.agda",
"max_line_length": 57,
"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": "examples/lib/Data/Real/Base.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": 351,
"size": 1106
} |
module Structure.Topology.Proofs where
| {
"alphanum_fraction": 0.8717948718,
"avg_line_length": 19.5,
"ext": "agda",
"hexsha": "59035d50ceec4ed5a208605a7728f901b1a37783",
"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": "Structure/Topology/Proofs.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": "Structure/Topology/Proofs.agda",
"max_line_length": 38,
"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": "Structure/Topology/Proofs.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": 8,
"size": 39
} |
------------------------------------------------------------------------
-- Abstract binding trees, based on Harper's "Practical Foundations
-- for Programming Languages"
------------------------------------------------------------------------
-- Operators are not indexed by symbolic parameters.
-- TODO: Define α-equivalence, prove that key operations respect
-- α-equivalence.
{-# OPTIONS --cubical --safe #-}
import Equality.Path as P
module Abstract-binding-tree
{e⁺}
(equality-with-paths : ∀ {a p} → P.Equality-with-paths a p e⁺)
where
open P.Derived-definitions-and-properties equality-with-paths
open import Dec
open import Logical-equivalence using (_⇔_)
open import Prelude hiding (swap) renaming ([_,_] to [_,_]′)
open import Bijection equality-with-J as Bijection using (_↔_)
open import Equality.Decidable-UIP equality-with-J
open import Equality.Decision-procedures equality-with-J
open import Equality.Path.Isomorphisms equality-with-paths
open import Equivalence equality-with-J as Eq using (_≃_)
open import Erased.Cubical equality-with-paths as E
open import Finite-subset.Listed equality-with-paths as L
hiding (fresh)
open import Function-universe equality-with-J as F hiding (id; _∘_)
open import H-level equality-with-J
open import H-level.Closure equality-with-J
open import H-level.Truncation.Propositional equality-with-paths
as Trunc
open import List equality-with-J using (H-level-List)
private
variable
p : Level
------------------------------------------------------------------------
-- Signatures
private
module Dummy where
-- Signatures for abstract binding trees.
record Signature ℓ : Type (lsuc ℓ) where
infix 4 _≟S_ _≟O_ _≟V_
field
-- A set of sorts with decidable erased equality.
Sort : Type ℓ
_≟S_ : Decidable-erased-equality Sort
-- Valences.
Valence : Type ℓ
Valence = List Sort × Sort
field
-- Codomain-indexed operators with decidable erased equality and
-- domains.
Op : @0 Sort → Type ℓ
_≟O_ : ∀ {@0 s} → Decidable-erased-equality (Op s)
domain : ∀ {@0 s} → Op s → List Valence
-- A sort-indexed type of variables with decidable erased
-- equality.
Var : @0 Sort → Type ℓ
_≟V_ : ∀ {@0 s} → Decidable-erased-equality (Var s)
-- Non-indexed variables.
∃Var : Type ℓ
∃Var = ∃ λ (s : Sort) → Var s
-- Finite subsets of variables.
--
-- This type is used by the substitution functions, so it might
-- make sense to make it possible to switch to a more efficient
-- data structure. (For instance, if variables are natural
-- numbers, then it should suffice to store an upper bound of the
-- variables in the term.)
Vars : Type ℓ
Vars = Finite-subset-of ∃Var
field
-- One can always find a fresh variable.
fresh : ∀ {s} (xs : Vars) →
∃ λ (x : Var s) → Erased ((_ , x) ∉ xs)
-- Arities.
Arity : Type ℓ
Arity = List Valence × Sort
-- An operator's arity.
arity : ∀ {s} → Op s → Arity
arity {s = s} o = domain o , s
open Dummy public using (Signature) hiding (module Signature)
-- Definitions depending on a signature. Defined in a separate module
-- to avoid problems with record modules.
module Signature {ℓ} (sig : Signature ℓ) where
open Dummy.Signature sig public
private
variable
@0 A : Type ℓ
@0 s s′ s₁ s₂ s₃ wf wf₁ wf₂ : A
@0 ss : List Sort
@0 v : Valence
@0 vs : List Valence
@0 o : Op s
@0 x y z : Var s
@0 dom fs xs ys : Finite-subset-of A
----------------------------------------------------------------------
-- Variants of some functions from the signature
-- A variant of fresh that does not return an erased proof.
fresh-not-erased :
∀ {s} (xs : Vars) → ∃ λ (x : Var s) → (_ , x) ∉ xs
fresh-not-erased =
Σ-map id Stable-¬ ∘ fresh
-- Erased equality is decidable for ∃Var.
infix 4 _≟∃V_
_≟∃V_ : Decidable-erased-equality ∃Var
_≟∃V_ =
decidable-erased⇒decidable-erased⇒Σ-decidable-erased _≟S_ _≟V_
----------------------------------------------------------------------
-- Some types are sets
-- Sort is a set (in erased contexts).
@0 Sort-set : Is-set Sort
Sort-set =
decidable⇒set $
Decidable-erased-equality≃Decidable-equality _ _≟S_
-- Valence is a set (in erased contexts).
@0 Valence-set : Is-set Valence
Valence-set = ×-closure 2
(H-level-List 0 Sort-set)
Sort-set
-- Arity is a set (in erased contexts).
@0 Arity-set : Is-set Arity
Arity-set = ×-closure 2
(H-level-List 0 Valence-set)
Sort-set
-- Var s is a set (in erased contexts).
@0 Var-set : Is-set (Var s)
Var-set =
decidable⇒set $
Decidable-erased-equality≃Decidable-equality _ _≟V_
-- ∃Var is a set (in erased contexts).
@0 ∃Var-set : Is-set ∃Var
∃Var-set =
decidable⇒set $
Decidable-erased-equality≃Decidable-equality _ _≟∃V_
----------------------------------------------------------------------
-- Some decision procedures
-- "Erased mere equality" is decidable for Var s.
merely-equal?-Var : (x y : Var s) → Dec-Erased ∥ x ≡ y ∥
merely-equal?-Var x y with x ≟V y
… | yes [ x≡y ] = yes [ ∣ x≡y ∣ ]
… | no [ x≢y ] = no [ x≢y ∘ Trunc.rec Var-set id ]
-- "Erased mere equality" is decidable for ∃Var.
merely-equal?-∃Var : (x y : ∃Var) → Dec-Erased ∥ x ≡ y ∥
merely-equal?-∃Var x y with x ≟∃V y
… | yes [ x≡y ] = yes [ ∣ x≡y ∣ ]
… | no [ x≢y ] = no [ x≢y ∘ Trunc.rec ∃Var-set id ]
private
-- An instance of delete.
del : ∃Var → Vars → Vars
del = delete merely-equal?-∃Var
-- An instance of minus.
infixl 5 _∖_
_∖_ :
Finite-subset-of (Var s) → Finite-subset-of (Var s) →
Finite-subset-of (Var s)
_∖_ = minus merely-equal?-Var
----------------------------------------------------------------------
-- Term skeletons
-- Term skeletons are terms without variables.
mutual
-- Terms.
data Tmˢ : @0 Sort → Type ℓ where
var : ∀ {s} → Tmˢ s
op : (o : Op s) → Argsˢ (domain o) → Tmˢ s
-- Sequences of arguments.
data Argsˢ : @0 List Valence → Type ℓ where
nil : Argsˢ []
cons : Argˢ v → Argsˢ vs → Argsˢ (v ∷ vs)
-- Arguments.
data Argˢ : @0 Valence → Type ℓ where
nil : Tmˢ s → Argˢ ([] , s)
cons : ∀ {s} → Argˢ (ss , s′) → Argˢ (s ∷ ss , s′)
private
variable
@0 tˢ : Tmˢ s
@0 asˢ : Argsˢ vs
@0 aˢ : Argˢ v
----------------------------------------------------------------------
-- Raw terms
-- Raw (possibly ill-scoped) terms.
mutual
Tm : Tmˢ s → Type ℓ
Tm {s = s} var = Var s
Tm (op o as) = Args as
Args : Argsˢ vs → Type ℓ
Args nil = ↑ _ ⊤
Args (cons a as) = Arg a × Args as
Arg : Argˢ v → Type ℓ
Arg (nil t) = Tm t
Arg (cons {s = s} a) = Var s × Arg a
----------------------------------------------------------------------
-- Casting variables
-- A cast lemma.
cast-Var : @0 s ≡ s′ → Var s → Var s′
cast-Var = substᴱ Var
-- Attempts to cast a variable to a given sort.
maybe-cast-∃Var : ∀ s → ∃Var → Maybe (Var s)
maybe-cast-∃Var s (s′ , x) with s′ ≟S s
… | yes [ s′≡s ] = just (cast-Var s′≡s x)
… | no _ = nothing
abstract
-- When no arguments are erased one can express cast-Var in a
-- different way.
cast-Var-not-erased :
∀ {s s′} {s≡s′ : s ≡ s′} {x} →
cast-Var s≡s′ x ≡ subst (λ s → Var s) s≡s′ x
cast-Var-not-erased {s≡s′ = s≡s′} {x = x} =
substᴱ Var s≡s′ x ≡⟨ substᴱ≡subst ⟩∎
subst (λ s → Var s) s≡s′ x ∎
-- If eq has type s₁ ≡ s₂, then s₁ paired up with x (as an element
-- of ∃Var) is equal to s₂ paired up with cast-Var eq x (if none
-- of these inputs are erased).
≡,cast-Var :
∀ {s₁ s₂ x} {eq : s₁ ≡ s₂} →
_≡_ {A = ∃Var} (s₁ , x) (s₂ , cast-Var eq x)
≡,cast-Var {s₁ = s₁} {s₂ = s₂} {x = x} {eq = eq} =
Σ-≡,≡→≡ eq
(subst (λ s → Var s) eq x ≡⟨ sym cast-Var-not-erased ⟩∎
cast-Var eq x ∎)
-- A "computation rule".
cast-Var-refl :
∀ {@0 s} {x : Var s} →
cast-Var (refl s) x ≡ x
cast-Var-refl {x = x} =
substᴱ Var (refl _) x ≡⟨ substᴱ-refl ⟩∎
x ∎
-- A fusion lemma for cast-Var.
cast-Var-cast-Var :
{x : Var s₁} {@0 eq₁ : s₁ ≡ s₂} {@0 eq₂ : s₂ ≡ s₃} →
cast-Var eq₂ (cast-Var eq₁ x) ≡ cast-Var (trans eq₁ eq₂) x
cast-Var-cast-Var {x = x} {eq₁ = eq₁} {eq₂ = eq₂} =
subst (λ ([ s ]) → Var s) ([]-cong [ eq₂ ])
(subst (λ ([ s ]) → Var s) ([]-cong [ eq₁ ]) x) ≡⟨ subst-subst _ _ _ _ ⟩
subst (λ ([ s ]) → Var s)
(trans ([]-cong [ eq₁ ]) ([]-cong [ eq₂ ])) x ≡⟨ cong (flip (subst _) _) $ sym []-cong-[trans] ⟩∎
subst (λ ([ s ]) → Var s) ([]-cong [ trans eq₁ eq₂ ]) x ∎
-- The proof given to cast-Var can be replaced.
cast-Var-irrelevance :
{x : Var s₁} {@0 eq₁ eq₂ : s₁ ≡ s₂} →
cast-Var eq₁ x ≡ cast-Var eq₂ x
cast-Var-irrelevance = congᴱ (λ eq → cast-Var eq _) (Sort-set _ _)
-- If cast-Var's proof argument is constructed (in a certain way)
-- from a (non-erased) proof of a kind of equality between
-- cast-Var's variable argument and another variable, then the
-- result is equal to the other variable.
cast-Var-Σ-≡,≡←≡ :
∀ {s₁ s₂} {x₁ : Var s₁} {x₂ : Var s₂}
(eq : _≡_ {A = ∃Var} (s₁ , x₁) (s₂ , x₂)) →
cast-Var (proj₁ (Σ-≡,≡←≡ eq)) x₁ ≡ x₂
cast-Var-Σ-≡,≡←≡ {x₁ = x₁} {x₂ = x₂} eq =
cast-Var (proj₁ (Σ-≡,≡←≡ eq)) x₁ ≡⟨ cast-Var-not-erased ⟩
subst (λ s → Var s) (proj₁ (Σ-≡,≡←≡ eq)) x₁ ≡⟨ proj₂ (Σ-≡,≡←≡ eq) ⟩∎
x₂ ∎
-- An equality between a casted variable and another variable can
-- be expressed in terms of an equality between elements of ∃Var.
-- (In erased contexts.)
@0 ≡cast-Var≃ :
{s≡s′ : s ≡ s′} →
(cast-Var s≡s′ x ≡ y) ≃ _≡_ {A = ∃Var} (s , x) (s′ , y)
≡cast-Var≃ {s = s} {s′ = s′} {x = x} {y = y} {s≡s′ = s≡s′} =
cast-Var s≡s′ x ≡ y ↝⟨ ≡⇒↝ _ $ cong (_≡ _) cast-Var-not-erased ⟩
subst (λ s → Var s) s≡s′ x ≡ y ↔⟨ inverse $ drop-⊤-left-Σ $ _⇔_.to contractible⇔↔⊤ $
propositional⇒inhabited⇒contractible Sort-set s≡s′ ⟩
(∃ λ (s≡s′ : s ≡ s′) → subst (λ s → Var s) s≡s′ x ≡ y) ↔⟨ Bijection.Σ-≡,≡↔≡ ⟩□
(s , x) ≡ (s′ , y) □
-- Equality between pairs in ∃Var can be "simplified" when the
-- sorts are equal. (In erased contexts.)
@0 ≡→,≡,≃ :
_≡_ {A = ∃Var} (s , x) (s , y) ≃ (x ≡ y)
≡→,≡,≃ {s = s} {x = x} {y = y} =
(s , x) ≡ (s , y) ↝⟨ inverse ≡cast-Var≃ ⟩
cast-Var (refl _) x ≡ y ↝⟨ ≡⇒↝ _ $ cong (_≡ _) cast-Var-refl ⟩□
x ≡ y □
-- Equality between pairs in ∃Var can be "simplified" when the
-- sorts are not equal.
≢→,≡,≃ :
∀ {s₁ s₂ x y} →
s₁ ≢ s₂ →
_≡_ {A = ∃Var} (s₁ , x) (s₂ , y) ≃ ⊥₀
≢→,≡,≃ {s₁ = s₁} {s₂ = s₂} {x = x} {y = y} s₁≢s₂ =
(s₁ , x) ≡ (s₂ , y) ↔⟨ inverse Bijection.Σ-≡,≡↔≡ ⟩
(∃ λ (s₁≡s₂ : s₁ ≡ s₂) → subst (λ s → Var s) s₁≡s₂ x ≡ y) ↝⟨ Σ-cong-contra (Bijection.⊥↔uninhabited s₁≢s₂) (λ _ → F.id) ⟩
(∃ λ (p : ⊥₀) → subst (λ s → Var s) (⊥-elim p) x ≡ y) ↔⟨ Σ-left-zero ⟩□
⊥ □
----------------------------------------------------------------------
-- A small universe
-- The universe.
data Term-kind : Type where
var tm args arg : Term-kind
private
variable
k : Term-kind
-- A variable skeleton is just an unerased sort.
data Varˢ : @0 Sort → Type ℓ where
var : ∀ {s} → Varˢ s
-- For each kind of term there is a kind of sort, a kind of
-- skeleton, and a kind of data.
Sort-kind : Term-kind → Type ℓ
Sort-kind var = Sort
Sort-kind tm = Sort
Sort-kind args = List Valence
Sort-kind arg = Valence
Skeleton : (k : Term-kind) → @0 Sort-kind k → Type ℓ
Skeleton var = Varˢ
Skeleton tm = Tmˢ
Skeleton args = Argsˢ
Skeleton arg = Argˢ
Data : Skeleton k s → Type ℓ
Data {k = var} {s = s} = λ _ → Var s
Data {k = tm} = Tm
Data {k = args} = Args
Data {k = arg} = Arg
-- Term-kind is equivalent to Fin 4.
Term-kind≃Fin-4 : Term-kind ≃ Fin 4
Term-kind≃Fin-4 = Eq.↔→≃ to from to∘from from∘to
where
to : Term-kind → Fin 4
to var = fzero
to tm = fsuc fzero
to args = fsuc (fsuc fzero)
to arg = fsuc (fsuc (fsuc fzero))
from : Fin 4 → Term-kind
from fzero = var
from (fsuc fzero) = tm
from (fsuc (fsuc fzero)) = args
from (fsuc (fsuc (fsuc fzero))) = arg
to∘from : ∀ i → to (from i) ≡ i
to∘from fzero = refl _
to∘from (fsuc fzero) = refl _
to∘from (fsuc (fsuc fzero)) = refl _
to∘from (fsuc (fsuc (fsuc fzero))) = refl _
from∘to : ∀ k → from (to k) ≡ k
from∘to var = refl _
from∘to tm = refl _
from∘to args = refl _
from∘to arg = refl _
----------------------------------------------------------------------
-- Computing the set of free variables
-- These functions return sets containing exactly the free
-- variables.
--
-- Note that this code is not intended to be used at run-time.
private
free-Var : ∀ {s} → Var s → Vars
free-Var x = singleton (_ , x)
mutual
free-Tm : (tˢ : Tmˢ s) → Tm tˢ → Vars
free-Tm var x = free-Var x
free-Tm (op o asˢ) as = free-Args asˢ as
free-Args : (asˢ : Argsˢ vs) → Args asˢ → Vars
free-Args nil _ = []
free-Args (cons aˢ asˢ) (a , as) =
free-Arg aˢ a ∪ free-Args asˢ as
free-Arg : (aˢ : Argˢ v) → Arg aˢ → Vars
free-Arg (nil tˢ) t = free-Tm tˢ t
free-Arg (cons aˢ) (x , a) = del (_ , x) (free-Arg aˢ a)
free : (tˢ : Skeleton k s) → Data tˢ → Vars
free {k = var} = λ { var → free-Var }
free {k = tm} = free-Tm
free {k = args} = free-Args
free {k = arg} = free-Arg
----------------------------------------------------------------------
-- Set restriction
-- Restricts a set to variables with the given sort.
restrict-to-sort :
∀ s → Vars → Finite-subset-of (Var s)
restrict-to-sort = map-Maybe ∘ maybe-cast-∃Var
abstract
-- A lemma characterising restrict-to-sort (in erased contexts).
@0 ∈restrict-to-sort≃ :
(x ∈ restrict-to-sort s xs) ≃ ((s , x) ∈ xs)
∈restrict-to-sort≃ {s = s} {x = x} {xs = xs} =
x ∈ restrict-to-sort s xs ↝⟨ ∈map-Maybe≃ ⟩
∥ (∃ λ y → y ∈ xs × maybe-cast-∃Var s y ≡ just x) ∥ ↝⟨ ∥∥-cong (∃-cong λ _ → ∃-cong λ _ → lemma) ⟩
∥ (∃ λ y → y ∈ xs × y ≡ (s , x)) ∥ ↝⟨ ∥∥-cong (∃-cong λ _ → ×-cong₁ λ eq → ≡⇒↝ _ $ cong (_∈ _) eq) ⟩
∥ (∃ λ y → (s , x) ∈ xs × y ≡ (s , x)) ∥ ↔⟨ (×-cong₁ λ _ → ∥∥↔ ∈-propositional) F.∘
inverse ∥∥×∥∥↔∥×∥ F.∘
∥∥-cong ∃-comm ⟩
(s , x) ∈ xs × ∥ (∃ λ y → y ≡ (s , x)) ∥ ↔⟨ (drop-⊤-right λ _ →
_⇔_.to contractible⇔↔⊤ $
propositional⇒inhabited⇒contractible
truncation-is-proposition
∣ _ , refl _ ∣) ⟩□
(s , x) ∈ xs □
where
lemma :
(maybe-cast-∃Var s (s′ , y) ≡ just x) ≃
_≡_ {A = ∃Var} (s′ , y) (s , x)
lemma {s′ = s′} {y = y} with s′ ≟S s
… | yes [ s′≡s ] =
just (cast-Var s′≡s y) ≡ just x ↔⟨ inverse Bijection.≡↔inj₂≡inj₂ ⟩
cast-Var s′≡s y ≡ x ↝⟨ ≡cast-Var≃ ⟩□
(s′ , y) ≡ (s , x) □
… | no [ s′≢s ] =
nothing ≡ just x ↔⟨ Bijection.≡↔⊎ ⟩
⊥ ↔⟨ ⊥↔⊥ ⟩
⊥ ↝⟨ inverse $ ≢→,≡,≃ s′≢s ⟩
(s′ , y) ≡ (s , x) □
-- A kind of extensionality.
@0 ≃∈restrict-to-sort :
((s , x) ∈ xs) ≃
(∀ s′ (s≡s′ : s ≡ s′) → cast-Var s≡s′ x ∈ restrict-to-sort s′ xs)
≃∈restrict-to-sort {s = s} {x = x} {xs = xs} =
(s , x) ∈ xs ↝⟨ inverse ∈restrict-to-sort≃ ⟩
x ∈ restrict-to-sort s xs ↝⟨ ≡⇒↝ _ $ cong (_∈ _) $ sym cast-Var-refl ⟩
cast-Var (refl _) x ∈ restrict-to-sort s xs ↝⟨ ∀-intro _ ext ⟩□
(∀ s′ (s≡s′ : s ≡ s′) → cast-Var s≡s′ x ∈ restrict-to-sort s′ xs) □
-- The function restrict-to-sort s is monotone with respect to _⊆_
-- (in erased contexts).
@0 restrict-to-sort-cong :
xs ⊆ ys → restrict-to-sort s xs ⊆ restrict-to-sort s ys
restrict-to-sort-cong {xs = xs} {ys = ys} {s = s} xs⊆ys = λ z →
z ∈ restrict-to-sort s xs ↔⟨ ∈restrict-to-sort≃ ⟩
(s , z) ∈ xs ↝⟨ xs⊆ys _ ⟩
(s , z) ∈ ys ↔⟨ inverse ∈restrict-to-sort≃ ⟩□
z ∈ restrict-to-sort s ys □
-- A lemma that allows one to replace the sort with an equal one
-- in an expression of the form z ∈ restrict-to-sort s xs.
sort-can-be-replaced-in-∈-restrict-to-sort :
∀ {s s′ s≡s′ z} xs →
(z ∈ restrict-to-sort s xs) ≃
(cast-Var s≡s′ z ∈ restrict-to-sort s′ xs)
sort-can-be-replaced-in-∈-restrict-to-sort
{s = s} {s≡s′ = s≡s′} {z = z} xs =
elim¹
(λ {s′} s≡s′ →
(z ∈ restrict-to-sort s xs) ≃
(cast-Var s≡s′ z ∈ restrict-to-sort s′ xs))
(≡⇒↝ _ $ cong (_∈ _) (sym cast-Var-refl))
s≡s′
-- The function restrict-to-sort commutes with _∪_ (in erased
-- contexts).
@0 restrict-to-sort-∪ :
∀ xs →
restrict-to-sort s (xs ∪ ys) ≡
restrict-to-sort s xs ∪ restrict-to-sort s ys
restrict-to-sort-∪ {s = s} {ys = ys} xs =
_≃_.from extensionality λ x →
x ∈ restrict-to-sort s (xs ∪ ys) ↔⟨ ∈∪≃ F.∘
∈restrict-to-sort≃ ⟩
(s , x) ∈ xs ∥⊎∥ (s , x) ∈ ys ↔⟨ inverse $
(∈restrict-to-sort≃
∥⊎∥-cong
∈restrict-to-sort≃) F.∘
∈∪≃ ⟩□
x ∈ restrict-to-sort s xs ∪ restrict-to-sort s ys □
----------------------------------------------------------------------
-- Renamings
-- Renamings.
--
-- A renaming for the sort s maps the variables to be renamed to the
-- corresponding "new" variables in Var s.
--
-- Every new variable must be in the set fs (the idea is that this
-- set should be a superset of the set of free variables of the
-- resulting term), and dom must be the renaming's domain.
--
-- TODO: It may make sense to replace this function type with an
-- efficient data structure.
Renaming :
(@0 dom fs : Finite-subset-of (Var s)) → Type ℓ
Renaming {s = s} dom fs =
(x : Var s) →
(∃ λ (y : Var s) → Erased (x ∈ dom × y ∈ fs))
⊎
Erased (x ∉ dom)
-- An empty renaming.
empty-renaming :
(@0 fs : Finite-subset-of (Var s)) →
Renaming [] fs
empty-renaming _ = λ _ → inj₂ [ (λ ()) ]
-- Adds the mapping x ↦ y to the renaming.
extend-renaming :
(x y : Var s) →
Renaming dom fs →
Renaming (x ∷ dom) (y ∷ fs)
extend-renaming {dom = dom} x y ρ z with z ≟V x
… | yes ([ z≡x ]) =
inj₁
( y
, [ ≡→∈∷ z≡x
, ≡→∈∷ (refl _)
]
)
… | no [ z≢x ] =
⊎-map
(Σ-map id (E.map (Σ-map ∈→∈∷ ∈→∈∷)))
(E.map (_∘
(z ∈ x ∷ dom ↔⟨ ∈∷≃ ⟩
z ≡ x ∥⊎∥ z ∈ dom ↔⟨ drop-⊥-left-∥⊎∥ ∈-propositional z≢x ⟩□
z ∈ dom □))) $
ρ z
-- A renaming for a single variable.
singleton-renaming :
(x y : Var s)
(@0 fs : Finite-subset-of (Var s)) →
Renaming (singleton x) (y ∷ fs)
singleton-renaming x y fs =
extend-renaming x y (empty-renaming fs)
----------------------------------------------------------------------
-- An implementation of renaming
private
-- Capture-avoiding renaming for variables.
rename-Var :
∀ {s s′} {@0 dom fs} (x : Var s′)
(ρ : Renaming dom fs) →
@0 restrict-to-sort s (free-Var x) ∖ dom ⊆ fs →
∃ λ (x′ : Var s′) →
Erased (restrict-to-sort s (free-Var x′) ⊆ fs
×
restrict-to-sort s (free-Var x) ⊆
dom ∪ restrict-to-sort s (free-Var x′)
×
∀ s′ → s′ ≢ s →
restrict-to-sort s′ (free-Var x′) ≡
restrict-to-sort s′ (free-Var x))
rename-Var {s = s} {s′ = s′} {dom = dom} {fs = fs}
x ρ ⊆free
with s ≟S s′
… | no [ s≢s′ ] =
x
, [ (λ y →
y ∈ restrict-to-sort s (free-Var x) ↔⟨ from-isomorphism (∥∥↔ ∃Var-set) F.∘
∈singleton≃ F.∘
∈restrict-to-sort≃ ⟩
(s , y) ≡ (s′ , x) ↝⟨ cong proj₁ ⟩
s ≡ s′ ↝⟨ s≢s′ ⟩
⊥ ↝⟨ ⊥-elim ⟩□
y ∈ fs □)
, (λ y →
y ∈ restrict-to-sort s (free-Var x) ↝⟨ ∈→∈∪ʳ dom ⟩□
y ∈ dom ∪ restrict-to-sort s (free-Var x) □)
, (λ _ _ → refl _)
]
… | yes [ s≡s′ ] with ρ (cast-Var (sym s≡s′) x)
… | inj₂ [ x∉domain ] =
x
, [ (λ y →
y ∈ restrict-to-sort s (free-Var x) ↝⟨ (λ hyp →
hyp
, _≃_.to
(from-isomorphism ≡-comm F.∘
inverse ≡cast-Var≃ F.∘
from-isomorphism ≡-comm F.∘
from-isomorphism (∥∥↔ ∃Var-set) F.∘
∈singleton≃ F.∘
∈restrict-to-sort≃)
hyp) ⟩
y ∈ restrict-to-sort s (free-Var x) ×
y ≡ cast-Var (sym s≡s′) x ↝⟨ Σ-map id (λ y≡x → subst (_∉ _) (sym y≡x) x∉domain) ⟩
y ∈ restrict-to-sort s (free-Var x) × y ∉ dom ↔⟨ inverse ∈minus≃ ⟩
y ∈ restrict-to-sort s (free-Var x) ∖ dom ↝⟨ ⊆free _ ⟩□
y ∈ fs □)
, (λ y →
y ∈ restrict-to-sort s (free-Var x) ↝⟨ ∈→∈∪ʳ dom ⟩□
y ∈ dom ∪ restrict-to-sort s (free-Var x) □)
, (λ _ _ → refl _)
]
… | inj₁ (y , [ x∈dom , y∈free ]) =
cast-Var s≡s′ y
, [ (λ z →
z ∈ restrict-to-sort s (free-Var (cast-Var s≡s′ y)) ↔⟨ from-isomorphism (∥∥↔ ∃Var-set) F.∘
∈singleton≃ F.∘
∈restrict-to-sort≃ ⟩
(s , z) ≡ (s′ , cast-Var s≡s′ y) ↝⟨ ≡⇒↝ _ $ cong (_ ≡_) $ sym ≡,cast-Var ⟩
(s , z) ≡ (s , y) ↔⟨ ≡→,≡,≃ ⟩
z ≡ y ↝⟨ (λ z≡y → subst (_∈ _) (sym z≡y) y∈free) ⟩□
z ∈ fs □)
, (λ z →
z ∈ restrict-to-sort s (free-Var x) ↔⟨ from-isomorphism ≡-comm F.∘
inverse ≡cast-Var≃ F.∘
from-isomorphism ≡-comm F.∘
from-isomorphism (∥∥↔ ∃Var-set) F.∘
∈singleton≃ F.∘
∈restrict-to-sort≃ ⟩
z ≡ cast-Var (sym s≡s′) x ↝⟨ (λ z≡x → subst (_∈ _) (sym z≡x) x∈dom) ⟩
z ∈ dom ↝⟨ ∈→∈∪ˡ ⟩□
z ∈ dom ∪ restrict-to-sort s (free-Var (cast-Var s≡s′ y)) □)
, (λ s″ s″≢s → _≃_.from extensionality λ z →
z ∈ restrict-to-sort s″ (singleton (s′ , cast-Var s≡s′ y)) ↔⟨ from-isomorphism (∥∥↔ ∃Var-set) F.∘
∈singleton≃ F.∘
∈restrict-to-sort≃ ⟩
(s″ , z) ≡ (s′ , cast-Var s≡s′ y) ↔⟨ ≢→,≡,≃ (subst (_ ≢_) s≡s′ s″≢s) ⟩
⊥ ↔⟨ inverse $ ≢→,≡,≃ (subst (_ ≢_) s≡s′ s″≢s) ⟩
(s″ , z) ≡ (s′ , x) ↔⟨ inverse $
from-isomorphism (∥∥↔ ∃Var-set) F.∘
∈singleton≃ F.∘
∈restrict-to-sort≃ ⟩□
z ∈ restrict-to-sort s″ ((s′ , x) ∷ []) □)
]
private
mutual
-- Capture-avoiding renaming for terms.
rename-Tm :
∀ {s} {@0 dom} {fs} (tˢ : Tmˢ s′) (t : Tm tˢ)
(ρ : Renaming dom fs) →
@0 restrict-to-sort s (free-Tm tˢ t) ∖ dom ⊆ fs →
∃ λ (t′ : Tm tˢ) →
Erased (restrict-to-sort s (free-Tm tˢ t′) ⊆ fs
×
restrict-to-sort s (free-Tm tˢ t) ⊆
dom ∪ restrict-to-sort s (free-Tm tˢ t′)
×
∀ s′ → s′ ≢ s →
restrict-to-sort s′ (free-Tm tˢ t′) ≡
restrict-to-sort s′ (free-Tm tˢ t))
rename-Tm var = rename-Var
rename-Tm (op _ asˢ) = rename-Args asˢ
-- Capture-avoiding renaming for sequences of arguments.
rename-Args :
∀ {s} {@0 dom} {fs} (asˢ : Argsˢ vs) (as : Args asˢ)
(ρ : Renaming dom fs) →
@0 restrict-to-sort s (free-Args asˢ as) ∖ dom ⊆ fs →
∃ λ (as′ : Args asˢ) →
Erased (restrict-to-sort s (free-Args asˢ as′) ⊆ fs
×
restrict-to-sort s (free-Args asˢ as) ⊆
dom ∪ restrict-to-sort s (free-Args asˢ as′)
×
∀ s′ → s′ ≢ s →
restrict-to-sort s′ (free-Args asˢ as′) ≡
restrict-to-sort s′ (free-Args asˢ as))
rename-Args nil _ _ _ =
_
, [ (λ _ ())
, (λ _ ())
, (λ _ _ → refl _)
]
rename-Args {s = s} {dom = dom} {fs = fs}
(cons aˢ asˢ) (a , as) ρ ⊆free =
Σ-zip _,_
(λ {a′ as′} ([ ⊆free₁ , ⊆dom₁ , ≡free₁ ])
([ ⊆free₂ , ⊆dom₂ , ≡free₂ ]) →
[ (λ x →
x ∈ restrict-to-sort s
(free-Arg aˢ a′ ∪ free-Args asˢ as′) ↝⟨ ≡⇒↝ _ $ cong (_ ∈_) $ restrict-to-sort-∪ (free-Arg aˢ a′) ⟩
x ∈ restrict-to-sort s (free-Arg aˢ a′) ∪
restrict-to-sort s (free-Args asˢ as′) ↝⟨ ∪-cong-⊆ ⊆free₁ ⊆free₂ _ ⟩
x ∈ fs ∪ fs ↝⟨ ≡⇒↝ _ $ cong (_ ∈_) $ idem _ ⟩□
x ∈ fs □)
, (λ x →
x ∈ restrict-to-sort s
(free-Arg aˢ a ∪ free-Args asˢ as) ↝⟨ ≡⇒↝ _ $ cong (_ ∈_) $
restrict-to-sort-∪ (free-Arg aˢ a) ⟩
x ∈ restrict-to-sort s (free-Arg aˢ a) ∪
restrict-to-sort s (free-Args asˢ as) ↝⟨ ∪-cong-⊆ ⊆dom₁ ⊆dom₂ _ ⟩
x ∈ (dom ∪ restrict-to-sort s (free-Arg aˢ a′)) ∪
(dom ∪ restrict-to-sort s (free-Args asˢ as′)) ↝⟨ ≡⇒↝ _ $ cong (_ ∈_) (
(dom ∪ restrict-to-sort s (free-Arg aˢ a′)) ∪
(dom ∪ restrict-to-sort s (free-Args asˢ as′)) ≡⟨ sym $
L.assoc dom ⟩
dom ∪
(restrict-to-sort s (free-Arg aˢ a′) ∪
(dom ∪ restrict-to-sort s (free-Args asˢ as′))) ≡⟨ cong (dom ∪_) $
L.assoc (restrict-to-sort s (free-Arg aˢ a′)) ⟩
dom ∪
((restrict-to-sort s (free-Arg aˢ a′) ∪ dom) ∪
restrict-to-sort s (free-Args asˢ as′)) ≡⟨ cong (λ xs → dom ∪ (xs ∪ _)) $ sym $
L.comm dom ⟩
dom ∪
((dom ∪ restrict-to-sort s (free-Arg aˢ a′)) ∪
restrict-to-sort s (free-Args asˢ as′)) ≡⟨ cong (dom ∪_) $ sym $
L.assoc dom ⟩
dom ∪
(dom ∪
(restrict-to-sort s (free-Arg aˢ a′) ∪
restrict-to-sort s (free-Args asˢ as′))) ≡⟨ L.assoc dom ⟩
(dom ∪ dom) ∪
(restrict-to-sort s (free-Arg aˢ a′) ∪
restrict-to-sort s (free-Args asˢ as′)) ≡⟨ cong (_∪ _) $
idem dom ⟩
dom ∪
(restrict-to-sort s (free-Arg aˢ a′) ∪
restrict-to-sort s (free-Args asˢ as′)) ≡⟨ cong (dom ∪_) $ sym $
restrict-to-sort-∪ (free-Arg aˢ a′) ⟩∎
dom ∪ restrict-to-sort s
(free-Arg aˢ a′ ∪ free-Args asˢ as′) ∎) ⟩□
x ∈ dom ∪ restrict-to-sort s
(free-Arg aˢ a′ ∪ free-Args asˢ as′) □)
, (λ s′ s′≢s → _≃_.from extensionality λ x →
x ∈ restrict-to-sort s′ (free-Arg aˢ a′ ∪ free-Args asˢ as′) ↔⟨ inverse (∈restrict-to-sort≃ ∥⊎∥-cong ∈restrict-to-sort≃) F.∘
∈∪≃ {y = free-Arg aˢ a′} F.∘
∈restrict-to-sort≃ ⟩
x ∈ restrict-to-sort s′ (free-Arg aˢ a′) ∥⊎∥
x ∈ restrict-to-sort s′ (free-Args asˢ as′) ↝⟨ ≡⇒↝ _ $ cong₂ (λ y z → x ∈ y ∥⊎∥ x ∈ z)
(≡free₁ s′ s′≢s)
(≡free₂ s′ s′≢s) ⟩
x ∈ restrict-to-sort s′ (free-Arg aˢ a) ∥⊎∥
x ∈ restrict-to-sort s′ (free-Args asˢ as) ↔⟨ inverse $
inverse (∈restrict-to-sort≃ ∥⊎∥-cong ∈restrict-to-sort≃) F.∘
∈∪≃ {y = free-Arg aˢ a} F.∘
∈restrict-to-sort≃ ⟩□
x ∈ restrict-to-sort s′ (free-Arg aˢ a ∪ free-Args asˢ as) □)
])
(rename-Arg aˢ a ρ
(λ x →
x ∈ restrict-to-sort s (free-Arg aˢ a) ∖ dom ↝⟨ minus-cong-⊆
(restrict-to-sort-cong λ _ → ∈→∈∪ˡ {y = free-Arg aˢ a})
(⊆-refl {x = dom}) _ ⟩
x ∈ restrict-to-sort s
(free-Arg aˢ a ∪ free-Args asˢ as) ∖ dom ↝⟨ ⊆free _ ⟩□
x ∈ fs □))
(rename-Args asˢ as ρ
(λ x →
x ∈ restrict-to-sort s (free-Args asˢ as) ∖ dom ↝⟨ minus-cong-⊆
(restrict-to-sort-cong λ _ → ∈→∈∪ʳ (free-Arg aˢ a))
(⊆-refl {x = dom}) _ ⟩
x ∈ restrict-to-sort s
(free-Arg aˢ a ∪ free-Args asˢ as) ∖ dom ↝⟨ ⊆free _ ⟩□
x ∈ fs □))
-- Capture-avoiding renaming for arguments.
rename-Arg :
∀ {s} {@0 dom} {fs} (aˢ : Argˢ v) (a : Arg aˢ)
(ρ : Renaming dom fs) →
@0 restrict-to-sort s (free-Arg aˢ a) ∖ dom ⊆ fs →
∃ λ (a′ : Arg aˢ) →
Erased (restrict-to-sort s (free-Arg aˢ a′) ⊆ fs
×
restrict-to-sort s (free-Arg aˢ a) ⊆
dom ∪ restrict-to-sort s (free-Arg aˢ a′)
×
∀ s′ → s′ ≢ s →
restrict-to-sort s′ (free-Arg aˢ a′) ≡
restrict-to-sort s′ (free-Arg aˢ a))
rename-Arg (nil tˢ) = rename-Tm tˢ
rename-Arg {s = s} {dom = dom} {fs = fs}
(cons {s = s′} aˢ) (x , a) ρ ⊆free with s ≟S s′
… | no [ s≢s′ ] =
-- The bound variable does not have the same sort as the
-- ones to be renamed. Continue recursively.
Σ-map
(x ,_)
(λ {a′} → E.map (Σ-map
(λ ⊆free y →
y ∈ restrict-to-sort s (del (s′ , x) (free-Arg aˢ a′)) ↔⟨ ∈delete≃ merely-equal?-∃Var F.∘
∈restrict-to-sort≃ ⟩
(s , y) ≢ (s′ , x) × (s , y) ∈ free-Arg aˢ a′ ↝⟨ proj₂ ⟩
(s , y) ∈ free-Arg aˢ a′ ↔⟨ inverse ∈restrict-to-sort≃ ⟩
y ∈ restrict-to-sort s (free-Arg aˢ a′) ↝⟨ ⊆free _ ⟩□
y ∈ fs □)
(Σ-map
(λ ⊆dom y →
y ∈ restrict-to-sort s (del (s′ , x) (free-Arg aˢ a)) ↔⟨ (∃-cong λ _ → inverse $ ∈restrict-to-sort≃ {xs = free-Arg aˢ a}) F.∘
∈delete≃ merely-equal?-∃Var F.∘
∈restrict-to-sort≃ ⟩
(s , y) ≢ (s′ , x) ×
y ∈ restrict-to-sort s (free-Arg aˢ a) ↝⟨ Σ-map id (⊆dom _) ⟩
(s , y) ≢ (s′ , x) ×
y ∈ dom ∪ restrict-to-sort s (free-Arg aˢ a′) ↔⟨ (∃-cong λ _ →
(F.id ∥⊎∥-cong ∈restrict-to-sort≃) F.∘
∈∪≃) ⟩
(s , y) ≢ (s′ , x) ×
(y ∈ dom ∥⊎∥ (s , y) ∈ free-Arg aˢ a′) ↝⟨ (uncurry λ y≢x → id ∥⊎∥-cong y≢x ,_) ⟩
y ∈ dom ∥⊎∥
(s , y) ≢ (s′ , x) × (s , y) ∈ free-Arg aˢ a′ ↔⟨ inverse $
(F.id
∥⊎∥-cong
(∈delete≃ merely-equal?-∃Var F.∘
∈restrict-to-sort≃)) F.∘
∈∪≃ ⟩□
y ∈ dom ∪ restrict-to-sort s
(del (s′ , x) (free-Arg aˢ a′)) □)
(λ ≡free s″ s″≢s → _≃_.from extensionality λ z →
z ∈ restrict-to-sort s″ (del (s′ , x) (free-Arg aˢ a′)) ↔⟨ (∃-cong λ _ → inverse $ ∈restrict-to-sort≃ {xs = free-Arg aˢ a′}) F.∘
∈delete≃ merely-equal?-∃Var F.∘
∈restrict-to-sort≃ ⟩
(s″ , z) ≢ (s′ , x) ×
z ∈ restrict-to-sort s″ (free-Arg aˢ a′) ↝⟨ (∃-cong λ _ → ≡⇒↝ _ $ cong (_ ∈_) $ ≡free s″ s″≢s) ⟩
(s″ , z) ≢ (s′ , x) ×
z ∈ restrict-to-sort s″ (free-Arg aˢ a) ↔⟨ inverse $
(∃-cong λ _ → inverse $ ∈restrict-to-sort≃ {xs = free-Arg aˢ a}) F.∘
∈delete≃ merely-equal?-∃Var F.∘
∈restrict-to-sort≃ ⟩□
z ∈ restrict-to-sort s″ (del (s′ , x) (free-Arg aˢ a)) □))))
(rename-Arg aˢ a ρ
(λ y →
y ∈ restrict-to-sort s (free-Arg aˢ a) ∖ dom ↔⟨ (∈restrict-to-sort≃ ×-cong F.id) F.∘
∈minus≃ ⟩
(s , y) ∈ free-Arg aˢ a × y ∉ dom ↝⟨ Σ-map (s≢s′ ∘ cong proj₁ ,_) id ⟩
((s , y) ≢ (s′ , x) × (s , y) ∈ free-Arg aˢ a) ×
y ∉ dom ↔⟨ inverse $
(×-cong₁ λ _ → ∈delete≃ merely-equal?-∃Var) F.∘
(∈restrict-to-sort≃ ×-cong F.id) F.∘
∈minus≃ ⟩
y ∈ restrict-to-sort s
(del (s′ , x) (free-Arg aˢ a)) ∖ dom ↝⟨ ⊆free _ ⟩□
y ∈ fs □))
… | yes [ s≡s′ ] =
-- The bound variable has the same sort as the ones to be
-- renamed. Extend the renaming with a mapping from the bound
-- variable to a fresh one, and continue recursively.
Σ-map
(x′ ,_)
(λ {a′} → E.map (Σ-map
(λ ⊆x′∷free y →
y ∈ restrict-to-sort s (del (s′ , x′) (free-Arg aˢ a′)) ↔⟨ (∃-cong λ _ → inverse $
∈restrict-to-sort≃ {xs = free-Arg aˢ a′}) F.∘
∈delete≃ merely-equal?-∃Var F.∘
∈restrict-to-sort≃ ⟩
(s , y) ≢ (s′ , x′) ×
y ∈ restrict-to-sort s (free-Arg aˢ a′) ↝⟨ Σ-map id (⊆x′∷free _) ⟩
(s , y) ≢ (s′ , x′) ×
y ∈ cast-Var (sym s≡s′) x′ ∷ fs ↔⟨ (¬-cong ext $
from-isomorphism ≡-comm F.∘
inverse ≡cast-Var≃ F.∘
from-isomorphism ≡-comm)
×-cong
∈∷≃ ⟩
y ≢ cast-Var (sym s≡s′) x′ ×
(y ≡ cast-Var (sym s≡s′) x′ ∥⊎∥ y ∈ fs) ↔⟨ (∃-cong λ y≢x → drop-⊥-left-∥⊎∥ ∈-propositional y≢x) ⟩
y ≢ cast-Var (sym s≡s′) x′ × y ∈ fs ↝⟨ proj₂ ⟩□
y ∈ fs □)
(Σ-map
(λ ⊆x∷dom y y∈ →
let lemma : y ∉ dom → y ∈ fs
lemma =
y ∉ dom ↝⟨ _≃_.from ∈minus≃ ∘ (y∈ ,_) ⟩
y ∈ restrict-to-sort s
(del (s′ , x) (free-Arg aˢ a)) ∖ dom ↝⟨ ⊆free _ ⟩□
y ∈ fs □
in $⟨ y∈ ⟩
y ∈ restrict-to-sort s (del (s′ , x) (free-Arg aˢ a)) ↔⟨ (∃-cong λ _ → inverse $ ∈restrict-to-sort≃ {xs = free-Arg aˢ a}) F.∘
∈delete≃ merely-equal?-∃Var F.∘
∈restrict-to-sort≃ ⟩
(s , y) ≢ (s′ , x) ×
y ∈ restrict-to-sort s (free-Arg aˢ a) ↝⟨ Σ-map id (⊆x∷dom _) ⟩
(s , y) ≢ (s′ , x) ×
y ∈ cast-Var (sym s≡s′) x ∷ dom ∪
restrict-to-sort s (free-Arg aˢ a′) ↔⟨ (∃-cong λ _ →
(F.id
∥⊎∥-cong
((F.id ∥⊎∥-cong ∈restrict-to-sort≃) F.∘
∈∪≃)) F.∘
∈∷≃) ⟩
(s , y) ≢ (s′ , x) ×
(y ≡ cast-Var (sym s≡s′) x ∥⊎∥ y ∈ dom ∥⊎∥
(s , y) ∈ free-Arg aˢ a′) ↔⟨ (∃-cong λ y≢x → drop-⊥-left-∥⊎∥ ∥⊎∥-propositional $
y≢x ∘ sym ∘ _≃_.to ≡cast-Var≃ ∘ sym) ⟩
(s , y) ≢ (s′ , x) ×
(y ∈ dom ∥⊎∥ (s , y) ∈ free-Arg aˢ a′) ↔⟨ (∃-cong λ _ →
∥⊎∥≃∥⊎∥¬× $
decidable→decidable-∥∥
(member? (decidable→decidable-∥∥ $
Decidable-erased-equality≃Decidable-equality _
_≟V_))
y dom) ⟩
(s , y) ≢ (s′ , x) ×
(y ∈ dom ∥⊎∥ y ∉ dom × (s , y) ∈ free-Arg aˢ a′) ↝⟨ (uncurry λ y≢x → id ∥⊎∥-cong ×-cong₁ λ _ →
y ∉ dom ↝⟨ _≃_.from ∈minus≃ ∘ (y∈ ,_) ⟩
y ∈ restrict-to-sort s
(del (s′ , x) (free-Arg aˢ a)) ∖ dom ↝⟨ ⊆free _ ⟩
y ∈ fs ↝⟨ ∈→∈map ⟩
(s , y) ∈ L.map (s ,_) fs ↝⟨ (λ y∈ →
(s , y) ≡ (s′ , x′) ↝⟨ (λ y≡x′ → subst (_∈ _) y≡x′ y∈) ⟩
(s′ , x′) ∈ L.map (s ,_) fs ↝⟨ erased (proj₂ (fresh (L.map (s ,_) fs))) ⟩□
⊥ □) ⟩□
(s , y) ≢ (s′ , x′) □) ⟩
y ∈ dom ∥⊎∥
(s , y) ≢ (s′ , x′) × (s , y) ∈ free-Arg aˢ a′ ↔⟨ inverse $
(F.id
∥⊎∥-cong
(∈delete≃ merely-equal?-∃Var F.∘
∈restrict-to-sort≃)) F.∘
∈∪≃ ⟩□
y ∈ dom ∪ restrict-to-sort s
(del (s′ , x′) (free-Arg aˢ a′)) □)
(λ ≡free s″ s″≢s → _≃_.from extensionality λ z →
z ∈ restrict-to-sort s″
(del (s′ , x′) (free-Arg aˢ a′)) ↔⟨ (∃-cong λ _ → inverse $ ∈restrict-to-sort≃ {xs = free-Arg aˢ a′}) F.∘
∈delete≃ merely-equal?-∃Var F.∘
∈restrict-to-sort≃ ⟩
(s″ , z) ≢ (s′ , x′) ×
z ∈ restrict-to-sort s″ (free-Arg aˢ a′) ↔⟨ (×-cong₁ λ _ → ¬-cong ext $
≢→,≡,≃ $ s″≢s ∘ subst (_ ≡_) (sym s≡s′)) ⟩
¬ ⊥ × z ∈ restrict-to-sort s″ (free-Arg aˢ a′) ↝⟨ (∃-cong λ _ → ≡⇒↝ _ $ cong (_ ∈_) $ ≡free s″ s″≢s) ⟩
¬ ⊥ × z ∈ restrict-to-sort s″ (free-Arg aˢ a) ↔⟨ (inverse $ ×-cong₁ λ _ → ¬-cong ext $
≢→,≡,≃ $ s″≢s ∘ subst (_ ≡_) (sym s≡s′)) ⟩
(s″ , z) ≢ (s′ , x) ×
z ∈ restrict-to-sort s″ (free-Arg aˢ a) ↔⟨ inverse $
(∃-cong λ _ → inverse $ ∈restrict-to-sort≃ {xs = free-Arg aˢ a}) F.∘
∈delete≃ merely-equal?-∃Var F.∘
∈restrict-to-sort≃ ⟩□
z ∈ restrict-to-sort s″ (del (s′ , x) (free-Arg aˢ a)) □))))
(rename-Arg aˢ a
(extend-renaming
(cast-Var (sym s≡s′) x)
(cast-Var (sym s≡s′) x′)
ρ)
(λ y →
y ∈ restrict-to-sort s (free-Arg aˢ a) ∖
(cast-Var (sym s≡s′) x ∷ dom) ↔⟨ (∈restrict-to-sort≃
×-cong
¬⊎↔¬×¬ ext F.∘
from-isomorphism ¬∥∥↔¬ F.∘
¬-cong ext ∈∷≃) F.∘
∈minus≃ {_≟_ = merely-equal?-Var} ⟩
(s , y) ∈ free-Arg aˢ a ×
y ≢ cast-Var (sym s≡s′) x × y ∉ dom ↔⟨ inverse $
from-isomorphism (inverse Σ-assoc) F.∘
(×-cong₁ λ _ →
((∃-cong λ _ → ¬-cong ext $
from-isomorphism ≡-comm F.∘
inverse ≡cast-Var≃ F.∘
from-isomorphism ≡-comm) F.∘
from-isomorphism ×-comm) F.∘
∈delete≃ merely-equal?-∃Var F.∘
∈restrict-to-sort≃) F.∘
∈minus≃ ⟩
y ∈ restrict-to-sort s
(del (s′ , x) (free-Arg aˢ a)) ∖ dom ↝⟨ ⊆free _ ⟩
y ∈ fs ↝⟨ ∣inj₂∣ ⟩
y ≡ cast-Var (sym s≡s′) x′ ∥⊎∥ y ∈ fs ↔⟨ inverse ∈∷≃ ⟩□
y ∈ cast-Var (sym s≡s′) x′ ∷ fs □))
where
-- TODO: Perhaps it would make sense to avoid the use of L.map
-- below.
x′ = proj₁ (fresh (L.map (s ,_) fs))
-- Capture-avoiding renaming of free variables.
--
-- Bound variables are renamed to variables that are fresh with
-- respect to the set fs.
--
-- Note that this function renames every bound variable of the given
-- sort.
rename :
∀ {s} {@0 dom} {fs} (tˢ : Skeleton k s′) (t : Data tˢ)
(ρ : Renaming dom fs) →
@0 restrict-to-sort s (free tˢ t) ∖ dom ⊆ fs →
∃ λ (t′ : Data tˢ) →
Erased (restrict-to-sort s (free tˢ t′) ⊆ fs
×
restrict-to-sort s (free tˢ t) ⊆
dom ∪ restrict-to-sort s (free tˢ t′)
×
∀ s′ → s′ ≢ s →
restrict-to-sort s′ (free tˢ t′) ≡
restrict-to-sort s′ (free tˢ t))
rename {k = var} = λ { var → rename-Var }
rename {k = tm} = rename-Tm
rename {k = args} = rename-Args
rename {k = arg} = rename-Arg
----------------------------------------------------------------------
-- A special case of the implementation of renaming above
-- Capture-avoiding renaming of x to y.
--
-- Note that this function is not intended to be used at runtime. It
-- uses free to compute the set of free variables.
rename₁ :
∀ {s} (x y : Var s) (tˢ : Skeleton k s′) → Data tˢ → Data tˢ
rename₁ x y tˢ t =
proj₁ $
rename tˢ t
(singleton-renaming x y
(restrict-to-sort _ (free tˢ t) ∖ singleton x))
(λ _ → ∈→∈∷)
-- If x is renamed to y in a, then the free variables of the result
-- are a subset of the free variables of a, minus x, plus y.
@0 free-rename₁⊆ :
{x y : Var s} (tˢ : Skeleton k s′) {t : Data tˢ} →
free tˢ (rename₁ x y tˢ t) ⊆
(_ , y) ∷ del (_ , x) (free tˢ t)
free-rename₁⊆ {s = s} {x = x} {y = y} tˢ {t = t} (s′ , z) =
(s′ , z) ∈ free tˢ (rename₁ x y tˢ t) ↔⟨ ≃∈restrict-to-sort ⟩
(∀ s″ (s′≡s″ : s′ ≡ s″) →
cast-Var s′≡s″ z ∈
restrict-to-sort s″ (free tˢ (rename₁ x y tˢ t))) ↝⟨ (∀-cong _ λ s″ → ∀-cong _ λ s′≡s″ →
lemma s″ s′≡s″ (s″ ≟S s)) ⟩
(∀ s″ (s′≡s″ : s′ ≡ s″) →
cast-Var s′≡s″ z ∈
restrict-to-sort s″ ((s , y) ∷ del (s , x) (free tˢ t))) ↔⟨ inverse ≃∈restrict-to-sort ⟩□
(s′ , z) ∈ (s , y) ∷ del (s , x) (free tˢ t) □
where
lemma :
∀ s″ (s′≡s″ : s′ ≡ s″) → Dec-Erased (s″ ≡ s) → _ ∈ _ → _ ∈ _
lemma s″ s′≡s″ (no [ s″≢s ]) =
cast-Var s′≡s″ z ∈
restrict-to-sort s″ (free tˢ (rename₁ x y tˢ t)) ↝⟨ ≡⇒↝ _ $ cong (_ ∈_) $
proj₂ (proj₂ $ erased $ proj₂ $ rename tˢ _ _ _) s″ s″≢s ⟩
cast-Var s′≡s″ z ∈ restrict-to-sort s″ (free tˢ t) ↔⟨ ∈restrict-to-sort≃ ⟩
z′ ∈ free tˢ t ↝⟨ s″≢s ∘ cong proj₁ ,_ ⟩
z′ ≢ (s , x) × z′ ∈ free tˢ t ↝⟨ ∣inj₂∣ ⟩
z′ ≡ (s , y) ∥⊎∥ z′ ≢ (s , x) × z′ ∈ free tˢ t ↔⟨ inverse $
(F.id ∥⊎∥-cong ∈delete≃ merely-equal?-∃Var) F.∘
∈∷≃ F.∘
∈restrict-to-sort≃ ⟩□
cast-Var s′≡s″ z ∈
restrict-to-sort s″ ((s , y) ∷ del (s , x) (free tˢ t)) □
where
z′ = s″ , cast-Var s′≡s″ z
lemma s″ s′≡s″ (yes [ s″≡s ]) =
cast-Var s′≡s″ z ∈
restrict-to-sort s″ (free tˢ (rename₁ x y tˢ t)) ↔⟨ sort-can-be-replaced-in-∈-restrict-to-sort
(free tˢ (rename₁ x y tˢ t)) ⟩
z′ ∈ restrict-to-sort s (free tˢ (rename₁ x y tˢ t)) ↝⟨ proj₁ (erased $ proj₂ $ rename tˢ _ _ _) _ ⟩
z′ ∈ y ∷ (restrict-to-sort s (free tˢ t) ∖ singleton x) ↔⟨ (F.id
∥⊎∥-cong
((∈restrict-to-sort≃
×-cong
(from-isomorphism ¬∥∥↔¬ F.∘
¬-cong ext ∈singleton≃)) F.∘
∈minus≃ {_≟_ = merely-equal?-Var})) F.∘
∈∷≃ ⟩
z′ ≡ y ∥⊎∥ (s , z′) ∈ free tˢ t × z′ ≢ x ↔⟨ inverse $
≡→,≡,≃
∥⊎∥-cong
(∃-cong λ _ → ¬-cong ext ≡→,≡,≃) ⟩
(s , z′) ≡ (s , y) ∥⊎∥
(s , z′) ∈ free tˢ t × (s , z′) ≢ (s , x) ↔⟨ inverse $
(F.id ∥⊎∥-cong (from-isomorphism ×-comm F.∘
∈delete≃ merely-equal?-∃Var)) F.∘
∈∷≃ F.∘
∈restrict-to-sort≃ ⟩
z′ ∈ restrict-to-sort s ((s , y) ∷ del (s , x) (free tˢ t)) ↔⟨ inverse $
sort-can-be-replaced-in-∈-restrict-to-sort
((s , y) ∷ del (s , x) (free tˢ t)) ⟩□
cast-Var s′≡s″ z ∈
restrict-to-sort s″ ((s , y) ∷ del (s , x) (free tˢ t)) □
where
z′ = cast-Var s″≡s $ cast-Var s′≡s″ z
-- If x is renamed to y in t, then the free variables of t are a
-- subset of the free variables of the result plus x.
@0 ⊆free-rename₁ :
{x y : Var s} (tˢ : Skeleton k s′) {t : Data tˢ} →
free tˢ t ⊆ (_ , x) ∷ free tˢ (rename₁ x y tˢ t)
⊆free-rename₁ {s = s} {x = x} {y = y} tˢ {t = t} (s′ , z) =
(s′ , z) ∈ free tˢ t ↔⟨ ≃∈restrict-to-sort ⟩
(∀ s″ (s′≡s″ : s′ ≡ s″) →
cast-Var s′≡s″ z ∈ restrict-to-sort s″ (free tˢ t)) ↝⟨ (∀-cong _ λ s″ → ∀-cong _ λ s′≡s″ →
lemma s″ s′≡s″ (s″ ≟S s)) ⟩
(∀ s″ (s′≡s″ : s′ ≡ s″) →
cast-Var s′≡s″ z ∈
restrict-to-sort s″
((s , x) ∷ free tˢ (rename₁ x y tˢ t))) ↔⟨ inverse ≃∈restrict-to-sort ⟩□
(s′ , z) ∈ (s , x) ∷ free tˢ (rename₁ x y tˢ t) □
where
lemma :
∀ s″ (s′≡s″ : s′ ≡ s″) → Dec-Erased (s″ ≡ s) → _ ∈ _ → _ ∈ _
lemma s″ s′≡s″ (no [ s″≢s ]) =
cast-Var s′≡s″ z ∈ restrict-to-sort s″ (free tˢ t) ↝⟨ ≡⇒↝ _ $ cong (_ ∈_) $ sym $
proj₂ (proj₂ $ erased $ proj₂ $ rename tˢ _ _ _) s″ s″≢s ⟩
cast-Var s′≡s″ z ∈
restrict-to-sort s″ (free tˢ (rename₁ x y tˢ t)) ↝⟨ restrict-to-sort-cong
{xs = free tˢ (rename₁ x y tˢ t)}
(λ _ → ∈→∈∷) _ ⟩□
cast-Var s′≡s″ z ∈
restrict-to-sort s″ ((s , x) ∷ free tˢ (rename₁ x y tˢ t)) □
lemma s″ s′≡s″ (yes [ s″≡s ]) =
cast-Var s′≡s″ z ∈ restrict-to-sort s″ (free tˢ t) ↔⟨ sort-can-be-replaced-in-∈-restrict-to-sort (free tˢ t) ⟩
z′ ∈ restrict-to-sort s (free tˢ t) ↝⟨ proj₁
(proj₂ $ erased $ proj₂ $
rename tˢ _
(singleton-renaming x y
(restrict-to-sort _ (free tˢ t) ∖ singleton x))
(λ _ → ∈→∈∷))
_ ⟩
z′ ∈ x ∷ restrict-to-sort s (free tˢ (rename₁ x y tˢ t)) ↔⟨ inverse ∈∷≃ F.∘
(inverse ≡→,≡,≃ ∥⊎∥-cong ∈restrict-to-sort≃) F.∘
∈∷≃ ⟩
(s , z′) ∈ (s , x) ∷ free tˢ (rename₁ x y tˢ t) ↔⟨ inverse ∈restrict-to-sort≃ ⟩
z′ ∈ restrict-to-sort s ((s , x) ∷ free tˢ (rename₁ x y tˢ t)) ↔⟨ inverse $
sort-can-be-replaced-in-∈-restrict-to-sort
((s , x) ∷ free tˢ (rename₁ x y tˢ t)) ⟩□
cast-Var s′≡s″ z ∈
restrict-to-sort s″ ((s , x) ∷ free tˢ (rename₁ x y tˢ t)) □
where
z′ = cast-Var s″≡s $ cast-Var s′≡s″ z
----------------------------------------------------------------------
-- Well-formed terms
-- Predicates for well-formed variables, terms and arguments.
mutual
Wf : Vars → (tˢ : Skeleton k s) → Data tˢ → Type ℓ
Wf {k = var} = λ { xs var → Wf-var xs }
Wf {k = tm} = Wf-tm
Wf {k = args} = Wf-args
Wf {k = arg} = Wf-arg
private
Wf-var : ∀ {s} → Vars → Var s → Type ℓ
Wf-var xs x = (_ , x) ∈ xs
Wf-tm : Vars → (tˢ : Tmˢ s) → Tm tˢ → Type ℓ
Wf-tm xs var = Wf-var xs
Wf-tm xs (op o asˢ) = Wf-args xs asˢ
Wf-args : Vars → (asˢ : Argsˢ vs) → Args asˢ → Type ℓ
Wf-args _ nil _ = ↑ _ ⊤
Wf-args xs (cons aˢ asˢ) (a , as) =
Wf-arg xs aˢ a × Wf-args xs asˢ as
Wf-arg : Vars → (aˢ : Argˢ v) → Arg aˢ → Type ℓ
Wf-arg xs (nil tˢ) t = Wf-tm xs tˢ t
Wf-arg xs (cons aˢ) (x , a) =
∀ y → (_ , y) ∉ xs →
Wf-arg ((_ , y) ∷ xs) aˢ (rename₁ x y aˢ a)
-- Well-formed terms.
Term[_] : (k : Term-kind) → @0 Vars → @0 Sort-kind k → Type ℓ
Term[ k ] xs s =
∃ λ (tˢ : Skeleton k s) →
∃ λ (t : Data tˢ) →
Erased (Wf xs tˢ t)
Term : @0 Vars → @0 Sort → Type ℓ
Term = Term[ tm ]
pattern var-wf x wf = var , x , [ wf ]
pattern op-wf o asˢ as wfs = op o asˢ , as , [ wfs ]
pattern nil-wfs =
Argsˢ.nil , lift tt , [ lift tt ]
pattern cons-wfs aˢ asˢ a as wf wfs =
Argsˢ.cons aˢ asˢ , (a , as) , [ wf , wfs ]
pattern nil-wf tˢ t wf = Argˢ.nil tˢ , t , [ wf ]
pattern cons-wf aˢ x a wf = Argˢ.cons aˢ , (x , a) , [ wf ]
----------------------------------------------------------------------
-- Some rearrangement lemmas
-- A rearrangement lemma for Tmˢ.
Tmˢ≃ :
Tmˢ s ≃
((∃ λ s′ → Erased (s′ ≡ s)) ⊎
(∃ λ (o : Op s) → Argsˢ (domain o)))
Tmˢ≃ = Eq.↔⇒≃ (record
{ surjection = record
{ logical-equivalence = record
{ to = to
; from = from
}
; right-inverse-of = λ where
(inj₂ _) → refl _
(inj₁ (s′ , [ eq ])) → elim¹ᴱ
(λ eq → to (substᴱ Tmˢ eq var) ≡
inj₁ (s′ , [ eq ]))
(to (substᴱ Tmˢ (refl _) var) ≡⟨ cong to substᴱ-refl ⟩
to var ≡⟨⟩
inj₁ (s′ , [ refl _ ]) ∎)
eq
}
; left-inverse-of = λ where
(op _ _) → refl _
var → substᴱ-refl
})
where
RHS : @0 Sort → Type ℓ
RHS s =
(∃ λ s′ → Erased (s′ ≡ s)) ⊎
(∃ λ (o : Op s) → Argsˢ (domain o))
to : Tmˢ s → RHS s
to var = inj₁ (_ , [ refl _ ])
to (op o as) = inj₂ (o , as)
from : RHS s → Tmˢ s
from (inj₁ (s′ , [ eq ])) = substᴱ Tmˢ eq var
from (inj₂ (o , as)) = op o as
-- A rearrangement lemma for Argsˢ.
Argsˢ≃ :
Argsˢ vs ≃
(Erased ([] ≡ vs) ⊎
(∃ λ ((([ v ] , _) , [ vs′ ] , _) :
(∃ λ v → Argˢ (erased v)) ×
(∃ λ vs′ → Argsˢ (erased vs′))) →
Erased (v ∷ vs′ ≡ vs)))
Argsˢ≃ = Eq.↔⇒≃ (record
{ surjection = record
{ logical-equivalence = record
{ to = to
; from = from
}
; right-inverse-of = to∘from
}
; left-inverse-of = from∘to
})
where
RHS : @0 List Valence → Type ℓ
RHS vs =
(Erased ([] ≡ vs) ⊎
(∃ λ ((([ v ] , _) , [ vs′ ] , _) :
(∃ λ v → Argˢ (erased v)) ×
(∃ λ vs′ → Argsˢ (erased vs′))) →
Erased (v ∷ vs′ ≡ vs)))
to : Argsˢ vs → RHS vs
to nil = inj₁ [ refl _ ]
to (cons a as) = inj₂ (((_ , a) , _ , as) , [ refl _ ])
from : RHS vs → Argsˢ vs
from (inj₁ [ eq ]) =
substᴱ Argsˢ eq nil
from (inj₂ (((_ , a) , _ , as) , [ eq ])) =
substᴱ Argsˢ eq (cons a as)
to∘from : ∀ x → to (from x) ≡ x
to∘from (inj₁ [ eq ]) = elim¹ᴱ
(λ eq → to (substᴱ Argsˢ eq nil) ≡ inj₁ [ eq ])
(to (substᴱ Argsˢ (refl _) nil) ≡⟨ cong to substᴱ-refl ⟩
to nil ≡⟨⟩
inj₁ [ refl _ ] ∎)
eq
to∘from (inj₂ (((_ , a) , _ , as) , [ eq ])) = elim¹ᴱ
(λ eq → to (substᴱ Argsˢ eq (cons a as)) ≡
inj₂ (((_ , a) , _ , as) , [ eq ]))
(to (substᴱ Argsˢ (refl _) (cons a as)) ≡⟨ cong to substᴱ-refl ⟩
to (cons a as) ≡⟨⟩
inj₂ (((_ , a) , _ , as) , [ refl _ ]) ∎)
eq
from∘to : ∀ x → from (to x) ≡ x
from∘to nil = substᴱ-refl
from∘to (cons _ _) = substᴱ-refl
-- A rearrangement lemma for Argˢ.
Argˢ≃ :
Argˢ v ≃
((∃ λ (([ s ] , _) : ∃ λ s → Tmˢ (erased s)) →
Erased (([] , s) ≡ v)) ⊎
(∃ λ ((s , [ ss , s′ ] , _) : Sort × ∃ λ v → Argˢ (erased v)) →
Erased ((s ∷ ss , s′) ≡ v)))
Argˢ≃ = Eq.↔⇒≃ (record
{ surjection = record
{ logical-equivalence = record
{ to = to
; from = from
}
; right-inverse-of = to∘from
}
; left-inverse-of = from∘to
})
where
RHS : @0 Valence → Type ℓ
RHS v =
(∃ λ (([ s ] , _) : ∃ λ s → Tmˢ (erased s)) →
Erased (([] , s) ≡ v)) ⊎
(∃ λ ((s , [ ss , s′ ] , _) : Sort × ∃ λ v → Argˢ (erased v)) →
Erased ((s ∷ ss , s′) ≡ v))
to : Argˢ v → RHS v
to (nil t) = inj₁ ((_ , t) , [ refl _ ])
to (cons a) = inj₂ ((_ , _ , a) , [ refl _ ])
from : RHS v → Argˢ v
from (inj₁ ((_ , t) , [ eq ])) = substᴱ Argˢ eq (nil t)
from (inj₂ ((_ , _ , a) , [ eq ])) = substᴱ Argˢ eq (cons a)
to∘from : ∀ x → to (from x) ≡ x
to∘from (inj₁ ((_ , t) , [ eq ])) = elim¹ᴱ
(λ eq → to (substᴱ Argˢ eq (nil t)) ≡
inj₁ ((_ , t) , [ eq ]))
(to (substᴱ Argˢ (refl _) (nil t)) ≡⟨ cong to substᴱ-refl ⟩
to (nil t) ≡⟨⟩
inj₁ ((_ , t) , [ refl _ ]) ∎)
eq
to∘from (inj₂ ((_ , _ , a) , [ eq ])) = elim¹ᴱ
(λ eq → to (substᴱ Argˢ eq (cons a)) ≡
inj₂ ((_ , _ , a) , [ eq ]))
(to (substᴱ Argˢ (refl _) (cons a)) ≡⟨ cong to substᴱ-refl ⟩
to (cons a) ≡⟨⟩
inj₂ ((_ , _ , a) , [ refl _ ]) ∎)
eq
from∘to : ∀ x → from (to x) ≡ x
from∘to (nil _) = substᴱ-refl
from∘to (cons _) = substᴱ-refl
----------------------------------------------------------------------
-- Alternative definitions of Tm/Args/Arg/Data and Term[_]
-- The following four definitions are indexed by /erased/ skeletons.
mutual
data Tm′ : @0 Tmˢ s → Type ℓ where
var : Var s → Tm′ (var {s = s})
op : Args′ asˢ → Tm′ (op o asˢ)
data Args′ : @0 Argsˢ vs → Type ℓ where
nil : Args′ nil
cons : Arg′ aˢ → Args′ asˢ → Args′ (cons aˢ asˢ)
data Arg′ : @0 Argˢ v → Type ℓ where
nil : Tm′ tˢ → Arg′ (nil tˢ)
cons : {@0 aˢ : Argˢ v} →
Var s → Arg′ aˢ → Arg′ (cons {s = s} aˢ)
Data′ : @0 Skeleton k s → Type ℓ
Data′ {k = var} {s = s} = λ _ → Var s
Data′ {k = tm} = Tm′
Data′ {k = args} = Args′
Data′ {k = arg} = Arg′
-- Lemmas used by Tm′≃Tm, Args′≃Args and Arg′≃Arg below.
private
module ′≃ where
mutual
to-Tm : {tˢ : Tmˢ s} → Tm′ tˢ → Tm tˢ
to-Tm {tˢ = var} (var x) = x
to-Tm {tˢ = op _ _} (op as) = to-Args as
to-Args : {asˢ : Argsˢ vs} → Args′ asˢ → Args asˢ
to-Args {asˢ = nil} nil = _
to-Args {asˢ = cons _ _} (cons a as) = to-Arg a , to-Args as
to-Arg : {aˢ : Argˢ v} → Arg′ aˢ → Arg aˢ
to-Arg {aˢ = nil _} (nil t) = to-Tm t
to-Arg {aˢ = cons _} (cons x a) = x , to-Arg a
mutual
from-Tm : (tˢ : Tmˢ s) → Tm tˢ → Tm′ tˢ
from-Tm var x = var x
from-Tm (op o asˢ) as = op (from-Args asˢ as)
from-Args : (asˢ : Argsˢ vs) → Args asˢ → Args′ asˢ
from-Args nil _ = nil
from-Args (cons aˢ asˢ) (a , as) =
cons (from-Arg aˢ a) (from-Args asˢ as)
from-Arg : (aˢ : Argˢ v) → Arg aˢ → Arg′ aˢ
from-Arg (nil tˢ) t = nil (from-Tm tˢ t)
from-Arg (cons aˢ) (x , a) = cons x (from-Arg aˢ a)
mutual
to-from-Tm :
(tˢ : Tmˢ s) (t : Tm tˢ) → to-Tm (from-Tm tˢ t) ≡ t
to-from-Tm var x = refl _
to-from-Tm (op o asˢ) as = to-from-Args asˢ as
to-from-Args :
(asˢ : Argsˢ vs) (as : Args asˢ) →
to-Args (from-Args asˢ as) ≡ as
to-from-Args nil _ = refl _
to-from-Args (cons aˢ asˢ) (a , as) =
cong₂ _,_ (to-from-Arg aˢ a) (to-from-Args asˢ as)
to-from-Arg :
(aˢ : Argˢ v) (a : Arg aˢ) → to-Arg (from-Arg aˢ a) ≡ a
to-from-Arg (nil tˢ) t = to-from-Tm tˢ t
to-from-Arg (cons aˢ) (x , a) = cong (x ,_) (to-from-Arg aˢ a)
mutual
from-to-Tm :
(tˢ : Tmˢ s) (t : Tm′ tˢ) → from-Tm tˢ (to-Tm t) ≡ t
from-to-Tm var (var x) = refl _
from-to-Tm (op _ _) (op as) = cong op (from-to-Args as)
from-to-Args :
{asˢ : Argsˢ vs} (as : Args′ asˢ) →
from-Args asˢ (to-Args as) ≡ as
from-to-Args {asˢ = nil} nil = refl _
from-to-Args {asˢ = cons _ _} (cons a as) =
cong₂ cons (from-to-Arg a) (from-to-Args as)
from-to-Arg :
{aˢ : Argˢ v} (a : Arg′ aˢ) → from-Arg aˢ (to-Arg a) ≡ a
from-to-Arg {aˢ = nil _} (nil t) = cong nil (from-to-Tm _ t)
from-to-Arg {aˢ = cons _} (cons x a) =
cong (cons x) (from-to-Arg a)
-- The alternative definitions of Tm, Args, Arg and Data are
-- pointwise equivalent to the original ones.
Tm′≃Tm : {tˢ : Tmˢ s} → Tm′ tˢ ≃ Tm tˢ
Tm′≃Tm {tˢ = tˢ} = Eq.↔→≃
to-Tm
(from-Tm _)
(to-from-Tm tˢ)
(from-to-Tm _)
where
open ′≃
Args′≃Args : {asˢ : Argsˢ vs} → Args′ asˢ ≃ Args asˢ
Args′≃Args = Eq.↔→≃
to-Args
(from-Args _)
(to-from-Args _)
from-to-Args
where
open ′≃
Arg′≃Arg : {aˢ : Argˢ v} → Arg′ aˢ ≃ Arg aˢ
Arg′≃Arg {aˢ = aˢ} = Eq.↔→≃
to-Arg
(from-Arg _)
(to-from-Arg aˢ)
from-to-Arg
where
open ′≃
Data′≃Data : ∀ k {@0 s} {tˢ : Skeleton k s} → Data′ tˢ ≃ Data tˢ
Data′≃Data var = F.id
Data′≃Data tm = Tm′≃Tm
Data′≃Data args = Args′≃Args
Data′≃Data arg = Arg′≃Arg
-- The following alternative definition of Term[_] uses Data′
-- instead of Data.
Term[_]′ :
(k : Term-kind) →
@0 Vars → @0 Sort-kind k → Type ℓ
Term[ k ]′ xs s =
∃ λ (tˢ : Skeleton k s) →
∃ λ (t : Data′ tˢ) →
Erased (Wf xs tˢ (_≃_.to (Data′≃Data k) t))
-- This alternative definition is also pointwise equivalent to the
-- original one.
Term′≃Term : Term[ k ]′ xs s ≃ Term[ k ] xs s
Term′≃Term {k = k} = ∃-cong λ _ → Σ-cong (Data′≃Data k) λ _ → F.id
----------------------------------------------------------------------
-- Decision procedures for equality
-- Erased equality is decidable for Term-kind.
--
-- This decision procedure is not optimised.
infix 4 _≟Term-kind_
_≟Term-kind_ : Decidable-erased-equality Term-kind
_≟Term-kind_ = $⟨ Fin._≟_ ⟩
Decidable-equality (Fin 4) ↝⟨ Decidable-equality→Decidable-erased-equality ⟩
Decidable-erased-equality (Fin 4) ↝⟨ Decidable-erased-equality-map (_≃_.surjection $ inverse Term-kind≃Fin-4) ⟩□
Decidable-erased-equality Term-kind □
-- Erased equality is decidable for Skeleton k s.
infix 4 _≟ˢ_ _≟Tmˢ_ _≟Argsˢ_ _≟Argˢ_
mutual
_≟ˢ_ : Decidable-erased-equality (Skeleton k s)
_≟ˢ_ {k = var} = _≟Varˢ_
_≟ˢ_ {k = tm} = _≟Tmˢ_
_≟ˢ_ {k = args} = _≟Argsˢ_
_≟ˢ_ {k = arg} = _≟Argˢ_
private
_≟Varˢ_ : Decidable-erased-equality (Varˢ s)
var ≟Varˢ var = yes [ refl _ ]
_≟Tmˢ_ : Decidable-erased-equality (Tmˢ s)
var ≟Tmˢ var = yes [ refl _ ]
var ≟Tmˢ op _ _ = $⟨ no [ (λ ()) ] ⟩
Dec-Erased ⊥ ↝⟨ Dec-Erased-map (from-isomorphism (Eq.≃-≡ Tmˢ≃) F.∘
from-isomorphism (inverse Bijection.≡↔⊎)) ⟩□
Dec-Erased (var ≡ op _ _) □
op _ _ ≟Tmˢ var = $⟨ no [ (λ ()) ] ⟩
Dec-Erased ⊥ ↝⟨ Dec-Erased-map (from-isomorphism (Eq.≃-≡ Tmˢ≃) F.∘
from-isomorphism (inverse Bijection.≡↔⊎)) ⟩□
Dec-Erased (op _ _ ≡ var) □
op o₁ as₁ ≟Tmˢ op o₂ as₂ = $⟨ decidable-erased⇒dec-erased⇒Σ-dec-erased _≟O_ (λ _ → _ ≟Argsˢ as₂) ⟩
Dec-Erased ((o₁ , as₁) ≡ (o₂ , as₂)) ↝⟨ Dec-Erased-map (from-isomorphism (Eq.≃-≡ Tmˢ≃) F.∘
from-isomorphism Bijection.≡↔inj₂≡inj₂) ⟩□
Dec-Erased (op o₁ as₁ ≡ op o₂ as₂) □
_≟Argsˢ_ : Decidable-erased-equality (Argsˢ vs)
nil ≟Argsˢ nil = $⟨ yes [ refl _ ] ⟩
Dec-Erased ([ refl _ ] ≡ [ refl _ ]) ↝⟨ Dec-Erased-map (from-isomorphism (Eq.≃-≡ Argsˢ≃) F.∘
from-isomorphism Bijection.≡↔inj₁≡inj₁) ⟩□
Dec-Erased (nil ≡ nil) □
cons a₁ as₁ ≟Argsˢ cons a₂ as₂ = $⟨ dec-erased⇒dec-erased⇒×-dec-erased
(set⇒dec-erased⇒dec-erased⇒Σ-dec-erased
(H-level-Erased 2 (×-closure 2 (H-level-List 0 Sort-set) Sort-set))
(yes [ refl _ ])
(λ _ → _ ≟Argˢ a₂))
(set⇒dec-erased⇒dec-erased⇒Σ-dec-erased
(H-level-Erased 2 (H-level-List 0 Valence-set))
(yes [ refl _ ])
(λ _ → _ ≟Argsˢ as₂)) ⟩
Dec-Erased (((_ , a₁) , _ , as₁) ≡ ((_ , a₂) , _ , as₂)) ↝⟨ Dec-Erased-map (from-isomorphism $ ignore-propositional-component $
H-level-Erased 1 (H-level-List 0 Valence-set)) ⟩
Dec-Erased ((((_ , a₁) , _ , as₁) , [ refl _ ]) ≡
(((_ , a₂) , _ , as₂) , [ refl _ ])) ↝⟨ Dec-Erased-map (
from-isomorphism (Eq.≃-≡ Argsˢ≃) F.∘
from-isomorphism Bijection.≡↔inj₂≡inj₂) ⟩□
Dec-Erased (cons a₁ as₁ ≡ cons a₂ as₂) □
_≟Argˢ_ : Decidable-erased-equality (Argˢ v)
nil t₁ ≟Argˢ nil t₂ = $⟨ set⇒dec-erased⇒dec-erased⇒Σ-dec-erased
(H-level-Erased 2 Sort-set)
(yes [ refl _ ])
(λ _ → _ ≟Tmˢ t₂) ⟩
Dec-Erased ((_ , t₁) ≡ (_ , t₂)) ↝⟨ Dec-Erased-map (from-isomorphism $ ignore-propositional-component $
H-level-Erased 1 Valence-set) ⟩
Dec-Erased (((_ , t₁) , [ refl _ ]) ≡ ((_ , t₂) , [ refl _ ])) ↝⟨ Dec-Erased-map (from-isomorphism (Eq.≃-≡ Argˢ≃) F.∘
from-isomorphism Bijection.≡↔inj₁≡inj₁) ⟩□
Dec-Erased (nil t₁ ≡ nil t₂) □
cons a₁ ≟Argˢ cons a₂ = $⟨ dec-erased⇒dec-erased⇒×-dec-erased
(yes [ refl _ ])
(set⇒dec-erased⇒dec-erased⇒Σ-dec-erased
(H-level-Erased 2 Valence-set)
(yes [ refl _ ])
(λ _ → _ ≟Argˢ a₂)) ⟩
Dec-Erased ((_ , _ , a₁) ≡ (_ , _ , a₂)) ↝⟨ Dec-Erased-map (from-isomorphism $ ignore-propositional-component $
H-level-Erased 1 Valence-set) ⟩
Dec-Erased (((_ , _ , a₁) , [ refl _ ]) ≡
((_ , _ , a₂) , [ refl _ ])) ↝⟨ Dec-Erased-map (
from-isomorphism (Eq.≃-≡ Argˢ≃) F.∘ from-isomorphism Bijection.≡↔inj₂≡inj₂) ⟩□
Dec-Erased (cons a₁ ≡ cons a₂) □
-- Erased equality is decidable for Data tˢ.
mutual
equal?-Data :
(tˢ : Skeleton k s) → Decidable-erased-equality (Data tˢ)
equal?-Data {k = var} = λ _ → _≟V_
equal?-Data {k = tm} = equal?-Tm
equal?-Data {k = args} = equal?-Args
equal?-Data {k = arg} = equal?-Arg
private
equal?-Tm : (tˢ : Tmˢ s) → Decidable-erased-equality (Tm tˢ)
equal?-Tm var x₁ x₂ = x₁ ≟V x₂
equal?-Tm (op o asˢ) as₁ as₂ = equal?-Args asˢ as₁ as₂
equal?-Args :
(asˢ : Argsˢ vs) → Decidable-erased-equality (Args asˢ)
equal?-Args nil _ _ = yes [ refl _ ]
equal?-Args (cons aˢ asˢ) (a₁ , as₁) (a₂ , as₂) =
dec-erased⇒dec-erased⇒×-dec-erased
(equal?-Arg aˢ a₁ a₂)
(equal?-Args asˢ as₁ as₂)
equal?-Arg : (aˢ : Argˢ v) → Decidable-erased-equality (Arg aˢ)
equal?-Arg (nil tˢ) t₁ t₂ = equal?-Tm tˢ t₁ t₂
equal?-Arg (cons aˢ) (x₁ , a₁) (x₂ , a₂) =
dec-erased⇒dec-erased⇒×-dec-erased
(x₁ ≟V x₂)
(equal?-Arg aˢ a₁ a₂)
-- Erased equality is decidable for Data′ tˢ.
--
-- (Presumably it is possible to prove this without converting to
-- Data, and in that case the sort and skeleton arguments can
-- perhaps be erased.)
equal?-Data′ :
∀ k {s} {tˢ : Skeleton k s} →
Decidable-erased-equality (Data′ tˢ)
equal?-Data′ k {tˢ = tˢ} t₁ t₂ = $⟨ equal?-Data tˢ _ _ ⟩
Dec-Erased (_≃_.to (Data′≃Data k) t₁ ≡ _≃_.to (Data′≃Data k) t₂) ↝⟨ Dec-Erased-map (from-equivalence (Eq.≃-≡ (Data′≃Data k))) ⟩□
Dec-Erased (t₁ ≡ t₂) □
-- The Wf predicate is propositional.
mutual
@0 Wf-propositional :
∀ {s} (tˢ : Skeleton k s) {t : Data tˢ} →
Is-proposition (Wf xs tˢ t)
Wf-propositional {k = var} var = ∈-propositional
Wf-propositional {k = tm} = Wf-tm-propositional
Wf-propositional {k = args} = Wf-args-propositional
Wf-propositional {k = arg} = Wf-arg-propositional
private
@0 Wf-tm-propositional :
(tˢ : Tmˢ s) {t : Tm tˢ} → Is-proposition (Wf-tm xs tˢ t)
Wf-tm-propositional var = ∈-propositional
Wf-tm-propositional (op o asˢ) = Wf-args-propositional asˢ
@0 Wf-args-propositional :
(asˢ : Argsˢ vs) {as : Args asˢ} →
Is-proposition (Wf-args xs asˢ as)
Wf-args-propositional nil _ _ = refl _
Wf-args-propositional (cons aˢ asˢ) (wf₁ , wfs₁) (wf₂ , wfs₂) =
cong₂ _,_
(Wf-arg-propositional aˢ wf₁ wf₂)
(Wf-args-propositional asˢ wfs₁ wfs₂)
@0 Wf-arg-propositional :
(aˢ : Argˢ v) {a : Arg aˢ} →
Is-proposition (Wf-arg xs aˢ a)
Wf-arg-propositional (nil tˢ) = Wf-tm-propositional tˢ
Wf-arg-propositional (cons aˢ) wf₁ wf₂ =
⟨ext⟩ λ y → ⟨ext⟩ λ y∉xs →
Wf-arg-propositional aˢ (wf₁ y y∉xs) (wf₂ y y∉xs)
-- Erased equality is decidable for Term[_]′.
infix 4 _≟Term′_
_≟Term′_ : ∀ {s} → Decidable-erased-equality (Term[ k ]′ xs s)
_≟Term′_ {k = k} =
decidable-erased⇒decidable-erased⇒Σ-decidable-erased
_≟ˢ_
λ {tˢ} →
decidable-erased⇒decidable-erased⇒Σ-decidable-erased
(equal?-Data′ k)
λ _ _ → yes [ []-cong [ Wf-propositional tˢ _ _ ] ]
-- Erased equality is decidable for Term[_].
--
-- TODO: Is it possible to prove this without converting to
-- Term[_]′?
infix 4 _≟Term_
_≟Term_ : ∀ {s} → Decidable-erased-equality (Term[ k ] xs s)
_≟Term_ {k = k} {xs = xs} {s = s} = $⟨ _≟Term′_ ⟩
Decidable-erased-equality (Term[ k ]′ xs s) ↝⟨ Decidable-erased-equality-map (_≃_.surjection Term′≃Term) ⟩□
Decidable-erased-equality (Term[ k ] xs s) □
-- Skeleton, Data, Data′, Term[_] and Term[_]′ are sets (pointwise,
-- in erased contexts).
@0 Skeleton-set : Is-set (Skeleton k s)
Skeleton-set =
decidable⇒set $
Decidable-erased-equality≃Decidable-equality _ _≟ˢ_
@0 Data-set : (tˢ : Skeleton k s) → Is-set (Data tˢ)
Data-set tˢ =
decidable⇒set $
Decidable-erased-equality≃Decidable-equality _ (equal?-Data tˢ)
@0 Data′-set : ∀ k {s} {tˢ : Skeleton k s} → Is-set (Data′ tˢ)
Data′-set k =
decidable⇒set $
Decidable-erased-equality≃Decidable-equality _ (equal?-Data′ k)
@0 Term-set : Is-set (Term[ k ] xs s)
Term-set =
decidable⇒set $
Decidable-erased-equality≃Decidable-equality _ _≟Term_
@0 Term′-set : Is-set (Term[ k ]′ xs s)
Term′-set =
decidable⇒set $
Decidable-erased-equality≃Decidable-equality _ _≟Term′_
----------------------------------------------------------------------
-- A lemma
-- Changing the well-formedness proof does not actually change
-- anything.
@0 Wf-proof-irrelevant :
∀ {tˢ : Skeleton k s} {t : Data tˢ} {wf₁ wf₂} →
_≡_ {A = Term[ k ] xs s} (tˢ , t , [ wf₁ ]) (tˢ , t , [ wf₂ ])
Wf-proof-irrelevant {tˢ = tˢ} =
cong (λ wf → tˢ , _ , [ wf ]) (Wf-propositional tˢ _ _)
----------------------------------------------------------------------
-- An elimination principle for well-formed terms ("structural
-- induction modulo fresh renaming")
-- The eliminator's arguments.
record Wf-elim
(P : ∀ k {@0 xs s} → Term[ k ] xs s → Type p) :
Type (ℓ ⊔ p) where
no-eta-equality
field
varʳ : ∀ {s} (x : Var s) (@0 x∈ : (_ , x) ∈ xs) →
P var (var-wf x x∈)
varʳ′ : ∀ {s} (x : Var s) (@0 wf : Wf xs Varˢ.var x) →
P var (var-wf x wf) →
P tm (var-wf x wf)
opʳ : ∀ (o : Op s) asˢ as (@0 wfs : Wf xs asˢ as) →
P args (asˢ , as , [ wfs ]) →
P tm (op-wf o asˢ as wfs)
nilʳ : P args {xs = xs} nil-wfs
consʳ : ∀ aˢ a asˢ as
(@0 wf : Wf {s = v} xs aˢ a)
(@0 wfs : Wf {s = vs} xs asˢ as) →
P arg (aˢ , a , [ wf ]) →
P args (asˢ , as , [ wfs ]) →
P args (cons-wfs aˢ asˢ a as wf wfs)
nilʳ′ : ∀ tˢ t (@0 wf : Wf {s = s} xs tˢ t) →
P tm (tˢ , t , [ wf ]) →
P arg (nil-wf tˢ t wf)
consʳ′ : ∀ {@0 xs : Vars} {s}
(aˢ : Argˢ v) (x : Var s) a (@0 wf) →
(∀ y (@0 y∉ : (_ , y) ∉ xs) →
P arg (aˢ , rename₁ x y aˢ a , [ wf y y∉ ])) →
P arg (cons-wf aˢ x a wf)
-- The eliminator.
-- TODO: Can one implement a more efficient eliminator that does not
-- use rename₁, and that merges all the renamings into one?
module _
{P : ∀ k {@0 xs s} → Term[ k ] xs s → Type p}
(e : Wf-elim P)
where
open Wf-elim
mutual
wf-elim : ∀ {xs} (t : Term[ k ] xs s) → P k t
wf-elim {k = var} (var , x , [ wf ]) =
wf-elim-Var x wf
wf-elim {k = tm} (tˢ , t , [ wf ]) =
wf-elim-Term tˢ t wf
wf-elim {k = args} (asˢ , as , [ wfs ]) =
wf-elim-Arguments asˢ as wfs
wf-elim {k = arg} (aˢ , a , [ wf ]) =
wf-elim-Argument aˢ a wf
private
wf-elim-Var :
∀ {xs s} (x : Var s) (@0 wf : Wf xs Varˢ.var x) →
P var (var , x , [ wf ])
wf-elim-Var x wf = e .varʳ x wf
wf-elim-Term :
∀ {xs} (tˢ : Tmˢ s) (t : Tm tˢ) (@0 wf : Wf-tm xs tˢ t) →
P tm (tˢ , t , [ wf ])
wf-elim-Term var x wf =
e .varʳ′ x wf (wf-elim-Var x wf)
wf-elim-Term (op o asˢ) as wfs =
e .opʳ o asˢ as wfs (wf-elim-Arguments asˢ as wfs)
wf-elim-Arguments :
∀ {xs} (asˢ : Argsˢ vs) (as : Args asˢ)
(@0 wfs : Wf-args xs asˢ as) →
P args (asˢ , as , [ wfs ])
wf-elim-Arguments nil _ _ = e .nilʳ
wf-elim-Arguments (cons aˢ asˢ) (a , as) (wf , wfs) =
e .consʳ aˢ a asˢ as wf wfs
(wf-elim-Argument aˢ a wf)
(wf-elim-Arguments asˢ as wfs)
wf-elim-Argument :
∀ {xs} (aˢ : Argˢ v) (a : Arg aˢ) (@0 wf : Wf-arg xs aˢ a) →
P arg (aˢ , a , [ wf ])
wf-elim-Argument (nil tˢ) t wf =
e .nilʳ′ tˢ t wf (wf-elim-Term tˢ t wf)
wf-elim-Argument (cons aˢ) (x , a) wf =
e .consʳ′ aˢ x a wf λ y y∉ →
wf-elim-Argument aˢ (rename₁ x y aˢ a) (wf y y∉)
----------------------------------------------------------------------
-- Free variables
-- An alternative definition of what it means for a variable to be
-- free in a term.
--
-- This definition is based on Harper's.
module _ {s} (x : Var s) where
private
Free-in-var :
∀ {s′} → Var s′ →
∃ λ (A : Type ℓ) → Erased (Is-proposition A)
Free-in-var y =
_≡_ {A = ∃Var} (_ , x) (_ , y)
, [ ∃Var-set ]
mutual
Free-in-term :
∀ {xs} (tˢ : Tmˢ s′) t →
@0 Wf ((_ , x) ∷ xs) tˢ t →
∃ λ (A : Type ℓ) → Erased (Is-proposition A)
Free-in-term var y _ = Free-in-var y
Free-in-term (op o asˢ) as wf =
Free-in-arguments asˢ as wf
Free-in-arguments :
∀ {xs} (asˢ : Argsˢ vs) as →
@0 Wf ((_ , x) ∷ xs) asˢ as →
∃ λ (A : Type ℓ) → Erased (Is-proposition A)
Free-in-arguments nil _ _ = ⊥ , [ ⊥-propositional ]
Free-in-arguments (cons aˢ asˢ) (a , as) (wf , wfs) =
(proj₁ (Free-in-argument aˢ a wf) ∥⊎∥
proj₁ (Free-in-arguments asˢ as wfs))
, [ ∥⊎∥-propositional ]
Free-in-argument :
∀ {xs} (aˢ : Argˢ v) a →
@0 Wf ((_ , x) ∷ xs) aˢ a →
∃ λ (A : Type ℓ) → Erased (Is-proposition A)
Free-in-argument (nil tˢ) t wf = Free-in-term tˢ t wf
Free-in-argument {xs = xs} (cons aˢ) (y , a) wf =
Π _ λ z → Π (Erased ((_ , z) ∉ (_ , x) ∷ xs)) λ ([ z∉ ]) →
Free-in-argument
aˢ
(rename₁ y z aˢ a)
(subst (λ xs′ → Wf xs′ aˢ (rename₁ y z aˢ a))
swap
(wf z z∉))
where
Π :
(A : Type ℓ) →
(A → ∃ λ (B : Type ℓ) → Erased (Is-proposition B)) →
∃ λ (B : Type ℓ) → Erased (Is-proposition B)
Π A B =
(∀ x → proj₁ (B x))
, [ (Π-closure ext 1 λ x →
erased (proj₂ (B x)))
]
-- A predicate that holds if x is free in the term.
Free-in : ∀ {xs} → Term[ k ] ((_ , x) ∷ xs) s′ → Type ℓ
Free-in {k = var} (var , y , [ wf ]) =
proj₁ (Free-in-var y)
Free-in {k = tm} (tˢ , t , [ wf ]) =
proj₁ (Free-in-term tˢ t wf)
Free-in {k = args} (asˢ , as , [ wfs ]) =
proj₁ (Free-in-arguments asˢ as wfs)
Free-in {k = arg} (aˢ , a , [ wf ]) =
proj₁ (Free-in-argument aˢ a wf)
abstract
-- The alternative definition of what it means for a variable to
-- be free is propositional (in erased contexts).
@0 Free-in-propositional :
(t : Term[ k ] ((_ , x) ∷ xs) s′) →
Is-proposition (Free-in t)
Free-in-propositional {k = var} (var , y , [ wf ]) =
erased (proj₂ (Free-in-var y))
Free-in-propositional {k = tm} (tˢ , t , [ wf ]) =
erased (proj₂ (Free-in-term tˢ t wf))
Free-in-propositional {k = args} (asˢ , as , [ wfs ]) =
erased (proj₂ (Free-in-arguments asˢ as wfs))
Free-in-propositional {k = arg} (aˢ , a , [ wf ]) =
erased (proj₂ (Free-in-argument aˢ a wf))
abstract
mutual
-- Variables that are free according to the alternative
-- definition are in the set of free variables (in erased
-- contexts).
@0 Free-free :
∀ (tˢ : Skeleton k s′) {t} (wf : Wf ((s , x) ∷ xs) tˢ t) →
Free-in x (tˢ , t , [ wf ]) → (s , x) ∈ free tˢ t
Free-free {k = var} = λ yˢ wf → Free-free-Var yˢ wf
Free-free {k = tm} = Free-free-Tm
Free-free {k = args} = Free-free-Args
Free-free {k = arg} = Free-free-Arg
private
@0 Free-free-Var :
∀ {s} {x : Var s} (yˢ : Varˢ s′) {y : Var s′}
(@0 wf : Wf ((_ , x) ∷ xs) yˢ y) →
Free-in x (yˢ , y , [ wf ]) → (_ , x) ∈ free yˢ y
Free-free-Var var _ = ≡→∈singleton
@0 Free-free-Tm :
∀ (tˢ : Tmˢ s′) {t} (wf : Wf ((_ , x) ∷ xs) tˢ t) →
Free-in x (tˢ , t , [ wf ]) → (_ , x) ∈ free tˢ t
Free-free-Tm var wf = Free-free-Var var wf
Free-free-Tm (op o asˢ) wfs = Free-free-Args asˢ wfs
@0 Free-free-Args :
∀ (asˢ : Argsˢ vs) {as} (wfs : Wf ((_ , x) ∷ xs) asˢ as) →
Free-in x (asˢ , as , [ wfs ]) →
(_ , x) ∈ free asˢ as
Free-free-Args {x = x} (cons aˢ asˢ) {as = a , as} (wf , wfs) =
Free-in x (aˢ , a , [ wf ]) ∥⊎∥ Free-in x (asˢ , as , [ wfs ]) ↝⟨ Free-free-Arg aˢ wf ∥⊎∥-cong Free-free-Args asˢ wfs ⟩
(_ , x) ∈ free aˢ a ∥⊎∥ (_ , x) ∈ free asˢ as ↔⟨ inverse ∈∪≃ ⟩□
(_ , x) ∈ free aˢ a ∪ free asˢ as □
@0 Free-free-Arg :
∀ (aˢ : Argˢ v) {a} (wf : Wf ((_ , x) ∷ xs) aˢ a) →
Free-in x (aˢ , a , [ wf ]) → (_ , x) ∈ free aˢ a
Free-free-Arg (nil tˢ) = Free-free-Tm tˢ
Free-free-Arg {x = x} {xs = xs}
(cons {s = s} aˢ) {a = y , a} wf =
let xxs = (_ , x) ∷ xs
x₁ , x₁∉ = fresh-not-erased xxs
x₂ , x₂≢x₁ , x₂∉ = $⟨ fresh-not-erased ((_ , x₁) ∷ xxs) ⟩
(∃ λ x₂ → (_ , x₂) ∉ (_ , x₁) ∷ xxs) ↝⟨ (∃-cong λ _ → →-cong₁ ext ∈∷≃) ⟩
(∃ λ x₂ → ¬ ((_ , x₂) ≡ (_ , x₁) ∥⊎∥ (_ , x₂) ∈ xxs)) ↝⟨ (∃-cong λ _ → Π∥⊎∥↔Π×Π λ _ → ⊥-propositional) ⟩□
(∃ λ x₂ → (_ , x₂) ≢ (_ , x₁) × (_ , x₂) ∉ xxs) □
in
(∀ z (z∉ : Erased ((_ , z) ∉ (_ , x) ∷ xs)) →
Free-in x
( aˢ
, rename₁ y z aˢ a
, [ subst (λ xs → Wf xs aˢ (rename₁ y z aˢ a))
swap
(wf z (erased z∉)) ]
)) ↝⟨ (λ hyp z z∉ → Free-free-Arg
aˢ
(subst (λ xs → Wf xs aˢ (rename₁ y z aˢ a))
swap
(wf z z∉))
(hyp z [ z∉ ])) ⟩
(∀ z → (_ , z) ∉ (_ , x) ∷ xs →
(_ , x) ∈ free aˢ (rename₁ y z aˢ a)) ↝⟨ (λ hyp z z∉ → free-rename₁⊆ aˢ _ (hyp z z∉)) ⦂ (_ → _) ⟩
(∀ z → (_ , z) ∉ (_ , x) ∷ xs →
(_ , x) ∈ (_ , z) ∷ fs′) ↝⟨ (λ hyp → hyp x₁ x₁∉ , hyp x₂ x₂∉) ⟩
(_ , x) ∈ (_ , x₁) ∷ fs′ ×
(_ , x) ∈ (_ , x₂) ∷ fs′ ↔⟨ ∈∷≃ ×-cong ∈∷≃ ⟩
((_ , x) ≡ (_ , x₁) ∥⊎∥ (_ , x) ∈ fs′) ×
((_ , x) ≡ (_ , x₂) ∥⊎∥ (_ , x) ∈ fs′) ↔⟨ (Σ-∥⊎∥-distrib-right (λ _ → ∃Var-set) ∥⊎∥-cong F.id) F.∘
Σ-∥⊎∥-distrib-left ∥⊎∥-propositional ⟩
((_ , x) ≡ (_ , x₁) × (_ , x) ≡ (_ , x₂) ∥⊎∥
(_ , x) ∈ fs′ × (_ , x) ≡ (_ , x₂)) ∥⊎∥
((_ , x) ≡ (_ , x₁) ∥⊎∥ (_ , x) ∈ fs′) × (_ , x) ∈ fs′ ↝⟨ ((λ (y≡x₁ , y≡x₂) → x₂≢x₁ (trans (sym y≡x₂) y≡x₁)) ∥⊎∥-cong proj₁)
∥⊎∥-cong
proj₂ ⟩
(⊥ ∥⊎∥ (_ , x) ∈ fs′) ∥⊎∥ (_ , x) ∈ fs′ ↔⟨ ∥⊎∥-idempotent ∈-propositional F.∘
(∥⊎∥-left-identity ∈-propositional ∥⊎∥-cong F.id) ⟩□
(_ , x) ∈ fs′ □
where
fs′ : Vars
fs′ = del (_ , y) (free aˢ a)
mutual
-- Every member of the set of free variables is free according
-- to the alternative definition (in erased contexts).
@0 free-Free :
∀ (tˢ : Skeleton k s) {t} (wf : Wf ((s′ , x) ∷ xs) tˢ t) →
(s′ , x) ∈ free tˢ t → Free-in x (tˢ , t , [ wf ])
free-Free {k = var} = free-Free-Var
free-Free {k = tm} = free-Free-Tm
free-Free {k = args} = free-Free-Args
free-Free {k = arg} = free-Free-Arg
private
@0 free-Free-Var :
∀ (yˢ : Varˢ s) {y} (wf : Wf ((_ , x) ∷ xs) yˢ y) →
(_ , x) ∈ free yˢ y → Free-in x (yˢ , y , [ wf ])
free-Free-Var {x = x} var {y = y} _ =
(_ , x) ∈ singleton (_ , y) ↔⟨ ∈singleton≃ ⟩
∥ (_ , x) ≡ (_ , y) ∥ ↔⟨ ∥∥↔ ∃Var-set ⟩□
(_ , x) ≡ (_ , y) □
@0 free-Free-Tm :
∀ (tˢ : Tmˢ s) {t} (wf : Wf-tm ((_ , x) ∷ xs) tˢ t) →
(_ , x) ∈ free tˢ t → Free-in x (tˢ , t , [ wf ])
free-Free-Tm var = free-Free-Var var
free-Free-Tm (op o asˢ) = free-Free-Args asˢ
@0 free-Free-Args :
∀ (asˢ : Argsˢ vs) {as} (wf : Wf ((_ , x) ∷ xs) asˢ as) →
(_ , x) ∈ free asˢ as → Free-in x (asˢ , as , [ wf ])
free-Free-Args {x = x} (cons aˢ asˢ) {as = a , as} (wf , wfs) =
(_ , x) ∈ free aˢ a ∪ free asˢ as ↔⟨ ∈∪≃ ⟩
(_ , x) ∈ free aˢ a ∥⊎∥ (_ , x) ∈ free asˢ as ↝⟨ free-Free-Arg aˢ wf
∥⊎∥-cong
free-Free-Args asˢ wfs ⟩□
Free-in x (aˢ , a , [ wf ]) ∥⊎∥ Free-in x (asˢ , as , [ wfs ]) □
@0 free-Free-Arg :
∀ (aˢ : Argˢ v) {a} (wf : Wf ((_ , x) ∷ xs) aˢ a) →
(_ , x) ∈ free aˢ a → Free-in x (aˢ , a , [ wf ])
free-Free-Arg (nil tˢ) = free-Free-Tm tˢ
free-Free-Arg {x = x} {xs = xs} (cons aˢ) {a = y , a} wf =
(_ , x) ∈ del (_ , y) (free aˢ a) ↔⟨ ∈delete≃ merely-equal?-∃Var ⟩
(_ , x) ≢ (_ , y) × (_ , x) ∈ free aˢ a ↝⟨ Σ-map id (λ x∈ _ → ⊆free-rename₁ aˢ _ x∈) ⟩
(_ , x) ≢ (_ , y) ×
(∀ z → (_ , x) ∈ (_ , y) ∷ free aˢ (rename₁ y z aˢ a)) ↔⟨ (∃-cong λ x≢y → ∀-cong ext λ z →
drop-⊥-left-∥⊎∥ ∈-propositional x≢y F.∘
from-equivalence ∈∷≃) ⟩
(_ , x) ≢ (_ , y) ×
(∀ z → (_ , x) ∈ free aˢ (rename₁ y z aˢ a)) ↝⟨ proj₂ ⟩
(∀ z → (_ , x) ∈ free aˢ (rename₁ y z aˢ a)) ↝⟨ (λ hyp z _ → hyp z) ⟩
(∀ z → (_ , z) ∉ (_ , x) ∷ xs →
(_ , x) ∈ free aˢ (rename₁ y z aˢ a)) ↝⟨ (λ x∈ z z∉ →
free-Free-Arg aˢ
(subst (λ xs → Wf xs aˢ (rename₁ y z aˢ a))
swap
(wf z (erased z∉)))
(x∈ z (Stable-¬ z∉))) ⟩□
(∀ z (z∉ : Erased ((_ , z) ∉ (_ , x) ∷ xs)) →
Free-in x
( aˢ
, rename₁ y z aˢ a
, [ subst (λ xs → Wf xs aˢ (rename₁ y z aˢ a))
swap
(wf z (erased z∉))
]
)) □
----------------------------------------------------------------------
-- Lemmas related to the Wf predicate
abstract
-- Weakening of the Wf predicate.
mutual
@0 weaken-Wf :
xs ⊆ ys → ∀ (tˢ : Skeleton k s) {t} →
Wf xs tˢ t → Wf ys tˢ t
weaken-Wf {k = var} = weaken-Wf-var
weaken-Wf {k = tm} = weaken-Wf-tm
weaken-Wf {k = args} = weaken-Wf-args
weaken-Wf {k = arg} = weaken-Wf-arg
private
@0 weaken-Wf-var :
xs ⊆ ys → ∀ (xˢ : Varˢ s) {x} →
Wf xs xˢ x → Wf ys xˢ x
weaken-Wf-var xs⊆ys var = xs⊆ys _
@0 weaken-Wf-tm :
xs ⊆ ys → ∀ (tˢ : Tmˢ s) {t} →
Wf xs tˢ t → Wf ys tˢ t
weaken-Wf-tm xs⊆ys var = weaken-Wf-var xs⊆ys var
weaken-Wf-tm xs⊆ys (op o asˢ) = weaken-Wf-args xs⊆ys asˢ
@0 weaken-Wf-args :
xs ⊆ ys → ∀ (asˢ : Argsˢ vs) {as} →
Wf xs asˢ as → Wf ys asˢ as
weaken-Wf-args xs⊆ys nil = id
weaken-Wf-args xs⊆ys (cons aˢ asˢ) =
Σ-map (weaken-Wf-arg xs⊆ys aˢ)
(weaken-Wf-args xs⊆ys asˢ)
@0 weaken-Wf-arg :
xs ⊆ ys → ∀ (aˢ : Argˢ v) {a} →
Wf xs aˢ a → Wf ys aˢ a
weaken-Wf-arg xs⊆ys (nil tˢ) = weaken-Wf-tm xs⊆ys tˢ
weaken-Wf-arg xs⊆ys (cons aˢ) =
λ wf y y∉ys →
weaken-Wf-arg (∷-cong-⊆ xs⊆ys) aˢ (wf y (y∉ys ∘ xs⊆ys _))
-- A term is well-formed for its set of free variables.
mutual
@0 wf-free :
∀ (tˢ : Skeleton k s) {t} → Wf (free tˢ t) tˢ t
wf-free {k = var} = wf-free-Var
wf-free {k = tm} = wf-free-Tm
wf-free {k = args} = wf-free-Args
wf-free {k = arg} = wf-free-Arg
private
@0 wf-free-Var :
∀ (xˢ : Varˢ s) {x} → Wf (free xˢ x) xˢ x
wf-free-Var var = ≡→∈∷ (refl _)
@0 wf-free-Tm :
∀ (tˢ : Tmˢ s) {t} → Wf (free tˢ t) tˢ t
wf-free-Tm var = wf-free-Var var
wf-free-Tm (op o asˢ) = wf-free-Args asˢ
@0 wf-free-Args :
∀ (asˢ : Argsˢ vs) {as} → Wf (free asˢ as) asˢ as
wf-free-Args nil = _
wf-free-Args (cons aˢ asˢ) =
weaken-Wf-arg (λ _ → ∈→∈∪ˡ) aˢ (wf-free-Arg aˢ)
, weaken-Wf-args (λ _ → ∈→∈∪ʳ (free-Arg aˢ _))
asˢ (wf-free-Args asˢ)
@0 wf-free-Arg :
∀ (aˢ : Argˢ v) {a : Arg aˢ} → Wf (free aˢ a) aˢ a
wf-free-Arg (nil tˢ) = wf-free-Tm tˢ
wf-free-Arg (cons aˢ) {a = x , a} = λ y y∉ →
$⟨ wf-free-Arg aˢ ⟩
Wf-arg (free aˢ (rename₁ x y aˢ a))
aˢ (rename₁ x y aˢ a) ↝⟨ weaken-Wf (free-rename₁⊆ aˢ) aˢ ⟩□
Wf-arg ((_ , y) ∷ del (_ , x) (free aˢ a))
aˢ (rename₁ x y aˢ a) □
-- If a term is well-formed with respect to a set of variables xs,
-- then xs is a superset of the term's set of free variables.
mutual
@0 free-⊆ :
∀ (tˢ : Skeleton k s) {t} → Wf xs tˢ t → free tˢ t ⊆ xs
free-⊆ {k = var} = free-⊆-Var
free-⊆ {k = tm} = free-⊆-Tm
free-⊆ {k = args} = free-⊆-Args
free-⊆ {k = arg} = free-⊆-Arg
private
@0 free-⊆-Var :
∀ (xˢ : Varˢ s) {x} → Wf xs xˢ x → free xˢ x ⊆ xs
free-⊆-Var {xs = xs} var {x = x} wf y =
y ∈ singleton (_ , x) ↔⟨ ∈singleton≃ ⟩
∥ y ≡ (_ , x) ∥ ↔⟨ ∥∥↔ ∃Var-set ⟩
y ≡ (_ , x) ↝⟨ (λ eq → subst (_∈ xs) (sym eq) wf) ⟩□
y ∈ xs □
@0 free-⊆-Tm :
∀ (tˢ : Tmˢ s) {t} → Wf xs tˢ t → free tˢ t ⊆ xs
free-⊆-Tm var = free-⊆-Var var
free-⊆-Tm (op o asˢ) = free-⊆-Args asˢ
@0 free-⊆-Args :
∀ (asˢ : Argsˢ vs) {as} → Wf xs asˢ as → free asˢ as ⊆ xs
free-⊆-Args nil _ _ = λ ()
free-⊆-Args {xs = xs} (cons aˢ asˢ) (wf , wfs) y =
y ∈ free aˢ _ ∪ free asˢ _ ↔⟨ ∈∪≃ ⟩
y ∈ free aˢ _ ∥⊎∥ y ∈ free asˢ _ ↝⟨ free-⊆-Arg aˢ wf y ∥⊎∥-cong free-⊆-Args asˢ wfs y ⟩
y ∈ xs ∥⊎∥ y ∈ xs ↔⟨ ∥⊎∥-idempotent ∈-propositional ⟩□
y ∈ xs □
@0 free-⊆-Arg :
∀ (aˢ : Argˢ v) {a} → Wf xs aˢ a → free aˢ a ⊆ xs
free-⊆-Arg (nil tˢ) = free-⊆-Tm tˢ
free-⊆-Arg {xs = xs} (cons {s = s} aˢ) {a = x , a} wf y =
y ∈ del (_ , x) (free aˢ a) ↔⟨ ∈delete≃ merely-equal?-∃Var ⟩
y ≢ (_ , x) × y ∈ free aˢ a ↝⟨ uncurry lemma ⟩□
y ∈ xs □
where
lemma : y ≢ (_ , x) → y ∈ free aˢ a → y ∈ xs
lemma y≢x =
let x₁ , x₁∉ = fresh-not-erased xs
x₂ , x₂≢x₁ , x₂∉ = $⟨ fresh-not-erased ((_ , x₁) ∷ xs) ⟩
(∃ λ x₂ → (_ , x₂) ∉ (_ , x₁) ∷ xs) ↝⟨ (∃-cong λ _ → →-cong₁ ext ∈∷≃) ⟩
(∃ λ x₂ →
¬ ((_ , x₂) ≡ (_ , x₁) ∥⊎∥ (_ , x₂) ∈ xs)) ↝⟨ (∃-cong λ _ → Π∥⊎∥↔Π×Π λ _ → ⊥-propositional) ⟩□
(∃ λ x₂ → (_ , x₂) ≢ (_ , x₁) × (_ , x₂) ∉ xs) □
in
y ∈ free aˢ a ↝⟨ (λ y∈ _ → ⊆free-rename₁ aˢ _ y∈) ⟩
(∀ z → y ∈ (_ , x) ∷ free aˢ (rename₁ x z aˢ a)) ↝⟨ (∀-cong _ λ _ → to-implication (∈≢∷≃ y≢x)) ⟩
(∀ z → y ∈ free aˢ (rename₁ x z aˢ a)) ↝⟨ (λ hyp →
free-⊆-Arg aˢ (wf x₁ x₁∉) y (hyp x₁)
, free-⊆-Arg aˢ (wf x₂ x₂∉) y (hyp x₂)) ⟩
y ∈ (_ , x₁) ∷ xs × y ∈ (_ , x₂) ∷ xs ↔⟨ ∈∷≃ ×-cong ∈∷≃ ⟩
(y ≡ (_ , x₁) ∥⊎∥ y ∈ xs) ×
(y ≡ (_ , x₂) ∥⊎∥ y ∈ xs) ↔⟨ (Σ-∥⊎∥-distrib-right (λ _ → ∃Var-set) ∥⊎∥-cong F.id) F.∘
Σ-∥⊎∥-distrib-left ∥⊎∥-propositional ⟩
(y ≡ (_ , x₁) × y ≡ (_ , x₂) ∥⊎∥ y ∈ xs × y ≡ (_ , x₂)) ∥⊎∥
(y ≡ (_ , x₁) ∥⊎∥ y ∈ xs) × y ∈ xs ↝⟨ ((λ (y≡x₁ , y≡x₂) → x₂≢x₁ (trans (sym y≡x₂) y≡x₁)) ∥⊎∥-cong proj₁)
∥⊎∥-cong
proj₂ ⟩
(⊥ ∥⊎∥ y ∈ xs) ∥⊎∥ y ∈ xs ↔⟨ ∥⊎∥-idempotent ∈-propositional F.∘
(∥⊎∥-left-identity ∈-propositional ∥⊎∥-cong F.id) ⟩□
y ∈ xs □
-- Strengthening of the Wf predicate.
@0 strengthen-Wf :
∀ (tˢ : Skeleton k s) {t} →
(_ , x) ∉ free tˢ t →
Wf ((_ , x) ∷ xs) tˢ t → Wf xs tˢ t
strengthen-Wf {x = x} {xs = xs} tˢ {t = t} x∉ =
Wf ((_ , x) ∷ xs) tˢ t ↝⟨ free-⊆ tˢ ⟩
free tˢ t ⊆ (_ , x) ∷ xs ↝⟨ ∉→⊆∷→⊆ x∉ ⟩
free tˢ t ⊆ xs ↝⟨ _, wf-free tˢ ⟩
free tˢ t ⊆ xs × Wf (free tˢ t) tˢ t ↝⟨ (λ (sub , wf) → weaken-Wf sub tˢ wf) ⟩□
Wf xs tˢ t □
where
∉→⊆∷→⊆ :
{x : ∃Var} {xs ys : Vars} →
x ∉ xs → xs ⊆ x ∷ ys → xs ⊆ ys
∉→⊆∷→⊆ {x = x} {xs = xs} {ys = ys} x∉ xs⊆x∷ys z =
z ∈ xs ↝⟨ (λ z∈ → x∉ ∘ flip (subst (_∈ _)) z∈ , z∈) ⟩
z ≢ x × z ∈ xs ↝⟨ Σ-map id (xs⊆x∷ys _) ⟩
z ≢ x × z ∈ x ∷ ys ↔⟨ ∃-cong ∈≢∷≃ ⟩
z ≢ x × z ∈ ys ↝⟨ proj₂ ⟩□
z ∈ ys □
-- Renaming preserves well-formedness.
@0 rename₁-Wf :
∀ (tˢ : Skeleton k s) {t} →
Wf ((_ , x) ∷ xs) tˢ t →
Wf ((_ , y) ∷ xs) tˢ (rename₁ x y tˢ t)
rename₁-Wf {x = x} {xs = xs} {y = y} tˢ {t = t} wf =
$⟨ wf-free tˢ ⟩
Wf (free tˢ (rename₁ x y tˢ t)) tˢ (rename₁ x y tˢ t) ↝⟨ weaken-Wf
(⊆∷delete→⊆∷→⊆∷
(free-rename₁⊆ tˢ)
(free-⊆ tˢ wf))
tˢ ⟩□
Wf ((_ , y) ∷ xs) tˢ (rename₁ x y tˢ t) □
where
⊆∷delete→⊆∷→⊆∷ :
∀ {x y : ∃Var} {xs ys zs} →
xs ⊆ x ∷ del y ys →
ys ⊆ y ∷ zs →
xs ⊆ x ∷ zs
⊆∷delete→⊆∷→⊆∷ {x = x} {y = y} {xs = xs} {ys = ys} {zs = zs}
xs⊆ ys⊆ z =
z ∈ xs ↝⟨ xs⊆ z ⟩
z ∈ x ∷ del y ys ↔⟨ (F.id ∥⊎∥-cong ∈delete≃ merely-equal?-∃Var) F.∘ ∈∷≃ ⟩
z ≡ x ∥⊎∥ z ≢ y × z ∈ ys ↝⟨ id ∥⊎∥-cong id ×-cong ys⊆ z ⟩
z ≡ x ∥⊎∥ z ≢ y × z ∈ y ∷ zs ↔⟨ (F.id ∥⊎∥-cong ∃-cong λ z≢y → ∈≢∷≃ z≢y) ⟩
z ≡ x ∥⊎∥ z ≢ y × z ∈ zs ↝⟨ id ∥⊎∥-cong proj₂ ⟩
z ≡ x ∥⊎∥ z ∈ zs ↔⟨ inverse ∈∷≃ ⟩□
z ∈ x ∷ zs □
-- If one renames with a fresh variable, and the renamed thing is
-- well-formed (with respect to a certain set of variables), then
-- the original thing is also well-formed (with respect to a
-- certain set of variables).
@0 renamee-Wf :
∀ (tˢ : Skeleton k s) {t} →
(_ , y) ∉ free tˢ t →
Wf ((_ , y) ∷ xs) tˢ (rename₁ x y tˢ t) →
Wf ((_ , x) ∷ xs) tˢ t
renamee-Wf {y = y} {xs = xs} {x = x} tˢ {t = t} y∉a =
Wf ((_ , y) ∷ xs) tˢ (rename₁ x y tˢ t) ↝⟨ free-⊆ tˢ ⟩
free tˢ (rename₁ x y tˢ t) ⊆ (_ , y) ∷ xs ↝⟨ ∉→⊆∷∷→⊆∷→⊆∷ y∉a (⊆free-rename₁ tˢ) ⟩
free tˢ t ⊆ (_ , x) ∷ xs ↝⟨ (λ wf → weaken-Wf wf tˢ (wf-free tˢ)) ⟩□
Wf ((_ , x) ∷ xs) tˢ t □
where
∉→⊆∷∷→⊆∷→⊆∷ :
∀ {x y : ∃Var} {xs ys zs} →
y ∉ xs →
xs ⊆ x ∷ ys →
ys ⊆ y ∷ zs →
xs ⊆ x ∷ zs
∉→⊆∷∷→⊆∷→⊆∷ {x = x} {y = y} {xs = xs} {ys = ys} {zs = zs}
y∉xs xs⊆x∷y∷ys ys⊆y∷zs = λ z →
z ∈ xs ↝⟨ (λ z∈xs → (λ z≡y → y∉xs (subst (_∈ _) z≡y z∈xs))
, xs⊆x∷y∷ys z z∈xs) ⟩
z ≢ y × z ∈ x ∷ ys ↔⟨ (∃-cong λ _ → ∈∷≃) ⟩
z ≢ y × (z ≡ x ∥⊎∥ z ∈ ys) ↝⟨ (∃-cong λ _ → F.id ∥⊎∥-cong ys⊆y∷zs z) ⟩
z ≢ y × (z ≡ x ∥⊎∥ z ∈ y ∷ zs) ↔⟨ (∃-cong λ _ → F.id ∥⊎∥-cong ∈∷≃) ⟩
z ≢ y × (z ≡ x ∥⊎∥ z ≡ y ∥⊎∥ z ∈ zs) ↔⟨ (∃-cong λ z≢y → F.id ∥⊎∥-cong (
drop-⊥-left-∥⊎∥ ∈-propositional z≢y)) ⟩
z ≢ y × (z ≡ x ∥⊎∥ z ∈ zs) ↝⟨ proj₂ ⟩
z ≡ x ∥⊎∥ z ∈ zs ↔⟨ inverse ∈∷≃ ⟩□
z ∈ x ∷ zs □
-- If the "body of a lambda" is well-formed for all fresh
-- variables, then it is well-formed for the bound variable.
@0 body-Wf :
∀ (tˢ : Skeleton k s′) {t} →
(∀ (y : Var s) →
(_ , y) ∉ xs →
Wf ((_ , y) ∷ xs) tˢ (rename₁ x y tˢ t)) →
Wf ((_ , x) ∷ xs) tˢ t
body-Wf {xs = xs} tˢ {t = t} wf =
let y , [ y-fresh ] = fresh (xs ∪ free tˢ t)
y∉xs = y-fresh ∘ ∈→∈∪ˡ
y∉t = y-fresh ∘ ∈→∈∪ʳ xs
in
renamee-Wf tˢ y∉t (wf y y∉xs)
----------------------------------------------------------------------
-- Weakening, casting and strengthening
-- Weakening.
weaken : @0 xs ⊆ ys → Term[ k ] xs s → Term[ k ] ys s
weaken xs⊆ys (tˢ , t , [ wf ]) =
tˢ , t , [ weaken-Wf xs⊆ys tˢ wf ]
-- Casting.
cast :
@0 xs ≡ ys → Term[ k ] xs s → Term[ k ] ys s
cast eq = weaken (subst (_ ⊆_) eq ⊆-refl)
-- Strengthening.
strengthen :
(t : Term[ k ] ((s′ , x) ∷ xs) s) →
@0 ¬ Free-in x t →
Term[ k ] xs s
strengthen (tˢ , t , [ wf ]) ¬free =
tˢ , t , [ strengthen-Wf tˢ (¬free ∘ free-Free tˢ wf) wf ]
----------------------------------------------------------------------
-- Substitution
-- The function subst-Term maps variables to terms. Other kinds of
-- terms are preserved.
var-to-tm : Term-kind → Term-kind
var-to-tm var = tm
var-to-tm k = k
-- The kind of sort corresponding to var-to-tm k is the same as that
-- for k.
var-to-tm-for-sorts : ∀ k → Sort-kind k → Sort-kind (var-to-tm k)
var-to-tm-for-sorts var = id
var-to-tm-for-sorts tm = id
var-to-tm-for-sorts args = id
var-to-tm-for-sorts arg = id
-- Capture-avoiding substitution. The term subst-Term x t′ t is the
-- result of substituting t′ for x in t.
syntax subst-Term x t′ t = t [ x ← t′ ]
subst-Term :
∀ {xs s}
(x : Var s) → Term xs s →
Term[ k ] ((_ , x) ∷ xs) s′ →
Term[ var-to-tm k ] xs (var-to-tm-for-sorts k s′)
subst-Term {s = s} x t t′ = wf-elim e t′ (refl _) t
where
e : Wf-elim
(λ k {xs = xs′} {s = s′} _ →
∀ {xs} → @0 xs′ ≡ (_ , x) ∷ xs →
Term xs s →
Term[ var-to-tm k ] xs (var-to-tm-for-sorts k s′))
e .Wf-elim.varʳ {xs = xs′} y y∈xs′ {xs = xs} xs′≡x∷xs t =
case (_ , y) ≟∃V (_ , x) of λ where
(yes [ y≡x ]) →
substᴱ (λ p → Term xs (proj₁ p)) (sym y≡x) t
(no [ y≢x ]) →
var-wf y
( $⟨ y∈xs′ ⟩
(_ , y) ∈ xs′ ↝⟨ subst (_ ∈_) xs′≡x∷xs ⟩
(_ , y) ∈ (_ , x) ∷ xs ↔⟨ ∈≢∷≃ y≢x ⟩□
(_ , y) ∈ xs □)
e .Wf-elim.varʳ′ _ _ hyp eq t = hyp eq t
e .Wf-elim.opʳ o _ _ _ hyp eq t = Σ-map (op o) id (hyp eq t)
e .Wf-elim.nilʳ = λ _ _ → nil-wfs
e .Wf-elim.consʳ _ _ _ _ _ _ hyp hyps eq t =
Σ-zip cons (Σ-zip _,_ λ ([ wf ]) ([ wfs ]) → [ (wf , wfs) ])
(hyp eq t) (hyps eq t)
e .Wf-elim.nilʳ′ _ _ _ hyp eq t = Σ-map nil id (hyp eq t)
e .Wf-elim.consʳ′ {xs = xs′} aˢ y a wf hyp {xs = xs} eq t =
case (_ , x) ≟∃V (_ , y) of λ where
(inj₁ [ x≡y ]) →
-- If the bound variable matches x, keep the original
-- term (with a new well-formedness proof).
cons-wf aˢ y a
( $⟨ wf ⟩
Wf xs′ (Argˢ.cons aˢ) (y , a) ↝⟨ subst (λ xs → Wf xs (Argˢ.cons aˢ) _) eq ⟩
Wf ((_ , x) ∷ xs) (Argˢ.cons aˢ) (y , a) ↝⟨ strengthen-Wf (Argˢ.cons aˢ) (
(_ , x) ∈ del (_ , y) (free aˢ a) ↔⟨ ∈delete≃ merely-equal?-∃Var ⟩
(_ , x) ≢ (_ , y) × (_ , x) ∈ free aˢ a ↝⟨ (_$ x≡y) ∘ proj₁ ⟩□
⊥ □) ⟩□
Wf xs (Argˢ.cons aˢ) (y , a) □)
(inj₂ [ x≢y ]) →
-- Otherwise, rename the bound variable to something fresh
-- and keep substituting.
let z , [ z∉ ] = fresh ((_ , x) ∷ xs)
aˢ′ , a′ , [ wf′ ] =
hyp z (z∉ ∘ subst (_ ∈_) eq)
((_ , z) ∷ xs′ ≡⟨ cong (_ ∷_) eq ⟩
(_ , z) ∷ (_ , x) ∷ xs ≡⟨ swap ⟩∎
(_ , x) ∷ (_ , z) ∷ xs ∎)
(weaken
(λ u →
u ∈ xs ↝⟨ ∈→∈∷ ⟩□
u ∈ (_ , z) ∷ xs □)
t)
in
cons-wf aˢ′ z a′
(λ p _ → $⟨ wf′ ⟩
Wf ((_ , z) ∷ xs) aˢ′ a′ ↝⟨ rename₁-Wf aˢ′ ⟩□
Wf ((_ , p) ∷ xs) aˢ′ (rename₁ z p aˢ′ a′) □)
| {
"alphanum_fraction": 0.3726008908,
"avg_line_length": 41.921916258,
"ext": "agda",
"hexsha": "9348787e78fdc617e330c6a3b26738c06031cd1b",
"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": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/equality",
"max_forks_repo_path": "src/Abstract-binding-tree.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"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/equality",
"max_issues_repo_path": "src/Abstract-binding-tree.agda",
"max_line_length": 146,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/equality",
"max_stars_repo_path": "src/Abstract-binding-tree.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z",
"num_tokens": 38382,
"size": 111135
} |
{-
This module contains:
- constant displayed structures of URG structures
- products of URG structures
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.DStructures.Structures.Constant where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Equiv
open import Cubical.Data.Sigma
open import Cubical.DStructures.Base
open import Cubical.DStructures.Meta.Properties
open import Cubical.Relation.Binary
private
variable
ℓA ℓ≅A ℓB ℓ≅B ℓC ℓ≅C ℓ≅A×B : Level
-- The constant displayed structure of a URG structure 𝒮-B over 𝒮-A
𝒮ᴰ-const : {A : Type ℓA} (𝒮-A : URGStr A ℓ≅A)
{B : Type ℓB} (𝒮-B : URGStr B ℓ≅B)
→ URGStrᴰ 𝒮-A (λ _ → B) ℓ≅B
𝒮ᴰ-const {A = A} 𝒮-A {B} 𝒮-B
= urgstrᴰ (λ b _ b' → b ≅ b') ρ uni
where
open URGStr 𝒮-B
-- the total structure of the constant structure gives
-- nondependent product of URG structures
_×𝒮_ : {A : Type ℓA} (StrA : URGStr A ℓ≅A)
{B : Type ℓB} (StrB : URGStr B ℓ≅B)
→ URGStr (A × B) (ℓ-max ℓ≅A ℓ≅B)
_×𝒮_ StrA {B} StrB = ∫⟨ StrA ⟩ (𝒮ᴰ-const StrA StrB)
-- any displayed structure defined over a
-- structure on a product can also be defined
-- over the swapped product
×𝒮-swap : {A : Type ℓA} {B : Type ℓB} {C : A × B → Type ℓC}
{ℓ≅A×B ℓ≅ᴰ : Level}
{StrA×B : URGStr (A × B) ℓ≅A×B}
(StrCᴰ : URGStrᴰ StrA×B C ℓ≅ᴰ)
→ URGStrᴰ (𝒮-transport Σ-swap-≃ StrA×B)
(λ (b , a) → C (a , b))
ℓ≅ᴰ
×𝒮-swap {C = C} {ℓ≅ᴰ = ℓ≅ᴰ} {StrA×B = StrA×B} StrCᴰ =
make-𝒮ᴰ (λ c p c' → c ≅ᴰ⟨ p ⟩ c')
ρᴰ
λ (b , a) c → isUnivalent→contrRelSingl (λ c c' → c ≅ᴰ⟨ URGStr.ρ StrA×B (a , b) ⟩ c')
ρᴰ
uniᴰ
c
where
open URGStrᴰ StrCᴰ
| {
"alphanum_fraction": 0.5436548223,
"avg_line_length": 31.2698412698,
"ext": "agda",
"hexsha": "d088c9bb77a3126ac1f372d3fe26182d0fbb0f04",
"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": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Schippmunk/cubical",
"max_forks_repo_path": "Cubical/DStructures/Structures/Constant.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"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": "Schippmunk/cubical",
"max_issues_repo_path": "Cubical/DStructures/Structures/Constant.agda",
"max_line_length": 99,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Schippmunk/cubical",
"max_stars_repo_path": "Cubical/DStructures/Structures/Constant.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 791,
"size": 1970
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
-- Some basic facts about Spans in some category 𝒞.
--
-- For the Category instances for these, you can look at the following modules
-- Categories.Category.Construction.Spans
-- Categories.Bicategory.Construction.Spans
module Categories.Category.Diagram.Span {o ℓ e} (𝒞 : Category o ℓ e) where
open import Level
open import Function using (_$_)
open import Categories.Diagram.Pullback 𝒞
open import Categories.Morphism.Reasoning 𝒞
open Category 𝒞
open HomReasoning
open Equiv
open Pullback
private
variable
A B C D E : Obj
--------------------------------------------------------------------------------
-- Spans, and Span morphisms
infixr 9 _∘ₛ_
record Span (X Y : Obj) : Set (o ⊔ ℓ) where
field
M : Obj
dom : M ⇒ X
cod : M ⇒ Y
open Span
id-span : Span A A
id-span {A} = record
{ M = A
; dom = id
; cod = id
}
record Span⇒ {X Y} (f g : Span X Y) : Set (o ⊔ ℓ ⊔ e) where
field
arr : M f ⇒ M g
commute-dom : dom g ∘ arr ≈ dom f
commute-cod : cod g ∘ arr ≈ cod f
open Span⇒
id-span⇒ : ∀ {f : Span A B} → Span⇒ f f
id-span⇒ = record
{ arr = id
; commute-dom = identityʳ
; commute-cod = identityʳ
}
_∘ₛ_ : ∀ {f g h : Span A B} → (α : Span⇒ g h) → (β : Span⇒ f g) → Span⇒ f h
_∘ₛ_ {f = f} {g = g} {h = h} α β = record
{ arr = arr α ∘ arr β
; commute-dom = begin
dom h ∘ arr α ∘ arr β ≈⟨ pullˡ (commute-dom α) ⟩
dom g ∘ arr β ≈⟨ commute-dom β ⟩
dom f ∎
; commute-cod = begin
cod h ∘ arr α ∘ arr β ≈⟨ pullˡ (commute-cod α) ⟩
cod g ∘ arr β ≈⟨ commute-cod β ⟩
cod f ∎
}
--------------------------------------------------------------------------------
-- Span Compositions
module Compositions (_×ₚ_ : ∀ {X Y Z} (f : X ⇒ Z) → (g : Y ⇒ Z) → Pullback f g) where
_⊚₀_ : Span B C → Span A B → Span A C
f ⊚₀ g =
let g×ₚf = (cod g) ×ₚ (dom f)
in record
{ M = P g×ₚf
; dom = dom g ∘ p₁ g×ₚf
; cod = cod f ∘ p₂ g×ₚf
}
_⊚₁_ : {f f′ : Span B C} {g g′ : Span A B} → Span⇒ f f′ → Span⇒ g g′ → Span⇒ (f ⊚₀ g) (f′ ⊚₀ g′)
_⊚₁_ {f = f} {f′ = f′} {g = g} {g′ = g′} α β =
let pullback = (cod g) ×ₚ (dom f)
pullback′ = (cod g′) ×ₚ (dom f′)
in record
{ arr = universal pullback′ {h₁ = arr β ∘ p₁ pullback} {h₂ = arr α ∘ p₂ pullback} $ begin
cod g′ ∘ arr β ∘ p₁ pullback ≈⟨ pullˡ (commute-cod β) ⟩
cod g ∘ p₁ pullback ≈⟨ commute pullback ⟩
dom f ∘ p₂ pullback ≈⟨ pushˡ (⟺ (commute-dom α)) ⟩
dom f′ ∘ arr α ∘ p₂ pullback ∎
; commute-dom = begin
(dom g′ ∘ p₁ pullback′) ∘ universal pullback′ _ ≈⟨ pullʳ (p₁∘universal≈h₁ pullback′) ⟩
dom g′ ∘ arr β ∘ p₁ pullback ≈⟨ pullˡ (commute-dom β) ⟩
dom g ∘ p₁ pullback ∎
; commute-cod = begin
(cod f′ ∘ p₂ pullback′) ∘ universal pullback′ _ ≈⟨ pullʳ (p₂∘universal≈h₂ pullback′) ⟩
cod f′ ∘ arr α ∘ p₂ pullback ≈⟨ pullˡ (commute-cod α) ⟩
cod f ∘ p₂ pullback ∎
}
| {
"alphanum_fraction": 0.504931594,
"avg_line_length": 28.8348623853,
"ext": "agda",
"hexsha": "0573208c7a2252bd2070d9da27dd06e3b3131806",
"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/Diagram/Span.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/Diagram/Span.agda",
"max_line_length": 98,
"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/Diagram/Span.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": 1199,
"size": 3143
} |
------------------------------------------------------------------------------
-- Issue in the translation of definitions using λ-terms.
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module Issue2b where
postulate
D : Set
_≡_ : D → D → Set
-- The translations of foo₁ and foo₂ should be the same.
foo₁ : D → D → D
foo₁ d _ = d
{-# ATP definition foo₁ #-}
foo₂ : D → D → D
foo₂ = λ d _ → d
{-# ATP definition foo₂ #-}
postulate bar₁ : ∀ d e → d ≡ foo₁ d e
{-# ATP prove bar₁ #-}
postulate bar₂ : ∀ d e → d ≡ foo₂ d e
{-# ATP prove bar₂ #-}
| {
"alphanum_fraction": 0.4451783355,
"avg_line_length": 25.2333333333,
"ext": "agda",
"hexsha": "4754b46622514063fed6795f0b2fe031ad7808ea",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z",
"max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/apia",
"max_forks_repo_path": "issues/Issue2/Issue2b.agda",
"max_issues_count": 121,
"max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/apia",
"max_issues_repo_path": "issues/Issue2/Issue2b.agda",
"max_line_length": 78,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/apia",
"max_stars_repo_path": "issues/Issue2/Issue2b.agda",
"max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z",
"num_tokens": 181,
"size": 757
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some derivable properties
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Algebra
module Algebra.Properties.Ring {r₁ r₂} (R : Ring r₁ r₂) where
import Algebra.Properties.AbelianGroup as AGP
open import Function
import Relation.Binary.Reasoning.Setoid as EqR
open Ring R
open EqR setoid
open AGP +-abelianGroup public
renaming ( ⁻¹-involutive to -‿involutive
; left-identity-unique to +-left-identity-unique
; right-identity-unique to +-right-identity-unique
; identity-unique to +-identity-unique
; left-inverse-unique to +-left-inverse-unique
; right-inverse-unique to +-right-inverse-unique
; ⁻¹-∙-comm to -‿+-comm
)
-‿*-distribˡ : ∀ x y → - x * y ≈ - (x * y)
-‿*-distribˡ x y = begin
- x * y ≈⟨ sym $ +-identityʳ _ ⟩
- x * y + 0# ≈⟨ +-congˡ $ sym (-‿inverseʳ _) ⟩
- x * y + (x * y + - (x * y)) ≈⟨ sym $ +-assoc _ _ _ ⟩
- x * y + x * y + - (x * y) ≈⟨ +-congʳ $ sym (distribʳ _ _ _) ⟩
(- x + x) * y + - (x * y) ≈⟨ +-congʳ $ *-congʳ $ -‿inverseˡ _ ⟩
0# * y + - (x * y) ≈⟨ +-congʳ $ zeroˡ _ ⟩
0# + - (x * y) ≈⟨ +-identityˡ _ ⟩
- (x * y) ∎
-‿*-distribʳ : ∀ x y → x * - y ≈ - (x * y)
-‿*-distribʳ x y = begin
x * - y ≈⟨ sym $ +-identityˡ _ ⟩
0# + x * - y ≈⟨ +-congʳ $ sym (-‿inverseˡ _) ⟩
- (x * y) + x * y + x * - y ≈⟨ +-assoc _ _ _ ⟩
- (x * y) + (x * y + x * - y) ≈⟨ +-congˡ $ sym (distribˡ _ _ _) ⟩
- (x * y) + x * (y + - y) ≈⟨ +-congˡ $ *-congˡ $ -‿inverseʳ _ ⟩
- (x * y) + x * 0# ≈⟨ +-congˡ $ zeroʳ _ ⟩
- (x * y) + 0# ≈⟨ +-identityʳ _ ⟩
- (x * y) ∎
| {
"alphanum_fraction": 0.4161968221,
"avg_line_length": 38.2549019608,
"ext": "agda",
"hexsha": "5ba6b3b505e41168156aa3592c5dd07ac506118c",
"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/Algebra/Properties/Ring.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/Algebra/Properties/Ring.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/Algebra/Properties/Ring.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 742,
"size": 1951
} |
open import FRP.JS.Bool using ( Bool )
open import FRP.JS.RSet using ( RSet ; ⟦_⟧ ; ⟨_⟩ ; _⇒_ )
open import FRP.JS.Behaviour using ( Beh ; map2 )
open import FRP.JS.Event using ( Evt ; ∅ ; _∪_ ; map )
open import FRP.JS.Product using ( _∧_ ; _,_ )
open import FRP.JS.String using ( String )
module FRP.JS.DOM where
infixr 2 _≟*_
infixr 4 _++_ _+++_
postulate
Mouse Keyboard : RSet
EventType : RSet → Set
click : EventType Mouse
press : EventType Keyboard
{-# COMPILED_JS click "click" #-}
{-# COMPILED_JS press "press" #-}
postulate
DOW : Set
unattached : DOW
left right : DOW → DOW
child : String → DOW → DOW
events : ∀ {A} → EventType A → DOW → ⟦ Evt A ⟧
{-# COMPILED_JS unattached require("agda.frp").unattached() #-}
{-# COMPILED_JS left function(w) { return w.left(); } #-}
{-# COMPILED_JS right function(w) { return w.right(); } #-}
{-# COMPILED_JS child function(a) { return function(w) { return w.child(a); }; } #-}
{-# COMPILED_JS events function(A) { return function(t) { return function(w) { return function(s) { return w.events(t); }; }; }; } #-}
postulate
DOM : DOW → RSet
text : ∀ {w} → ⟦ Beh ⟨ String ⟩ ⇒ Beh (DOM w) ⟧
attr : ∀ {w} → String → ⟦ Beh ⟨ String ⟩ ⇒ Beh (DOM w) ⟧
element : ∀ a {w} → ⟦ Beh (DOM (child a w)) ⇒ Beh (DOM w) ⟧
[] : ∀ {w} → ⟦ Beh (DOM w) ⟧
_++_ : ∀ {w} → ⟦ Beh (DOM (left w)) ⇒ Beh (DOM (right w)) ⇒ Beh (DOM w) ⟧
{-# COMPILED_JS attr function(w) { return function(k) { return function(s) { return function(b) { return b.attribute(k); }; }; }; } #-}
{-# COMPILED_JS text function(w) { return function(s) { return function(b) { return b.text(); }; }; } #-}
{-# COMPILED_JS element function(a) { return function(w) { return function(s) { return function(b) { return w.element(a,b); }; }; }; } #-}
{-# COMPILED_JS [] function(w) { return require("agda.frp").empty; } #-}
{-# COMPILED_JS _++_ function(w) { return function(s) { return function(a) { return function(b) { return a.concat(b); }; }; }; } #-}
listen : ∀ {A w} → EventType A → ⟦ Beh (DOM w) ⇒ Evt A ⟧
listen {A} {w} t b = events t w
{-# COMPILED_JS listen function(A) { return function(w) { return function(t) { return function(s) { return function(b) { return w.events(t); }; }; }; }; } #-}
private
postulate
_≟_ : ∀ {w} → ⟦ DOM w ⇒ DOM w ⇒ ⟨ Bool ⟩ ⟧
{-# COMPILED_JS _≟_ function(w) { return function(s) { return function(a) { return function(b) { return a.equals(b); }; }; }; } #-}
_≟*_ : ∀ {w} → ⟦ Beh (DOM w) ⇒ Beh (DOM w) ⇒ Beh ⟨ Bool ⟩ ⟧
_≟*_ = map2 _≟_
[+] : ∀ {A w} → ⟦ Beh (DOM w) ∧ Evt A ⟧
[+] = ([] , ∅)
_+++_ : ∀ {A w} → ⟦ (Beh (DOM (left w)) ∧ Evt A) ⇒ (Beh (DOM (right w)) ∧ Evt A) ⇒ (Beh (DOM w) ∧ Evt A) ⟧
(dom₁ , evt₁) +++ (dom₂ , evt₂) = ((dom₁ ++ dom₂) , (evt₁ ∪ evt₂))
text+ : ∀ {A w} → ⟦ Beh ⟨ String ⟩ ⇒ (Beh (DOM w) ∧ Evt A) ⟧
text+ msg = (text msg , ∅)
attr+ : ∀ {A w} → String → ⟦ Beh ⟨ String ⟩ ⇒ (Beh (DOM w) ∧ Evt A) ⟧
attr+ key val = (attr key val , ∅)
element+ : ∀ a {A w} → ⟦ (Beh (DOM (child a w)) ∧ Evt A) ⇒ (Beh (DOM w) ∧ Evt A) ⟧
element+ a (dom , evt) = (element a dom , evt)
listen+ : ∀ {A B w} → EventType A → ⟦ A ⇒ B ⟧ → ⟦ (Beh (DOM w) ∧ Evt B) ⇒ (Beh (DOM w) ∧ Evt B) ⟧
listen+ t f (dom , evt) = (dom , map f (listen t dom) ∪ evt)
| {
"alphanum_fraction": 0.5619578686,
"avg_line_length": 40.35,
"ext": "agda",
"hexsha": "5661625be5b4b83dd470abc54d66ecec08d67f47",
"lang": "Agda",
"max_forks_count": 7,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z",
"max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_forks_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_forks_repo_name": "agda/agda-frp-js",
"max_forks_repo_path": "src/agda/FRP/JS/DOM.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_issues_repo_name": "agda/agda-frp-js",
"max_issues_repo_path": "src/agda/FRP/JS/DOM.agda",
"max_line_length": 158,
"max_stars_count": 63,
"max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72",
"max_stars_repo_licenses": [
"MIT",
"BSD-3-Clause"
],
"max_stars_repo_name": "agda/agda-frp-js",
"max_stars_repo_path": "src/agda/FRP/JS/DOM.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z",
"num_tokens": 1185,
"size": 3228
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import Setoids.Setoids
open import Rings.Definition
open import Rings.Homomorphisms.Definition
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
module Rings.Isomorphisms.Definition {a b c d : _} {A : Set a} {S : Setoid {a} {b} A} {_+1_ _*1_ : A → A → A} (R1 : Ring S _+1_ _*1_) {B : Set c} {T : Setoid {c} {d} B} {_+2_ _*2_ : B → B → B} (R2 : Ring T _+2_ _*2_) where
record RingIso (f : A → B) : Set (a ⊔ b ⊔ c ⊔ d) where
field
ringHom : RingHom R1 R2 f
bijective : SetoidBijection S T f
record RingsIsomorphic : Set (a ⊔ b ⊔ c ⊔ d) where
field
f : A → B
iso : RingIso f
| {
"alphanum_fraction": 0.6193353474,
"avg_line_length": 33.1,
"ext": "agda",
"hexsha": "8f0e02ffed98ea0b063f21628967b5842b464127",
"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": "Rings/Isomorphisms/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": "Rings/Isomorphisms/Definition.agda",
"max_line_length": 222,
"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": "Rings/Isomorphisms/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": 263,
"size": 662
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.SymmetricGroup where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Data.Sigma
open import Cubical.Data.Nat using (ℕ ; suc ; zero)
open import Cubical.Data.Fin using (Fin ; isSetFin)
open import Cubical.Data.Empty
open import Cubical.Relation.Nullary using (¬_)
open import Cubical.Algebra.Group
private
variable
ℓ : Level
Symmetric-Group : (X : Type ℓ) → isSet X → Group {ℓ}
Symmetric-Group X isSetX = makeGroup (idEquiv X) compEquiv invEquiv (isOfHLevel≃ 2 isSetX isSetX)
compEquiv-assoc compEquivEquivId compEquivIdEquiv invEquiv-is-rinv invEquiv-is-linv
-- Finite symmetrics groups
Sym : ℕ → Group
Sym n = Symmetric-Group (Fin n) isSetFin
| {
"alphanum_fraction": 0.7725060827,
"avg_line_length": 30.4444444444,
"ext": "agda",
"hexsha": "70cfc37f3bee72336a2fa54a9d9d16343749cad0",
"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": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Algebra/SymmetricGroup.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Algebra/SymmetricGroup.agda",
"max_line_length": 97,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/Algebra/SymmetricGroup.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 251,
"size": 822
} |
module Issue258 where
data D (A : Set) : Set where
d : D A
foo : Set → Set
foo A with d {A}
foo A | p = A
| {
"alphanum_fraction": 0.5765765766,
"avg_line_length": 11.1,
"ext": "agda",
"hexsha": "2a18ffc122b0e1f187ca7a3ef8e70e00f8498886",
"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/Issue258.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/Issue258.agda",
"max_line_length": 28,
"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/Issue258.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": 43,
"size": 111
} |
module Structure.Operator.Properties where
import Lvl
open import Functional
open import Lang.Instance
open import Logic
open import Logic.Predicate
open import Logic.Propositional
import Structure.Operator.Names as Names
open import Structure.Setoid
open import Syntax.Function
open import Type
private variable ℓ ℓₑ ℓ₁ ℓ₂ ℓ₃ ℓₑ₁ ℓₑ₂ ℓₑ₃ : Lvl.Level
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫_ : T₁ → T₁ → T₂) where
record Commutativity : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ₂} where
constructor intro
field proof : Names.Commutativity(_▫_)
commutativity = inst-fn Commutativity.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫_ : T₁ → T₂ → T₂) (id : T₁) where
record Identityₗ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ₂} where
constructor intro
field proof : Names.Identityₗ(_▫_)(id)
identityₗ = inst-fn Identityₗ.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫_ : T₁ → T₂ → T₂) (null : T₂) where
record Absorberᵣ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ₂} where
constructor intro
field proof : Names.Absorberᵣ(_▫_)(null)
absorberᵣ = inst-fn Absorberᵣ.proof
module _ {T₁ : Type{ℓ₁}} ⦃ _ : Equiv{ℓₑ₁}(T₁) ⦄ {T₂ : Type{ℓ₂}} (_▫_ : T₁ → T₂ → T₁) (id : T₂) where
record Identityᵣ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ₁} where
constructor intro
field proof : Names.Identityᵣ(_▫_)(id)
identityᵣ = inst-fn Identityᵣ.proof
module _ {T₁ : Type{ℓ₁}} ⦃ _ : Equiv{ℓₑ₁}(T₁) ⦄ {T₂ : Type{ℓ₂}} (_▫_ : T₁ → T₂ → T₁) (null : T₁) where
record Absorberₗ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ₁} where
constructor intro
field proof : Names.Absorberₗ(_▫_)(null)
absorberₗ = inst-fn Absorberₗ.proof
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) (id : T) where
record Identity : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field
instance ⦃ left ⦄ : Identityₗ(_▫_)(id)
instance ⦃ right ⦄ : Identityᵣ(_▫_)(id)
identity-left = inst-fn (Identityₗ.proof ∘ Identity.left)
identity-right = inst-fn (Identityᵣ.proof ∘ Identity.right)
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) where
record Idempotence : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field proof : Names.Idempotence(_▫_)
idempotence = inst-fn Idempotence.proof
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) (id : T) where
record Absorber : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field
instance ⦃ left ⦄ : Absorberₗ(_▫_)(id)
instance ⦃ right ⦄ : Absorberᵣ(_▫_)(id)
absorber-left = inst-fn (Absorberₗ.proof ∘ Absorber.left)
absorber-right = inst-fn (Absorberᵣ.proof ∘ Absorber.right)
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) ⦃ identityₗ : ∃(Identityₗ(_▫_)) ⦄ where
module _ (x : T) where
module _ (inv : T) where
record InverseElementₗ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field proof : Names.InverseElementₗ(_▫_)([∃]-witness identityₗ)(x)(inv)
inverseElementₗ = inst-fn InverseElementₗ.proof
InvertibleElementₗ = ∃(InverseElementₗ)
module _ (inv : T → T) where
record InverseFunctionₗ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field proof : Names.InverseFunctionₗ(_▫_)([∃]-witness identityₗ)(inv)
inverseFunctionₗ = inst-fn InverseFunctionₗ.proof
Invertibleₗ = ∃(InverseFunctionₗ)
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) ⦃ identityᵣ : ∃(Identityᵣ(_▫_)) ⦄ where
module _ (x : T) where
module _ (inv : T) where
record InverseElementᵣ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field proof : Names.InverseElementᵣ(_▫_)([∃]-witness identityᵣ)(x)(inv)
inverseElementᵣ = inst-fn InverseElementᵣ.proof
InvertibleElementᵣ = ∃(InverseElementᵣ)
module _ (inv : T → T) where
record InverseFunctionᵣ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field proof : Names.InverseFunctionᵣ(_▫_)([∃]-witness identityᵣ)(inv)
inverseFunctionᵣ = inst-fn InverseFunctionᵣ.proof
Invertibleᵣ = ∃(InverseFunctionᵣ)
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) ⦃ identity : ∃(Identity(_▫_)) ⦄ where
module _ (x : T) where
module _ (inv : T) where
InverseElement : Stmt
InverseElement =
InverseElementₗ(_▫_) ⦃ [∃]-map-proof Identity.left identity ⦄ (x)(inv) ∧
InverseElementᵣ(_▫_) ⦃ [∃]-map-proof Identity.right identity ⦄ (x)(inv)
InvertibleElement = ∃(InverseElement)
module _ (inv : T → T) where
import Logic.IntroInstances
record InverseFunction : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field
instance ⦃ left ⦄ : InverseFunctionₗ(_▫_) ⦃ [∃]-map-proof Identity.left identity ⦄ (inv)
instance ⦃ right ⦄ : InverseFunctionᵣ(_▫_) ⦃ [∃]-map-proof Identity.right identity ⦄ (inv)
inverseFunction-left = inst-fn (InverseFunctionₗ.proof ∘ InverseFunction.left)
inverseFunction-right = inst-fn (InverseFunctionᵣ.proof ∘ InverseFunction.right)
Invertible = ∃(InverseFunction)
-- TODO: Add some kind of inverse function
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) ⦃ absorberₗ : ∃(Absorberₗ(_▫_)) ⦄ where
module _ (opp : T → T) where
record ComplementFunctionₗ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field proof : Names.InverseFunctionₗ(_▫_)([∃]-witness absorberₗ)(opp)
oppositeFunctionₗ = inst-fn ComplementFunctionₗ.proof
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) ⦃ absorberᵣ : ∃(Absorberᵣ(_▫_)) ⦄ where
module _ (opp : T → T) where
record ComplementFunctionᵣ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field proof : Names.InverseFunctionᵣ(_▫_)([∃]-witness absorberᵣ)(opp)
oppositeFunctionᵣ = inst-fn ComplementFunctionᵣ.proof
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) ⦃ absorber : ∃(Absorber(_▫_)) ⦄ where
module _ (opp : T → T) where
record ComplementFunction : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field
instance ⦃ left ⦄ : ComplementFunctionₗ(_▫_) ⦃ [∃]-map-proof Absorber.left absorber ⦄ (opp)
instance ⦃ right ⦄ : ComplementFunctionᵣ(_▫_) ⦃ [∃]-map-proof Absorber.right absorber ⦄ (opp)
module _{T : Type{ℓ}} ⦃ _ : Equiv{ℓₑ}(T) ⦄ (_▫_ : T → T → T) where
record Associativity : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ} where
constructor intro
field proof : Names.Associativity(_▫_)
associativity = inst-fn Associativity.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫₁_ : T₁ → T₂ → T₂) (_▫₂_ : T₂ → T₂ → T₂) where
record Distributivityₗ : Stmt{Lvl.of(Type.of(_▫₁_)) Lvl.⊔ Lvl.of(Type.of(_▫₂_)) Lvl.⊔ ℓₑ₂} where
constructor intro
field proof : Names.Distributivityₗ(_▫₁_)(_▫₂_)
distributivityₗ = inst-fn Distributivityₗ.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫₁_ : T₂ → T₁ → T₂) (_▫₂_ : T₂ → T₂ → T₂) where
record Distributivityᵣ : Stmt{Lvl.of(Type.of(_▫₁_)) Lvl.⊔ Lvl.of(Type.of(_▫₂_)) Lvl.⊔ ℓₑ₂} where
constructor intro
field proof : Names.Distributivityᵣ(_▫₁_)(_▫₂_)
distributivityᵣ = inst-fn Distributivityᵣ.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ {T₃ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑ₃}(T₃) ⦄ (_▫_ : T₁ → T₂ → T₃) where
record Cancellationₗ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ₂ Lvl.⊔ ℓₑ₃} where
constructor intro
field proof : Names.Cancellationₗ(_▫_)
cancellationₗ = inst-fn Cancellationₗ.proof
module _ {T₁ : Type{ℓ₁}} ⦃ _ : Equiv{ℓₑ₁}(T₁) ⦄ {T₂ : Type{ℓ₂}} {T₃ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑ₃}(T₃) ⦄ (_▫_ : T₁ → T₂ → T₃) where
record Cancellationᵣ : Stmt{Lvl.of(Type.of(_▫_)) Lvl.⊔ ℓₑ₁ Lvl.⊔ ℓₑ₃} where
constructor intro
field proof : Names.Cancellationᵣ(_▫_)
cancellationᵣ = inst-fn Cancellationᵣ.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} {T₃ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑ₁}(T₁) ⦄ (_▫₁_ : T₁ → T₃ → T₁) (_▫₂_ : T₁ → T₂ → T₃) where
record Absorptionₗ : Stmt{Lvl.of(Type.of(_▫₁_)) Lvl.⊔ Lvl.of(Type.of(_▫₂_)) Lvl.⊔ ℓₑ₁} where
constructor intro
field proof : Names.Absorptionₗ(_▫₁_)(_▫₂_)
absorptionₗ = inst-fn Absorptionₗ.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} {T₃ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫₁_ : T₃ → T₂ → T₂) (_▫₂_ : T₁ → T₂ → T₃) where
record Absorptionᵣ : Stmt{Lvl.of(Type.of(_▫₁_)) Lvl.⊔ Lvl.of(Type.of(_▫₂_)) Lvl.⊔ ℓₑ₂} where
constructor intro
field proof : Names.Absorptionᵣ(_▫₁_)(_▫₂_)
absorptionᵣ = inst-fn Absorptionᵣ.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} {T₃ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫₁_ : T₁ → T₂ → T₃) (_▫₂_ : T₁ → T₃ → T₂) where
record InverseOperatorₗ : Stmt{Lvl.of(Type.of(_▫₁_)) Lvl.⊔ Lvl.of(Type.of(_▫₂_)) Lvl.⊔ ℓₑ₂} where
constructor intro
field proof : Names.InverseOperatorₗ(_▫₁_)(_▫₂_)
inverseOperₗ = inst-fn InverseOperatorₗ.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} {T₃ : Type{ℓ₃}} ⦃ _ : Equiv{ℓₑ₁}(T₁) ⦄ (_▫₁_ : T₁ → T₂ → T₃) (_▫₂_ : T₃ → T₂ → T₁) where
record InverseOperatorᵣ : Stmt{Lvl.of(Type.of(_▫₁_)) Lvl.⊔ Lvl.of(Type.of(_▫₂_)) Lvl.⊔ ℓₑ₁} where
constructor intro
field proof : Names.InverseOperatorᵣ(_▫₁_)(_▫₂_)
inverseOperᵣ = inst-fn InverseOperatorᵣ.proof
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫_ : T₁ → T₂ → T₂) (inv : T₁ → T₁) where
InversePropertyₗ = InverseOperatorₗ(_▫_)(a ↦ b ↦ inv(a) ▫ b)
module InversePropertyₗ = InverseOperatorₗ{_▫₁_ = _▫_}{_▫₂_ = a ↦ b ↦ inv(a) ▫ b}
inversePropₗ = inverseOperₗ(_▫_)(a ↦ b ↦ inv(a) ▫ b)
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫_ : T₂ → T₁ → T₂) (inv : T₁ → T₁) where
InversePropertyᵣ = InverseOperatorᵣ(_▫_)(a ↦ b ↦ a ▫ inv(b))
module InversePropertyᵣ = InverseOperatorᵣ{_▫₁_ = _▫_}{_▫₂_ = a ↦ b ↦ a ▫ inv(b)}
inversePropᵣ = inverseOperᵣ(_▫_)(a ↦ b ↦ a ▫ inv(b))
module _ {T₁ : Type{ℓ₁}} {T₂ : Type{ℓ₂}} ⦃ _ : Equiv{ℓₑ₂}(T₂) ⦄ (_▫_ : T₁ → T₁ → T₂) where
record Central(x : T₁) : Stmt{ℓ₁ Lvl.⊔ ℓₑ₂} where
constructor intro
field proof : ∀{y : T₁} → (x ▫ y ≡ y ▫ x)
| {
"alphanum_fraction": 0.6374729384,
"avg_line_length": 47.4859813084,
"ext": "agda",
"hexsha": "19a1cd2898cf8da43aba6107e1fb956cd7d97f1f",
"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": "Structure/Operator/Properties.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": "Structure/Operator/Properties.agda",
"max_line_length": 129,
"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": "Structure/Operator/Properties.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": 4639,
"size": 10162
} |
open import Common.Prelude
open import TestHarness
module TestBool where
not : Bool → Bool
not true = false
not false = true
{-# COMPILED_JS not function (x) { return !x; } #-}
_∧_ : Bool → Bool → Bool
true ∧ x = x
false ∧ x = false
{-# COMPILED_JS _∧_ function (x) { return function (y) { return x && y; }; } #-}
_∨_ : Bool → Bool → Bool
true ∨ x = true
false ∨ x = x
{-# COMPILED_JS _∨_ function (x) { return function (y) { return x || y; }; } #-}
_↔_ : Bool → Bool → Bool
true ↔ true = true
false ↔ false = true
_ ↔ _ = false
{-# COMPILED_JS _↔_ function (x) { return function (y) { return x === y; }; } #-}
tests : Tests
tests _ = (
assert true "tt" ,
assert (not false) "!ff" ,
assert (true ∧ true) "tt∧tt" ,
assert (not (true ∧ false)) "!(tt∧ff)" ,
assert (not (false ∧ false)) "!(ff∧ff)" ,
assert (not (false ∧ true)) "!(ff∧tt)" ,
assert (true ∨ true) "tt∨tt" ,
assert (true ∨ false) "tt∨ff" ,
assert (false ∨ true) "ff∨tt" ,
assert (not (false ∨ false)) "!(ff∧ff)" ,
assert (true ↔ true) "tt=tt" ,
assert (not (true ↔ false)) "tt≠ff" ,
assert (not (false ↔ true)) "ff≠tt" ,
assert (false ↔ false) "ff=ff"
)
| {
"alphanum_fraction": 0.5549958018,
"avg_line_length": 27.0681818182,
"ext": "agda",
"hexsha": "35bf861a11eef20e0b78f7f464aa1e5300f88156",
"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/js/TestBool.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/js/TestBool.agda",
"max_line_length": 81,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/js/TestBool.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": 428,
"size": 1191
} |
module AllStdLib where
-- Ensure that the entire standard library is compiled.
import README
open import Data.Unit.Polymorphic using (⊤)
open import Data.String
open import IO using (putStrLn; run)
open import IO.Primitive using (IO; _>>=_)
import DivMod
import HelloWorld
import HelloWorldPrim
import ShowNat
import TrustMe
import Vec
import dimensions
infixr 1 _>>_
_>>_ : ∀ {A B : Set} → IO A → IO B → IO B
m >> m₁ = m >>= λ _ → m₁
main : IO ⊤
main = do
run (putStrLn "Hello World!")
DivMod.main
HelloWorld.main
HelloWorldPrim.main
ShowNat.main
TrustMe.main
Vec.main
dimensions.main
| {
"alphanum_fraction": 0.7203947368,
"avg_line_length": 17.8823529412,
"ext": "agda",
"hexsha": "92f5e8d2ef197db79b19b6224155c8a5b42fc84d",
"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/Compiler/with-stdlib/AllStdLib.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/Compiler/with-stdlib/AllStdLib.agda",
"max_line_length": 55,
"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/Compiler/with-stdlib/AllStdLib.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 180,
"size": 608
} |
module rummy where
open import Data.Nat
-- The suit type
data Suit : Set where
♣ : Suit
♢ : Suit
♥ : Suit
♠ : Suit
-- A card consists of a value and a suite.
data Card : ℕ → Suit → Set where
_of_ : (n : ℕ) (s : Suit) → Card n s
-- Common names for cards
A : ℕ; A = 1
K : ℕ; K = 13
Q : ℕ; Q = 12
J : ℕ; J = 11
--
-- The clubs suit
--
A♣ : Card A ♣; A♣ = A of ♣
2♣ : Card 2 ♣; 2♣ = 2 of ♣
3♣ : Card 3 ♣; 3♣ = 3 of ♣
4♣ : Card 4 ♣; 4♣ = 4 of ♣
5♣ : Card 5 ♣; 5♣ = 5 of ♣
6♣ : Card 6 ♣; 6♣ = 6 of ♣
7♣ : Card 7 ♣; 7♣ = 7 of ♣
8♣ : Card 8 ♣; 8♣ = 8 of ♣
9♣ : Card 9 ♣; 9♣ = 9 of ♣
10♣ : Card 10 ♣; 10♣ = 10 of ♣
J♣ : Card J ♣; J♣ = J of ♣
Q♣ : Card Q ♣; Q♣ = Q of ♣
K♣ : Card K ♣; K♣ = K of ♣
--
-- The diamond suit
--
A♢ : Card A ♢; A♢ = A of ♢
2♢ : Card 2 ♢; 2♢ = 2 of ♢
3♢ : Card 3 ♢; 3♢ = 3 of ♢
4♢ : Card 4 ♢; 4♢ = 4 of ♢
5♢ : Card 5 ♢; 5♢ = 5 of ♢
6♢ : Card 6 ♢; 6♢ = 6 of ♢
7♢ : Card 7 ♢; 7♢ = 7 of ♢
8♢ : Card 8 ♢; 8♢ = 8 of ♢
9♢ : Card 9 ♢; 9♢ = 9 of ♢
10♢ : Card 10 ♢; 10♢ = 10 of ♢
J♢ : Card J ♢; J♢ = J of ♢
Q♢ : Card Q ♢; Q♢ = Q of ♢
K♢ : Card K ♢; K♢ = K of ♢
--
-- The heart suit
--
A♥ : Card A ♥; A♥ = A of ♥
2♥ : Card 2 ♥; 2♥ = 2 of ♥
3♥ : Card 3 ♥; 3♥ = 3 of ♥
4♥ : Card 4 ♥; 4♥ = 4 of ♥
5♥ : Card 5 ♥; 5♥ = 5 of ♥
6♥ : Card 6 ♥; 6♥ = 6 of ♥
7♥ : Card 7 ♥; 7♥ = 7 of ♥
8♥ : Card 8 ♥; 8♥ = 8 of ♥
9♥ : Card 9 ♥; 9♥ = 9 of ♥
10♥ : Card 10 ♥; 10♥ = 10 of ♥
J♥ : Card J ♥; J♥ = J of ♥
Q♥ : Card Q ♥; Q♥ = Q of ♥
K♥ : Card K ♥; K♥ = K of ♥
--
-- The spade suit
--
A♠ : Card A ♠; A♠ = A of ♠
2♠ : Card 2 ♠; 2♠ = 2 of ♠
3♠ : Card 3 ♠; 3♠ = 3 of ♠
4♠ : Card 4 ♠; 4♠ = 4 of ♠
5♠ : Card 5 ♠; 5♠ = 5 of ♠
6♠ : Card 6 ♠; 6♠ = 6 of ♠
7♠ : Card 7 ♠; 7♠ = 7 of ♠
8♠ : Card 8 ♠; 8♠ = 8 of ♠
9♠ : Card 9 ♠; 9♠ = 9 of ♠
10♠ : Card 10 ♠; 10♠ = 10 of ♠
J♠ : Card J ♠; J♠ = J of ♠
Q♠ : Card Q ♠; Q♠ = Q of ♠
K♠ : Card K ♠; K♠ = K of ♠
-- A run of length ℓ.
data Run (suit : Suit) : (start ℓ : ℕ) → Set where
[] : {start : ℕ} → Run suit start 0
_,_ : {n ℓ : ℕ}
→ Card n suit
→ Run suit (1 + n) ℓ
→ Run suit n (1 + ℓ)
-- A group of length ℓ.
data Group : (value ℓ : ℕ) → Set where
[] : {value : ℕ} → Group value 0
_,_ : {suit : Suit} {value ℓ : ℕ}
→ Card value suit
→ Group value ℓ
→ Group value (1 + ℓ)
-- Some pretty functions for creating runs. You can create a run as
-- follows:
--
-- myrun = ⟨ A♣ , 2♣ , 3♣ ⟩
--
⟨_ : {suit : Suit} {n ℓ : ℕ} → Run suit n ℓ → Run suit n ℓ
⟨ r = r
_⟩ : {suit : Suit} {n : ℕ} → Card n suit → Run suit n 1
c ⟩ = c , []
-- Some pretty functions for creating groups. You can create a group
-- group as follows:
--
-- mygroup = ⟦ A♣ , A♥ , A♢ ⟧
--
⟦_ : {value ℓ : ℕ} → Group value ℓ → Group value ℓ
⟦ g = g
_⟧ : {suit : Suit} {n : ℕ} → Card n suit → Group n 1
c ⟧ = c , []
infixr 2 _⟩ _⟧ _,_
infixl 1 ⟨_ ⟦_
mygroup = ⟦ A♣ , A♣ , A♠ ⟧
myrun = ⟨ A♣ , 2♣ , 3♣ ⟩
| {
"alphanum_fraction": 0.4134366925,
"avg_line_length": 21.0612244898,
"ext": "agda",
"hexsha": "432adc982b5390270532742d10cb4fdea0751494",
"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": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "piyush-kurur/sample-code",
"max_forks_repo_path": "agda/rummy.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8",
"max_issues_repo_issues_event_max_datetime": "2017-11-01T05:48:28.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-11-01T05:48:28.000Z",
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "piyush-kurur/sample-code",
"max_issues_repo_path": "agda/rummy.agda",
"max_line_length": 68,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "1062c0b81f8dbb664fcc9376ba13695f0ee7ebc8",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "piyush-kurur/sample-code",
"max_stars_repo_path": "agda/rummy.agda",
"max_stars_repo_stars_event_max_datetime": "2017-06-20T02:19:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-06-19T12:34:08.000Z",
"num_tokens": 1781,
"size": 3096
} |
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-}
module Light.Implementation.Standard.Data.These where
open import Light.Library.Data.These using (Library ; Dependencies)
instance dependencies : Dependencies
dependencies = record {}
instance library : Library dependencies
library = record { Implementation }
where
module Implementation where
open import Data.These using (These ; this ; that ; these) public
| {
"alphanum_fraction": 0.7435897436,
"avg_line_length": 31.2,
"ext": "agda",
"hexsha": "d41f58bdc1f4765c6c804a373250f655cf1e1e19",
"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": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756",
"max_forks_repo_licenses": [
"0BSD"
],
"max_forks_repo_name": "Zambonifofex/lightlib",
"max_forks_repo_path": "bindings/stdlib/Light/Implementation/Standard/Data/These.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"0BSD"
],
"max_issues_repo_name": "Zambonifofex/lightlib",
"max_issues_repo_path": "bindings/stdlib/Light/Implementation/Standard/Data/These.agda",
"max_line_length": 79,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756",
"max_stars_repo_licenses": [
"0BSD"
],
"max_stars_repo_name": "zamfofex/lightlib",
"max_stars_repo_path": "bindings/stdlib/Light/Implementation/Standard/Data/These.agda",
"max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z",
"num_tokens": 88,
"size": 468
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import LogicalFormulae
open import Sets.EquivalenceRelations
open import Setoids.Setoids
module Setoids.Subset {a b : _} {A : Set a} (S : Setoid {a} {b} A) where
open Setoid S
open Equivalence eq
subset : {c : _} (pred : A → Set c) → Set (a ⊔ b ⊔ c)
subset pred = ({x y : A} → x ∼ y → pred x → pred y)
subsetSetoid : {c : _} {pred : A → Set c} → (subs : subset pred) → Setoid (Sg A pred)
Setoid._∼_ (subsetSetoid subs) (x , predX) (y , predY) = Setoid._∼_ S x y
Equivalence.reflexive (Setoid.eq (subsetSetoid subs)) {a , b} = reflexive
Equivalence.symmetric (Setoid.eq (subsetSetoid subs)) {a , prA} {b , prB} x = symmetric x
Equivalence.transitive (Setoid.eq (subsetSetoid subs)) {a , prA} {b , prB} {c , prC} x y = transitive x y
| {
"alphanum_fraction": 0.6596244131,
"avg_line_length": 40.5714285714,
"ext": "agda",
"hexsha": "20b11bf6c3192be0fbbf5256593cad4815ac6fd5",
"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": "Setoids/Subset.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": "Setoids/Subset.agda",
"max_line_length": 105,
"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": "Setoids/Subset.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": 305,
"size": 852
} |
------------------------------------------------------------------------------
-- Equality reasoning on FOL
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- This module only re-export the preorder reasoning instanced on the
-- propositional equality.
module Common.FOL.Relation.Binary.EqReasoning where
open import Common.FOL.FOL-Eq using ( _≡_ ; refl ; trans )
import Common.Relation.Binary.PreorderReasoning
open module ≡-Reasoning =
Common.Relation.Binary.PreorderReasoning _≡_ refl trans public
renaming ( _∼⟨_⟩_ to _≡⟨_⟩_ )
| {
"alphanum_fraction": 0.5315436242,
"avg_line_length": 35.4761904762,
"ext": "agda",
"hexsha": "8f96203944d48ec1feadad55c7d2f708a3baf637",
"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/Common/FOL/Relation/Binary/EqReasoning.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/Common/FOL/Relation/Binary/EqReasoning.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": "src/fot/Common/FOL/Relation/Binary/EqReasoning.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": 151,
"size": 745
} |
module slots where
open import slots.defs
open import slots.bruteforce
| {
"alphanum_fraction": 0.8219178082,
"avg_line_length": 12.1666666667,
"ext": "agda",
"hexsha": "b470ec313df23f4ab770fd974daca238598bd82e",
"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": "86d777ade14f63032c46bd168b76ac60d6bdf9b9",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "semenov-vladyslav/slots-agda",
"max_forks_repo_path": "src/slots.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "86d777ade14f63032c46bd168b76ac60d6bdf9b9",
"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": "semenov-vladyslav/slots-agda",
"max_issues_repo_path": "src/slots.agda",
"max_line_length": 28,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "86d777ade14f63032c46bd168b76ac60d6bdf9b9",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "semenov-vladyslav/slots-agda",
"max_stars_repo_path": "src/slots.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 18,
"size": 73
} |
{-
Definition of the circle as a HIT with a proof that Ω(S¹) ≡ ℤ
-}
{-# OPTIONS --cubical --safe #-}
module Cubical.HITs.S1.Base where
open import Cubical.Core.Glue
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Data.Nat
hiding (_+_ ; _*_ ; +-assoc ; +-comm)
open import Cubical.Data.Int
data S¹ : Type₀ where
base : S¹
loop : base ≡ base
-- Check that transp is the identity function for S¹
module _ where
transpS¹ : ∀ (φ : I) (u0 : S¹) → transp (λ _ → S¹) φ u0 ≡ u0
transpS¹ φ u0 = refl
compS1 : ∀ (φ : I) (u : ∀ i → Partial φ S¹) (u0 : S¹ [ φ ↦ u i0 ]) →
comp (λ _ → S¹) u (outS u0) ≡ hcomp u (outS u0)
compS1 φ u u0 = refl
helix : S¹ → Type₀
helix base = Int
helix (loop i) = sucPathInt i
ΩS¹ : Type₀
ΩS¹ = base ≡ base
encode : ∀ x → base ≡ x → helix x
encode x p = subst helix p (pos zero)
winding : ΩS¹ → Int
winding = encode base
intLoop : Int → ΩS¹
intLoop (pos zero) = refl
intLoop (pos (suc n)) = intLoop (pos n) ∙ loop
intLoop (negsuc zero) = sym loop
intLoop (negsuc (suc n)) = intLoop (negsuc n) ∙ sym loop
decodeSquare : (n : Int) → PathP (λ i → base ≡ loop i) (intLoop (predInt n)) (intLoop n)
decodeSquare (pos zero) i j = loop (i ∨ ~ j)
decodeSquare (pos (suc n)) i j = hfill (λ k → λ { (j = i0) → base
; (j = i1) → loop k } )
(inS (intLoop (pos n) j)) i
decodeSquare (negsuc n) i j = hcomp (λ k → λ { (i = i1) → intLoop (negsuc n) j
; (j = i0) → base
; (j = i1) → loop (i ∨ ~ k) })
(intLoop (negsuc n) j)
decode : (x : S¹) → helix x → base ≡ x
decode base = intLoop
decode (loop i) y j =
let n : Int
n = unglue (i ∨ ~ i) y
in hcomp (λ k → λ { (i = i0) → intLoop (predSuc y k) j
; (i = i1) → intLoop y j
; (j = i0) → base
; (j = i1) → loop i })
(decodeSquare n i j)
decodeEncode : (x : S¹) (p : base ≡ x) → decode x (encode x p) ≡ p
decodeEncode x p = J (λ y q → decode y (encode y q) ≡ q) (λ _ → refl) p
isSetΩS¹ : isSet ΩS¹
isSetΩS¹ p q r s j i =
hcomp (λ k → λ { (i = i0) → decodeEncode base p k
; (i = i1) → decodeEncode base q k
; (j = i0) → decodeEncode base (r i) k
; (j = i1) → decodeEncode base (s i) k })
(decode base (isSetInt (winding p) (winding q) (cong winding r) (cong winding s) j i))
-- This proof does not rely on rewriting hcomp with empty systems in
-- Int as ghcomp has been implemented!
windingIntLoop : (n : Int) → winding (intLoop n) ≡ n
windingIntLoop (pos zero) = refl
windingIntLoop (pos (suc n)) = cong sucInt (windingIntLoop (pos n))
windingIntLoop (negsuc zero) = refl
windingIntLoop (negsuc (suc n)) = cong predInt (windingIntLoop (negsuc n))
ΩS¹≡Int : ΩS¹ ≡ Int
ΩS¹≡Int = isoToPath (iso winding intLoop windingIntLoop (decodeEncode base))
-- intLoop and winding are group homomorphisms
private
intLoop-sucInt : (z : Int) → intLoop (sucInt z) ≡ intLoop z ∙ loop
intLoop-sucInt (pos n) = refl
intLoop-sucInt (negsuc zero) = sym (lCancel loop)
intLoop-sucInt (negsuc (suc n)) =
rUnit (intLoop (negsuc n))
∙ (λ i → intLoop (negsuc n) ∙ lCancel loop (~ i))
∙ assoc (intLoop (negsuc n)) (sym loop) loop
intLoop-predInt : (z : Int) → intLoop (predInt z) ≡ intLoop z ∙ sym loop
intLoop-predInt (pos zero) = lUnit (sym loop)
intLoop-predInt (pos (suc n)) =
rUnit (intLoop (pos n))
∙ (λ i → intLoop (pos n) ∙ (rCancel loop (~ i)))
∙ assoc (intLoop (pos n)) loop (sym loop)
intLoop-predInt (negsuc n) = refl
intLoop-hom : (a b : Int) → (intLoop a) ∙ (intLoop b) ≡ intLoop (a + b)
intLoop-hom a (pos zero) = sym (rUnit (intLoop a))
intLoop-hom a (pos (suc n)) =
assoc (intLoop a) (intLoop (pos n)) loop
∙ (λ i → (intLoop-hom a (pos n) i) ∙ loop)
∙ sym (intLoop-sucInt (a + pos n))
intLoop-hom a (negsuc zero) = sym (intLoop-predInt a)
intLoop-hom a (negsuc (suc n)) =
assoc (intLoop a) (intLoop (negsuc n)) (sym loop)
∙ (λ i → (intLoop-hom a (negsuc n) i) ∙ (sym loop))
∙ sym (intLoop-predInt (a + negsuc n))
winding-hom : (a b : ΩS¹) → winding (a ∙ b) ≡ (winding a) + (winding b)
winding-hom a b i =
hcomp (λ t → λ { (i = i0) → winding (decodeEncode base a t ∙ decodeEncode base b t)
; (i = i1) → windingIntLoop (winding a + winding b) t })
(winding (intLoop-hom (winding a) (winding b) i))
-- Based homotopy group
basedΩS¹ : (x : S¹) → Type₀
basedΩS¹ x = x ≡ x
-- Proof that the homotopy group is actually independent on the basepoint
-- first, give a quasi-inverse to the basechange basedΩS¹→ΩS¹ for any loop i
-- (which does *not* match at endpoints)
private
ΩS¹→basedΩS¹-filler : I → I → ΩS¹ → I → S¹
ΩS¹→basedΩS¹-filler l i x j =
hfill (λ t → λ { (j = i0) → loop (i ∧ t)
; (j = i1) → loop (i ∧ t) })
(inS (x j)) l
basedΩS¹→ΩS¹-filler : (_ i : I) → basedΩS¹ (loop i) → I → S¹
basedΩS¹→ΩS¹-filler l i x j =
hfill (λ t → λ { (j = i0) → loop (i ∧ (~ t))
; (j = i1) → loop (i ∧ (~ t)) })
(inS (x j)) l
ΩS¹→basedΩS¹ : (i : I) → ΩS¹ → basedΩS¹ (loop i)
ΩS¹→basedΩS¹ i x j = ΩS¹→basedΩS¹-filler i1 i x j
basedΩS¹→ΩS¹ : (i : I) → basedΩS¹ (loop i) → ΩS¹
basedΩS¹→ΩS¹ i x j = basedΩS¹→ΩS¹-filler i1 i x j
basedΩS¹→ΩS¹→basedΩS¹ : (i : I) → (x : basedΩS¹ (loop i))
→ ΩS¹→basedΩS¹ i (basedΩS¹→ΩS¹ i x) ≡ x
basedΩS¹→ΩS¹→basedΩS¹ i x j k =
hcomp (λ t → λ { (j = i1) → basedΩS¹→ΩS¹-filler (~ t) i x k
; (j = i0) → ΩS¹→basedΩS¹ i (basedΩS¹→ΩS¹ i x) k
; (k = i0) → loop (i ∧ (t ∨ (~ j)))
; (k = i1) → loop (i ∧ (t ∨ (~ j))) })
(ΩS¹→basedΩS¹-filler (~ j) i (basedΩS¹→ΩS¹ i x) k)
ΩS¹→basedΩS¹→ΩS¹ : (i : I) → (x : ΩS¹)
→ basedΩS¹→ΩS¹ i (ΩS¹→basedΩS¹ i x) ≡ x
ΩS¹→basedΩS¹→ΩS¹ i x j k =
hcomp (λ t → λ { (j = i1) → ΩS¹→basedΩS¹-filler (~ t) i x k
; (j = i0) → basedΩS¹→ΩS¹ i (ΩS¹→basedΩS¹ i x) k
; (k = i0) → loop (i ∧ ((~ t) ∧ j))
; (k = i1) → loop (i ∧ ((~ t) ∧ j)) })
(basedΩS¹→ΩS¹-filler (~ j) i (ΩS¹→basedΩS¹ i x) k)
-- from the existence of our quasi-inverse, we deduce that the basechange is an equivalence
-- for all loop i
basedΩS¹→ΩS¹-isequiv : (i : I) → isEquiv (basedΩS¹→ΩS¹ i)
basedΩS¹→ΩS¹-isequiv i = isoToIsEquiv (iso (basedΩS¹→ΩS¹ i) (ΩS¹→basedΩS¹ i)
(ΩS¹→basedΩS¹→ΩS¹ i) (basedΩS¹→ΩS¹→basedΩS¹ i))
-- now extend the basechange so that both ends match
-- (and therefore we get a basechange for any x : S¹)
private
loop-conjugation : basedΩS¹→ΩS¹ i1 ≡ λ x → x
loop-conjugation i x =
let p = (doubleCompPath-elim loop x (sym loop))
∙ (λ i → (lUnit loop i ∙ x) ∙ sym loop)
in
((sym (decodeEncode base (basedΩS¹→ΩS¹ i1 x)))
∙ (λ t → intLoop (winding (p t)))
∙ (λ t → intLoop (winding-hom (intLoop (pos (suc zero)) ∙ x)
(intLoop (negsuc zero)) t))
∙ (λ t → intLoop ((winding-hom (intLoop (pos (suc zero))) x t)
+ (windingIntLoop (negsuc zero) t)))
∙ (λ t → intLoop (((windingIntLoop (pos (suc zero)) t) + (winding x)) + (negsuc zero)))
∙ (λ t → intLoop ((+-comm (pos (suc zero)) (winding x) t) + (negsuc zero)))
∙ (λ t → intLoop (+-assoc (winding x) (pos (suc zero)) (negsuc zero) (~ t)))
∙ (decodeEncode base x)) i
refl-conjugation : basedΩS¹→ΩS¹ i0 ≡ λ x → x
refl-conjugation i x j =
hfill (λ t → λ { (j = i0) → base
; (j = i1) → base })
(inS (x j)) (~ i)
basechange : (x : S¹) → basedΩS¹ x → ΩS¹
basechange base y = y
basechange (loop i) y =
hcomp (λ t → λ { (i = i0) → refl-conjugation t y
; (i = i1) → loop-conjugation t y })
(basedΩS¹→ΩS¹ i y)
-- for any loop i, the old basechange is equal to the new one
basedΩS¹→ΩS¹≡basechange : (i : I) → basedΩS¹→ΩS¹ i ≡ basechange (loop i)
basedΩS¹→ΩS¹≡basechange i j y =
hfill (λ t → λ { (i = i0) → refl-conjugation t y
; (i = i1) → loop-conjugation t y })
(inS (basedΩS¹→ΩS¹ i y)) j
-- so for any loop i, the extended basechange is an equivalence
basechange-isequiv-aux : (i : I) → isEquiv (basechange (loop i))
basechange-isequiv-aux i =
transport (λ j → isEquiv (basedΩS¹→ΩS¹≡basechange i j)) (basedΩS¹→ΩS¹-isequiv i)
-- as being an equivalence is contractible, basechange is an equivalence for all x : S¹
basechange-isequiv : (x : S¹) → isEquiv (basechange x)
basechange-isequiv base = basechange-isequiv-aux i0
basechange-isequiv (loop i) =
hcomp (λ t → λ { (i = i0) → basechange-isequiv-aux i0
; (i = i1) → isPropIsEquiv (basechange base) (basechange-isequiv-aux i1)
(basechange-isequiv-aux i0) t })
(basechange-isequiv-aux i)
basedΩS¹≡ΩS¹ : (x : S¹) → basedΩS¹ x ≡ ΩS¹
basedΩS¹≡ΩS¹ x = ua (basechange x , basechange-isequiv x)
basedΩS¹≡Int : (x : S¹) → basedΩS¹ x ≡ Int
basedΩS¹≡Int x = (basedΩS¹≡ΩS¹ x) ∙ ΩS¹≡Int
-- Some tests
module _ where
private
test-winding-pos : winding (intLoop (pos 5)) ≡ pos 5
test-winding-pos = refl
test-winding-neg : winding (intLoop (negsuc 5)) ≡ negsuc 5
test-winding-neg = refl
-- the inverse when S¹ is seen as a group
inv : S¹ → S¹
inv base = base
inv (loop i) = loop (~ i)
-- rot, used in the Hopf fibration
rotLoop : (a : S¹) → a ≡ a
rotLoop base = loop
rotLoop (loop i) j =
hcomp (λ k → λ { (i = i0) → loop (j ∨ ~ k)
; (i = i1) → loop (j ∧ k)
; (j = i0) → loop (i ∨ ~ k)
; (j = i1) → loop (i ∧ k)}) base
rot : S¹ → S¹ → S¹
rot base x = x
rot (loop i) x = rotLoop x i
_*_ : S¹ → S¹ → S¹
a * b = rot a b
infixl 30 _*_
-- rot i j = filler-rot i j i1
filler-rot : I → I → I → S¹
filler-rot i j = hfill (λ k → λ { (i = i0) → loop (j ∨ ~ k)
; (i = i1) → loop (j ∧ k)
; (j = i0) → loop (i ∨ ~ k)
; (j = i1) → loop (i ∧ k) }) (inS base)
isPropFamS¹ : ∀ {ℓ} (P : S¹ → Type ℓ) (pP : (x : S¹) → isProp (P x)) (b0 : P base) →
PathP (λ i → P (loop i)) b0 b0
isPropFamS¹ P pP b0 i = pP (loop i) (transp (λ j → P (loop (i ∧ j))) (~ i) b0)
(transp (λ j → P (loop (i ∨ ~ j))) i b0) i
rotIsEquiv : (a : S¹) → isEquiv (rot a)
rotIsEquiv base = idIsEquiv S¹
rotIsEquiv (loop i) = isPropFamS¹ (λ x → isEquiv (rot x))
(λ x → isPropIsEquiv (rot x))
(idIsEquiv _) i
-- more direct definition of the rot (loop i) equivalence
rotLoopInv : (a : S¹) → PathP (λ i → rotLoop (rotLoop a (~ i)) i ≡ a) refl refl
rotLoopInv a i j =
hcomp
(λ k → λ {
(i = i0) → a;
(i = i1) → rotLoop a (j ∧ ~ k);
(j = i0) → rotLoop (rotLoop a (~ i)) i;
(j = i1) → rotLoop a (i ∧ ~ k)})
(rotLoop (rotLoop a (~ i ∨ j)) i)
rotLoopEquiv : (i : I) → S¹ ≃ S¹
rotLoopEquiv i =
isoToEquiv
(iso (λ a → rotLoop a i)
(λ a → rotLoop a (~ i))
(λ a → rotLoopInv a i)
(λ a → rotLoopInv a (~ i)))
-- some cancellation laws, used in the Hopf fibration
private
rotInv-aux-1 : I → I → I → I → S¹
rotInv-aux-1 j k i =
hfill (λ l → λ { (k = i0) → (loop (i ∧ ~ l)) * loop j
; (k = i1) → loop j
; (i = i0) → (loop k * loop j) * loop (~ k)
; (i = i1) → loop (~ k ∧ ~ l) * loop j })
(inS ((loop (k ∨ i) * loop j) * loop (~ k)))
rotInv-aux-2 : I → I → I → S¹
rotInv-aux-2 i j k =
hcomp (λ l → λ { (k = i0) → inv (filler-rot (~ i) (~ j) l)
; (k = i1) → loop (j ∧ l)
; (i = i0) → filler-rot k j l
; (i = i1) → loop (j ∧ l)
; (j = i0) → loop (i ∨ k ∨ (~ l))
; (j = i1) → loop ((i ∨ k) ∧ l) })
(base)
rotInv-aux-3 : I → I → I → I → S¹
rotInv-aux-3 j k i =
hfill (λ l → λ { (k = i0) → rotInv-aux-2 i j l
; (k = i1) → loop j
; (i = i0) → loop (k ∨ l) * loop j
; (i = i1) → loop k * (inv (loop (~ j) * loop k)) })
(inS (loop k * (inv (loop (~ j) * loop (k ∨ ~ i)))))
rotInv-aux-4 : I → I → I → I → S¹
rotInv-aux-4 j k i =
hfill (λ l → λ { (k = i0) → rotInv-aux-2 i j l
; (k = i1) → loop j
; (i = i0) → loop j * loop (k ∨ l)
; (i = i1) → (inv (loop (~ j) * loop k)) * loop k })
(inS ((inv (loop (~ j) * loop (k ∨ ~ i))) * loop k))
rotInv-1 : (a b : S¹) → b * a * inv b ≡ a
rotInv-1 base base i = base
rotInv-1 base (loop k) i = rotInv-aux-1 i0 k i i1
rotInv-1 (loop j) base i = loop j
rotInv-1 (loop j) (loop k) i = rotInv-aux-1 j k i i1
rotInv-2 : (a b : S¹) → inv b * a * b ≡ a
rotInv-2 base base i = base
rotInv-2 base (loop k) i = rotInv-aux-1 i0 (~ k) i i1
rotInv-2 (loop j) base i = loop j
rotInv-2 (loop j) (loop k) i = rotInv-aux-1 j (~ k) i i1
rotInv-3 : (a b : S¹) → b * (inv (inv a * b)) ≡ a
rotInv-3 base base i = base
rotInv-3 base (loop k) i = rotInv-aux-3 i0 k (~ i) i1
rotInv-3 (loop j) base i = loop j
rotInv-3 (loop j) (loop k) i = rotInv-aux-3 j k (~ i) i1
rotInv-4 : (a b : S¹) → inv (b * inv a) * b ≡ a
rotInv-4 base base i = base
rotInv-4 base (loop k) i = rotInv-aux-4 i0 k (~ i) i1
rotInv-4 (loop j) base i = loop j
rotInv-4 (loop j) (loop k) i = rotInv-aux-4 j k (~ i) i1
| {
"alphanum_fraction": 0.5263954998,
"avg_line_length": 36.5857519789,
"ext": "agda",
"hexsha": "eb3464c325c56c9ff0766c2eba57058ebb9b3084",
"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": "7fd336c6d31a6e6d58a44114831aacd63f422545",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cj-xu/cubical",
"max_forks_repo_path": "Cubical/HITs/S1/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545",
"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": "cj-xu/cubical",
"max_issues_repo_path": "Cubical/HITs/S1/Base.agda",
"max_line_length": 94,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "7fd336c6d31a6e6d58a44114831aacd63f422545",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cj-xu/cubical",
"max_stars_repo_path": "Cubical/HITs/S1/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5576,
"size": 13866
} |
{-# OPTIONS --no-pattern-matching #-}
id : {A : Set} (x : A) → A
id x = x
data Unit : Set where
unit : Unit
fail : Unit → Set
fail unit = Unit
-- Expected error: Pattern matching is disabled
| {
"alphanum_fraction": 0.6224489796,
"avg_line_length": 16.3333333333,
"ext": "agda",
"hexsha": "4e2b53e79b54e4b67a584870e53e4913bffa662b",
"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/NoPatternMatching.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/NoPatternMatching.agda",
"max_line_length": 47,
"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/NoPatternMatching.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": 59,
"size": 196
} |
{-# OPTIONS --without-K #-}
open import lib.Basics
open import lib.types.Pi
open import lib.types.Pointed
module lib.types.Cospan where
record Cospan {i j k : ULevel} : Type (lsucc (lmax (lmax i j) k)) where
constructor cospan
field
A : Type i
B : Type j
C : Type k
f : A → C
g : B → C
record ⊙Cospan {i j k : ULevel} : Type (lsucc (lmax (lmax i j) k)) where
constructor ⊙cospan
field
X : Ptd i
Y : Ptd j
Z : Ptd k
f : fst (X ⊙→ Z)
g : fst (Y ⊙→ Z)
⊙cospan-out : ∀ {i j k} → ⊙Cospan {i} {j} {k} → Cospan {i} {j} {k}
⊙cospan-out (⊙cospan X Y Z f g) =
cospan (fst X) (fst Y) (fst Z) (fst f) (fst g)
| {
"alphanum_fraction": 0.5628834356,
"avg_line_length": 21.7333333333,
"ext": "agda",
"hexsha": "1cd2503d54812e846cd707042cfba5a9e4a48222",
"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": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nicolaikraus/HoTT-Agda",
"max_forks_repo_path": "lib/types/Cospan.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"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": "nicolaikraus/HoTT-Agda",
"max_issues_repo_path": "lib/types/Cospan.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "f8fa68bf753d64d7f45556ca09d0da7976709afa",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "UlrikBuchholtz/HoTT-Agda",
"max_stars_repo_path": "lib/types/Cospan.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z",
"num_tokens": 267,
"size": 652
} |
{-
Constant structure: _ ↦ A
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Structures.Constant where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.SIP
private
variable
ℓ ℓ' : Level
-- Structured isomorphisms
module _ (A : Type ℓ') where
ConstantStructure : Type ℓ → Type ℓ'
ConstantStructure _ = A
ConstantEquivStr : StrEquiv {ℓ} ConstantStructure ℓ'
ConstantEquivStr (_ , a) (_ , a') _ = a ≡ a'
constantUnivalentStr : UnivalentStr {ℓ} ConstantStructure ConstantEquivStr
constantUnivalentStr e = idEquiv _
constantEquivAction : EquivAction {ℓ} ConstantStructure
constantEquivAction e = idEquiv _
constantTransportStr : TransportStr {ℓ} constantEquivAction
constantTransportStr e _ = sym (transportRefl _)
| {
"alphanum_fraction": 0.7481927711,
"avg_line_length": 23.0555555556,
"ext": "agda",
"hexsha": "7564392224c64a19de331b62f61ebb115811a011",
"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": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Structures/Constant.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Structures/Constant.agda",
"max_line_length": 76,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dan-iel-lee/cubical",
"max_stars_repo_path": "Cubical/Structures/Constant.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 242,
"size": 830
} |
------------------------------------------------------------------------
-- INCREMENTAL λ-CALCULUS
--
-- Values for standard evaluation of MTerm
------------------------------------------------------------------------
import Parametric.Syntax.Type as Type
import Parametric.Syntax.MType as MType
import Parametric.Denotation.Value as Value
module Parametric.Denotation.MValue
(Base : Type.Structure)
(⟦_⟧Base : Value.Structure Base)
where
open import Base.Denotation.Notation
open Type.Structure Base
open MType.Structure Base
open Value.Structure Base ⟦_⟧Base
open import Data.Product hiding (map)
open import Data.Sum hiding (map)
open import Data.Unit
open import Level
open import Function hiding (const)
module Structure where
⟦_⟧ValType : (τ : ValType) → Set
⟦_⟧CompType : (τ : CompType) → Set
⟦ U c ⟧ValType = ⟦ c ⟧CompType
⟦ B ι ⟧ValType = ⟦ base ι ⟧
⟦ vUnit ⟧ValType = ⊤
⟦ τ₁ v× τ₂ ⟧ValType = ⟦ τ₁ ⟧ValType × ⟦ τ₂ ⟧ValType
⟦ τ₁ v+ τ₂ ⟧ValType = ⟦ τ₁ ⟧ValType ⊎ ⟦ τ₂ ⟧ValType
⟦ F τ ⟧CompType = ⟦ τ ⟧ValType
⟦ σ ⇛ τ ⟧CompType = ⟦ σ ⟧ValType → ⟦ τ ⟧CompType
instance
-- This means: Overload ⟦_⟧ to mean ⟦_⟧ValType.
meaningOfValType : Meaning ValType
meaningOfValType = meaning ⟦_⟧ValType
meaningOfCompType : Meaning CompType
meaningOfCompType = meaning ⟦_⟧CompType
-- We also provide: Environments of values (but not of computations).
open import Base.Denotation.Environment ValType ⟦_⟧ValType public
using ()
renaming ( ⟦_⟧Var to ⟦_⟧ValVar
; ⟦_⟧Context to ⟦_⟧ValContext
; meaningOfContext to meaningOfValContext
)
| {
"alphanum_fraction": 0.6268382353,
"avg_line_length": 29.6727272727,
"ext": "agda",
"hexsha": "23a2adde7eeb41123fcb8ecc31d928009d4a8a29",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "inc-lc/ilc-agda",
"max_forks_repo_path": "Parametric/Denotation/MValue.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "inc-lc/ilc-agda",
"max_issues_repo_path": "Parametric/Denotation/MValue.agda",
"max_line_length": 72,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "inc-lc/ilc-agda",
"max_stars_repo_path": "Parametric/Denotation/MValue.agda",
"max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z",
"num_tokens": 515,
"size": 1632
} |
-- Logical consistency of IPL
open import Library
module Consistency (Base : Set) where
import Formulas ; open module Form = Formulas Base
import Derivations ; open module Der = Derivations Base
import NfModelMonad; open module NfM = NfModelMonad Base
open Normalization caseTreeMonad using (norm)
-- No variable in the empty context.
noVar : ∀{A} → Hyp A ε → ⊥
noVar ()
-- No neutral in the empty context.
noNe : ∀{A} → Ne ε A → ⊥
noNe (hyp ())
noNe (impE t u) = noNe t
noNe (andE₁ t) = noNe t
noNe (andE₂ t) = noNe t
-- No normal proof of False in the empty context.
noNf : Nf ε False → ⊥
noNf (orE t t₁ t₂) = noNe t
noNf (falseE t) = noNe t
-- No proof of False in the empty context.
consistency : ε ⊢ False → ⊥
consistency = noNf ∘ norm
| {
"alphanum_fraction": 0.67578125,
"avg_line_length": 21.9428571429,
"ext": "agda",
"hexsha": "c8920c17001c167a55471698cc15c95504d0dfa0",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-02-25T20:39:03.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-11-13T16:01:46.000Z",
"max_forks_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "andreasabel/ipl",
"max_forks_repo_path": "src/Consistency.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"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": "andreasabel/ipl",
"max_issues_repo_path": "src/Consistency.agda",
"max_line_length": 57,
"max_stars_count": 19,
"max_stars_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "andreasabel/ipl",
"max_stars_repo_path": "src/Consistency.agda",
"max_stars_repo_stars_event_max_datetime": "2021-04-27T19:10:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-16T08:08:51.000Z",
"num_tokens": 260,
"size": 768
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import LogicalFormulae
open import Numbers.Naturals.Definition
module Sets.FinSet.Definition where
data FinSet : (n : ℕ) → Set where
fzero : {n : ℕ} → FinSet (succ n)
fsucc : {n : ℕ} → FinSet n → FinSet (succ n)
fsuccInjective : {n : ℕ} → {a b : FinSet n} → fsucc a ≡ fsucc b → a ≡ b
fsuccInjective refl = refl
data FinNotEquals : {n : ℕ} → (a b : FinSet (succ n)) → Set where
fne2 : (a b : FinSet 2) → ((a ≡ fzero) && (b ≡ fsucc (fzero))) || ((b ≡ fzero) && (a ≡ fsucc (fzero))) → FinNotEquals {1} a b
fneN : {n : ℕ} → (a b : FinSet (succ (succ (succ n)))) → (((a ≡ fzero) && (Sg (FinSet (succ (succ n))) (λ c → b ≡ fsucc c))) || ((Sg (FinSet (succ (succ n))) (λ c → a ≡ fsucc c)) && (b ≡ fzero))) || (Sg (FinSet (succ (succ n)) && FinSet (succ (succ n))) (λ t → (a ≡ fsucc (_&&_.fst t)) & (b ≡ fsucc (_&&_.snd t)) & FinNotEquals (_&&_.fst t) (_&&_.snd t))) → FinNotEquals {succ (succ n)} a b
| {
"alphanum_fraction": 0.5638629283,
"avg_line_length": 53.5,
"ext": "agda",
"hexsha": "9b50ce0673dcf432cee8b06b9be630da54a0991c",
"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": "Sets/FinSet/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": "Sets/FinSet/Definition.agda",
"max_line_length": 392,
"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": "Sets/FinSet/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": 383,
"size": 963
} |
-- Andreas, 2017-07-28, issue #1126 reported by Saizan is fixed
data ℕ : Set where
zero : ℕ
suc : (n : ℕ) → ℕ
{-# BUILTIN NATURAL ℕ #-}
data Unit : Set where
unit : Unit
slow : ℕ → Unit
slow zero = unit
slow (suc n) = slow n
postulate
IO : Set → Set
{-# COMPILE GHC IO = type IO #-}
{-# BUILTIN IO IO #-}
postulate
return : ∀ {A} → A → IO A
{-# COMPILE GHC return = (\ _ -> return) #-}
{-# COMPILE JS return =
function(u0) { return function(u1) { return function(x) { return function(cb) { cb(x); }; }; }; } #-}
{-# FOREIGN OCaml
let return _ x world = Lwt.return x
#-}
{-# COMPILE OCaml return = return #-}
force : Unit → IO Unit
force unit = return unit
n = 3000000000
main : IO Unit
main = force (slow n)
-- Should terminate instantaneously.
| {
"alphanum_fraction": 0.6059431525,
"avg_line_length": 19.35,
"ext": "agda",
"hexsha": "baec1dea216368b39e3d21fea394b7b7618e815f",
"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": "026a8f8473ab91f99c3f6545728e71fa847d2720",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "xekoukou/agda-ocaml",
"max_forks_repo_path": "test/Compiler/simple/Issue1126.agda",
"max_issues_count": 16,
"max_issues_repo_head_hexsha": "026a8f8473ab91f99c3f6545728e71fa847d2720",
"max_issues_repo_issues_event_max_datetime": "2019-09-08T13:47:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-10-08T00:32:04.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "xekoukou/agda-ocaml",
"max_issues_repo_path": "test/Compiler/simple/Issue1126.agda",
"max_line_length": 105,
"max_stars_count": 7,
"max_stars_repo_head_hexsha": "026a8f8473ab91f99c3f6545728e71fa847d2720",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "xekoukou/agda-ocaml",
"max_stars_repo_path": "test/Compiler/simple/Issue1126.agda",
"max_stars_repo_stars_event_max_datetime": "2018-11-06T16:38:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-11-05T22:13:36.000Z",
"num_tokens": 243,
"size": 774
} |
module Base.Prelude.Pair where
open import Base.Free using (Free; pure)
data Pair (Shape : Set) (Pos : Shape → Set) (A B : Set) : Set where
pair : Free Shape Pos A → Free Shape Pos B → Pair Shape Pos A B
pattern Pair′ ma mb = pure (pair ma mb)
| {
"alphanum_fraction": 0.6746987952,
"avg_line_length": 27.6666666667,
"ext": "agda",
"hexsha": "d2d8216ff762111a77715af8c1d423c8f71e1d91",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2021-05-14T07:48:41.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-04-08T11:23:46.000Z",
"max_forks_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "FreeProving/free-compiler",
"max_forks_repo_path": "base/agda/Base/Prelude/Pair.agda",
"max_issues_count": 120,
"max_issues_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9",
"max_issues_repo_issues_event_max_datetime": "2020-12-08T07:46:01.000Z",
"max_issues_repo_issues_event_min_datetime": "2020-04-09T09:40:39.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "FreeProving/free-compiler",
"max_issues_repo_path": "base/agda/Base/Prelude/Pair.agda",
"max_line_length": 67,
"max_stars_count": 36,
"max_stars_repo_head_hexsha": "6931b9ca652a185a92dd824373f092823aea4ea9",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "FreeProving/free-compiler",
"max_stars_repo_path": "base/agda/Base/Prelude/Pair.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-21T13:38:23.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-02-06T11:03:34.000Z",
"num_tokens": 73,
"size": 249
} |
-- Quicksort
{-# OPTIONS --without-K --safe #-}
module Algorithms.List.Sort.Quick where
-- agda-stdlib
open import Level
open import Data.List
import Data.List.Properties as Listₚ
open import Data.Product
import Data.Nat as ℕ
open import Data.Nat.Induction as Ind
open import Relation.Binary as B
open import Relation.Binary.PropositionalEquality as P using (_≡_)
open import Relation.Unary as U
import Relation.Unary.Properties as Uₚ
open import Function.Base
open import Induction.WellFounded
private
variable
a p r : Level
module _ {A : Set a} {P : U.Pred A p} (P? : U.Decidable P) where
partition₁-defn : ∀ xs → proj₁ (partition P? xs) ≡ filter P? xs
partition₁-defn xs = P.cong proj₁ (Listₚ.partition-defn P? xs)
partition₂-defn : ∀ xs → proj₂ (partition P? xs) ≡ filter (Uₚ.∁? P?) xs
partition₂-defn xs = P.cong proj₂ (Listₚ.partition-defn P? xs)
length-partition₁ : ∀ xs → length (proj₁ (partition P? xs)) ℕ.≤ length xs
length-partition₁ xs =
P.subst (ℕ._≤ length xs)
(P.sym $ P.cong length $ partition₁-defn xs)
(Listₚ.length-filter P? xs)
length-partition₂ : ∀ xs → length (proj₂ (partition P? xs)) ℕ.≤ length xs
length-partition₂ xs =
P.subst (ℕ._≤ length xs)
(P.sym $ P.cong length $ partition₂-defn xs)
(Listₚ.length-filter (Uₚ.∁? P?) xs)
module Quicksort {A : Set a} {_≤_ : Rel A r} (_≤?_ : B.Decidable _≤_) where
split : A → List A → List A × List A
split x xs = partition (λ y → y ≤? x) xs
_L<_ : Rel (List A) _
_L<_ = ℕ._<_ on length
sort-acc : ∀ xs → Acc _L<_ xs → List A
sort-acc [] _ = []
sort-acc (x ∷ xs) (acc rs) =
sort-acc ys (rs _ (ℕ.s≤s $ length-partition₁ (_≤? x) xs)) ++
[ x ] ++
sort-acc zs (rs _ (ℕ.s≤s $ length-partition₂ (_≤? x) xs))
where
splitted = split x xs
ys = proj₁ splitted
zs = proj₂ splitted
L<-wf : WellFounded _L<_
L<-wf = InverseImage.wellFounded length Ind.<-wellFounded
-- Quicksort
sort : List A → List A
sort xs = sort-acc xs (L<-wf xs)
| {
"alphanum_fraction": 0.6310160428,
"avg_line_length": 29.8115942029,
"ext": "agda",
"hexsha": "ec4438e7dd443dfb02004d26824668e0fc939c14",
"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": "37200ea91d34a6603d395d8ac81294068303f577",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "rei1024/agda-misc",
"max_forks_repo_path": "Algorithms/List/Sort/Quick.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"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": "rei1024/agda-misc",
"max_issues_repo_path": "Algorithms/List/Sort/Quick.agda",
"max_line_length": 75,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "rei1024/agda-misc",
"max_stars_repo_path": "Algorithms/List/Sort/Quick.agda",
"max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z",
"num_tokens": 693,
"size": 2057
} |
module F2 where
open import Data.Empty
open import Data.Unit
open import Data.Sum hiding (map; [_,_])
open import Data.Product hiding (map; ,_)
open import Function using (flip)
open import Relation.Binary.Core
using (IsEquivalence; Reflexive; Symmetric; Transitive)
open import Relation.Binary
open import Groupoid
infix 2 _∎ -- equational reasoning
infixr 2 _≡⟨_⟩_ -- equational reasoning
---------------------------------------------------------------------------
-- Paths
-- these are individual paths so to speak
-- should we represent a path like swap+ as a family explicitly:
-- swap+ : (x : A) -> x ⇛ swapF x
-- I guess we can: swap+ : (x : A) -> case x of inj1 -> swap1 x else swap2 x
{--
Use pointed types instead of singletons
If A={x0,x1,x2}, 1/A has three values:
(x0<-x0, x0<-x1, x0<-x2)
(x1<-x0, x1<-x1, x1<-x2)
(x2<-x0, x2<-x1, x2<-x2)
It is a fake choice between x0, x1, and x2 (some negative information). You base
yourself at x0 for example and enforce that any other value can be mapped to x0.
So think of a value of type 1/A as an uncertainty about which value of A we
have. It could be x0, x1, or x2 but at the end it makes no difference. There is
no choice.
You can manipulate a value of type 1/A (x0<-x0, x0<-x1, x0<-x2) by with a
path to some arbitrary path to b0 for example:
(b0<-x0<-x0, b0<-x0<-x1, b0<-x0<-x2)
eta_3 will give (x0<-x0, x0<-x1, x0<-x2, x0) for example but any other
combination is equivalent.
epsilon_3 will take (x0<-x0, x0<-x1, x0<-x2) and one actual xi which is now
certain; we can resolve our previous uncertainty by following the path from
xi to x0 thus eliminating the fake choice we seemed to have.
Explain connection to negative information.
Knowing head or tails is 1 bits. Giving you a choice between heads and tails
and then cooking this so that heads=tails takes away your choice.
--}
data _⇛_ : {A B : Set} → (x : A) → (y : B) → Set₁ where
-- +
unite₊⇛ : {A : Set} {x : A} → _⇛_ {⊥ ⊎ A} {A} (inj₂ x) x
uniti₊⇛ : {A : Set} {x : A} → _⇛_ {A} {⊥ ⊎ A} x (inj₂ x)
swap₁₊⇛ : {A B : Set} {x : A} → _⇛_ {A ⊎ B} {B ⊎ A} (inj₁ x) (inj₂ x)
swap₂₊⇛ : {A B : Set} {y : B} → _⇛_ {A ⊎ B} {B ⊎ A} (inj₂ y) (inj₁ y)
assocl₁₊⇛ : {A B C : Set} {x : A} →
_⇛_ {A ⊎ (B ⊎ C)} {(A ⊎ B) ⊎ C} (inj₁ x) (inj₁ (inj₁ x))
assocl₂₁₊⇛ : {A B C : Set} {y : B} →
_⇛_ {A ⊎ (B ⊎ C)} {(A ⊎ B) ⊎ C} (inj₂ (inj₁ y)) (inj₁ (inj₂ y))
assocl₂₂₊⇛ : {A B C : Set} {z : C} →
_⇛_ {A ⊎ (B ⊎ C)} {(A ⊎ B) ⊎ C} (inj₂ (inj₂ z)) (inj₂ z)
assocr₁₁₊⇛ : {A B C : Set} {x : A} →
_⇛_ {(A ⊎ B) ⊎ C} {A ⊎ (B ⊎ C)} (inj₁ (inj₁ x)) (inj₁ x)
assocr₁₂₊⇛ : {A B C : Set} {y : B} →
_⇛_ {(A ⊎ B) ⊎ C} {A ⊎ (B ⊎ C)} (inj₁ (inj₂ y)) (inj₂ (inj₁ y))
assocr₂₊⇛ : {A B C : Set} {z : C} →
_⇛_ {(A ⊎ B) ⊎ C} {A ⊎ (B ⊎ C)} (inj₂ z) (inj₂ (inj₂ z))
-- *
unite⋆⇛ : {A : Set} {x : A} → _⇛_ {⊤ × A} {A} (tt , x) x
uniti⋆⇛ : {A : Set} {x : A} → _⇛_ {A} {⊤ × A} x (tt , x)
swap⋆⇛ : {A B : Set} {x : A} {y : B} → _⇛_ {A × B} {B × A} (x , y) (y , x)
assocl⋆⇛ : {A B C : Set} {x : A} {y : B} {z : C} →
_⇛_ {A × (B × C)} {(A × B) × C} (x , (y , z)) ((x , y) , z)
assocr⋆⇛ : {A B C : Set} {x : A} {y : B} {z : C} →
_⇛_ {(A × B) × C} {A × (B × C)} ((x , y) , z) (x , (y , z))
-- distributivity
dist₁⇛ : {A B C : Set} {x : A} {z : C} →
_⇛_ {(A ⊎ B) × C} {(A × C) ⊎ (B × C)} (inj₁ x , z) (inj₁ (x , z))
dist₂⇛ : {A B C : Set} {y : B} {z : C} →
_⇛_ {(A ⊎ B) × C} {(A × C) ⊎ (B × C)} (inj₂ y , z) (inj₂ (y , z))
factor₁⇛ : {A B C : Set} {x : A} {z : C} →
_⇛_ {(A × C) ⊎ (B × C)} {(A ⊎ B) × C} (inj₁ (x , z)) (inj₁ x , z)
factor₂⇛ : {A B C : Set} {y : B} {z : C} →
_⇛_ {(A × C) ⊎ (B × C)} {(A ⊎ B) × C}
(inj₂ (y , z)) (inj₂ y , z)
dist0⇛ : {A : Set} {• : ⊥} {x : A} → _⇛_ {⊥ × A} {⊥} (• , x) •
factor0⇛ : {A : Set} {• : ⊥} {x : A} → _⇛_ {⊥} {⊥ × A} • (• , x)
-- congruence
id⇛ : {A : Set} → (x : A) → x ⇛ x
sym⇛ : {A B : Set} {x : A} {y : B} → x ⇛ y → y ⇛ x
trans⇛ : {A B C : Set} {x : A} {y : B} {z : C} → x ⇛ y → y ⇛ z → x ⇛ z
plus₁⇛ : {A B C D : Set} {x : A} {z : C} →
x ⇛ z → _⇛_ {A ⊎ B} {C ⊎ D} (inj₁ x) (inj₁ z)
plus₂⇛ : {A B C D : Set} {y : B} {w : D} →
y ⇛ w → _⇛_ {A ⊎ B} {C ⊎ D} (inj₂ y) (inj₂ w)
times⇛ : {A B C D : Set} {x : A} {y : B} {z : C} {w : D} →
x ⇛ z → y ⇛ w → _⇛_ {A × B} {C × D} (x , y) (z , w)
-- permute
-- for any given type, we should be able to generate permutations mapping any
-- point to any other type
-- Introduce equational reasoning syntax to simplify proofs
_≡⟨_⟩_ : {A B C : Set} (x : A) {y : B} {z : C} → (x ⇛ y) → (y ⇛ z) → (x ⇛ z)
_ ≡⟨ p ⟩ q = trans⇛ p q
bydef : {A : Set} {x : A} → (x ⇛ x)
bydef {A} {x} = id⇛ x
_∎ : {A : Set} (x : A) → x ⇛ x
_∎ x = id⇛ x
data Singleton {A : Set} : A → Set where
singleton : (x : A) → Singleton x
mutual
ap : {A B : Set} {x : A} {y : B} → x ⇛ y → Singleton x → Singleton y
ap {.(⊥ ⊎ A)} {A} {.(inj₂ x)} {x} unite₊⇛ (singleton .(inj₂ x)) =
singleton x
ap uniti₊⇛ (singleton x) = singleton (inj₂ x)
ap (swap₁₊⇛ {A} {B} {x}) (singleton .(inj₁ x)) = singleton (inj₂ x)
ap (swap₂₊⇛ {A} {B} {y}) (singleton .(inj₂ y)) = singleton (inj₁ y)
ap (assocl₁₊⇛ {A} {B} {C} {x}) (singleton .(inj₁ x)) =
singleton (inj₁ (inj₁ x))
ap (assocl₂₁₊⇛ {A} {B} {C} {y}) (singleton .(inj₂ (inj₁ y))) =
singleton (inj₁ (inj₂ y))
ap (assocl₂₂₊⇛ {A} {B} {C} {z}) (singleton .(inj₂ (inj₂ z))) =
singleton (inj₂ z)
ap (assocr₁₁₊⇛ {A} {B} {C} {x}) (singleton .(inj₁ (inj₁ x))) =
singleton (inj₁ x)
ap (assocr₁₂₊⇛ {A} {B} {C} {y}) (singleton .(inj₁ (inj₂ y))) =
singleton (inj₂ (inj₁ y))
ap (assocr₂₊⇛ {A} {B} {C} {z}) (singleton .(inj₂ z)) =
singleton (inj₂ (inj₂ z))
ap {.(⊤ × A)} {A} {.(tt , x)} {x} unite⋆⇛ (singleton .(tt , x)) =
singleton x
ap uniti⋆⇛ (singleton x) = singleton (tt , x)
ap (swap⋆⇛ {A} {B} {x} {y}) (singleton .(x , y)) = singleton (y , x)
ap (assocl⋆⇛ {A} {B} {C} {x} {y} {z}) (singleton .(x , (y , z))) =
singleton ((x , y) , z)
ap (assocr⋆⇛ {A} {B} {C} {x} {y} {z}) (singleton .((x , y) , z)) =
singleton (x , (y , z))
ap (dist₁⇛ {A} {B} {C} {x} {z}) (singleton .(inj₁ x , z)) =
singleton (inj₁ (x , z))
ap (dist₂⇛ {A} {B} {C} {y} {z}) (singleton .(inj₂ y , z)) =
singleton (inj₂ (y , z))
ap (factor₁⇛ {A} {B} {C} {x} {z}) (singleton .(inj₁ (x , z))) =
singleton (inj₁ x , z)
ap (factor₂⇛ {A} {B} {C} {y} {z}) (singleton .(inj₂ (y , z))) =
singleton (inj₂ y , z)
ap {.(⊥ × A)} {.⊥} {.(• , x)} {•} (dist0⇛ {A} {.•} {x}) (singleton .(• , x)) =
singleton •
ap factor0⇛ (singleton ())
ap (id⇛ .x) (singleton x) = singleton x
ap (sym⇛ c) (singleton x) = apI c (singleton x)
ap (trans⇛ c₁ c₂) (singleton x) = ap c₂ (ap c₁ (singleton x))
ap (plus₁⇛ {A} {B} {C} {D} {x} {z} c) (singleton .(inj₁ x))
with ap c (singleton x)
... | singleton .z = singleton (inj₁ z)
ap (plus₂⇛ {A} {B} {C} {D} {y} {w} c) (singleton .(inj₂ y))
with ap c (singleton y)
... | singleton .w = singleton (inj₂ w)
ap (times⇛ {A} {B} {C} {D} {x} {y} {z} {w} c₁ c₂) (singleton .(x , y))
with ap c₁ (singleton x) | ap c₂ (singleton y)
... | singleton .z | singleton .w = singleton (z , w)
apI : {A B : Set} {x : A} {y : B} → x ⇛ y → Singleton y → Singleton x
apI unite₊⇛ (singleton x) = singleton (inj₂ x)
apI {A} {.(⊥ ⊎ A)} {x} uniti₊⇛ (singleton .(inj₂ x)) = singleton x
apI (swap₁₊⇛ {A} {B} {x}) (singleton .(inj₂ x)) = singleton (inj₁ x)
apI (swap₂₊⇛ {A} {B} {y}) (singleton .(inj₁ y)) = singleton (inj₂ y)
apI (assocl₁₊⇛ {A} {B} {C} {x}) (singleton .(inj₁ (inj₁ x))) =
singleton (inj₁ x)
apI (assocl₂₁₊⇛ {A} {B} {C} {y}) (singleton .(inj₁ (inj₂ y))) =
singleton (inj₂ (inj₁ y))
apI (assocl₂₂₊⇛ {A} {B} {C} {z}) (singleton .(inj₂ z)) =
singleton (inj₂ (inj₂ z))
apI (assocr₁₁₊⇛ {A} {B} {C} {x}) (singleton .(inj₁ x)) =
singleton (inj₁ (inj₁ x))
apI (assocr₁₂₊⇛ {A} {B} {C} {y}) (singleton .(inj₂ (inj₁ y))) =
singleton (inj₁ (inj₂ y))
apI (assocr₂₊⇛ {A} {B} {C} {z}) (singleton .(inj₂ (inj₂ z))) =
singleton (inj₂ z)
apI unite⋆⇛ (singleton x) = singleton (tt , x)
apI {A} {.(⊤ × A)} {x} uniti⋆⇛ (singleton .(tt , x)) = singleton x
apI (swap⋆⇛ {A} {B} {x} {y}) (singleton .(y , x)) = singleton (x , y)
apI (assocl⋆⇛ {A} {B} {C} {x} {y} {z}) (singleton .((x , y) , z)) =
singleton (x , (y , z))
apI (assocr⋆⇛ {A} {B} {C} {x} {y} {z}) (singleton .(x , (y , z))) =
singleton ((x , y) , z)
apI (dist₁⇛ {A} {B} {C} {x} {z}) (singleton .(inj₁ (x , z))) =
singleton (inj₁ x , z)
apI (dist₂⇛ {A} {B} {C} {y} {z}) (singleton .(inj₂ (y , z))) =
singleton (inj₂ y , z)
apI (factor₁⇛ {A} {B} {C} {x} {z}) (singleton .(inj₁ x , z)) =
singleton (inj₁ (x , z))
apI (factor₂⇛ {A} {B} {C} {y} {z}) (singleton .(inj₂ y , z)) =
singleton (inj₂ (y , z))
apI dist0⇛ (singleton ())
apI {.⊥} {.(⊥ × A)} {•} (factor0⇛ {A} {.•} {x}) (singleton .(• , x)) =
singleton •
apI (id⇛ .x) (singleton x) = singleton x
apI (sym⇛ c) (singleton x) = ap c (singleton x)
apI {A} {B} {x} {y} (trans⇛ c₁ c₂) (singleton .y) =
apI c₁ (apI c₂ (singleton y))
apI (plus₁⇛ {A} {B} {C} {D} {x} {z} c) (singleton .(inj₁ z))
with apI c (singleton z)
... | singleton .x = singleton (inj₁ x)
apI (plus₂⇛ {A} {B} {C} {D} {y} {w} c) (singleton .(inj₂ w))
with apI c (singleton w)
... | singleton .y = singleton (inj₂ y)
apI (times⇛ {A} {B} {C} {D} {x} {y} {z} {w} c₁ c₂) (singleton .(z , w))
with apI c₁ (singleton z) | apI c₂ (singleton w)
... | singleton .x | singleton .y = singleton (x , y)
-- Path induction
pathInd :
(C : (A : Set) → (B : Set) → (x : A) → (y : B) → x ⇛ y → Set) →
(c : (A : Set) → (x : A) → C A A x x (id⇛ x)) →
-- add more cases, one for each constructor
(A : Set) → (B : Set) → (x : A) → (y : B) → (p : x ⇛ y) → C A B x y p
pathInd C c .(⊥ ⊎ B) B .(inj₂ y) y unite₊⇛ = {!!}
pathInd C c A .(⊥ ⊎ A) x .(inj₂ x) uniti₊⇛ = {!!}
pathInd C c .(A ⊎ B) .(B ⊎ A) .(inj₁ x) .(inj₂ x) (swap₁₊⇛ {A} {B} {x}) = {!!}
pathInd C c .(A ⊎ B) .(B ⊎ A) .(inj₂ y) .(inj₁ y) (swap₂₊⇛ {A} {B} {y}) = {!!}
pathInd C c .(A ⊎ B ⊎ C₁) .((A ⊎ B) ⊎ C₁) .(inj₁ x) .(inj₁ (inj₁ x))
(assocl₁₊⇛ {A} {B} {C₁} {x}) = {!!}
pathInd C c .(A ⊎ B ⊎ C₁) .((A ⊎ B) ⊎ C₁) .(inj₂ (inj₁ y)) .(inj₁ (inj₂ y))
(assocl₂₁₊⇛ {A} {B} {C₁} {y}) = {!!}
pathInd C c .(A ⊎ B ⊎ C₁) .((A ⊎ B) ⊎ C₁) .(inj₂ (inj₂ z)) .(inj₂ z)
(assocl₂₂₊⇛ {A} {B} {C₁} {z}) = {!!}
pathInd C c .((A ⊎ B) ⊎ C₁) .(A ⊎ B ⊎ C₁) .(inj₁ (inj₁ x)) .(inj₁ x)
(assocr₁₁₊⇛ {A} {B} {C₁} {x}) = {!!}
pathInd C c .((A ⊎ B) ⊎ C₁) .(A ⊎ B ⊎ C₁) .(inj₁ (inj₂ y)) .(inj₂ (inj₁ y))
(assocr₁₂₊⇛ {A} {B} {C₁} {y}) = {!!}
pathInd C c .((A ⊎ B) ⊎ C₁) .(A ⊎ B ⊎ C₁) .(inj₂ z) .(inj₂ (inj₂ z))
(assocr₂₊⇛ {A} {B} {C₁} {z}) = {!!}
pathInd C c .(Σ ⊤ (λ x₁ → B)) B .(tt , y) y unite⋆⇛ = {!!}
pathInd C c A .(Σ ⊤ (λ x₁ → A)) x .(tt , x) uniti⋆⇛ = {!!}
pathInd C c .(Σ A (λ x₁ → B)) .(Σ B (λ x₁ → A)) .(x , y) .(y , x)
(swap⋆⇛ {A} {B} {x} {y}) = {!!}
pathInd C c .(Σ A (λ x₁ → Σ B (λ x₂ → C₁))) .(Σ (Σ A (λ x₁ → B)) (λ x₁ → C₁))
.(x , y , z) .((x , y) , z) (assocl⋆⇛ {A} {B} {C₁} {x} {y} {z}) = {!!}
pathInd C c .(Σ (Σ A (λ x₁ → B)) (λ x₁ → C₁)) .(Σ A (λ x₁ → Σ B (λ x₂ → C₁)))
.((x , y) , z) .(x , y , z) (assocr⋆⇛ {A} {B} {C₁} {x} {y} {z}) = {!!}
pathInd C c .(Σ (A ⊎ B) (λ x₁ → C₁)) .(Σ A (λ x₁ → C₁) ⊎ Σ B (λ x₁ → C₁))
.(inj₁ x , z) .(inj₁ (x , z)) (dist₁⇛ {A} {B} {C₁} {x} {z}) = {!!}
pathInd C c .(Σ (A ⊎ B) (λ x₁ → C₁)) .(Σ A (λ x₁ → C₁) ⊎ Σ B (λ x₁ → C₁))
.(inj₂ y , z) .(inj₂ (y , z)) (dist₂⇛ {A} {B} {C₁} {y} {z}) = {!!}
pathInd C c .(Σ A (λ x₁ → C₁) ⊎ Σ B (λ x₁ → C₁)) .(Σ (A ⊎ B) (λ x₁ → C₁))
.(inj₁ (x , z)) .(inj₁ x , z) (factor₁⇛ {A} {B} {C₁} {x} {z}) = {!!}
pathInd C c .(Σ A (λ x₁ → C₁) ⊎ Σ B (λ x₁ → C₁)) .(Σ (A ⊎ B) (λ x₁ → C₁))
.(inj₂ (y , z)) .(inj₂ y , z) (factor₂⇛ {A} {B} {C₁} {y} {z}) = {!!}
pathInd C c .(Σ ⊥ (λ x₁ → A)) .⊥ .(y , x) y (dist0⇛ {A} {.y} {x}) = {!!}
pathInd C c .⊥ .(Σ ⊥ (λ x₁ → A)) x .(x , x₁) (factor0⇛ {A} {.x} {x₁}) = {!!}
pathInd C c A .A x .x (id⇛ .x) = c A x
pathInd C c A B x y (sym⇛ p) = {!!}
pathInd C c A B x y (trans⇛ p p₁) = {!!}
pathInd C c .(A ⊎ B) .(C₁ ⊎ D) .(inj₁ x) .(inj₁ z)
(plus₁⇛ {A} {B} {C₁} {D} {x} {z} p) = {!!}
pathInd C c .(A ⊎ B) .(C₁ ⊎ D) .(inj₂ y) .(inj₂ w)
(plus₂⇛ {A} {B} {C₁} {D} {y} {w} p) = {!!}
pathInd C c .(Σ A (λ x₁ → B)) .(Σ C₁ (λ x₁ → D)) .(x , y) .(z , w)
(times⇛ {A} {B} {C₁} {D} {x} {y} {z} {w} p p₁) = {!!}
------------------------------------------------------------------------------
-- Now interpret a path (x ⇛ y) as a value of type (1/x , y)
Recip : {A : Set} → (base : A) → (x : A) → Set₁
Recip {A} base = λ x → (x ⇛ base)
η : {A : Set} {base : A} → ⊤ → Recip base × Singleton base
η {A} {base} tt = (λ x → ? , singleton base)
{--
If A={x0,x1,x2}, 1/A has three values:
(x0<-x0, x0<-x1, x0<-x2)
η : {A : Set} {x : A} → ⊤ → Recip x × Singleton x
η {A} {x} tt = (id⇛ x , singleton x)
ε : {A : Set} {x : A} → Recip x × Singleton x → ⊤
ε {A} {x} (rx , singleton .x) = tt -- makes no sense
apr : {A B : Set} {x : A} {y : B} → (x ⇛ y) → Recip y → Recip x
apr {A} {B} {x} {y} p ry =
x
≡⟨ p ⟩
y
≡⟨ ry ⟩
y
≡⟨ sym⇛ p ⟩
x ∎
ε : {A B : Set} {x : A} {y : B} → Recip x → Singleton y → x ⇛ y
ε rx (singleton y) = rx y
pathV : {A B : Set} {x : A} {y : B} → (x ⇛ y) → Recip x × Singleton y
pathV unite₊⇛ = {!!}
pathV uniti₊⇛ = {!!}
-- swap₁₊⇛ : {A B : Set} {x : A} → _⇛_ {A ⊎ B} {B ⊎ A} (inj₁ x) (inj₂ x)
pathV (swap₁₊⇛ {A} {B} {x}) = ((λ x' → {!!}) , singleton (inj₂ x))
pathV swap₂₊⇛ = {!!}
pathV assocl₁₊⇛ = {!!}
pathV assocl₂₁₊⇛ = {!!}
pathV assocl₂₂₊⇛ = {!!}
pathV assocr₁₁₊⇛ = {!!}
pathV assocr₁₂₊⇛ = {!!}
pathV assocr₂₊⇛ = {!!}
pathV unite⋆⇛ = {!!}
pathV uniti⋆⇛ = {!!}
pathV swap⋆⇛ = {!!}
pathV assocl⋆⇛ = {!!}
pathV assocr⋆⇛ = {!!}
pathV dist₁⇛ = {!!}
pathV dist₂⇛ = {!!}
pathV factor₁⇛ = {!!}
pathV factor₂⇛ = {!!}
pathV dist0⇛ = {!!}
pathV factor0⇛ = {!!}
pathV {A} {.A} {x} (id⇛ .x) = {!!}
pathV (sym⇛ p) = {!!}
pathV (trans⇛ p p₁) = {!!}
pathV (plus₁⇛ p) = {!!}
pathV (plus₂⇛ p) = {!!}
pathV (times⇛ p p₁) = {!!}
data _⇛_ : {A B : Set} → (x : A) → (y : B) → Set₁ where
------------------------------------------------------------------------------
-- pi types with exactly one level of reciprocals
-- interpretation of B1 types as 1-groupoids
data B0 : Set where
ZERO : B0
ONE : B0
PLUS0 : B0 → B0 → B0
TIMES0 : B0 → B0 → B0
⟦_⟧₀ : B0 → Set
⟦ ZERO ⟧₀ = ⊥
⟦ ONE ⟧₀ = ⊤
⟦ PLUS0 b₁ b₂ ⟧₀ = ⟦ b₁ ⟧₀ ⊎ ⟦ b₂ ⟧₀
⟦ TIMES0 b₁ b₂ ⟧₀ = ⟦ b₁ ⟧₀ × ⟦ b₂ ⟧₀
data B1 : Set where
LIFT0 : B0 → B1
PLUS1 : B1 → B1 → B1
TIMES1 : B1 → B1 → B1
RECIP1 : B0 → B1
open 1Groupoid
⟦_⟧₁ : B1 → 1Groupoid
⟦ LIFT0 b0 ⟧₁ = discrete ⟦ b0 ⟧₀
⟦ PLUS1 b₁ b₂ ⟧₁ = ⟦ b₁ ⟧₁ ⊎G ⟦ b₂ ⟧₁
⟦ TIMES1 b₁ b₂ ⟧₁ = ⟦ b₁ ⟧₁ ×G ⟦ b₂ ⟧₁
⟦ RECIP1 b0 ⟧₁ = {!!} -- allPaths (ı₀ b0)
ı₁ : B1 → Set
ı₁ b = set ⟦ b ⟧₁
test10 = ⟦ LIFT0 ONE ⟧₁
test11 = ⟦ LIFT0 (PLUS0 ONE ONE) ⟧₁
test12 = ⟦ RECIP1 (PLUS0 ONE ONE) ⟧₁
-- interpret isos as functors
data _⟷₁_ : B1 → B1 → Set where
-- +
swap₊ : { b₁ b₂ : B1 } → PLUS1 b₁ b₂ ⟷₁ PLUS1 b₂ b₁
assocl₊ : { b₁ b₂ b₃ : B1 } → PLUS b₁ (PLUS b₂ b₃) ⟷₁ PLUS (PLUS b₁ b₂) b₃
assocr₊ : { b₁ b₂ b₃ : B1 } → PLUS (PLUS b₁ b₂) b₃ ⟷₁ PLUS b₁ (PLUS b₂ b₃)
-- *
unite⋆ : { b : B1 } → TIMES1 (LIFT0 ONE) b ⟷₁ b
uniti⋆ : { b : B1 } → b ⟷₁ TIMES1 (LIFT0 ONE) b
swap⋆ : { b₁ b₂ : B } → TIMES b₁ b₂ ⟷₁ TIMES b₂ b₁
assocl⋆ : { b₁ b₂ b₃ : B } → TIMES b₁ (TIMES b₂ b₃) ⟷₁ TIMES (TIMES b₁ b₂) b₃
assocr⋆ : { b₁ b₂ b₃ : B } → TIMES (TIMES b₁ b₂) b₃ ⟷₁ TIMES b₁ (TIMES b₂ b₃)
-- * distributes over +
dist : { b₁ b₂ b₃ : B } →
TIMES (PLUS b₁ b₂) b₃ ⟷₁ PLUS (TIMES b₁ b₃) (TIMES b₂ b₃)
factor : { b₁ b₂ b₃ : B } →
PLUS (TIMES b₁ b₃) (TIMES b₂ b₃) ⟷₁ TIMES (PLUS b₁ b₂) b₃
-- congruence
id⟷₁ : { b : B } → b ⟷₁ b
sym : { b₁ b₂ : B } → (b₁ ⟷₁ b₂) → (b₂ ⟷₁ b₁)
_∘_ : { b₁ b₂ b₃ : B } → (b₁ ⟷₁ b₂) → (b₂ ⟷₁ b₃) → (b₁ ⟷₁ b₃)
_⊕_ : { b₁ b₂ b₃ b₄ : B } →
(b₁ ⟷₁ b₃) → (b₂ ⟷₁ b₄) → (PLUS b₁ b₂ ⟷₁ PLUS b₃ b₄)
_⊗_ : { b₁ b₂ b₃ b₄ : B } →
(b₁ ⟷₁ b₃) → (b₂ ⟷₁ b₄) → (TIMES b₁ b₂ ⟷₁ TIMES b₃ b₄)
η⋆ : (b : B0) → LIFT0 ONE ⟷₁ TIMES1 (LIFT0 b) (RECIP1 b)
ε⋆ : (b : B0) → TIMES1 (LIFT0 b) (RECIP1 b) ⟷₁ LIFT0 ONE
record 1-functor (A B : 1Groupoid) : Set where
constructor 1F
private module A = 1Groupoid A
private module B = 1Groupoid B
field
F₀ : set A → set B
F₁ : ∀ {X Y : set A} → A [ X , Y ] → B [ F₀ X , F₀ Y ]
-- identity : ∀ {X} → B._≈_ (F₁ (A.id {X})) B.id
-- F-resp-≈ : ∀ {X Y} {F G : A [ X , Y ]} → A._≈_ F G → B._≈_ (F₁ F) (F₁ G)
open 1-functor public
ipath : (b : B1) → ı₁ b → ı₁ b → Set
ipath b x y = Path {ı₁ b} x y
swap⊎ : {A B : Set} → A ⊎ B → B ⊎ A
swap⊎ (inj₁ a) = inj₂ a
swap⊎ (inj₂ b) = inj₁ b
intro1⋆ : {b : B1} {x y : ı₁ b} → ipath b x y → ipath (TIMES1 (LIFT0 ONE) b) (tt , x) (tt , y)
intro1⋆ (y ⇛ z) = (tt , y) ⇛ (tt , z)
objη⋆ : (b : B0) → ı₁ (LIFT0 ONE) → ı₁ (TIMES1 (LIFT0 b) (RECIP1 b))
objη⋆ b tt = point b , point b
objε⋆ : (b : B0) → ı₁ (TIMES1 (LIFT0 b) (RECIP1 b)) → ı₁ (LIFT0 ONE)
objε⋆ b (x , y) = tt
elim1∣₁ : (b : B1) → ı₁ (TIMES1 (LIFT0 ONE) b) → ı₁ b
elim1∣₁ b (tt , x) = x
intro1∣₁ : (b : B1) → ı₁ b → ı₁ (TIMES1 (LIFT0 ONE) b)
intro1∣₁ b x = (tt , x)
swapF : {b₁ b₂ : B1} →
let G = ⟦ b₁ ⟧₁ ⊎G ⟦ b₂ ⟧₁
G' = ⟦ b₂ ⟧₁ ⊎G ⟦ b₁ ⟧₁ in
{X Y : set G} → G [ X , Y ] → G' [ swap⊎ X , swap⊎ Y ]
swapF {X = inj₁ _} {inj₁ _} f = f
swapF {X = inj₁ _} {inj₂ _} ()
swapF {X = inj₂ _} {inj₁ _} ()
swapF {X = inj₂ _} {inj₂ _} f = f
eta : (b : B0) → List (ipath (LIFT0 ONE)) → List (ipath (TIMES1 (LIFT0 b) (RECIP1 b)))
-- note how the input list is not used at all!
eta b _ = prod (λ a a' → _↝_ (a , tt) (a' , tt)) (elems0 b) (elems0 b)
eps : (b : B0) → ipath (TIMES1 (LIFT0 b) (RECIP1 b)) → ipath (LIFT0 ONE)
eps b0 (a ⇛ b) = tt ⇛ tt
Funite⋆ : {b₁ : B1} → ∀ {X Y : set (discrete (ı₀ ONE) ×G ⟦ b₁ ⟧₁)} → DPath (proj₁ X) (proj₁ Y) × (_↝_ ⟦ b₁ ⟧₁) (proj₂ X) (proj₂ Y) → _↝_ ⟦ b₁ ⟧₁ (proj₂ X) (proj₂ Y)
Funite⋆ {b₁} {tt , _} {tt , _} (reflD , y) = y
Funiti⋆ : {b₁ : B1} → ∀ {X Y : set (discrete (ı₀ ONE) ×G ⟦ b₁ ⟧₁)} → _↝_ ⟦ b₁ ⟧₁ (proj₂ X) (proj₂ Y) → DPath (proj₁ X) (proj₁ Y) × (_↝_ ⟦ b₁ ⟧₁) (proj₂ X) (proj₂ Y)
Funiti⋆ y = reflD , y
mutual
eval : {b₁ b₂ : B1} → (b₁ ⟷₁ b₂) → 1-functor ⟦ b₁ ⟧₁ ⟦ b₂ ⟧₁
eval (swap₊ {b₁} {b₂}) = 1F swap⊎ (λ {X Y} → swapF {b₁} {b₂} {X} {Y})
eval (unite⋆ {b}) = 1F (elim1∣₁ b) (Funite⋆ {b})
eval (uniti⋆ {b}) = 1F (intro1∣₁ b) (Funiti⋆ {b})
-- eval (η⋆ b) = F₁ (objη⋆ b) (eta b )
-- eval (ε⋆ b) = F₁ (objε⋆ b) (map (eps b))
evalB : {b₁ b₂ : B1} → (b₁ ⟷₁ b₂) → 1-functor ⟦ b₂ ⟧₁ ⟦ b₁ ⟧₁
evalB (swap₊ {b₁} {b₂}) = 1F swap⊎ ((λ {X Y} → swapF {b₂} {b₁} {X} {Y}))
evalB (unite⋆ {b}) = 1F (intro1∣₁ b) (Funiti⋆ {b})
evalB (uniti⋆ {b}) = 1F (elim1∣₁ b) (Funite⋆ {b})
-- evalB (η⋆ b) = F₁ (objε⋆ b) (map (eps b))
-- evalB (ε⋆ b) = F₁ (objη⋆ b) (eta b)
eval assocl₊ = ? -- : { b₁ b₂ b₃ : B } → PLUS b₁ (PLUS b₂ b₃) ⟷₁ PLUS (PLUS b₁ b₂) b₃
eval assocr₊ = ? -- : { b₁ b₂ b₃ : B } → PLUS (PLUS b₁ b₂) b₃ ⟷₁ PLUS b₁ (PLUS b₂ b₃)
eval uniti⋆ = ? -- : { b : B } → b ⟷₁ TIMES ONE b
eval swap⋆ = ? -- : { b₁ b₂ : B } → TIMES b₁ b₂ ⟷₁ TIMES b₂ b₁
eval assocl⋆ = ? -- : { b₁ b₂ b₃ : B } → TIMES b₁ (TIMES b₂ b₃) ⟷₁ TIMES (TIMES b₁ b₂) b₃
eval assocr⋆ = ? -- : { b₁ b₂ b₃ : B } → TIMES (TIMES b₁ b₂) b₃ ⟷₁ TIMES b₁ (TIMES b₂ b₃)
eval dist = ? -- : { b₁ b₂ b₃ : B } → TIMES (PLUS b₁ b₂) b₃ ⟷₁ PLUS (TIMES b₁ b₃) (TIMES b₂ b₃)
eval factor = ? -- : { b₁ b₂ b₃ : B } → PLUS (TIMES b₁ b₃) (TIMES b₂ b₃) ⟷₁ TIMES (PLUS b₁ b₂) b₃
eval id⟷₁ = ? -- : { b : B } → b ⟷₁ b
eval (sym c) = ? -- : { b₁ b₂ : B } → (b₁ ⟷₁ b₂) → (b₂ ⟷₁ b₁)
eval (c₁ ∘ c₂) = ? -- : { b₁ b₂ b₃ : B } → (b₁ ⟷₁ b₂) → (b₂ ⟷₁ b₃) → (b₁ ⟷₁ b₃)
eval (c₁ ⊕ c₂) = ? -- : { b₁ b₂ b₃ b₄ : B } → (b₁ ⟷₁ b₃) → (b₂ ⟷₁ b₄) → (PLUS b₁ b₂ ⟷₁ PLUS b₃ b₄)
eval (c₁ ⊗ c₂) = ? -- : { b₁ b₂ b₃ b₄ : B } → (b₁ ⟷₁ b₃) → (b₂ ⟷₁ b₄) → (TIMES b₁ b₂ ⟷₁ TIMES b₃ b₄)
-- lid⇛ : {A B : Set} {x : A} {y : B} → (trans⇛ (id⇛ x) (x ⇛ y)) ⇛ (x ⇛ y)
-- lid⇛ {A} {B} {x} {y} =
-- pathInd ?
ap : {A B : Set} → (f : A → B) → {a a' : A} → Path a a' → Path (f a) (f a')
ap f (a ⇛ a') = (f a) ⇛ (f a')
_∙⇛_ : {A : Set} {a b c : A} → Path b c → Path a b → Path a c
(b ⇛ c) ∙⇛ (a ⇛ .b) = a ⇛ c
_⇚ : {A : Set} {a b : A} → Path a b → Path b a
(x ⇛ y) ⇚ = y ⇛ x
lid⇛ : {A : Set} {x y : A} (α : Path x y) → (id⇛ y ∙⇛ α) ≣⇛ α
lid⇛ (x ⇛ y) = refl⇛
rid⇛ : {A : Set} {x y : A} (α : Path x y) → (α ∙⇛ id⇛ x) ≣⇛ α
rid⇛ (x ⇛ y) = refl⇛
assoc⇛ : {A : Set} {w x y z : A} (α : Path y z) (β : Path x y) (δ : Path w x) → ((α ∙⇛ β) ∙⇛ δ) ≣⇛ (α ∙⇛ (β ∙⇛ δ))
assoc⇛ (y ⇛ z) (x ⇛ .y) (w ⇛ .x) = refl⇛
l⇚ : {A : Set} {x y : A} (α : Path x y) → ((α ⇚) ∙⇛ α) ≣⇛ id⇛ x
l⇚ (x ⇛ y) = refl⇛
r⇚ : {A : Set} {x y : A} (α : Path x y) → (α ∙⇛ (α ⇚)) ≣⇛ id⇛ y
r⇚ (x ⇛ y) = refl⇛
sym⇛ : {A : Set} {x y : A} {α β : Path x y} → α ≣⇛ β → β ≣⇛ α
sym⇛ refl⇛ = refl⇛
trans⇛ : {A : Set} {x y : A} {α β δ : Path x y} → α ≣⇛ β → β ≣⇛ δ → α ≣⇛ δ
trans⇛ refl⇛ refl⇛ = refl⇛
equiv≣⇛ : {A : Set} {x y : A} → IsEquivalence {_} {_} {Path x y} (_≣⇛_)
equiv≣⇛ = record { refl = refl⇛; sym = sym⇛; trans = trans⇛ }
resp≣⇛ : {A : Set} {x y z : A} {f h : Path y z} {g i : Path x y} →
f ≣⇛ h → g ≣⇛ i → (f ∙⇛ g) ≣⇛ (h ∙⇛ i)
resp≣⇛ refl⇛ refl⇛ = refl⇛
record 0-type : Set₁ where
constructor G₀
field
∣_∣₀ : Set
open 0-type public
plus : 0-type → 0-type → 0-type
plus t₁ t₂ = G₀ (∣ t₁ ∣₀ ⊎ ∣ t₂ ∣₀)
times : 0-type → 0-type → 0-type
times t₁ t₂ = G₀ (∣ t₁ ∣₀ × ∣ t₂ ∣₀)
⟦_⟧₀ : B0 → 0-type
⟦ ONE ⟧₀ = G₀ ⊤
⟦ PLUS0 b₁ b₂ ⟧₀ = plus ⟦ b₁ ⟧₀ ⟦ b₂ ⟧₀
⟦ TIMES0 b₁ b₂ ⟧₀ = times ⟦ b₁ ⟧₀ ⟦ b₂ ⟧₀
ı₀ : B0 → Set
ı₀ b = ∣ ⟦ b ⟧₀ ∣₀
point : (b : B0) → ı₀ b
point ONE = tt
point (PLUS0 b _) = inj₁ (point b)
point (TIMES0 b₀ b₁) = point b₀ , point b₁
allPaths : Set → 1Groupoid
allPaths a = record
{ set = a
; _↝_ = Path
; _≈_ = _≣⇛_
; id = λ {x} → id⇛ x
; _∘_ = _∙⇛_
; _⁻¹ = _⇚
; lneutr = lid⇛
; rneutr = rid⇛
; assoc = assoc⇛
; linv = l⇚
; rinv = r⇚
; equiv = equiv≣⇛
; ∘-resp-≈ = resp≣⇛}
--}
| {
"alphanum_fraction": 0.4633092884,
"avg_line_length": 38.8546712803,
"ext": "agda",
"hexsha": "526ea83158572f2e7d450e5df71f5d17ee1797a4",
"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": "F2.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": "F2.agda",
"max_line_length": 168,
"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": "F2.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": 12007,
"size": 22458
} |
open import ExtractSac as ES using ()
open import Extract (ES.kompile-fun)
open import Data.Nat
open import Data.Nat.Properties
open import Data.List as L using (List; []; _∷_)
open import Data.Vec as V using (Vec; []; _∷_)
open import Data.Fin using (Fin; zero; suc; #_)
open import Relation.Binary.PropositionalEquality
open import Reflection
open import Structures
open import Function
test-13f : ∀ {n} → Vec ℕ n → Vec ℕ (n + n * n) → ℕ
test-13f [] _ = 0
test-13f (x ∷ a) b = x
test₁₃ : kompile test-13f [] [] ≡ ok _
test₁₃ = refl
test-14f : ∀ {n} → Vec ℕ n → Vec ℕ (n) → Vec ℕ n
test-14f [] _ = []
test-14f (x ∷ a) (y ∷ b) = x + y ∷ test-14f a b
test₁₄ : kompile test-14f [] [] ≡ ok _
test₁₄ = refl
-- Note that rewrite helper function would generate
-- the equality type amongst its arguments.
test-15f : ∀ {a b} → Fin (a + b) → Fin (b + a)
test-15f {a}{b} x rewrite (+-comm a b) = x
test₁₅ : let fs = L.[ quote +-comm ] in
kompile test-15f fs fs ≡ ok _
test₁₅ = refl
module absurd-patterns where
test-16f : ∀ {n} → Fin n → Fin n
test-16f {0} ()
test-16f {suc n} i = i
test₁₆ : kompile test-16f [] [] ≡ ok _
test₁₆ = refl
-- Ugh, when we found an absurd pattern, the rest of the
-- patterns may or may not be present (which seem to make no sense).
-- If they are present, then other (missing) constructors are inserted
-- automatically. Therefore, extracted code for the function below
-- would look rather scary.
test-17f : ∀ {n} → Fin (n ∸ 1) → ℕ → ℕ → Fin n
test-17f {0} () (suc (suc k))
test-17f {1} ()
test-17f {suc (suc n)} i m mm = zero
test₁₇ : kompile test-17f [] [] ≡ ok _
test₁₇ = refl
-- Dot patterns
test-18f : ∀ m n → m ≡ n → Fin (suc m)
test-18f zero .zero refl = zero
test-18f (suc m) .(suc m) refl = suc (test-18f m m refl)
test₁₈ : kompile test-18f [] [] ≡ ok _
test₁₈ = refl
-- Increment the first column of the 2-d array expressed in vectors
test-19f : ∀ {m n} → Vec (Vec ℕ n) m → Vec (Vec ℕ n) m
test-19f [] = []
test-19f ([] ∷ xss) = [] ∷ test-19f xss
test-19f ((x ∷ xs) ∷ xss) = (x + 1 ∷ xs) ∷ test-19f xss
test₁₉ : kompile test-19f [] [] ≡ ok _
test₁₉ = refl
| {
"alphanum_fraction": 0.6040816327,
"avg_line_length": 27.2222222222,
"ext": "agda",
"hexsha": "495d7e6ded1cf70394d77d938b1efe022c6cccde",
"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": "c8954c8acd8089ced82af9e05084fbbc7fedb36c",
"max_forks_repo_licenses": [
"0BSD"
],
"max_forks_repo_name": "ashinkarov/agda-extractor",
"max_forks_repo_path": "Example-01.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c8954c8acd8089ced82af9e05084fbbc7fedb36c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"0BSD"
],
"max_issues_repo_name": "ashinkarov/agda-extractor",
"max_issues_repo_path": "Example-01.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "c8954c8acd8089ced82af9e05084fbbc7fedb36c",
"max_stars_repo_licenses": [
"0BSD"
],
"max_stars_repo_name": "ashinkarov/agda-extractor",
"max_stars_repo_path": "Example-01.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-11T14:52:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-01-11T14:52:59.000Z",
"num_tokens": 825,
"size": 2205
} |
{-# OPTIONS --without-K #-}
-- Specific constructions on top of summation functions
module Explore.Summable where
open import Type
open import Function.NP
import Relation.Binary.PropositionalEquality.NP as ≡
open ≡ using (_≡_ ; _≗_ ; _≗₂_)
open import Explore.Core
open import Explore.Properties
open import Explore.Product
open import Data.Product
open import Data.Nat.NP
open import Data.Nat.Properties
open import Data.Two
open Data.Two.Indexed
module FromSum {a} {A : ★_ a} (sum : Sum A) where
Card : ℕ
Card = sum (const 1)
count : Count A
count f = sum (𝟚▹ℕ ∘ f)
sum-lin⇒sum-zero : SumLin sum → SumZero sum
sum-lin⇒sum-zero sum-lin = sum-lin (λ _ → 0) 0
sum-mono⇒sum-ext : SumMono sum → SumExt sum
sum-mono⇒sum-ext sum-mono f≗g = ℕ≤.antisym (sum-mono (ℕ≤.reflexive ∘ f≗g)) (sum-mono (ℕ≤.reflexive ∘ ≡.sym ∘ f≗g))
sum-ext+sum-hom⇒sum-mono : SumExt sum → SumHom sum → SumMono sum
sum-ext+sum-hom⇒sum-mono sum-ext sum-hom {f} {g} f≤°g =
sum f ≤⟨ m≤m+n _ _ ⟩
sum f + sum (λ x → g x ∸ f x) ≡⟨ ≡.sym (sum-hom _ _) ⟩
sum (λ x → f x + (g x ∸ f x)) ≡⟨ sum-ext (m+n∸m≡n ∘ f≤°g) ⟩
sum g ∎ where open ≤-Reasoning
module FromSumInd {a} {A : ★_ a}
{sum : Sum A}
(sum-ind : SumInd sum) where
open FromSum sum public
sum-ext : SumExt sum
sum-ext = sum-ind (λ s → s _ ≡ s _) ≡.refl (≡.ap₂ _+_)
sum-zero : SumZero sum
sum-zero = sum-ind (λ s → s (const 0) ≡ 0) ≡.refl (≡.ap₂ _+_) (λ _ → ≡.refl)
sum-hom : SumHom sum
sum-hom f g = sum-ind (λ s → s (f +° g) ≡ s f + s g)
≡.refl
(λ {s₀} {s₁} p₀ p₁ → ≡.trans (≡.ap₂ _+_ p₀ p₁) (+-interchange (s₀ _) (s₀ _) _ _))
(λ _ → ≡.refl)
sum-mono : SumMono sum
sum-mono = sum-ind (λ s → s _ ≤ s _) z≤n _+-mono_
sum-lin : SumLin sum
sum-lin f zero = sum-zero
sum-lin f (suc k) = ≡.trans (sum-hom f (λ x → k * f x)) (≡.ap₂ _+_ (≡.refl {x = sum f}) (sum-lin f k))
module _ (f g : A → ℕ) where
open ≡.≡-Reasoning
sum-⊓-∸ : sum f ≡ sum (f ⊓° g) + sum (f ∸° g)
sum-⊓-∸ = sum f ≡⟨ sum-ext (f ⟨ a≡a⊓b+a∸b ⟩° g) ⟩
sum ((f ⊓° g) +° (f ∸° g)) ≡⟨ sum-hom (f ⊓° g) (f ∸° g) ⟩
sum (f ⊓° g) + sum (f ∸° g) ∎
sum-⊔-⊓ : sum f + sum g ≡ sum (f ⊔° g) + sum (f ⊓° g)
sum-⊔-⊓ = sum f + sum g ≡⟨ ≡.sym (sum-hom f g) ⟩
sum (f +° g) ≡⟨ sum-ext (f ⟨ a+b≡a⊔b+a⊓b ⟩° g) ⟩
sum (f ⊔° g +° f ⊓° g) ≡⟨ sum-hom (f ⊔° g) (f ⊓° g) ⟩
sum (f ⊔° g) + sum (f ⊓° g) ∎
sum-⊔ : sum (f ⊔° g) ≤ sum f + sum g
sum-⊔ = ℕ≤.trans (sum-mono (f ⟨ ⊔≤+ ⟩° g)) (ℕ≤.reflexive (sum-hom f g))
count-ext : CountExt count
count-ext f≗g = sum-ext (≡.cong 𝟚▹ℕ ∘ f≗g)
sum-const : ∀ k → sum (const k) ≡ Card * k
sum-const k
rewrite ℕ°.*-comm Card k
| ≡.sym (sum-lin (const 1) k)
| proj₂ ℕ°.*-identity k = ≡.refl
module _ f g where
count-∧-not : count f ≡ count (f ∧° g) + count (f ∧° not° g)
count-∧-not rewrite sum-⊓-∸ (𝟚▹ℕ ∘ f) (𝟚▹ℕ ∘ g)
| sum-ext (f ⟨ 𝟚▹ℕ-⊓ ⟩° g)
| sum-ext (f ⟨ 𝟚▹ℕ-∸ ⟩° g)
= ≡.refl
count-∨-∧ : count f + count g ≡ count (f ∨° g) + count (f ∧° g)
count-∨-∧ rewrite sum-⊔-⊓ (𝟚▹ℕ ∘ f) (𝟚▹ℕ ∘ g)
| sum-ext (f ⟨ 𝟚▹ℕ-⊔ ⟩° g)
| sum-ext (f ⟨ 𝟚▹ℕ-⊓ ⟩° g)
= ≡.refl
count-∨≤+ : count (f ∨° g) ≤ count f + count g
count-∨≤+ = ℕ≤.trans (ℕ≤.reflexive (sum-ext (≡.sym ∘ (f ⟨ 𝟚▹ℕ-⊔ ⟩° g))))
(sum-⊔ (𝟚▹ℕ ∘ f) (𝟚▹ℕ ∘ g))
module FromSum×
{a} {A : Set a}
{b} {B : Set b}
{sumᴬ : Sum A}
(sum-indᴬ : SumInd sumᴬ)
{sumᴮ : Sum B}
(sum-indᴮ : SumInd sumᴮ) where
module |A| = FromSumInd sum-indᴬ
module |B| = FromSumInd sum-indᴮ
open Operators
sumᴬᴮ = sumᴬ ×ˢ sumᴮ
sum-∘proj₁≡Card* : ∀ f → sumᴬᴮ (f ∘ proj₁) ≡ |B|.Card * sumᴬ f
sum-∘proj₁≡Card* f
rewrite |A|.sum-ext (|B|.sum-const ∘ f)
= |A|.sum-lin f |B|.Card
sum-∘proj₂≡Card* : ∀ f → sumᴬᴮ (f ∘ proj₂) ≡ |A|.Card * sumᴮ f
sum-∘proj₂≡Card* = |A|.sum-const ∘ sumᴮ
sum-∘proj₁ : ∀ {f} {g} → sumᴬ f ≡ sumᴬ g → sumᴬᴮ (f ∘ proj₁) ≡ sumᴬᴮ (g ∘ proj₁)
sum-∘proj₁ {f} {g} sumf≡sumg
rewrite sum-∘proj₁≡Card* f
| sum-∘proj₁≡Card* g
| sumf≡sumg = ≡.refl
sum-∘proj₂ : ∀ {f} {g} → sumᴮ f ≡ sumᴮ g → sumᴬᴮ (f ∘ proj₂) ≡ sumᴬᴮ (g ∘ proj₂)
sum-∘proj₂ sumf≡sumg = |A|.sum-ext (const sumf≡sumg)
-- -}
-- -}
-- -}
-- -}
| {
"alphanum_fraction": 0.475177305,
"avg_line_length": 33,
"ext": "agda",
"hexsha": "99196d164ca9c647ca2a2d4fce35ff4784f84f75",
"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": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "crypto-agda/explore",
"max_forks_repo_path": "lib/Explore/Summable.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_issues_repo_issues_event_max_datetime": "2019-03-16T14:24:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-03-16T14:24:04.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "crypto-agda/explore",
"max_issues_repo_path": "lib/Explore/Summable.agda",
"max_line_length": 116,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "16bc8333503ff9c00d47d56f4ec6113b9269a43e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "crypto-agda/explore",
"max_stars_repo_path": "lib/Explore/Summable.agda",
"max_stars_repo_stars_event_max_datetime": "2017-06-28T19:19:29.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-05T09:25:32.000Z",
"num_tokens": 2191,
"size": 4653
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- The lifting of a non-strict order to incorporate new extrema
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
-- This module is designed to be used with
-- Relation.Nullary.Construct.Add.Extrema
open import Relation.Binary
module Relation.Binary.Construct.Add.Extrema.NonStrict
{a ℓ} {A : Set a} (_≤_ : Rel A ℓ) where
open import Function
open import Relation.Nullary.Construct.Add.Extrema
import Relation.Nullary.Construct.Add.Infimum as I
import Relation.Binary.Construct.Add.Infimum.NonStrict as AddInfimum
import Relation.Binary.Construct.Add.Supremum.NonStrict as AddSupremum
import Relation.Binary.Construct.Add.Extrema.Equality as Equality
-------------------------------------------------------------------------
-- Definition
private
module Inf = AddInfimum _≤_
module Sup = AddSupremum Inf._≤₋_
open Sup using () renaming (_≤⁺_ to _≤±_) public
-------------------------------------------------------------------------
-- Useful pattern synonyms
pattern ⊥±≤⊥± = Sup.[ Inf.⊥₋≤ I.⊥₋ ]
pattern ⊥±≤[_] l = Sup.[ Inf.⊥₋≤ I.[ l ] ]
pattern [_] p = Sup.[ Inf.[ p ] ]
pattern ⊥±≤⊤± = ⊥± Sup.≤⊤⁺
pattern [_]≤⊤± k = [ k ] Sup.≤⊤⁺
pattern ⊤±≤⊤± = ⊤± Sup.≤⊤⁺
⊥±≤_ : ∀ k → ⊥± ≤± k
⊥±≤ ⊥± = ⊥±≤⊥±
⊥±≤ [ k ] = ⊥±≤[ k ]
⊥±≤ ⊤± = ⊥±≤⊤±
_≤⊤± : ∀ k → k ≤± ⊤±
⊥± ≤⊤± = ⊥±≤⊤±
[ k ] ≤⊤± = [ k ]≤⊤±
⊤± ≤⊤± = ⊤±≤⊤±
-------------------------------------------------------------------------
-- Relational properties
[≤]-injective : ∀ {k l} → [ k ] ≤± [ l ] → k ≤ l
[≤]-injective = Inf.[≤]-injective ∘′ Sup.[≤]-injective
module _ {e} {_≈_ : Rel A e} where
open Equality _≈_
≤±-reflexive : (_≈_ ⇒ _≤_) → (_≈±_ ⇒ _≤±_)
≤±-reflexive = Sup.≤⁺-reflexive ∘′ Inf.≤₋-reflexive
≤±-antisym : Antisymmetric _≈_ _≤_ → Antisymmetric _≈±_ _≤±_
≤±-antisym = Sup.≤⁺-antisym ∘′ Inf.≤₋-antisym
≤±-trans : Transitive _≤_ → Transitive _≤±_
≤±-trans = Sup.≤⁺-trans ∘′ Inf.≤₋-trans
≤±-minimum : Minimum _≤±_ ⊥±
≤±-minimum = ⊥±≤_
≤±-maximum : Maximum _≤±_ ⊤±
≤±-maximum = _≤⊤±
≤±-dec : Decidable _≤_ → Decidable _≤±_
≤±-dec = Sup.≤⁺-dec ∘′ Inf.≤₋-dec
≤±-total : Total _≤_ → Total _≤±_
≤±-total = Sup.≤⁺-total ∘′ Inf.≤₋-total
≤±-irrelevant : Irrelevant _≤_ → Irrelevant _≤±_
≤±-irrelevant = Sup.≤⁺-irrelevant ∘′ Inf.≤₋-irrelevant
-------------------------------------------------------------------------
-- Structures
module _ {e} {_≈_ : Rel A e} where
open Equality _≈_
≤±-isPreorder : IsPreorder _≈_ _≤_ → IsPreorder _≈±_ _≤±_
≤±-isPreorder = Sup.≤⁺-isPreorder ∘′ Inf.≤₋-isPreorder
≤±-isPartialOrder : IsPartialOrder _≈_ _≤_ → IsPartialOrder _≈±_ _≤±_
≤±-isPartialOrder = Sup.≤⁺-isPartialOrder ∘′ Inf.≤₋-isPartialOrder
≤±-isDecPartialOrder : IsDecPartialOrder _≈_ _≤_ → IsDecPartialOrder _≈±_ _≤±_
≤±-isDecPartialOrder = Sup.≤⁺-isDecPartialOrder ∘′ Inf.≤₋-isDecPartialOrder
≤±-isTotalOrder : IsTotalOrder _≈_ _≤_ → IsTotalOrder _≈±_ _≤±_
≤±-isTotalOrder = Sup.≤⁺-isTotalOrder ∘′ Inf.≤₋-isTotalOrder
≤±-isDecTotalOrder : IsDecTotalOrder _≈_ _≤_ → IsDecTotalOrder _≈±_ _≤±_
≤±-isDecTotalOrder = Sup.≤⁺-isDecTotalOrder ∘′ Inf.≤₋-isDecTotalOrder
| {
"alphanum_fraction": 0.528602019,
"avg_line_length": 30.2685185185,
"ext": "agda",
"hexsha": "57a2666df3bfcb6603e155c3eeabf2489f01d84f",
"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/Relation/Binary/Construct/Add/Extrema/NonStrict.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/Binary/Construct/Add/Extrema/NonStrict.agda",
"max_line_length": 80,
"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/Relation/Binary/Construct/Add/Extrema/NonStrict.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1345,
"size": 3269
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
module Categories.Functor.Construction.SubCategory.Properties {o ℓ e} (C : Category o ℓ e) where
open Category C
open Equiv
open import Level
open import Function.Base using () renaming (id to id→)
open import Function.Surjection using (Surjection) renaming (id to id↠)
open import Categories.Category.SubCategory C
open import Categories.Functor.Construction.SubCategory C
open import Categories.Functor.Properties
private
variable
ℓ′ i : Level
I : Set i
U : I → Obj
SubFaithful : ∀ (sub : SubCat {i} {ℓ′} I) → Faithful (Sub sub)
SubFaithful _ _ _ = id→
FullSubFaithful : Faithful (FullSub {U = U})
FullSubFaithful _ _ = id→
FullSubFull : Full (FullSub {U = U})
FullSubFull = Surjection.surjective id↠
| {
"alphanum_fraction": 0.7246558198,
"avg_line_length": 24.96875,
"ext": "agda",
"hexsha": "2a1f292cc0db489a47685893fbeaba7501d4b1cb",
"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/Functor/Construction/SubCategory/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/Functor/Construction/SubCategory/Properties.agda",
"max_line_length": 96,
"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/Functor/Construction/SubCategory/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": 231,
"size": 799
} |
-- The simpler case of index inductive definitions. (no induction-recursion)
module IID where
open import LF
-- A code for an IID
-- I - index set
-- E = I for general IIDs
-- E = One for restricted IIDs
data OP (I : Set)(E : Set) : Set1 where
ι : E -> OP I E
σ : (A : Set)(γ : A -> OP I E) -> OP I E
δ : (A : Set)(i : A -> I)(γ : OP I E) -> OP I E
-- The type of constructor arguments. Parameterised over
-- U - the inductive type
-- This is the F of the simple polynomial type μF
Args : {I : Set}{E : Set} -> OP I E ->
(U : I -> Set) -> Set
Args (ι e) U = One
Args (σ A γ) U = A × \a -> Args (γ a) U
Args (δ A i γ) U = ((a : A) -> U (i a)) × \_ -> Args γ U
-- Computing the index
index : {I : Set}{E : Set}(γ : OP I E)(U : I -> Set) -> Args γ U -> E
index (ι e) U _ = e
index (σ A γ) U a = index (γ (π₀ a)) U (π₁ a)
index (δ A i γ) U a = index γ U (π₁ a)
-- The assumptions of a particular inductive occurrence in a value.
IndArg : {I : Set}{E : Set}
(γ : OP I E)(U : I -> Set) ->
Args γ U -> Set
IndArg (ι e) U _ = Zero
IndArg (σ A γ) U a = IndArg (γ (π₀ a)) U (π₁ a)
IndArg (δ A i γ) U a = A + IndArg γ U (π₁ a)
-- Given the assumptions of an inductive occurence in a value we can compute
-- its index.
IndIndex : {I : Set}{E : Set}
(γ : OP I E)(U : I -> Set) ->
(a : Args γ U) -> IndArg γ U a -> I
IndIndex (ι e) U _ ()
IndIndex (σ A γ) U arg c = IndIndex (γ (π₀ arg)) U (π₁ arg) c
IndIndex (δ A i γ) U arg (inl a) = i a
IndIndex (δ A i γ) U arg (inr a) = IndIndex γ U (π₁ arg) a
-- Given the assumptions of an inductive occurrence in a value we can compute
-- its value.
Ind : {I : Set}{E : Set}
(γ : OP I E)(U : I -> Set) ->
(a : Args γ U)(v : IndArg γ U a) -> U (IndIndex γ U a v)
Ind (ι e) U _ ()
Ind (σ A γ) U arg c = Ind (γ (π₀ arg)) U (π₁ arg) c
Ind (δ A i γ) U arg (inl a) = (π₀ arg) a
Ind (δ A i γ) U arg (inr a) = Ind γ U (π₁ arg) a
-- The type of induction hypotheses. Basically
-- forall assumptions, the predicate holds for an inductive occurrence with
-- those assumptions
IndHyp : {I : Set}{E : Set}
(γ : OP I E)(U : I -> Set) ->
(F : (i : I) -> U i -> Set)(a : Args γ U) -> Set
IndHyp γ U F a = (v : IndArg γ U a) -> F (IndIndex γ U a v) (Ind γ U a v)
IndHyp₁ : {I : Set}{E : Set}
(γ : OP I E)(U : I -> Set) ->
(F : (i : I) -> U i -> Set1)(a : Args γ U) -> Set1
IndHyp₁ γ U F a = (v : IndArg γ U a) -> F (IndIndex γ U a v) (Ind γ U a v)
-- If we can prove a predicate F for any values, we can construct the inductive
-- hypotheses for a given value.
-- Termination note: g will only be applied to values smaller than a
induction :
{I : Set}{E : Set}
(γ : OP I E)(U : I -> Set)
(F : (i : I) -> U i -> Set)
(g : (i : I)(u : U i) -> F i u)
(a : Args γ U) -> IndHyp γ U F a
induction γ U F g a = \hyp -> g (IndIndex γ U a hyp) (Ind γ U a hyp)
induction₁ :
{I : Set}{E : Set}
(γ : OP I E)(U : I -> Set)
(F : (i : I) -> U i -> Set1)
(g : (i : I)(u : U i) -> F i u)
(a : Args γ U) -> IndHyp₁ γ U F a
induction₁ γ U F g a = \hyp -> g (IndIndex γ U a hyp) (Ind γ U a hyp)
| {
"alphanum_fraction": 0.5324881141,
"avg_line_length": 34.6703296703,
"ext": "agda",
"hexsha": "0e11ca6abdd9f2076214feeb5e3c88ae1064f8a9",
"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/outdated-and-incorrect/iird/IID.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/outdated-and-incorrect/iird/IID.agda",
"max_line_length": 79,
"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/outdated-and-incorrect/iird/IID.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": 1212,
"size": 3155
} |
module start where
open import Relation.Binary.PropositionalEquality
open import Data.Product
open import Function hiding (id)
injective : {A B : Set} → (f : A → B) → Set
injective f = ∀ a₁ a₂ → f a₁ ≡ f a₂ → a₁ ≡ a₂
surjective : {A B : Set} → (f : A → B) → Set
surjective f = ∀ b → ∃ (λ a → f a ≡ b)
bijective : {A B : Set} → (f : A → B) → Set
bijective f = injective f × surjective f
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
lemma-suc-inj : ∀ {a₁ a₂} → suc a₁ ≡ suc a₂ → a₁ ≡ a₂
lemma-suc-inj refl = refl
suc-injective : injective suc
suc-injective a₁ a₂ = lemma-suc-inj
id : {A : Set} → A → A
id x = x
lemma-id-inj : ∀ {A} {a₁ a₂ : A} → id a₁ ≡ id a₂ → a₁ ≡ a₂
lemma-id-inj refl = refl
id-injective : ∀ {A} → injective (id {A})
id-injective a₁ a₂ = lemma-id-inj
lemma-id-surj : ∀ {A} (b : A) → ∃ (λ a → id a ≡ b)
lemma-id-surj b = b , refl
id-surjective : ∀ {A} → surjective (id {A})
id-surjective = lemma-id-surj
bijective→injective : ∀ {A B} {f : A → B} → bijective f → injective f
bijective→injective b = proj₁ b
bijective→surjective : ∀ {A B} {f : A → B} → bijective f → surjective f
bijective→surjective b = proj₂ b
left-inverse : ∀ {A B} → (f : A → B) → Set
left-inverse f = ∃ (λ g → g ∘ f ≡ id)
right-inverse : ∀ {A B} → (f : A → B) → Set
right-inverse f = ∃ (λ g → f ∘ g ≡ id)
infix 5 _s~_
_s~_ : {A : Set} {a b c : A} → a ≡ b → a ≡ c → c ≡ b
_s~_ refl refl = refl
infix 5 _~_
_~_ : {A : Set} {a b c : A} → a ≡ b → b ≡ c → a ≡ c
_~_ = trans
lemma-left-id₁ : ∀ {A B : Set} (g : B → A) (f : A → B) → g ∘ f ≡ id → (∀ a → g (f a) ≡ a)
lemma-left-id₁ g f idcomp a = cong (λ f₁ → f₁ a) idcomp
lemma-left-id : ∀ {A B : Set} (a₁ a₂ : A) (g : B → A) (f : A → B) → g ∘ f ≡ id → g (f a₁) ≡ g (f a₂) → a₁ ≡ a₂
lemma-left-id a₁ a₂ g f idcomp comp = (comp ~ lemma-left-id₁ g f idcomp a₂) s~ lemma-left-id₁ g f idcomp a₁
lemma-left-inj : ∀ {A B : Set} (a₁ a₂ : A) → (f : A → B) → ∃ (λ g → g ∘ f ≡ id) → f a₁ ≡ f a₂ → a₁ ≡ a₂
lemma-left-inj a₁ a₂ f (g , idcomp) eq = lemma-left-id a₁ a₂ g f idcomp (cong (λ x → g x) eq)
left-inverse→injective : ∀ {A B} (f : A → B) → left-inverse f → injective f
left-inverse→injective f left-inv a₁ a₂ fas = lemma-left-inj a₁ a₂ f left-inv fas
right-inverse→surjective : ∀ {A B} (f : A → B) → right-inverse f → surjective f
right-inverse→surjective f (g , right) b = g b , cong (λ f₁ → f₁ b) right
postulate extensionality : {A : Set} {B : Set} {f g : A → B} → (∀ x → f x ≡ g x) → f ≡ g
id-unique : ∀ {A : Set} → (f : A → A) → (∀ a → f a ≡ a) → f ≡ id
id-unique f fa-prop = extensionality {f = f} {g = id} fa-prop
surjective→right-inverse : ∀ {A B} (f : A → B) → surjective f → right-inverse f
surjective→right-inverse f right = g , id-unique (f ∘ g) (λ b → proj₂ (right b))
where g = λ b → proj₁ (right b)
| {
"alphanum_fraction": 0.5636036036,
"avg_line_length": 30.1630434783,
"ext": "agda",
"hexsha": "c271b13ce3f16eb560ab939047f32cd8ab78ed67",
"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": "a5f046cd37c7c2abb5d287c7d7572f3e84dceb96",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Chobbes/AbstractAgdabra",
"max_forks_repo_path": "start.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a5f046cd37c7c2abb5d287c7d7572f3e84dceb96",
"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": "Chobbes/AbstractAgdabra",
"max_issues_repo_path": "start.agda",
"max_line_length": 110,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a5f046cd37c7c2abb5d287c7d7572f3e84dceb96",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Chobbes/AbstractAgdabra",
"max_stars_repo_path": "start.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1167,
"size": 2775
} |
module DataDef where
data ⊤
: Set
where
tt
: ⊤
data ⊤'
(x : ⊤)
: Set
where
tt
: ⊤' x
data D
{y : ⊤}
(y' : ⊤' y)
: Set
data D {z} _ where
postulate
d
: D {tt} tt
| {
"alphanum_fraction": 0.4215686275,
"avg_line_length": 6.8,
"ext": "agda",
"hexsha": "3c0b4066df819a749f52fd4de51a293867d176ae",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-01T16:38:14.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-01T16:38:14.000Z",
"max_forks_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "msuperdock/agda-unused",
"max_forks_repo_path": "data/declaration/DataDef.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9",
"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": "msuperdock/agda-unused",
"max_issues_repo_path": "data/declaration/DataDef.agda",
"max_line_length": 20,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "msuperdock/agda-unused",
"max_stars_repo_path": "data/declaration/DataDef.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-01T16:38:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-29T09:38:43.000Z",
"num_tokens": 98,
"size": 204
} |
{-# OPTIONS --without-K --safe #-}
module Dodo.Unary.Unique where
-- Stdlib imports
open import Level using (Level)
open import Relation.Unary using (Pred)
open import Relation.Binary using (Rel)
-- Local imports
open import Dodo.Nullary.Unique
-- # Definitions #
-- | At most one element satisfies the predicate
Unique₁ : ∀ {a ℓ₁ ℓ₂ : Level} {A : Set a}
→ Rel A ℓ₁ → Pred A ℓ₂ → Set _
Unique₁ _≈_ P = ∀ {x y} → P x → P y → x ≈ y
-- | For every `x`, there exists at most one inhabitant of `P x`.
UniquePred : ∀ {a ℓ : Level} {A : Set a}
→ Pred A ℓ → Set _
UniquePred P = ∀ x → Unique (P x)
| {
"alphanum_fraction": 0.6433333333,
"avg_line_length": 25,
"ext": "agda",
"hexsha": "21416802f97d42f092e6f877fc67ea78d96c19af",
"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": "376f0ccee1e1aa31470890e494bcb534324f598a",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "sourcedennis/agda-dodo",
"max_forks_repo_path": "src/Dodo/Unary/Unique.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a",
"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": "sourcedennis/agda-dodo",
"max_issues_repo_path": "src/Dodo/Unary/Unique.agda",
"max_line_length": 65,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "sourcedennis/agda-dodo",
"max_stars_repo_path": "src/Dodo/Unary/Unique.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 190,
"size": 600
} |
-- Minimal implicational modal logic, de Bruijn approach, initial encoding
module Bi.BoxMp where
open import Lib using (List; []; _,_; LMem; lzero; lsuc)
-- Types
infixr 0 _=>_
data Ty : Set where
UNIT : Ty
_=>_ : Ty -> Ty -> Ty
BOX : Ty -> Ty
-- Context and truth/validity judgements
Cx : Set
Cx = List Ty
isTrue : Ty -> Cx -> Set
isTrue a tc = LMem a tc
isValid : Ty -> Cx -> Set
isValid a vc = LMem a vc
-- Terms
module BoxMp where
infixl 1 _$_
infixr 0 lam=>_
data Tm (vc tc : Cx) : Ty -> Set where
var : forall {a} -> isTrue a tc -> Tm vc tc a
lam=>_ : forall {a b} -> Tm vc (tc , a) b -> Tm vc tc (a => b)
_$_ : forall {a b} -> Tm vc tc (a => b) -> Tm vc tc a -> Tm vc tc b
var# : forall {a} -> isValid a vc -> Tm vc tc a
box : forall {a} -> Tm vc [] a -> Tm vc tc (BOX a)
unbox' : forall {a b} -> Tm vc tc (BOX a) -> Tm (vc , a) tc b -> Tm vc tc b
syntax unbox' x' x = unbox x' => x
v0 : forall {vc tc a} -> Tm vc (tc , a) a
v0 = var lzero
v1 : forall {vc tc a b} -> Tm vc (tc , a , b) a
v1 = var (lsuc lzero)
v2 : forall {vc tc a b c} -> Tm vc (tc , a , b , c) a
v2 = var (lsuc (lsuc lzero))
v0# : forall {vc tc a} -> Tm (vc , a) tc a
v0# = var# lzero
v1# : forall {vc tc a b} -> Tm (vc , a , b) tc a
v1# = var# (lsuc lzero)
v2# : forall {vc tc a b c} -> Tm (vc , a , b , c) tc a
v2# = var# (lsuc (lsuc lzero))
Thm : Ty -> Set
Thm a = forall {vc tc} -> Tm vc tc a
open BoxMp public
-- Example theorems
rNec : forall {a} -> Thm a -> Thm (BOX a)
rNec x =
box x
aK : forall {a b} -> Thm (BOX (a => b) => BOX a => BOX b)
aK =
lam=>
lam=>
(unbox v1 =>
unbox v0 =>
box (v1# $ v0#))
aT : forall {a} -> Thm (BOX a => a)
aT =
lam=>
(unbox v0 => v0#)
a4 : forall {a} -> Thm (BOX a => BOX (BOX a))
a4 =
lam=>
(unbox v0 => box (box v0#))
t1 : forall {a} -> Thm (a => BOX (a => a))
t1 =
lam=> box (lam=> v0)
| {
"alphanum_fraction": 0.4875912409,
"avg_line_length": 21.8617021277,
"ext": "agda",
"hexsha": "dc2928fee3f2c57256a46b24f9eb4fc51a369d01",
"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": "2dd761bfa96ccda089888e8defa6814776fa2922",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/formal-logic",
"max_forks_repo_path": "src/Bi/BoxMp.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/formal-logic",
"max_issues_repo_path": "src/Bi/BoxMp.agda",
"max_line_length": 81,
"max_stars_count": 26,
"max_stars_repo_head_hexsha": "2dd761bfa96ccda089888e8defa6814776fa2922",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/formal-logic",
"max_stars_repo_path": "src/Bi/BoxMp.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-13T12:37:44.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-31T09:49:52.000Z",
"num_tokens": 817,
"size": 2055
} |
{-# OPTIONS --without-K #-}
module PiU where
open import Data.Nat using (ℕ; _+_; _*_)
------------------------------------------------------------------------------
-- Define the ``universe'' for Pi. All versions of Pi share the same
-- universe. Where they differ is in what combinators exist between
-- members of the universe.
--
-- ZERO is a type with no elements
-- ONE is a type with one element 'tt'
-- PLUS ONE ONE is a type with elements 'false' and 'true'
-- and so on for all finite types built from ZERO, ONE, PLUS, and TIMES
--
-- We also have that U is a type with elements ZERO, ONE, PLUS ONE ONE,
-- TIMES BOOL BOOL, etc.
data U : Set where
ZERO : U
ONE : U
PLUS : U → U → U
TIMES : U → U → U
-- defines the size of a finite type
toℕ : U → ℕ
toℕ ZERO = 0
toℕ ONE = 1
toℕ (PLUS t₁ t₂) = toℕ t₁ + toℕ t₂
toℕ (TIMES t₁ t₂) = toℕ t₁ * toℕ t₂
------------------------------------------------------------------------------
| {
"alphanum_fraction": 0.5385416667,
"avg_line_length": 27.4285714286,
"ext": "agda",
"hexsha": "be9347e352f0e8fbdd5cb8e12a514008ccbd3e76",
"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/PiU.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/PiU.agda",
"max_line_length": 78,
"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/PiU.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": 275,
"size": 960
} |
module Using where
module Dummy where
data DummySet1 : Set where ds1 : DummySet1
data DummySet2 : Set where ds2 : DummySet2
open Dummy
using (DummySet1)
open Dummy -- checking that newline + comment is allowed before "using"
using (DummySet2)
-- Andreas, 2020-06-06, issue #4704
-- Allow repetions in `using` directives, but emit warning.
open Dummy
using (DummySet1; DummySet1)
using (DummySet1)
-- EXPECTED: dead code highlighting for 2nd and 3rd occurrence and warning:
-- Duplicates in using directive: DummySet1 DummySet1
-- when scope checking the declaration
-- open Dummy using (DummySet1; DummySet1; DummySet1)
| {
"alphanum_fraction": 0.7527386541,
"avg_line_length": 27.7826086957,
"ext": "agda",
"hexsha": "0d65a7dff4b5863c262174378cbdf2afeaf1ae5b",
"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/Using.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/Using.agda",
"max_line_length": 75,
"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/Using.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": 178,
"size": 639
} |
{-# OPTIONS --without-K --safe #-}
module Data.Binary.Conversion where
open import Data.Binary.Definition
open import Data.Binary.Increment
import Data.Nat as ℕ
open import Data.Nat using (ℕ; suc; zero)
⟦_⇑⟧ : ℕ → 𝔹
⟦ zero ⇑⟧ = 0ᵇ
⟦ suc n ⇑⟧ = inc ⟦ n ⇑⟧
⟦_⇓⟧ : 𝔹 → ℕ
⟦ 0ᵇ ⇓⟧ = 0
⟦ 1ᵇ xs ⇓⟧ = 1 ℕ.+ ⟦ xs ⇓⟧ ℕ.* 2
⟦ 2ᵇ xs ⇓⟧ = 2 ℕ.+ ⟦ xs ⇓⟧ ℕ.* 2
| {
"alphanum_fraction": 0.5641025641,
"avg_line_length": 19.5,
"ext": "agda",
"hexsha": "dd1983c8831af6b6588eaef5132b36dff108c419",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-playground",
"max_forks_repo_path": "Data/Binary/Conversion.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"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/agda-playground",
"max_issues_repo_path": "Data/Binary/Conversion.agda",
"max_line_length": 41,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-playground",
"max_stars_repo_path": "Data/Binary/Conversion.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z",
"num_tokens": 186,
"size": 351
} |
{-# OPTIONS --warning=error #-}
module AbstractModuleMacro where
import Common.Issue481ParametrizedModule as P
abstract
module M = P Set
| {
"alphanum_fraction": 0.7676056338,
"avg_line_length": 15.7777777778,
"ext": "agda",
"hexsha": "88e03a2cd754afccd50004418994ef05a2fba969",
"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/AbstractModuleMacro.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/AbstractModuleMacro.agda",
"max_line_length": 45,
"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/AbstractModuleMacro.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": 34,
"size": 142
} |
{-# OPTIONS --postfix-projections #-}
{-# OPTIONS --allow-unsolved-metas #-}
module StateSizedIO.writingOOsUsingIOVers4ReaderMethods where
open import StateSizedIO.RObject
open import StateSizedIO.Object
open import StateSizedIO.Base
open import Data.Product
open import Data.Nat
open import Data.Fin
open import Data.Bool
open import Function
open import Data.Unit
open import Data.String
open import Unit
open import Data.Bool.Base
open import Relation.Binary.PropositionalEquality
open import SizedIO.Console
open import Size
open import SizedIO.Base
open import Data.Sum
open import Data.Empty
-- ### new imports
--
open import StateSizedIO.cellStateDependent using (CellInterfaceˢ; empty; cellPempty')
open import NativeIO
objectInterfToIOInterfˢ : RInterfaceˢ → IOInterfaceˢ
objectInterfToIOInterfˢ I .IOStateˢ = I .Stateˢ
objectInterfToIOInterfˢ I .Commandˢ s = I .Methodˢ s ⊎ I .RMethodˢ s
objectInterfToIOInterfˢ I .Responseˢ s (inj₁ c) = I .Resultˢ s c
objectInterfToIOInterfˢ I .Responseˢ s (inj₂ c) = I .RResultˢ s c -- I .Resultˢ
objectInterfToIOInterfˢ I .IOnextˢ s (inj₁ c) r = I .nextˢ s c r
objectInterfToIOInterfˢ I .IOnextˢ s (inj₂ c) r = s -- I .nextˢ
ioInterfToObjectInterfˢ : IOInterfaceˢ → RInterfaceˢ
ioInterfToObjectInterfˢ I .Stateˢ = I .IOStateˢ
ioInterfToObjectInterfˢ I .Methodˢ = I .Commandˢ
ioInterfToObjectInterfˢ I .Resultˢ = I .Responseˢ --
ioInterfToObjectInterfˢ I .nextˢ = I .IOnextˢ
ioInterfToObjectInterfˢ I .RMethodˢ s = ⊥
ioInterfToObjectInterfˢ I .RResultˢ s ()
data DecSets : Set where
fin : ℕ → DecSets
TDecSets : DecSets → Set
TDecSets (fin n) = Fin n
toDecSets : ∀{n} → (x : Fin n) → DecSets
toDecSets x = fin (toℕ x)
_==fin_ : {n : ℕ} → Fin n → Fin n → Bool
_==fin_ {zero} () t
_==fin_ {suc _} zero zero = true
_==fin_ {suc _} zero (suc _) = false
_==fin_ {suc _} (suc _) zero = false
_==fin_ {suc _} (suc s) (suc t) = s ==fin t
transferFin : {n : ℕ} → (P : Fin n → Set) →
(i j : Fin n) → T (i ==fin j) →
P i → P j
transferFin {zero} P () j q p
transferFin {suc n} P zero zero q p = p
transferFin {suc n} P zero (suc j) () p
transferFin {suc n} P (suc i) zero () p
transferFin {suc n} P (suc i) (suc j) q p = transferFin {n} (P ∘ suc) i j q p
_==DecSets_ : {d : DecSets} → TDecSets d → TDecSets d → Bool
_==DecSets_ {fin n} = _==fin_
transferFin' : {n : ℕ} → (P : Fin n → Set) →
(i j : Fin n) → ((i ==fin j) ≡ true) →
P i → P j
transferFin' {zero} P () j q p
transferFin' {suc n} P zero zero q p = p
transferFin' {suc n} P zero (suc j) () p
transferFin' {suc n} P (suc i) zero () p
transferFin' {suc n} P (suc i) (suc j) q p = transferFin' {n} (P ∘ suc) i j q p
transferDecSets : {J : DecSets} → (P : TDecSets J → Set) →
(i j : TDecSets J) → ((i ==DecSets j) ≡ true) →
P i → P j
transferDecSets {(fin n)} P i j q p = transferFin' {n} P i j q p
{-
transferDec : {J : DecSets} → (P : TDecSets J → Set) →
(i j : TDecSets) → ((i ==DecSets j) ≡ true) →
P i → P j
-}
--with {!!} inspect {!!} --(_==DecSets_ j j')
--... | x = {!!}
{-
... | true = {!!} -- {!(I j).nextˢ (f j) m ?!}
... | false = {!!}
-}
{-
= if (j ==DecSets j') then else {!!}
-}
module _ (I : IOInterfaceˢ )
(let S = IOStateˢ I) (let C = Commandˢ I)
(let R = Responseˢ I) (let n = IOnextˢ I)
where
mutual
-- \writingOOsUsingIOVersFourReaderMethodsIOind
data IOˢind (A : S → Set) (s : S) : Set where
doˢ'' : (c : C s) (f : (r : R s c) → IOˢind A (n s c r)) → IOˢind A s
returnˢ'' : (a : A s) → IOˢind A s
IOˢindₚ : (A : Set)(s s' : S) → Set
IOˢindₚ A s s' = IOˢind (λ s'' → (s'' ≡ s) × A) s
module _ {I : RInterfaceˢ } (let S = Stateˢ I) (let n = nextˢ I)
where
-- \writingOOsUsingIOVersFourReaderMethodstranslateIOind
translateˢ : {A : S → Set} (s : S) (obj : RObjectˢ I s) (p : IOˢind (objectInterfToIOInterfˢ I) A s)
→ Σ[ s′ ∈ S ] (A s′ × RObjectˢ I s′)
translateˢ s obj (returnˢ'' x) = s , (x , obj)
translateˢ s obj (doˢ'' (inj₁ c) p) = obj .objectMethod c ▹ λ {(x , o′) → translateˢ (n s c x) o′ (p x) }
translateˢ s obj (doˢ'' (inj₂ c) p) = obj .readerMethod c ▹ λ x → translateˢ s obj (p x)
-- obj .objectMethod c ▹ λ {(x , o′)
-- → translateˢ {A} {n s c x} o′ (p x) }
module _ {I : RInterfaceˢ } (let S = Stateˢ I)
where
getAˢ : ∀{A : S → Set} (s : S)
→ RObjectˢ I s
→ IOˢind (objectInterfToIOInterfˢ I) A s
→ Σ[ s′ ∈ S ] A s′
getAˢ s obj (returnˢ'' x) = s , x
getAˢ s obj p = let res = translateˢ s obj p
in proj₁ res , proj₁ (proj₂ res)
module _ (I : IOInterfaceˢ )
(let S = IOStateˢ I) (let C = Commandˢ I)
(let R = Responseˢ I) (let n = IOnextˢ I)
where
mutual
-- IOˢind' A sbegin send
-- are programs which start in state sbegin and end in state send
data IOˢind' (A : S → Set) (sbegin : S) : (send : S) → Set where
doˢ''' : {send : S} → (c : C sbegin) →
(f : (r : R sbegin c) → IOˢind' A (n sbegin c r) send)
→ IOˢind' A sbegin send
returnˢ''' : (a : A sbegin) → IOˢind' A sbegin sbegin
module _ {I : RInterfaceˢ } (let S = Stateˢ I) (let n = nextˢ I)
where
translateˢ' : ∀{A : S → Set}{sbegin : S}{send : S}
→ RObjectˢ I sbegin
→ IOˢind' (objectInterfToIOInterfˢ I) A sbegin send
→ (A send × RObjectˢ I send)
translateˢ' {A} {sbegin} {send} obj (returnˢ''' x) = x , obj
translateˢ' {A} {sbegin} {send} obj (doˢ''' (inj₁ c) p) =
obj .objectMethod c ▹ λ {(x , o')
→ translateˢ' {A} {n sbegin c x} {send} o' (p x) }
translateˢ' {A} {sbegin} {send} obj (doˢ''' (inj₂ c) p) =
obj .readerMethod c ▹ λ x
→ translateˢ' {A} {sbegin} {send} obj (p x)
-- obj .objectMethod c ▹ λ {(x , o')
-- → translateˢ' {A} {n sbegin c x} {send} o' (p x) }
module _ {I : RInterfaceˢ } (let S = Stateˢ I)
where
getAˢ' : ∀{A : S → Set}{sbegin : S}{send : S}
→ RObjectˢ I sbegin
→ IOˢind' (objectInterfToIOInterfˢ I) A sbegin send
→ A send
getAˢ' {A} {sbegin} {send} obj (returnˢ''' x) = x
getAˢ' {A} {sbegin} {send} obj p = let res = translateˢ' {I} {A} {sbegin} {send} obj p
in proj₁ res
updateFinFunction : {n : ℕ} → (P : Fin n → Set)
→ (f : (k : Fin n) → P k)
→ (l : Fin n)
→ (b : P l)
→ (k : Fin n) → P k
updateFinFunction {zero} P f () b k
updateFinFunction {suc n} P f zero b zero = b
updateFinFunction {suc n} P f zero b (suc k) = f (suc k)
updateFinFunction {suc n} P f (suc l) b zero = f zero
updateFinFunction {suc n} P f (suc l) b (suc k) = updateFinFunction {n} (P ∘ suc) (f ∘ suc) l b k
updateDecSetsFunction : {J : DecSets} → (P : TDecSets J → Set)
→ (f : (k : TDecSets J) → P k)
→ (l : TDecSets J)
→ (b : P l)
→ (k : TDecSets J) → P k
updateDecSetsFunction {fin n} P f l b k = updateFinFunction {n} P f l b k
updateFinFunctionStateChange : {n : ℕ}
→ (P : Fin n → Set)
→ (f : (k : Fin n) → P k)
→ (Q : (k : Fin n) → P k → Set)
→ (g : (k : Fin n) → Q k (f k) )
→ (l : Fin n)
→ (newP : P l)
→ (newQ : Q l newP)
→ (k : Fin n)
→ Q k (updateFinFunction {n} P f l newP k)
updateFinFunctionStateChange {zero} P f Q g () newP newQ k
updateFinFunctionStateChange {suc n} P f Q g zero newP newQ zero = newQ
updateFinFunctionStateChange {suc n} P f Q g zero newP newQ (suc k) = g (suc k)
updateFinFunctionStateChange {suc n} P f Q g (suc l) newP newQ zero = g zero
updateFinFunctionStateChange {suc n} P f Q g (suc l) newP newQ (suc k) =
updateFinFunctionStateChange {n} (P ∘ suc) (f ∘ suc)
(λ k p → Q (suc k) p)
(g ∘ suc) l newP newQ k
updateDecSetsFunctionStateChange : {J : DecSets}
→ (P : TDecSets J → Set)
→ (f : (k : TDecSets J) → P k)
→ (Q : (k : TDecSets J) → P k → Set)
→ (g : (k : TDecSets J) → Q k (f k) )
→ (l : TDecSets J)
→ (newP : P l)
→ (newQ : Q l newP)
→ (k : TDecSets J)
→ Q k (updateDecSetsFunction {J} P f l newP k)
updateDecSetsFunctionStateChange {fin n} P f Q g l newP newQ k = updateFinFunctionStateChange {n} P f Q g l newP newQ k
objectInterfMultiToIOInterfˢ : (J : DecSets) → (TDecSets J → Interfaceˢ) → IOInterfaceˢ
objectInterfMultiToIOInterfˢ J I .IOStateˢ = (j : TDecSets J) → (I j).Stateˢ
objectInterfMultiToIOInterfˢ J I .Commandˢ f = Σ[ j ∈ TDecSets J ] (I j).Methodˢ (f j)
objectInterfMultiToIOInterfˢ J I .Responseˢ f (j , m) = (I j).Resultˢ (f j) m
objectInterfMultiToIOInterfˢ J I .IOnextˢ f (j , m) r =
updateDecSetsFunction {J} (λ j₁ → I j₁ .Stateˢ) f j (I j .nextˢ (f j) m r)
{-
objectInterfMultiToIOInterfˢ J I .IOnextˢ f (j , m) r j' with (_==DecSets_ j j') | inspect (_==DecSets_ j) j'
... | true | [ eq ] = transferDecSets {J} (λ j'' → I j'' .Stateˢ) j j' eq ((I j).nextˢ (f j) m r)
... | false | [ eq ] = f j'
-}
translateMultiˢ : (J : DecSets) → (I : TDecSets J → Interfaceˢ) →
(A : ((j : TDecSets J) → (I j).Stateˢ) → Set)
(f : (j : TDecSets J) → (I j).Stateˢ)
(obj : (j : TDecSets J) → Objectˢ (I j) (f j))
→ IOˢind (objectInterfMultiToIOInterfˢ J I) A f
→ Σ[ s' ∈ ((j : TDecSets J) → (I j).Stateˢ) ]
(A s' × ( (j : TDecSets J) → Objectˢ (I j) (s' j)))
translateMultiˢ J I A f obj (doˢ'' (j , m) p) = (obj j) .objectMethod m ▹ λ {(r , o')
→ translateMultiˢ J I A (IOnextˢ (objectInterfMultiToIOInterfˢ J I) f (j , m) r)
(updateDecSetsFunctionStateChange {J}
(λ j₁ → I j₁ .Stateˢ)
f
(λ j₁ state → Objectˢ (I j₁) state)
obj j
(I j .nextˢ (f j) m r) o')
(p r)}
translateMultiˢ J I A f obj (returnˢ'' a) = f , a , obj
module _ (I₁ : IOInterfaceˢ )
(let S₁ = IOStateˢ I₁) (let C₁ = Commandˢ I₁)
(let R₁ = Responseˢ I₁) (let n₁ = IOnextˢ I₁)
(I₂ : IOInterfaceˢ )
(let S₂ = IOStateˢ I₂)
(let C₂ = Commandˢ I₂)
(let R₂ = Responseˢ I₂)
(let n₂ = IOnextˢ I₂)
where
mutual
record IOˢindcoind (i : Size)(A : S₁ → S₂ → Set) (s₁ : S₁)(s₂ : S₂) : Set where
coinductive
field
forceIC : {j : Size< i} → IOˢindcoind+ j A s₁ s₂
data IOˢindcoind+ (i : Size)(A : S₁ → S₂ → Set) (s₁ : S₁)(s₂ : S₂) : Set where
doˢIO : (c₁ : C₁ s₁) (f : (r₁ : R₁ s₁ c₁) → IOˢindcoind i A (n₁ s₁ c₁ r₁) s₂)
→ IOˢindcoind+ i A s₁ s₂
doˢobj : (c₂ : C₂ s₂)(f : (r₂ : R₂ s₂ c₂) → IOˢindcoind+ i A s₁ (n₂ s₂ c₂ r₂))
→ IOˢindcoind+ i A s₁ s₂
returnˢic : A s₁ s₂
→ IOˢindcoind+ i A s₁ s₂
open IOˢindcoind public
module _ (I₁ : IOInterfaceˢ )
(let S₁ = IOStateˢ I₁) (let C₁ = Commandˢ I₁)
(let R₁ = Responseˢ I₁) (let n₁ = IOnextˢ I₁)
(I₂ : IOInterfaceˢ )
(let S₂ = IOStateˢ I₂)
(let C₂ = Commandˢ I₂)
(let R₂ = Responseˢ I₂)
(let n₂ = IOnextˢ I₂) where
ioˢind2IOˢindcoind+ : (A : S₁ → S₂ → Set) (s₁ : S₁)(s₂ : S₂)
(p : IOˢind I₂ (λ s₂' → A s₁ s₂') s₂)
→ IOˢindcoind+ I₁ I₂ ∞ A s₁ s₂
ioˢind2IOˢindcoind+ A s₁ s₂ (doˢ'' c f) = doˢobj c λ r →
ioˢind2IOˢindcoind+ A s₁ (IOnextˢ I₂ s₂ c r) (f r)
ioˢind2IOˢindcoind+ A s₁ s₂ (returnˢ'' a) = returnˢic a
ioˢind2IOˢindcoind : (A : S₁ → S₂ → Set) (s₁ : S₁)(s₂ : S₂)
(p : IOˢind I₂ (λ s₂' → A s₁ s₂') s₂)
→ IOˢindcoind I₁ I₂ ∞ A s₁ s₂
ioˢind2IOˢindcoind A s₁ s₂ p .forceIC = ioˢind2IOˢindcoind+ A s₁ s₂ p
{-
translateˢ : ∀{A : S → Set}{s : S}
→ Objectˢ I s
→ IOˢindcoind+ (objectInterfToIOInterfˢ I) A s
→ Σ[ s' ∈ S ] (A s' × Objectˢ I s')
translateˢ {A} {s} obj (returnˢ'' x) = s , (x , obj)
translateˢ {A} {s} obj (doˢobj c p) = obj .objectMethod c ▹ λ {(x , o')
→ translateˢ {A} {n s c x} o' (p x) }
-}
{-
delayˢic : {i : Size}{A : S₁ → S₂ → Set}{s₁ : S₁}{s₂ : S₂}
→ IOˢindcoindShape i A s₁ s₂
→ IOˢindcoind (↑ i) A s₁ s₂
delayˢic {i} {A} {s₁} {s₂} P .IOˢindcoind.forceIC {j} = P
-}
module _ {I : IOInterfaceˢ } (let S = IOStateˢ I)
where
_>>=ind_ : {A : S → Set}{B : S → Set}{s : S}
(m : IOˢind I A s)
(f : (s' : S) (a : A s') → IOˢind I B s')
→ IOˢind I B s
_>>=ind_ (doˢ'' c f₁) f = doˢ'' c (λ r → f₁ r >>=ind f)
_>>=ind_ {s = s} (returnˢ'' a) f = f s a
module _ {I₁ : IOInterfaceˢ }
(let S₁ = IOStateˢ I₁) (let C₁ = Commandˢ I₁)
(let R₁ = Responseˢ I₁) (let n₁ = IOnextˢ I₁)
{I₂ : IOInterfaceˢ }
(let S₂ = IOStateˢ I₂)
(let C₂ = Commandˢ I₂)
(let R₂ = Responseˢ I₂)
(let n₂ = IOnextˢ I₂)
where
mutual
_>>=indcoind+_ : {i : Size}{A : S₁ → S₂ → Set}
{B : S₁ → S₂ → Set}
{s₁ : S₁}{s₂ : S₂}
(p : IOˢindcoind+ I₁ I₂ i A s₁ s₂)
(f : {s₁' : S₁}{s₂' : S₂}(a : A s₁' s₂') → IOˢindcoind+ I₁ I₂ i B s₁' s₂')
→ IOˢindcoind+ I₁ I₂ i B s₁ s₂
doˢobj c f₁ >>=indcoind+ f = doˢobj c (λ r → f₁ r >>=indcoind+ f)
doˢIO c f₁ >>=indcoind+ f = doˢIO c (λ r → f₁ r >>=indcoind f)
returnˢic x >>=indcoind+ f = f x
{-
_>>=indcoindShape_ : {i : Size}{A : S₁ → S₂ → Set}
{B : S₁ → S₂ → Set}
{s₁ : S₁}{s₂ : S₂}
(p : IOˢindcoindShape I₁ I₂ i A s₁ s₂)
(f : (s₁' : S₁)(s₂' : S₂)(a : A s₁' s₂') → IOˢindcoind+ I₁ I₂ i B s₁' s₂')
→ IOˢindcoind+ I₁ I₂ i B s₁ s₂
doˢIO c₁ f₁ >>=indcoindShape f = returnˢ'' (doˢIO c₁ (λ r → f₁ r >>=indcoind f))
_>>=indcoindShape_ {s₁ = s₁} {s₂ = s₂} (returnˢic x) f = x >>=indcoindaux' f
-}
_>>=indcoind_ : {i : Size}{A : S₁ → S₂ → Set}
{B : S₁ → S₂ → Set}
{s₁ : S₁}{s₂ : S₂}
(p : IOˢindcoind I₁ I₂ i A s₁ s₂)
(f : {s₁' : S₁}{s₂' : S₂}(a : A s₁' s₂') → IOˢindcoind+ I₁ I₂ i B s₁' s₂')
→ IOˢindcoind I₁ I₂ i B s₁ s₂
(p >>=indcoind f) .forceIC {j} = p .forceIC >>=indcoind+ f
{-
_>>=indcoindaux'_ : {i : Size}{A : S₁ → S₂ → Set}
{B : S₁ → S₂ → Set}
{s₁ : S₁}{s₂ : S₂}
(p : IOˢ' I₁ i (λ s₁' → A s₁' s₂) s₁)
(f : {s₁' : S₁}{s₂' : S₂}(a : A s₁' s₂') → IOˢindcoind+ I₁ I₂ i B s₁' s₂')
→ IOˢindcoind+ I₁ I₂ i B s₁ s₂
doˢ' c f₁ >>=indcoindaux' f = {!!} -- returnˢ'' (returnˢic (doˢ' c λ r → {!returnˢic!})) -- doˢ' c λ r → f₁ r >>=indcoindaux f
_>>=indcoindaux'_ {s₁ = s₁}{s₂ = s₂} (returnˢ' a) f = f {s₁} {s₂} a -- doˢobj {!inj₂ c!} {!!}
-}
{-
_>>=indcoindaux_ : {i : Size}{A : S₁ → S₂ → Set}
{B : S₁ → S₂ → Set}
{s₁ : S₁}{s₂ : S₂}
(p : IOˢ I₁ i (λ s₁' → A s₁' s₂) s₁)
(f : (s₁' : S₁)(s₂' : S₂)(a : A s₁' s₂') → IOˢindcoind+ I₁ I₂ i B s₁' s₂')
→ IOˢindcoind+ I₁ I₂ i B s₁ s₂
p >>=indcoindaux f = {!!}
-}
module _ {I₁ : IOInterfaceˢ }
(let S₁ = IOStateˢ I₁) (let C₁ = Commandˢ I₁)
(let R₁ = Responseˢ I₁) (let n₁ = IOnextˢ I₁)
{I₂ : IOInterfaceˢ }
(let S₂ = IOStateˢ I₂)
where
open IOˢindcoind
delayˢic : {i : Size}{A : S₁ → S₂ → Set}{s₁ : S₁}{s₂ : S₂}
→ IOˢindcoind+ I₁ I₂ i A s₁ s₂
→ IOˢindcoind I₁ I₂ (↑ i) A s₁ s₂
delayˢic {i} {A} {s₁} {s₂} P .forceIC {j} = P
--Σ (Stateˢ I₂) (λ s₄ → Σ (A s₃ s₄) (λ x → Objectˢ I₂ s₄))) s₁
--→ IOˢind I₂ (λ s₂ → A s₁ s₂) s₂
open IOˢindcoind public
module _ (I₁ : IOInterfaceˢ )
(let S₁ = IOStateˢ I₁) (let C₁ = Commandˢ I₁)
(let R₁ = Responseˢ I₁) (let n₁ = IOnextˢ I₁)
(I₂ : RInterfaceˢ )
(let I₂′ = objectInterfToIOInterfˢ I₂)
(let S₂ = Stateˢ I₂)(let n₂ = IOnextˢ I₂′)
where
mutual
translateˢIndCoind : ∀ {i A s₁ s₂} (obj : RObjectˢ I₂ s₂) (p : IOˢindcoind I₁ I₂′ i A s₁ s₂)
→ IOˢ I₁ i (λ s₁ → Σ[ s₂ ∈ S₂ ] (A s₁ s₂ × RObjectˢ I₂ s₂)) s₁
translateˢIndCoind obj p .forceˢ = translateˢIndCoind+ obj (p .forceIC)
translateˢIndCoind+ : ∀{i A s₁ s₂} (obj : RObjectˢ I₂ s₂) (p : IOˢindcoind+ I₁ I₂′ i A s₁ s₂)
→ IOˢ' I₁ i (λ s₁ → Σ[ s₂ ∈ S₂ ] (A s₁ s₂ × RObjectˢ I₂ s₂)) s₁
translateˢIndCoind+ obj (doˢobj (inj₁ c) f) = obj .objectMethod c ▹ λ { (x , obj′) →
translateˢIndCoind+ obj′ (f x)}
translateˢIndCoind+ obj (doˢobj (inj₂ c) f) = obj .readerMethod c ▹ λ x →
translateˢIndCoind+ obj (f x)
translateˢIndCoind+ obj (doˢIO c₁ f) = doˢ' c₁ λ r₁ →
translateˢIndCoind obj (f r₁)
translateˢIndCoind+ {i} {A} {s₁} {s₂} obj (returnˢic a) = returnˢ' (s₂ , a , obj)
{-
translateˢIndCoindShape : ∀{i} → {A : S₁ → S₂ → Set}{s₁ : S₁}{s₂ : S₂}
→ RObjectˢ I₂ s₂
→ IOˢindcoindShape I₁ I₂′ i A s₁ s₂
→ IOˢ' I₁ i ((λ s₁ → Σ[ s₂ ∈ S₂ ] (A s₁ s₂ × RObjectˢ I₂ s₂))) s₁
translateˢIndCoindShape {i} {A} {.s₁} {.s₂} obj (doˢIO {s₁} {s₂} c₁ p)
= doˢ' c₁ (λ r₁ → translateˢIndCoind {i} {A} {n₁ s₁ c₁ r₁} {s₂} obj (p r₁))
translateˢIndCoindShape {i} {A} {.s₁} {.s₂} obj (returnˢic {s₁} {s₂} p)
= fmapˢ' i (λ s a → ( s₂ , a , obj)) s₁ p
-}
---
--- ### file content of writingOOsUsingIO
---
{-
objectInterfMultiToIOInterfˢ J I .IOnextˢ f (j , m) r j' with (_==DecSets_ j j') | inspect (_==DecSets_ j) j'
... | true | [ eq ] = transferDecSets {J} (λ j'' → I j'' .Stateˢ) j j' eq ((I j).nextˢ (f j) m r)
... | false | [ eq ] = f j'
-}
module _ (I₁ : IOInterfaceˢ )
(let S₁ = IOStateˢ I₁) (let C₁ = Commandˢ I₁)
(let R₁ = Responseˢ I₁) (let n₁ = IOnextˢ I₁)
(I₂ : IOInterfaceˢ )
(let S₂ = IOStateˢ I₂)
where
unsizedIOInterfToIOInterfˢ : IOInterface → IOInterfaceˢ
unsizedIOInterfToIOInterfˢ x .IOStateˢ = Unit
unsizedIOInterfToIOInterfˢ x .Commandˢ = λ _ → x .Command
unsizedIOInterfToIOInterfˢ x .Responseˢ = λ _ → x .Response
unsizedIOInterfToIOInterfˢ x .IOnextˢ _ _ _ = unit
ConsoleInterfaceˢ : IOInterfaceˢ
ConsoleInterfaceˢ = unsizedIOInterfToIOInterfˢ consoleI
data RCellStateˢ : Set where
empty full : RCellStateˢ
data RCellMethodEmpty (A : Set) : Set where
put : A → RCellMethodEmpty A
data RCellMethodFull (A : Set) : Set where
put : A → RCellMethodFull A
data RRCellMethodEmpty (A : Set) : Set where
data RRCellMethodFull (A : Set) : Set where
get : RRCellMethodFull A
RCellMethodˢ : (A : Set) → RCellStateˢ → Set
RCellMethodˢ A empty = RCellMethodEmpty A
RCellMethodˢ A full = RCellMethodFull A
RRCellMethodˢ : (A : Set) → RCellStateˢ → Set
RRCellMethodˢ A empty = RRCellMethodEmpty A
RRCellMethodˢ A full = RRCellMethodFull A
putGen : {A : Set} → {i : RCellStateˢ} → A → RCellMethodˢ A i
putGen {A} {empty} = put
putGen {A} {full} = put
RCellResultFull : ∀{A} → RCellMethodFull A → Set
RCellResultFull (put _) = Unit
RCellResultEmpty : ∀{A} → RCellMethodEmpty A → Set
RCellResultEmpty (put _) = Unit
RRCellResultFull : ∀{A} → RRCellMethodFull A → Set
RRCellResultFull {A} get = A
RRCellResultEmpty : ∀{A} → RRCellMethodEmpty A → Set
RRCellResultEmpty ()
RCellResultˢ : (A : Set) → (s : RCellStateˢ) → RCellMethodˢ A s → Set
RCellResultˢ A empty = RCellResultEmpty{A}
RCellResultˢ A full = RCellResultFull{A}
RRCellResultˢ : (A : Set) → (s : RCellStateˢ) → RRCellMethodˢ A s → Set
RRCellResultˢ A empty = RRCellResultEmpty{A}
RRCellResultˢ A full = RRCellResultFull{A}
nˢ : ∀{A} → (s : RCellStateˢ) → (c : RCellMethodˢ A s) → (RCellResultˢ A s c) → RCellStateˢ
nˢ _ _ _ = full
RCellInterfaceˢ : (A : Set) → RInterfaceˢ
Stateˢ (RCellInterfaceˢ A) = RCellStateˢ
Methodˢ (RCellInterfaceˢ A) = RCellMethodˢ A
Resultˢ (RCellInterfaceˢ A) = RCellResultˢ A
RMethodˢ (RCellInterfaceˢ A) = RRCellMethodˢ A
RResultˢ (RCellInterfaceˢ A) = RRCellResultˢ A
nextˢ (RCellInterfaceˢ A) = nˢ
{-
mutual
RcellPempty : (i : Size) → IOObject consoleI (RCellInterfaceˢ String) i empty
method (cellPempty i) {j} (put str) = do (putStrLn ("put (" ++ str ++ ")")) λ _ →
return (unit , cellPfull j str)
cellPfull : (i : Size) → (str : String) → IOObject consoleI (CellInterfaceˢ String) i full
method (cellPfull i str) {j} get = do (putStrLn ("get (" ++ str ++ ")")) λ _ →
return (str , cellPfull j str)
method (cellPfull i str) {j} (put str') = do (putStrLn ("put (" ++ str' ++ ")")) λ _ →
return (unit , cellPfull j str')
-}
-- UNSIZED Version, without IO
mutual
RcellPempty' : ∀{A} → RObjectˢ (RCellInterfaceˢ A) empty
RcellPempty' .objectMethod (put a) = (_ , RcellPfull' a)
RcellPempty' .readerMethod ()
RcellPfull' : ∀{A} → A → RObjectˢ (RCellInterfaceˢ A) full
RcellPfull' a .readerMethod get = a
RcellPfull' a .objectMethod (put a') = (_ , RcellPfull' a')
RCellInterfaceˢIO : IOInterfaceˢ
RCellInterfaceˢIO = objectInterfToIOInterfˢ (RCellInterfaceˢ String)
module _ (I : IOInterface)
(let C = I .Command)
(let R = I .Response)
(let I' = unsizedIOInterfToIOInterfˢ I)
(let C' = I' .Commandˢ)
(let R' = I' .Responseˢ)
(convertC : C' _ → C)
(convertR : ∀{c : C} → Response I (convertC c) → I .Response c)
where
mutual
flatternIOˢ : ∀ {A : Set}
→ IOˢ (unsizedIOInterfToIOInterfˢ I) ∞ (λ _ → A) unit
→ IO I ∞ A
flatternIOˢ {A} p .force = flatternIOˢ' (forceˢ p)
flatternIOˢ' : {A : Set}
→ IOˢ' (unsizedIOInterfToIOInterfˢ I) ∞ (λ _ → A) unit
→ IO' I ∞ A
flatternIOˢ' {A} (doˢ' cˢ f) = do' (convertC cˢ) (λ rˢ →
flatternIOˢ (f (convertR {cˢ} rˢ)))
flatternIOˢ' {A} (returnˢ' a) = return' a
{-
doIOShape : {i : Size}
{I₁ : IOInterfaceˢ} {I₂ : IOInterfaceˢ}
{A : I₁ .IOStateˢ → I₂ .IOStateˢ → Set}
{s₁ : I₁ .IOStateˢ}
{s₂ : I₂ .IOStateˢ}
(c₁ : I₁ .Commandˢ s₁) →
((r₁ : I₁ .Responseˢ s₁ c₁) →
IOˢindcoind I₁ I₂ i A (IOnextˢ I₁ s₁ c₁ r₁) s₂)
→ IOˢindcoindShape I₁ I₂ i A s₁ s₂
doIOShape = doˢIO
-}
{-
callMethod'' : {I₂ : IOInterfaceˢ}
{A : I₂ .IOStateˢ → Set}
{s₂ : I₂ .IOStateˢ}
(c : Commandˢ I₂ s₂) →
((r : Responseˢ I₂ s₂ c) → IOˢind I₂ A (IOnextˢ I₂ s₂ c r))
→ IOˢind I₂ A s₂
callMethod'' = doˢobj
-}
doˢobj∞ : {I₁ : IOInterfaceˢ }{I₂ : IOInterfaceˢ}
{A : IOStateˢ I₁ → I₂ .IOStateˢ → Set}
{s₁ : IOStateˢ I₁}
{s₂ : I₂ .IOStateˢ}
(c : Commandˢ I₂ s₂) →
((r : Responseˢ I₂ s₂ c) → IOˢindcoind+ I₁ I₂ ∞ A s₁ (IOnextˢ I₂ s₂ c r) )
→ IOˢindcoind I₁ I₂ ∞ A s₁ s₂
doˢobj∞ {I₁} {I₂} {A} {s₁} {s₂} c f .forceIC {j} = doˢobj c f
{-
callMethod+ : {I₁ : IOInterfaceˢ }{I₂ : IOInterfaceˢ}
{A : IOStateˢ I₁ → I₂ .IOStateˢ → Set}
{s₁ : IOStateˢ I₁}
{s₂ : I₂ .IOStateˢ}
(c : Commandˢ I₂ s₂) →
((r : Responseˢ I₂ s₂ c) → IOˢindcoind+ I₁ I₂ ∞ A s₁ (IOnextˢ I₂ s₂ c r) )
→ IOˢindcoind+ I₁ I₂ ∞ A s₁ s₂
callMethod+ {I₁} {I₂} {A} {s₁} {s₂} = doˢobj
-}
{-
we think not needed anymore
endIO : {I₁ : IOInterfaceˢ} {I₂ : IOInterfaceˢ}
-- {A : I₁ .IOStateˢ → I₂ .IOStateˢ → Set}
{s₁ : I₁ .IOStateˢ}
{s₂ : I₂ .IOStateˢ}
→ IOˢind I₂ (λ s → IOˢindcoind I₁ I₂ ∞ (λ _ _ → Unit) s₁ s) s₂
endIO {I₁} {I₂} {s₁} {s₂} = returnˢ'' (delayˢic (returnˢ'' (returnˢic (returnˢ' unit)))) -- (delayˢic (returnˢic (returnˢ' unit)))
-- returnˢ'' {I₂}
-- {!!} -- (delayˢic {!returnˢ''!} ) -- (returnˢ'' (returnˢic (returnˢ' unit)))) --(returnˢic (returnˢ' unit)))
-}
endIO+ : {I₁ : IOInterfaceˢ} {I₂ : IOInterfaceˢ}
{s₁ : I₁ .IOStateˢ}
{s₂ : I₂ .IOStateˢ}
→ IOˢindcoind+ I₁ I₂ ∞ (λ _ _ → Unit) s₁ s₂
endIO+ = returnˢic unit
endIO∞ : {I₁ : IOInterfaceˢ} {I₂ : IOInterfaceˢ}
{s₁ : I₁ .IOStateˢ}
{s₂ : I₂ .IOStateˢ}
→ IOˢindcoind I₁ I₂ ∞ (λ _ _ → Unit) s₁ s₂
endIO∞ .forceIC {j} = endIO+
doˢIO∞ : {i : Size}
{I₁ : IOInterfaceˢ} {I₂ : IOInterfaceˢ}
{s₁ : I₁ .IOStateˢ}
{s₂ : I₂ .IOStateˢ}
(c₁ : I₁ .Commandˢ s₁) →
((r₁ : I₁ .Responseˢ s₁ c₁) →
IOˢindcoind I₁ I₂ i (λ _ _ → Unit) (IOnextˢ I₁ s₁ c₁ r₁) s₂)
→ IOˢindcoind I₁ I₂ i (λ _ _ → Unit) s₁ s₂
doˢIO∞ {i} c p .forceIC {j} = doˢIO c p
callProg : {I : IOInterfaceˢ }{A : I .IOStateˢ → Set}{s : I .IOStateˢ} (a : A s) → IOˢind I A s
callProg = returnˢ''
run' : IOˢindcoind ConsoleInterfaceˢ RCellInterfaceˢIO ∞ (λ x y → Unit)
unit empty
→ NativeIO Unit
run' prog = translateIOConsole
(flatternIOˢ consoleI (λ c → c) (λ r → r)
(fmapˢ ∞ (λ x y → unit) unit
(translateˢIndCoind ConsoleInterfaceˢ
(RCellInterfaceˢ String) RcellPempty' (prog))))
module _ {objInf : RInterfaceˢ}
(let objIOInf = objectInterfToIOInterfˢ objInf)
{objState : objIOInf .IOStateˢ }
where
run_startingWith_ : IOˢindcoind ConsoleInterfaceˢ objIOInf ∞ (λ x y → Unit) unit objState
→ RObjectˢ objInf objState → NativeIO Unit
run prog startingWith obj = translateIOConsole
(flatternIOˢ consoleI (λ c → c) (λ r → r) (fmapˢ ∞ (λ x y → unit) unit
(translateˢIndCoind ConsoleInterfaceˢ objInf obj prog)))
run+_startingWith_ : IOˢindcoind+ ConsoleInterfaceˢ objIOInf ∞ (λ _ _ → Unit) unit objState
→ RObjectˢ objInf objState
→ NativeIO Unit
run+ prog startingWith obj = translateIOConsole
(flatternIOˢ consoleI id id (fmapˢ ∞ (λ _ _ → unit) unit
(delayˢ (translateˢIndCoind+ ConsoleInterfaceˢ objInf obj prog))))
-- (ioInterfToObjectInterfˢ objIOInf)
--- ### END of file content of writingOOsUsingIO
---
{-
obj .objectMethod c ▹ λ {(x , o')
→ translateˢ {A} {n s c x} o' (p x) }
let q : Σ[ s' ∈ S₂ ]
(IOˢindcoindShape I₁ I₂′ i A s₁ s'
× Objectˢ I₂ s')
q = translateˢ obj p
in translateˢIndCoindShape (proj₂ (proj₂ q)) (proj₁ (proj₂ q)) -}
module _ (I₁ : IOInterfaceˢ )
(let S₁ = IOStateˢ I₁) (let C₁ = Commandˢ I₁)
(let R₁ = Responseˢ I₁) (let n₁ = IOnextˢ I₁)
(I₂ : IOInterfaceˢ )
(let S₂ = IOStateˢ I₂)
(let C₂ = Commandˢ I₂)
(let R₂ = Responseˢ I₂)
(let n₂ = IOnextˢ I₂)
(I₂' : IOInterface)
(let C₂' = I₂' .Command)
(let R₂' = I₂' .Response)
(let I₂'' = unsizedIOInterfToIOInterfˢ I₂')
(let C₂'' = I₂'' .Commandˢ)
(let R₂'' = I₂'' .Responseˢ)
(convertC : (s₂ : S₂)(c₂ : C₂ s₂) → C₂')
(convertR : (s₂ : S₂)(c₂ : C₂ s₂)(r₂ : R₂' (convertC s₂ c₂)) → R₂ s₂ c₂)
(A : Set)
where
mutual
translateIndCoindFlatteningObj : ∀{i} (s₁ : S₁) (s₂ : S₂)
→ IOˢindcoind I₁ I₂ i (λ _ _ → A) s₁ s₂
→ IOˢindcoind I₁ I₂'' i (λ _ _ → A) s₁ _
translateIndCoindFlatteningObj {i} s₁ s₂ p .forceIC {j} = translateIndCoindFlatteningObj+ {j} s₁ s₂ (p .forceIC {j})
translateIndCoindFlatteningObj+ : ∀{i} (s₁ : S₁) (s₂ : S₂)
→ IOˢindcoind+ I₁ I₂ i (λ _ _ → A) s₁ s₂
→ IOˢindcoind+ I₁ I₂'' i (λ _ _ → A) s₁ _
translateIndCoindFlatteningObj+ {i} s₁ s₂ (doˢIO c₁ f) = doˢIO c₁ λ r₁ → translateIndCoindFlatteningObj (n₁ s₁ c₁ r₁) s₂ (f r₁)
translateIndCoindFlatteningObj+ {i} s₁ s₂ (doˢobj c₂ f) = doˢobj (convertC s₂ c₂) λ r₂ →
translateIndCoindFlatteningObj+ s₁ (n₂ s₂ c₂ (convertR s₂ c₂ r₂)) (f (convertR s₂ c₂ r₂))
translateIndCoindFlatteningObj+ {i} s₁ s₂ (returnˢic x) = returnˢic x
| {
"alphanum_fraction": 0.5277269338,
"avg_line_length": 35.5445783133,
"ext": "agda",
"hexsha": "91c5151191546bbc4fe71245f2a465df483fca32",
"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": "src/StateSizedIO/writingOOsUsingIOVers4ReaderMethods.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": "src/StateSizedIO/writingOOsUsingIOVers4ReaderMethods.agda",
"max_line_length": 151,
"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": "src/StateSizedIO/writingOOsUsingIOVers4ReaderMethods.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": 11714,
"size": 29502
} |
module Issue1436-1 where
module A where
infixl 20 _↑_
infixl 1 _↓_
data D : Set where
● : D
_↓_ _↑_ : D → D → D
module B where
infix -1000000 _↓_
data D : Set where
_↓_ : D → D → D
open A
open B
-- The expression below is not parsed. If the number 20 above is
-- replaced by 19, then it is parsed…
rejected = ● ↑ ● ↓ ● ↑ ● ↓ ● ↑ ●
| {
"alphanum_fraction": 0.5691056911,
"avg_line_length": 14.1923076923,
"ext": "agda",
"hexsha": "dc5df4dc5d146f15159dec83f8b822af75fcbd04",
"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/Issue1436-1.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/Issue1436-1.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/Issue1436-1.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": 134,
"size": 369
} |
-- Andreas, 2016-07-29, issue #717
-- reported by LarryTheLiquid on 2012-10-28
data Foo (A : Set) : Set where
foo : Foo A
data Bar : Set where
bar baz : Foo {!Bar!} → Bar -- previously, this IP got duplicated internally
fun : (x : Bar) → Foo Bar
fun (bar y) = {!y!} -- WAS: goal is "Set" (incorrect, should be "Foo Bar")
fun (baz z) = {!z!} -- goal is "Foo Bar" (correct)
-- Works now, after fix for #1720!
| {
"alphanum_fraction": 0.6201923077,
"avg_line_length": 27.7333333333,
"ext": "agda",
"hexsha": "6b8f1c30bcc435c22df4a5ebe40d93e5bb44d045",
"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/interaction/Issue717.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/interaction/Issue717.agda",
"max_line_length": 79,
"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/interaction/Issue717.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": 143,
"size": 416
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
open import Categories.Category.Complete
module Categories.Category.Complete.Properties.SolutionSet where
open import Level
open import Categories.Functor
open import Categories.Object.Initial
open import Categories.Object.Product.Indexed
open import Categories.Object.Product.Indexed.Properties
open import Categories.Diagram.Equalizer
open import Categories.Diagram.Equalizer.Limit
open import Categories.Diagram.Equalizer.Properties
import Categories.Diagram.Limit as Lim
import Categories.Morphism.Reasoning as MR
private
variable
o ℓ e : Level
o′ ℓ′ e′ : Level
J : Category o ℓ e
module _ (C : Category o ℓ e) where
open Category C
record SolutionSet : Set (o ⊔ ℓ) where
field
D : Obj → Obj
arr : ∀ X → D X ⇒ X
module _ {C : Category o ℓ e} (Com : Complete (o ⊔ ℓ ⊔ o′) (o ⊔ ℓ ⊔ ℓ′) (o ⊔ ℓ ⊔ e′) C) (S : SolutionSet C) where
private
module S = SolutionSet S
module C = Category C
open S
open Category C
open HomReasoning
open MR C
W : IndexedProductOf C D
W = Complete⇒IndexedProductOf C {o′ = ℓ ⊔ o′} {ℓ′ = ℓ ⊔ ℓ′} {e′ = ℓ ⊔ e′} Com D
module W = IndexedProductOf W
W⇒W : Set ℓ
W⇒W = W.X ⇒ W.X
Warr : IndexedProductOf C {I = W⇒W} λ _ → W.X
Warr = Complete⇒IndexedProductOf C {o′ = o ⊔ o′} {ℓ′ = o ⊔ ℓ′} {e′ = o ⊔ e′} Com _
module Warr = IndexedProductOf Warr
Δ : W.X ⇒ Warr.X
Δ = Warr.⟨ (λ _ → C.id) ⟩
Γ : W.X ⇒ Warr.X
Γ = Warr.⟨ (λ f → f) ⟩
equalizer : Equalizer C Δ Γ
equalizer = complete⇒equalizer C Com Δ Γ
module equalizer = Equalizer equalizer
prop : (f : W.X ⇒ W.X) → f ∘ equalizer.arr ≈ equalizer.arr
prop f = begin
f ∘ equalizer.arr ≈˘⟨ pullˡ (Warr.commute _ f) ⟩
Warr.π f ∘ Γ ∘ equalizer.arr ≈˘⟨ refl⟩∘⟨ equalizer.equality ⟩
Warr.π f ∘ Δ ∘ equalizer.arr ≈⟨ cancelˡ (Warr.commute _ f) ⟩
equalizer.arr ∎
! : ∀ A → equalizer.obj ⇒ A
! A = arr A ∘ W.π A ∘ equalizer.arr
module _ {A} (f : equalizer.obj ⇒ A) where
equalizer′ : Equalizer C (! A) f
equalizer′ = complete⇒equalizer C Com (! A) f
module equalizer′ = Equalizer equalizer′
s : W.X ⇒ equalizer′.obj
s = arr _ ∘ W.π (equalizer′.obj)
t : W.X ⇒ W.X
t = equalizer.arr ∘ equalizer′.arr ∘ s
t′ : equalizer.obj ⇒ equalizer.obj
t′ = equalizer′.arr ∘ s ∘ equalizer.arr
t∘eq≈eq∘1 : equalizer.arr ∘ t′ ≈ equalizer.arr ∘ C.id
t∘eq≈eq∘1 = begin
equalizer.arr ∘ t′ ≈⟨ refl⟩∘⟨ sym-assoc ⟩
equalizer.arr ∘ (equalizer′.arr ∘ s) ∘ equalizer.arr ≈⟨ sym-assoc ⟩
t ∘ equalizer.arr ≈⟨ prop _ ⟩
equalizer.arr ≈˘⟨ identityʳ ⟩
equalizer.arr ∘ C.id ∎
t′≈id : t′ ≈ C.id
t′≈id = Equalizer⇒Mono C equalizer _ _ t∘eq≈eq∘1
!-unique : ! A ≈ f
!-unique = equalizer-≈⇒≈ C equalizer′ t′≈id
SolutionSet⇒Initial : Initial C
SolutionSet⇒Initial = record
{ ⊥ = equalizer.obj
; ⊥-is-initial = record
{ ! = ! _
; !-unique = !-unique
}
}
| {
"alphanum_fraction": 0.5638753056,
"avg_line_length": 28.9557522124,
"ext": "agda",
"hexsha": "f5629ad811d9638ff745377774cf460bc1d4e74a",
"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/Complete/Properties/SolutionSet.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/Complete/Properties/SolutionSet.agda",
"max_line_length": 113,
"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/Complete/Properties/SolutionSet.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": 1148,
"size": 3272
} |
-- examples for termination with tupled arguments
module Tuple where
data Nat : Set where
zero : Nat
succ : Nat -> Nat
data Pair (A : Set) (B : Set) : Set where
pair : A -> B -> Pair A B
-- uncurried addition
add : Pair Nat Nat -> Nat
add (pair x (succ y)) = succ (add (pair x y))
add (pair x zero) = x
data T (A : Set) (B : Set) : Set where
c1 : A -> B -> T A B
c2 : A -> B -> T A B
{-
-- constructor names do not matter
add' : T Nat Nat -> Nat
add' (c1 x (succ y)) = succ (add' (c2 x y))
add' (c2 x (succ y)) = succ (add' (c1 x y))
add' (c1 x zero) = x
add' (c2 x zero) = x
-- additionally: permutation of arguments
add'' : T Nat Nat -> Nat
add'' (c1 x (succ y)) = succ (add'' (c2 y x))
add'' (c2 (succ y) x) = succ (add'' (c1 x y))
add'' (c1 x zero) = x
add'' (c2 zero x) = x
-}
| {
"alphanum_fraction": 0.5595533499,
"avg_line_length": 21.7837837838,
"ext": "agda",
"hexsha": "e10eb6db6f9abbd0f5b90e5a2382639439f6f22a",
"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": "examples/Termination/Tuple.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": "examples/Termination/Tuple.agda",
"max_line_length": 49,
"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": "examples/Termination/Tuple.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": 304,
"size": 806
} |
-- Andreas, 2016-08-01, issue #2125, qualified names in pragmas
{-# OPTIONS --rewriting #-}
import Common.Equality as Eq
{-# BUILTIN REWRITE Eq._≡_ #-} -- qualified name, should be accepted
postulate
A : Set
a b : A
module M where
open Eq
postulate
rule : a ≡ b
{-# REWRITE M.rule #-} -- qualified name, should be accepted
-- ERROR WAS: in the name M.rule, the part M.rule is not valid
-- NOW: works
| {
"alphanum_fraction": 0.6571428571,
"avg_line_length": 19.0909090909,
"ext": "agda",
"hexsha": "e8a2dd888a66e8b5964bc1ad475f7c2c3f6351b0",
"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/Succeed/RewriteQualified.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/Succeed/RewriteQualified.agda",
"max_line_length": 68,
"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/Succeed/RewriteQualified.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": 128,
"size": 420
} |
{-# OPTIONS --universe-polymorphism #-}
open import Categories.Category
open import Categories.Object.Products
module Categories.Object.Products.N-ary {o ℓ e}
(C : Category o ℓ e)
(P : Products C)
where
open Category C
open Products P
open Equiv
import Categories.Object.Product
open Categories.Object.Product C
import Categories.Object.BinaryProducts
open Categories.Object.BinaryProducts C
import Categories.Object.BinaryProducts.N-ary
import Categories.Object.Terminal
open Categories.Object.Terminal C
open import Data.Nat
open import Data.Vec
open import Data.Vec.Properties
open import Data.Product.N-ary hiding ([])
import Level
open import Relation.Binary.PropositionalEquality as PropEq
using ()
renaming (_≡_ to _≣_
; refl to ≣-refl
; sym to ≣-sym
; cong to ≣-cong
)
open BinaryProducts binary
module NonEmpty = Categories.Object.BinaryProducts.N-ary C binary
open Terminal terminal
Prod : {n : ℕ} → Vec Obj n → Obj
Prod { zero} [] = ⊤
Prod {suc n} As = NonEmpty.Prod As
-- This whole module is made a great deal more heinous than it should be
-- by the fact that "xs ++ [] ≣ xs" is ill-typed, so I have to repeatedly
-- prove trivial corrolaries of that fact without using it directly.
-- I don't really know how to deal with that in a sane way.
πˡ : {n m : ℕ}
→ (As : Vec Obj n)
→ (Bs : Vec Obj m)
→ Prod (As ++ Bs) ⇒ Prod As
πˡ { zero} [] Bs = !
πˡ { suc n} (A ∷ As) (B ∷ Bs) = NonEmpty.πˡ (A ∷ As) (B ∷ Bs)
πˡ { suc zero} (A ∷ []) [] = id
πˡ {suc (suc n)} (A ∷ As) [] = ⟨ π₁ , πˡ As [] ∘ π₂ ⟩
πʳ : {n m : ℕ}
→ (As : Vec Obj n)
→ (Bs : Vec Obj m)
→ Prod (As ++ Bs) ⇒ Prod Bs
πʳ [] Bs = id
πʳ (A ∷ As) (B ∷ Bs) = NonEmpty.πʳ (A ∷ As) (B ∷ Bs)
πʳ As [] = !
glue : {n m : ℕ}{X : Obj}
→ (As : Vec Obj n)
→ (Bs : Vec Obj m)
→ (f : X ⇒ Prod As)
→ (g : X ⇒ Prod Bs)
→ X ⇒ Prod (As ++ Bs)
glue { zero} [] Bs f g = g
glue { suc n} (A ∷ As) (B ∷ Bs) f g = NonEmpty.glue (A ∷ As) (B ∷ Bs) f g
glue { suc zero} (A ∷ []) [] f g = f
glue {suc (suc n)} (A ∷ As) [] f g = ⟨ π₁ ∘ f , glue As [] (π₂ ∘ f) g ⟩
open HomReasoning
.commuteˡ : {n m : ℕ}{X : Obj}
→ (As : Vec Obj n)
→ (Bs : Vec Obj m)
→ {f : X ⇒ Prod As}
→ {g : X ⇒ Prod Bs}
→ πˡ As Bs ∘ glue As Bs f g ≡ f
commuteˡ { zero} [] Bs {f}{g} = !-unique₂ (! ∘ g) f
commuteˡ { suc n} (A ∷ As) (B ∷ Bs) {f}{g} = NonEmpty.commuteˡ (A ∷ As) (B ∷ Bs)
commuteˡ { suc zero} (A ∷ []) [] {f}{g} = identityˡ
commuteˡ {suc (suc n)} (A ∷ As) [] {f}{g} =
begin
⟨ π₁ , πˡ As [] ∘ π₂ ⟩ ∘ ⟨ π₁ ∘ f , glue As [] (π₂ ∘ f) g ⟩
↓⟨ ⟨⟩∘ ⟩
⟨ π₁ ∘ ⟨ π₁ ∘ f , glue As [] (π₂ ∘ f) g ⟩
, (πˡ As [] ∘ π₂) ∘ ⟨ π₁ ∘ f , glue As [] (π₂ ∘ f) g ⟩
⟩
↓⟨ ⟨⟩-congʳ assoc ⟩
⟨ π₁ ∘ ⟨ π₁ ∘ f , glue As [] (π₂ ∘ f) g ⟩
, πˡ As [] ∘ π₂ ∘ ⟨ π₁ ∘ f , glue As [] (π₂ ∘ f) g ⟩
⟩
↓⟨ ⟨⟩-cong₂ commute₁ (∘-resp-≡ʳ commute₂) ⟩
⟨ π₁ ∘ f , πˡ As [] ∘ glue As [] (π₂ ∘ f) g ⟩
↓⟨ ⟨⟩-congʳ (commuteˡ As []) ⟩
⟨ π₁ ∘ f , π₂ ∘ f ⟩
↓⟨ g-η ⟩
f
∎
.commuteʳ : {n m : ℕ}{X : Obj}
→ (As : Vec Obj n)
→ (Bs : Vec Obj m)
→ {f : X ⇒ Prod As}
→ {g : X ⇒ Prod Bs}
→ πʳ As Bs ∘ glue As Bs f g ≡ g
commuteʳ { zero} [] Bs {f}{g} = identityˡ
commuteʳ { suc n} (A ∷ As) (B ∷ Bs) {f}{g} = NonEmpty.commuteʳ (A ∷ As) (B ∷ Bs)
commuteʳ { suc zero} (A ∷ []) [] {f}{g} = !-unique₂ (! ∘ f) g
commuteʳ {suc (suc n)} (A ∷ As) [] {f}{g} = !-unique₂ (! ∘ glue (A ∷ As) [] f g) g
.N-universal : {n m : ℕ}{X : Obj}
→ (As : Vec Obj n)
→ (Bs : Vec Obj m)
→ {f : X ⇒ Prod As}
→ {g : X ⇒ Prod Bs}
→ {h : X ⇒ Prod (As ++ Bs) }
→ πˡ As Bs ∘ h ≡ f
→ πʳ As Bs ∘ h ≡ g
→ glue As Bs f g ≡ h
N-universal { zero} [] Bs {f}{g}{h} h-commuteˡ h-commuteʳ = trans (sym h-commuteʳ) identityˡ
N-universal { suc n} (A ∷ As) (B ∷ Bs) {f}{g}{h} h-commuteˡ h-commuteʳ = NonEmpty.N-universal (A ∷ As) (B ∷ Bs) h-commuteˡ h-commuteʳ
N-universal { suc zero} (A ∷ []) [] {f}{g}{h} h-commuteˡ h-commuteʳ = trans (sym h-commuteˡ) identityˡ
N-universal {suc (suc n)} (A ∷ As) [] {f}{g}{h} h-commuteˡ h-commuteʳ =
begin
⟨ π₁ ∘ f , glue As [] (π₂ ∘ f) g ⟩
↓⟨ ⟨⟩-congʳ (N-universal As [] π₂∘h-commuteˡ π₂∘h-commuteʳ) ⟩
⟨ π₁ ∘ f , π₂ ∘ h ⟩
↑⟨ ⟨⟩-congˡ π₁∘h-commuteˡ ⟩
⟨ π₁ ∘ h , π₂ ∘ h ⟩
↓⟨ g-η ⟩
h
∎
where
-- h-commuteˡ : ⟨ π₁ , πˡ As [] ∘ π₂ ⟩ ∘ h ≡ f
-- h-commuteʳ : (πʳ As [] ∘ π₂) ∘ h ≡ g
π₁∘h-commuteˡ : π₁ ∘ h ≡ π₁ ∘ f
π₁∘h-commuteˡ =
begin
π₁ ∘ h
↑⟨ commute₁ ⟩∘⟨ refl ⟩
(π₁ ∘ ⟨ π₁ , πˡ As [] ∘ π₂ ⟩) ∘ h
↓⟨ assoc ⟩
π₁ ∘ ⟨ π₁ , πˡ As [] ∘ π₂ ⟩ ∘ h
↓⟨ refl ⟩∘⟨ h-commuteˡ ⟩
π₁ ∘ f
∎
π₂∘h-commuteˡ : πˡ As [] ∘ π₂ ∘ h ≡ π₂ ∘ f
π₂∘h-commuteˡ =
begin
πˡ As [] ∘ π₂ ∘ h
↑⟨ assoc ⟩
(πˡ As [] ∘ π₂) ∘ h
↑⟨ commute₂ ⟩∘⟨ refl ⟩
(π₂ ∘ ⟨ π₁ , πˡ As [] ∘ π₂ ⟩) ∘ h
↓⟨ assoc ⟩
π₂ ∘ ⟨ π₁ , πˡ As [] ∘ π₂ ⟩ ∘ h
↓⟨ refl ⟩∘⟨ h-commuteˡ ⟩
π₂ ∘ f
∎
π₂∘h-commuteʳ : πʳ As [] ∘ π₂ ∘ h ≡ g
π₂∘h-commuteʳ = !-unique₂ (πʳ As [] ∘ π₂ ∘ h) g
isProduct : {n m : ℕ}
→ (As : Vec Obj n)
→ (Bs : Vec Obj m)
→ Product (Prod As) (Prod Bs)
isProduct {n}{m} As Bs = record
{ A×B = Prod (As ++ Bs)
; π₁ = πˡ As Bs
; π₂ = πʳ As Bs
; ⟨_,_⟩ = glue As Bs
; commute₁ = commuteˡ As Bs
; commute₂ = commuteʳ As Bs
; universal = N-universal As Bs
}
| {
"alphanum_fraction": 0.4885714286,
"avg_line_length": 29.3193717277,
"ext": "agda",
"hexsha": "add755fff0317b85e5f7caef69daf38297e8f4f2",
"lang": "Agda",
"max_forks_count": 23,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z",
"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/Object/Products/N-ary.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "p-pavel/categories",
"max_issues_repo_path": "Categories/Object/Products/N-ary.agda",
"max_line_length": 138,
"max_stars_count": 98,
"max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "copumpkin/categories",
"max_stars_repo_path": "Categories/Object/Products/N-ary.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z",
"num_tokens": 2515,
"size": 5600
} |
-- {-# OPTIONS -v tc.term.args:30 -v tc.meta:50 #-}
module Issue795 where
data Q (A : Set) : Set where
F : (N : Set → Set) → Set₁
F N = (A : Set) → N (Q A) → N A
postulate
N : Set → Set
f : F N
R : (N : Set → Set) → Set
funny-term : ∀ N → (f : F N) → R N
-- This should work now: WAS: "Refuse to construct infinite term".
thing : R N
thing = funny-term _ (λ A → f _)
-- funny-term ?N : F ?N -> R ?N
-- funny-term ?N : ((A : Set) -> ?N (Q A) -> ?N A) -> R ?N
-- A : F ?N |- f (?A A) :=> ?N (Q (?A A)) -> ?N (?A A)
-- |- λ A → f (?A A) <=: (A : Set) -> N (Q A) -> N A
{- What is happening here?
Agda first creates a (closed) meta variable
?N : Set -> Set
Then it checks
λ A → f ? against type F ?N = (A : Set) -> ?N (Q A) -> ?N A
(After what it does now, it still needs to check that
R ?N is a subtype of R N
It would be smart if that was done first.)
In context A : Set, continues to check
f ? against type ?N (Q A) -> ?N A
Since the type of f is F N = (A : Set) -> N (Q A) -> N A, the created meta,
dependent on A : Set is
?A : Set -> Set
and we are left with checking that the inferred type of f (?A A),
N (Q (?A A)) -> N (?A A)
is a subtype of
?N (Q A) -> ?N A
This yields two equations
?N (Q A) = N (Q (?A A))
?N A = N (?A A)
The second one is solved as
?N = λ z → N (?A z)
simpliying the remaining equation to
N (?A (Q A)) = N (Q (?A A))
and further to
?A (Q A) = Q (?A A)
The expected solution is, of course, the identity, but it cannot be
found mechanically from this equation.
At this point, another solution is ?A = Q.
In general, any power of Q is a solution.
If Agda postponed here, it would come to the problem
R ?N = R N
simplified to ?N = N and instantiated to
λ z → N (?A z) = N
This would solve ?A to be the identity.
-}
| {
"alphanum_fraction": 0.5554951034,
"avg_line_length": 20.1978021978,
"ext": "agda",
"hexsha": "1caea53527969f970c7ce4a1da2e1164ca814a02",
"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/Issue795.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/Issue795.agda",
"max_line_length": 75,
"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/Issue795.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": 659,
"size": 1838
} |
module Examples where
open import Prelude
open import Sessions.Syntax
module _ where
open import Relation.Ternary.Separation.Construct.List Type
lets : ∀[ Exp a ⇒ (a ∷_) ⊢ Exp b ─✴ Exp b ]
app (lets e₁) e₂ σ = ap (lam _ e₂ ×⟨ ⊎-comm σ ⟩ e₁)
-- The example from section 2.1 of the paper
ex₁ : Exp unit ε
ex₁ =
letpair (mkchan (unit ! end) ×⟨ ⊎-idʳ ⟩ (
lets (fork
(lam unit
(letpair (recv (var refl) ×⟨ consʳ (consˡ []) ⟩
letunit (letunit (var refl ×⟨ ⊎-∙ ⟩ var refl) ×⟨ consʳ ⊎-idʳ ⟩
(terminate (var refl))))))) $⟨ consʳ (consˡ []) ⟩
(lets (send (unit ×⟨ ⊎-idˡ ⟩ var refl)) $⟨ ⊎-comm ⊎-∙ ⟩
letunit (var refl ×⟨ consʳ ⊎-∙ ⟩ terminate (var refl)))))
module _ where
open import Sessions.Semantics.Expr
open import Sessions.Semantics.Process as P hiding (main)
open import Relation.Ternary.Separation.Construct.Market
open import Relation.Ternary.Separation.Monad.Error
pool₁ : ∃ λ Φ → Except Exc (● St) Φ
pool₁ = start 1000 (P.main comp)
where
comp = app (runReader nil) (eval 1000 ex₁) ⊎-idˡ
open import IO
open import Data.String.Base using (_++_)
open import Codata.Musical.Notation
open import Debug.Trace
open import Data.Sum
open import Relation.Ternary.Separation.Monad.Error
-- to run the main and see the program trace,
-- run 'make examples'
main = run $ ♯ (putStrLn "Hello, World!")
>> ♯ (♯ putStrLn result
>> ♯ putStrLn "done")
where
result = case pool₁ of λ where
(ty , ExceptT.partial (inj₁ e)) → "fail"
(ty , ExceptT.partial (inj₂ v)) → "ok"
| {
"alphanum_fraction": 0.6307498425,
"avg_line_length": 31.1176470588,
"ext": "agda",
"hexsha": "d4d4c3df29653fb13c9b4df039fd0129d4da4b39",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2020-05-23T00:34:36.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-01-30T14:15:14.000Z",
"max_forks_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "laMudri/linear.agda",
"max_forks_repo_path": "src/Examples.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"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": "laMudri/linear.agda",
"max_issues_repo_path": "src/Examples.agda",
"max_line_length": 72,
"max_stars_count": 34,
"max_stars_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "laMudri/linear.agda",
"max_stars_repo_path": "src/Examples.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-03T15:22:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-12-20T13:57:50.000Z",
"num_tokens": 546,
"size": 1587
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category using (Category)
open import Categories.Category.Monoidal.Core using (Monoidal)
-- The tensor product of certain monoidal categories is a monoidal functor.
module Categories.Functor.Monoidal.Tensor {o ℓ e} {C : Category o ℓ e}
{M : Monoidal C} where
open import Data.Product using (_,_)
open import Categories.Category.Product using (Product)
open import Categories.Category.Monoidal.Braided using (Braided)
open import Categories.Category.Monoidal.Symmetric using (Symmetric)
open import Categories.Category.Monoidal.Construction.Product hiding (⊗)
open import Categories.Category.Monoidal.Interchange
open import Categories.Category.Monoidal.Structure
open import Categories.Morphism using (module ≅)
open import Categories.Functor.Monoidal
import Categories.Functor.Monoidal.Braided as BMF
import Categories.Functor.Monoidal.Symmetric as SMF
open import Categories.NaturalTransformation.NaturalIsomorphism
using (NaturalIsomorphism)
open NaturalIsomorphism
private
C-monoidal : MonoidalCategory o ℓ e
C-monoidal = record { U = C; monoidal = M }
C×C = Product C C
C×C-monoidal = Product-MonoidalCategory C-monoidal C-monoidal
open MonoidalCategory C-monoidal
-- By definition, the tensor product ⊗ of a monoidal category C is a
-- binary functor ⊗ : C × C → C. The product category C × C of a
-- monoidal category C is again monoidal. Thus we may ask:
--
-- Is the functor ⊗ a monoidal functor, i.e. does it preserve the
-- monoidal structure in a suitable way (lax or strong)?
--
-- The answer is "yes", provided ⊗ comes equipped with a (coherent)
-- interchange map, aka a "four-middle interchange", which is the case
-- e.g. when C is braided.
module Lax (hasInterchange : HasInterchange M) where
private module interchange = HasInterchange hasInterchange
⊗-isMonoidalFunctor : IsMonoidalFunctor C×C-monoidal C-monoidal ⊗
⊗-isMonoidalFunctor = record
{ ε = unitorˡ.to
; ⊗-homo = F⇒G interchange.naturalIso
; associativity = interchange.assoc
; unitaryˡ = interchange.unitˡ
; unitaryʳ = interchange.unitʳ
}
⊗-MonoidalFunctor : MonoidalFunctor C×C-monoidal C-monoidal
⊗-MonoidalFunctor = record { F = ⊗ ; isMonoidal = ⊗-isMonoidalFunctor }
module LaxBraided (B : Braided M) where
open Lax (BraidedInterchange.hasInterchange B) public
module LaxSymmetric (S : Symmetric M) where
open SymmetricInterchange S
open Lax hasInterchange public
open SymmetricMonoidalCategory using ()
renaming (braidedMonoidalCategory to bmc)
private
C-symmetric : SymmetricMonoidalCategory o ℓ e
C-symmetric = record { symmetric = S }
C×C-symmetric = Product-SymmetricMonoidalCategory C-symmetric C-symmetric
open BMF.Lax (bmc C×C-symmetric) (bmc C-symmetric)
open SMF.Lax C×C-symmetric C-symmetric
⊗-isBraidedMonoidalFunctor : IsBraidedMonoidalFunctor ⊗
⊗-isBraidedMonoidalFunctor = record
{ isMonoidal = ⊗-isMonoidalFunctor
; braiding-compat = swapInner-braiding′
}
⊗-SymmetricMonoidalFunctor : SymmetricMonoidalFunctor
⊗-SymmetricMonoidalFunctor = record
{ isBraidedMonoidal = ⊗-isBraidedMonoidalFunctor }
module Strong (hasInterchange : HasInterchange M) where
private module interchange = HasInterchange hasInterchange
⊗-isMonoidalFunctor : IsStrongMonoidalFunctor C×C-monoidal C-monoidal ⊗
⊗-isMonoidalFunctor = record
{ ε = ≅.sym C unitorˡ
; ⊗-homo = interchange.naturalIso
; associativity = interchange.assoc
; unitaryˡ = interchange.unitˡ
; unitaryʳ = interchange.unitʳ
}
⊗-MonoidalFunctor : StrongMonoidalFunctor C×C-monoidal C-monoidal
⊗-MonoidalFunctor = record { isStrongMonoidal = ⊗-isMonoidalFunctor }
-- TODO: implement the missing bits in Categories.Category.Monoidal.Interchange.
module StrongBraided (B : Braided M) where
open Strong (BraidedInterchange.hasInterchange B) public
module StrongSymmetric (S : Symmetric M) where
open SymmetricInterchange S
open Strong hasInterchange public
open SymmetricMonoidalCategory using ()
renaming (braidedMonoidalCategory to bmc)
private
C-symmetric : SymmetricMonoidalCategory o ℓ e
C-symmetric = record { symmetric = S }
C×C-symmetric = Product-SymmetricMonoidalCategory C-symmetric C-symmetric
open BMF.Strong (bmc C×C-symmetric) (bmc C-symmetric)
open SMF.Strong C×C-symmetric C-symmetric
⊗-isBraidedMonoidalFunctor : IsBraidedMonoidalFunctor ⊗
⊗-isBraidedMonoidalFunctor = record
{ isStrongMonoidal = ⊗-isMonoidalFunctor
; braiding-compat = swapInner-braiding′
}
⊗-SymmetricMonoidalFunctor : SymmetricMonoidalFunctor
⊗-SymmetricMonoidalFunctor = record
{ isBraidedMonoidal = ⊗-isBraidedMonoidalFunctor }
| {
"alphanum_fraction": 0.7472458948,
"avg_line_length": 36.446969697,
"ext": "agda",
"hexsha": "e99dc8cb02ee64d274ba01169d56b3326df09ac9",
"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": "f8a33de12956c729c7fb00a302f166a643eb6052",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "TOTBWF/agda-categories",
"max_forks_repo_path": "src/Categories/Functor/Monoidal/Tensor.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f8a33de12956c729c7fb00a302f166a643eb6052",
"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": "TOTBWF/agda-categories",
"max_issues_repo_path": "src/Categories/Functor/Monoidal/Tensor.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f8a33de12956c729c7fb00a302f166a643eb6052",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "TOTBWF/agda-categories",
"max_stars_repo_path": "src/Categories/Functor/Monoidal/Tensor.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1392,
"size": 4811
} |
{-# OPTIONS --cubical #-}
open import Agda.Builtin.Cubical.Path
data PushOut {A B C : Set} (f : C → A) (g : C → B) : Set where
inl : A → PushOut f g
inr : B → PushOut f g
push : ∀ c → inl (f c) ≡ inr (g c)
squash : ∀ a b → a ≡ b
data ∥_∥₀ (A : Set) : Set where
∣_∣ : A → ∥ A ∥₀
squash : ∀ (x y : ∥ A ∥₀) → (p q : x ≡ y) → p ≡ q
data Segment : Set where
start end : Segment
line : start ≡ end
-- prop truncation
data ∥_∥ (A : Set) : Set where
∣_∣ : A → ∥ A ∥
squash : ∀ (x y : ∥ A ∥) → x ≡ y
elim : ∀ {A : Set} (P : Set) → ((x y : P) → x ≡ y) → (A → P) → ∥ A ∥ → P
elim P Pprop f ∣ x ∣ = f x
elim P Pprop f (squash x y i) = Pprop (elim P Pprop f x) (elim P Pprop f y) i
| {
"alphanum_fraction": 0.4810126582,
"avg_line_length": 27.3461538462,
"ext": "agda",
"hexsha": "4ded3fd061f5569bbdbf29406a245efb5d3eb371",
"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/HITs.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/HITs.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/HITs.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": 329,
"size": 711
} |
-- Andreas, 2014-05-17
open import Common.Prelude
open import Common.Equality
postulate
bla : ∀ x → x ≡ zero
P : Nat → Set
p : P zero
K : ∀{A B : Set} → A → B → A
f : ∀ x → P x
f x rewrite K {x ≡ x} {Nat} refl {!!} = {!!}
-- Expected: two interaction points!
| {
"alphanum_fraction": 0.5503597122,
"avg_line_length": 16.3529411765,
"ext": "agda",
"hexsha": "c86de705e646b98c4bc0d6a71c4046326ab82427",
"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/interaction/Issue1110c.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/interaction/Issue1110c.agda",
"max_line_length": 44,
"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/interaction/Issue1110c.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": 104,
"size": 278
} |
------------------------------------------------------------------------
-- Equivalences with erased "proofs", defined in terms of partly
-- erased contractible fibres
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Equality
module Equivalence.Erased.Contractible-preimages
{reflexive} (eq : ∀ {a p} → Equality-with-J a p reflexive) where
open Derived-definitions-and-properties eq
open import Prelude
open import Bijection eq using (_↔_)
open import Equivalence eq as Eq using (_≃_; Is-equivalence)
import Equivalence.Contractible-preimages eq as CP
open import Erased.Level-1 eq as Erased
hiding (module []-cong; module []-cong₁; module []-cong₂)
open import Function-universe eq hiding (id; _∘_)
open import H-level eq as H-level
open import H-level.Closure eq
open import Preimage eq as Preimage using (_⁻¹_)
open import Surjection eq using (_↠_; Split-surjective)
private
variable
a b ℓ ℓ₁ ℓ₂ : Level
A B : Type a
c ext k k′ p x y : A
P : A → Type p
f : (x : A) → P x
------------------------------------------------------------------------
-- Some basic types
-- "Preimages" with erased proofs.
infix 5 _⁻¹ᴱ_
_⁻¹ᴱ_ : {A : Type a} {@0 B : Type b} → @0 (A → B) → @0 B → Type (a ⊔ b)
f ⁻¹ᴱ y = ∃ λ x → Erased (f x ≡ y)
-- Contractibility with an erased proof.
Contractibleᴱ : Type ℓ → Type ℓ
Contractibleᴱ A = ∃ λ (x : A) → Erased (∀ y → x ≡ y)
-- The property of being an equivalence (with erased proofs).
Is-equivalenceᴱ : {A : Type a} {B : Type b} → @0 (A → B) → Type (a ⊔ b)
Is-equivalenceᴱ f = ∀ y → Contractibleᴱ (f ⁻¹ᴱ y)
-- Equivalences with erased proofs.
_≃ᴱ_ : Type a → Type b → Type (a ⊔ b)
A ≃ᴱ B = ∃ λ (f : A → B) → Is-equivalenceᴱ f
------------------------------------------------------------------------
-- Some conversion lemmas
-- Conversions between _⁻¹_ and _⁻¹ᴱ_.
⁻¹→⁻¹ᴱ :
{@0 A : Type a} {@0 B : Type b} {@0 f : A → B} {@0 y : B} →
f ⁻¹ y → f ⁻¹ᴱ y
⁻¹→⁻¹ᴱ = Σ-map id [_]→
@0 ⁻¹ᴱ→⁻¹ : f ⁻¹ᴱ x → f ⁻¹ x
⁻¹ᴱ→⁻¹ = Σ-map id erased
@0 ⁻¹≃⁻¹ᴱ : f ⁻¹ y ≃ f ⁻¹ᴱ y
⁻¹≃⁻¹ᴱ {f = f} {y = y} =
(∃ λ x → f x ≡ y) ↝⟨ (∃-cong λ _ → Eq.inverse $ Eq.↔⇒≃ $ erased Erased↔) ⟩□
(∃ λ x → Erased (f x ≡ y)) □
_ : _≃_.to ⁻¹≃⁻¹ᴱ p ≡ ⁻¹→⁻¹ᴱ p
_ = refl _
@0 _ : _≃_.from ⁻¹≃⁻¹ᴱ p ≡ ⁻¹ᴱ→⁻¹ p
_ = refl _
-- Conversions between Contractible and Contractibleᴱ.
Contractible→Contractibleᴱ :
{@0 A : Type a} →
Contractible A → Contractibleᴱ A
Contractible→Contractibleᴱ = Σ-map id [_]→
@0 Contractibleᴱ→Contractible : Contractibleᴱ A → Contractible A
Contractibleᴱ→Contractible = Σ-map id erased
@0 Contractible≃Contractibleᴱ :
Contractible A ≃ Contractibleᴱ A
Contractible≃Contractibleᴱ =
(∃ λ x → ∀ y → x ≡ y) ↝⟨ (∃-cong λ _ → Eq.inverse $ Eq.↔⇒≃ $ erased Erased↔) ⟩□
(∃ λ x → Erased (∀ y → x ≡ y)) □
_ :
_≃_.to Contractible≃Contractibleᴱ c ≡ Contractible→Contractibleᴱ c
_ = refl _
@0 _ :
_≃_.from Contractible≃Contractibleᴱ c ≡ Contractibleᴱ→Contractible c
_ = refl _
-- Conversions between CP.Is-equivalence and Is-equivalenceᴱ.
Is-equivalence→Is-equivalenceᴱ :
{@0 A : Type a} {@0 B : Type b} {@0 f : A → B} →
CP.Is-equivalence f → Is-equivalenceᴱ f
Is-equivalence→Is-equivalenceᴱ eq y =
⁻¹→⁻¹ᴱ (proj₁₀ (eq y))
, [ cong ⁻¹→⁻¹ᴱ ∘ proj₂ (eq y) ∘ ⁻¹ᴱ→⁻¹ ]
@0 Is-equivalenceᴱ→Is-equivalence :
Is-equivalenceᴱ f → CP.Is-equivalence f
Is-equivalenceᴱ→Is-equivalence eq y =
⁻¹ᴱ→⁻¹ (proj₁ (eq y))
, cong ⁻¹ᴱ→⁻¹ ∘ erased (proj₂ (eq y)) ∘ ⁻¹→⁻¹ᴱ
private
-- In an erased context CP.Is-equivalence and Is-equivalenceᴱ are
-- pointwise equivalent (assuming extensionality).
--
-- This lemma is not exported. See Is-equivalence≃Is-equivalenceᴱ
-- below, which computes in a different way.
@0 Is-equivalence≃Is-equivalenceᴱ′ :
{A : Type a} {B : Type b} {f : A → B} →
CP.Is-equivalence f ↝[ a ⊔ b ∣ a ⊔ b ] Is-equivalenceᴱ f
Is-equivalence≃Is-equivalenceᴱ′ {a = a} {f = f} {k = k} ext =
(∀ y → Contractible (f ⁻¹ y)) ↝⟨ (∀-cong ext′ λ _ → H-level-cong ext 0 ⁻¹≃⁻¹ᴱ) ⟩
(∀ y → Contractible (f ⁻¹ᴱ y)) ↝⟨ (∀-cong ext′ λ _ → from-isomorphism Contractible≃Contractibleᴱ) ⟩□
(∀ y → Contractibleᴱ (f ⁻¹ᴱ y)) □
where
ext′ = lower-extensionality? k a lzero ext
------------------------------------------------------------------------
-- Some type formers are propositional in erased contexts
-- In an erased context Contractibleᴱ is propositional (assuming
-- extensionality).
@0 Contractibleᴱ-propositional :
{A : Type a} →
Extensionality a a →
Is-proposition (Contractibleᴱ A)
Contractibleᴱ-propositional ext =
H-level.respects-surjection
(_≃_.surjection Contractible≃Contractibleᴱ)
1
(Contractible-propositional ext)
-- In an erased context Is-equivalenceᴱ f is a proposition (assuming
-- extensionality).
--
-- See also Is-equivalenceᴱ-propositional-for-Erased below.
@0 Is-equivalenceᴱ-propositional :
{A : Type a} {B : Type b} →
Extensionality (a ⊔ b) (a ⊔ b) →
(f : A → B) → Is-proposition (Is-equivalenceᴱ f)
Is-equivalenceᴱ-propositional ext f =
H-level.respects-surjection
(_≃_.surjection $ Is-equivalence≃Is-equivalenceᴱ′ ext)
1
(CP.propositional ext f)
------------------------------------------------------------------------
-- More conversion lemmas
-- In an erased context CP.Is-equivalence and Is-equivalenceᴱ are
-- pointwise equivalent (assuming extensionality).
@0 Is-equivalence≃Is-equivalenceᴱ :
{A : Type a} {B : Type b} {f : A → B} →
CP.Is-equivalence f ↝[ a ⊔ b ∣ a ⊔ b ] Is-equivalenceᴱ f
Is-equivalence≃Is-equivalenceᴱ {k = equivalence} ext =
Eq.with-other-function
(Eq.with-other-inverse
(Is-equivalence≃Is-equivalenceᴱ′ ext)
Is-equivalenceᴱ→Is-equivalence
(λ _ → CP.propositional ext _ _ _))
Is-equivalence→Is-equivalenceᴱ
(λ _ → Is-equivalenceᴱ-propositional ext _ _ _)
Is-equivalence≃Is-equivalenceᴱ = Is-equivalence≃Is-equivalenceᴱ′
_ :
_≃_.to (Is-equivalence≃Is-equivalenceᴱ ext) p ≡
Is-equivalence→Is-equivalenceᴱ p
_ = refl _
@0 _ :
_≃_.from (Is-equivalence≃Is-equivalenceᴱ ext) p ≡
Is-equivalenceᴱ→Is-equivalence p
_ = refl _
-- Conversions between CP._≃_ and _≃ᴱ_.
≃→≃ᴱ :
{@0 A : Type a} {@0 B : Type b} →
A CP.≃ B → A ≃ᴱ B
≃→≃ᴱ = Σ-map id Is-equivalence→Is-equivalenceᴱ
@0 ≃ᴱ→≃ : A ≃ᴱ B → A CP.≃ B
≃ᴱ→≃ = Σ-map id Is-equivalenceᴱ→Is-equivalence
-- In an erased context CP._≃_ and _≃ᴱ_ are pointwise equivalent
-- (assuming extensionality).
@0 ≃≃≃ᴱ :
{A : Type a} {B : Type b} →
(A CP.≃ B) ↝[ a ⊔ b ∣ a ⊔ b ] (A ≃ᴱ B)
≃≃≃ᴱ {A = A} {B = B} ext =
A CP.≃ B ↔⟨⟩
(∃ λ f → CP.Is-equivalence f) ↝⟨ (∃-cong λ _ → Is-equivalence≃Is-equivalenceᴱ ext) ⟩
(∃ λ f → Is-equivalenceᴱ f) ↔⟨⟩
A ≃ᴱ B □
_ : _≃_.to (≃≃≃ᴱ ext) p ≡ ≃→≃ᴱ p
_ = refl _
@0 _ : _≃_.from (≃≃≃ᴱ ext) p ≡ ≃ᴱ→≃ p
_ = refl _
-- An isomorphism relating _⁻¹ᴱ_ to _⁻¹_.
Erased-⁻¹ᴱ↔Erased-⁻¹ :
{@0 A : Type a} {@0 B : Type b} {@0 f : A → B} {@0 y : B} →
Erased (f ⁻¹ᴱ y) ↔ Erased (f ⁻¹ y)
Erased-⁻¹ᴱ↔Erased-⁻¹ {f = f} {y = y} =
Erased (∃ λ x → Erased (f x ≡ y)) ↝⟨ Erased-Σ↔Σ ⟩
(∃ λ x → Erased (Erased (f (erased x) ≡ y))) ↝⟨ (∃-cong λ _ → Erased-Erased↔Erased) ⟩
(∃ λ x → Erased (f (erased x) ≡ y)) ↝⟨ inverse Erased-Σ↔Σ ⟩□
Erased (∃ λ x → f x ≡ y) □
-- An isomorphism relating Contractibleᴱ to Contractible.
Erased-Contractibleᴱ↔Erased-Contractible :
{@0 A : Type a} →
Erased (Contractibleᴱ A) ↔ Erased (Contractible A)
Erased-Contractibleᴱ↔Erased-Contractible =
Erased (∃ λ x → Erased (∀ y → x ≡ y)) ↝⟨ Erased-Σ↔Σ ⟩
(∃ λ x → Erased (Erased (∀ y → erased x ≡ y))) ↝⟨ (∃-cong λ _ → Erased-Erased↔Erased) ⟩
(∃ λ x → Erased (∀ y → erased x ≡ y)) ↝⟨ inverse Erased-Σ↔Σ ⟩□
Erased (∃ λ x → ∀ y → x ≡ y) □
------------------------------------------------------------------------
-- Some results related to Contractibleᴱ
-- Contractibleᴱ respects split surjections with erased proofs.
Contractibleᴱ-respects-surjection :
{@0 A : Type a} {@0 B : Type b}
(f : A → B) → @0 Split-surjective f →
Contractibleᴱ A → Contractibleᴱ B
Contractibleᴱ-respects-surjection {A = A} {B = B} f s h@(x , _) =
f x
, [ proj₂ (H-level.respects-surjection surj 0
(Contractibleᴱ→Contractible h))
]
where
@0 surj : A ↠ B
surj = record
{ logical-equivalence = record
{ to = f
; from = proj₁ ∘ s
}
; right-inverse-of = proj₂ ∘ s
}
-- "Preimages" (with erased proofs) of an erased function with a
-- quasi-inverse with erased proofs are contractible.
Contractibleᴱ-⁻¹ᴱ :
{@0 A : Type a} {@0 B : Type b}
(@0 f : A → B)
(g : B → A)
(@0 f∘g : ∀ x → f (g x) ≡ x)
(@0 g∘f : ∀ x → g (f x) ≡ x) →
∀ y → Contractibleᴱ (f ⁻¹ᴱ y)
Contractibleᴱ-⁻¹ᴱ {A = A} {B = B} f g f∘g g∘f y =
(g y , [ proj₂ (proj₁ c′) ])
, [ cong ⁻¹→⁻¹ᴱ ∘ proj₂ c′ ∘ ⁻¹ᴱ→⁻¹ ]
where
@0 A↔B : A ↔ B
A↔B = record
{ surjection = record
{ logical-equivalence = record
{ to = f
; from = g
}
; right-inverse-of = f∘g
}
; left-inverse-of = g∘f
}
@0 c′ : Contractible (f ⁻¹ y)
c′ = Preimage.bijection⁻¹-contractible A↔B y
-- If an inhabited type comes with an erased proof of
-- propositionality, then it is contractible (with erased proofs).
inhabited→Is-proposition→Contractibleᴱ :
{@0 A : Type a} →
A → @0 Is-proposition A → Contractibleᴱ A
inhabited→Is-proposition→Contractibleᴱ x prop = (x , [ prop x ])
-- Some closure properties.
Contractibleᴱ-Σ :
{@0 A : Type a} {@0 P : A → Type p} →
Contractibleᴱ A → (∀ x → Contractibleᴱ (P x)) → Contractibleᴱ (Σ A P)
Contractibleᴱ-Σ cA@(a , _) cP =
(a , proj₁₀ (cP a))
, [ proj₂ $ Σ-closure 0 (Contractibleᴱ→Contractible cA)
(Contractibleᴱ→Contractible ∘ cP)
]
Contractibleᴱ-× :
{@0 A : Type a} {@0 B : Type b} →
Contractibleᴱ A → Contractibleᴱ B → Contractibleᴱ (A × B)
Contractibleᴱ-× cA cB = Contractibleᴱ-Σ cA (λ _ → cB)
Contractibleᴱ-Π :
{@0 A : Type a} {@0 P : A → Type p} →
@0 Extensionality a p →
(∀ x → Contractibleᴱ (P x)) → Contractibleᴱ ((x : A) → P x)
Contractibleᴱ-Π ext c =
proj₁₀ ∘ c
, [ proj₂ $ Π-closure ext 0 (Contractibleᴱ→Contractible ∘ c)
]
Contractibleᴱ-↑ :
{@0 A : Type a} →
Contractibleᴱ A → Contractibleᴱ (↑ ℓ A)
Contractibleᴱ-↑ c@(a , _) =
lift a
, [ proj₂ $ ↑-closure 0 (Contractibleᴱ→Contractible c)
]
------------------------------------------------------------------------
-- Results that follow if the []-cong axioms hold for one universe
-- level
module []-cong₁ (ax : []-cong-axiomatisation ℓ) where
open Erased-cong ax ax
open Erased.[]-cong₁ ax
----------------------------------------------------------------------
-- Some results related to _⁻¹ᴱ_
-- The function _⁻¹ᴱ y respects erased extensional equality.
⁻¹ᴱ-respects-extensional-equality :
{@0 B : Type ℓ} {@0 f g : A → B} {@0 y : B} →
@0 (∀ x → f x ≡ g x) → f ⁻¹ᴱ y ≃ g ⁻¹ᴱ y
⁻¹ᴱ-respects-extensional-equality {f = f} {g = g} {y = y} f≡g =
(∃ λ x → Erased (f x ≡ y)) ↝⟨ (∃-cong λ _ → Erased-cong-≃ (≡⇒↝ _ (cong (_≡ _) $ f≡g _))) ⟩□
(∃ λ x → Erased (g x ≡ y)) □
-- An isomorphism relating _⁻¹ᴱ_ to _⁻¹_.
⁻¹ᴱ[]↔⁻¹[] :
{@0 B : Type ℓ} {f : A → Erased B} {@0 y : B} →
f ⁻¹ᴱ [ y ] ↔ f ⁻¹ [ y ]
⁻¹ᴱ[]↔⁻¹[] {f = f} {y = y} =
(∃ λ x → Erased (f x ≡ [ y ])) ↔⟨ (∃-cong λ _ → Erased-cong-≃ (Eq.≃-≡ $ Eq.↔⇒≃ $ inverse $ erased Erased↔)) ⟩
(∃ λ x → Erased (erased (f x) ≡ y)) ↝⟨ (∃-cong λ _ → Erased-≡↔[]≡[]) ⟩□
(∃ λ x → f x ≡ [ y ]) □
-- Erased "commutes" with _⁻¹ᴱ_.
Erased-⁻¹ᴱ :
{@0 A : Type a} {@0 B : Type ℓ} {@0 f : A → B} {@0 y : B} →
Erased (f ⁻¹ᴱ y) ↔ map f ⁻¹ᴱ [ y ]
Erased-⁻¹ᴱ {f = f} {y = y} =
Erased (f ⁻¹ᴱ y) ↝⟨ Erased-⁻¹ᴱ↔Erased-⁻¹ ⟩
Erased (f ⁻¹ y) ↝⟨ Erased-⁻¹ ⟩
map f ⁻¹ [ y ] ↝⟨ inverse ⁻¹ᴱ[]↔⁻¹[] ⟩□
map f ⁻¹ᴱ [ y ] □
----------------------------------------------------------------------
-- Some results related to Contractibleᴱ
-- Erased commutes with Contractibleᴱ.
Erased-Contractibleᴱ↔Contractibleᴱ-Erased :
{@0 A : Type ℓ} →
Erased (Contractibleᴱ A) ↝[ ℓ ∣ ℓ ]ᴱ Contractibleᴱ (Erased A)
Erased-Contractibleᴱ↔Contractibleᴱ-Erased {A = A} ext =
Erased (∃ λ x → Erased ((y : A) → x ≡ y)) ↔⟨ Erased-cong-↔ (∃-cong λ _ → erased Erased↔) ⟩
Erased (∃ λ x → (y : A) → x ≡ y) ↔⟨ Erased-Σ↔Σ ⟩
(∃ λ x → Erased ((y : A) → erased x ≡ y)) ↝⟨ (∃-cong λ _ →
Erased-cong?
(λ ext → ∀-cong ext λ _ →
from-isomorphism (inverse $ erased Erased↔))
ext) ⟩
(∃ λ x → Erased ((y : A) → Erased (erased x ≡ y))) ↝⟨ (∃-cong λ _ →
Erased-cong?
(λ ext → Π-cong ext (inverse $ erased Erased↔) λ _ →
from-isomorphism Erased-≡↔[]≡[])
ext) ⟩□
(∃ λ x → Erased ((y : Erased A) → x ≡ y)) □
-- An isomorphism relating Contractibleᴱ to Contractible.
Contractibleᴱ-Erased↔Contractible-Erased :
{@0 A : Type ℓ} →
Contractibleᴱ (Erased A) ↝[ ℓ ∣ ℓ ] Contractible (Erased A)
Contractibleᴱ-Erased↔Contractible-Erased {A = A} ext =
Contractibleᴱ (Erased A) ↝⟨ inverse-erased-ext? Erased-Contractibleᴱ↔Contractibleᴱ-Erased ext ⟩
Erased (Contractibleᴱ A) ↔⟨ Erased-Contractibleᴱ↔Erased-Contractible ⟩
Erased (Contractible A) ↝⟨ Erased-H-level↔H-level 0 ext ⟩□
Contractible (Erased A) □
------------------------------------------------------------------------
-- Results that follow if the []-cong axioms hold for two universe
-- levels
module []-cong₂
(ax₁ : []-cong-axiomatisation ℓ₁)
(ax₂ : []-cong-axiomatisation ℓ₂)
where
open Erased-cong ax₁ ax₂
----------------------------------------------------------------------
-- A result related to Contractibleᴱ
-- Contractibleᴱ preserves isomorphisms (assuming extensionality).
Contractibleᴱ-cong :
{A : Type ℓ₁} {B : Type ℓ₂} →
@0 Extensionality? k′ (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂) →
A ↔[ k ] B → Contractibleᴱ A ↝[ k′ ] Contractibleᴱ B
Contractibleᴱ-cong {A = A} {B = B} ext A↔B =
(∃ λ (x : A) → Erased ((y : A) → x ≡ y)) ↝⟨ (Σ-cong A≃B′ λ _ →
Erased-cong?
(λ ext → Π-cong ext A≃B′ λ _ →
from-isomorphism $ inverse $ Eq.≃-≡ A≃B′)
ext) ⟩□
(∃ λ (x : B) → Erased ((y : B) → x ≡ y)) □
where
A≃B′ = from-isomorphism A↔B
------------------------------------------------------------------------
-- Results that follow if the []-cong axioms hold for all universe
-- levels
module []-cong (ax : ∀ {ℓ} → []-cong-axiomatisation ℓ) where
private
open module BC₁ {ℓ} =
[]-cong₁ (ax {ℓ = ℓ})
public
open module BC₂ {ℓ₁ ℓ₂} =
[]-cong₂ (ax {ℓ = ℓ₁}) (ax {ℓ = ℓ₂})
public
| {
"alphanum_fraction": 0.5240236382,
"avg_line_length": 33.5517241379,
"ext": "agda",
"hexsha": "38e92b837bb6cf873f0298596d98230f974f932a",
"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": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/equality",
"max_forks_repo_path": "src/Equivalence/Erased/Contractible-preimages.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"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/equality",
"max_issues_repo_path": "src/Equivalence/Erased/Contractible-preimages.agda",
"max_line_length": 119,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/equality",
"max_stars_repo_path": "src/Equivalence/Erased/Contractible-preimages.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z",
"num_tokens": 6048,
"size": 15568
} |
------------------------------------------------------------------------------
-- Testing the translation of the propositional functions
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module PropositionalFunction4 where
------------------------------------------------------------------------------
postulate
D : Set
f : D → D
a : D
_≡_ : D → D → Set
A : D → Set
A x = f x ≡ f x
{-# ATP definition A #-}
-- In this case the propositional function uses functions.
postulate foo : A a → A a
{-# ATP prove foo #-}
| {
"alphanum_fraction": 0.387755102,
"avg_line_length": 27.2222222222,
"ext": "agda",
"hexsha": "72de5a4e541b619cc319655502776a7b233da300",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z",
"max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/apia",
"max_forks_repo_path": "test/Succeed/fol-theorems/PropositionalFunction4.agda",
"max_issues_count": 121,
"max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/apia",
"max_issues_repo_path": "test/Succeed/fol-theorems/PropositionalFunction4.agda",
"max_line_length": 78,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/apia",
"max_stars_repo_path": "test/Succeed/fol-theorems/PropositionalFunction4.agda",
"max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z",
"num_tokens": 137,
"size": 735
} |
{-# OPTIONS --cubical --no-import-sorts --safe --guardedness #-}
module Cubical.DStructures.Experiments where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.Path
open import Cubical.Functions.FunExtEquiv
open import Cubical.Homotopy.Base
open import Cubical.Data.Sigma
open import Cubical.Data.Unit
open import Cubical.Data.Maybe
open import Cubical.Relation.Binary
open import Cubical.Structures.Subtype
open import Cubical.Structures.LeftAction
open import Cubical.Algebra.Group
open import Cubical.Algebra.Group.Semidirect
-- this file also serves as Everything.agda
open import Cubical.DStructures.Base
open import Cubical.DStructures.Meta.Properties
open import Cubical.DStructures.Meta.Isomorphism
open import Cubical.DStructures.Structures.Action
open import Cubical.DStructures.Structures.Category
open import Cubical.DStructures.Structures.Constant
open import Cubical.DStructures.Structures.Group
-- open import Cubical.DStructures.Structures.Higher
open import Cubical.DStructures.Structures.Nat
open import Cubical.DStructures.Structures.PeifferGraph
open import Cubical.DStructures.Structures.ReflGraph
open import Cubical.DStructures.Structures.SplitEpi
open import Cubical.DStructures.Structures.Strict2Group
open import Cubical.DStructures.Structures.Type
-- open import Cubical.DStructures.Structures.Universe
open import Cubical.DStructures.Structures.VertComp
open import Cubical.DStructures.Structures.XModule
open import Cubical.DStructures.Equivalences.GroupSplitEpiAction
open import Cubical.DStructures.Equivalences.PreXModReflGraph
open import Cubical.DStructures.Equivalences.XModPeifferGraph
open import Cubical.DStructures.Equivalences.PeifferGraphS2G
private
variable
ℓ ℓ' ℓ'' ℓ₁ ℓ₁' ℓ₁'' ℓ₂ ℓA ℓA' ℓ≅A ℓ≅A' ℓB ℓB' ℓ≅B ℓC ℓ≅C ℓ≅ᴰ ℓ≅ᴰ' ℓ≅B' : Level
open Kernel
open GroupHom -- such .fun!
open GroupLemmas
open MorphismLemmas
{-
record Hom-𝒮 {A : Type ℓA} {ℓ≅A : Level} (𝒮-A : URGStr A ℓ≅A)
{B : Type ℓB} {ℓ≅B : Level} (𝒮-B : URGStr B ℓ≅B)
: Type (ℓ-max (ℓ-max ℓA ℓB) (ℓ-max ℓ≅A ℓ≅B)) where
constructor hom-𝒮
open URGStr
field
fun : A → B
fun-≅ : {a a' : A} → (p : _≅_ 𝒮-A a a') → _≅_ 𝒮-B (fun a) (fun a')
fun-ρ : {a : A} → fun-≅ (ρ 𝒮-A a) ≡ ρ 𝒮-B (fun a)
∫𝒮ᴰ-π₁ : {A : Type ℓA} {𝒮-A : URGStr A ℓ≅A}
{B : A → Type ℓB} (𝒮ᴰ-B : URGStrᴰ 𝒮-A B ℓ≅B)
→ Hom-𝒮 (∫⟨ 𝒮-A ⟩ 𝒮ᴰ-B) 𝒮-A
Hom-𝒮.fun (∫𝒮ᴰ-π₁ 𝒮ᴰ-B) = fst
Hom-𝒮.fun-≅ (∫𝒮ᴰ-π₁ 𝒮ᴰ-B) = fst
Hom-𝒮.fun-ρ (∫𝒮ᴰ-π₁ 𝒮ᴰ-B) = refl
module _ {ℓ : Level} {A : Type ℓ} (𝒮-A : URGStr A ℓ) where
𝒮ᴰ-toHom : Iso (Σ[ B ∈ (A → Type ℓ) ] (URGStrᴰ 𝒮-A B ℓ)) (Σ[ B ∈ (Type ℓ) ] Σ[ 𝒮-B ∈ (URGStr B ℓ) ] (Hom-𝒮 𝒮-B 𝒮-A))
Iso.fun 𝒮ᴰ-toHom (B , 𝒮ᴰ-B) = (Σ[ a ∈ A ] B a) , {!!} , {!!}
Iso.inv 𝒮ᴰ-toHom (B , 𝒮ᴰ-B , F) = (λ a → Σ[ b ∈ B ] F .fun b ≡ a) , {!!}
where
open Hom-𝒮
Iso.leftInv 𝒮ᴰ-toHom (B , 𝒮ᴰ-B) = ΣPathP ((funExt (λ a → {!!})) , {!!})
Iso.rightInv 𝒮ᴰ-toHom (B , 𝒮ᴰ-B , F) = {!!}
-}
-- Older Experiments --
-- needs --guardedness flag
module _ where
record Hierarchy {A : Type ℓ} (𝒮-A : URGStr A ℓ) : Type (ℓ-suc ℓ) where
coinductive
field
B : A → Type ℓ
𝒮ᴰ-B : URGStrᴰ 𝒮-A B ℓ
ℋ : Maybe (Hierarchy {A = Σ A B} (∫⟨ 𝒮-A ⟩ 𝒮ᴰ-B))
| {
"alphanum_fraction": 0.6952965235,
"avg_line_length": 30.8378378378,
"ext": "agda",
"hexsha": "1139e52a1edf95efa105f3fcf0b7e2d5189a58c0",
"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": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Schippmunk/cubical",
"max_forks_repo_path": "Cubical/DStructures/Experiments.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"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": "Schippmunk/cubical",
"max_issues_repo_path": "Cubical/DStructures/Experiments.agda",
"max_line_length": 118,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Schippmunk/cubical",
"max_stars_repo_path": "Cubical/DStructures/Experiments.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1385,
"size": 3423
} |
module Issue357 where
module M (X : Set) where
data R : Set where
r : X → R
postulate
P Q : Set
q : Q
open M P
open M.R
works : M.R Q
works = M.R.r q
fails : M.R Q
fails = r q
| {
"alphanum_fraction": 0.5692307692,
"avg_line_length": 9.2857142857,
"ext": "agda",
"hexsha": "c4d4874d4f3f534abf528e725021019d5465b9bf",
"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/Issue357.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/Issue357.agda",
"max_line_length": 24,
"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/Issue357.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": 76,
"size": 195
} |
{-# OPTIONS --without-K --rewriting #-}
open import lib.Basics
open import lib.types.Coproduct
open import lib.types.Paths
open import lib.types.Pointed
open import lib.types.Pushout
open import lib.types.PushoutFlattening
open import lib.types.PushoutFmap
open import lib.types.Span
open import lib.types.Unit
-- Wedge of two pointed types is defined as a particular case of pushout
module lib.types.Wedge where
module _ {i j} (X : Ptd i) (Y : Ptd j) where
wedge-span : Span
wedge-span = span (de⊙ X) (de⊙ Y) Unit (λ _ → pt X) (λ _ → pt Y)
Wedge : Type (lmax i j)
Wedge = Pushout wedge-span
infix 80 _∨_
_∨_ = Wedge
module _ {i j} {X : Ptd i} {Y : Ptd j} where
winl : de⊙ X → X ∨ Y
winl x = left x
winr : de⊙ Y → X ∨ Y
winr y = right y
wglue : winl (pt X) == winr (pt Y)
wglue = glue tt
module _ {i j} (X : Ptd i) (Y : Ptd j) where
⊙Wedge : Ptd (lmax i j)
⊙Wedge = ⊙[ Wedge X Y , winl (pt X) ]
infix 80 _⊙∨_
_⊙∨_ = ⊙Wedge
module _ {i j} {X : Ptd i} {Y : Ptd j} where
⊙winl : X ⊙→ X ⊙∨ Y
⊙winl = (winl , idp)
⊙winr : Y ⊙→ X ⊙∨ Y
⊙winr = (winr , ! wglue)
module _ {i j} {X : Ptd i} {Y : Ptd j} where
module WedgeElim {k} {P : X ∨ Y → Type k}
(inl* : (x : de⊙ X) → P (winl x)) (inr* : (y : de⊙ Y) → P (winr y))
(glue* : inl* (pt X) == inr* (pt Y) [ P ↓ wglue ]) where
private
module M = PushoutElim inl* inr* (λ _ → glue*)
f = M.f
glue-β = M.glue-β unit
open WedgeElim public using () renaming (f to Wedge-elim)
module WedgeRec {k} {C : Type k} (inl* : de⊙ X → C) (inr* : de⊙ Y → C)
(glue* : inl* (pt X) == inr* (pt Y)) where
private
module M = PushoutRec {d = wedge-span X Y} inl* inr* (λ _ → glue*)
f = M.f
glue-β = M.glue-β unit
open WedgeRec public using () renaming (f to Wedge-rec)
module ⊙WedgeRec {i j k} {X : Ptd i} {Y : Ptd j} {Z : Ptd k}
(g : X ⊙→ Z) (h : Y ⊙→ Z) where
open WedgeRec (fst g) (fst h) (snd g ∙ ! (snd h)) public
⊙f : X ⊙∨ Y ⊙→ Z
⊙f = (f , snd g)
⊙winl-β : ⊙f ⊙∘ ⊙winl == g
⊙winl-β = idp
⊙winr-β : ⊙f ⊙∘ ⊙winr == h
⊙winr-β = ⊙λ= (λ _ → idp) $
ap (_∙ snd g)
(ap-! f wglue ∙ ap ! glue-β ∙ !-∙ (snd g) (! (snd h)))
∙ ∙-assoc (! (! (snd h))) (! (snd g)) (snd g)
∙ ap (! (! (snd h)) ∙_) (!-inv-l (snd g))
∙ ∙-unit-r (! (! (snd h)))
∙ !-! (snd h)
⊙Wedge-rec = ⊙WedgeRec.⊙f
⊙Wedge-rec-post∘ : ∀ {i j k l} {X : Ptd i} {Y : Ptd j} {Z : Ptd k} {W : Ptd l}
(k : Z ⊙→ W) (g : X ⊙→ Z) (h : Y ⊙→ Z)
→ k ⊙∘ ⊙Wedge-rec g h == ⊙Wedge-rec (k ⊙∘ g) (k ⊙∘ h)
⊙Wedge-rec-post∘ k g h = ⊙λ=
(Wedge-elim (λ _ → idp) (λ _ → idp)
(↓-='-in' $ ⊙WedgeRec.glue-β (k ⊙∘ g) (k ⊙∘ h)
∙ lemma (fst k) (snd g) (snd h) (snd k)
∙ ! (ap (ap (fst k)) (⊙WedgeRec.glue-β g h))
∙ ∘-ap (fst k) (fst (⊙Wedge-rec g h)) wglue))
idp
where
lemma : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {x y z : A} {w : B}
(p : x == z) (q : y == z) (r : f z == w)
→ (ap f p ∙ r) ∙ ! (ap f q ∙ r) == ap f (p ∙ ! q)
lemma f idp idp idp = idp
⊙Wedge-rec-η : ∀ {i j} {X : Ptd i} {Y : Ptd j}
→ ⊙Wedge-rec ⊙winl ⊙winr == ⊙idf (X ⊙∨ Y)
⊙Wedge-rec-η = ⊙λ=
(Wedge-elim (λ _ → idp) (λ _ → idp)
(↓-='-in' $ ap-idf wglue
∙ ! (!-! wglue)
∙ ! (⊙WedgeRec.glue-β ⊙winl ⊙winr)))
idp
module _ {i j} {X : Ptd i} {Y : Ptd j} where
add-wglue : de⊙ (X ⊙⊔ Y) → X ∨ Y
add-wglue (inl x) = winl x
add-wglue (inr y) = winr y
⊙add-wglue : X ⊙⊔ Y ⊙→ X ⊙∨ Y
⊙add-wglue = add-wglue , idp
module Fold {i} {X : Ptd i} = ⊙WedgeRec (⊙idf X) (⊙idf X)
fold = Fold.f
⊙fold = Fold.⊙f
module _ {i j} (X : Ptd i) (Y : Ptd j) where
module Projl = ⊙WedgeRec (⊙idf X) (⊙cst {X = Y})
module Projr = ⊙WedgeRec (⊙cst {X = X}) (⊙idf Y)
projl = Projl.f
projr = Projr.f
⊙projl = Projl.⊙f
⊙projr = Projr.⊙f
module _ {i i' j j'} {X : Ptd i} {X' : Ptd i'} {Y : Ptd j} {Y' : Ptd j'}
(eqX : X ⊙≃ X') (eqY : Y ⊙≃ Y') where
wedge-span-emap : SpanEquiv (wedge-span X Y) (wedge-span X' Y')
wedge-span-emap = ( span-map (fst (fst eqX)) (fst (fst eqY)) (idf _)
(comm-sqr λ _ → snd (fst eqX))
(comm-sqr λ _ → snd (fst eqY))
, snd eqX , snd eqY , idf-is-equiv _)
∨-emap : X ∨ Y ≃ X' ∨ Y'
∨-emap = Pushout-emap wedge-span-emap
⊙∨-emap : X ⊙∨ Y ⊙≃ X' ⊙∨ Y'
⊙∨-emap = ≃-to-⊙≃ ∨-emap (ap winl (snd (fst eqX)))
| {
"alphanum_fraction": 0.4954627949,
"avg_line_length": 26.8780487805,
"ext": "agda",
"hexsha": "416becf895a38ad44c9d7aa9c062750a6f2ae9e5",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mikeshulman/HoTT-Agda",
"max_forks_repo_path": "core/lib/types/Wedge.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"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": "mikeshulman/HoTT-Agda",
"max_issues_repo_path": "core/lib/types/Wedge.agda",
"max_line_length": 78,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mikeshulman/HoTT-Agda",
"max_stars_repo_path": "core/lib/types/Wedge.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2106,
"size": 4408
} |
module _ where
infix -1 _■
infixr -2 step-∼
postulate
Transitive : {A : Set} (P Q : A → A → Set) → Set
step-∼ : ∀ {A} {P Q : A → A → Set}
⦃ t : Transitive P Q ⦄ x {y z} →
Q y z → P x y → Q x z
syntax step-∼ x Qyz Pxy = x ∼⟨ Pxy ⟩ Qyz
infix 4 _≈_
postulate
Proc : Set
_≈_ : Proc → Proc → Set
_■ : ∀ x → x ≈ x
instance trans : Transitive _≈_ _≈_
module DummyInstances where
postulate
R₁ R₂ R₃ R₄ R₅ : Proc → Proc → Set
postulate
instance
transitive₁₁ : Transitive R₁ R₁
transitive₁₂ : Transitive R₁ R₂
transitive₁₃ : Transitive R₁ R₃
transitive₁₄ : Transitive R₁ R₄
transitive₁₅ : Transitive R₁ R₅
transitive₂₁ : Transitive R₂ R₁
transitive₂₂ : Transitive R₂ R₂
transitive₂₃ : Transitive R₂ R₃
transitive₂₄ : Transitive R₂ R₄
transitive₂₅ : Transitive R₂ R₅
transitive₃₁ : Transitive R₃ R₁
transitive₃₂ : Transitive R₃ R₂
transitive₃₃ : Transitive R₃ R₃
transitive₃₄ : Transitive R₃ R₄
transitive₃₅ : Transitive R₃ R₅
transitive₄₁ : Transitive R₄ R₁
transitive₄₂ : Transitive R₄ R₂
transitive₄₃ : Transitive R₄ R₃
transitive₄₄ : Transitive R₄ R₄
transitive₄₅ : Transitive R₄ R₅
transitive₅₁ : Transitive R₅ R₁
transitive₅₂ : Transitive R₅ R₂
transitive₅₃ : Transitive R₅ R₃
transitive₅₄ : Transitive R₅ R₄
transitive₅₅ : Transitive R₅ R₅
postulate
comm : ∀ {P} → P ≈ P
P : Proc
cong : P ≈ P
cong =
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ∼⟨ comm ⟩
P ■
| {
"alphanum_fraction": 0.5768386389,
"avg_line_length": 21.6904761905,
"ext": "agda",
"hexsha": "4e50e3e14843875b4a09b6d3b022ceaafb4e6cdc",
"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/Issue3435.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/Issue3435.agda",
"max_line_length": 50,
"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/Issue3435.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": 851,
"size": 1822
} |
{-# OPTIONS --rewriting #-}
-- Syntax
open import Library
module Derivations (Base : Set) where
import Formulas; private open module Form = Formulas Base
-- open import Formulas Base public
-- Derivations
infix 2 _⊢_
data _⊢_ (Γ : Cxt) : (A : Form) → Set where
hyp : ∀{A} (x : Hyp A Γ) → Γ ⊢ A
impI : ∀{A B} (t : Γ ∙ A ⊢ B) → Γ ⊢ A ⇒ B
impE : ∀{A B} (t : Γ ⊢ A ⇒ B) (u : Γ ⊢ A) → Γ ⊢ B
andI : ∀{A B} (t : Γ ⊢ A) (u : Γ ⊢ B) → Γ ⊢ A ∧ B
andE₁ : ∀{A B} (t : Γ ⊢ A ∧ B) → Γ ⊢ A
andE₂ : ∀{A B} (t : Γ ⊢ A ∧ B) → Γ ⊢ B
orI₁ : ∀{A B} (t : Γ ⊢ A) → Γ ⊢ A ∨ B
orI₂ : ∀{A B} (t : Γ ⊢ B) → Γ ⊢ A ∨ B
orE : ∀{A B C} (t : Γ ⊢ A ∨ B) (u : Γ ∙ A ⊢ C) (v : Γ ∙ B ⊢ C) → Γ ⊢ C
falseE : ∀{C} (t : Γ ⊢ False) → Γ ⊢ C
trueI : Γ ⊢ True
-- Example derivation
andComm : ∀{A B} → ε ⊢ A ∧ B ⇒ B ∧ A
andComm = impI (andI (andE₂ (hyp top)) (andE₁ (hyp top)))
-- Weakening
Tm = λ A Γ → Γ ⊢ A
monD : ∀{A} → Mon (Tm A)
monD τ (hyp x) = hyp (monH τ x)
monD τ (impI t) = impI (monD (lift τ) t)
monD τ (impE t u) = impE (monD τ t) (monD τ u)
monD τ (andI t u) = andI (monD τ t) (monD τ u)
monD τ (andE₁ t) = andE₁ (monD τ t)
monD τ (andE₂ t) = andE₂ (monD τ t)
monD τ (orI₁ t) = orI₁ (monD τ t)
monD τ (orI₂ t) = orI₂ (monD τ t)
monD τ (orE t u v) = orE (monD τ t) (monD (lift τ) u) (monD (lift τ) v)
monD τ (falseE t) = falseE (monD τ t)
monD τ trueI = trueI
monD-id : ∀{Γ A} (t : Γ ⊢ A) → monD id≤ t ≡ t
monD-id (hyp x) = refl
monD-id (impI t) = cong impI (monD-id t) -- REWRITE lift-id≤
monD-id (impE t u) = cong₂ impE (monD-id t) (monD-id u)
monD-id (andI t u) = cong₂ andI (monD-id t) (monD-id u)
monD-id (andE₁ t) = cong andE₁ (monD-id t)
monD-id (andE₂ t) = cong andE₂ (monD-id t)
monD-id (orI₁ t) = cong orI₁ (monD-id t)
monD-id (orI₂ t) = cong orI₂ (monD-id t)
monD-id (orE t u v) = cong₃ orE (monD-id t) (monD-id u) (monD-id v)
monD-id (falseE t) = cong falseE (monD-id t)
monD-id trueI = refl
-- For normal forms, we use the standard presentation.
-- Normal forms are not unique.
-- Normality as predicate
mutual
data Neutral {Γ} {A} : (t : Γ ⊢ A) → Set where
hyp : (x : Hyp A Γ) → Neutral (hyp x)
impE : ∀{B} {t : Γ ⊢ B ⇒ A} {u : Γ ⊢ B} (ne : Neutral t) (nf : Normal u) → Neutral (impE t u)
andE₁ : ∀{B} {t : Γ ⊢ A ∧ B} (ne : Neutral t) → Neutral (andE₁ t)
andE₂ : ∀{B} {t : Γ ⊢ B ∧ A} (ne : Neutral t) → Neutral (andE₂ t)
data Normal {Γ} : ∀{A} (t : Γ ⊢ A) → Set where
ne : ∀{A} {t : Γ ⊢ A} (ne : Neutral t) → Normal t
impI : ∀{A B} (t : Γ ∙ A ⊢ B) (nf : Normal t) → Normal (impI t)
andI : ∀{A B} (t : Γ ⊢ A) (u : Γ ⊢ B) (nf₁ : Normal t) (nf₂ : Normal u) → Normal (andI t u)
orI₁ : ∀{A B} {t : Γ ⊢ A} (nf : Normal t) → Normal (orI₁ {Γ} {A} {B} t)
orI₂ : ∀{A B} {t : Γ ⊢ B} (nf : Normal t) → Normal (orI₂ {Γ} {A} {B} t)
orE : ∀{A B C} {t : Γ ⊢ A ∨ B} {u : Γ ∙ A ⊢ C} {v : Γ ∙ B ⊢ C}
(ne : Neutral t) (nf₁ : Normal u) (nf₂ : Normal v) → Normal (orE t u v)
falseE : ∀{A} {t : Γ ⊢ False} (ne : Neutral t) → Normal (falseE {Γ} {A} t)
trueI : Normal trueI
-- Intrinsic normality
mutual
data Ne (Γ : Cxt) (A : Form) : Set where
hyp : ∀ (x : Hyp A Γ) → Ne Γ A
impE : ∀{B} (t : Ne Γ (B ⇒ A)) (u : Nf Γ B) → Ne Γ A
andE₁ : ∀{B} (t : Ne Γ (A ∧ B)) → Ne Γ A
andE₂ : ∀{B} (t : Ne Γ (B ∧ A)) → Ne Γ A
data Nf (Γ : Cxt) : (A : Form) → Set where
-- ne : ∀{A} (t : Ne Γ A) → Nf Γ A -- allows η-short nfs
ne : ∀{P} (t : Ne Γ (Atom P)) → Nf Γ (Atom P)
impI : ∀{A B} (t : Nf (Γ ∙ A) B) → Nf Γ (A ⇒ B)
andI : ∀{A B} (t : Nf Γ A) (u : Nf Γ B) → Nf Γ (A ∧ B)
orI₁ : ∀{A B} (t : Nf Γ A) → Nf Γ (A ∨ B)
orI₂ : ∀{A B} (t : Nf Γ B) → Nf Γ (A ∨ B)
orE : ∀{A B C} (t : Ne Γ (A ∨ B)) (u : Nf (Γ ∙ A) C) (v : Nf (Γ ∙ B) C) → Nf Γ C
falseE : ∀{A} (t : Ne Γ False) → Nf Γ A
trueI : Nf Γ True
-- Presheaf-friendly argument order
Ne' = λ A Γ → Ne Γ A
Nf' = λ A Γ → Nf Γ A
-- Admissible false-Elimination from a normal proof of false (using case splits)
falseE! : ∀{A} → Nf' False →̇ Nf' A
-- falseE! (ne t) = falseE t -- only for η-short
falseE! (orE t t₁ t₂) = orE t (falseE! t₁) (falseE! t₂)
falseE! (falseE t) = falseE t
-- Ne' and Nf' are presheaves over (Cxt, ≤)
mutual
monNe : ∀{A} → Mon (Ne' A)
monNe τ (hyp x) = hyp (monH τ x)
monNe τ (impE t u) = impE (monNe τ t) (monNf τ u)
monNe τ (andE₁ t) = andE₁ (monNe τ t)
monNe τ (andE₂ t) = andE₂ (monNe τ t)
monNf : ∀{A} → Mon (Nf' A)
monNf τ (ne t) = ne (monNe τ t)
monNf τ (impI t) = impI (monNf (lift τ) t)
monNf τ (andI t u) = andI (monNf τ t) (monNf τ u)
monNf τ (orI₁ t) = orI₁ (monNf τ t)
monNf τ (orI₂ t) = orI₂ (monNf τ t)
monNf τ (orE t u v) = orE (monNe τ t) (monNf (lift τ) u) (monNf (lift τ) v)
monNf τ (falseE t) = falseE (monNe τ t)
monNf τ trueI = trueI
-- Forgetting normality
mutual
ne[_] : ∀{Γ A} (t : Ne Γ A) → Γ ⊢ A
ne[ hyp x ] = hyp x
ne[ impE t u ] = impE ne[ t ] nf[ u ]
ne[ andE₁ t ] = andE₁ ne[ t ]
ne[ andE₂ t ] = andE₂ ne[ t ]
nf[_] : ∀{Γ A} (t : Nf Γ A) → Γ ⊢ A
nf[ ne t ] = ne[ t ]
nf[ impI t ] = impI nf[ t ]
nf[ andI t u ] = andI nf[ t ] nf[ u ]
nf[ orI₁ t ] = orI₁ nf[ t ]
nf[ orI₂ t ] = orI₂ nf[ t ]
nf[ orE t u v ] = orE ne[ t ] nf[ u ] nf[ v ]
nf[ falseE t ] = falseE ne[ t ]
nf[ trueI ] = trueI
mutual
monD-ne : ∀{Γ Δ A} (τ : Δ ≤ Γ) (t : Ne Γ A) → ne[ monNe τ t ] ≡ monD τ ne[ t ]
monD-ne τ (hyp x) = refl
monD-ne τ (impE t u) = cong₂ impE (monD-ne τ t) (monD-nf τ u)
monD-ne τ (andE₁ t) = cong andE₁ (monD-ne τ t)
monD-ne τ (andE₂ t) = cong andE₂ (monD-ne τ t)
monD-nf : ∀{Γ Δ A} (τ : Δ ≤ Γ) (t : Nf Γ A) → nf[ monNf τ t ] ≡ monD τ nf[ t ]
monD-nf τ (ne t) = monD-ne τ t
monD-nf τ (impI t) = cong impI (monD-nf (lift τ) t)
monD-nf τ (andI t u) = cong₂ andI (monD-nf τ t) (monD-nf τ u)
monD-nf τ (orI₁ t) = cong orI₁ (monD-nf τ t)
monD-nf τ (orI₂ t) = cong orI₂ (monD-nf τ t)
monD-nf τ (orE t u v) = cong₃ orE (monD-ne τ t) (monD-nf (lift τ) u) (monD-nf (lift τ) v)
monD-nf τ (falseE t) = cong falseE (monD-ne τ t)
monD-nf τ trueI = refl
-- monD-ne : ∀{Γ Δ A} (τ : Δ ≤ Γ) (t : Ne Γ A) → monD τ ne[ t ] ≡ ne[ monNe τ t ]
-- monD-ne τ (hyp x) = refl
-- monD-ne τ (impE t u) = cong₂ impE (monD-ne τ t) (monD-nf τ u)
-- monD-ne τ (andE₁ t) = cong andE₁ (monD-ne τ t)
-- monD-ne τ (andE₂ t) = cong andE₂ (monD-ne τ t)
-- monD-nf : ∀{Γ Δ A} (τ : Δ ≤ Γ) (t : Nf Γ A) → monD τ nf[ t ] ≡ nf[ monNf τ t ]
-- monD-nf τ (ne t) = monD-ne τ t
-- monD-nf τ (impI t) = cong impI (monD-nf (lift τ) t)
-- monD-nf τ (andI t u) = cong₂ andI (monD-nf τ t) (monD-nf τ u)
-- monD-nf τ (orI₁ t) = cong orI₁ (monD-nf τ t)
-- monD-nf τ (orI₂ t) = cong orI₂ (monD-nf τ t)
-- monD-nf τ (orE t u v) = cong₃ orE (monD-ne τ t) (monD-nf (lift τ) u) (monD-nf (lift τ) v)
-- monD-nf τ (falseE t) = cong falseE (monD-ne τ t)
-- monD-nf τ trueI = refl
{-# REWRITE monD-ne monD-nf #-}
| {
"alphanum_fraction": 0.5007042254,
"avg_line_length": 36.7875647668,
"ext": "agda",
"hexsha": "b132ff794810466b4d97399d6481a14ffef5553a",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-02-25T20:39:03.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-11-13T16:01:46.000Z",
"max_forks_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "andreasabel/ipl",
"max_forks_repo_path": "src/Derivations.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"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": "andreasabel/ipl",
"max_issues_repo_path": "src/Derivations.agda",
"max_line_length": 97,
"max_stars_count": 19,
"max_stars_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "andreasabel/ipl",
"max_stars_repo_path": "src/Derivations.agda",
"max_stars_repo_stars_event_max_datetime": "2021-04-27T19:10:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-16T08:08:51.000Z",
"num_tokens": 3430,
"size": 7100
} |
{-# OPTIONS --without-K #-}
open import Library
--------------------------------------------------------------------------------
-- Universes for a Category
--------------------------------------------------------------------------------
record CatLevel : Set where
field
Obj : Level
Hom : Level
Obj-Hom : Level
Obj-Hom = ℓ-max Obj Hom
Cat : Level
Cat = ℓ-suc (ℓ-max Obj Hom)
--------------------------------------------------------------------------------
-- Definition of a Category
--------------------------------------------------------------------------------
module _ (ℓ : CatLevel) (let module ℓ = CatLevel ℓ) where
record Category : Set ℓ.Cat where
field
Obj : Set ℓ.Obj
_⇒_ : Obj → Obj → Set ℓ.Hom
id : (X : Obj) → X ⇒ X
_∘_ : ∀{X Y Z} → Y ⇒ Z → X ⇒ Y → X ⇒ Z
infix 4 _⇒_
infix 6 _∘_
field
idl : ∀{X Y}{f : X ⇒ Y} → (id Y) ∘ f ≡ f
idr : ∀{X Y}{f : X ⇒ Y} → f ∘ (id X) ≡ f
assoc : ∀{W X Y Z}{f : W ⇒ X}{g : X ⇒ Y}{h : Y ⇒ Z}
→ (h ∘ g) ∘ f ≡ h ∘ (g ∘ f)
--------------------------------------------------------------------------------
-- Dual Category
--------------------------------------------------------------------------------
op : Category
op = record { Obj = Obj
; _⇒_ = λ-flip _⇒_
; id = id
; _∘_ = λ-flip _∘_
; idl = idr
; idr = idl
; assoc = ≡-sym assoc }
--------------------------------------------------------------------------------
-- Properties of Spacial Morphisms
--------------------------------------------------------------------------------
record _≅_ (X Y : Obj) : Set ℓ.Cat where
field
f : X ⇒ Y
g : Y ⇒ X
g∘f : g ∘ f ≡ id X
f∘g : f ∘ g ≡ id Y
record _≾_ (X Y : Obj) : Set ℓ.Cat where
field
s : X ⇒ Y
r : Y ⇒ X
r∘s : r ∘ s ≡ id X
module _ {X Y : Obj} (f : X ⇒ Y) where
is-isomorphism : Set ℓ.Hom
is-isomorphism = Σ[ g ∈ Y ⇒ X ] (g ∘ f ≡ id X) × (f ∘ g ≡ id Y)
is-section : Set ℓ.Hom
is-section = Σ[ g ∈ Y ⇒ X ] g ∘ f ≡ id X
is-retraction : Set ℓ.Hom
is-retraction = Σ[ g ∈ Y ⇒ X ] f ∘ g ≡ id Y
is-monomorphism : Set ℓ.Obj-Hom
is-monomorphism = ∀{Z}{g h : Z ⇒ X} → f ∘ g ≡ f ∘ h → g ≡ h
is-epimorphism : Set ℓ.Obj-Hom
is-epimorphism = ∀{Z}{g h : Y ⇒ Z} → g ∘ f ≡ h ∘ f → g ≡ h
is-bimorphism : Set ℓ.Obj-Hom
is-bimorphism = is-monomorphism × is-epimorphism
module _ (X Y : Obj) where
_iso⇒_ : Set ℓ.Hom
_iso⇒_ = Σ (X ⇒ Y) is-isomorphism
_mono⇒_ : Set ℓ.Obj-Hom
_mono⇒_ = Σ (X ⇒ Y) is-monomorphism
_epi⇒_ : Set ℓ.Obj-Hom
_epi⇒_ = Σ (X ⇒ Y) is-epimorphism
--------------------------------------------------------------------------------
-- Category of Sets i.e. Types that has no non-trival equality
--------------------------------------------------------------------------------
SetCat : (ℓ : Level) → Category (record { Obj = ℓ-suc ℓ ; Hom = ℓ })
SetCat ℓ = record
{ Obj = Object
; _⇒_ = λ (X Y : Object) → (X → Y)
; id = λ (X : Object) → (λ x → x)
; _∘_ = λ {X Y Z : Object} (g : Y → Z) (f : X → Y) → (λ x → g (f x))
; idl = ≡-refl
; idr = ≡-refl
; assoc = ≡-refl
} where Object = Set ℓ
SetCat₀ = SetCat ℓ-zero
| {
"alphanum_fraction": 0.345386173,
"avg_line_length": 30.0608695652,
"ext": "agda",
"hexsha": "d7b3c4f24b52f040221160d3e8b8304131f75322",
"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": "045f2ab8a40c1b87f578ef12c0d1e10d131b7da3",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "gunpinyo/agda-cat",
"max_forks_repo_path": "src/Basic.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "045f2ab8a40c1b87f578ef12c0d1e10d131b7da3",
"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": "gunpinyo/agda-cat",
"max_issues_repo_path": "src/Basic.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "045f2ab8a40c1b87f578ef12c0d1e10d131b7da3",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "gunpinyo/agda-cat",
"max_stars_repo_path": "src/Basic.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1130,
"size": 3457
} |
module Luau.Value.ToString where
open import Agda.Builtin.String using (String)
open import Agda.Builtin.Float using (primShowFloat)
open import Luau.Value using (Value; nil; addr; number)
open import Luau.Addr.ToString using (addrToString)
valueToString : Value → String
valueToString nil = "nil"
valueToString (addr a) = addrToString a
valueToString (number x) = primShowFloat x
| {
"alphanum_fraction": 0.7911227154,
"avg_line_length": 31.9166666667,
"ext": "agda",
"hexsha": "51c3fa78c6642762b927c96f69eff75943c43f4d",
"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": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Tr4shh/Roblox-Luau",
"max_forks_repo_path": "prototyping/Luau/Value/ToString.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734",
"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": "Tr4shh/Roblox-Luau",
"max_issues_repo_path": "prototyping/Luau/Value/ToString.agda",
"max_line_length": 55,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Tr4shh/Roblox-Luau",
"max_stars_repo_path": "prototyping/Luau/Value/ToString.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 94,
"size": 383
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties satisfied by lattices
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary.Lattice
module Relation.Binary.Properties.Lattice
{c ℓ₁ ℓ₂} (L : Lattice c ℓ₁ ℓ₂) where
open Lattice L
import Algebra as Alg
import Algebra.Structures as Alg
open import Algebra.FunctionProperties _≈_
open import Data.Product using (_,_)
open import Function using (flip)
open import Relation.Binary
open import Relation.Binary.Properties.Poset poset
import Relation.Binary.Properties.JoinSemilattice joinSemilattice as J
import Relation.Binary.Properties.MeetSemilattice meetSemilattice as M
import Relation.Binary.Reasoning.Setoid as EqReasoning
import Relation.Binary.Reasoning.PartialOrder as POR
∨-absorbs-∧ : _∨_ Absorbs _∧_
∨-absorbs-∧ x y =
let x≤x∨[x∧y] , _ , least = supremum x (x ∧ y)
x∧y≤x , _ , _ = infimum x y
in antisym (least x refl x∧y≤x) x≤x∨[x∧y]
∧-absorbs-∨ : _∧_ Absorbs _∨_
∧-absorbs-∨ x y =
let x∧[x∨y]≤x , _ , greatest = infimum x (x ∨ y)
x≤x∨y , _ , _ = supremum x y
in antisym x∧[x∨y]≤x (greatest x refl x≤x∨y)
absorptive : Absorptive _∨_ _∧_
absorptive = ∨-absorbs-∧ , ∧-absorbs-∨
∧≤∨ : ∀ {x y} → x ∧ y ≤ x ∨ y
∧≤∨ {x} {y} = begin
x ∧ y ≤⟨ x∧y≤x x y ⟩
x ≤⟨ x≤x∨y x y ⟩
x ∨ y ∎
where open POR poset
-- two quadrilateral arguments
quadrilateral₁ : ∀ {x y} → x ∨ y ≈ x → x ∧ y ≈ y
quadrilateral₁ {x} {y} x∨y≈x = begin
x ∧ y ≈⟨ M.∧-cong (Eq.sym x∨y≈x) Eq.refl ⟩
(x ∨ y) ∧ y ≈⟨ M.∧-comm _ _ ⟩
y ∧ (x ∨ y) ≈⟨ M.∧-cong Eq.refl (J.∨-comm _ _) ⟩
y ∧ (y ∨ x) ≈⟨ ∧-absorbs-∨ _ _ ⟩
y ∎
where open EqReasoning setoid
quadrilateral₂ : ∀ {x y} → x ∧ y ≈ y → x ∨ y ≈ x
quadrilateral₂ {x} {y} x∧y≈y = begin
x ∨ y ≈⟨ J.∨-cong Eq.refl (Eq.sym x∧y≈y) ⟩
x ∨ (x ∧ y) ≈⟨ ∨-absorbs-∧ _ _ ⟩
x ∎
where open EqReasoning setoid
-- collapsing sublattice
collapse₁ : ∀ {x y} → x ≈ y → x ∧ y ≈ x ∨ y
collapse₁ {x} {y} x≈y = begin
x ∧ y ≈⟨ M.y≤x⇒x∧y≈y y≤x ⟩
y ≈⟨ Eq.sym x≈y ⟩
x ≈⟨ Eq.sym (J.x≤y⇒x∨y≈y y≤x) ⟩
y ∨ x ≈⟨ J.∨-comm _ _ ⟩
x ∨ y ∎
where
y≤x = reflexive (Eq.sym x≈y)
open EqReasoning setoid
-- this can also be proved by quadrilateral argument, but it's much less symmetric.
collapse₂ : ∀ {x y} → x ∨ y ≤ x ∧ y → x ≈ y
collapse₂ {x} {y} ∨≤∧ = antisym
(begin x ≤⟨ x≤x∨y _ _ ⟩
x ∨ y ≤⟨ ∨≤∧ ⟩
x ∧ y ≤⟨ x∧y≤y _ _ ⟩
y ∎)
(begin y ≤⟨ y≤x∨y _ _ ⟩
x ∨ y ≤⟨ ∨≤∧ ⟩
x ∧ y ≤⟨ x∧y≤x _ _ ⟩
x ∎)
where open POR poset
------------------------------------------------------------------------
-- The dual construction is also a lattice.
∧-∨-isLattice : IsLattice _≈_ (flip _≤_) _∧_ _∨_
∧-∨-isLattice = record
{ isPartialOrder = invIsPartialOrder
; supremum = infimum
; infimum = supremum
}
∧-∨-lattice : Lattice c ℓ₁ ℓ₂
∧-∨-lattice = record
{ _∧_ = _∨_
; _∨_ = _∧_
; isLattice = ∧-∨-isLattice
}
------------------------------------------------------------------------
-- Every order-theoretic lattice can be turned into an algebraic one.
isAlgLattice : Alg.IsLattice _≈_ _∨_ _∧_
isAlgLattice = record
{ isEquivalence = isEquivalence
; ∨-comm = J.∨-comm
; ∨-assoc = J.∨-assoc
; ∨-cong = J.∨-cong
; ∧-comm = M.∧-comm
; ∧-assoc = M.∧-assoc
; ∧-cong = M.∧-cong
; absorptive = absorptive
}
algLattice : Alg.Lattice c ℓ₁
algLattice = record { isLattice = isAlgLattice }
| {
"alphanum_fraction": 0.523249453,
"avg_line_length": 28.5625,
"ext": "agda",
"hexsha": "3e6ad770f06d603f7de20f2025f690278e26243e",
"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/Relation/Binary/Properties/Lattice.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/Binary/Properties/Lattice.agda",
"max_line_length": 83,
"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/Relation/Binary/Properties/Lattice.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1543,
"size": 3656
} |
data Unit : Set where
unit : Unit
data Builtin : Set where
addInteger : Builtin
data SizedTermCon : Set where
integer : (s : Unit) → SizedTermCon
data ScopedTm : Set where
con : SizedTermCon → ScopedTm
data Value : ScopedTm → Set where
V-con : (tcn : SizedTermCon) → Value (con tcn)
BUILTIN : Builtin → (t : ScopedTm) → Value t → Unit
BUILTIN addInteger _ (V-con (integer s)) = s
| {
"alphanum_fraction": 0.6818181818,
"avg_line_length": 20.8421052632,
"ext": "agda",
"hexsha": "4774415b4180b71bf5966fd57f31e833779c0c33",
"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/Issue3651.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/Issue3651.agda",
"max_line_length": 51,
"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/Issue3651.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": 396
} |
-- The Berry majority function.
module Berry where
data Bool : Set where
F : Bool
T : Bool
maj : Bool -> Bool -> Bool -> Bool
maj T T T = T
maj T F x = x
maj F x T = x
maj x T F = x -- doesn't hold definitionally
maj F F F = F
postulate
z : Bool
| {
"alphanum_fraction": 0.5602836879,
"avg_line_length": 14.1,
"ext": "agda",
"hexsha": "25b3ec6cd685db85ea2e207dd0b987e2156df376",
"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/Berry.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/Berry.agda",
"max_line_length": 48,
"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/Berry.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": 95,
"size": 282
} |
module Inductive.Examples.Nat where
open import Inductive
open import Tuple
import Data.Fin as Fin
open import Data.Product
open import Data.List
open import Data.Vec hiding (lookup)
Nat : Set
Nat = Inductive ( ([] , []) ∷ (([] , ([] ∷ [])) ∷ []))
zero : Nat
zero = construct Fin.zero [] []
suc : Nat → Nat
suc n = construct (Fin.suc Fin.zero) [] ((λ _ → n) ∷ [])
_+_ : Nat → Nat → Nat
n + m = rec (m ∷ ((λ x x₁ → suc x₁) ∷ [])) n
| {
"alphanum_fraction": 0.5972540046,
"avg_line_length": 19.8636363636,
"ext": "agda",
"hexsha": "9453d3cd4808e3e07049bf9b13d03cd389bac275",
"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": "dc157acda597a2c758e82b5637e4fd6717ccec3f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mr-ohman/general-induction",
"max_forks_repo_path": "Inductive/Examples/Nat.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "dc157acda597a2c758e82b5637e4fd6717ccec3f",
"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": "mr-ohman/general-induction",
"max_issues_repo_path": "Inductive/Examples/Nat.agda",
"max_line_length": 56,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "dc157acda597a2c758e82b5637e4fd6717ccec3f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mr-ohman/general-induction",
"max_stars_repo_path": "Inductive/Examples/Nat.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 144,
"size": 437
} |
{-# OPTIONS --without-K --safe #-}
module Data.Binary.Proofs.Multiplication where
open import Relation.Binary.PropositionalEquality
open import Data.Binary.Operations.Unary
open import Data.Binary.Operations.Addition
open import Data.Binary.Operations.Multiplication
open import Data.Binary.Proofs.Unary
open import Data.Binary.Proofs.Addition
open import Data.Binary.Definitions
open import Data.Binary.Operations.Semantics
open import Data.Nat as ℕ using (ℕ; suc; zero)
open import Relation.Binary.PropositionalEquality.FasterReasoning
import Data.Nat.Properties as ℕ
open import Function
open import Data.Nat.Reasoning
mul-homo : ∀ xs ys → ⟦ mul xs ys ⇓⟧⁺ ≡ ⟦ xs ⇓⟧⁺ ℕ.* ⟦ ys ⇓⟧⁺
mul-homo 1ᵇ ys = sym (ℕ.+-identityʳ _)
mul-homo (O ∷ xs) ys = cong 2* (mul-homo xs ys) ⟨ trans ⟩ sym (ℕ.*-distribʳ-+ ⟦ ys ⇓⟧⁺ ⟦ xs ⇓⟧⁺ _)
mul-homo (I ∷ xs) ys =
begin
⟦ add O (O ∷ mul ys xs) ys ⇓⟧⁺
≡⟨ add₀-homo (O ∷ mul ys xs) ys ⟩
2* ⟦ mul ys xs ⇓⟧⁺ ℕ.+ ⟦ ys ⇓⟧⁺
≡⟨ ⟦ ys ⇓⟧⁺ ≪+ cong 2* (mul-homo ys xs) ⟩
2* (⟦ ys ⇓⟧⁺ ℕ.* ⟦ xs ⇓⟧⁺) ℕ.+ ⟦ ys ⇓⟧⁺
≡⟨ ℕ.+-comm _ ⟦ ys ⇓⟧⁺ ⟩
⟦ ys ⇓⟧⁺ ℕ.+ 2* (⟦ ys ⇓⟧⁺ ℕ.* ⟦ xs ⇓⟧⁺)
≡˘⟨ ⟦ ys ⇓⟧⁺ +≫ ℕ.*-distribˡ-+ ⟦ ys ⇓⟧⁺ _ _ ⟩
⟦ ys ⇓⟧⁺ ℕ.+ ⟦ ys ⇓⟧⁺ ℕ.* (2* ⟦ xs ⇓⟧⁺)
≡⟨ ⟦ ys ⇓⟧⁺ +≫ ℕ.*-comm ⟦ ys ⇓⟧⁺ _ ⟩
⟦ ys ⇓⟧⁺ ℕ.+ (2* ⟦ xs ⇓⟧⁺) ℕ.* ⟦ ys ⇓⟧⁺
∎
*-homo : ∀ xs ys → ⟦ xs * ys ⇓⟧ ≡ ⟦ xs ⇓⟧ ℕ.* ⟦ ys ⇓⟧
*-homo 0ᵇ ys = refl
*-homo (0< x) 0ᵇ = sym (ℕ.*-zeroʳ ⟦ x ⇓⟧⁺)
*-homo (0< xs) (0< ys) = mul-homo xs ys
| {
"alphanum_fraction": 0.5713305898,
"avg_line_length": 35.5609756098,
"ext": "agda",
"hexsha": "054e7bb1a243b5e8f6795ea01de3e891c6fb07ea",
"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": "92af4d620febd47a9791d466d747278dc4a417aa",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-binary",
"max_forks_repo_path": "Data/Binary/Proofs/Multiplication.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa",
"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/agda-binary",
"max_issues_repo_path": "Data/Binary/Proofs/Multiplication.agda",
"max_line_length": 98,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-binary",
"max_stars_repo_path": "Data/Binary/Proofs/Multiplication.agda",
"max_stars_repo_stars_event_max_datetime": "2019-03-21T21:30:10.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-03-21T21:30:10.000Z",
"num_tokens": 727,
"size": 1458
} |
-- Copatterns disabled!
{-# OPTIONS --no-copatterns #-}
open import Common.Product
test : {A B : Set} (a : A) (b : B) → A × B
test a b = {!!}
-- Should give error when attempting to split.
| {
"alphanum_fraction": 0.612565445,
"avg_line_length": 21.2222222222,
"ext": "agda",
"hexsha": "db8d90ae82094644ebb5757d15210e1f61d234ab",
"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/interaction/SplitOnResultCopatternsDisabled.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/interaction/SplitOnResultCopatternsDisabled.agda",
"max_line_length": 46,
"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/interaction/SplitOnResultCopatternsDisabled.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": 58,
"size": 191
} |
module bstd.belt where
open import Agda.Builtin.Nat using () renaming (Nat to ℕ)
-- open import Agda.Builtin.Word using (Word64)
record traits : Set₁ where
infixl 5 _⊕_
infixl 6 _⊞_ _⊟_
field
w : Set
_⊟_ : w → w → w
_⊞_ : w → w → w
_⊕_ : w → w → w
G_ : ℕ → w → w
_⋘_ : w → ℕ → w
module prim (t : traits) where
open traits t
record block : Set where
constructor _∶_∶_∶_
field
a b c d : w
record key : Set where
G₅ = G 5
G₁₃ = G 13
G₂₁ = G 21
encᵢ : w → (ℕ → w) → block → block
encᵢ i k (a ∶ b ∶ c ∶ d) = b‴ ∶ d′ ∶ a′ ∶ c‴ where
b′ = b ⊕ G₅ (a ⊞ k 0)
c′ = c ⊕ G₂₁ (d ⊞ k 1)
a′ = a ⊟ G₁₃ (b ⊞ k 2)
e = G₂₁ (b ⊞ c ⊞ k 3) ⊕ i
b″ = b′ ⊞ e
c″ = c′ ⊟ e
d′ = d ⊞ G₁₃ (c ⊞ k 4)
b‴ = b″ ⊕ G₂₁ (a ⊞ k 5)
c‴ = c″ ⊕ G₅ (d ⊞ k 6)
𝔼 : key → block → block
𝔼 k b = {!encᵢ 2 k (encᵢ 1 k x))!}
{-
0 B1 94 BA C8 0A 08 F5 3B 36 6D 00 8E 58 4A 5D E4
1 85 04 FA 9D 1B B6 C7 AC 25 2E 72 C2 02 FD CE 0D
2 5B E3 D6 12 17 B9 61 81 FE 67 86 AD 71 6B 89 0B
3 5C B0 C0 FF 33 C3 56 B8 35 C4 05 AE D8 E0 7F 99
4 E1 2B DC 1A E2 82 57 EC 70 3F CC F0 95 EE 8D F1
5 C1 AB 76 38 9F E6 78 CA F7 C6 F8 60 D5 BB 9C 4F
6 F3 3C 65 7B 63 7C 30 6A DD 4E A7 79 9E B2 3D 31
7 3E 98 B5 6E 27 D3 BC CF 59 1E 18 1F 4C 5A B7 93
8 E9 DE E7 2C 8F 0C 0F A6 2D DB 49 F4 6F 73 96 47
9 06 07 53 16 ED 24 7A 37 39 CB A3 83 03 A9 8B F6
A 92 BD 9B 1C E5 D1 41 01 54 45 FB C9 5E 4D 0E F2
B 68 20 80 AA 22 7D 64 2F 26 87 F9 34 90 40 55 11
C BE 32 97 13 43 FC 9A 48 A0 2A 88 5F 19 4B 09 A1
D 7E CD A4 D0 15 44 AF 8C A5 84 50 BF 66 D2 E8 8A
E A2 D7 46 52 42 A8 DF B3 69 74 C5 51 EB 23 29 21
F D4 EF D9 B4 3A 62 28 75 91 14 10 EA 77 6C DA 1D
-}
| {
"alphanum_fraction": 0.5553582001,
"avg_line_length": 26.390625,
"ext": "agda",
"hexsha": "1fb2e27a81ad36478de8631b6becba8952621e61",
"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": "fe95ba440099f9cf086096469133576a9652c122",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "semenov-vladyslav/bstd",
"max_forks_repo_path": "src/bstd/belt.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fe95ba440099f9cf086096469133576a9652c122",
"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": "semenov-vladyslav/bstd",
"max_issues_repo_path": "src/bstd/belt.agda",
"max_line_length": 57,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "fe95ba440099f9cf086096469133576a9652c122",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "semenov-vladyslav/bstd",
"max_stars_repo_path": "src/bstd/belt.agda",
"max_stars_repo_stars_event_max_datetime": "2019-06-29T10:40:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-29T10:40:15.000Z",
"num_tokens": 1039,
"size": 1689
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Some simple binary relations
------------------------------------------------------------------------
module Relation.Binary.Simple where
open import Relation.Binary
open import Data.Unit
open import Data.Empty
open import Level
-- Constant relations.
Const : ∀ {a b c} {A : Set a} {B : Set b} → Set c → REL A B c
Const I = λ _ _ → I
-- The universally true relation.
Always : ∀ {a ℓ} {A : Set a} → Rel A ℓ
Always = Const (Lift ⊤)
Always-setoid : ∀ {a ℓ} (A : Set a) → Setoid a ℓ
Always-setoid A = record
{ Carrier = A
; _≈_ = Always
; isEquivalence = record {}
}
-- The universally false relation.
Never : ∀ {a ℓ} {A : Set a} → Rel A ℓ
Never = Const (Lift ⊥)
| {
"alphanum_fraction": 0.5081148564,
"avg_line_length": 22.8857142857,
"ext": "agda",
"hexsha": "dc4d8f40032e3a363df0c7238b208f642eb93d73",
"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/Relation/Binary/Simple.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/Relation/Binary/Simple.agda",
"max_line_length": 72,
"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/Relation/Binary/Simple.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": 212,
"size": 801
} |
module RandomAccessList.Redundant.Core where
open import BuildingBlock.BinaryLeafTree using (BinaryLeafTree; Node; Leaf)
open import Data.Num.Redundant
open import Data.Nat using (ℕ; zero; suc)
open import Data.Nat.Etc
infixr 2 0∷ _1∷_ _,_2∷_
data 0-2-RAL (A : Set) : ℕ → Set where
[] : ∀ {n} → 0-2-RAL A n
0∷ : ∀ {n} → 0-2-RAL A (suc n) → 0-2-RAL A n
_1∷_ : ∀ {n} → BinaryLeafTree A n → 0-2-RAL A (suc n) → 0-2-RAL A n
_,_2∷_ : ∀ {n} → BinaryLeafTree A n → BinaryLeafTree A n → 0-2-RAL A (suc n) → 0-2-RAL A n
--------------------------------------------------------------------------------
-- to Redundant Binary Numeral System
--------------------------------------------------------------------------------
⟦_⟧ₙ : ∀ {n A} → 0-2-RAL A n → Redundant
⟦ [] ⟧ₙ = []
⟦ 0∷ xs ⟧ₙ = zero ∷ ⟦ xs ⟧ₙ
⟦ x 1∷ xs ⟧ₙ = one ∷ ⟦ xs ⟧ₙ
⟦ x , y 2∷ xs ⟧ₙ = two ∷ ⟦ xs ⟧ₙ
⟦_⟧ : ∀ {n A} → 0-2-RAL A n → Redundant
⟦_⟧ {n} xs = n <<< ⟦ xs ⟧ₙ
--------------------------------------------------------------------------------
-- to ℕ
--------------------------------------------------------------------------------
{-
[_]ₙ : ∀ {A n} → 0-2-RAL A n → ℕ
[ [] ]ₙ = 0
[ 0∷ xs ]ₙ = 0 + 2 * [ xs ]ₙ
[ x 1∷ xs ]ₙ = 1 + 2 * [ xs ]ₙ
[ x , y 2∷ xs ]ₙ = 2 + 2 * [ xs ]ₙ
[_] : ∀ {n A} → 0-2-RAL A n → ℕ
[_] {n} xs = 2 ^ n * [ xs ]ₙ
-}
| {
"alphanum_fraction": 0.3426666667,
"avg_line_length": 34.0909090909,
"ext": "agda",
"hexsha": "25a82acf702b09cfb7d684eaf7ecf9263dc710d8",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/numeral",
"max_forks_repo_path": "legacy/RandomAccessList/Redundant/Core.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"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": "banacorn/numeral",
"max_issues_repo_path": "legacy/RandomAccessList/Redundant/Core.agda",
"max_line_length": 94,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/numeral",
"max_stars_repo_path": "legacy/RandomAccessList/Redundant/Core.agda",
"max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z",
"num_tokens": 565,
"size": 1500
} |
module prelude.list where
open import Data.Nat renaming (zero to z; suc to s)
open import Data.Fin as Fin using (Fin)
import Data.Fin as Fin renaming (zero to z; suc to s)
open import Agda.Builtin.Sigma
open import Data.Product
open import Relation.Binary.PropositionalEquality.Core using (_≡_; _≢_; refl; cong)
open import Data.Empty
open import Function
Vect : ∀ {ℓ} → ℕ → Set ℓ → Set ℓ
Vect n t = Fin n → t
List : ∀ {ℓ} → Set ℓ → Set ℓ
List t = Σ[ n ∈ ℕ ] Vect n t
len : ∀ {ℓ} {a : Set ℓ} → List a → ℕ
len = fst
head : ∀ {ℓ} {a : Set ℓ} → (as : List a) → (len as ≢ z) → a
head (z , as) n≢0 = ⊥-elim (n≢0 refl)
head (s n , as) _ = as Fin.z
tail : ∀ {ℓ} {a : Set ℓ} → (as : List a) → (len as ≢ z) → List a
tail (z , as) n≢0 = ⊥-elim (n≢0 refl)
tail (s n , as) _ = n , (as ∘ Fin.inject₁)
| {
"alphanum_fraction": 0.6070975919,
"avg_line_length": 34.3043478261,
"ext": "agda",
"hexsha": "3b2407f9882bced8d9067f71b37d5787054db06a",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2022-01-30T11:45:57.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-07-10T17:19:37.000Z",
"max_forks_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dspivak/poly",
"max_forks_repo_path": "code-examples/agda/prelude/list.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea",
"max_issues_repo_issues_event_max_datetime": "2022-01-12T10:06:32.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-09-02T02:29:39.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dspivak/poly",
"max_issues_repo_path": "code-examples/agda/prelude/list.agda",
"max_line_length": 83,
"max_stars_count": 53,
"max_stars_repo_head_hexsha": "425de958985aacbd3284d3057fe21fd682e315ea",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mstone/poly",
"max_stars_repo_path": "code-examples/agda/prelude/list.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T23:08:27.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-02-18T16:31:04.000Z",
"num_tokens": 315,
"size": 789
} |
Subsets and Splits