hexsha
stringlengths
40
40
size
int64
3
1.05M
ext
stringclasses
163 values
lang
stringclasses
53 values
max_stars_repo_path
stringlengths
3
945
max_stars_repo_name
stringlengths
4
112
max_stars_repo_head_hexsha
stringlengths
40
78
max_stars_repo_licenses
listlengths
1
10
max_stars_count
float64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
3
945
max_issues_repo_name
stringlengths
4
113
max_issues_repo_head_hexsha
stringlengths
40
78
max_issues_repo_licenses
listlengths
1
10
max_issues_count
float64
1
116k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
3
945
max_forks_repo_name
stringlengths
4
113
max_forks_repo_head_hexsha
stringlengths
40
78
max_forks_repo_licenses
listlengths
1
10
max_forks_count
float64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
3
1.05M
avg_line_length
float64
1
966k
max_line_length
int64
1
977k
alphanum_fraction
float64
0
1
2efe6632850279c4676a4f82577a67921de897ee
1,130
agda
Agda
prototyping/Luau/Type/ToString.agda
gideros/luau
3f69d3a4f2b74dac8ecff2ef8ec851c8636324b6
[ "MIT" ]
1
2022-03-18T04:10:20.000Z
2022-03-18T04:10:20.000Z
prototyping/Luau/Type/ToString.agda
gideros/luau
3f69d3a4f2b74dac8ecff2ef8ec851c8636324b6
[ "MIT" ]
null
null
null
prototyping/Luau/Type/ToString.agda
gideros/luau
3f69d3a4f2b74dac8ecff2ef8ec851c8636324b6
[ "MIT" ]
null
null
null
module Luau.Type.ToString where open import FFI.Data.String using (String; _++_) open import Luau.Type using (Type; nil; _⇒_; none; any; number; boolean; string; _∪_; _∩_; normalizeOptional) {-# TERMINATING #-} typeToString : Type → String typeToStringᵁ : Type → String typeToStringᴵ : Type → String typeToString nil = "nil" typeToString (S ⇒ T) = "(" ++ (typeToString S) ++ ") -> " ++ (typeToString T) typeToString none = "none" typeToString any = "any" typeToString number = "number" typeToString boolean = "boolean" typeToString string = "string" typeToString (S ∪ T) with normalizeOptional(S ∪ T) typeToString (S ∪ T) | ((S′ ⇒ T′) ∪ nil) = "(" ++ typeToString (S′ ⇒ T′) ++ ")?" typeToString (S ∪ T) | (S′ ∪ nil) = typeToString S′ ++ "?" typeToString (S ∪ T) | (S′ ∪ T′) = "(" ++ typeToStringᵁ (S ∪ T) ++ ")" typeToString (S ∪ T) | T′ = typeToString T′ typeToString (S ∩ T) = "(" ++ typeToStringᴵ (S ∩ T) ++ ")" typeToStringᵁ (S ∪ T) = (typeToStringᵁ S) ++ " | " ++ (typeToStringᵁ T) typeToStringᵁ T = typeToString T typeToStringᴵ (S ∩ T) = (typeToStringᴵ S) ++ " & " ++ (typeToStringᴵ T) typeToStringᴵ T = typeToString T
37.666667
109
0.637168
585b4720e0592d4e573f4b97f9dcd5e11299cc97
5,127
agda
Agda
Cubical/HITs/Colimit/Base.agda
kiana-S/univalent-foundations
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
[ "MIT" ]
null
null
null
Cubical/HITs/Colimit/Base.agda
kiana-S/univalent-foundations
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
[ "MIT" ]
null
null
null
Cubical/HITs/Colimit/Base.agda
kiana-S/univalent-foundations
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
[ "MIT" ]
1
2021-11-22T02:02:01.000Z
2021-11-22T02:02:01.000Z
{- Homotopy colimits of graphs -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.Colimit.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.HLevels open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Data.Graph -- Cones under a diagram record Cocone ℓ {ℓd ℓv ℓe} {I : Graph ℓv ℓe} (F : Diag ℓd I) (X : Type ℓ) : Type (ℓ-suc (ℓ-max ℓ (ℓ-max (ℓ-max ℓv ℓe) (ℓ-suc ℓd)))) where field leg : ∀ (j : Obj I) → F $ j → X com : ∀ {j k} (f : Hom I j k) → leg k ∘ F <$> f ≡ leg j postcomp : ∀ {ℓ'} {Y : Type ℓ'} → (X → Y) → Cocone ℓ' F Y leg (postcomp h) j = h ∘ leg j com (postcomp h) f = cong (h ∘_) (com f) open Cocone public -- Σ (Type ℓ) (Cocone ℓ F) forms a category: module _ {ℓd ℓv ℓe} {I : Graph ℓv ℓe} {F : Diag ℓd I} where private -- the "lower star" functor _* : ∀ {ℓ ℓ'} {X : Type ℓ} {Y : Type ℓ'} → (X → Y) → Cocone _ F X → Cocone _ F Y (h *) C = postcomp C h CoconeMor : ∀ {ℓ ℓ'} → Σ (Type ℓ) (Cocone ℓ F) → Σ (Type ℓ') (Cocone ℓ' F) → Type _ CoconeMor (X , C) (Y , D) = Σ[ h ∈ (X → Y) ] (h *) C ≡ D idCoconeMor : ∀ {ℓ} (Cp : Σ (Type ℓ) (Cocone ℓ F)) → CoconeMor Cp Cp idCoconeMor Cp = (λ x → x) , refl compCoconeMor : ∀ {ℓ ℓ' ℓ''} {C : Σ (Type ℓ) (Cocone ℓ F)} {D : Σ (Type ℓ') (Cocone ℓ' F)} {E : Σ (Type ℓ'') (Cocone ℓ'' F)} → CoconeMor D E → CoconeMor C D → CoconeMor C E compCoconeMor (g , q) (f , p) = g ∘ f , (cong (g *) p) ∙ q -- Universal cocones are initial objects in the category Σ (Type ℓ) (Cocone ℓ F) module _ {ℓ ℓd ℓv ℓe} {I : Graph ℓv ℓe} {F : Diag ℓd I} {X : Type ℓ} where isUniversalAt : ∀ ℓq → Cocone ℓ F X → Type (ℓ-max ℓ (ℓ-suc (ℓ-max ℓq (ℓ-max (ℓ-max ℓv ℓe) (ℓ-suc ℓd))))) isUniversalAt ℓq C = ∀ (Y : Type ℓq) → isEquiv {A = (X → Y)} {B = Cocone ℓq F Y} (postcomp C) -- (unfolding isEquiv, this ^ is equivalent to what one might expect:) -- ∀ (Y : Type ℓ) (D : Cocone ℓ F Y) → ∃![ h ∈ (X → Y) ] (h *) C ≡ D -- (≡ isContr (CoconeMor (X , C) (Y , D))) isPropIsUniversalAt : ∀ ℓq (C : Cocone ℓ F X) → isProp (isUniversalAt ℓq C) isPropIsUniversalAt ℓq C = isPropΠ (λ Y → isPropIsEquiv (postcomp C)) isUniversal : Cocone ℓ F X → Typeω isUniversal C = ∀ ℓq → isUniversalAt ℓq C -- Colimits are universal cocones record isColimit {ℓ ℓd ℓv ℓe} {I : Graph ℓv ℓe} (F : Diag ℓd I) (X : Type ℓ) : Typeω where field cone : Cocone ℓ F X univ : isUniversal cone open isColimit public module _ {ℓ ℓ' ℓd ℓv ℓe} {I : Graph ℓv ℓe} {F : Diag ℓd I} {X : Type ℓ} {Y : Type ℓ'} where postcomp⁻¹ : isColimit F X → Cocone ℓ' F Y → (X → Y) postcomp⁻¹ cl = invEq (_ , univ cl _ Y) postcomp⁻¹-inv : (cl : isColimit F X) (D : Cocone ℓ' F Y) → (postcomp (cone cl) (postcomp⁻¹ cl D)) ≡ D postcomp⁻¹-inv cl D = retEq (_ , univ cl _ Y) D postcomp⁻¹-mor : (cl : isColimit F X) (D : Cocone ℓ' F Y) → CoconeMor (X , cone cl) (Y , D) postcomp⁻¹-mor cl D = (postcomp⁻¹ cl D) , (postcomp⁻¹-inv cl D) -- Colimits are unique module _ {ℓ ℓ' ℓd ℓv ℓe} {I : Graph ℓv ℓe} {F : Diag ℓd I} {X : Type ℓ} {Y : Type ℓ'} where uniqColimit : isColimit F X → isColimit F Y → X ≃ Y uniqColimit cl cl' = isoToEquiv (iso (fst fwd) (fst bwd) (λ x i → fst (isContr→isProp (equiv-proof (univ cl' ℓ' Y) (cone cl')) (compCoconeMor fwd bwd) (idCoconeMor (Y , cone cl')) i) x) (λ x i → fst (isContr→isProp (equiv-proof (univ cl ℓ X) (cone cl)) (compCoconeMor bwd fwd) (idCoconeMor (X , cone cl)) i) x)) where fwd : CoconeMor (X , cone cl ) (Y , cone cl') bwd : CoconeMor (Y , cone cl') (X , cone cl ) fwd = postcomp⁻¹-mor cl (cone cl') bwd = postcomp⁻¹-mor cl' (cone cl) -- Colimits always exist data colim {ℓd ℓe ℓv} {I : Graph ℓv ℓe} (F : Diag ℓd I) : Type (ℓ-suc (ℓ-max (ℓ-max ℓv ℓe) (ℓ-suc ℓd))) where colim-leg : ∀ (j : Obj I) → F $ j → colim F colim-com : ∀ {j k} (f : Hom I j k) → colim-leg k ∘ F <$> f ≡ colim-leg j module _ {ℓd ℓv ℓe} {I : Graph ℓv ℓe} {F : Diag ℓd I} where colimCone : Cocone _ F (colim F) leg colimCone = colim-leg com colimCone = colim-com rec : ∀ {ℓ} {X : Type ℓ} → Cocone ℓ F X → (colim F → X) rec C (colim-leg j A) = leg C j A rec C (colim-com f i A) = com C f i A colimIsColimit : isColimit F (colim F) cone colimIsColimit = colimCone univ colimIsColimit ℓq Y = isoToIsEquiv record { fun = postcomp colimCone ; inv = rec ; rightInv = λ C → refl ; leftInv = λ h → funExt (eq h) } where eq : ∀ h (x : colim _) → rec (postcomp colimCone h) x ≡ h x eq h (colim-leg j A) = refl eq h (colim-com f i A) = refl
37.977778
109
0.534621
29a472d7239454c61c85fb2410c62319807ba89e
1,810
agda
Agda
core/lib/types/Join.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
null
null
null
core/lib/types/Join.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
null
null
null
core/lib/types/Join.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
1
2018-12-26T21:31:57.000Z
2018-12-26T21:31:57.000Z
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics open import lib.types.Paths open import lib.types.Pointed open import lib.types.Pushout open import lib.types.PushoutFmap open import lib.types.Sigma open import lib.types.Span module lib.types.Join where module _ {i j} (A : Type i) (B : Type j) where *-span : Span *-span = span A B (A × B) fst snd infix 80 _*_ _*_ : Type _ _*_ = Pushout *-span module JoinElim {i j} {A : Type i} {B : Type j} {k} {P : A * B → Type k} (left* : (a : A) → P (left a)) (right* : (b : B) → P (right b)) (glue* : (ab : A × B) → left* (fst ab) == right* (snd ab) [ P ↓ glue ab ]) = PushoutElim left* right* glue* open JoinElim public using () renaming (f to Join-elim) module JoinRec {i j} {A : Type i} {B : Type j} {k} {D : Type k} (left* : (a : A) → D) (right* : (b : B) → D) (glue* : (ab : A × B) → left* (fst ab) == right* (snd ab)) = PushoutRec left* right* glue* open JoinRec public using () renaming (f to Join-rec) module _ {i j} (X : Ptd i) (Y : Ptd j) where ⊙*-span : ⊙Span ⊙*-span = ⊙span X Y (X ⊙× Y) ⊙fst ⊙snd infix 80 _⊙*_ _⊙*_ : Ptd _ _⊙*_ = ⊙Pushout ⊙*-span module _ {i i' j j'} {A : Type i} {A' : Type i'} {B : Type j} {B' : Type j'} (eqA : A ≃ A') (eqB : B ≃ B') where *-span-emap : SpanEquiv (*-span A B) (*-span A' B') *-span-emap = ( span-map (fst eqA) (fst eqB) (×-fmap (fst eqA) (fst eqB)) (comm-sqr λ _ → idp) (comm-sqr λ _ → idp) , snd eqA , snd eqB , ×-isemap (snd eqA) (snd eqB)) *-emap : A * B ≃ A' * B' *-emap = Pushout-emap *-span-emap module _ {i i' j j'} {X : Ptd i} {X' : Ptd i'} {Y : Ptd j} {Y' : Ptd j'} where ⊙*-emap : X ⊙≃ X' → Y ⊙≃ Y' → X ⊙* Y ⊙≃ X' ⊙* Y' ⊙*-emap ⊙eqX ⊙eqY = ≃-to-⊙≃ (*-emap (⊙≃-to-≃ ⊙eqX) (⊙≃-to-≃ ⊙eqY)) (ap left (snd (⊙–> ⊙eqX)))
30.677966
117
0.534254
4b58aca47fafa37795962b8271751a06b1f51cbb
23,054
agda
Agda
Categories/Category/Construction/Classifying.agda
elpinal/exsub-ccc
7541ab22debdfe9d529ac7a210e5bd102c788ad9
[ "Apache-2.0" ]
3
2022-02-05T06:16:32.000Z
2022-02-05T13:30:48.000Z
Categories/Category/Construction/Classifying.agda
elpinal/exsub-ccc
7541ab22debdfe9d529ac7a210e5bd102c788ad9
[ "Apache-2.0" ]
null
null
null
Categories/Category/Construction/Classifying.agda
elpinal/exsub-ccc
7541ab22debdfe9d529ac7a210e5bd102c788ad9
[ "Apache-2.0" ]
null
null
null
open import Theory module Categories.Category.Construction.Classifying {ℓ₁ ℓ₂ ℓ₃} (Th : Theory ℓ₁ ℓ₂ ℓ₃) where open import Relation.Binary using (Rel) open import Data.List using ([]; _∷_) open import Data.Fin using () renaming (zero to fzero; suc to fsuc) open import Level using (_⊔_) open import Categories.Category open import Syntax open Theory.Theory Th open Signature Sg open Term Sg private arr : Rel Type (ℓ₁ ⊔ ℓ₂) arr A B = A ∷ [] ⊢ B identityʳ : forall {A B} {e : A ∷ [] ⊢ B} -> A ∷ [] ⊢ e [ ext ! var ] ≡ e identityʳ {A} {e = e} = trans (cong/sub (trans (cong/ext !-unique refl) η-pair) refl) sub/id assoc : {A B C D : Type} {f : arr A B} {g : arr B C} {h : arr C D} -> A ∷ [] ⊢ h [ ext ! g ] [ ext ! f ] ≡ h [ ext ! (g [ ext ! f ]) ] assoc {f = f} {g = g} {h = h} = trans (sym sub/∙) (cong/sub (trans ext∙ (cong/ext (sym !-unique) refl)) refl) Cl : Category ℓ₁ (ℓ₁ ⊔ ℓ₂) (ℓ₁ ⊔ ℓ₂ ⊔ ℓ₃) Cl = record { Obj = Type ; _⇒_ = arr ; _≈_ = λ e₁ e₂ → _ ∷ [] ⊢ e₁ ≡ e₂ ; id = var ; _∘_ = λ e₁ e₂ → e₁ [ ext ! e₂ ] ; assoc = assoc ; sym-assoc = sym assoc ; identityˡ = λ {A} {B} {f} -> var/ext ! f ; identityʳ = identityʳ ; identity² = var/ext ! var ; equiv = record { refl = refl ; sym = sym ; trans = trans } ; ∘-resp-≈ = λ x x₁ → cong/sub (cong/ext refl x₁) x } open import Categories.Category.BinaryProducts Cl module M where open import Categories.Category.CartesianClosed.Canonical Cl CC : CartesianClosed CC = record { ⊤ = Unit ; _×_ = _*_ ; ! = unit ; π₁ = fst var ; π₂ = snd var ; ⟨_,_⟩ = pair ; !-unique = eta/Unit ; π₁-comp = trans comm/fst (trans (cong/fst (var/ext ! (pair _ _))) (beta/*₁ _ _)) ; π₂-comp = trans comm/snd (trans (cong/snd (var/ext ! (pair _ _))) (beta/*₂ _ _)) ; ⟨,⟩-unique = ⟨,⟩-unique ; _^_ = λ A B → B => A ; eval = app (fst var) (snd var) ; curry = λ e → abs (e [ ext ! (pair (var [ weaken ]) var) ]) ; eval-comp = eval-comp ; curry-resp-≈ = λ x → cong/abs (cong/sub refl x) ; curry-unique = λ x → curry-unique x } where ⟨,⟩-unique : forall {A B C} {h : C ∷ [] ⊢ A * B} {i : C ∷ [] ⊢ A} {j : C ∷ [] ⊢ B} -> C ∷ [] ⊢ fst var [ ext ! h ] ≡ i -> C ∷ [] ⊢ snd var [ ext ! h ] ≡ j -> C ∷ [] ⊢ pair i j ≡ h ⟨,⟩-unique x y = trans (cong/pair (sym (trans (cong/fst (sym (var/ext ! _))) (trans (sym comm/fst) x))) (sym (trans (cong/snd (sym (var/ext ! _))) (trans (sym comm/snd) y))) ) (eta/* _) open import Categories.Object.Product.Morphisms Cl using ([_⇒_]_×_) open import Categories.Object.Product Cl using (Product) product : forall {A B} -> Product A B product {A} {B} = record { A×B = A * B ; π₁ = fst var ; π₂ = snd var ; ⟨_,_⟩ = pair ; project₁ = trans comm/fst (trans (cong/fst (var/ext ! (pair _ _))) (beta/*₁ _ _)) ; project₂ = trans comm/snd (trans (cong/snd (var/ext ! (pair _ _))) (beta/*₂ _ _)) ; unique = ⟨,⟩-unique } eval-comp : forall {B A C} {f : arr (C * A) B} -> C * A ∷ [] ⊢ app (fst var) (snd var) [ ext ! ([ product ⇒ product ] (abs (f [ ext ! (pair (var [ weaken ]) var)])) × var) ] ≡ f eval-comp = trans comm/app (trans (cong/app (trans comm/fst (cong/fst (var/ext _ _))) (trans comm/snd (cong/snd (var/ext _ _)))) (trans (cong/app (trans (beta/*₁ _ _) comm/abs) (beta/*₂ _ _)) (trans (beta/=> _ _) (trans (sym sub/∙) (trans (cong/sub (trans ext∙ (cong/ext (trans (cong/∙ (trans ext∙ (cong/ext (sym !-unique) comm/fst)) refl) (trans ext∙ (cong/ext (sym !-unique) (trans comm/fst (cong/fst (trans (sym sub/∙) (cong/sub weaken/ext refl))))))) (trans (var/ext _ _) (var/ext _ _)))) refl) (trans (sym sub/∙) (trans (cong/sub (trans ext∙ (trans (cong/ext (sym !-unique) (trans comm/pair (cong/pair (trans (sym sub/∙) (trans (cong/sub weaken/ext refl) (trans (var/ext _ _) (cong/fst sub/id)))) (var/ext _ _)))) (trans (cong/ext !-unique (eta/* _)) η-pair))) refl) sub/id))))))) open BinaryProducts (record { product = product }) open Category Cl helper : forall {A B C} {f : A ⇒ B => C} -> B ∷ A ∷ [] ⊨ ext ! (var [ weaken ]) ≡ weaken helper = trans (cong/ext (!-unique {γ = weaken ∙ weaken}) refl) (trans (sym ext∙) (trans (cong/∙ η-pair refl) id∙ˡ)) curry-unique : forall {A B C} {f : A ⇒ B => C} {g : A × B ⇒ C} -> app (fst var) (snd var) ∘ (f ⁂ Category.id Cl) ≈ g -> f ≈ abs (g [ ext ! (pair (var [ weaken ]) var) ]) curry-unique {A} {B} {C} {f = f} {g = g} x = begin f ≈˘⟨ eta/=> _ ⟩ abs (app (f [ weaken ]) var) ≈˘⟨ cong/abs (cong/app (cong/sub (helper {f = f}) refl) refl) ⟩ abs (app (f [ ext ! (var [ weaken ]) ]) var) ≈˘⟨ cong/abs (cong/app (beta/*₁ _ _) (beta/*₂ _ _)) ⟩ abs (app (fst (pair (f [ ext ! (var [ weaken ]) ]) var)) (snd (pair (f [ ext ! (var [ weaken ]) ]) var))) ≈˘⟨ cong/abs (cong/app (trans comm/fst (cong/fst (var/ext _ _))) (trans comm/snd (cong/snd (var/ext _ _)))) ⟩ abs (app (fst var [ ext ! (pair (f [ ext ! (var [ weaken ]) ]) var) ]) (snd var [ ext ! (pair (f [ ext ! (var [ weaken ]) ]) var) ])) ≈˘⟨ cong/abs comm/app ⟩ abs (app (fst var) (snd var) [ ext ! (pair (f [ ext ! (var [ weaken ]) ]) var) ]) ≈˘⟨ cong/abs (cong/sub (cong/ext refl (cong/pair (cong/sub (cong/ext refl (trans comm/fst (trans (cong/fst (var/ext _ _)) (beta/*₁ _ _)))) refl) refl)) refl) ⟩ abs (app (fst var) (snd var) [ ext ! (pair (f [ ext ! (fst var [ ext ! (pair (var [ weaken ]) var)]) ]) var) ]) ≈˘⟨ cong/abs (cong/sub (cong/ext refl (cong/pair (cong/sub (trans ext∙ (cong/ext (sym !-unique) refl)) refl) (trans (cong/snd (var/ext _ _)) (beta/*₂ _ _)))) refl) ⟩ abs (app (fst var) (snd var) [ ext ! (pair (f [ ext ! (fst var) ∙ ext ! (pair (var [ weaken ]) var) ]) (snd (var [ ext ! (pair (var [ weaken ]) var) ]))) ]) ≈˘⟨ cong/abs (cong/sub (cong/ext refl (cong/pair (sym sub/∙) comm/snd)) refl) ⟩ abs (app (fst var) (snd var) [ ext ! (pair (f [ ext ! (fst var) ] [ ext ! (pair (var [ weaken ]) var) ]) (snd var [ ext ! (pair (var [ weaken ]) var) ])) ]) ≈˘⟨ cong/abs (cong/sub (cong/ext refl comm/pair) refl) ⟩ abs (app (fst var) (snd var) [ ext ! (pair (f [ ext ! (fst var) ]) (snd var) [ ext ! (pair (var [ weaken ]) var) ]) ]) ≈⟨ cong/abs (cong/sub (cong/ext !-unique (cong/sub refl (cong/pair refl (sym (var/ext _ _))))) refl) ⟩ abs (app (fst var) (snd var) [ ext (! ∙ ext ! (pair (var [ weaken ]) var)) (pair (f [ ext ! (fst var) ]) (var [ ext ! (snd var) ]) [ ext ! (pair (var [ weaken ]) var) ]) ]) ≈˘⟨ cong/abs (cong/sub ext∙ refl) ⟩ abs (app (fst var) (snd var) [ ext ! (pair (f [ ext ! (fst var) ]) (var [ ext ! (snd var) ])) ∙ ext ! (pair (var [ weaken ]) var) ]) ≡⟨⟩ abs (app (fst var) (snd var) [ ext ! ⟨ f ∘ fst var , Category.id Cl ∘ snd var ⟩ ∙ ext ! (pair (var [ weaken ]) var) ]) ≈⟨ cong/abs sub/∙ ⟩ abs ((app (fst var) (snd var) ∘ ⟨ f ∘ fst var , Category.id Cl ∘ snd var ⟩) [ ext ! (pair (var [ weaken ]) var) ]) ≡⟨⟩ abs ((app (fst var) (snd var) ∘ (f ⁂ Category.id Cl)) [ ext ! (pair (var [ weaken ]) var) ]) ≈⟨ cong/abs (cong/sub refl x) ⟩ abs (g [ ext ! (pair (var [ weaken ]) var) ]) ∎ where open import Relation.Binary.Reasoning.Setoid TermSetoid open import Categories.Category.CartesianClosed Cl import Categories.Category.CartesianClosed.Canonical Cl as Can CC : CartesianClosed CC = Can.Equivalence.fromCanonical M.CC open import Semantics Cl CC Sg open Category Cl private open import Data.Product using (_,_) open import Categories.Morphism Cl using (Iso; _≅_) open import Categories.Category.Cartesian using (Cartesian) open import Categories.Functor open import Categories.Functor.Properties using ([_]-resp-∘) open import Categories.Functor.Construction.Product using (Product) open import Categories.Functor.Construction.Exponential using (Exp) open import Categories.Functor.Bifunctor using (Bifunctor) open CartesianClosed CC open BinaryProducts (Cartesian.products cartesian) open I ⌊_⌋ P : Bifunctor Cl Cl Cl P = Product Cl cartesian E : Bifunctor Cl op Cl E = Exp Cl CC from/⟦⟧T : forall (A : Type) -> ⟦ A ⟧T ⇒ A to/⟦⟧T : forall (A : Type) -> A ⇒ ⟦ A ⟧T from/⟦⟧T ⌊ x ⌋ = Category.id Cl from/⟦⟧T Unit = Category.id Cl from/⟦⟧T (A * A₁) = from/⟦⟧T A ⁂ from/⟦⟧T A₁ from/⟦⟧T (A => A₁) = λg (from/⟦⟧T A₁ ∘ eval′ ∘ (Category.id Cl ⁂ to/⟦⟧T A)) to/⟦⟧T ⌊ x ⌋ = Category.id Cl to/⟦⟧T Unit = Category.id Cl to/⟦⟧T (A * A₁) = to/⟦⟧T A ⁂ to/⟦⟧T A₁ to/⟦⟧T (A => A₁) = λg (to/⟦⟧T A₁ ∘ eval′ ∘ (Category.id Cl ⁂ from/⟦⟧T A)) to∘from : forall {A} -> ⟦ A ⟧T ∷ [] ⊢ to/⟦⟧T A [ ext ! (from/⟦⟧T A) ] ≡ var to∘from {⌊ x ⌋} = var/ext _ _ to∘from {Unit} = var/ext _ _ to∘from {A * A₁} = trans ([ P ]-resp-∘ (to∘from , to∘from)) (Functor.identity P) to∘from {A => A₁} = trans ([ E ]-resp-∘ (to∘from , to∘from)) (Functor.identity E) from∘to : forall {A} -> A ∷ [] ⊢ from/⟦⟧T A [ ext ! (to/⟦⟧T A) ] ≡ var from∘to {⌊ x ⌋} = var/ext _ _ from∘to {Unit} = var/ext _ _ from∘to {A * A₁} = trans ([ P ]-resp-∘ (from∘to , from∘to)) (Functor.identity P) from∘to {A => A₁} = trans ([ E ]-resp-∘ (from∘to , from∘to)) (Functor.identity E) Iso/⟦⟧T : forall {A : Type} -> ⟦ A ⟧T ≅ A Iso/⟦⟧T {A} = record { from = from/⟦⟧T A ; to = to/⟦⟧T A ; iso = record { isoˡ = to∘from ; isoʳ = from∘to } } ⟦_⟧F : (f : Func) -> ⟦ dom f ⟧T ⇒ ⟦ cod f ⟧T ⟦_⟧F f = _≅_.to Iso/⟦⟧T ∘ x ∘ _≅_.from Iso/⟦⟧T where x : dom f ⇒ cod f x = func f var S : Structure S = record { ⟦_⟧G = ⌊_⌋ ; ⟦_⟧F = λ f → ⟦ f ⟧F } open Structure S private γC : forall {Γ} -> ⟦ Γ ⟧C ∷ [] ⊨ Γ γC {[]} = ! γC {A ∷ Γ} = ext (γC {Γ} ∙ ext ! π₁) (from/⟦⟧T A ∘ π₂) open HomReasoning open import Categories.Morphism.Reasoning Cl import Categories.Object.Product Cl as Prod open import Categories.Object.Terminal Cl using (Terminal) module T = Terminal (Cartesian.terminal cartesian) helper : forall {Γ} {A} {e : Γ ⊢ A} -> ⟦ e ⟧ ≈ to/⟦⟧T A ∘ (e [ γC ]) helperS : forall {Γ Γ′} {γ : Γ ⊨ Γ′} -> _ ⊨ γC ∙ ext ! ⟦ γ ⟧S ≡ γ ∙ γC helper {e = func f e} = begin (to/⟦⟧T (cod f) ∘ func f var ∘ from/⟦⟧T (dom f)) ∘ ⟦ e ⟧ ≈⟨ ∘-resp-≈ʳ (helper {e = e}) ⟩ (to/⟦⟧T (cod f) ∘ func f var ∘ from/⟦⟧T (dom f)) ∘ to/⟦⟧T _ ∘ (e [ γC ]) ≈⟨ assoc²' ⟩ to/⟦⟧T (cod f) ∘ func f var ∘ from/⟦⟧T (dom f) ∘ to/⟦⟧T (dom f) ∘ (e [ γC ]) ≈⟨ ∘-resp-≈ʳ (∘-resp-≈ʳ (cancelˡ from∘to)) ⟩ to/⟦⟧T (cod f) ∘ func f var ∘ (e [ γC ]) ≈⟨ ∘-resp-≈ʳ (comm/func _ _ _ _ _) ⟩ to/⟦⟧T (cod f) ∘ func f (var ∘ (e [ γC ])) ≈⟨ ∘-resp-≈ʳ (cong/func identityˡ) ⟩ to/⟦⟧T (cod f) ∘ func f (e [ γC ]) ≈˘⟨ ∘-resp-≈ʳ (comm/func _ _ _ _ _) ⟩ to/⟦⟧T (cod f) ∘ (func f e [ γC ]) ∎ helper {e = var} = begin π₂ ≈⟨ insertˡ to∘from ⟩ to/⟦⟧T _ ∘ (from/⟦⟧T _ ∘ π₂) ≈˘⟨ ∘-resp-≈ʳ (var/ext _ _) ⟩ to/⟦⟧T _ ∘ (var [ ext _ (from/⟦⟧T _ ∘ π₂) ]) ∎ helper {e = unit} = T.!-unique _ helper {e = pair e₁ e₂} = begin ⟨ ⟦ e₁ ⟧ , ⟦ e₂ ⟧ ⟩ ≈⟨ ⟨⟩-cong₂ (helper {e = e₁}) (helper {e = e₂}) ⟩ ⟨ to/⟦⟧T _ ∘ (e₁ [ γC ]) , to/⟦⟧T _ ∘ (e₂ [ γC ]) ⟩ ≈˘⟨ ⁂∘⟨⟩ ⟩ (to/⟦⟧T _ ⁂ to/⟦⟧T _) ∘ (pair (e₁ [ γC ]) (e₂ [ γC ])) ≈˘⟨ ∘-resp-≈ʳ comm/pair ⟩ (to/⟦⟧T _ ⁂ to/⟦⟧T _) ∘ (pair e₁ e₂ [ γC ]) ∎ helper {e = fst {A = A} {B = B} e} = switch-fromtoˡ Iso/⟦⟧T ( begin from/⟦⟧T _ ∘ π₁ ∘ ⟦ e ⟧ ≈⟨ ∘-resp-≈ʳ (∘-resp-≈ʳ (helper {e = e})) ⟩ from/⟦⟧T A ∘ π₁ ∘ to/⟦⟧T (A * B) ∘ (e [ γC ]) ≈⟨ ∘-resp-≈ʳ (pullˡ π₁∘⁂) ⟩ from/⟦⟧T A ∘ (to/⟦⟧T A ∘ π₁) ∘ (e [ γC ]) ≈⟨ assoc²'' ⟩ (from/⟦⟧T A ∘ to/⟦⟧T A) ∘ π₁ ∘ (e [ γC ]) ≈⟨ elimˡ from∘to ⟩ π₁ ∘ (e [ γC ]) ≈⟨ comm/fst ⟩ fst (var [ ext ! (e [ γC ]) ]) ≈⟨ cong/fst (var/ext _ _) ⟩ fst (e [ γC ]) ≈˘⟨ comm/fst ⟩ fst e [ γC ] ∎) helper {e = snd e} = begin π₂ ∘ ⟦ e ⟧ ≈⟨ ∘-resp-≈ʳ (helper {e = e}) ⟩ π₂ ∘ (to/⟦⟧T _ ∘ (e [ γC ])) ≈⟨ pullˡ π₂∘⁂ ⟩ (to/⟦⟧T _ ∘ snd var) ∘ (e [ γC ]) ≈⟨ pullʳ comm/snd ⟩ to/⟦⟧T _ ∘ snd (var ∘ (e [ γC ])) ≈⟨ ∘-resp-≈ʳ (cong/snd identityˡ) ⟩ to/⟦⟧T _ ∘ snd (e [ γC ]) ≈˘⟨ ∘-resp-≈ʳ comm/snd ⟩ to/⟦⟧T _ ∘ (snd e [ γC ]) ∎ helper {e = abs e} = begin λg ⟦ e ⟧ ≈⟨ λ-cong (helper {e = e}) ⟩ λg (to/⟦⟧T _ ∘ (e [ γC ])) ≈⟨ refl ⟩ λg (to/⟦⟧T _ ∘ (e [ ext (γC ∙ ext ! π₁) (from/⟦⟧T _ ∘ π₂) ])) ≈˘⟨ λ-cong (∘-resp-≈ʳ (cong/sub (cong/ext id∙ʳ refl) refl)) ⟩ λg (to/⟦⟧T _ ∘ (e [ ext ((γC ∙ ext ! π₁) ∙ _⊨_.id) (from/⟦⟧T _ ∘ π₂) ])) ≈˘⟨ λ-cong (∘-resp-≈ʳ (cong/sub ×id′-ext refl)) ⟩ λg (to/⟦⟧T _ ∘ (e [ (γC ∙ ext ! π₁) ×id′ ∙ ext _⊨_.id (from/⟦⟧T _ ∘ π₂)])) ≈⟨ λ-cong (∘-resp-≈ʳ sub/∙) ⟩ λg (to/⟦⟧T _ ∘ (e [ (γC ∙ ext ! π₁) ×id′ ] [ ext _⊨_.id (from/⟦⟧T _ ∘ π₂)])) ≈˘⟨ λ-cong (∘-resp-≈ʳ (cong/sub refl (cong/sub ×id′-∙ refl))) ⟩ λg (to/⟦⟧T _ ∘ (e [ γC ×id′ ∙ ext ! π₁ ×id′ ] [ ext _⊨_.id (from/⟦⟧T _ ∘ π₂)])) ≈⟨ λ-cong (∘-resp-≈ʳ (cong/sub refl sub/∙)) ⟩ λg (to/⟦⟧T _ ∘ (e [ ext (γC ∙ weaken) var ] [ ext (ext ! π₁ ∙ weaken) var ] [ ext _⊨_.id (from/⟦⟧T _ ∘ π₂)])) ≈˘⟨ λ-cong (∘-resp-≈ʳ (beta/=> _ _)) ⟩ λg (to/⟦⟧T _ ∘ app (abs (e [ ext (γC ∙ weaken) var ] [ ext (ext ! π₁ ∙ weaken) var ])) (from/⟦⟧T _ ∘ π₂)) ≈˘⟨ λ-cong (∘-resp-≈ʳ (cong/app comm/abs refl)) ⟩ λg (to/⟦⟧T _ ∘ app (abs (e [ ext (γC ∙ weaken) var ]) ∘ π₁) (from/⟦⟧T _ ∘ π₂)) ≈˘⟨ λ-cong (∘-resp-≈ʳ (cong/app (beta/*₁ _ _) (beta/*₂ _ _))) ⟩ λg (to/⟦⟧T _ ∘ app (fst (abs (e [ ext (γC ∙ weaken) var ]) ⁂ from/⟦⟧T _)) (snd (abs (e [ ext (γC ∙ weaken) var ]) ⁂ from/⟦⟧T _))) ≈˘⟨ λ-cong (∘-resp-≈ʳ (trans comm/app (cong/app (trans comm/fst (cong/fst (var/ext _ _))) (trans comm/snd (cong/snd (var/ext _ _)))))) ⟩ λg (to/⟦⟧T _ ∘ (app π₁ π₂) ∘ (abs (e [ ext (γC ∙ weaken) var ]) ⁂ from/⟦⟧T _)) ≈˘⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ˡ (cong/app (beta/*₁ _ _) (beta/*₂ _ _)))) ⟩ λg (to/⟦⟧T _ ∘ (app (fst (pair π₁ π₂)) (snd (pair π₁ π₂))) ∘ (abs (e [ ext (γC ∙ weaken) var ]) ⁂ from/⟦⟧T _)) ≈˘⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ˡ (cong/app (trans comm/fst (cong/fst (var/ext _ _))) (trans comm/snd (cong/snd (var/ext _ _)))))) ⟩ λg (to/⟦⟧T _ ∘ (app (fst var ∘ pair π₁ π₂) (snd var ∘ pair π₁ π₂)) ∘ (abs (e [ ext (γC ∙ weaken) var ]) ⁂ from/⟦⟧T _)) ≈˘⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ˡ comm/app)) ⟩ λg (to/⟦⟧T _ ∘ (app (fst var) (snd var) ∘ (pair π₁ π₂)) ∘ (abs (e [ ext (γC ∙ weaken) var ]) ⁂ from/⟦⟧T _)) ≈⟨ refl ⟩ λg (to/⟦⟧T _ ∘ (eval ∘ Prod.repack product exp.product) ∘ (abs (e [ ext (γC ∙ weaken) var ]) ⁂ from/⟦⟧T _)) ≈⟨ refl ⟩ λg (to/⟦⟧T _ ∘ eval′ ∘ (abs (e [ ext (γC ∙ weaken) var ]) ⁂ from/⟦⟧T _)) ≈˘⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ (⁂-cong₂ comm/abs refl))) ⟩ λg (to/⟦⟧T _ ∘ eval′ ∘ ((abs e [ γC ]) ⁂ from/⟦⟧T _)) ≈˘⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ (⁂-cong₂ identityˡ (Category.identityʳ Cl)))) ⟩ λg (to/⟦⟧T _ ∘ eval′ ∘ (var ∘ (abs e [ γC ]) ⁂ from/⟦⟧T _ ∘ var)) ≈˘⟨ λ-cong (∘-resp-≈ʳ (∘-resp-≈ʳ ⁂∘⁂)) ⟩ λg (to/⟦⟧T _ ∘ eval′ ∘ (var ⁂ from/⟦⟧T _) ∘ ((abs e [ γC ]) ⁂ var)) ≈˘⟨ λ-cong assoc²' ⟩ λg ((to/⟦⟧T _ ∘ eval′ ∘ (var ⁂ from/⟦⟧T _)) ∘ ((abs e [ γC ]) ⁂ var)) ≈˘⟨ exp.subst product product ⟩ (λg (to/⟦⟧T _ ∘ eval′ ∘ (var ⁂ from/⟦⟧T _))) ∘ (abs e [ γC ]) ≈⟨ refl ⟩ to/⟦⟧T (_ => _) ∘ (abs e [ γC ]) ∎ helper {e = app e₁ e₂} = begin eval′ ∘ ⟨ ⟦ e₁ ⟧ , ⟦ e₂ ⟧ ⟩ ≈⟨ refl ⟩ (app (fst var) (snd var) ∘ _) ∘ ⟨ ⟦ e₁ ⟧ , ⟦ e₂ ⟧ ⟩ ≈⟨ ∘-resp-≈ˡ (elimʳ η) ⟩ app (fst var) (snd var) ∘ ⟨ ⟦ e₁ ⟧ , ⟦ e₂ ⟧ ⟩ ≈⟨ ∘-resp-≈ʳ (⟨⟩-cong₂ (helper {e = e₁}) (helper {e = e₂})) ⟩ app (fst var) (snd var) ∘ ⟨ to/⟦⟧T _ ∘ (e₁ [ γC ]) , to/⟦⟧T _ ∘ (e₂ [ γC ]) ⟩ ≈⟨ comm/app ⟩ app (fst var ∘ ⟨ to/⟦⟧T _ ∘ (e₁ [ γC ]) , to/⟦⟧T _ ∘ (e₂ [ γC ]) ⟩) (snd var ∘ ⟨ to/⟦⟧T _ ∘ (e₁ [ γC ]) , to/⟦⟧T _ ∘ (e₂ [ γC ]) ⟩) ≈⟨ cong/app comm/fst comm/snd ⟩ app (fst (var ∘ ⟨ to/⟦⟧T _ ∘ (e₁ [ γC ]) , to/⟦⟧T _ ∘ (e₂ [ γC ]) ⟩)) (snd (var ∘ ⟨ to/⟦⟧T _ ∘ (e₁ [ γC ]) , to/⟦⟧T _ ∘ (e₂ [ γC ]) ⟩)) ≈⟨ cong/app (cong/fst (var/ext _ _)) (cong/snd (var/ext _ _)) ⟩ app (fst ⟨ to/⟦⟧T _ ∘ (e₁ [ γC ]) , to/⟦⟧T _ ∘ (e₂ [ γC ]) ⟩) (snd ⟨ to/⟦⟧T _ ∘ (e₁ [ γC ]) , to/⟦⟧T _ ∘ (e₂ [ γC ]) ⟩) ≈⟨ cong/app (beta/*₁ _ _) (beta/*₂ _ _) ⟩ app (to/⟦⟧T (_ => _) ∘ (e₁ [ γC ])) (to/⟦⟧T _ ∘ (e₂ [ γC ])) ≈⟨ refl ⟩ app (λg (to/⟦⟧T _ ∘ eval′ ∘ (var ⁂ from/⟦⟧T _)) ∘ (e₁ [ γC ])) (to/⟦⟧T _ ∘ (e₂ [ γC ])) ≈⟨ refl ⟩ app (curry ((to/⟦⟧T _ ∘ eval′ ∘ (var ⁂ from/⟦⟧T _)) ∘ Prod.repack product product) ∘ (e₁ [ γC ])) (to/⟦⟧T _ ∘ (e₂ [ γC ])) ≈⟨ refl ⟩ app (abs (((to/⟦⟧T _ ∘ eval′ ∘ (var ⁂ from/⟦⟧T _)) ∘ Prod.repack product product) [ ext ! (pair (var [ weaken ]) var) ]) ∘ (e₁ [ γC ])) (to/⟦⟧T _ ∘ (e₂ [ γC ])) ≈⟨ cong/app (cong/sub refl (cong/abs (cong/sub refl (elimʳ η)))) refl ⟩ app (abs ((to/⟦⟧T _ ∘ eval′ ∘ (var ⁂ from/⟦⟧T _)) [ ext ! (pair (var [ weaken ]) var) ]) ∘ (e₁ [ γC ])) (to/⟦⟧T _ ∘ (e₂ [ γC ])) ≈⟨ cong/app comm/abs refl ⟩ app (abs ((to/⟦⟧T _ ∘ eval′ ∘ (var ⁂ from/⟦⟧T _)) [ ext ! (pair (var [ weaken ]) var) ] [ ext ! (e₁ [ γC ]) ×id′ ])) (to/⟦⟧T _ ∘ (e₂ [ γC ])) ≈⟨ beta/=> _ _ ⟩ (to/⟦⟧T _ ∘ eval′ ∘ (var ⁂ from/⟦⟧T _)) [ ext ! (pair (var [ weaken ]) var) ] [ ext ! (e₁ [ γC ]) ×id′ ] [ ext _⊨_.id (to/⟦⟧T _ ∘ (e₂ [ γC ])) ] ≈⟨ refl ⟩ (to/⟦⟧T _ ∘ (eval ∘ Prod.repack product product) ∘ (var ⁂ from/⟦⟧T _)) [ ext ! (pair (var [ weaken ]) var) ] [ ext ! (e₁ [ γC ]) ×id′ ] [ ext _⊨_.id (to/⟦⟧T _ ∘ (e₂ [ γC ])) ] ≈⟨ cong/sub refl (cong/sub refl (cong/sub refl (∘-resp-≈ʳ (∘-resp-≈ˡ (elimʳ η))))) ⟩ (to/⟦⟧T _ ∘ (app (fst var) (snd var)) ∘ (var ⁂ from/⟦⟧T _)) [ ext ! (pair (var [ weaken ]) var) ] [ ext ! (e₁ [ γC ]) ×id′ ] [ ext _⊨_.id (to/⟦⟧T _ ∘ (e₂ [ γC ])) ] ≈˘⟨ sub/∙ ⟩ (to/⟦⟧T _ ∘ (app (fst var) (snd var)) ∘ (var ⁂ from/⟦⟧T _)) [ ext ! (pair (var [ weaken ]) var) ] [ ext ! (e₁ [ γC ]) ×id′ ∙ ext _⊨_.id (to/⟦⟧T _ ∘ (e₂ [ γC ])) ] ≈⟨ cong/sub (×id′-ext) refl ⟩ (to/⟦⟧T _ ∘ (app (fst var) (snd var)) ∘ (var ⁂ from/⟦⟧T _)) [ ext ! (pair (var [ weaken ]) var) ] [ ext (ext ! (e₁ [ γC ]) ∙ _⊨_.id) (to/⟦⟧T _ ∘ (e₂ [ γC ])) ] ≈⟨ cong/sub (cong/ext id∙ʳ refl) refl ⟩ (to/⟦⟧T _ ∘ (app (fst var) (snd var)) ∘ (var ⁂ from/⟦⟧T _)) [ ext ! (pair (var [ weaken ]) var) ] [ ext (ext ! (e₁ [ γC ])) (to/⟦⟧T _ ∘ (e₂ [ γC ])) ] ≈˘⟨ sub/∙ ⟩ (to/⟦⟧T _ ∘ (app (fst var) (snd var)) ∘ (var ⁂ from/⟦⟧T _)) [ ext ! (pair (var [ weaken ]) var) ∙ ext (ext ! (e₁ [ γC ])) (to/⟦⟧T _ ∘ (e₂ [ γC ])) ] ≈⟨ cong/sub (trans ext∙ (cong/ext (sym !-unique) refl)) refl ⟩ (to/⟦⟧T _ ∘ (app (fst var) (snd var)) ∘ (var ⁂ from/⟦⟧T _)) ∘ (pair (var [ weaken ]) var [ ext (ext ! (e₁ [ γC ])) (to/⟦⟧T _ ∘ (e₂ [ γC ])) ]) ≈⟨ ∘-resp-≈ʳ (trans comm/pair (cong/pair (trans (sym sub/∙) (cong/sub weaken/ext refl)) (var/ext _ _))) ⟩ (to/⟦⟧T _ ∘ (app (fst var) (snd var)) ∘ (var ⁂ from/⟦⟧T _)) ∘ (pair (var [ (ext ! (e₁ [ γC ])) ]) (to/⟦⟧T _ ∘ (e₂ [ γC ]))) ≈⟨ ∘-resp-≈ʳ (cong/pair (var/ext _ _) refl) ⟩ (to/⟦⟧T _ ∘ (app (fst var) (snd var)) ∘ (var ⁂ from/⟦⟧T _)) ∘ (pair (e₁ [ γC ]) (to/⟦⟧T _ ∘ (e₂ [ γC ]))) ≈⟨ pull-last ⁂∘⟨⟩ ⟩ to/⟦⟧T _ ∘ (app (fst var) (snd var)) ∘ (pair (var ∘ (e₁ [ γC ])) (from/⟦⟧T _ ∘ to/⟦⟧T _ ∘ (e₂ [ γC ]))) ≈⟨ ∘-resp-≈ʳ (cong/sub (cong/ext refl (cong/pair identityˡ (cancelˡ from∘to))) refl) ⟩ to/⟦⟧T _ ∘ (app (fst var) (snd var)) ∘ (pair (e₁ [ γC ]) (e₂ [ γC ])) ≈⟨ ∘-resp-≈ʳ (trans comm/app (cong/app (trans comm/fst (trans (cong/fst (var/ext _ _)) (beta/*₁ _ _))) (trans comm/snd (trans (cong/snd (var/ext _ _)) (beta/*₂ _ _))))) ⟩ to/⟦⟧T _ ∘ (app (e₁ [ γC ]) (e₂ [ γC ])) ≈˘⟨ ∘-resp-≈ʳ (comm/app) ⟩ to/⟦⟧T _ ∘ (app e₁ e₂ [ γC ]) ∎ where curry : _ -> _ curry e = abs (e [ ext ! (pair (var [ weaken ]) var) ]) helper {e = e [ γ ]} = begin ⟦ e ⟧ ∘ ⟦ γ ⟧S ≈⟨ pushˡ (helper {e = e}) ⟩ to/⟦⟧T _ ∘ (e [ γC ]) ∘ ⟦ γ ⟧S ≈⟨ refl ⟩ to/⟦⟧T _ ∘ (e [ γC ] [ ext ! ⟦ γ ⟧S ]) ≈˘⟨ ∘-resp-≈ʳ sub/∙ ⟩ to/⟦⟧T _ ∘ (e [ γC ∙ ext ! ⟦ γ ⟧S ]) ≈⟨ ∘-resp-≈ʳ (cong/sub (helperS {γ = γ}) refl) ⟩ to/⟦⟧T _ ∘ (e [ γ ∙ γC ]) ≈⟨ ∘-resp-≈ʳ sub/∙ ⟩ to/⟦⟧T _ ∘ (e [ γ ] [ γC ]) ∎ helperS {γ = id} = trans (trans (cong/∙ refl (cong/ext !-unique refl)) (trans (cong/∙ refl η-pair) id∙ʳ)) (sym id∙ˡ) helperS {γ = γ ∙ γ₁} = S.begin γC ∙ ext ! (⟦ γ ⟧S ∘ ⟦ γ₁ ⟧S) S.≈˘⟨ cong/∙ refl (trans ext∙ (cong/ext (sym !-unique) refl)) ⟩ γC ∙ (ext ! ⟦ γ ⟧S ∙ ext ! ⟦ γ₁ ⟧S) S.≈˘⟨ assoc∙ ⟩ (γC ∙ ext ! ⟦ γ ⟧S) ∙ ext ! ⟦ γ₁ ⟧S S.≈⟨ cong/∙ (helperS {γ = γ}) refl ⟩ (γ ∙ γC) ∙ ext ! ⟦ γ₁ ⟧S S.≈⟨ assoc∙ ⟩ γ ∙ (γC ∙ ext ! ⟦ γ₁ ⟧S) S.≈⟨ cong/∙ refl (helperS {γ = γ₁}) ⟩ γ ∙ (γ₁ ∙ γC) S.≈˘⟨ assoc∙ ⟩ (γ ∙ γ₁) ∙ γC S.∎ where import Relation.Binary.Reasoning.Setoid SubstSetoid as S helperS {γ = weaken} = sym weaken/ext helperS {γ = ext γ e} = S.begin γC {_ ∷ _} ∙ (ext ! ⟨ ⟦ γ ⟧S , ⟦ e ⟧ ⟩) S.≡⟨⟩ ext (γC ∙ ext ! π₁) (from/⟦⟧T _ ∘ π₂) ∙ (ext ! ⟨ ⟦ γ ⟧S , ⟦ e ⟧ ⟩) S.≈⟨ ext∙ ⟩ ext ((γC ∙ ext ! π₁) ∙ (ext ! ⟨ ⟦ γ ⟧S , ⟦ e ⟧ ⟩)) ((from/⟦⟧T _ ∘ π₂) ∘ ⟨ ⟦ γ ⟧S , ⟦ e ⟧ ⟩) S.≈⟨ cong/ext assoc∙ (pullʳ project₂) ⟩ ext (γC ∙ (ext ! π₁ ∙ (ext ! ⟨ ⟦ γ ⟧S , ⟦ e ⟧ ⟩))) (from/⟦⟧T _ ∘ ⟦ e ⟧) S.≈⟨ cong/ext (cong/∙ refl (trans ext∙ (cong/ext (sym !-unique) refl))) refl ⟩ ext (γC ∙ (ext ! (π₁ [ ext ! ⟨ ⟦ γ ⟧S , ⟦ e ⟧ ⟩ ]))) (from/⟦⟧T _ ∘ ⟦ e ⟧) S.≈⟨ cong/ext (cong/∙ refl (cong/ext refl project₁)) refl ⟩ ext (γC ∙ ext ! ⟦ γ ⟧S) (from/⟦⟧T _ ∘ ⟦ e ⟧) S.≈⟨ cong/ext (helperS {γ = γ}) (sym (switch-tofromˡ Iso/⟦⟧T (sym (helper {e = e})))) ⟩ ext (γ ∙ γC) (e [ γC ]) S.≈˘⟨ ext∙ ⟩ ext γ e ∙ γC S.∎ where import Relation.Binary.Reasoning.Setoid SubstSetoid as S helperS {γ = !} = trans (sym !-unique) !-unique satisfyAxiom : forall {Γ} {A} {e₁ e₂ : Γ ⊢ A} -> Ax Γ A e₁ e₂ -> ⟦ e₁ ⟧ ≈ ⟦ e₂ ⟧ satisfyAxiom {Γ} {A} {e₁} {e₂} x = trans (helper {e = e₁}) (trans (∘-resp-≈ʳ a) (sym (helper {e = e₂}))) where a : (e₁ [ γC ]) ≈ (e₂ [ γC ]) a = cong/sub refl (ax x) M : Model Cl CC Th M = S , satisfyAxiom
47.436214
791
0.46621
5873f8f18836e5e079aee79057ff4403153caed8
3,340
agda
Agda
examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Vec.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Vec.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Vec.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module Data.Vec where open import Prelude open import Data.Nat open import Data.Fin hiding (_==_; _<_) open import Logic.Structure.Applicative open import Logic.Identity open import Logic.Base infixl 90 _#_ infixr 50 _::_ infixl 45 _!_ _[!]_ data Vec (A : Set) : Nat -> Set where [] : Vec A zero _::_ : {n : Nat} -> A -> Vec A n -> Vec A (suc n) -- Indexing _!_ : {n : Nat}{A : Set} -> Vec A n -> Fin n -> A x :: xs ! fzero = x x :: xs ! fsuc i = xs ! i -- Insertion insert : {n : Nat}{A : Set} -> Fin (suc n) -> A -> Vec A n -> Vec A (suc n) insert fzero y xs = y :: xs insert (fsuc i) y (x :: xs) = x :: insert i y xs -- Index view data IndexView {A : Set} : {n : Nat}(i : Fin n) -> Vec A n -> Set where ixV : {n : Nat}{i : Fin (suc n)}(x : A)(xs : Vec A n) -> IndexView i (insert i x xs) _[!]_ : {A : Set}{n : Nat}(xs : Vec A n)(i : Fin n) -> IndexView i xs x :: xs [!] fzero = ixV x xs x :: xs [!] fsuc i = aux xs i (xs [!] i) where aux : {n : Nat}(xs : Vec _ n)(i : Fin n) -> IndexView i xs -> IndexView (fsuc i) (x :: xs) aux .(insert i y xs) i (ixV y xs) = ixV y (x :: xs) -- Build a vector from an indexing function (inverse of _!_) build : {n : Nat}{A : Set} -> (Fin n -> A) -> Vec A n build {zero } f = [] build {suc _} f = f fzero :: build (f ∘ fsuc) -- Constant vectors vec : {n : Nat}{A : Set} -> A -> Vec A n vec {zero } _ = [] vec {suc m} x = x :: vec x -- Vector application _#_ : {n : Nat}{A B : Set} -> Vec (A -> B) n -> Vec A n -> Vec B n [] # [] = [] (f :: fs) # (x :: xs) = f x :: fs # xs -- Vectors of length n form an applicative structure ApplicativeVec : {n : Nat} -> Applicative (\A -> Vec A n) ApplicativeVec {n} = applicative (vec {n}) (_#_ {n}) -- Map map : {n : Nat}{A B : Set} -> (A -> B) -> Vec A n -> Vec B n map f xs = vec f # xs -- Zip zip : {n : Nat}{A B C : Set} -> (A -> B -> C) -> Vec A n -> Vec B n -> Vec C n zip f xs ys = vec f # xs # ys module Elem where infix 40 _∈_ _∉_ data _∈_ {A : Set}(x : A) : {n : Nat}(xs : Vec A n) -> Set where hd : {n : Nat} {xs : Vec A n} -> x ∈ x :: xs tl : {n : Nat}{y : A}{xs : Vec A n} -> x ∈ xs -> x ∈ y :: xs data _∉_ {A : Set}(x : A) : {n : Nat}(xs : Vec A n) -> Set where nl : x ∉ [] cns : {n : Nat}{y : A}{xs : Vec A n} -> x ≢ y -> x ∉ xs -> x ∉ y :: xs ∉=¬∈ : {A : Set}{x : A}{n : Nat}{xs : Vec A n} -> x ∉ xs -> ¬ (x ∈ xs) ∉=¬∈ nl () ∉=¬∈ {A} (cns x≠x _) hd = elim-False (x≠x refl) ∉=¬∈ {A} (cns _ ne) (tl e) = ∉=¬∈ ne e ∈=¬∉ : {A : Set}{x : A}{n : Nat}{xs : Vec A n} -> x ∈ xs -> ¬ (x ∉ xs) ∈=¬∉ e ne = ∉=¬∈ ne e find : {A : Set}{n : Nat} -> ((x y : A) -> x ≡ y \/ x ≢ y) -> (x : A)(xs : Vec A n) -> x ∈ xs \/ x ∉ xs find _ _ [] = \/-IR nl find eq y (x :: xs) = aux x y (eq y x) (find eq y xs) where aux : forall x y -> y ≡ x \/ y ≢ x -> y ∈ xs \/ y ∉ xs -> y ∈ x :: xs \/ y ∉ x :: xs aux x .x (\/-IL refl) _ = \/-IL hd aux x y (\/-IR y≠x) (\/-IR y∉xs) = \/-IR (cns y≠x y∉xs) aux x y (\/-IR _) (\/-IL y∈xs) = \/-IL (tl y∈xs) delete : {A : Set}{n : Nat}(x : A)(xs : Vec A (suc n)) -> x ∈ xs -> Vec A n delete .x (x :: xs) hd = xs delete {A}{zero } _ ._ (tl ()) delete {A}{suc _} y (x :: xs) (tl p) = x :: delete y xs p
32.427184
88
0.456886
57feb013454cbc7940373821bb1b821cf951562e
5,351
agda
Agda
src/Bisimilarity/CCS/Examples/Natural-numbers.agda
nad/up-to
b936ff85411baf3401ad85ce85d5ff2e9aa0ca14
[ "MIT" ]
null
null
null
src/Bisimilarity/CCS/Examples/Natural-numbers.agda
nad/up-to
b936ff85411baf3401ad85ce85d5ff2e9aa0ca14
[ "MIT" ]
null
null
null
src/Bisimilarity/CCS/Examples/Natural-numbers.agda
nad/up-to
b936ff85411baf3401ad85ce85d5ff2e9aa0ca14
[ "MIT" ]
null
null
null
------------------------------------------------------------------------ -- An example that uses natural numbers as names, implemented using -- the coinductive definition of bisimilarity ------------------------------------------------------------------------ {-# OPTIONS --sized-types #-} module Bisimilarity.CCS.Examples.Natural-numbers where open import Equality.Propositional open import Logical-equivalence using (_⇔_) open import Prelude open import Prelude.Size open import Bijection equality-with-J using (_↔_) open import Equality.Decision-procedures equality-with-J open import Fin equality-with-J open import Function-universe equality-with-J as F hiding (id; _∘_; Distinct↔≢) open import Nat equality-with-J hiding (Distinct) open import Bisimilarity.CCS import Bisimilarity.Equational-reasoning-instances open import Bisimilarity.CCS.Examples open import Equational-reasoning open import Labelled-transition-system.CCS ℕ open import Bisimilarity CCS module _ (μ : Action) where -- Two processes that are strongly bisimilar. P : ∀ {i} → ℕ → Proc i P n = Restricted n ∣ (μ · λ { .force → P (1 + n) }) Q : ∀ {i} → Proc i Q = μ · λ { .force → Q } P∼Q : ∀ {i n} → [ i ] P n ∼ Q P∼Q {n = n} = P n ∼⟨ Restricted∼∅ ∣-cong (refl ·-cong λ { .force → P∼Q }) ⟩ ∅ ∣ Q ∼⟨ ∣-left-identity ⟩■ Q -- Q is not finite. Q-infinite : ¬ Finite Q Q-infinite (action f) = Q-infinite f -- However, Q is regular. Q-regular : Regular Q Q-regular = 1 , (λ _ → Q) , (fzero ,_) ∘ lemma where lemma : ∀ {P} → Subprocess P Q → Equal ∞ P Q lemma (refl eq) = eq lemma (action sub) = lemma sub -- The processes in the family P are not finite. P-infinite : ∀ {n} → ¬ Finite (P n) P-infinite (_ ∣ action f) = P-infinite f -- Furthermore they are irregular. P-irregular : ∀ {n} → ¬ Regular (P n) P-irregular (k , Qs , hyp) = irregular′ k hyp where Regular′ : ℕ → ∀ k → (Fin k → Proc ∞) → Type Regular′ n k Qs = ∀ {Q} → Subprocess Q (P n) → ∃ λ (i : Fin k) → Equal ∞ Q (Qs i) irregular′ : ∀ {n} k {Qs} → ¬ Regular′ n k Qs irregular′ {n} zero {Qs} = Regular′ n zero Qs ↝⟨ _$ refl (Proc-refl _) ⟩ (∃ λ (i : Fin zero) → _) ↝⟨ proj₁ ⟩□ ⊥ □ irregular′ {n} (suc k) {Qs} = Regular′ n (suc k) Qs ↝⟨ lemma₂ ⟩ (∃ λ Qs′ → Regular′ (suc n) k Qs′) ↝⟨ irregular′ k ∘ proj₂ ⟩□ ⊥ □ where lemma₁ : ∀ {Q} m {n} → Subprocess Q (P (1 + m + n)) → ¬ Equal ∞ Q (P n) lemma₁ m (par-right (action sub)) eq = lemma₁ (suc m) sub eq lemma₁ m {n} (refl (⟨ν refl ⟩ _ ∣ _)) (⟨ν suc[m+n]≡n ⟩ _ ∣ _) = ≢1+ _ (n ≡⟨ sym suc[m+n]≡n ⟩ suc (m + n) ≡⟨ cong suc (+-comm m) ⟩∎ suc (n + m) ∎) lemma₁ _ (par-left (refl ())) (_ ∣ _) lemma₁ _ (par-left (restriction (refl ()))) (_ ∣ _) lemma₁ _ (par-left (restriction (action (refl ())))) (_ ∣ _) lemma₁ _ (par-right (refl p)) q with Proc-trans (Proc-sym p) q ... | () lemma₂ : ∀ {n k Qs} → Regular′ n (suc k) Qs → ∃ λ Qs′ → Regular′ (suc n) k Qs′ lemma₂ {n} {k} {Qs} reg = let i , Pn≡Qsi = reg (refl (Proc-refl _)) Fin↔ = Fin↔Fin+≢ i Qs′ = Fin k ↔⟨ Fin↔ ⟩ (∃ λ (j : Fin (suc k)) → Distinct j i) ↝⟨ Qs ∘ proj₁ ⟩□ Proc ∞ □ in Qs′ , λ {Q} → Subprocess Q (P (1 + n)) ↝⟨ (λ sub → reg (par-right (action sub)) , lemma₁ 0 sub) ⟩ (∃ λ (j : Fin (suc k)) → Equal ∞ Q (Qs j)) × ¬ Equal ∞ Q (P n) ↝⟨ (λ { ((j , Q≡Qsj) , Q≢Pn) → ( j , (case j Fin.≟ i of λ where (inj₁ refl) → ⊥-elim $ Q≢Pn (Proc-trans Q≡Qsj (Proc-sym Pn≡Qsi)) (inj₂ j≢i) → _⇔_.from (Distinct↔≢ _) j≢i) ) , Q≡Qsj }) ⟩ (∃ λ (j : ∃ λ (j : Fin (suc k)) → Distinct j i) → Equal ∞ Q (Qs (proj₁ j))) ↝⟨ ∃-cong (λ _ → ≡⇒↝ _ $ cong (λ j → Equal ∞ Q (Qs (proj₁ j))) $ sym $ _↔_.right-inverse-of Fin↔ _) ⟩ (∃ λ (j : ∃ λ (j : Fin (suc k)) → Distinct j i) → Equal ∞ Q (Qs (proj₁ (_↔_.to Fin↔ (_↔_.from Fin↔ j))))) ↔⟨⟩ (∃ λ (j : ∃ λ (j : Fin (suc k)) → Distinct j i) → Equal ∞ Q (Qs′ (_↔_.from Fin↔ j))) ↝⟨ Σ-cong (inverse Fin↔) (λ _ → F.id) ⟩□ (∃ λ (j : Fin k) → Equal ∞ Q (Qs′ j)) □
39.932836
142
0.404224
0e86dd3238ac4b966fbf1dd30a54a86c104cb686
546
agda
Agda
src/Quasigroup/Definitions.agda
Akshobhya1234/agda-NonAssociativeAlgebra
443e831e536b756acbd1afd0d6bae7bc0d288048
[ "MIT" ]
2
2021-08-15T06:16:13.000Z
2021-08-17T09:14:03.000Z
src/Quasigroup/Definitions.agda
Akshobhya1234/agda-NonAssociativeAlgebra
443e831e536b756acbd1afd0d6bae7bc0d288048
[ "MIT" ]
2
2021-10-04T05:30:30.000Z
2021-10-09T08:24:56.000Z
src/Quasigroup/Definitions.agda
Akshobhya1234/agda-NonAssociativeAlgebra
443e831e536b756acbd1afd0d6bae7bc0d288048
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K --safe #-} open import Relation.Binary.Core module Quasigroup.Definitions {a ℓ} {A : Set a} -- The underlying set (_≈_ : Rel A ℓ) -- The underlying equality where open import Algebra.Core open import Data.Product LatinSquareProperty₁ : Op₂ A → Set _ LatinSquareProperty₁ _*_ = ∀ a b x → (a * x) ≈ b LatinSquareProperty₂ : Op₂ A → Set _ LatinSquareProperty₂ _*_ = ∀ a b y → (y * a) ≈ b LatinSquareProperty : Op₂ A → Set _ LatinSquareProperty _*_ = (LatinSquareProperty₁ _*_) × (LatinSquareProperty₂ _*_)
26
81
0.688645
41e9ecf5a81fb7b2bbb3675f2bf568a08884d428
9,089
agda
Agda
Cubical/Algebra/ZariskiLattice/BasicOpens.agda
ByteBucket123/cubical
aeaa15fb846a3e8bda73635dc7462ae3813b4b1b
[ "MIT" ]
null
null
null
Cubical/Algebra/ZariskiLattice/BasicOpens.agda
ByteBucket123/cubical
aeaa15fb846a3e8bda73635dc7462ae3813b4b1b
[ "MIT" ]
null
null
null
Cubical/Algebra/ZariskiLattice/BasicOpens.agda
ByteBucket123/cubical
aeaa15fb846a3e8bda73635dc7462ae3813b4b1b
[ "MIT" ]
null
null
null
{-# OPTIONS --safe --experimental-lossy-unification #-} module Cubical.Algebra.ZariskiLattice.BasicOpens where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.HLevels open import Cubical.Foundations.Powerset open import Cubical.Foundations.Transport open import Cubical.Foundations.Structure open import Cubical.Functions.FunExtEquiv import Cubical.Data.Empty as ⊥ open import Cubical.Data.Bool open import Cubical.Data.Nat renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_ ; +-comm to +ℕ-comm ; +-assoc to +ℕ-assoc ; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm) open import Cubical.Data.Sigma.Base open import Cubical.Data.Sigma.Properties open import Cubical.Data.FinData open import Cubical.Relation.Nullary open import Cubical.Relation.Binary open import Cubical.Algebra.Ring open import Cubical.Algebra.Algebra open import Cubical.Algebra.CommRing open import Cubical.Algebra.CommRing.Localisation.Base open import Cubical.Algebra.CommRing.Localisation.UniversalProperty open import Cubical.Algebra.CommRing.Localisation.InvertingElements open import Cubical.Algebra.CommAlgebra.Base open import Cubical.Algebra.CommAlgebra.Properties open import Cubical.Algebra.CommAlgebra.Localisation open import Cubical.Algebra.RingSolver.ReflectionSolving open import Cubical.HITs.SetQuotients as SQ open import Cubical.HITs.PropositionalTruncation as PT open Iso open BinaryRelation open isEquivRel private variable ℓ ℓ' : Level module Presheaf (A' : CommRing ℓ) where open CommRingStr (snd A') renaming (_·_ to _·r_ ; ·-comm to ·r-comm ; ·Assoc to ·rAssoc ; ·Lid to ·rLid ; ·Rid to ·rRid) open Exponentiation A' open CommRingTheory A' open isMultClosedSubset open CommAlgebraStr ⦃...⦄ private A = fst A' A[1/_] : A → CommAlgebra A' ℓ A[1/ x ] = AlgLoc.S⁻¹RAsCommAlg A' ([_ⁿ|n≥0] A' x) (powersFormMultClosedSubset _ _) A[1/_]ˣ : (x : A) → ℙ (fst A[1/ x ]) A[1/ x ]ˣ = (CommAlgebra→CommRing A[1/ x ]) ˣ _≼_ : A → A → Type ℓ x ≼ y = ∃[ n ∈ ℕ ] Σ[ z ∈ A ] x ^ n ≡ z ·r y -- rad(x) ⊆ rad(y) -- ≼ is a pre-order: Refl≼ : isRefl _≼_ Refl≼ x = PT.∣ 1 , 1r , ·r-comm _ _ ∣ Trans≼ : isTrans _≼_ Trans≼ x y z = map2 Trans≼Σ where Trans≼Σ : Σ[ n ∈ ℕ ] Σ[ a ∈ A ] x ^ n ≡ a ·r y → Σ[ n ∈ ℕ ] Σ[ a ∈ A ] y ^ n ≡ a ·r z → Σ[ n ∈ ℕ ] Σ[ a ∈ A ] x ^ n ≡ a ·r z Trans≼Σ (n , a , p) (m , b , q) = n ·ℕ m , (a ^ m ·r b) , path where path : x ^ (n ·ℕ m) ≡ a ^ m ·r b ·r z path = x ^ (n ·ℕ m) ≡⟨ ^-rdist-·ℕ x n m ⟩ (x ^ n) ^ m ≡⟨ cong (_^ m) p ⟩ (a ·r y) ^ m ≡⟨ ^-ldist-· a y m ⟩ a ^ m ·r y ^ m ≡⟨ cong (a ^ m ·r_) q ⟩ a ^ m ·r (b ·r z) ≡⟨ ·rAssoc _ _ _ ⟩ a ^ m ·r b ·r z ∎ R : A → A → Type ℓ R x y = x ≼ y × y ≼ x -- rad(x) ≡ rad(y) RequivRel : isEquivRel R RequivRel .reflexive x = Refl≼ x , Refl≼ x RequivRel .symmetric _ _ Rxy = (Rxy .snd) , (Rxy .fst) RequivRel .transitive _ _ _ Rxy Ryz = Trans≼ _ _ _ (Rxy .fst) (Ryz .fst) , Trans≼ _ _ _ (Ryz .snd) (Rxy .snd) RpropValued : isPropValued R RpropValued x y = isProp× isPropPropTrunc isPropPropTrunc powerIs≽ : (x a : A) → x ∈ ([_ⁿ|n≥0] A' a) → a ≼ x powerIs≽ x a = map powerIs≽Σ where powerIs≽Σ : Σ[ n ∈ ℕ ] (x ≡ a ^ n) → Σ[ n ∈ ℕ ] Σ[ z ∈ A ] (a ^ n ≡ z ·r x) powerIs≽Σ (n , p) = n , 1r , sym p ∙ sym (·rLid _) module ≼ToLoc (x y : A) where private instance _ = snd A[1/ x ] lemma : x ≼ y → y ⋆ 1a ∈ A[1/ x ]ˣ -- y/1 ∈ A[1/x]ˣ lemma = PT.rec (A[1/ x ]ˣ (y ⋆ 1a) .snd) lemmaΣ where path1 : (y z : A) → 1r ·r (y ·r 1r ·r z) ·r 1r ≡ z ·r y path1 = solve A' path2 : (xn : A) → xn ≡ 1r ·r 1r ·r (1r ·r 1r ·r xn) path2 = solve A' lemmaΣ : Σ[ n ∈ ℕ ] Σ[ a ∈ A ] x ^ n ≡ a ·r y → y ⋆ 1a ∈ A[1/ x ]ˣ lemmaΣ (n , z , p) = [ z , (x ^ n) , PT.∣ n , refl ∣ ] -- xⁿ≡zy → y⁻¹ ≡ z/xⁿ , eq/ _ _ ((1r , powersFormMultClosedSubset _ _ .containsOne) , (path1 _ _ ∙∙ sym p ∙∙ path2 _)) module ≼PowerToLoc (x y : A) (x≼y : x ≼ y) where private [yⁿ|n≥0] = [_ⁿ|n≥0] A' y instance _ = snd A[1/ x ] lemma : ∀ (s : A) → s ∈ [yⁿ|n≥0] → s ⋆ 1a ∈ A[1/ x ]ˣ lemma _ s∈[yⁿ|n≥0] = ≼ToLoc.lemma _ _ (Trans≼ _ y _ x≼y (powerIs≽ _ _ s∈[yⁿ|n≥0])) 𝓞ᴰ : A / R → CommAlgebra A' ℓ 𝓞ᴰ = rec→Gpd.fun isGroupoidCommAlgebra (λ a → A[1/ a ]) RCoh LocPathProp where RCoh : ∀ a b → R a b → A[1/ a ] ≡ A[1/ b ] RCoh a b (a≼b , b≼a) = fst (isContrS₁⁻¹R≡S₂⁻¹R (≼PowerToLoc.lemma _ _ b≼a) (≼PowerToLoc.lemma _ _ a≼b)) where open AlgLocTwoSubsets A' ([_ⁿ|n≥0] A' a) (powersFormMultClosedSubset _ _) ([_ⁿ|n≥0] A' b) (powersFormMultClosedSubset _ _) LocPathProp : ∀ a b → isProp (A[1/ a ] ≡ A[1/ b ]) LocPathProp a b = isPropS₁⁻¹R≡S₂⁻¹R where open AlgLocTwoSubsets A' ([_ⁿ|n≥0] A' a) (powersFormMultClosedSubset _ _) ([_ⁿ|n≥0] A' b) (powersFormMultClosedSubset _ _) -- The quotient A/R corresponds to the basic opens of the Zariski topology. -- Multiplication lifts to the quotient and corresponds to intersection -- of basic opens, i.e. we get a meet-semilattice with: _∧/_ : A / R → A / R → A / R _∧/_ = setQuotSymmBinOp (RequivRel .reflexive) (RequivRel .transitive) _·r_ ·r-comm ·r-lcoh where ·r-lcoh-≼ : (x y z : A) → x ≼ y → (x ·r z) ≼ (y ·r z) ·r-lcoh-≼ x y z = map ·r-lcoh-≼Σ where path : (x z a y zn : A) → x ·r z ·r (a ·r y ·r zn) ≡ x ·r zn ·r a ·r (y ·r z) path = solve A' ·r-lcoh-≼Σ : Σ[ n ∈ ℕ ] Σ[ a ∈ A ] x ^ n ≡ a ·r y → Σ[ n ∈ ℕ ] Σ[ a ∈ A ] (x ·r z) ^ n ≡ a ·r (y ·r z) ·r-lcoh-≼Σ (n , a , p) = suc n , (x ·r z ^ n ·r a) , (cong (x ·r z ·r_) (^-ldist-· _ _ _) ∙∙ cong (λ v → x ·r z ·r (v ·r z ^ n)) p ∙∙ path _ _ _ _ _) ·r-lcoh : (x y z : A) → R x y → R (x ·r z) (y ·r z) ·r-lcoh x y z Rxy = ·r-lcoh-≼ x y z (Rxy .fst) , ·r-lcoh-≼ y x z (Rxy .snd) -- The induced partial order _≼/_ : A / R → A / R → Type ℓ x ≼/ y = x ≡ (x ∧/ y) -- coincides with our ≼ ≼/CoincidesWith≼ : ∀ (x y : A) → [ x ] ≼/ [ y ] ≡ x ≼ y ≼/CoincidesWith≼ x y = [ x ] ≼/ [ y ] -- ≡⟨ refl ⟩ [ x ] ≡ [ x ·r y ] ≡⟨ isoToPath (isEquivRel→effectiveIso RpropValued RequivRel _ _) ⟩ R x (x ·r y) ≡⟨ hPropExt (RpropValued _ _) isPropPropTrunc ·To≼ ≼To· ⟩ x ≼ y ∎ where x≼xy→x≼yΣ : Σ[ n ∈ ℕ ] Σ[ z ∈ A ] x ^ n ≡ z ·r (x ·r y) → Σ[ n ∈ ℕ ] Σ[ z ∈ A ] x ^ n ≡ z ·r y x≼xy→x≼yΣ (n , z , p) = n , (z ·r x) , p ∙ ·rAssoc _ _ _ ·To≼ : R x (x ·r y) → x ≼ y ·To≼ (x≼xy , _) = PT.map x≼xy→x≼yΣ x≼xy x≼y→x≼xyΣ : Σ[ n ∈ ℕ ] Σ[ z ∈ A ] x ^ n ≡ z ·r y → Σ[ n ∈ ℕ ] Σ[ z ∈ A ] x ^ n ≡ z ·r (x ·r y) x≼y→x≼xyΣ (n , z , p) = suc n , z , cong (x ·r_) p ∙ ·-commAssocl _ _ _ ≼To· : x ≼ y → R x ( x ·r y) ≼To· x≼y = PT.map x≼y→x≼xyΣ x≼y , PT.∣ 1 , y , ·rRid _ ∙ ·r-comm _ _ ∣ Refl≼/ : isRefl _≼/_ Refl≼/ = SQ.elimProp (λ _ → squash/ _ _) λ _ → transport⁻ (≼/CoincidesWith≼ _ _) (Refl≼ _) Trans≼/ : isTrans _≼/_ Trans≼/ = SQ.elimProp3 (λ _ _ _ → isPropΠ2 (λ _ _ → squash/ _ _)) λ _ _ _ [a]≼/[b] [b]≼/[c] → transport⁻ (≼/CoincidesWith≼ _ _) (Trans≼ _ _ _ (transport (≼/CoincidesWith≼ _ _) [a]≼/[b]) (transport (≼/CoincidesWith≼ _ _) [b]≼/[c])) -- The restrictions: ρᴰᴬ : (a b : A) → a ≼ b → isContr (CommAlgebraHom A[1/ b ] A[1/ a ]) ρᴰᴬ _ b a≼b = A[1/b]HasUniversalProp _ (≼PowerToLoc.lemma _ _ a≼b) where open AlgLoc A' ([_ⁿ|n≥0] A' b) (powersFormMultClosedSubset _ _) renaming (S⁻¹RHasAlgUniversalProp to A[1/b]HasUniversalProp) ρᴰᴬId : ∀ (a : A) (r : a ≼ a) → ρᴰᴬ a a r .fst ≡ idAlgHom ρᴰᴬId a r = ρᴰᴬ a a r .snd _ ρᴰᴬComp : ∀ (a b c : A) (l : a ≼ b) (m : b ≼ c) → ρᴰᴬ a c (Trans≼ _ _ _ l m) .fst ≡ ρᴰᴬ a b l .fst ∘a ρᴰᴬ b c m .fst ρᴰᴬComp a _ c l m = ρᴰᴬ a c (Trans≼ _ _ _ l m) .snd _ ρᴰ : (x y : A / R) → x ≼/ y → CommAlgebraHom (𝓞ᴰ y) (𝓞ᴰ x) ρᴰ = elimContr2 λ _ _ → isOfHLevelΠ 0 λ [a]≼/[b] → ρᴰᴬ _ _ (transport (≼/CoincidesWith≼ _ _) [a]≼/[b]) ρᴰId : ∀ (x : A / R) (r : x ≼/ x) → ρᴰ x x r ≡ idAlgHom ρᴰId = SQ.elimProp (λ _ → isPropΠ (λ _ → isSetAlgebraHom _ _ _ _)) λ a r → ρᴰᴬId a (transport (≼/CoincidesWith≼ _ _) r) ρᴰComp : ∀ (x y z : A / R) (l : x ≼/ y) (m : y ≼/ z) → ρᴰ x z (Trans≼/ _ _ _ l m) ≡ ρᴰ x y l ∘a ρᴰ y z m ρᴰComp = SQ.elimProp3 (λ _ _ _ → isPropΠ2 (λ _ _ → isSetAlgebraHom _ _ _ _)) λ a b c _ _ → sym (ρᴰᴬ a c _ .snd _) ∙ ρᴰᴬComp a b c _ _
38.350211
99
0.52382
293e5cfb67c262f4a0db5fd6ae389405d01dbc61
6,593
agda
Agda
benchmark/monad/Monad.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
benchmark/monad/Monad.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
benchmark/monad/Monad.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
------------------------------------------------------------------------ -- Parser monad ------------------------------------------------------------------------ open import Relation.Binary open import Relation.Binary.OrderMorphism open import Relation.Binary.PropositionalEquality import Relation.Binary.Properties.StrictTotalOrder as STOProps open import Data.Product open import Level module Monad -- Input string positions. {Position : Set} {_<P_ : Rel Position zero} (posOrdered : IsStrictTotalOrder _≡_ _<P_) -- Input strings. (Input : Position -> Set) -- In order to be able to store results in a memo table (and avoid -- having to lift the table code to Set1) the result types have to -- come from the following universe: {Result : Set} (⟦_⟧ : Result -> Set) -- Memoisation keys. These keys must uniquely identify the -- computation that they are associated with, when paired up with -- the current input string position. {Key : let PosPoset = STOProps.poset (record { Carrier = _ ; _≈_ = _; _<_ = _ ; isStrictTotalOrder = posOrdered }) MonoFun = PosPoset ⇒-Poset PosPoset in MonoFun -> Result -> Set} {_≋_ _<_ : Rel (∃₂ Key) zero} (keyOrdered : IsStrictTotalOrder _≋_ _<_) -- Furthermore the underlying equality needs to be strong enough. (funsEqual : _≋_ =[ proj₁ ]⇒ _≡_) (resultsEqual : _≋_ =[ (\rfk -> proj₁ (proj₂ rfk)) ]⇒ _≡_) where open _⇒-Poset_ open STOProps (record { Carrier = _ ; _≈_ = _; _<_ = _ ; isStrictTotalOrder = posOrdered }) import IndexedMap as Map -- renaming (Map to MemoTable) open import Category.Monad open import Category.Monad.State import Data.List as List; open List using (List) open import Data.Unit hiding (poset; _≤_) open import Function open import Data.Maybe hiding (Eq) open import Data.Product.Relation.Lex.Strict open import Data.Product.Relation.Pointwise.NonDependent import Relation.Binary.Construct.On as On ------------------------------------------------------------------------ -- Monotone functions MonoFun : Set MonoFun = poset ⇒-Poset poset ------------------------------------------------------------------------ -- Memo tables -- Indices and keys used by the memo table. Index : Set Index = Position × MonoFun × Result data MemoTableKey : Index -> Set where key : forall {f r} (key : Key f r) pos -> MemoTableKey (pos , f , r) -- Input strings of a certain maximum length. Input≤ : Position -> Set Input≤ pos = ∃ \pos′ -> pos′ ≤ pos × Input pos′ -- Memo table values. Value : Index -> Set Value (pos , f , r) = List (⟦ r ⟧ × Input≤ (fun f pos)) -- Shuffles the elements to simplify defining equality and order -- relations for the keys. shuffle : ∃ MemoTableKey -> Position × ∃₂ Key shuffle ((pos , f , r) , key k .pos) = (pos , f , r , k) -- Equality and order. Eq : Rel (∃ MemoTableKey) _ Eq = Pointwise _≡_ _≋_ on shuffle Lt : Rel (∃ MemoTableKey) _ Lt = ×-Lex _≡_ _<P_ _<_ on shuffle isOrdered : IsStrictTotalOrder Eq Lt isOrdered = On.isStrictTotalOrder shuffle (×-isStrictTotalOrder posOrdered keyOrdered) indicesEqual′ : Eq =[ proj₁ ]⇒ _≡_ indicesEqual′ {((_ , _ , _) , key _ ._)} {((_ , _ , _) , key _ ._)} (eq₁ , eq₂) = cong₂ _,_ eq₁ (cong₂ _,_ (funsEqual eq₂) (resultsEqual eq₂)) open Map isOrdered (\{k₁} {k₂} -> indicesEqual′ {k₁} {k₂}) Value {- ------------------------------------------------------------------------ -- Parser monad -- The parser monad is built upon a list monad, for backtracking, and -- two state monads. One of the state monads stores a memo table, and -- is unaffected by backtracking. The other state monad, which /is/ -- affected by backtracking, stores the remaining input string. -- The memo table state monad. module MemoState = RawMonadState (StateMonadState MemoTable) -- The list monad. module List = RawMonadPlus List.ListMonadPlus -- The inner monad (memo table plus list). module IM where Inner : Set -> Set Inner R = State MemoTable (List R) InnerMonadPlus : RawMonadPlus Inner InnerMonadPlus = record { monadZero = record { monad = record { return = \x -> return (List.return x) ; _>>=_ = \m f -> List.concat <$> (List.mapM monad f =<< m) } ; ∅ = return List.∅ } ; _∣_ = \m₁ m₂ -> List._∣_ <$> m₁ ⊛ m₂ } where open MemoState InnerMonadState : RawMonadState MemoTable Inner InnerMonadState = record { monad = RawMonadPlus.monad InnerMonadPlus ; get = List.return <$> get ; put = \s -> List.return <$> put s } where open MemoState open RawMonadPlus InnerMonadPlus public open RawMonadState InnerMonadState public using (get; put; modify) -- The complete parser monad. module PM where P : MonoFun -> Set -> Set P f A = forall {n} -> Input n -> IM.Inner (A × Input≤ (fun f n)) -- Memoises the computation, assuming that the key is sufficiently -- unique. memoise : forall {f r} -> Key f r -> P f ⟦ r ⟧ -> P f ⟦ r ⟧ memoise k p {pos} xs = let open IM in helper =<< lookup k′ <$> get where i = (pos , _) k′ : MemoTableKey i k′ = key k pos helper : Maybe (Value i) -> State MemoTable (Value i) helper (just ris) = return ris where open MemoState helper nothing = p xs >>= \ris -> modify (insert k′ ris) >> return ris where open MemoState -- Other monadic operations. return : forall {A} -> A -> P idM A return a = \xs -> IM.return (a , _ , refl , xs) _>>=_ : forall {A B f g} -> P f A -> (A -> P g B) -> P (g ∘M f) B _>>=_ {g = g} m₁ m₂ xs = m₁ xs ⟨ IM._>>=_ ⟩ \ays -> let a = proj₁ ays le = proj₁ $ proj₂ $ proj₂ ays ys = proj₂ $ proj₂ $ proj₂ ays in fix le ⟨ IM._<$>_ ⟩ m₂ a ys where lemma : forall {i j k} -> j ≤ k -> i ≤ fun g j -> i ≤ fun g k lemma j≤k i≤gj = trans i≤gj (monotone g j≤k) fix : forall {A i j} -> i ≤ j -> A × Input≤ (fun g i) -> A × Input≤ (fun g j) fix le = map-× id (map-Σ id (map-× (lemma le) id)) ∅ : forall {A} -> P idM A ∅ = const IM.∅ _∣_ : forall {A f} -> P f A -> P f A -> P f A m₁ ∣ m₂ = \xs -> IM._∣_ (m₁ xs) (m₂ xs) put : forall {n} -> Input n -> P (constM n) ⊤ put xs = \_ -> IM.return (_ , _ , refl , xs) modify : forall {A f} -> (forall {n} -> Input n -> A × Input (fun f n)) -> P f A modify g xs = IM.return (proj₁ gxs , _ , refl , proj₂ gxs) where gxs = g xs -}
29.044053
72
0.575004
29a804add2c7fb3a1d1de8359e1f0638cf27f769
1,040
agda
Agda
notes/FOT/FOTC/Data/Nat/SubtractionSL.agda
asr/fotc
2fc9f2b81052a2e0822669f02036c5750371b72d
[ "MIT" ]
11
2015-09-03T20:53:42.000Z
2021-09-12T16:09:54.000Z
notes/FOT/FOTC/Data/Nat/SubtractionSL.agda
asr/fotc
2fc9f2b81052a2e0822669f02036c5750371b72d
[ "MIT" ]
2
2016-10-12T17:28:16.000Z
2017-01-01T14:34:26.000Z
notes/FOT/FOTC/Data/Nat/SubtractionSL.agda
asr/fotc
2fc9f2b81052a2e0822669f02036c5750371b72d
[ "MIT" ]
3
2016-09-19T14:18:30.000Z
2018-03-14T08:50:00.000Z
------------------------------------------------------------------------------ -- Testing an alternative definition of subtraction ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Data.Nat.SubtractionSL where open import Data.Nat hiding ( _∸_ ) open import Relation.Binary.PropositionalEquality -- We add 3 to the fixities of the Agda standard library 0.8.1 (see -- Data/Nat.agda). infixl 9 _∸₁_ _∸₂_ -- First definition (from the Agda standard library 0.8.1). _∸₁_ : ℕ → ℕ → ℕ m ∸₁ zero = m zero ∸₁ suc n = zero suc m ∸₁ suc n = m ∸₁ n -- Second definition. _∸₂_ : ℕ → ℕ → ℕ m ∸₂ zero = m {-# CATCHALL #-} zero ∸₂ n = zero suc m ∸₂ suc n = m ∸₂ n -- Both definitions are equivalents. thm : ∀ m n → m ∸₁ n ≡ m ∸₂ n thm m zero = refl thm zero (suc n) = refl thm (suc m) (suc n) = thm m n
28.108108
78
0.507692
3daa4936860ce8a7b51f6b72243e615a90b4ce91
864
agda
Agda
Functional/Combinations.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
6
2020-04-07T17:58:13.000Z
2022-02-05T06:53:22.000Z
Functional/Combinations.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
Functional/Combinations.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
module Functional.Combinations where open import Type -- TODO: Generalize these. Probably by lists and foldᵣ of combination and rotation construction functions. Also categorically or dependently rotate₃Fn₃Op₂ : ∀{ℓ₁ ℓ₂}{A : Type{ℓ₁}}{B : Type{ℓ₂}} → (A → A → A → B) → (B → B → B) → (A → A → A → B) rotate₃Fn₃Op₂(F)(_▫_) a b c = (F a b c) ▫ ((F b c a) ▫ (F c a b)) combine₃Fn₂Op₂ : ∀{ℓ₁ ℓ₂}{A : Type{ℓ₁}}{B : Type{ℓ₂}} → (A → A → B) → (B → B → B) → (A → A → A → B) combine₃Fn₂Op₂(F)(_▫_) a b c = (F a b) ▫ ((F a c) ▫ (F b c)) all₃Fn₁Op₂ : ∀{ℓ₁ ℓ₂}{A : Type{ℓ₁}}{B : Type{ℓ₂}} → (A → B) → (B → B → B) → (A → A → A → B) all₃Fn₁Op₂(F)(_▫_) a b c = (F a) ▫ ((F b) ▫ (F c)) combine₄Fn₃Op₂ : ∀{ℓ₁ ℓ₂}{A : Type{ℓ₁}}{B : Type{ℓ₂}} → (A → A → A → B) → (B → B → B) → (A → A → A → A → B) combine₄Fn₃Op₂(F)(_▫_) a b c d = (F a b c) ▫ ((F a b d) ▫ ((F a c d) ▫ (F b c d)))
50.823529
140
0.518519
57ec4f499e9680fe46fd9a9fe92653855f5522a7
9,535
agda
Agda
core/lib/types/Paths.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
null
null
null
core/lib/types/Paths.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
null
null
null
core/lib/types/Paths.agda
mikeshulman/HoTT-Agda
e7d663b63d89f380ab772ecb8d51c38c26952dbb
[ "MIT" ]
1
2018-12-26T21:31:57.000Z
2018-12-26T21:31:57.000Z
{-# OPTIONS --without-K --rewriting #-} open import lib.Basics module lib.types.Paths where {- ! is an equivalence and works on ≠ -} module _ {i} {A : Type i} {x y : A} where !-equiv : (x == y) ≃ (y == x) !-equiv = equiv ! ! !-! !-! ≠-inv : (x ≠ y) → (y ≠ x) ≠-inv x≠y y=x = x≠y (! y=x) {- Pre- and post- concatenation are equivalences -} module _ {i} {A : Type i} {x y z : A} where pre∙-is-equiv : (p : x == y) → is-equiv (λ (q : y == z) → p ∙ q) pre∙-is-equiv p = is-eq (λ q → p ∙ q) (λ r → ! p ∙ r) f-g g-f where f-g : ∀ r → p ∙ ! p ∙ r == r f-g r = ! (∙-assoc p (! p) r) ∙ ap (λ s → s ∙ r) (!-inv-r p) g-f : ∀ q → ! p ∙ p ∙ q == q g-f q = ! (∙-assoc (! p) p q) ∙ ap (λ s → s ∙ q) (!-inv-l p) pre∙-equiv : (p : x == y) → (y == z) ≃ (x == z) pre∙-equiv p = ((λ q → p ∙ q) , pre∙-is-equiv p) post∙-is-equiv : (p : y == z) → is-equiv (λ (q : x == y) → q ∙ p) post∙-is-equiv p = is-eq (λ q → q ∙ p) (λ r → r ∙ ! p) f-g g-f where f-g : ∀ r → (r ∙ ! p) ∙ p == r f-g r = ∙-assoc r (! p) p ∙ ap (λ s → r ∙ s) (!-inv-l p) ∙ ∙-unit-r r g-f : ∀ q → (q ∙ p) ∙ ! p == q g-f q = ∙-assoc q p (! p) ∙ ap (λ s → q ∙ s) (!-inv-r p) ∙ ∙-unit-r q post∙-equiv : (p : y == z) → (x == y) ≃ (x == z) post∙-equiv p = ((λ q → q ∙ p) , post∙-is-equiv p) pre∙'-is-equiv : (p : x == y) → is-equiv (λ (q : y == z) → p ∙' q) pre∙'-is-equiv p = is-eq (λ q → p ∙' q) (λ r → ! p ∙' r) f-g g-f where f-g : ∀ r → p ∙' ! p ∙' r == r f-g r = ! (∙'-assoc p (! p) r) ∙ ap (λ s → s ∙' r) (!-inv'-r p) ∙ ∙'-unit-l r g-f : ∀ q → ! p ∙' p ∙' q == q g-f q = ! (∙'-assoc (! p) p q) ∙ ap (λ s → s ∙' q) (!-inv'-l p) ∙ ∙'-unit-l q pre∙'-equiv : (p : x == y) → (y == z) ≃ (x == z) pre∙'-equiv p = ((λ q → p ∙' q) , pre∙'-is-equiv p) post∙'-is-equiv : (p : y == z) → is-equiv (λ (q : x == y) → q ∙' p) post∙'-is-equiv p = is-eq (λ q → q ∙' p) (λ r → r ∙' ! p) f-g g-f where f-g : ∀ r → (r ∙' ! p) ∙' p == r f-g r = ∙'-assoc r (! p) p ∙ ap (λ s → r ∙' s) (!-inv'-l p) g-f : ∀ q → (q ∙' p) ∙' ! p == q g-f q = ∙'-assoc q p (! p) ∙ ap (λ s → q ∙' s) (!-inv'-r p) post∙'-equiv : (p : y == z) → (x == y) ≃ (x == z) post∙'-equiv p = ((λ q → q ∙' p) , post∙'-is-equiv p) module _ {i j} {A : Type i} {B : Type j} {f : A → B} {b : B} where ↓-app=cst-in : {x y : A} {p : x == y} {u : f x == b} {v : f y == b} → u == (ap f p ∙ v) → (u == v [ (λ x → f x == b) ↓ p ]) ↓-app=cst-in {p = idp} q = q ↓-app=cst-out : {x y : A} {p : x == y} {u : f x == b} {v : f y == b} → (u == v [ (λ x → f x == b) ↓ p ]) → u == (ap f p ∙ v) ↓-app=cst-out {p = idp} r = r ↓-app=cst-econv : {x y : A} {p : x == y} {u : f x == b} {v : f y == b} → (u == (ap f p ∙ v)) ≃ (u == v [ (λ x → f x == b) ↓ p ]) ↓-app=cst-econv {p = idp} = equiv ↓-app=cst-in ↓-app=cst-out (λ _ → idp) (λ _ → idp) ↓-cst=app-in : {x y : A} {p : x == y} {u : b == f x} {v : b == f y} → (u ∙' ap f p) == v → (u == v [ (λ x → b == f x) ↓ p ]) ↓-cst=app-in {p = idp} q = q ↓-cst=app-out : {x y : A} {p : x == y} {u : b == f x} {v : b == f y} → (u == v [ (λ x → b == f x) ↓ p ]) → (u ∙' ap f p) == v ↓-cst=app-out {p = idp} r = r ↓-cst=app-econv : {x y : A} {p : x == y} {u : b == f x} {v : b == f y} → ((u ∙' ap f p) == v) ≃ (u == v [ (λ x → b == f x) ↓ p ]) ↓-cst=app-econv {p = idp} = equiv ↓-cst=app-in ↓-cst=app-out (λ _ → idp) (λ _ → idp) {- alternative versions -} module _ {i j} {A : Type i} {B : Type j} {f : A → B} where ↓-app=cst-in' : {x y : A} {b : B} {p : x == y} {u : f x == b} {v : f y == b} → u == (ap f p ∙' v) → (u == v [ (λ x → f x == b) ↓ p ]) ↓-app=cst-in' {p = idp} {v = idp} q = q ↓-app=cst-out' : {x y : A} {b : B} {p : x == y} {u : f x == b} {v : f y == b} → (u == v [ (λ x → f x == b) ↓ p ]) → u == (ap f p ∙' v) ↓-app=cst-out' {p = idp} {v = idp} r = r ↓-cst=app-in' : {x y : A} {b : B} {p : x == y} {u : b == f x} {v : b == f y} → (u ∙ ap f p) == v → (u == v [ (λ x → b == f x) ↓ p ]) ↓-cst=app-in' {p = idp} {u = idp} q = q ↓-cst=app-out' : {x y : A} {b : B} {p : x == y} {u : b == f x} {v : b == f y} → (u == v [ (λ x → b == f x) ↓ p ]) → (u ∙ ap f p) == v ↓-cst=app-out' {p = idp} {u = idp} r = r module _ {i} {A : Type i} where ↓-app=idf-in : {f : A → A} {x y : A} {p : x == y} {u : f x == x} {v : f y == y} → u ∙' p == ap f p ∙ v → u == v [ (λ z → f z == z) ↓ p ] ↓-app=idf-in {p = idp} q = q ↓-app=idf-out : {f : A → A} {x y : A} {p : x == y} {u : f x == x} {v : f y == y} → u == v [ (λ z → f z == z) ↓ p ] → u ∙' p == ap f p ∙ v ↓-app=idf-out {p = idp} q = q ↓-cst=idf-in : {a : A} {x y : A} {p : x == y} {u : a == x} {v : a == y} → (u ∙' p) == v → (u == v [ (λ x → a == x) ↓ p ]) ↓-cst=idf-in {p = idp} q = q ↓-cst=idf-in' : {a : A} {x y : A} {p : x == y} {u : a == x} {v : a == y} → (u ∙ p) == v → (u == v [ (λ x → a == x) ↓ p ]) ↓-cst=idf-in' {p = idp} q = ! (∙-unit-r _) ∙ q ↓-idf=cst-in : {a : A} {x y : A} {p : x == y} {u : x == a} {v : y == a} → u == p ∙ v → (u == v [ (λ x → x == a) ↓ p ]) ↓-idf=cst-in {p = idp} q = q ↓-idf=cst-out : {a : A} {x y : A} {p : x == y} {u : x == a} {v : y == a} → (u == v [ (λ x → x == a) ↓ p ]) → u == p ∙ v ↓-idf=cst-out {p = idp} q = q ↓-idf=cst-in' : {a : A} {x y : A} {p : x == y} {u : x == a} {v : y == a} → u == p ∙' v → (u == v [ (λ x → x == a) ↓ p ]) ↓-idf=cst-in' {p = idp} q = q ∙ ∙'-unit-l _ ↓-idf=idf-in' : {x y : A} {p : x == y} {u : x == x} {v : y == y} → u ∙ p == p ∙' v → (u == v [ (λ x → x == x) ↓ p ]) ↓-idf=idf-in' {p = idp} q = ! (∙-unit-r _) ∙ q ∙ ∙'-unit-l _ ↓-idf=idf-out' : {x y : A} {p : x == y} {u : x == x} {v : y == y} → (u == v [ (λ x → x == x) ↓ p ]) → u ∙ p == p ∙' v ↓-idf=idf-out' {p = idp} q = ∙-unit-r _ ∙ q ∙ ! (∙'-unit-l _) {- Nondependent identity type -} ↓-='-in : ∀ {i j} {A : Type i} {B : Type j} {f g : A → B} {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y} → (u ∙' ap g p) == (ap f p ∙ v) → (u == v [ (λ x → f x == g x) ↓ p ]) ↓-='-in {p = idp} q = q ↓-='-out : ∀ {i j} {A : Type i} {B : Type j} {f g : A → B} {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y} → (u == v [ (λ x → f x == g x) ↓ p ]) → (u ∙' ap g p) == (ap f p ∙ v) ↓-='-out {p = idp} q = q ↓-='-in' : ∀ {i j} {A : Type i} {B : Type j} {f g : A → B} {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y} → (u ∙ ap g p) == (ap f p ∙' v) → (u == v [ (λ x → f x == g x) ↓ p ]) ↓-='-in' {p = idp} q = ! (∙-unit-r _) ∙ q ∙ (∙'-unit-l _) ↓-='-out' : ∀ {i j} {A : Type i} {B : Type j} {f g : A → B} {x y : A} {p : x == y} {u : f x == g x} {v : f y == g y} → (u == v [ (λ x → f x == g x) ↓ p ]) → (u ∙ ap g p) == (ap f p ∙' v) ↓-='-out' {p = idp} q = (∙-unit-r _) ∙ q ∙ ! (∙'-unit-l _) {- Identity type where the type is dependent -} ↓-=-in : ∀ {i j} {A : Type i} {B : A → Type j} {f g : Π A B} {x y : A} {p : x == y} {u : g x == f x} {v : g y == f y} → (u ◃ apd f p) == (apd g p ▹ v) → (u == v [ (λ x → g x == f x) ↓ p ]) ↓-=-in {B = B} {p = idp} {u} {v} q = ! (◃idp {B = B} u) ∙ q ∙ idp▹ {B = B} v ↓-=-out : ∀ {i j} {A : Type i} {B : A → Type j} {f g : Π A B} {x y : A} {p : x == y} {u : g x == f x} {v : g y == f y} → (u == v [ (λ x → g x == f x) ↓ p ]) → (u ◃ apd f p) == (apd g p ▹ v) ↓-=-out {B = B} {p = idp} {u} {v} q = (◃idp {B = B} u) ∙ q ∙ ! (idp▹ {B = B} v) -- Dependent path in a type of the form [λ x → g (f x) == x] module _ {i j} {A : Type i} {B : Type j} (g : B → A) (f : A → B) where ↓-∘=idf-in' : {x y : A} {p : x == y} {u : g (f x) == x} {v : g (f y) == y} → ((ap g (ap f p) ∙' v) == (u ∙ p)) → (u == v [ (λ x → g (f x) == x) ↓ p ]) ↓-∘=idf-in' {p = idp} q = ! (∙-unit-r _) ∙ (! q) ∙ (∙'-unit-l _) -- WIP, derive it from more primitive principles -- ↓-∘=id-in f g {p = p} {u} {v} q = -- ↓-=-in (u ◃ apd (λ x → g (f x)) p =⟨ apd-∘ f g p |in-ctx (λ t → u ◃ t) ⟩ -- u ◃ ↓-apd-out _ f p (apdd g p (apd f p)) =⟨ apdd-cst (λ _ b → g b) p (ap f p) (! (apd-nd f p)) |in-ctx (λ t → u ◃ ↓-apd-out _ f p t) ⟩ -- u ◃ ↓-apd-out _ f p (apd (λ t → g (π₂ t)) (pair= p (apd f p))) =⟨ apd-∘ π₂ g (pair= p (apd f p)) |in-ctx (λ t → u ◃ ↓-apd-out _ f p t) ⟩ -- u ◃ ↓-apd-out _ f p (↓-apd-out _ π₂ (pair= p (apd f p)) (apdd g (pair= p (apd f p)) (apd π₂ (pair= p (apd f p))))) =⟨ {!!} ⟩ -- apd (λ x → x) p ▹ v ∎) -- module _ {i j} {A : Type i} {B : Type j} {x y z : A → B} where -- lhs : -- {a a' : A} {p : a == a'} {q : x a == y a} {q' : x a' == y a'} -- {r : y a == z a} {r' : y a' == z a'} -- (α : q == q' [ (λ a → x a == y a) ↓ p ]) -- (β : r ∙ ap z p == ap y p ∙' r') -- → (q ∙' r) ∙ ap z p == ap x p ∙' q' ∙' r' -- lhs = -- (q ∙' r) ∙ ap z p =⟨ ? ⟩ -- assoc -- q ∙' (r ∙ ap z p) =⟨ ? ⟩ -- β -- q ∙' (ap y p ∙' r') =⟨ ? ⟩ -- assoc -- (q ∙' ap y p) ∙' r' =⟨ ? ⟩ -- ∙ = ∙' -- (q ∙ ap y p) ∙' r' =⟨ ? ⟩ -- α -- (ap x p ∙' q') ∙' r' =⟨ ? ⟩ -- assoc -- ap x p ∙' q' ∙' r' ∎ -- thing : -- {a a' : A} {p : a == a'} {q : x a == y a} {q' : x a' == y a'} -- {r : y a == z a} {r' : y a' == z a'} -- (α : q == q' [ (λ a → x a == y a) ↓ p ]) -- (β : r ∙ ap z p == ap y p ∙' r') -- → (_∙'2ᵈ_ {r = r} {r' = r'} α (↓-='-in' β) == ↓-='-in' {!!}) -- thing = {!!}
38.14
147
0.332459
9aa398edc15b68eea2c29081300d3548dfbbf9c0
228
agda
Agda
agda/BTree.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
6
2015-05-21T12:50:35.000Z
2021-08-24T22:11:15.000Z
agda/BTree.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
null
null
null
agda/BTree.agda
bgbianchi/sorting
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
[ "MIT" ]
null
null
null
module BTree {A : Set} where open import Data.List data BTree : Set where leaf : BTree node : A → BTree → BTree → BTree flatten : BTree → List A flatten leaf = [] flatten (node x l r) = (flatten l) ++ (x ∷ flatten r)
16.285714
54
0.627193
04e986f7f7e60cc4e19c80117221be8c97c17843
2,959
agda
Agda
theorems/groups/DisjointlyPointedSet.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
294
2015-01-09T16:23:23.000Z
2022-03-20T13:54:45.000Z
theorems/groups/DisjointlyPointedSet.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
31
2015-03-05T20:09:00.000Z
2021-10-03T19:15:25.000Z
theorems/groups/DisjointlyPointedSet.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
50
2015-01-10T01:48:08.000Z
2022-02-14T03:03:25.000Z
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import homotopy.DisjointlyPointedSet module groups.DisjointlyPointedSet where diff-and-separate : ∀ {i j} {X : Ptd i} (G : Group j) → (de⊙ X → Group.El G) → Group.El G × (MinusPoint X → Group.El G) diff-and-separate {X = X} G f = f (pt X) , λ x- → Group.diff G (f (fst x-)) (f (pt X)) shift-and-unite : ∀ {i j} {X : Ptd i} (G : Group j) → is-separable X → Group.El G × (MinusPoint X → Group.El G) → (de⊙ X → Group.El G) shift-and-unite {X = X} G X-sep p x with X-sep x ... | inl _ = fst p ... | inr pt≠x = Group.comp G (snd p (x , pt≠x)) (fst p) diff-and-separate-hom : ∀ {i j} {X : Ptd i} (G : AbGroup j) → Πᴳ (de⊙ X) (λ _ → AbGroup.grp G) →ᴳ AbGroup.grp G ×ᴳ Πᴳ (MinusPoint X) (λ _ → AbGroup.grp G) diff-and-separate-hom {X = X} G = group-hom (diff-and-separate grp) lemma where open AbGroup G abstract lemma : preserves-comp (Group.comp (Πᴳ (de⊙ X) (λ _ → AbGroup.grp G))) (Group.comp (AbGroup.grp G ×ᴳ Πᴳ (MinusPoint X) (λ _ → AbGroup.grp G))) (diff-and-separate grp) lemma f₀ f₁ = pair×= idp (λ= λ x- → diff-comp (f₀ (fst x-)) (f₁ (fst x-)) (f₀ (pt X)) (f₁ (pt X))) diff-and-separate-is-equiv : ∀ {i j} {X : Ptd i} (G : Group j) → is-separable X → is-equiv (diff-and-separate {X = X} G) diff-and-separate-is-equiv {X = X} G X-sep = is-eq to from to-from (λ= ∘ from-to) where open Group G to = diff-and-separate {X = X} G from = shift-and-unite {X = X} G X-sep abstract fst-to-from : ∀ p → fst (to (from p)) == fst p fst-to-from _ with X-sep (pt X) ... | inl _ = idp ... | inr pt≠pt = ⊥-rec (pt≠pt idp) snd-to-from : ∀ p x → snd (to (from p)) x == snd p x snd-to-from p x with X-sep (fst x) ... | inl pt=x = ⊥-rec (snd x pt=x) ... | inr pt≠x with X-sep (pt X) ... | inl _ = assoc (snd p (fst x , pt≠x)) (fst p) (inv (fst p)) ∙ ap (comp (snd p (fst x , pt≠x))) (inv-r (fst p)) ∙ unit-r (snd p (fst x , pt≠x)) ∙ ap (λ neq → snd p (fst x , neq)) (prop-has-all-paths _ _) ... | inr pt≠pt = ⊥-rec (pt≠pt idp) to-from : ∀ p → to (from p) == p to-from p = pair×= (fst-to-from p) (λ= (snd-to-from p)) from-to : ∀ f x → from (to f) x == f x from-to f x with X-sep x ... | inl idp = idp ... | inr _ = assoc (f x) (inv (f (pt X))) (f (pt X)) ∙ ap (comp (f x)) (inv-l (f (pt X))) ∙ unit-r (f x) diff-and-separate-iso : ∀ {i j} {X : Ptd i} (G : AbGroup j) → is-separable X → Πᴳ (de⊙ X) (λ _ → AbGroup.grp G) ≃ᴳ AbGroup.grp G ×ᴳ Πᴳ (MinusPoint X) (λ _ → AbGroup.grp G) diff-and-separate-iso G X-sep = diff-and-separate-hom G , diff-and-separate-is-equiv (AbGroup.grp G) X-sep
40.534247
87
0.500169
c78d0ad387191768e768f7ae77c7e2be35f4d4c7
227
agda
Agda
src/Examples.agda
jonsterling/agda-calf
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
[ "Apache-2.0" ]
29
2021-07-14T03:18:28.000Z
2022-03-22T20:35:11.000Z
src/Examples.agda
jonsterling/agda-calf
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
[ "Apache-2.0" ]
null
null
null
src/Examples.agda
jonsterling/agda-calf
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
[ "Apache-2.0" ]
2
2021-10-06T10:28:24.000Z
2022-01-29T08:12:01.000Z
{-# OPTIONS --prop --rewriting #-} module Examples where -- Sequential import Examples.Id import Examples.Gcd import Examples.Queue -- Parallel import Examples.TreeSum import Examples.Exp2 -- Hybrid import Examples.Sorting
14.1875
34
0.770925
1deae02bfeaaf1bb7f4ce390efa59210b7c5221d
10,457
agda
Agda
Cubical/Algebra/Group/Algebra.agda
cangiuli/cubical
d103ec455d41cccf9b13a4803e7d3cf462e00067
[ "MIT" ]
null
null
null
Cubical/Algebra/Group/Algebra.agda
cangiuli/cubical
d103ec455d41cccf9b13a4803e7d3cf462e00067
[ "MIT" ]
1
2022-01-27T02:07:48.000Z
2022-01-27T02:07:48.000Z
Cubical/Algebra/Group/Algebra.agda
cangiuli/cubical
d103ec455d41cccf9b13a4803e7d3cf462e00067
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Group.Algebra where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.HLevels open import Cubical.Foundations.Structure open import Cubical.Foundations.Function using (_∘_) open import Cubical.Foundations.GroupoidLaws open import Cubical.Data.Sigma open import Cubical.Data.Unit open import Cubical.Algebra.Group.Base open import Cubical.Algebra.Group.Properties open import Cubical.Algebra.Group.Morphism open import Cubical.Algebra.Group.MorphismProperties open import Cubical.HITs.PropositionalTruncation hiding (map) open Iso open GroupHom private variable ℓ ℓ' ℓ₁ ℓ₂ ℓ₃ : Level ------- elementary properties of morphisms -------- module _ (G : Group {ℓ}) (H : Group {ℓ'}) where module G = GroupStr (snd G) module H = GroupStr (snd H) -0≡0 : G.- G.0g ≡ G.0g -0≡0 = sym (G.lid _) ∙ G.invr _ -- ϕ(0) ≡ 0 morph0→0 : (f : GroupHom G H) → f .fun G.0g ≡ H.0g morph0→0 fh@(grouphom f _) = f G.0g ≡⟨ sym (H.rid _) ⟩ f G.0g H.+ H.0g ≡⟨ (λ i → f G.0g H.+ H.invr (f G.0g) (~ i)) ⟩ f G.0g H.+ (f G.0g H.- f G.0g) ≡⟨ H.assoc _ _ _ ⟩ (f G.0g H.+ f G.0g) H.- f G.0g ≡⟨ sym (cong (λ x → x H.+ (H.- f G.0g)) (sym (cong f (G.lid _)) ∙ isHom fh G.0g G.0g)) ⟩ f G.0g H.- f G.0g ≡⟨ H.invr _ ⟩ H.0g ∎ -- ϕ(- x) = - ϕ(x) morphMinus : (f : GroupHom G H) → (g : ⟨ G ⟩) → f .fun (G.- g) ≡ H.- (f .fun g) morphMinus fc@(grouphom f fh) g = f (G.- g) ≡⟨ sym (H.rid _) ⟩ f (G.- g) H.+ H.0g ≡⟨ cong (f (G.- g) H.+_) (sym (H.invr _)) ⟩ f (G.- g) H.+ (f g H.- f g) ≡⟨ H.assoc _ _ _ ⟩ (f (G.- g) H.+ f g) H.- f g ≡⟨ cong (H._+ (H.- f g)) helper ⟩ H.0g H.- f g ≡⟨ H.lid _ ⟩ H.- f g ∎ where helper : f (G.- g) H.+ f g ≡ H.0g helper = sym (fh (G.- g) g) ∙∙ cong f (G.invl g) ∙∙ morph0→0 fc -- ----------- Alternative notions of isomorphisms -------------- record GroupIso {ℓ ℓ'} (G : Group {ℓ}) (H : Group {ℓ'}) : Type (ℓ-max ℓ ℓ') where constructor iso field map : GroupHom G H inv : ⟨ H ⟩ → ⟨ G ⟩ rightInv : section (GroupHom.fun map) inv leftInv : retract (GroupHom.fun map) inv record BijectionIso {ℓ ℓ'} (A : Group {ℓ}) (B : Group {ℓ'}) : Type (ℓ-max ℓ ℓ') where constructor bij-iso field map' : GroupHom A B inj : isInjective A B map' surj : isSurjective A B map' -- "Very" short exact sequences -- i.e. an exact sequence A → B → C → D where A and D are trivial record vSES {ℓ ℓ' ℓ'' ℓ'''} (A : Group {ℓ}) (B : Group {ℓ'}) (leftGr : Group {ℓ''}) (rightGr : Group {ℓ'''}) : Type (ℓ-suc (ℓ-max ℓ (ℓ-max ℓ' (ℓ-max ℓ'' ℓ''')))) where constructor ses field isTrivialLeft : isProp ⟨ leftGr ⟩ isTrivialRight : isProp ⟨ rightGr ⟩ left : GroupHom leftGr A right : GroupHom B rightGr ϕ : GroupHom A B Ker-ϕ⊂Im-left : (x : ⟨ A ⟩) → isInKer A B ϕ x → isInIm leftGr A left x Ker-right⊂Im-ϕ : (x : ⟨ B ⟩) → isInKer B rightGr right x → isInIm A B ϕ x open BijectionIso open GroupIso open vSES Iso+Hom→GrIso : {G : Group {ℓ}} {H : Group {ℓ₁}} → (e : Iso ⟨ G ⟩ ⟨ H ⟩) → isGroupHom G H (Iso.fun e) → GroupIso G H fun (map (Iso+Hom→GrIso e hom)) = Iso.fun e isHom (map (Iso+Hom→GrIso e hom)) = hom inv (Iso+Hom→GrIso e hom) = Iso.inv e rightInv (Iso+Hom→GrIso e hom) = Iso.rightInv e leftInv (Iso+Hom→GrIso e hom) = Iso.leftInv e compGroupIso : {G : Group {ℓ}} {H : Group {ℓ₁}} {A : Group {ℓ₂}} → GroupIso G H → GroupIso H A → GroupIso G A map (compGroupIso iso1 iso2) = compGroupHom (map iso1) (map iso2) inv (compGroupIso iso1 iso2) = inv iso1 ∘ inv iso2 rightInv (compGroupIso iso1 iso2) a = cong (fun (map iso2)) (rightInv iso1 _) ∙ rightInv iso2 a leftInv (compGroupIso iso1 iso2) a = cong (inv iso1) (leftInv iso2 _) ∙ leftInv iso1 a isGroupHomInv' : {G : Group {ℓ}} {H : Group {ℓ₁}} (f : GroupIso G H) → isGroupHom H G (inv f) isGroupHomInv' {G = G} {H = H} f h h' = isInj-f _ _ ( f' (g (h ⋆² h')) ≡⟨ (rightInv f) _ ⟩ (h ⋆² h') ≡⟨ sym (cong₂ _⋆²_ (rightInv f h) (rightInv f h')) ⟩ (f' (g h) ⋆² f' (g h')) ≡⟨ sym (isHom (map f) _ _) ⟩ f' (g h ⋆¹ g h') ∎) where f' = fun (map f) _⋆¹_ = GroupStr._+_ (snd G) _⋆²_ = GroupStr._+_ (snd H) g = inv f isInj-f : (x y : ⟨ G ⟩) → f' x ≡ f' y → x ≡ y isInj-f x y p = sym (leftInv f _) ∙∙ cong g p ∙∙ leftInv f _ invGroupIso : {G : Group {ℓ}} {H : Group {ℓ₁}} → GroupIso G H → GroupIso H G fun (map (invGroupIso iso1)) = inv iso1 isHom (map (invGroupIso iso1)) = isGroupHomInv' iso1 inv (invGroupIso iso1) = fun (map iso1) rightInv (invGroupIso iso1) = leftInv iso1 leftInv (invGroupIso iso1) = rightInv iso1 dirProdGroupIso : {G : Group {ℓ}} {H : Group {ℓ₁}} {A : Group {ℓ₂}} {B : Group {ℓ₃}} → GroupIso G H → GroupIso A B → GroupIso (dirProd G A) (dirProd H B) fun (map (dirProdGroupIso iso1 iso2)) prod = fun (map iso1) (fst prod) , fun (map iso2) (snd prod) isHom (map (dirProdGroupIso iso1 iso2)) a b = ΣPathP (isHom (map iso1) (fst a) (fst b) , isHom (map iso2) (snd a) (snd b)) inv (dirProdGroupIso iso1 iso2) prod = (inv iso1) (fst prod) , (inv iso2) (snd prod) rightInv (dirProdGroupIso iso1 iso2) a = ΣPathP (rightInv iso1 (fst a) , (rightInv iso2 (snd a))) leftInv (dirProdGroupIso iso1 iso2) a = ΣPathP (leftInv iso1 (fst a) , (leftInv iso2 (snd a))) GrIsoToGrEquiv : {G : Group {ℓ}} {H : Group {ℓ₂}} → GroupIso G H → GroupEquiv G H GroupEquiv.eq (GrIsoToGrEquiv i) = isoToEquiv (iso (fun (map i)) (inv i) (rightInv i) (leftInv i)) GroupEquiv.isHom (GrIsoToGrEquiv i) = isHom (map i) --- Proofs that BijectionIso and vSES both induce isomorphisms --- BijectionIsoToGroupIso : {A : Group {ℓ}} {B : Group {ℓ'}} → BijectionIso A B → GroupIso A B BijectionIsoToGroupIso {A = A} {B = B} i = grIso where module A = GroupStr (snd A) module B = GroupStr (snd B) f = fun (map' i) helper : (b : _) → isProp (Σ[ a ∈ ⟨ A ⟩ ] f a ≡ b) helper _ a b = Σ≡Prop (λ _ → isSetCarrier B _ _) (fst a ≡⟨ sym (A.rid _) ⟩ fst a A.+ A.0g ≡⟨ cong (fst a A.+_) (sym (A.invl _)) ⟩ fst a A.+ ((A.- fst b) A.+ fst b) ≡⟨ A.assoc _ _ _ ⟩ (fst a A.- fst b) A.+ fst b ≡⟨ cong (A._+ fst b) idHelper ⟩ A.0g A.+ fst b ≡⟨ A.lid _ ⟩ fst b ∎) where idHelper : fst a A.- fst b ≡ A.0g idHelper = inj i _ (isHom (map' i) (fst a) (A.- (fst b)) ∙ (cong (f (fst a) B.+_) (morphMinus A B (map' i) (fst b)) ∙∙ cong (B._+ (B.- f (fst b))) (snd a ∙ sym (snd b)) ∙∙ B.invr (f (fst b)))) grIso : GroupIso A B map grIso = map' i inv grIso b = (rec (helper b) (λ a → a) (surj i b)) .fst rightInv grIso b = (rec (helper b) (λ a → a) (surj i b)) .snd leftInv grIso b j = rec (helper (f b)) (λ a → a) (propTruncIsProp (surj i (f b)) ∣ b , refl ∣ j) .fst BijectionIsoToGroupEquiv : {A : Group {ℓ}} {B : Group {ℓ₂}} → BijectionIso A B → GroupEquiv A B BijectionIsoToGroupEquiv i = GrIsoToGrEquiv (BijectionIsoToGroupIso i) vSES→GroupIso : ∀ {ℓ ℓ' ℓ'' ℓ'''} {A : Group {ℓ}} {B : Group {ℓ'}} (leftGr : Group {ℓ''}) (rightGr : Group {ℓ'''}) → vSES A B leftGr rightGr → GroupIso A B vSES→GroupIso {A = A} lGr rGr vses = BijectionIsoToGroupIso theIso where theIso : BijectionIso _ _ map' theIso = vSES.ϕ vses inj theIso a inker = rec (isSetCarrier A _ _) (λ (a , p) → sym p ∙∙ cong (fun (left vses)) (isTrivialLeft vses a _) ∙∙ morph0→0 lGr A (left vses)) (Ker-ϕ⊂Im-left vses a inker) surj theIso a = Ker-right⊂Im-ϕ vses a (isTrivialRight vses _ _) vSES→GroupEquiv : {A : Group {ℓ}} {B : Group {ℓ₁}} (leftGr : Group {ℓ₂}) (rightGr : Group {ℓ₃}) → vSES A B leftGr rightGr → GroupEquiv A B vSES→GroupEquiv {A = A} lGr rGr vses = GrIsoToGrEquiv (vSES→GroupIso lGr rGr vses) -- The trivial group is a unit. lUnitGroupIso : ∀ {ℓ} {G : Group {ℓ}} → GroupIso (dirProd trivialGroup G) G fun (map lUnitGroupIso) = snd isHom (map lUnitGroupIso) _ _ = refl inv lUnitGroupIso g = tt , g rightInv lUnitGroupIso _ = refl leftInv lUnitGroupIso _ = refl rUnitGroupIso : ∀ {ℓ} {G : Group {ℓ}} → GroupIso (dirProd G trivialGroup) G fun (map rUnitGroupIso) = fst isHom (map rUnitGroupIso) _ _ = refl inv rUnitGroupIso g = g , tt rightInv rUnitGroupIso _ = refl leftInv rUnitGroupIso _ = refl lUnitGroupEquiv : ∀ {ℓ} {G : Group {ℓ}} → GroupEquiv (dirProd trivialGroup G) G lUnitGroupEquiv = GrIsoToGrEquiv lUnitGroupIso rUnitGroupEquiv : ∀ {ℓ} {G : Group {ℓ}} → GroupEquiv (dirProd G trivialGroup) G rUnitGroupEquiv = GrIsoToGrEquiv rUnitGroupIso IsoContrGroupTrivialGroup : {G : Group {ℓ}} → isContr ⟨ G ⟩ → GroupIso G trivialGroup fun (map (IsoContrGroupTrivialGroup contr)) _ = tt isHom (map (IsoContrGroupTrivialGroup contr)) _ _ = refl inv (IsoContrGroupTrivialGroup contr) x = fst contr rightInv (IsoContrGroupTrivialGroup contr) x = refl leftInv (IsoContrGroupTrivialGroup contr) x = snd contr x contrGroup≅trivialGroup : {G : Group {ℓ}} → isContr ⟨ G ⟩ → GroupEquiv G trivialGroup contrGroup≅trivialGroup contr = GrIsoToGrEquiv (IsoContrGroupTrivialGroup contr) GroupIso→Iso : {A : Group {ℓ}} {B : Group {ℓ₁}} → GroupIso A B → Iso ⟨ A ⟩ ⟨ B ⟩ fun (GroupIso→Iso i) = fun (map i) inv (GroupIso→Iso i) = inv i rightInv (GroupIso→Iso i) = rightInv i leftInv (GroupIso→Iso i) = leftInv i congIdLeft≡congIdRight : {A : Type ℓ} (_+A_ : A → A → A) (-A_ : A → A) (0A : A) (rUnitA : (x : A) → x +A 0A ≡ x) (lUnitA : (x : A) → 0A +A x ≡ x) → (r≡l : rUnitA 0A ≡ lUnitA 0A) → (p : 0A ≡ 0A) → cong (0A +A_) p ≡ cong (_+A 0A) p congIdLeft≡congIdRight _+A_ -A_ 0A rUnitA lUnitA r≡l p = rUnit (cong (0A +A_) p) ∙∙ ((λ i → (λ j → lUnitA 0A (i ∧ j)) ∙∙ cong (λ x → lUnitA x i) p ∙∙ λ j → lUnitA 0A (i ∧ ~ j)) ∙∙ cong₂ (λ x y → x ∙∙ p ∙∙ y) (sym r≡l) (cong sym (sym r≡l)) ∙∙ λ i → (λ j → rUnitA 0A (~ i ∧ j)) ∙∙ cong (λ x → rUnitA x (~ i)) p ∙∙ λ j → rUnitA 0A (~ i ∧ ~ j)) ∙∙ sym (rUnit (cong (_+A 0A) p))
40.688716
122
0.573396
1de8ae5e9502f474d75aa8a0193760375f9fd681
4,170
agda
Agda
agda/Data/Fin/Properties.agda
oisdk/combinatorics-paper
3c176d4690566d81611080e9378f5a178b39b851
[ "MIT" ]
4
2021-01-05T14:07:44.000Z
2021-01-05T15:32:14.000Z
agda/Data/Fin/Properties.agda
oisdk/combinatorics-paper
3c176d4690566d81611080e9378f5a178b39b851
[ "MIT" ]
null
null
null
agda/Data/Fin/Properties.agda
oisdk/combinatorics-paper
3c176d4690566d81611080e9378f5a178b39b851
[ "MIT" ]
1
2021-01-05T14:05:30.000Z
2021-01-05T14:05:30.000Z
{-# OPTIONS --cubical --safe --postfix-projections #-} module Data.Fin.Properties where open import Prelude open import Data.Fin.Base import Data.Nat.Properties as ℕ open import Data.Nat.Properties using (+-comm) open import Data.Nat open import Function.Injective open import Agda.Builtin.Nat renaming (_<_ to _<ᵇ_) private variable n m : ℕ suc-natfin : Σ[ m ⦂ ℕ ] (m ℕ.< n) → Σ[ m ⦂ ℕ ] (m ℕ.< suc n) suc-natfin (m , p) = suc m , p Fin-to-Nat-lt : Fin n → Σ[ m ⦂ ℕ ] (m ℕ.< n) Fin-to-Nat-lt {n = suc n} f0 = zero , tt Fin-to-Nat-lt {n = suc n} (fs x) = suc-natfin (Fin-to-Nat-lt x) Fin-from-Nat-lt : ∀ m → m ℕ.< n → Fin n Fin-from-Nat-lt {n = suc n} zero p = f0 Fin-from-Nat-lt {n = suc n} (suc m) p = fs (Fin-from-Nat-lt m p) Fin-Nat-lt-rightInv : ∀ m → (p : m ℕ.< n) → Fin-to-Nat-lt {n = n} (Fin-from-Nat-lt m p) ≡ (m , p) Fin-Nat-lt-rightInv {n = suc n} zero p = refl Fin-Nat-lt-rightInv {n = suc n} (suc m) p = cong (suc-natfin {n = n}) (Fin-Nat-lt-rightInv {n = n} m p) Fin-Nat-lt-leftInv : (x : Fin n) → uncurry Fin-from-Nat-lt (Fin-to-Nat-lt x) ≡ x Fin-Nat-lt-leftInv {n = suc n} f0 = refl Fin-Nat-lt-leftInv {n = suc n} (fs x) = cong fs (Fin-Nat-lt-leftInv x) Fin-Nat-lt : Fin n ⇔ Σ[ m ⦂ ℕ ] (m ℕ.< n) Fin-Nat-lt .fun = Fin-to-Nat-lt Fin-Nat-lt .inv = uncurry Fin-from-Nat-lt Fin-Nat-lt .rightInv = uncurry Fin-Nat-lt-rightInv Fin-Nat-lt .leftInv = Fin-Nat-lt-leftInv FinToℕ : Fin n → ℕ FinToℕ {n = suc n} f0 = zero FinToℕ {n = suc n} (fs x) = suc (FinToℕ x) FinToℕ-injective : ∀ {k} {m n : Fin k} → FinToℕ m ≡ FinToℕ n → m ≡ n FinToℕ-injective {suc k} {f0} {f0} _ = refl FinToℕ-injective {suc k} {f0} {fs x} p = ⊥-elim (ℕ.znots p) FinToℕ-injective {suc k} {fs m} {f0} p = ⊥-elim (ℕ.snotz p) FinToℕ-injective {suc k} {fs m} {fs x} p = cong fs (FinToℕ-injective (ℕ.injSuc p)) pred : Fin (suc n) → Fin (suc (ℕ.pred n)) pred f0 = f0 pred {n = suc n} (fs m) = m discreteFin : ∀ {k} → Discrete (Fin k) discreteFin {k = suc _} f0 f0 = yes refl discreteFin {k = suc _} f0 (fs fk) = no (ℕ.znots ∘ cong FinToℕ) discreteFin {k = suc _} (fs fj) f0 = no (ℕ.snotz ∘ cong FinToℕ) discreteFin {k = suc _} (fs fj) (fs fk) = ⟦yes cong fs ,no cong (λ { f0 → fk ; (fs x) → x}) ⟧ (discreteFin fj fk) isSetFin : isSet (Fin n) isSetFin = Discrete→isSet discreteFin FinFromℕ : (n m : ℕ) → T (n <ᵇ m) → Fin m FinFromℕ zero (suc m) p = f0 FinFromℕ (suc n) (suc m) p = fs (FinFromℕ n m p) infix 4 _≢ᶠ_ _≡ᶠ_ _≢ᶠ_ _≡ᶠ_ : Fin n → Fin n → Type _ n ≢ᶠ m = T (not (discreteFin n m .does)) n ≡ᶠ m = T (discreteFin n m .does) _F↣_ : ℕ → ℕ → Type₀ n F↣ m = Σ[ f ⦂ (Fin n → Fin m) ] ∀ {x y} → x ≢ᶠ y → f x ≢ᶠ f y shift : (x y : Fin (suc n)) → x ≢ᶠ y → Fin n shift f0 (fs y) x≢y = y shift {suc _} (fs x) f0 x≢y = f0 shift {suc _} (fs x) (fs y) x≢y = fs (shift x y x≢y) shift-inj : ∀ (x y z : Fin (suc n)) x≢y x≢z → y ≢ᶠ z → shift x y x≢y ≢ᶠ shift x z x≢z shift-inj f0 (fs y) (fs z) x≢y x≢z x+y≢x+z = x+y≢x+z shift-inj {suc _} (fs x) f0 (fs z) x≢y x≢z x+y≢x+z = tt shift-inj {suc _} (fs x) (fs y) f0 x≢y x≢z x+y≢x+z = tt shift-inj {suc _} (fs x) (fs y) (fs z) x≢y x≢z x+y≢x+z = shift-inj x y z x≢y x≢z x+y≢x+z shrink : suc n F↣ suc m → n F↣ m shrink (f , inj) .fst x = shift (f f0) (f (fs x)) (inj tt) shrink (f , inj) .snd p = shift-inj (f f0) (f (fs _)) (f (fs _)) (inj tt) (inj tt) (inj p) ¬plus-inj : ∀ n m → ¬ (suc (n + m) F↣ m) ¬plus-inj zero zero (f , _) = f f0 ¬plus-inj zero (suc m) inj = ¬plus-inj zero m (shrink inj) ¬plus-inj (suc n) m (f , p) = ¬plus-inj n m (f ∘ fs , p) toFin-inj : (Fin n ↣ Fin m) → n F↣ m toFin-inj f .fst = f .fst toFin-inj (f , inj) .snd {x} {y} x≢ᶠy with discreteFin x y | discreteFin (f x) (f y) ... | no ¬p | yes p = ¬p (inj _ _ p) ... | no _ | no _ = tt n≢sn+m : ∀ n m → Fin n ≢ Fin (suc (n + m)) n≢sn+m n m n≡m = ¬plus-inj m n (toFin-inj (subst (_↣ Fin n) (n≡m ; cong (Fin ∘ suc) (+-comm n m)) refl-↣)) Fin-inj : Injective Fin Fin-inj n m eq with compare n m ... | equal _ = refl ... | less n k = ⊥-elim (n≢sn+m n k eq) ... | greater m k = ⊥-elim (n≢sn+m m k (sym eq))
34.75
103
0.554436
13e83d479e8abbf1c80af6af5ccf9005001b9b5b
1,664
agda
Agda
Cubical/Structures/Relational/Pointed.agda
guilhermehas/cubical
ce3120d3f8d692847b2744162bcd7a01f0b687eb
[ "MIT" ]
1
2021-10-31T17:32:49.000Z
2021-10-31T17:32:49.000Z
Cubical/Structures/Relational/Pointed.agda
guilhermehas/cubical
ce3120d3f8d692847b2744162bcd7a01f0b687eb
[ "MIT" ]
null
null
null
Cubical/Structures/Relational/Pointed.agda
guilhermehas/cubical
ce3120d3f8d692847b2744162bcd7a01f0b687eb
[ "MIT" ]
null
null
null
{- Pointed structure: X ↦ X -} {-# OPTIONS --safe #-} module Cubical.Structures.Relational.Pointed where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Structure open import Cubical.Foundations.RelationalStructure open import Cubical.Foundations.Univalence open import Cubical.Relation.ZigZag.Base open import Cubical.HITs.SetQuotients open import Cubical.HITs.PropositionalTruncation open import Cubical.Structures.Pointed private variable ℓ : Level -- Structured relations PointedRelStr : StrRel PointedStructure ℓ PointedRelStr R = R pointedSuitableRel : SuitableStrRel {ℓ = ℓ} PointedStructure PointedRelStr pointedSuitableRel .quo _ _ _ = isContrSingl _ pointedSuitableRel .symmetric _ r = r pointedSuitableRel .transitive _ _ r r' = ∣ _ , r , r' ∣₁ pointedSuitableRel .set setX = setX pointedSuitableRel .prop propR = propR pointedRelMatchesEquiv : StrRelMatchesEquiv {ℓ = ℓ} PointedRelStr PointedEquivStr pointedRelMatchesEquiv _ _ _ = idEquiv _ pointedRelAction : StrRelAction {ℓ = ℓ} PointedRelStr pointedRelAction .actStr f = f pointedRelAction .actStrId _ = refl pointedRelAction .actRel α = α pointedPositiveRel : PositiveStrRel {ℓ = ℓ} pointedSuitableRel pointedPositiveRel .act = pointedRelAction pointedPositiveRel .reflexive x = ∣ refl ∣₁ pointedPositiveRel .detransitive R R' rr' = rr' pointedPositiveRel .quo R = isoToIsEquiv isom where open Iso isom : Iso _ _ isom .fun = _ isom .inv q = q isom .rightInv = elimProp (λ _ → squash/ _ _) (λ _ → refl) isom .leftInv = elimProp (λ _ → squash/ _ _) (λ _ → refl)
29.192982
81
0.778245
58a1d8de1f9af52f4f3c904e751ee47927936a53
3,150
agda
Agda
UniDB/Morph/Sim.agda
skeuchel/unidb-agda
7ae52205db44ad4f463882ba7e5082120fb76349
[ "MIT" ]
null
null
null
UniDB/Morph/Sim.agda
skeuchel/unidb-agda
7ae52205db44ad4f463882ba7e5082120fb76349
[ "MIT" ]
null
null
null
UniDB/Morph/Sim.agda
skeuchel/unidb-agda
7ae52205db44ad4f463882ba7e5082120fb76349
[ "MIT" ]
null
null
null
module UniDB.Morph.Sim where open import UniDB.Spec open import UniDB.Subst.Core open import UniDB.Morph.Depth import Level open import Relation.Binary.PropositionalEquality -------------------------------------------------------------------------------- record Sim (T : STX) (γ₁ γ₂ : Dom) : Set where constructor sim field lk-sim : (i : Ix γ₁) → T γ₂ open Sim public module _ {T : STX} where instance iLkSim : {{vrT : Vr T}} → Lk T (Sim T) lk {{iLkSim}} = lk-sim iWkSim : {{wkT : Wk T}} → {γ₁ : Dom} → Wk (Sim T γ₁) wk₁ {{iWkSim}} (sim f) = sim (wk₁ ∘ f) wk {{iWkSim}} δ (sim f) = sim (wk δ ∘ f) wk-zero {{iWkSim {{wkT}}}} (sim f) = cong sim (ext (wk-zero {T} ∘ f)) where postulate ext : Extensionality Level.zero Level.zero wk-suc {{iWkSim}} δ (sim f) = cong sim (ext (wk-suc {T} δ ∘ f)) where postulate ext : Extensionality Level.zero Level.zero iSnocSim : Snoc T (Sim T) snoc {{iSnocSim}} (sim f) t = sim λ { zero → t ; (suc i) → f i } iUpSim : {{vrT : Vr T}} {{wkT : Wk T}} → Up (Sim T) _↑₁ {{iUpSim}} ξ = snoc {T} {Sim T} (wk₁ ξ) (vr {T} zero) _↑_ {{iUpSim}} ξ 0 = ξ _↑_ {{iUpSim}} ξ (suc δ⁺) = ξ ↑ δ⁺ ↑₁ ↑-zero {{iUpSim}} ξ = refl ↑-suc {{iUpSim}} ξ δ⁺ = refl iIdmSim : {{vrT : Vr T}} → Idm (Sim T) idm {{iIdmSim}} γ = sim (vr {T}) iWkmSim : {{vrT : Vr T}} → Wkm (Sim T) wkm {{iWkmSim}} δ = sim (vr {T} ∘ wk δ) iBetaSim : {{vrT : Vr T}} → Beta T (Sim T) beta {{iBetaSim}} t = snoc {T} {Sim T} (idm {Sim T} _) t iCompSim : {{vrT : Vr T}} {{wkT : Wk T}} {{apTT : Ap T T}} → Comp (Sim T) lk-sim (_⊙_ {{iCompSim}} ξ ζ) i = ap {T} {T} {Sim T} ζ (lk {T} {Sim T} ξ i) iLkUpSim : {{vrT : Vr T}} {{wkT : Wk T}} → LkUp T (Sim T) lk-↑₁-zero {{iLkUpSim}} ξ = refl lk-↑₁-suc {{iLkUpSim}} ξ zero = refl lk-↑₁-suc {{iLkUpSim}} ξ (suc i) = refl iLkWkmSim : {{vrT : Vr T}} → LkWkm T (Sim T) lk-wkm {{iLkWkmSim}} δ i = refl iLkIdmSim : {{vrT : Vr T}} → LkIdm T (Sim T) lk-idm {{iLkIdmSim}} i = refl iLkCompSim : {{vrT : Vr T}} {{wkT : Wk T}} {{apTT : Ap T T}} → LkCompAp T (Sim T) lk-⊙-ap {{iLkCompSim}} ξ₁ ξ₂ i = refl -------------------------------------------------------------------------------- module SimIxInstances (T : STX) where instance iLkSimIx : {{vrT : Vr T}} → Lk T (Sim Ix) lk {{iLkSimIx}} ξ i = vr {T} (lk {Ix} {Sim Ix} ξ i) iLkUpSimIx : {{vrT : Vr T}} {{wkT : Wk T}} {{wkVrT : WkVr T}} → LkUp T (Sim Ix) lk-↑₁-zero {{iLkUpSimIx}} ξ = refl lk-↑₁-suc {{iLkUpSimIx}} ξ i = sym (wk₁-vr {T} (lk {Ix} {Sim Ix} ξ i)) iLkWkmSimIx : {{vrT : Vr T}} → LkWkm T (Sim Ix) lk-wkm {{iLkWkmSimIx}} δ i = refl iLkIdmSimIx : {{vrT : Vr T}} → LkIdm T (Sim Ix) lk-idm {{iLkIdmSimIx}} i = refl iLkCompSimIx : {{vrT : Vr T}} {{apTT : Ap T T}} {{apVrT : ApVr T}} → LkCompAp T (Sim Ix) lk-⊙-ap {{iLkCompSimIx}} ξ₁ ξ₂ i = sym (ap-vr {T} {Sim Ix} ξ₂ (lk {Ix} {Sim Ix} ξ₁ i)) --------------------------------------------------------------------------------
32.8125
85
0.478413
adec4f8fea21cbe3da5e5acbdac17cd446aac111
12,423
agda
Agda
agda/book/Programming_Language_Foundations_in_Agda/x10-747Lists.agda
haroldcarr/learn-haskell-coq-ml-etc
3dc7abca7ad868316bb08f31c77fbba0d3910225
[ "Unlicense" ]
36
2015-01-29T14:37:15.000Z
2021-07-30T06:55:03.000Z
agda/book/Programming_Language_Foundations_in_Agda/x10-747Lists.agda
haroldcarr/learn-haskell-coq-ml-etc
3dc7abca7ad868316bb08f31c77fbba0d3910225
[ "Unlicense" ]
null
null
null
agda/book/Programming_Language_Foundations_in_Agda/x10-747Lists.agda
haroldcarr/learn-haskell-coq-ml-etc
3dc7abca7ad868316bb08f31c77fbba0d3910225
[ "Unlicense" ]
8
2015-04-13T21:40:15.000Z
2021-09-21T15:58:10.000Z
module 747Lists where -- Library import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; sym; trans; cong) open Eq.≡-Reasoning open import Data.Bool using (Bool; true; false; T; _∧_; _∨_; not) open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_; _≤_; s≤s; z≤n) open import Data.Nat.Properties using (+-assoc; +-identityˡ; +-identityʳ; *-assoc; *-identityˡ; *-identityʳ) open import Relation.Nullary using (¬_; Dec; yes; no) open import Data.Product using (_×_; ∃; ∃-syntax) renaming (_,_ to ⟨_,_⟩) open import Function using (_∘_) open import Level using (Level) -- Copied from 747Isomorphism. infix 0 _≃_ record _≃_ (A B : Set) : Set where constructor mk-≃ -- This has been added, not in PLFA field to : A → B from : B → A from∘to : ∀ (x : A) → from (to x) ≡ x to∘from : ∀ (y : B) → to (from y) ≡ y open _≃_ infix 0 _≲_ record _≲_ (A B : Set) : Set where field to : A → B from : B → A from∘to : ∀ (x : A) → from (to x) ≡ x open _≲_ record _⇔_ (A B : Set) : Set where field to : A → B from : B → A open _⇔_ -- Polymorphic lists (parameterized version). data List (A : Set) : Set where [] : List A _∷_ : A → List A → List A infixr 5 _∷_ -- An example. _ : List ℕ _ = 0 ∷ 1 ∷ 2 ∷ [] -- An equivalent indexed version data List′ : Set → Set where []′ : ∀ {A : Set} → List′ A _∷′_ : ∀ {A : Set} → A → List′ A → List′ A -- Putting the implicit arguments into our example (but why?). _ : List ℕ _ = _∷_ {ℕ} 0 (_∷_ {ℕ} 1 (_∷_ {ℕ} 2 ([] {ℕ}))) -- This pragma would tell Agda to use Haskell lists internally. -- {-# BUILTIN LIST List #-} -- Some useful syntax to let us write short lists quickly. pattern [_] z = z ∷ [] pattern [_,_] y z = y ∷ z ∷ [] pattern [_,_,_] x y z = x ∷ y ∷ z ∷ [] pattern [_,_,_,_] w x y z = w ∷ x ∷ y ∷ z ∷ [] pattern [_,_,_,_,_] v w x y z = v ∷ w ∷ x ∷ y ∷ z ∷ [] pattern [_,_,_,_,_,_] u v w x y z = u ∷ v ∷ w ∷ x ∷ y ∷ z ∷ [] infixr 5 _++_ -- Append for lists. _++_ : ∀ {A : Set} → List A → List A → List A [] ++ ys = ys (x ∷ xs) ++ ys = x ∷ (xs ++ ys) _ : [ 0 , 2 , 4 ] ++ [ 3 , 5 ] ≡ [ 0 , 2 , 4 , 3 , 5 ] _ = refl -- Associativity of append. -- Equational reasoning proof in PLFA. ++-assoc : ∀ {A : Set} (xs ys zs : List A) → (xs ++ ys) ++ zs ≡ xs ++ (ys ++ zs) ++-assoc [] ys zs = refl ++-assoc (x ∷ xs) ys zs rewrite ++-assoc xs ys zs = refl -- Left and right identity for append. ++-identityˡ : ∀ {A : Set} (xs : List A) → [] ++ xs ≡ xs ++-identityˡ xs = refl ++-identityʳ : ∀ {A : Set} (xs : List A) → xs ++ [] ≡ xs ++-identityʳ [] = refl ++-identityʳ (x ∷ xs) rewrite ++-identityʳ xs = refl -- Length of a list. length : ∀ {A : Set} → List A → ℕ length [] = zero length (x ∷ xs) = suc (length xs) _ : length [ 0 , 1 , 2 ] ≡ 3 _ = refl -- Reasoning about length. length-++ : ∀ {A : Set} (xs ys : List A) → length (xs ++ ys) ≡ length xs + length ys length-++ [] ys = refl length-++ (x ∷ xs) ys rewrite length-++ xs ys = refl -- Reverse using structural recursion (inefficient). reverse : ∀ {A : Set} → List A → List A reverse [] = [] reverse (x ∷ xs) = reverse xs ++ [ x ] _ : reverse [ 0 , 1 , 2 ] ≡ [ 2 , 1 , 0 ] _ = refl -- 747/PLFA exercise: RevCommApp (1 point) -- How reverse commutes with ++. -- Changed from PLFA to make xs and ys explicit arguments. reverse-++-commute : ∀ {A : Set} (xs ys : List A) → reverse (xs ++ ys) ≡ reverse ys ++ reverse xs reverse-++-commute xs ys = {!!} -- 747/PLFA exercise: RevInvol (1 point) -- Reverse is its own inverse. -- Changed from PLFA to make xs explicit. reverse-involutive : ∀ {A : Set} (xs : List A) → reverse (reverse xs) ≡ xs reverse-involutive xs = {!!} -- Towards more efficient reverse (linear time vs quadratic) -- Shunt is a generalization of reverse. shunt : ∀ {A : Set} → List A → List A → List A shunt [] ys = ys shunt (x ∷ xs) ys = shunt xs (x ∷ ys) -- A good explanation of what shunt is doing. shunt-reverse : ∀ {A : Set} (xs ys : List A) → shunt xs ys ≡ reverse xs ++ ys shunt-reverse xs ys = {!!} -- Now it's clear that more efficient reverse is a special case of shunt. reverse′ : ∀ {A : Set} → List A → List A reverse′ xs = shunt xs [] -- Confirmation that the two functions are equivalent. reverses : ∀ {A : Set} (xs : List A) → reverse′ xs ≡ reverse xs reverses xs = {!!} -- Some common higher-order list functions. -- 'map' applies a function to every element of a list. map : ∀ {A B : Set} → (A → B) → List A → List B map f [] = [] map f (x ∷ xs) = f x ∷ map f xs _ : map suc [ 0 , 1 , 2 ] ≡ [ 1 , 2 , 3 ] _ = refl -- An example of using map. sucs : List ℕ → List ℕ sucs = map suc _ : sucs [ 0 , 1 , 2 ] ≡ [ 1 , 2 , 3 ] _ = refl -- 747/PLFA exercise: MapCompose (1 point) -- The map of a composition is the composition of maps. -- Changed from PLFA: some arguments made explicit, uses pointwise equality. map-compose : ∀ {A B C : Set} (f : A → B) (g : B → C) (xs : List A) → map (g ∘ f) xs ≡ (map g ∘ map f) xs map-compose f g xs = {!!} -- 747/PLFA exercise: MapAppendComm (1 point) -- The map of an append is the append of maps. -- Changed from PLFA: some arguments made explicit. map-++-commute : ∀ {A B : Set} (f : A → B) (xs ys : List A) → map f (xs ++ ys) ≡ map f xs ++ map f ys map-++-commute f xs ys = {!!} -- PLFA exercise: map over trees -- Here is a definition of trees with -- leaves labelled with type A and internal nodes with type B. data Tree (A B : Set) : Set where leaf : A → Tree A B node : Tree A B → B → Tree A B → Tree A B -- Write map for Trees. -- map-Tree : ∀ {A B C D : Set} -- → (A → C) → (B → D) → Tree A B → Tree C D -- map-Tree f g t = {!!} -- Fold-right: put operator ⊗ between each list element (and supplied final element). -- ⊗ is considered right-associative. -- Fold-right is universal for structural recursion on one argument. foldr : ∀ {A B : Set} → (A → B → B) → B → List A → B foldr _⊗_ e [] = e foldr _⊗_ e (x ∷ xs) = x ⊗ foldr _⊗_ e xs _ : foldr _+_ 0 [ 1 , 2 , 3 , 4 ] ≡ 10 _ = refl -- Summing a list using foldr. sum : List ℕ → ℕ sum = foldr _+_ 0 _ : sum [ 1 , 2 , 3 , 4 ] ≡ 10 _ = refl -- PLFA exercise: use foldr to define product on lists of naturals -- 747/PLFA exercise: FoldrOverAppend (1 point) -- Show that foldr over an append can be expressed as -- foldrs over each list. foldr-++ : ∀ {A B : Set} (_⊗_ : A → B → B) (e : B) (xs ys : List A) → foldr _⊗_ e (xs ++ ys) ≡ foldr _⊗_ (foldr _⊗_ e ys) xs foldr-++ _⊗_ e xs ys = {!!} -- 747/PLFA exercise: MapIsFoldr (1 point) -- Show that map can be expressed as a fold. -- Changed from PLFA: some arguments made explicit, uses pointwise equality. map-is-foldr : ∀ {A B : Set} (f : A → B) (xs : List A) → map f xs ≡ foldr (λ x rs → f x ∷ rs) [] xs map-is-foldr f xs = {!!} -- PLFA exercise: write a fold for trees -- fold-Tree : ∀ {A B C : Set} -- → (A → C) → (C → B → C → C) → Tree A B → C -- fold-Tree f g t = {!!} -- PLFA exercise: the downFrom function computes a countdown list -- Prove an equality about its sum downFrom : ℕ → List ℕ downFrom zero = [] downFrom (suc n) = n ∷ downFrom n _ : downFrom 3 ≡ [ 2 , 1 , 0 ] _ = refl -- sum-downFrom : ∀ (n : ℕ) -- → sum (downFrom n) * 2 ≡ n * (n ∸ 1) -- sum-downFrom n = {!!} -- 'Monoid' is a mathematical term for a set with an associative operator -- and an element which is the left and right identity (eg lists). record IsMonoid (A : Set) : Set where field id : A _⊗_ : A → A → A assoc : ∀ (x y z : A) → (x ⊗ y) ⊗ z ≡ x ⊗ (y ⊗ z) identityˡ : ∀ (x : A) → id ⊗ x ≡ x identityʳ : ∀ (x : A) → x ⊗ id ≡ x -- The following open command is different from PLFA; it uses instance arguments, -- which work like typeclasses in Haskell (allow overloading, which is cleaner). open IsMonoid {{ ...}} public -- These pragmas make displays of goal and context look nicer. {-# DISPLAY IsMonoid.id _ = id #-} {-# DISPLAY IsMonoid._⊗_ _ = _⊗_ #-} -- We can now describe instances of Monoid using the following notation. instance +-monoid : IsMonoid ℕ IsMonoid.id +-monoid = 0 IsMonoid._⊗_ +-monoid = _+_ IsMonoid.assoc +-monoid = +-assoc IsMonoid.identityˡ +-monoid = +-identityˡ IsMonoid.identityʳ +-monoid = +-identityʳ *-monoid : IsMonoid ℕ IsMonoid.id *-monoid = 1 IsMonoid._⊗_ *-monoid = _*_ IsMonoid.assoc *-monoid = *-assoc IsMonoid.identityˡ *-monoid = *-identityˡ IsMonoid.identityʳ *-monoid = *-identityʳ ++-monoid : ∀ {A : Set} → IsMonoid (List A) IsMonoid.id ++-monoid = [] IsMonoid._⊗_ ++-monoid = _++_ IsMonoid.assoc ++-monoid = ++-assoc IsMonoid.identityˡ ++-monoid = ++-identityˡ IsMonoid.identityʳ ++-monoid = ++-identityʳ -- A property of foldr over a monoid. foldr-monoid : ∀ {A : Set} → {{m : IsMonoid A}} → ∀ (xs : List A) (y : A) → foldr _⊗_ y xs ≡ (foldr _⊗_ id xs) ⊗ y foldr-monoid xs y = {!!} -- How foldr commutes with ++ over a monoid. foldr-monoid-++ : ∀ {A : Set} → {{m : IsMonoid A}} → ∀ (xs ys : List A) → foldr _⊗_ id (xs ++ ys) ≡ foldr _⊗_ id xs ⊗ foldr _⊗_ id ys foldr-monoid-++ xs ys = {!!} -- 747/PLFA exercise: Foldl (1 point) -- Define foldl, which associates left instead of right, e.g. -- foldr _⊗_ e [ x , y , z ] = x ⊗ (y ⊗ (z ⊗ e)) -- foldl _⊗_ e [ x , y , z ] = ((e ⊗ x) ⊗ y) ⊗ z foldl : ∀ {A B : Set} → (B → A → B) → B → List A → B foldl _⊗_ e xs = {!!} -- 747/PLFA exercise: FoldrMonFoldl (2 points) -- Show that foldr and foldl compute the same value on a monoid -- when the base case is the identity. -- Hint: generalize to when the base case is an arbitrary value. foldl-r-mon : ∀ {A : Set} → {{m : IsMonoid A}} → ∀ (xs : List A) → foldl _⊗_ id xs ≡ foldr _⊗_ id xs foldl-r-mon xs = {!!} -- Inductively-defined predicates over lists -- All P xs means P x holds for every element of xs data All {A : Set} (P : A → Set) : List A → Set where [] : All P [] _∷_ : ∀ {x : A} {xs : List A} → P x → All P xs → All P (x ∷ xs) _ : All (_≤ 2) [ 0 , 1 , 2 ] _ = z≤n ∷ s≤s z≤n ∷ s≤s (s≤s z≤n) ∷ [] -- Any P xs means P x holds for some element of xs data Any {A : Set} (P : A → Set) : List A → Set where here : ∀ {x : A} {xs : List A} → P x → Any P (x ∷ xs) there : ∀ {x : A} {xs : List A} → Any P xs → Any P (x ∷ xs) infix 4 _∈_ _∉_ -- membership in list as application of Any _∈_ : ∀ {A : Set} (x : A) (xs : List A) → Set x ∈ xs = Any (x ≡_) xs _∉_ : ∀ {A : Set} (x : A) (xs : List A) → Set x ∉ xs = ¬ (x ∈ xs) _ : 0 ∈ [ 0 , 1 , 0 , 2 ] _ = {!!} _ : 0 ∈ [ 0 , 1 , 0 , 2 ] _ = {!!} not-in : 3 ∉ [ 0 , 1 , 0 , 2 ] not-in = {!!} -- The development in PLFA, repeated with our notation. All-++-⇔ : ∀ {A : Set} {P : A → Set} (xs ys : List A) → All P (xs ++ ys) ⇔ (All P xs × All P ys) All-++-⇔ xs ys = {!!} -- PLFA exercise: state and prove Any-++-⇔, and use it to demonstrate -- an equivalence relating ∈ and _++_. -- PLFA exercise: Show that the equivalence All-++-⇔ can be extended to an isomorphism. -- PLFA exercise: Here is a universe-polymorphic version of composition, -- and a version of DeMorgan's law for Any and All expressed using it. _∘′_ : ∀ {ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set ℓ₁} {B : Set ℓ₂} {C : Set ℓ₃} → (B → C) → (A → B) → A → C (g ∘′ f) x = g (f x) -- ¬Any≃All¬ : ∀ {A : Set} (P : A → Set) (xs : List A) -- → (¬_ ∘′ Any P) xs ≃ All (¬_ ∘′ P) xs -- ¬Any≃All¬ P xs = {!!} -- Can we prove the following? If not, explain why. -- ¬All≃Any¬ : ∀ {A : Set} (P : A → Set) (xs : List A) -- → (¬_ ∘′ All P) xs ≃ Any (¬_ ∘′ P) xs -- End of PLFA exercise -- Decidability of All -- A Boolean analogue of All all : ∀ {A : Set} → (A → Bool) → List A → Bool all p = foldr _∧_ true ∘ map p -- A Dec analogue of All -- A definition of a predicate being decidable Decidable : ∀ {A : Set} → (A → Set) → Set Decidable {A} P = ∀ (x : A) → Dec (P x) All? : ∀ {A : Set} {P : A → Set} → Decidable P → Decidable (All P) All? P? [] = yes [] All? P? (x ∷ xs) with P? x | All? P? xs All? P? (x ∷ xs) | yes p | yes p₁ = yes (p ∷ p₁) All? P? (x ∷ xs) | yes p | no ¬p = no (λ { (x ∷ x₁) → ¬p x₁}) All? P? (x ∷ xs) | no ¬p | _ = no (λ { (x ∷ x₁) → ¬p x}) -- PLFA exercise: repeat above for Any -- PLFA exercises: All-∀ and Any-∃ -- You will need the stronger version of extensionality -- (for dependent function types) given in PLFA Isomorphism. -- PLFA exercise: a version of 'filter' for decidable predicates -- filter? : ∀ {A : Set} {P : A → Set} -- → (P? : Decidable P) → List A → ∃[ ys ]( All P ys ) -- filter? P? xs = {!!}
27.729911
87
0.572487
9a1629aadbb530143e0ad61a290824b6e9557dab
1,041
agda
Agda
test/agda/FRP/JS/Test.agda
agda/agda-frp-js
c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72
[ "MIT", "BSD-3-Clause" ]
63
2015-04-20T21:47:00.000Z
2022-02-28T09:46:14.000Z
test/agda/FRP/JS/Test.agda
agda/agda-frp-js
c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72
[ "MIT", "BSD-3-Clause" ]
null
null
null
test/agda/FRP/JS/Test.agda
agda/agda-frp-js
c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72
[ "MIT", "BSD-3-Clause" ]
7
2016-11-07T21:50:58.000Z
2022-03-12T11:39:38.000Z
open import FRP.JS.QUnit using ( TestSuites ; suite ; _,_ ) import FRP.JS.Test.Bool import FRP.JS.Test.Nat import FRP.JS.Test.Int import FRP.JS.Test.Float import FRP.JS.Test.String import FRP.JS.Test.Maybe import FRP.JS.Test.List import FRP.JS.Test.Array import FRP.JS.Test.Object import FRP.JS.Test.JSON import FRP.JS.Test.Behaviour import FRP.JS.Test.DOM import FRP.JS.Test.Compiler module FRP.JS.Test where tests : TestSuites tests = ( suite "Bool" FRP.JS.Test.Bool.tests , suite "Nat" FRP.JS.Test.Nat.tests , suite "Int" FRP.JS.Test.Int.tests , suite "Float" FRP.JS.Test.Float.tests , suite "String" FRP.JS.Test.String.tests , suite "Maybe" FRP.JS.Test.Maybe.tests , suite "List" FRP.JS.Test.List.tests , suite "Array" FRP.JS.Test.Array.tests , suite "Object" FRP.JS.Test.Object.tests , suite "JSON" FRP.JS.Test.JSON.tests , suite "Behaviour" FRP.JS.Test.Behaviour.tests , suite "DOM" FRP.JS.Test.DOM.tests , suite "Compiler" FRP.JS.Test.Compiler.tests )
30.617647
59
0.690682
c75902104d7887bf796967eddd866ac0e7f6e53a
1,435
agda
Agda
Cubical/Algebra/RingSolver/Examples.agda
hyleIndex/cubical
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
[ "MIT" ]
301
2018-10-17T18:00:24.000Z
2022-03-24T02:10:47.000Z
Cubical/Algebra/RingSolver/Examples.agda
hyleIndex/cubical
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
[ "MIT" ]
584
2018-10-15T09:49:02.000Z
2022-03-30T12:09:17.000Z
Cubical/Algebra/RingSolver/Examples.agda
hyleIndex/cubical
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
[ "MIT" ]
134
2018-11-16T06:11:03.000Z
2022-03-23T16:22:13.000Z
{-# OPTIONS --safe #-} module Cubical.Algebra.RingSolver.Examples where open import Cubical.Foundations.Prelude open import Cubical.Data.Int.Base hiding (_+_ ; _·_ ; _-_) open import Cubical.Algebra.CommRing open import Cubical.Algebra.RingSolver.ReflectionSolving private variable ℓ : Level module Test (R : CommRing ℓ) where open CommRingStr (snd R) _ : 1r · (1r + 0r) ≡ (1r · 0r) + 1r _ = solve R _ : 1r · 0r + (1r - 1r) ≡ 0r - 0r _ = solve R _ : (x : fst R) → x ≡ x _ = solve R _ : (x y : fst R) → x ≡ x _ = solve R _ : (x y : fst R) → x + y ≡ y + x _ = solve R _ : (x y : fst R) → (x + y) · (x - y) ≡ x · x - y · y _ = solve R {- A bigger example, copied from the other example files: -} _ : (x y z : (fst R)) → (x + y) · (x + y) · (x + y) · (x + y) ≡ x · x · x · x + (fromℤ R 4) · x · x · x · y + (fromℤ R 6) · x · x · y · y + (fromℤ R 4) · x · y · y · y + y · y · y · y _ = solve R {- Examples that used to fail (see #513): -} _ : (x : (fst R)) → x · 0r ≡ 0r _ = solve R _ : (x y z : (fst R)) → x · (y - z) ≡ x · y - x · z _ = solve R {- Keep in mind, that the solver can lead to wrong error locations. For example, the commented code below tries to solve an equation that does not hold, with the result of an error at the wrong location. _ : (x y : (fst R)) → x ≡ y _ = solve R -}
22.777778
91
0.514983
c7099e53930a80e73aa6e4eadffb236fc35a5fb7
156
agda
Agda
src/Prelude/Variables.agda
jespercockx/agda-prelude
1984cf0341835b2f7bfe678098bd57cfe16ea11f
[ "MIT" ]
null
null
null
src/Prelude/Variables.agda
jespercockx/agda-prelude
1984cf0341835b2f7bfe678098bd57cfe16ea11f
[ "MIT" ]
null
null
null
src/Prelude/Variables.agda
jespercockx/agda-prelude
1984cf0341835b2f7bfe678098bd57cfe16ea11f
[ "MIT" ]
null
null
null
module Prelude.Variables where open import Agda.Primitive open import Agda.Builtin.Nat variable ℓ ℓ₁ ℓ₂ ℓ₃ : Level A B : Set ℓ x y : A n m : Nat
13
30
0.692308
c7087d8b323fb7f77839b439afcdb1f51a5f70bc
139
agda
Agda
src/hott/level/sets.agda
pcapriotti/agda-base
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
[ "BSD-3-Clause" ]
20
2015-06-12T12:20:17.000Z
2022-02-01T11:25:54.000Z
src/hott/level/sets.agda
pcapriotti/agda-base
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
[ "BSD-3-Clause" ]
4
2015-02-02T14:32:16.000Z
2016-10-26T11:57:26.000Z
src/hott/level/sets.agda
pcapriotti/agda-base
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
[ "BSD-3-Clause" ]
4
2015-02-02T12:17:00.000Z
2019-05-04T19:31:00.000Z
{-# OPTIONS --without-K #-} module hott.level.sets where open import hott.level.sets.core public open import hott.level.sets.extra public
23.166667
40
0.76259
22dcf6565127ecbb55da42178d47e0f0fb47576b
274
agda
Agda
test/Succeed/Issue414.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue414.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue414.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- {-# OPTIONS -v tc.rec:100 -v tc.signature:20 #-} module Issue414 where record P : Set₁ where field q : Set x : P x = record { q = q } -- Andreas 2011-05-19 -- record constructor should have been added to the signature -- before record module is constructed!
19.571429
61
0.660584
108fa2aeb6257663e4d61729e7cf567ff170c694
1,462
agda
Agda
Cubical/Algebra/CommRing/Ideal.agda
maxdore/cubical
ef62b84397396d48135d73ba7400b71c721ddc94
[ "MIT" ]
null
null
null
Cubical/Algebra/CommRing/Ideal.agda
maxdore/cubical
ef62b84397396d48135d73ba7400b71c721ddc94
[ "MIT" ]
null
null
null
Cubical/Algebra/CommRing/Ideal.agda
maxdore/cubical
ef62b84397396d48135d73ba7400b71c721ddc94
[ "MIT" ]
1
2021-03-12T20:08:45.000Z
2021-03-12T20:08:45.000Z
{- This is mostly for convenience, when working with ideals (which are defined for general rings) in a commutative ring. -} {-# OPTIONS --safe #-} module Cubical.Algebra.CommRing.Ideal where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Foundations.Powerset open import Cubical.Algebra.CommRing.Base open import Cubical.Algebra.Ring.Ideal renaming (IdealsIn to IdealsInRing) open import Cubical.Algebra.RingSolver.ReflectionSolving hiding (∣) private variable ℓ : Level IdealsIn : (R : CommRing ℓ) → Type _ IdealsIn R = IdealsInRing (CommRing→Ring R) module _ (Ring@(R , str) : CommRing ℓ) where open CommRingStr str makeIdeal : (I : R → hProp ℓ) → (+-closed : {x y : R} → x ∈ I → y ∈ I → (x + y) ∈ I) → (0r-closed : 0r ∈ I) → (·-closedLeft : {x : R} → (r : R) → x ∈ I → r · x ∈ I) → IdealsIn (R , str) makeIdeal I +-closed 0r-closed ·-closedLeft = I , (record { +-closed = +-closed ; -closed = λ x∈I → subst (_∈ I) (useSolver _) (·-closedLeft (- 1r) x∈I) ; 0r-closed = 0r-closed ; ·-closedLeft = ·-closedLeft ; ·-closedRight = λ r x∈I → subst (_∈ I) (·-comm r _) (·-closedLeft r x∈I) }) where useSolver : (x : R) → - 1r · x ≡ - x useSolver = solve Ring
32.488889
74
0.556772
2e219116e89c89bbcb9488095eb64cc85bcbaa57
2,172
agda
Agda
BasicIPC/Syntax/GentzenSpinalNormalForm.agda
mietek/hilbert-gentzen
fcd187db70f0a39b894fe44fad0107f61849405c
[ "X11" ]
29
2016-07-03T18:51:56.000Z
2022-01-01T10:29:18.000Z
BasicIPC/Syntax/GentzenSpinalNormalForm.agda
mietek/hilbert-gentzen
fcd187db70f0a39b894fe44fad0107f61849405c
[ "X11" ]
1
2018-06-10T09:11:22.000Z
2018-06-10T09:11:22.000Z
BasicIPC/Syntax/GentzenSpinalNormalForm.agda
mietek/hilbert-gentzen
fcd187db70f0a39b894fe44fad0107f61849405c
[ "X11" ]
null
null
null
-- Basic intuitionistic propositional calculus, without ∨ or ⊥. -- Gentzen-style formalisation of syntax. -- Normal forms, neutrals, and spines. module BasicIPC.Syntax.GentzenSpinalNormalForm where open import BasicIPC.Syntax.Gentzen public -- Derivations. mutual -- Normal forms, or introductions. infix 3 _⊢ⁿᶠ_ data _⊢ⁿᶠ_ (Γ : Cx Ty) : Ty → Set where neⁿᶠ : ∀ {P} → Γ ⊢ⁿᵉ α P → Γ ⊢ⁿᶠ α P lamⁿᶠ : ∀ {A B} → Γ , A ⊢ⁿᶠ B → Γ ⊢ⁿᶠ A ▻ B pairⁿᶠ : ∀ {A B} → Γ ⊢ⁿᶠ A → Γ ⊢ⁿᶠ B → Γ ⊢ⁿᶠ A ∧ B unitⁿᶠ : Γ ⊢ⁿᶠ ⊤ -- Neutrals, or eliminations. infix 3 _⊢ⁿᵉ_ data _⊢ⁿᵉ_ (Γ : Cx Ty) : Ty → Set where spⁿᵉ : ∀ {A C} → A ∈ Γ → Γ ⊢ˢᵖ A ⦙ C → Γ ⊢ⁿᵉ C -- Spines. infix 3 _⊢ˢᵖ_⦙_ data _⊢ˢᵖ_⦙_ (Γ : Cx Ty) : Ty → Ty → Set where nilˢᵖ : ∀ {C} → Γ ⊢ˢᵖ C ⦙ C appˢᵖ : ∀ {A B C} → Γ ⊢ˢᵖ B ⦙ C → Γ ⊢ⁿᶠ A → Γ ⊢ˢᵖ A ▻ B ⦙ C fstˢᵖ : ∀ {A B C} → Γ ⊢ˢᵖ A ⦙ C → Γ ⊢ˢᵖ A ∧ B ⦙ C sndˢᵖ : ∀ {A B C} → Γ ⊢ˢᵖ B ⦙ C → Γ ⊢ˢᵖ A ∧ B ⦙ C -- Translation from normal forms to simple terms. mutual nf→tm : ∀ {A Γ} → Γ ⊢ⁿᶠ A → Γ ⊢ A nf→tm (neⁿᶠ t) = ne→tm t nf→tm (lamⁿᶠ t) = lam (nf→tm t) nf→tm (pairⁿᶠ t u) = pair (nf→tm t) (nf→tm u) nf→tm unitⁿᶠ = unit ne→tm : ∀ {A Γ} → Γ ⊢ⁿᵉ A → Γ ⊢ A ne→tm (spⁿᵉ i xs) = sp→tm (var i) xs sp→tm : ∀ {A C Γ} → Γ ⊢ A → Γ ⊢ˢᵖ A ⦙ C → Γ ⊢ C sp→tm t nilˢᵖ = t sp→tm t (appˢᵖ xs u) = sp→tm (app t (nf→tm u)) xs sp→tm t (fstˢᵖ xs) = sp→tm (fst t) xs sp→tm t (sndˢᵖ xs) = sp→tm (snd t) xs -- Monotonicity with respect to context inclusion. mutual mono⊢ⁿᶠ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢ⁿᶠ A → Γ′ ⊢ⁿᶠ A mono⊢ⁿᶠ η (neⁿᶠ t) = neⁿᶠ (mono⊢ⁿᵉ η t) mono⊢ⁿᶠ η (lamⁿᶠ t) = lamⁿᶠ (mono⊢ⁿᶠ (keep η) t) mono⊢ⁿᶠ η (pairⁿᶠ t u) = pairⁿᶠ (mono⊢ⁿᶠ η t) (mono⊢ⁿᶠ η u) mono⊢ⁿᶠ η unitⁿᶠ = unitⁿᶠ mono⊢ⁿᵉ : ∀ {A Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢ⁿᵉ A → Γ′ ⊢ⁿᵉ A mono⊢ⁿᵉ η (spⁿᵉ i xs) = spⁿᵉ (mono∈ η i) (mono⊢ˢᵖ η xs) mono⊢ˢᵖ : ∀ {A C Γ Γ′} → Γ ⊆ Γ′ → Γ ⊢ˢᵖ A ⦙ C → Γ′ ⊢ˢᵖ A ⦙ C mono⊢ˢᵖ η nilˢᵖ = nilˢᵖ mono⊢ˢᵖ η (appˢᵖ xs u) = appˢᵖ (mono⊢ˢᵖ η xs) (mono⊢ⁿᶠ η u) mono⊢ˢᵖ η (fstˢᵖ xs) = fstˢᵖ (mono⊢ˢᵖ η xs) mono⊢ˢᵖ η (sndˢᵖ xs) = sndˢᵖ (mono⊢ˢᵖ η xs)
30.591549
63
0.525322
cb70fc79c4e51cdc793b0f06c661782dafbfdc4d
274
agda
Agda
src/NTypes/Unit.agda
vituscze/HoTT-lectures
7730385adfdbdda38ee8b124be3cdeebb7312c65
[ "BSD-3-Clause" ]
null
null
null
src/NTypes/Unit.agda
vituscze/HoTT-lectures
7730385adfdbdda38ee8b124be3cdeebb7312c65
[ "BSD-3-Clause" ]
null
null
null
src/NTypes/Unit.agda
vituscze/HoTT-lectures
7730385adfdbdda38ee8b124be3cdeebb7312c65
[ "BSD-3-Clause" ]
null
null
null
{-# OPTIONS --without-K #-} module NTypes.Unit where open import Equivalence open import NTypes open import PathStructure.Unit open import Types 1-isProp : isProp ⊤ 1-isProp _ _ = merge-path _ 1-isSet : isSet ⊤ 1-isSet _ _ = prop-eq (sym-equiv split-merge-eq) 1-isProp
18.266667
45
0.726277
a1aaa18cc396400b37fa1cdcf5163bb142ab6b79
3,886
agda
Agda
lib/Explore/BinTree.agda
crypto-agda/explore
16bc8333503ff9c00d47d56f4ec6113b9269a43e
[ "BSD-3-Clause" ]
2
2016-06-05T09:25:32.000Z
2017-06-28T19:19:29.000Z
lib/Explore/BinTree.agda
crypto-agda/explore
16bc8333503ff9c00d47d56f4ec6113b9269a43e
[ "BSD-3-Clause" ]
1
2019-03-16T14:24:04.000Z
2019-03-16T14:24:04.000Z
lib/Explore/BinTree.agda
crypto-agda/explore
16bc8333503ff9c00d47d56f4ec6113b9269a43e
[ "BSD-3-Clause" ]
null
null
null
{-# OPTIONS --without-K #-} module Explore.BinTree where open import Level.NP open import Type hiding (★) open import Data.Tree.Binary open import Data.Zero open import Data.One open import Data.Sum open import Data.Product open import Relation.Binary.PropositionalEquality.NP open import HoTT open Equivalences open import Type.Identities open import Function open import Function.Extensionality open import Explore.Core open import Explore.Properties open import Explore.Zero open import Explore.Sum open import Explore.Isomorphism fromBinTree : ∀ {m} {a} {A : ★ a} → BinTree A → Explore m A fromBinTree empty = empty-explore fromBinTree (leaf x) = point-explore x fromBinTree (fork ℓ r) = merge-explore (fromBinTree ℓ) (fromBinTree r) fromBinTree-ind : ∀ {m p a} {A : ★ a} (t : BinTree A) → ExploreInd p (fromBinTree {m} t) fromBinTree-ind empty = empty-explore-ind fromBinTree-ind (leaf x) = point-explore-ind x fromBinTree-ind (fork ℓ r) = merge-explore-ind (fromBinTree-ind ℓ) (fromBinTree-ind r) AnyP≡ΣfromBinTree : ∀ {a p}{A : ★ a}{P : A → ★ p}(xs : BinTree A) → Any P xs ≡ Σᵉ (fromBinTree xs) P AnyP≡ΣfromBinTree empty = idp AnyP≡ΣfromBinTree (leaf x) = idp AnyP≡ΣfromBinTree (fork xs xs₁) = ⊎= (AnyP≡ΣfromBinTree xs) (AnyP≡ΣfromBinTree xs₁) module _ {{_ : UA}}{{_ : FunExt}}{A : ★ ₀} where exploreΣ∈ : ∀ {m} xs → Explore m (Σ A λ x → Any (_≡_ x) xs) exploreΣ∈ empty = explore-iso (coe-equiv (Lift≡id ∙ ! ×𝟘-snd ∙ ×= idp (! Lift≡id))) Lift𝟘ᵉ exploreΣ∈ (leaf x) = point-explore (x , idp) exploreΣ∈ (fork xs xs₁) = explore-iso (coe-equiv (! Σ⊎-split)) (exploreΣ∈ xs ⊎ᵉ exploreΣ∈ xs₁) Σᵉ-adq-exploreΣ∈ : ∀ {m} xs → Adequate-Σ {m} (Σᵉ (exploreΣ∈ xs)) Σᵉ-adq-exploreΣ∈ empty = Σ-iso-ok (coe-equiv (Lift≡id ∙ ! ×𝟘-snd ∙ ×= idp (! Lift≡id))) {Aᵉ = Lift𝟘ᵉ} ΣᵉLift𝟘-ok Σᵉ-adq-exploreΣ∈ (leaf x₁) F = ! Σ𝟙-snd ∙ Σ-fst≃ (≃-sym (Σx≡≃𝟙 x₁)) F Σᵉ-adq-exploreΣ∈ (fork xs xs₁) = Σ-iso-ok (coe-equiv (! Σ⊎-split)) {Aᵉ = exploreΣ∈ xs ⊎ᵉ exploreΣ∈ xs₁} (Σᵉ⊎-ok {eᴬ = exploreΣ∈ xs}{eᴮ = exploreΣ∈ xs₁} (Σᵉ-adq-exploreΣ∈ xs) (Σᵉ-adq-exploreΣ∈ xs₁)) module _ {{_ : UA}}{{_ : FunExt}}{A : ★ ₀}{P : A → ★ _}(explore-P : ∀ {m} x → Explore m (P x)) where open import Explore.Zero open import Explore.Sum open import Explore.Isomorphism exploreAny : ∀ {m} xs → Explore m (Any P xs) exploreAny empty = Lift𝟘ᵉ exploreAny (leaf x) = explore-P x exploreAny (fork xs xs₁) = exploreAny xs ⊎ᵉ exploreAny xs₁ module _ (Σᵉ-adq-explore-P : ∀ {m} x → Adequate-Σ {m} (Σᵉ (explore-P x))) where Σᵉ-adq-exploreAny : ∀ {m} xs → Adequate-Σ {m} (Σᵉ (exploreAny xs)) Σᵉ-adq-exploreAny empty F = ! Σ𝟘-lift∘fst ∙ Σ-fst= (! Lift≡id) _ Σᵉ-adq-exploreAny (leaf x₁) F = Σᵉ-adq-explore-P x₁ F Σᵉ-adq-exploreAny (fork xs xs₁) F = ⊎= (Σᵉ-adq-exploreAny xs _) (Σᵉ-adq-exploreAny xs₁ _) ∙ ! dist-⊎-Σ exploreΣᵉ : ∀ {m} xs → Explore m (Σᵉ (fromBinTree xs) P) exploreΣᵉ {m} xs = fromBinTree-ind xs (λ e → Explore m (Σᵉ e P)) Lift𝟘ᵉ _⊎ᵉ_ explore-P module _ (Σᵉ-adq-explore-P : ∀ {m} x → Adequate-Σ {m} (Σᵉ (explore-P x))) where Σᵉ-adq-exploreΣᵉ : ∀ {m} xs → Adequate-Σ {m} (Σᵉ (exploreΣᵉ xs)) Σᵉ-adq-exploreΣᵉ empty F = ! Σ𝟘-lift∘fst ∙ Σ-fst= (! Lift≡id) _ Σᵉ-adq-exploreΣᵉ (leaf x₁) F = Σᵉ-adq-explore-P x₁ F Σᵉ-adq-exploreΣᵉ (fork xs xs₁) F = ⊎= (Σᵉ-adq-exploreΣᵉ xs _) (Σᵉ-adq-exploreΣᵉ xs₁ _) ∙ ! dist-⊎-Σ data Path {a}{A : ★_ a} : BinTree A → ★_ a where leaf : (x : A) → Path (leaf x) left : {t u : BinTree A} (p : Path t) → Path (fork t u) right : {t u : BinTree A} (p : Path u) → Path (fork t u) path : ∀ {a}{A : ★ a} → BinTree A → ★₀ path empty = 𝟘 path (leaf x) = 𝟙 path (fork t u) = path t ⊎ path u path' : ∀{a}{A : ★ a} → BinTree A → ★₀ path' t = fromBinTree t 𝟘 _⊎_ (const 𝟙) -- -} -- -} -- -} -- -}
39.252525
108
0.618116
1ab7ef005ad76d30967e51bf2afc5d0b7ba32ca6
3,702
agda
Agda
README.agda
nad/dependently-typed-syntax
498f8aefc570f7815fd1d6616508eeb92c52abce
[ "MIT" ]
5
2020-04-16T12:14:44.000Z
2020-07-08T22:51:36.000Z
README.agda
nad/dependently-typed-syntax
498f8aefc570f7815fd1d6616508eeb92c52abce
[ "MIT" ]
null
null
null
README.agda
nad/dependently-typed-syntax
498f8aefc570f7815fd1d6616508eeb92c52abce
[ "MIT" ]
null
null
null
------------------------------------------------------------------------ -- A library for working with dependently typed syntax -- Nils Anders Danielsson ------------------------------------------------------------------------ -- This library is leaning heavily on two of Conor McBride's papers: -- -- * Type-Preserving Renaming and Substitution. -- -- * Outrageous but Meaningful Coincidences: Dependent type-safe -- syntax and evaluation. -- This module gives a brief overview of the modules in the library. module README where ------------------------------------------------------------------------ -- The library -- Contexts, variables, context morphisms, context extensions, etc. import deBruijn.Context -- Parallel substitutions (defined using an inductive family). import deBruijn.Substitution.Data.Basics -- A map function for the substitutions. import deBruijn.Substitution.Data.Map -- Some simple substitution combinators. (Given a term type which -- supports weakening and transformation of variables to terms various -- substitutions are defined and various lemmas proved.) import deBruijn.Substitution.Data.Simple -- Given an operation which applies a substitution to a term, -- satisfying some properties, more operations and lemmas are -- defined/proved. -- -- (This module reexports various other modules.) import deBruijn.Substitution.Data.Application -- A module which repackages (and reexports) the development under -- deBruijn.Substitution.Data. import deBruijn.Substitution.Data -- Some modules mirroring the development under -- deBruijn.Substitution.Data, but using substitutions defined as -- functions rather than data. -- -- The functional version of substitutions is in some respects easier -- to work with than the one based on data, but in other respects more -- awkward. I maintain both developments so that they can be compared. import deBruijn.Substitution.Function.Basics import deBruijn.Substitution.Function.Map import deBruijn.Substitution.Function.Simple -- The two definitions of substitutions are isomorphic (assuming -- extensionality). import deBruijn.Substitution.Isomorphic ------------------------------------------------------------------------ -- An example showing how the library can be used -- A well-typed representation of a dependently typed language. import README.DependentlyTyped.Term -- Normal and neutral terms. import README.DependentlyTyped.NormalForm -- Instantiation of deBruijn.Substitution.Data for terms. import README.DependentlyTyped.Term.Substitution -- Instantiation of deBruijn.Substitution.Data for normal and neutral -- terms. import README.DependentlyTyped.NormalForm.Substitution -- Normalisation by evaluation. import README.DependentlyTyped.NBE -- Various equality checkers (some complete, all sound). import README.DependentlyTyped.Equality-checker -- Raw terms. import README.DependentlyTyped.Raw-term -- A type-checker (sound). import README.DependentlyTyped.Type-checker -- A definability result: A "closed value" is the semantics of a -- closed term if and only if it satisfies all "Kripke predicates". import README.DependentlyTyped.Definability -- An observation: There is a term without a corresponding syntactic -- type (given some assumptions). import README.DependentlyTyped.Term-without-type -- Another observation: If the "Outrageous but Meaningful -- Coincidences" approach is used to formalise a language, then you -- can end up with an extensional type theory (with equality -- reflection). import README.DependentlyTyped.Extensional-type-theory -- Inductively defined beta-eta-equality. import README.DependentlyTyped.Beta-Eta -- TODO: Add an untyped example.
29.380952
72
0.729606
59490d9eb60fb8f95b7269a67441f028f0878529
469
agda
Agda
archive/agda-2/Oscar/Data/Term.agda
m0davis/oscar
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
[ "RSA-MD" ]
null
null
null
archive/agda-2/Oscar/Data/Term.agda
m0davis/oscar
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
[ "RSA-MD" ]
1
2019-04-29T00:35:04.000Z
2019-05-11T23:33:04.000Z
archive/agda-2/Oscar/Data/Term.agda
m0davis/oscar
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
[ "RSA-MD" ]
null
null
null
module Oscar.Data.Term {𝔣} (FunctionName : Set 𝔣) where open import Oscar.Data.Equality open import Oscar.Data.Fin open import Oscar.Data.Nat open import Oscar.Data.Vec open import Oscar.Function open import Oscar.Relation mutual Terms : Nat → Nat → Set 𝔣 Terms N m = Vec (Term m) N data Term (m : Nat) : Set 𝔣 where i : (x : Fin m) → Term m leaf : Term m _fork_ : (s t : Term m) → Term m function : FunctionName → ∀ {N} → Terms N m → Term m
22.333333
56
0.658849
50321df32d758dd427b30a7e625f12e20ea194c8
235
agda
Agda
test/Succeed/Issue1691/Nat.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue1691/Nat.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue1691/Nat.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module Issue1691.Nat where data ℕ : Set where zero : ℕ suc : (n : ℕ) → ℕ {-# BUILTIN NATURAL ℕ #-} _∸_ : ℕ → ℕ → ℕ m ∸ zero = m zero ∸ suc n = zero suc m ∸ suc n = m ∸ n pred : ℕ → ℕ pred zero = zero pred (suc n) = n
13.823529
26
0.519149
3dcc87295a3375740a6258e9e4522eb4f081ff11
1,428
agda
Agda
src/SecondOrder/Theory.agda
andrejbauer/formal
2aaf850bb1a262681c5a232cdefae312f921b9d4
[ "MIT" ]
1
2021-04-18T18:21:00.000Z
2021-04-18T18:21:00.000Z
src/SecondOrder/Theory.agda
andrejbauer/formaltt
2aaf850bb1a262681c5a232cdefae312f921b9d4
[ "MIT" ]
null
null
null
src/SecondOrder/Theory.agda
andrejbauer/formaltt
2aaf850bb1a262681c5a232cdefae312f921b9d4
[ "MIT" ]
null
null
null
open import Agda.Primitive using (lzero; lsuc; _⊔_) import SecondOrder.Arity import SecondOrder.Signature import SecondOrder.Metavariable import SecondOrder.Renaming import SecondOrder.Term module SecondOrder.Theory {ℓ} {𝔸 : SecondOrder.Arity.Arity} (Σ : SecondOrder.Signature.Signature ℓ 𝔸) where open SecondOrder.Metavariable Σ public open SecondOrder.Term Σ public open SecondOrder.Signature.Signature Σ public open SecondOrder.Renaming Σ record Axiom : Set ℓ where constructor make-ax field ax-mv-ctx : MContext -- metavariable context of an equation ax-sort : sort -- sort of an equation ax-lhs : Term ax-mv-ctx ctx-empty ax-sort -- left-hand side ax-rhs : Term ax-mv-ctx ctx-empty ax-sort -- right-hand side record Theory ℓa : Set (lsuc (ℓ ⊔ ℓa)) where field ax : Set ℓa -- the axioms ax-eq : ax → Axiom -- each axiom has a corresponding Axiom ax-mv-ctx : ax → MContext -- the meta-context of each axiom ax-mv-ctx ε = Axiom.ax-mv-ctx (ax-eq ε) ax-sort : ax → sort -- the sort of each axiom ax-sort ε = Axiom.ax-sort (ax-eq ε) -- the left- and right-hand side of each axiom s ≈ t, promoted to any context ax-lhs : ∀ (ε : ax) {Γ} → Term (ax-mv-ctx ε) Γ (ax-sort ε) ax-lhs ε = [ inʳ ]ʳ Axiom.ax-lhs (ax-eq ε) ax-rhs : ∀ (ε : ax) {Γ} → Term (ax-mv-ctx ε) Γ (ax-sort ε) ax-rhs ε = [ inʳ ]ʳ Axiom.ax-rhs (ax-eq ε)
31.733333
81
0.661064
23589e2ad9417139e93ca11509d2392b4f6bc5cc
288
agda
Agda
test/Succeed/Issue1218.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue1218.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue1218.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
open import Common.Prelude open import Common.Reflection {-# NON_TERMINATING #-} -- Note that in the body of the unquote, 'loop' really means 'quote loop'. unquoteDecl loop = define (vArg loop) (funDef (def (quote Nat) []) (clause [] [] (def loop []) ∷ []))
26.181818
74
0.611111
134fa43002b4c1f2ac8b39e587641033d094bdc1
6,661
agda
Agda
TotalParserCombinators/Semantics/Continuation.agda
yurrriq/parser-combinators
b396d35cc2cb7e8aea50b982429ee385f001aa88
[ "MIT" ]
7
2016-12-13T05:23:14.000Z
2021-06-22T05:35:31.000Z
TotalParserCombinators/Semantics/Continuation.agda
yurrriq/parser-combinators
b396d35cc2cb7e8aea50b982429ee385f001aa88
[ "MIT" ]
1
2018-01-22T22:21:41.000Z
2018-01-24T16:39:37.000Z
TotalParserCombinators/Semantics/Continuation.agda
yurrriq/parser-combinators
b396d35cc2cb7e8aea50b982429ee385f001aa88
[ "MIT" ]
null
null
null
------------------------------------------------------------------------ -- A semantics which uses continuation-passing style ------------------------------------------------------------------------ module TotalParserCombinators.Semantics.Continuation where open import Algebra open import Coinduction open import Data.List open import Data.List.Any.Membership.Propositional using (bag) renaming (_∼[_]_ to _List-∼[_]_) import Data.List.Properties as ListProp open import Data.Maybe using (Maybe) open import Data.Product as Prod open import Function open import Relation.Binary.PropositionalEquality as P using (_≡_) private module LM {Tok : Set} = Monoid (ListProp.++-monoid Tok) open import TotalParserCombinators.Parser open import TotalParserCombinators.Semantics as S hiding ([_-_]_⊛_; [_-_]_>>=_) -- The statement x ⊕ s₂ ∈ p · s means that there is some s₁ such that -- s ≡ s₁ ++ s₂ and x ∈ p · s₁. This variant of the semantics is -- perhaps harder to understand, but sometimes easier to work with -- (and it is proved to be language equivalent to the semantics in -- TotalParserCombinators.Semantics). infix 60 <$>_ infixl 50 [_-_]_⊛_ infixl 10 [_-_]_>>=_ infix 4 _⊕_∈_·_ data _⊕_∈_·_ {Tok} : ∀ {R xs} → R → List Tok → Parser Tok R xs → List Tok → Set₁ where return : ∀ {R} {x : R} {s} → x ⊕ s ∈ return x · s token : ∀ {x s} → x ⊕ s ∈ token · x ∷ s ∣-left : ∀ {R x xs₁ xs₂ s s₁} {p₁ : Parser Tok R xs₁} {p₂ : Parser Tok R xs₂} (x∈p₁ : x ⊕ s₁ ∈ p₁ · s) → x ⊕ s₁ ∈ p₁ ∣ p₂ · s ∣-right : ∀ {R x xs₂ s s₁} xs₁ {p₁ : Parser Tok R xs₁} {p₂ : Parser Tok R xs₂} (x∈p₂ : x ⊕ s₁ ∈ p₂ · s) → x ⊕ s₁ ∈ p₁ ∣ p₂ · s <$>_ : ∀ {R₁ R₂ x s s₁ xs} {p : Parser Tok R₁ xs} {f : R₁ → R₂} (x∈p : x ⊕ s₁ ∈ p · s) → f x ⊕ s₁ ∈ f <$> p · s [_-_]_⊛_ : ∀ {R₁ R₂ f x s s₁ s₂} xs fs {p₁ : ∞⟨ xs ⟩Parser Tok (R₁ → R₂) (flatten fs)} {p₂ : ∞⟨ fs ⟩Parser Tok R₁ (flatten xs)} → (f∈p₁ : f ⊕ s₁ ∈ ♭? p₁ · s) (x∈p₂ : x ⊕ s₂ ∈ ♭? p₂ · s₁) → f x ⊕ s₂ ∈ p₁ ⊛ p₂ · s [_-_]_>>=_ : ∀ {R₁ R₂ x y s s₁ s₂} (f : Maybe (R₁ → List R₂)) xs {p₁ : ∞⟨ f ⟩Parser Tok R₁ (flatten xs)} {p₂ : (x : R₁) → ∞⟨ xs ⟩Parser Tok R₂ (apply f x)} → (x∈p₁ : x ⊕ s₁ ∈ ♭? p₁ · s) (y∈p₂x : y ⊕ s₂ ∈ ♭? (p₂ x) · s₁) → y ⊕ s₂ ∈ p₁ >>= p₂ · s nonempty : ∀ {R xs x y s₂} s₁ {p : Parser Tok R xs} (x∈p : y ⊕ s₂ ∈ p · x ∷ s₁ ++ s₂) → y ⊕ s₂ ∈ nonempty p · x ∷ s₁ ++ s₂ cast : ∀ {R xs₁ xs₂ x s₁ s₂} {xs₁≈xs₂ : xs₁ List-∼[ bag ] xs₂} {p : Parser Tok R xs₁} (x∈p : x ⊕ s₂ ∈ p · s₁) → x ⊕ s₂ ∈ cast xs₁≈xs₂ p · s₁ -- A simple cast lemma. private cast∈′ : ∀ {Tok R xs} {p : Parser Tok R xs} {x s s′ s₁} → s ≡ s′ → x ⊕ s₁ ∈ p · s → x ⊕ s₁ ∈ p · s′ cast∈′ P.refl x∈ = x∈ -- The definition is sound and complete with respect to the one in -- TotalParserCombinators.Semantics. sound′ : ∀ {Tok R xs x s₂ s} {p : Parser Tok R xs} → x ⊕ s₂ ∈ p · s → ∃ λ s₁ → s ≡ s₁ ++ s₂ × x ∈ p · s₁ sound′ return = ([] , P.refl , return) sound′ {x = x} token = ([ x ] , P.refl , token) sound′ (∣-left x∈p₁) = Prod.map id (Prod.map id ∣-left) (sound′ x∈p₁) sound′ (∣-right e₁ x∈p₁) = Prod.map id (Prod.map id (∣-right e₁)) (sound′ x∈p₁) sound′ (<$> x∈p) = Prod.map id (Prod.map id (<$>_)) (sound′ x∈p) sound′ ([ xs - fs ] f∈p₁ ⊛ x∈p₂) with sound′ f∈p₁ | sound′ x∈p₂ sound′ ([ xs - fs ] f∈p₁ ⊛ x∈p₂) | (s₁ , P.refl , f∈p₁′) | (s₂ , P.refl , x∈p₂′) = (s₁ ++ s₂ , P.sym (LM.assoc s₁ s₂ _) , S.[_-_]_⊛_ xs fs f∈p₁′ x∈p₂′) sound′ (nonempty s₁ x∈p) with sound′ x∈p sound′ (nonempty s₁ x∈p) | (y ∷ s , eq , x∈p′) = (y ∷ s , eq , nonempty x∈p′) sound′ (nonempty s₁ x∈p) | ([] , eq , x∈p′) with ListProp.left-identity-unique (_ ∷ s₁) (P.sym eq) sound′ (nonempty s₁ x∈p) | ([] , eq , x∈p′) | () sound′ (cast x∈p) = Prod.map id (Prod.map id cast) (sound′ x∈p) sound′ ([ f - xs ] x∈p₁ >>= y∈p₂x) with sound′ x∈p₁ | sound′ y∈p₂x sound′ ([ f - xs ] x∈p₁ >>= y∈p₂x) | (s₁ , P.refl , x∈p₁′) | (s₂ , P.refl , y∈p₂x′) = (s₁ ++ s₂ , P.sym (LM.assoc s₁ s₂ _) , S.[_-_]_>>=_ f xs x∈p₁′ y∈p₂x′) sound : ∀ {Tok R xs x s} {p : Parser Tok R xs} → x ⊕ [] ∈ p · s → x ∈ p · s sound x∈p with sound′ x∈p sound x∈p | (s , P.refl , x∈p′) with s ++ [] | Prod.proj₂ LM.identity s sound x∈p | (s , P.refl , x∈p′) | .s | P.refl = x∈p′ extend : ∀ {Tok R xs x s s′ s″} {p : Parser Tok R xs} → x ⊕ s′ ∈ p · s → x ⊕ s′ ++ s″ ∈ p · s ++ s″ extend return = return extend token = token extend (∣-left x∈p₁) = ∣-left (extend x∈p₁) extend (∣-right e₁ x∈p₂) = ∣-right e₁ (extend x∈p₂) extend (<$> x∈p) = <$> extend x∈p extend ([ xs - fs ] f∈p₁ ⊛ x∈p₂) = [ xs - fs ] extend f∈p₁ ⊛ extend x∈p₂ extend ([ f - xs ] x∈p₁ >>= y∈p₂x) = [ f - xs ] extend x∈p₁ >>= extend y∈p₂x extend (cast x∈p) = cast (extend x∈p) extend (nonempty s₁ x∈p) = cast₂ (nonempty s₁ (cast₁ (extend x∈p))) where lem = LM.assoc (_ ∷ s₁) _ _ cast₁ = cast∈′ lem cast₂ = cast∈′ (P.sym lem) complete : ∀ {Tok R xs x s} {p : Parser Tok R xs} → x ∈ p · s → x ⊕ [] ∈ p · s complete return = return complete token = token complete (∣-left x∈p₁) = ∣-left (complete x∈p₁) complete (∣-right e₁ x∈p₂) = ∣-right e₁ (complete x∈p₂) complete (<$> x∈p) = <$> complete x∈p complete (_⊛_ {fs = fs} {xs = xs} f∈p₁ x∈p₂) = [ xs - fs ] extend (complete f∈p₁) ⊛ complete x∈p₂ complete (_>>=_ {xs = xs} {f = f} x∈p₁ y∈p₂x) = [ f - xs ] extend (complete x∈p₁) >>= complete y∈p₂x complete (cast x∈p) = cast (complete x∈p) complete (nonempty {s = s} x∈p) = cast₂ (nonempty s (cast₁ (complete x∈p))) where lem = Prod.proj₂ LM.identity _ cast₁ = cast∈′ (P.sym lem) cast₂ = cast∈′ lem complete′ : ∀ {Tok R xs x s₂ s} {p : Parser Tok R xs} → (∃ λ s₁ → s ≡ s₁ ++ s₂ × x ∈ p · s₁) → x ⊕ s₂ ∈ p · s complete′ (s₁ , P.refl , x∈p) = extend (complete x∈p)
47.241135
103
0.463594
dc64a93a989bb7fc8c88b79407f0607e984ff4a3
3,618
agda
Agda
src/Web/URI.agda
agda/agda-web-uri
8ced22124dbe12fa820699bb362247a96d592c03
[ "MIT" ]
1
2019-12-23T04:56:25.000Z
2019-12-23T04:56:25.000Z
src/Web/URI.agda
agda/agda-web-uri
8ced22124dbe12fa820699bb362247a96d592c03
[ "MIT" ]
null
null
null
src/Web/URI.agda
agda/agda-web-uri
8ced22124dbe12fa820699bb362247a96d592c03
[ "MIT" ]
1
2022-03-12T11:37:59.000Z
2022-03-12T11:37:59.000Z
open import Data.Bool using ( Bool ; true ; false ; _∨_ ) open import Data.List.Primitive using ( #List ; [] ; _∷_ ) open import Data.Maybe using ( Maybe ; just ; nothing ) open import Data.Maybe.Primitive using ( #Maybe ; just ; nothing ) open import Data.String using ( String ) open import Web.URI.Primitive using ( #URI ; #toString ; #fromString ; #abs ; #rel ) open import Web.URI.Scheme using ( Scheme? ; http: ) open import Web.URI.Port using ( Port? ; ε ) module Web.URI where infixl 5 _/_ _#_ _//_∶_ _//_ -- No authority or query component for now, and no parent path segments. -- URIRef? isAbs isRef tracks whether a URI is absolute or relative, -- and whether it is a URI reference (allows a #fragment) or not. data URIRef? : Bool → Bool → Set where root : {isRef : Bool} → (URIRef? false isRef) _//_∶_ : {isRef : Bool} → Scheme? → String → Port? → (URIRef? true isRef) _/_ : {isAbs isRef : Bool} → (URIRef? isAbs false) → String → (URIRef? isAbs isRef) _#_ : {isAbs : Bool} → (URIRef? isAbs false) → String → (URIRef? isAbs true) RURI = URIRef? false false RURIRef = URIRef? false true RURIRef? = URIRef? false AURI = URIRef? true false AURIRef = URIRef? true true AURIRef? = URIRef? true URIRef : Bool → Set URIRef isAbs = URIRef? isAbs true URI : Bool → Set URI isAbs = URIRef? isAbs false _//_ : {isRef : Bool} → Scheme? → String → (URIRef? true isRef) s // h = s // h ∶ ε http://_ : {isRef : Bool} → String → (URIRef? true isRef) http:// h = http: // h xsd: : String → AURIRef xsd:(local) = http://"www.w3.org"/"2001"/"XMLSchema"#(local) rdf: : String → AURIRef rdf:(local) = http://"www.w3.org"/"1999"/"02"/"22-rdf-syntax-ns"#(local) rdfs: : String → AURIRef rdfs:(local) = http://"www.w3.org"/"2000"/"01"/"rdf-schema"#(local) owl: : String → AURIRef owl:(local) = http://"www.w3.org"/"2002"/"07"/"owl"#(local) -- Parsing -- fromURI : {isAbs isRef : Bool} → (URIRef? isAbs false) → (URIRef? isAbs isRef) fromURI {isAbs} {false} u = u fromURI root = root fromURI (s // h ∶ n) = s // h ∶ n fromURI (u / a) = u / a from#Path : {isAbs : Bool} → (URIRef? isAbs false) → (#List String) → (URIRef? isAbs false) from#Path u [] = u from#Path u (a ∷ as) = from#Path (u / a) as from#Fragment : {isAbs isRef : Bool} → (URIRef? isAbs false) → (#Maybe String) → (Maybe (URIRef? isAbs isRef)) from#Fragment {isAbs} {true} u (just f) = just (u # f) from#Fragment {isAbs} {false} u (just f) = nothing from#Fragment {isAbs} {isRef} u nothing = just (fromURI u) from#URI : {isAbs isRef : Bool} → (#Maybe #URI) → (Maybe (URIRef? isAbs isRef)) from#URI {true} (just (#abs s h n p f)) = from#Fragment (from#Path (s // h ∶ n) p) f from#URI {false} (just (#rel p f)) = from#Fragment (from#Path root p) f from#URI _ = nothing fromString : {isAbs isRef : Bool} → String → (Maybe (URIRef? isAbs isRef)) fromString s = from#URI (#fromString s) -- Serializing to#URI' to#URI : {isAbs isRef : Bool} → (URIRef? isAbs isRef) → (#List String) → (#Maybe String) → #URI to#URI root as f? = #rel as f? to#URI (s // h ∶ n) as f? = #abs s h n as f? to#URI (u / a) as f? = to#URI u (a ∷ as) f? to#URI (u # f) as f? = to#URI u as (just f) toString : {isAbs isRef : Bool} → (URIRef? isAbs isRef) → String toString u = #toString (to#URI u [] nothing) -- Composing -- _&_ : {isAbs₁ isAbs₂ isRef : Bool} → (URIRef? isAbs₁ false) → (URIRef? isAbs₂ isRef) → (URIRef? (isAbs₂ ∨ isAbs₁) isRef) u & root = fromURI u u & (s // h ∶ n) = s // h ∶ n u & (v / a) = (u & v) / a u & (v # a) = (u & v) # a
36.918367
120
0.606689
31be1320022b8c0c497e2391167f5d0e5264c62b
2,758
agda
Agda
Structure/Category/Functor.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
6
2020-04-07T17:58:13.000Z
2022-02-05T06:53:22.000Z
Structure/Category/Functor.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
Structure/Category/Functor.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
module Structure.Category.Functor where open import Functional using (_on₂_) open import Lang.Instance import Lvl open import Logic.Predicate open import Structure.Category open import Structure.Function open import Structure.Function.Multi import Structure.Relator.Names as Names open import Structure.Setoid open import Syntax.Function open import Type private variable ℓ ℓₒ ℓₘ ℓₗₒ ℓₗₘ ℓᵣₒ ℓᵣₘ ℓₑ ℓₗₑ ℓᵣₑ : Lvl.Level private variable Obj Objₗ Objᵣ : Type{ℓ} private variable Morphism Morphismₗ Morphismᵣ : Objₗ → Objᵣ → Type{ℓ} module _ ⦃ morphism-equivₗ : ∀{x y : Objₗ} → Equiv{ℓₗₑ}(Morphismₗ x y) ⦄ ⦃ morphism-equivᵣ : ∀{x y : Objᵣ} → Equiv{ℓᵣₑ}(Morphismᵣ x y) ⦄ (Categoryₗ : Category(Morphismₗ)) (Categoryᵣ : Category(Morphismᵣ)) where -- A covariant functor. -- A mapping which transforms objects and morphisms from one category to another while "preserving" the categorical structure. -- A homomorphism between categories. -- In the context of equivalence relations instead of categories, this is the "function"/"congruence" property of the function `F`. record Functor (F : Objₗ → Objᵣ) : Type{Lvl.of(Type.of(Categoryₗ)) Lvl.⊔ Lvl.of(Type.of(Categoryᵣ))} where constructor intro open Category ⦃ … ⦄ open Category.ArrowNotation ⦃ … ⦄ private instance _ = Categoryₗ private instance _ = Categoryᵣ field -- Morphs/Transforms morphisms from the left category to the right category. -- ∀{x y : Objₗ} → (x ⟶ y) → (F(x) ⟶ F(y)) map : Names.Subrelation(_⟶_) ((_⟶_) on₂ F) field ⦃ map-function ⦄ : ∀{x y} → Function(map{x}{y}) ⦃ op-preserving ⦄ : ∀{x y z : Objₗ}{f : y ⟶ z}{g : x ⟶ y} → (map(f ∘ g) ≡ map(f) ∘ map(g)) ⦃ id-preserving ⦄ : ∀{x : Objₗ} → Names.Preserving₀(map{x})(id)(id) --(map(id {x = x}) ≡ id) open import Structure.Categorical.Properties open import Structure.Function.Domain Faithful = ∀{x y} → Injective (map{x}{y}) -- TODO: F also? Not sure Full = ∀{x y} → Surjective(map{x}{y}) FullyFaithful = ∀{x y} → Bijective (map{x}{y}) -- TODO: Conservative = ∀{x y : Objₗ}{f : x ⟶ y} → Morphism.Isomorphism(\{x} → _∘_ {x = x})(\{x} → id{x = x})(map f) → Morphism.Isomorphism(\{x} → _∘_ {x = x})(id)(f) module _ ⦃ morphism-equiv : ∀{x y : Obj} → Equiv{ℓₑ}(Morphism x y) ⦄ (Category : Category(Morphism)) where Endofunctor = Functor(Category)(Category) module Endofunctor = Functor{Categoryₗ = Category}{Categoryᵣ = Category} _→ᶠᵘⁿᶜᵗᵒʳ_ : CategoryObject{ℓₗₒ}{ℓₗₘ}{ℓₗₑ} → CategoryObject{ℓᵣₒ}{ℓᵣₘ}{ℓᵣₑ} → Type catₗ →ᶠᵘⁿᶜᵗᵒʳ catᵣ = ∃(Functor (CategoryObject.category(catₗ)) ((CategoryObject.category(catᵣ)))) ⟲ᶠᵘⁿᶜᵗᵒʳ_ : CategoryObject{ℓₒ}{ℓₘ}{ℓₑ} → Type ⟲ᶠᵘⁿᶜᵗᵒʳ cat = cat →ᶠᵘⁿᶜᵗᵒʳ cat
40.558824
171
0.664249
13d039104419bf020adf0c94637845186e5f5e7a
3,467
agda
Agda
agda-stdlib-0.9/src/Algebra/Properties/Lattice.agda
qwe2/try-agda
9d4c43b1609d3f085636376fdca73093481ab882
[ "Apache-2.0" ]
1
2016-10-20T15:52:05.000Z
2016-10-20T15:52:05.000Z
agda-stdlib-0.9/src/Algebra/Properties/Lattice.agda
qwe2/try-agda
9d4c43b1609d3f085636376fdca73093481ab882
[ "Apache-2.0" ]
null
null
null
agda-stdlib-0.9/src/Algebra/Properties/Lattice.agda
qwe2/try-agda
9d4c43b1609d3f085636376fdca73093481ab882
[ "Apache-2.0" ]
null
null
null
------------------------------------------------------------------------ -- The Agda standard library -- -- Some derivable properties ------------------------------------------------------------------------ open import Algebra module Algebra.Properties.Lattice {l₁ l₂} (L : Lattice l₁ l₂) where open Lattice L open import Algebra.Structures import Algebra.FunctionProperties as P; open P _≈_ open import Relation.Binary import Relation.Binary.EqReasoning as EqR; open EqR setoid open import Function open import Function.Equality using (_⟨$⟩_) open import Function.Equivalence using (_⇔_; module Equivalence) open import Data.Product ∧-idempotent : Idempotent _∧_ ∧-idempotent x = begin x ∧ x ≈⟨ refl ⟨ ∧-cong ⟩ sym (proj₁ absorptive _ _) ⟩ x ∧ (x ∨ x ∧ x) ≈⟨ proj₂ absorptive _ _ ⟩ x ∎ ∨-idempotent : Idempotent _∨_ ∨-idempotent x = begin x ∨ x ≈⟨ refl ⟨ ∨-cong ⟩ sym (∧-idempotent _) ⟩ x ∨ x ∧ x ≈⟨ proj₁ absorptive _ _ ⟩ x ∎ -- The dual construction is also a lattice. ∧-∨-isLattice : IsLattice _≈_ _∧_ _∨_ ∧-∨-isLattice = record { isEquivalence = isEquivalence ; ∨-comm = ∧-comm ; ∨-assoc = ∧-assoc ; ∨-cong = ∧-cong ; ∧-comm = ∨-comm ; ∧-assoc = ∨-assoc ; ∧-cong = ∨-cong ; absorptive = swap absorptive } ∧-∨-lattice : Lattice _ _ ∧-∨-lattice = record { _∧_ = _∨_ ; _∨_ = _∧_ ; isLattice = ∧-∨-isLattice } -- Every lattice can be turned into a poset. poset : Poset _ _ _ poset = record { Carrier = Carrier ; _≈_ = _≈_ ; _≤_ = λ x y → x ≈ x ∧ y ; isPartialOrder = record { isPreorder = record { isEquivalence = isEquivalence ; reflexive = λ {i} {j} i≈j → begin i ≈⟨ sym $ ∧-idempotent _ ⟩ i ∧ i ≈⟨ ∧-cong refl i≈j ⟩ i ∧ j ∎ ; trans = λ {i} {j} {k} i≈i∧j j≈j∧k → begin i ≈⟨ i≈i∧j ⟩ i ∧ j ≈⟨ ∧-cong refl j≈j∧k ⟩ i ∧ (j ∧ k) ≈⟨ sym (∧-assoc _ _ _) ⟩ (i ∧ j) ∧ k ≈⟨ ∧-cong (sym i≈i∧j) refl ⟩ i ∧ k ∎ } ; antisym = λ {x} {y} x≈x∧y y≈y∧x → begin x ≈⟨ x≈x∧y ⟩ x ∧ y ≈⟨ ∧-comm _ _ ⟩ y ∧ x ≈⟨ sym y≈y∧x ⟩ y ∎ } } -- One can replace the underlying equality with an equivalent one. replace-equality : {_≈′_ : Rel Carrier l₂} → (∀ {x y} → x ≈ y ⇔ x ≈′ y) → Lattice _ _ replace-equality {_≈′_} ≈⇔≈′ = record { _≈_ = _≈′_ ; _∧_ = _∧_ ; _∨_ = _∨_ ; isLattice = record { isEquivalence = record { refl = to ⟨$⟩ refl ; sym = λ x≈y → to ⟨$⟩ sym (from ⟨$⟩ x≈y) ; trans = λ x≈y y≈z → to ⟨$⟩ trans (from ⟨$⟩ x≈y) (from ⟨$⟩ y≈z) } ; ∨-comm = λ x y → to ⟨$⟩ ∨-comm x y ; ∨-assoc = λ x y z → to ⟨$⟩ ∨-assoc x y z ; ∨-cong = λ x≈y u≈v → to ⟨$⟩ ∨-cong (from ⟨$⟩ x≈y) (from ⟨$⟩ u≈v) ; ∧-comm = λ x y → to ⟨$⟩ ∧-comm x y ; ∧-assoc = λ x y z → to ⟨$⟩ ∧-assoc x y z ; ∧-cong = λ x≈y u≈v → to ⟨$⟩ ∧-cong (from ⟨$⟩ x≈y) (from ⟨$⟩ u≈v) ; absorptive = (λ x y → to ⟨$⟩ proj₁ absorptive x y) , (λ x y → to ⟨$⟩ proj₂ absorptive x y) } } where open module E {x y} = Equivalence (≈⇔≈′ {x} {y})
32.401869
74
0.440438
418d5c59e9d71912c141b7f7720e4a8dd31d0b99
1,275
agda
Agda
archive/agda-3/src/Test/SurjidentityP.agda
m0davis/oscar
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
[ "RSA-MD" ]
null
null
null
archive/agda-3/src/Test/SurjidentityP.agda
m0davis/oscar
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
[ "RSA-MD" ]
1
2019-04-29T00:35:04.000Z
2019-05-11T23:33:04.000Z
archive/agda-3/src/Test/SurjidentityP.agda
m0davis/oscar
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
[ "RSA-MD" ]
null
null
null
open import Everything module Test.SurjidentityP where module _ {𝔬₁} {𝔒₁ : Ø 𝔬₁} {𝔯₁} (_∼₁_ : 𝔒₁ → 𝔒₁ → Ø 𝔯₁) {𝔬₂} {𝔒₂ : Ø 𝔬₂} {𝔯₂} (_∼₂_ : 𝔒₂ → 𝔒₂ → Ø 𝔯₂) (_∼₂2_ : 𝔒₂ → 𝔒₂ → Ø 𝔯₂) {𝔯₂'} (_∼₂'_ : 𝔒₂ → 𝔒₂ → Ø 𝔯₂') {ℓ₂} (_∼̇₂_ : ∀ {x y} → x ∼₂ y → x ∼₂ y → Ø ℓ₂) (_∼̇₂'_ : ∀ {x y} → x ∼₂' y → x ∼₂' y → Ø ℓ₂) (_∼̇₂2_ : ∀ {x y} → x ∼₂2 y → x ∼₂2 y → Ø ℓ₂) ⦃ _ : Surjection.class 𝔒₁ 𝔒₂ ⦄ ⦃ _ : Smap!.class _∼₁_ _∼₂_ ⦄ ⦃ _ : Smap!.class _∼₁_ _∼₂'_ ⦄ ⦃ _ : Smap!.class _∼₁_ _∼₂2_ ⦄ ⦃ _ : Reflexivity.class _∼₁_ ⦄ ⦃ _ : Reflexivity.class _∼₂_ ⦄ ⦃ _ : Reflexivity.class _∼₂'_ ⦄ ⦃ _ : Reflexivity.class _∼₂2_ ⦄ ⦃ _ : Surjidentity!.class _∼₁_ _∼₂_ _∼̇₂_ ⦄ ⦃ _ : Surjidentity!.class _∼₁_ _∼₂'_ _∼̇₂'_ ⦄ ⦃ _ : Surjidentity!.class _∼₁_ _∼₂2_ _∼̇₂2_ ⦄ where test-surj : Surjidentity!.type _∼₁_ _∼₂_ _∼̇₂_ test-surj = surjidentity test-surj[] : Surjidentity!.type _∼₁_ _∼₂_ _∼̇₂_ test-surj[] = surjidentity[ _∼₁_ , _∼̇₂_ ]
37.5
70
0.402353
c7469f81e3f86aa4e6cda5d3da2cc68b49bbcd9c
15,866
agda
Agda
src/general-util.agda
zmthy/cedille
9df4b85b55b57f97466242fdbb499adbd3bca893
[ "MIT" ]
null
null
null
src/general-util.agda
zmthy/cedille
9df4b85b55b57f97466242fdbb499adbd3bca893
[ "MIT" ]
null
null
null
src/general-util.agda
zmthy/cedille
9df4b85b55b57f97466242fdbb499adbd3bca893
[ "MIT" ]
null
null
null
module general-util where open import instances public get-file-contents : (filename : string) → IO (maybe string) get-file-contents e = doesFileExist e >>= λ b → if b then (readFiniteFile e >>= λ s → return (just s)) else return nothing maybe-else : ∀{ℓ}{A B : Set ℓ} → B → (A → B) → maybe A → B maybe-else y f (just x) = f x maybe-else y f nothing = y maybe-else' : ∀{ℓ}{A B : Set ℓ} → maybe A → B → (A → B) → B maybe-else' m y f = maybe-else y f m maybe-join : ∀ {a} {A : Set a} → maybe (maybe A) → maybe A maybe-join = maybe-else nothing id maybe-equal? : ∀ {a} {A : Set a} → (A → A → 𝔹) → (m₁ m₂ : maybe A) → 𝔹 maybe-equal? f (just x) (just x₁) = f x x₁ maybe-equal? f (just x) nothing = ff maybe-equal? f nothing (just x) = ff maybe-equal? f nothing nothing = tt _maybe-or_ : ∀ {ℓ} {A : Set ℓ} → maybe A → maybe A → maybe A (nothing maybe-or ma) = ma (just a maybe-or ma) = just a maybe-not : ∀ {ℓ} {A : Set ℓ} → maybe A → maybe ⊤ maybe-not (just a) = nothing maybe-not nothing = just triv maybe-if : 𝔹 → maybe ⊤ maybe-if tt = just triv maybe-if ff = nothing when : ∀ {A : Set} → 𝔹 → A → maybe A when b a = maybe-if b >> just a unless : ∀ {A : Set} → 𝔹 → A → maybe A unless b a = maybe-if (~ b) >> just a trie-lookupd : ∀ {A : Set} → trie A → string → A → A trie-lookupd t s d with trie-lookup t s trie-lookupd t s d | nothing = d trie-lookupd t s d | just x = x trie-lookup-else : ∀{A : Set} → A → trie A → string → A trie-lookup-else d t s = trie-lookupd t s d trie-single : ∀{A : Set} → string → A → trie A trie-single s x = trie-insert empty-trie s x trie-any : ∀{A : Set} → (A → 𝔹) → trie A → 𝔹 trie-cal-any : ∀{A : Set} → (A → 𝔹) → cal (trie A) → 𝔹 trie-any f (Node odata ts) = maybe-else (trie-cal-any f ts) f odata trie-cal-any f [] = ff trie-cal-any f ((c , t) :: cs) = trie-any f t || trie-cal-any f cs trie-all : ∀{A : Set} → (A → 𝔹) → trie A → 𝔹 trie-all f = ~_ ∘ trie-any (~_ ∘ f) trie-lookup𝕃 : ∀ {A : Set} → trie (𝕃 A) → string → 𝕃 A trie-lookup𝕃 t s = trie-lookupd t s [] trie-lookup𝕃2 : ∀ {A : Set} → trie (string × 𝕃 A) → string → string × 𝕃 A trie-lookup𝕃2 t s = trie-lookupd t s ("[nomod]" , []) trie-lookup-string : trie string → string → string trie-lookup-string t s = trie-lookupd t s "[not-found]" trie-insert-append : ∀ {A : Set} → trie (𝕃 A) → string → A → trie (𝕃 A) trie-insert-append t s a = trie-insert t s (a :: (trie-lookup𝕃 t s)) trie-insert-append2 : ∀ {A : Set} → trie (string × 𝕃 A) → string → string → A → trie (string × 𝕃 A) trie-insert-append2 t s mn a = trie-insert t s (mn , (a :: snd (trie-lookup𝕃2 t s))) trie-fill : ∀{A : Set} → trie A → 𝕃 (string × A) → trie A trie-fill t ((s , a) :: vs) = trie-fill (trie-insert t s a) vs trie-fill t [] = t trie-empty? : ∀ {A} → trie A → 𝔹 trie-empty? t = ~ trie-nonempty t trie-filter : ∀ {A} → (A → 𝔹) → trie A → trie A cal-filter : ∀ {A} → (A → 𝔹) → cal (trie A) → cal (trie A) trie-filter f (Node odata ts'@(c :: ts)) = Node odata (cal-filter f ts') trie-filter f t@(Node (just x) []) = if f x then t else empty-trie trie-filter f (Node nothing []) = empty-trie cal-filter f [] = [] cal-filter f ((a , t) :: c) with trie-filter f t | cal-filter f c ... | t' | c' = if trie-empty? t then c' else (a , t') :: c' trie-fold : ∀ {F : Set → Set} {A B : Set} → trie A → F B → (string → A → F B → F B) → F B trie-fold t n c = foldr (λ {(k , v) → c k v}) n (trie-mappings t) trie-catMaybe : ∀ {A} → trie (maybe A) → trie A cal-catMaybe : ∀ {A} → cal (trie (maybe A)) → cal (trie A) trie-catMaybe (Node odata ts'@(t :: ts)) = Node (maybe-join odata) (cal-catMaybe ts') trie-catMaybe (Node odata []) = maybe-else empty-trie (λ a → Node (just a) []) (maybe-join odata) cal-catMaybe [] = [] cal-catMaybe ((c , tr) :: trs) with trie-catMaybe tr | cal-catMaybe trs ... | tr' | trs' = if trie-empty? tr' then trs' else (c , tr') :: trs' trie-equal? : ∀ {A : Set} → (A → A → 𝔹) → (t₁ t₂ : trie A) → 𝔹 trie-equal? {A} f t₁ t₂ = length t₁𝕃 =ℕ length t₂𝕃 && list-all check-elems t₁𝕃 where t₁𝕃 = trie-mappings t₁ t₂𝕃 = trie-mappings t₂ check-elems : string × A → 𝔹 check-elems (name , dat₁) with trie-lookup t₂ name ... | nothing = ff ... | just dat₂ = f dat₁ dat₂ string-split-h : 𝕃 char → char → 𝕃 char → 𝕃 string → 𝕃 string string-split-h [] delim str-build out = reverse ((𝕃char-to-string (reverse str-build)) :: out) string-split-h (c :: cs) delim str-build out with (c =char delim) ... | tt = string-split-h cs delim [] ((𝕃char-to-string (reverse str-build)) :: out) ... | ff = string-split-h cs delim (c :: str-build) out string-split : string → char → 𝕃 string string-split str delim = string-split-h (string-to-𝕃char str) delim [] [] undo-escape-string-h : 𝕃 char → 𝕃 char → 𝕃 char undo-escape-string-h ('\\' :: 'n' :: rest) so-far = undo-escape-string-h rest ('\n' :: so-far) undo-escape-string-h ('\\' :: '\"' :: rest) so-far = undo-escape-string-h rest ('\"' :: so-far) undo-escape-string-h (c :: rest) so-far = undo-escape-string-h rest (c :: so-far) undo-escape-string-h [] so-far = reverse so-far undo-escape-string : string → string undo-escape-string str = 𝕃char-to-string (undo-escape-string-h (string-to-𝕃char str) []) is-pfx : (pfx str : string) → maybe string is-pfx pfx str = h (string-to-𝕃char pfx) (string-to-𝕃char str) where h : 𝕃 char → 𝕃 char → maybe string h [] cs = just (𝕃char-to-string cs) h (cₚ :: csₚ) [] = nothing h (cₚ :: csₚ) (cₛ :: csₛ) with cₚ =char cₛ ...| ff = nothing ...| tt = h csₚ csₛ -- functions.agda curry : ∀{ℓ₁ ℓ₂ ℓ₃}{A : Set ℓ₁}{B : Set ℓ₂}{C : Set ℓ₃} → (A × B → C) → A → B → C curry f a b = f (a , b) uncurry : ∀{ℓ₁ ℓ₂ ℓ₃}{A : Set ℓ₁}{B : Set ℓ₂}{C : Set ℓ₃} → (f : A → B → C) → (p : A × B) → C uncurry f (a , b) = f a b uncurry₂ : ∀{a b c d}{A : Set a}{B : Set b}{C : Set c}{D : Set d} → (f : A → B → C → D) → (p : A × B × C) → D uncurry₂ f (a , b , c) = f a b c elim-pair : ∀{ℓ₀ ℓ₁ ℓ₂}{A : Set ℓ₀}{B : Set ℓ₁}{C : Set ℓ₂} → A × B → (A → B → C) → C elim-pair (a , b) f = f a b elim-Σi : ∀ {ℓ₀ ℓ₁ ℓ₂} {A : Set ℓ₀} {B : A → Set ℓ₁} {X : Set ℓ₂} → Σi A B → ({a : A} → B a → X) → X elim-Σi (, b) f = f b elim_for : ∀ {ℓ₀ ℓ₁ ℓ₂} {A : Set ℓ₀} {B : Set ℓ₁} {X : Set ℓ₂} → A × B → (A → B → X) → X elim (a , b) for f = f a b infixr 0 case_ret_of_ case_of_ case_ret_of_ : ∀ {ℓ₁ ℓ₂} {A : Set ℓ₁} (x : A) (B : A → Set ℓ₂) → ((x : A) → B x) → B x case x ret B of f = f x case_of_ : ∀ {a b} {A : Set a} {B : Set b} → A → (A → B) → B case x of f = case_ret_of_ x _ f case₂_,_of_ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} → A → B → (A → B → C) → C case₂ x , y of f = f x y flip : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} → (A → B → C) → (B → A → C) flip f = λ b a → f a b const : ∀ {a b} {A : Set a} {B : Set b} → A → B → A const a b = a infixr 0 _$_ _$_ : ∀ {a b} {A : Set a} {B : Set b} → (A → B) → A → B f $ x = f x -- _∘_ just needs a fixity and association declaration in the IAL infixr 9 _∘'_ _∘'_ : ∀ {a b c} {A : Set a}{B : Set b}{C : Set c} → (B → C) → (A → B) → A → C g ∘' f = λ a → g (f a) -- list.agda take : ∀{ℓ}{A : Set ℓ} → ℕ → 𝕃 A → 𝕃 A take 0 l = [] take (suc n) (x :: l) = x :: (take n l) take (suc n) [] = [] drop : ∀{ℓ}{A : Set ℓ} → ℕ → 𝕃 A → 𝕃 A drop zero xs = xs drop (suc _) [] = [] drop (suc n) (x :: xs) = drop n xs drop-last : ∀{ℓ}{A : Set ℓ} → ℕ → 𝕃 A → 𝕃 A drop-last n xs = take (length xs ∸ n) xs zip-with : ∀{ℓ₁ ℓ₂ ℓ₃}{A : Set ℓ₁}{B : Set ℓ₂}{C : Set ℓ₃} → (A → B → C) → 𝕃 A → 𝕃 B → 𝕃 C zip-with f xs ys = map (uncurry f) (zip xs ys) for_yield_ : ∀ {a b} {A : Set a} {B : Set b} → 𝕃 A → (A → B) → 𝕃 B for xs yield f = map f xs for_accum_use_ : ∀ {a b} {A : Set a} {B : Set b} → 𝕃 A → B → (A → B → B) → B for xs accum n use f = foldr f n xs foldl : ∀{ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'} → (A → B → B) → B → 𝕃 A → B foldl f b [] = b foldl f b (a :: as) = foldl f (f a b) as foldr' : ∀{ℓ ℓ'}{A : Set ℓ}{B : Set ℓ'} → B → (A → B → B) → 𝕃 A → B foldr' = flip foldr -- error.agda err-guard : 𝔹 → string → error-t ⊤ err-guard tt msg = yes-error msg err-guard ff _ = no-error triv -- sum.agda either-else' : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} → A ∨ B → (A → C) → (B → C) → C either-else' (inj₁ x) f g = f x either-else' (inj₂ y) f g = g y either-else : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} → (A → C) → (B → C) → A ∨ B → C either-else f g (inj₁ x) = f x either-else f g (inj₂ y) = g y err⊎-guard : ∀ {e} {E : Set e} → 𝔹 → E → E ∨ ⊤ err⊎-guard tt err = inj₁ err err⊎-guard ff _ = inj₂ triv --infixl 1 _≫⊎_ --_≫⊎_ : ∀ {E B : Set} → E ∨ ⊤ → E ∨ B → E ∨ B --m₁ ≫⊎ m₂ = m₁ ≫=⊎ λ _ → m₂ -- Some file writing functions data IOMode : Set where ReadMode : IOMode WriteMode : IOMode AppendMode : IOMode ReadWriteMode : IOMode filepath = string postulate Handle : Set -- IOMode : Set openFile : filepath → IOMode -> IO Handle closeFile : Handle -> IO ⊤ hPutStr : Handle → string → IO ⊤ hSetToLineBuffering : Handle → IO ⊤ hFlush : Handle → IO ⊤ stdout : Handle doesDirectoryExist : filepath → IO 𝔹 {-# FOREIGN GHC import qualified System.IO #-} {-# FOREIGN GHC import qualified Data.Text.IO #-} {-# FOREIGN GHC import qualified System.Directory #-} {-# COMPILE GHC Handle = type System.IO.Handle #-} {-# COMPILE GHC IOMode = data System.IO.IOMode (System.IO.ReadMode | System.IO.WriteMode | System.IO.AppendMode | System.IO.ReadWriteMode) #-} {-# COMPILE GHC hSetToLineBuffering = \ hdl -> System.IO.hSetBuffering hdl System.IO.LineBuffering #-} {-# COMPILE GHC hFlush = System.IO.hFlush #-} {-# COMPILE GHC stdout = System.IO.stdout #-} {-# COMPILE GHC openFile = \ fp mode -> do outh <- System.IO.openFile (Data.Text.unpack fp) mode; System.IO.hSetNewlineMode outh System.IO.noNewlineTranslation; System.IO.hSetEncoding outh System.IO.utf8; return outh #-} {-# COMPILE GHC closeFile = System.IO.hClose #-} {-# COMPILE GHC hPutStr = Data.Text.IO.hPutStr #-} {-# COMPILE GHC doesDirectoryExist = System.Directory.doesDirectoryExist . Data.Text.unpack #-} clearFile : filepath → IO ⊤ clearFile fp = openFile fp WriteMode >>= λ hdl → hPutStr hdl "" >> closeFile hdl flush : IO ⊤ flush = hFlush stdout setToLineBuffering : IO ⊤ setToLineBuffering = hSetToLineBuffering stdout withFile : {A : Set} → filepath → IOMode → (Handle → IO A) → IO A withFile fp mode f = openFile fp mode >>= λ hdl → f hdl >≯ closeFile hdl -- Coordinated Universal Time infix 15 _utc-after_ _utc-before_ postulate UTC : Set getCurrentTime : IO UTC _utc-after_ : UTC → UTC → 𝔹 _utc-before_ : UTC → UTC → 𝔹 utcToString : UTC → string getModificationTime : filepath → IO UTC getCurrentDirectory : IO filepath pathSeparator : char {-# FOREIGN GHC import qualified Data.Time.Clock #-} {-# FOREIGN GHC import qualified Data.Time.Calendar #-} {-# FOREIGN GHC import qualified System.FilePath #-} {-# COMPILE GHC UTC = type Data.Time.Clock.UTCTime #-} {-# COMPILE GHC getCurrentTime = Data.Time.Clock.getCurrentTime #-} {-# COMPILE GHC _utc-after_ = (>) #-} {-# COMPILE GHC _utc-before_ = (<) #-} {-# COMPILE GHC utcToString = Data.Text.pack . show #-} {-# COMPILE GHC getModificationTime = System.Directory.getModificationTime . Data.Text.unpack #-} {-# COMPILE GHC getCurrentDirectory = System.Directory.getCurrentDirectory >>= return . Data.Text.pack #-} {-# COMPILE GHC pathSeparator = System.FilePath.pathSeparator #-} pathSeparatorString = 𝕃char-to-string [ pathSeparator ] splitPath : filepath → 𝕃 string splitPath = h [] [] ∘ string-to-𝕃char where cons-if-nonempty : 𝕃 char → 𝕃 string → 𝕃 string cons-if-nonempty [] acc = acc cons-if-nonempty cur acc = 𝕃char-to-string (reverse cur) :: acc h : 𝕃 string → 𝕃 char → 𝕃 char → 𝕃 string h acc cur [] = reverse (cons-if-nonempty cur acc) h acc cur (c :: cs) with c =char pathSeparator ...| tt = h (cons-if-nonempty cur acc) [] cs ...| ff = h acc (c :: cur) cs joinPath : 𝕃 string → filepath joinPath [] = "" joinPath (x :: []) = x joinPath (x :: xs) = x ^ pathSeparatorString ^ joinPath xs pathIsAbsolute : filepath → 𝔹 pathIsAbsolute = maybe-else ff (λ c → (c =char '~') || (c =char pathSeparator)) ∘ (head2 ∘ string-to-𝕃char) filepath-replace-tilde : filepath → IO (maybe filepath) filepath-replace-tilde fp with string-to-𝕃char fp ...| '~' :: '/' :: fp-cs = getHomeDirectory >>=r λ home → just (combineFileNames home (𝕃char-to-string fp-cs)) ...| fp-cs = return nothing -- string binary tree, for more efficient I/O printing than concatenation data rope : Set where _⊹⊹_ : rope → rope → rope [[_]] : string → rope infixl 9 _⊹⊹_ infix 9 [[_]] [[]] : rope [[]] = [[ "" ]] rope-to-string : rope → string rope-to-string = flip h "" where h : rope → string → string h (s₁ ⊹⊹ s₂) = h s₁ ∘ h s₂ h [[ s ]] acc = s ^ acc rope-length : rope → ℕ rope-length [[ s ]] = string-length s rope-length (r₁ ⊹⊹ r₂) = rope-length r₁ + rope-length r₂ 𝕃-to-rope : ∀{A : Set} → (A → rope) → string → 𝕃 A → rope 𝕃-to-rope to-rope sep [] = [[]] 𝕃-to-rope to-rope sep (x :: []) = to-rope x 𝕃-to-rope to-rope sep (x :: xs) = to-rope x ⊹⊹ [[ sep ]] ⊹⊹ 𝕃-to-rope to-rope sep xs putStrLn : string → IO ⊤ putStrLn str = putStr str >> putStr "\n" -- >> flush putRope : rope → IO ⊤ -- putRope = putStr ∘ rope-to-string putRope s = h s (return triv) where h : rope → IO ⊤ → IO ⊤ h (s₁ ⊹⊹ s₂) io = h s₁ (h s₂ io) h [[ s ]] io = putStr s >> io putRopeLn : rope → IO ⊤ putRopeLn s = putRope s >> putStr "\n" -- >> flush hPutRope : Handle → rope → IO ⊤ hPutRope outh s = h s (return triv) outh where h : rope → IO ⊤ → Handle → IO ⊤ h (s₁ ⊹⊹ s₂) io outh = h s₁ (h s₂ io outh) outh h [[ s ]] io outh = hPutStr outh s >> io writeRopeToFile : filepath → rope → IO ⊤ writeRopeToFile fp s = clearFile fp >> openFile fp AppendMode >>= λ hdl → hPutRope hdl s >> closeFile hdl stringset-singleton : string → stringset stringset-singleton x = stringset-insert empty-stringset x set-nth : ∀ {ℓ} {X : Set ℓ} → ℕ → X → 𝕃 X → 𝕃 X set-nth n x [] = [] set-nth zero x (x' :: xs) = x :: xs set-nth (suc n) x (x' :: xs) = x' :: set-nth n x xs map-fst : ∀ {ℓ₀ ℓ₁ ℓ₂} {X₀ : Set ℓ₀} {X₁ : Set ℓ₁} {X₂ : Set ℓ₂} → (X₀ → X₂) → (X₀ × X₁) → (X₂ × X₁) map-fst f (x₀ , x₁) = (f x₀ , x₁) map-snd : ∀ {ℓ₀ ℓ₁ ℓ₂} {X₀ : Set ℓ₀} {X₁ : Set ℓ₁} {X₂ : Set ℓ₂} → (X₁ → X₂) → (X₀ × X₁) → (X₀ × X₂) map-snd f (x₀ , x₁) = (x₀ , f x₁) --cons = _::_ --nil = [] --data 𝕃ᵢ (A : ℕ → Set) : ℕ → Set where -- cons : ∀ {n} → A 0 → 𝕃ᵢ A n → 𝕃ᵢ A (suc n) -- nil : 𝕃ᵢ A 0 --pattern _,_ = _::_ --{-# TERMINATING #-} --𝕃ᵢ-nests : Set → ℕ → Set --𝕃ᵢ-nests A 0 = A --𝕃ᵢ-nests A (suc n) = 𝕃ᵢ (𝕃ᵢ-nests A) 1 --cons' : ∀ {A n} → A → 𝕃ᵢ (𝕃ᵢ-nests A) n → 𝕃ᵢ (𝕃ᵢ-nests A) (suc n) --cons' h t = cons h t {- -- Syntactic sugar for Haskell-esque list construction infixr 4 _,,_ infixr 5 [:_ _:] [:_ = id _:] = [_] _,,_ : ∀ {ℓ} {A : Set ℓ} → A → 𝕃 A → 𝕃 A _,,_ = _::_ -} infixr 4 _⌟_ _⌟_ : ∀ {ℓ}{A : Set ℓ}{b : 𝔹} → A → if b then A else 𝕃 A → 𝕃 A _⌟_ {b = tt} a a' = a :: a' :: [] _⌟_ {b = ff} a as = a :: as [:_:] = id 𝕃-sugar-example = [: 0 ⌟ 1 ⌟ 2 ⌟ 3 ⌟ 4 :] {- postulate ord : char → ℕ chr : ℕ → char {-# FOREIGN GHC import qualified Data.Char #-} {-# COMPILE GHC ord = toInteger . Data.Char.ord #-} {-# COMPILE GHC chr = Data.Char.chr . fromIntegral #-} toLower : char → char toLower c = let n = ord c up? = n ≥ 65 {- A -} && n ≤ 90 {- Z -} in chr (if up? then n ∸ 32 else n) toUpper : char → char toUpper c = let n = ord c low? = n ≥ 97 {- A -} && n ≤ 122 {- Z -} in chr (if low? then n + 32 else n) capitalize : string → string capitalize x with string-to-𝕃char x ...| [] = "" ...| c :: cs = 𝕃char-to-string (toUpper c :: cs) uncapitalize : string → string uncapitalize x with string-to-𝕃char x ...| [] = "" ...| c :: cs = 𝕃char-to-string (toLower c :: cs) -}
31.795591
220
0.574751
4b7e6d83aa4fdd4d293c632cc9e1b10db2600ae4
2,277
agda
Agda
Cubical/HITs/Pushout/Base.agda
L-TChen/cubical
60226aacd7b386aef95d43a0c29c4eec996348a8
[ "MIT" ]
null
null
null
Cubical/HITs/Pushout/Base.agda
L-TChen/cubical
60226aacd7b386aef95d43a0c29c4eec996348a8
[ "MIT" ]
null
null
null
Cubical/HITs/Pushout/Base.agda
L-TChen/cubical
60226aacd7b386aef95d43a0c29c4eec996348a8
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.Pushout.Base where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Data.Unit open import Cubical.HITs.Susp.Base data Pushout {ℓ ℓ' ℓ''} {A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''} (f : A → B) (g : A → C) : Type (ℓ-max ℓ (ℓ-max ℓ' ℓ'')) where inl : B → Pushout f g inr : C → Pushout f g push : (a : A) → inl (f a) ≡ inr (g a) -- cofiber (equivalent to Cone in Cubical.HITs.MappingCones.Base) cofib : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (f : A → B) → Type _ cofib f = Pushout (λ _ → tt) f cfcod : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (f : A → B) → B → cofib f cfcod f = inr -- Suspension defined as a pushout PushoutSusp : ∀ {ℓ} (A : Type ℓ) → Type ℓ PushoutSusp A = Pushout {A = A} {B = Unit} {C = Unit} (λ _ → tt) (λ _ → tt) PushoutSusp→Susp : ∀ {ℓ} {A : Type ℓ} → PushoutSusp A → Susp A PushoutSusp→Susp (inl _) = north PushoutSusp→Susp (inr _) = south PushoutSusp→Susp (push a i) = merid a i Susp→PushoutSusp : ∀ {ℓ} {A : Type ℓ} → Susp A → PushoutSusp A Susp→PushoutSusp north = inl tt Susp→PushoutSusp south = inr tt Susp→PushoutSusp (merid a i) = push a i Susp→PushoutSusp→Susp : ∀ {ℓ} {A : Type ℓ} (x : Susp A) → PushoutSusp→Susp (Susp→PushoutSusp x) ≡ x Susp→PushoutSusp→Susp north = refl Susp→PushoutSusp→Susp south = refl Susp→PushoutSusp→Susp (merid _ _) = refl PushoutSusp→Susp→PushoutSusp : ∀ {ℓ} {A : Type ℓ} (x : PushoutSusp A) → Susp→PushoutSusp (PushoutSusp→Susp x) ≡ x PushoutSusp→Susp→PushoutSusp (inl _) = refl PushoutSusp→Susp→PushoutSusp (inr _) = refl PushoutSusp→Susp→PushoutSusp (push _ _) = refl PushoutSuspIsoSusp : ∀ {ℓ} {A : Type ℓ} → Iso (PushoutSusp A) (Susp A) Iso.fun PushoutSuspIsoSusp = PushoutSusp→Susp Iso.inv PushoutSuspIsoSusp = Susp→PushoutSusp Iso.rightInv PushoutSuspIsoSusp = Susp→PushoutSusp→Susp Iso.leftInv PushoutSuspIsoSusp = PushoutSusp→Susp→PushoutSusp PushoutSusp≃Susp : ∀ {ℓ} {A : Type ℓ} → PushoutSusp A ≃ Susp A PushoutSusp≃Susp = isoToEquiv PushoutSuspIsoSusp PushoutSusp≡Susp : ∀ {ℓ} {A : Type ℓ} → PushoutSusp A ≡ Susp A PushoutSusp≡Susp = isoToPath PushoutSuspIsoSusp
35.578125
75
0.659201
9a00d37e0ca1cc124c364611beda5ae7d9f82a72
12,466
agda
Agda
src/data/lib/prim/Agda/Builtin/Reflection.agda
AntoineAllioux/agda
68ec2312961776e415c99d2839e41a92ffe464db
[ "BSD-3-Clause" ]
null
null
null
src/data/lib/prim/Agda/Builtin/Reflection.agda
AntoineAllioux/agda
68ec2312961776e415c99d2839e41a92ffe464db
[ "BSD-3-Clause" ]
null
null
null
src/data/lib/prim/Agda/Builtin/Reflection.agda
AntoineAllioux/agda
68ec2312961776e415c99d2839e41a92ffe464db
[ "BSD-3-Clause" ]
null
null
null
{-# OPTIONS --without-K --safe --no-sized-types --no-guardedness --no-subtyping #-} module Agda.Builtin.Reflection where open import Agda.Builtin.Unit open import Agda.Builtin.Bool open import Agda.Builtin.Nat open import Agda.Builtin.Word open import Agda.Builtin.List open import Agda.Builtin.String open import Agda.Builtin.Char open import Agda.Builtin.Float open import Agda.Builtin.Int open import Agda.Builtin.Sigma open import Agda.Primitive -- Names -- postulate Name : Set {-# BUILTIN QNAME Name #-} primitive primQNameEquality : Name → Name → Bool primQNameLess : Name → Name → Bool primShowQName : Name → String -- Fixity -- data Associativity : Set where left-assoc : Associativity right-assoc : Associativity non-assoc : Associativity data Precedence : Set where related : Float → Precedence unrelated : Precedence data Fixity : Set where fixity : Associativity → Precedence → Fixity {-# BUILTIN ASSOC Associativity #-} {-# BUILTIN ASSOCLEFT left-assoc #-} {-# BUILTIN ASSOCRIGHT right-assoc #-} {-# BUILTIN ASSOCNON non-assoc #-} {-# BUILTIN PRECEDENCE Precedence #-} {-# BUILTIN PRECRELATED related #-} {-# BUILTIN PRECUNRELATED unrelated #-} {-# BUILTIN FIXITY Fixity #-} {-# BUILTIN FIXITYFIXITY fixity #-} {-# COMPILE GHC Associativity = data MAlonzo.RTE.Assoc (MAlonzo.RTE.LeftAssoc | MAlonzo.RTE.RightAssoc | MAlonzo.RTE.NonAssoc) #-} {-# COMPILE GHC Precedence = data MAlonzo.RTE.Precedence (MAlonzo.RTE.Related | MAlonzo.RTE.Unrelated) #-} {-# COMPILE GHC Fixity = data MAlonzo.RTE.Fixity (MAlonzo.RTE.Fixity) #-} {-# COMPILE JS Associativity = function (x,v) { return v[x](); } #-} {-# COMPILE JS left-assoc = "left-assoc" #-} {-# COMPILE JS right-assoc = "right-assoc" #-} {-# COMPILE JS non-assoc = "non-assoc" #-} {-# COMPILE JS Precedence = function (x,v) { if (x === "unrelated") { return v[x](); } else { return v["related"](x); }} #-} {-# COMPILE JS related = function(x) { return x; } #-} {-# COMPILE JS unrelated = "unrelated" #-} {-# COMPILE JS Fixity = function (x,v) { return v["fixity"](x["assoc"], x["prec"]); } #-} {-# COMPILE JS fixity = function (x) { return function (y) { return { "assoc": x, "prec": y}; }; } #-} primitive primQNameFixity : Name → Fixity primQNameToWord64s : Name → Σ Word64 (λ _ → Word64) -- Metavariables -- postulate Meta : Set {-# BUILTIN AGDAMETA Meta #-} primitive primMetaEquality : Meta → Meta → Bool primMetaLess : Meta → Meta → Bool primShowMeta : Meta → String primMetaToNat : Meta → Nat -- Arguments -- -- Arguments can be (visible), {hidden}, or {{instance}}. data Visibility : Set where visible hidden instance′ : Visibility {-# BUILTIN HIDING Visibility #-} {-# BUILTIN VISIBLE visible #-} {-# BUILTIN HIDDEN hidden #-} {-# BUILTIN INSTANCE instance′ #-} -- Arguments can be relevant or irrelevant. data Relevance : Set where relevant irrelevant : Relevance {-# BUILTIN RELEVANCE Relevance #-} {-# BUILTIN RELEVANT relevant #-} {-# BUILTIN IRRELEVANT irrelevant #-} data ArgInfo : Set where arg-info : (v : Visibility) (r : Relevance) → ArgInfo data Arg {a} (A : Set a) : Set a where arg : (i : ArgInfo) (x : A) → Arg A {-# BUILTIN ARGINFO ArgInfo #-} {-# BUILTIN ARGARGINFO arg-info #-} {-# BUILTIN ARG Arg #-} {-# BUILTIN ARGARG arg #-} -- Name abstraction -- data Abs {a} (A : Set a) : Set a where abs : (s : String) (x : A) → Abs A {-# BUILTIN ABS Abs #-} {-# BUILTIN ABSABS abs #-} -- Literals -- data Literal : Set where nat : (n : Nat) → Literal word64 : (n : Word64) → Literal float : (x : Float) → Literal char : (c : Char) → Literal string : (s : String) → Literal name : (x : Name) → Literal meta : (x : Meta) → Literal {-# BUILTIN AGDALITERAL Literal #-} {-# BUILTIN AGDALITNAT nat #-} {-# BUILTIN AGDALITWORD64 word64 #-} {-# BUILTIN AGDALITFLOAT float #-} {-# BUILTIN AGDALITCHAR char #-} {-# BUILTIN AGDALITSTRING string #-} {-# BUILTIN AGDALITQNAME name #-} {-# BUILTIN AGDALITMETA meta #-} -- Terms and patterns -- data Term : Set data Sort : Set data Pattern : Set data Clause : Set Type = Term data Term where var : (x : Nat) (args : List (Arg Term)) → Term con : (c : Name) (args : List (Arg Term)) → Term def : (f : Name) (args : List (Arg Term)) → Term lam : (v : Visibility) (t : Abs Term) → Term pat-lam : (cs : List Clause) (args : List (Arg Term)) → Term pi : (a : Arg Type) (b : Abs Type) → Term agda-sort : (s : Sort) → Term lit : (l : Literal) → Term meta : (x : Meta) → List (Arg Term) → Term unknown : Term data Sort where set : (t : Term) → Sort lit : (n : Nat) → Sort unknown : Sort data Pattern where con : (c : Name) (ps : List (Arg Pattern)) → Pattern dot : (t : Term) → Pattern var : (x : Nat) → Pattern lit : (l : Literal) → Pattern proj : (f : Name) → Pattern absurd : (x : Nat) → Pattern -- absurd patterns counts as variables data Clause where clause : (tel : List (Σ String λ _ → Arg Type)) (ps : List (Arg Pattern)) (t : Term) → Clause absurd-clause : (tel : List (Σ String λ _ → Arg Type)) (ps : List (Arg Pattern)) → Clause {-# BUILTIN AGDATERM Term #-} {-# BUILTIN AGDASORT Sort #-} {-# BUILTIN AGDAPATTERN Pattern #-} {-# BUILTIN AGDACLAUSE Clause #-} {-# BUILTIN AGDATERMVAR var #-} {-# BUILTIN AGDATERMCON con #-} {-# BUILTIN AGDATERMDEF def #-} {-# BUILTIN AGDATERMMETA meta #-} {-# BUILTIN AGDATERMLAM lam #-} {-# BUILTIN AGDATERMEXTLAM pat-lam #-} {-# BUILTIN AGDATERMPI pi #-} {-# BUILTIN AGDATERMSORT agda-sort #-} {-# BUILTIN AGDATERMLIT lit #-} {-# BUILTIN AGDATERMUNSUPPORTED unknown #-} {-# BUILTIN AGDASORTSET set #-} {-# BUILTIN AGDASORTLIT lit #-} {-# BUILTIN AGDASORTUNSUPPORTED unknown #-} {-# BUILTIN AGDAPATCON con #-} {-# BUILTIN AGDAPATDOT dot #-} {-# BUILTIN AGDAPATVAR var #-} {-# BUILTIN AGDAPATLIT lit #-} {-# BUILTIN AGDAPATPROJ proj #-} {-# BUILTIN AGDAPATABSURD absurd #-} {-# BUILTIN AGDACLAUSECLAUSE clause #-} {-# BUILTIN AGDACLAUSEABSURD absurd-clause #-} -- Definitions -- data Definition : Set where function : (cs : List Clause) → Definition data-type : (pars : Nat) (cs : List Name) → Definition record-type : (c : Name) (fs : List (Arg Name)) → Definition data-cons : (d : Name) → Definition axiom : Definition prim-fun : Definition {-# BUILTIN AGDADEFINITION Definition #-} {-# BUILTIN AGDADEFINITIONFUNDEF function #-} {-# BUILTIN AGDADEFINITIONDATADEF data-type #-} {-# BUILTIN AGDADEFINITIONRECORDDEF record-type #-} {-# BUILTIN AGDADEFINITIONDATACONSTRUCTOR data-cons #-} {-# BUILTIN AGDADEFINITIONPOSTULATE axiom #-} {-# BUILTIN AGDADEFINITIONPRIMITIVE prim-fun #-} -- Errors -- data ErrorPart : Set where strErr : String → ErrorPart termErr : Term → ErrorPart nameErr : Name → ErrorPart {-# BUILTIN AGDAERRORPART ErrorPart #-} {-# BUILTIN AGDAERRORPARTSTRING strErr #-} {-# BUILTIN AGDAERRORPARTTERM termErr #-} {-# BUILTIN AGDAERRORPARTNAME nameErr #-} -- TC monad -- postulate TC : ∀ {a} → Set a → Set a returnTC : ∀ {a} {A : Set a} → A → TC A bindTC : ∀ {a b} {A : Set a} {B : Set b} → TC A → (A → TC B) → TC B unify : Term → Term → TC ⊤ typeError : ∀ {a} {A : Set a} → List ErrorPart → TC A inferType : Term → TC Type checkType : Term → Type → TC Term normalise : Term → TC Term reduce : Term → TC Term catchTC : ∀ {a} {A : Set a} → TC A → TC A → TC A quoteTC : ∀ {a} {A : Set a} → A → TC Term unquoteTC : ∀ {a} {A : Set a} → Term → TC A quoteωTC : ∀ {A : Setω} → A → TC Term getContext : TC (List (Arg Type)) extendContext : ∀ {a} {A : Set a} → Arg Type → TC A → TC A inContext : ∀ {a} {A : Set a} → List (Arg Type) → TC A → TC A freshName : String → TC Name declareDef : Arg Name → Type → TC ⊤ declarePostulate : Arg Name → Type → TC ⊤ defineFun : Name → List Clause → TC ⊤ getType : Name → TC Type getDefinition : Name → TC Definition blockOnMeta : ∀ {a} {A : Set a} → Meta → TC A commitTC : TC ⊤ isMacro : Name → TC Bool -- If the argument is 'true' makes the following primitives also normalise -- their results: inferType, checkType, quoteTC, getType, and getContext withNormalisation : ∀ {a} {A : Set a} → Bool → TC A → TC A -- Makes the following primitives to reconstruct hidden arguments -- getDefinition, normalise, reduce, inferType, checkType and getContext withReconstructed : ∀ {a} {A : Set a} → TC A → TC A -- Prints the third argument if the corresponding verbosity level is turned -- on (with the -v flag to Agda). debugPrint : String → Nat → List ErrorPart → TC ⊤ -- Only allow reduction of specific definitions while executing the TC computation onlyReduceDefs : ∀ {a} {A : Set a} → List Name → TC A → TC A -- Don't allow reduction of specific definitions while executing the TC computation dontReduceDefs : ∀ {a} {A : Set a} → List Name → TC A → TC A -- Fail if the given computation gives rise to new, unsolved -- "blocking" constraints. noConstraints : ∀ {a} {A : Set a} → TC A → TC A -- Run the given TC action and return the first component. Resets to -- the old TC state if the second component is 'false', or keep the -- new TC state if it is 'true'. runSpeculative : ∀ {a} {A : Set a} → TC (Σ A λ _ → Bool) → TC A {-# BUILTIN AGDATCM TC #-} {-# BUILTIN AGDATCMRETURN returnTC #-} {-# BUILTIN AGDATCMBIND bindTC #-} {-# BUILTIN AGDATCMUNIFY unify #-} {-# BUILTIN AGDATCMTYPEERROR typeError #-} {-# BUILTIN AGDATCMINFERTYPE inferType #-} {-# BUILTIN AGDATCMCHECKTYPE checkType #-} {-# BUILTIN AGDATCMNORMALISE normalise #-} {-# BUILTIN AGDATCMREDUCE reduce #-} {-# BUILTIN AGDATCMCATCHERROR catchTC #-} {-# BUILTIN AGDATCMQUOTETERM quoteTC #-} {-# BUILTIN AGDATCMUNQUOTETERM unquoteTC #-} {-# BUILTIN AGDATCMQUOTEOMEGATERM quoteωTC #-} {-# BUILTIN AGDATCMGETCONTEXT getContext #-} {-# BUILTIN AGDATCMEXTENDCONTEXT extendContext #-} {-# BUILTIN AGDATCMINCONTEXT inContext #-} {-# BUILTIN AGDATCMFRESHNAME freshName #-} {-# BUILTIN AGDATCMDECLAREDEF declareDef #-} {-# BUILTIN AGDATCMDECLAREPOSTULATE declarePostulate #-} {-# BUILTIN AGDATCMDEFINEFUN defineFun #-} {-# BUILTIN AGDATCMGETTYPE getType #-} {-# BUILTIN AGDATCMGETDEFINITION getDefinition #-} {-# BUILTIN AGDATCMBLOCKONMETA blockOnMeta #-} {-# BUILTIN AGDATCMCOMMIT commitTC #-} {-# BUILTIN AGDATCMISMACRO isMacro #-} {-# BUILTIN AGDATCMWITHNORMALISATION withNormalisation #-} {-# BUILTIN AGDATCMDEBUGPRINT debugPrint #-} {-# BUILTIN AGDATCMONLYREDUCEDEFS onlyReduceDefs #-} {-# BUILTIN AGDATCMDONTREDUCEDEFS dontReduceDefs #-} {-# BUILTIN AGDATCMWITHRECONSPARAMS withReconstructed #-} {-# BUILTIN AGDATCMNOCONSTRAINTS noConstraints #-} {-# BUILTIN AGDATCMRUNSPECULATIVE runSpeculative #-}
37.661631
130
0.5661
3da926bccdd5fa6bde402ced10159bffa504d189
6,764
agda
Agda
Structure/Operator/Proofs/Util.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
6
2020-04-07T17:58:13.000Z
2022-02-05T06:53:22.000Z
Structure/Operator/Proofs/Util.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
Structure/Operator/Proofs/Util.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
module Structure.Operator.Proofs.Util where import Lvl open import Data open import Data.Tuple open import Functional hiding (id) open import Function.Equals import Function.Names as Names import Lang.Vars.Structure.Operator open Lang.Vars.Structure.Operator.Select open import Logic.IntroInstances open import Logic.Predicate open import Structure.Setoid open import Structure.Function.Domain import Structure.Operator.Names as Names open import Structure.Operator.Properties open import Structure.Operator open import Structure.Relator.Properties open import Syntax.Transitivity open import Type module One {ℓ ℓₑ} {T : Type{ℓ}} ⦃ equiv : Equiv{ℓₑ}(T) ⦄ {_▫_ : T → T → T} where open Lang.Vars.Structure.Operator.One ⦃ equiv = equiv ⦄ {_▫_ = _▫_} -- TODO: Rename this to associate-commute4-commuting associate-commute4 : let _ = op , assoc in ∀{a b c d} → Names.Commuting(_▫_)(b)(c) → ((a ▫ b) ▫ (c ▫ d) ≡ (a ▫ c) ▫ (b ▫ d)) associate-commute4 {a}{b}{c}{d} com = (a ▫ b) ▫ (c ▫ d) 🝖-[ symmetry(_≡_) (associativity(_▫_) {a ▫ b} {c} {d}) ] ((a ▫ b) ▫ c) ▫ d 🝖-[ congruence₂ₗ(_▫_)(d) (associativity(_▫_) {a} {b} {c}) ] (a ▫ (b ▫ c)) ▫ d 🝖-[ (congruence₂ₗ(_▫_)(d) ∘ congruence₂ᵣ(_▫_)(a)) com ] (a ▫ (c ▫ b)) ▫ d 🝖-[ associativity(_▫_) {a} {c ▫ b} {d} ] a ▫ ((c ▫ b) ▫ d) 🝖-[ congruence₂ᵣ(_▫_)(a) (associativity(_▫_) {c} {b} {d}) ] a ▫ (c ▫ (b ▫ d)) 🝖-[ symmetry(_≡_) (associativity(_▫_) {a} {c} {b ▫ d}) ] (a ▫ c) ▫ (b ▫ d) 🝖-end -- TODO: Rename this to associate-commute4 associate-commute4-c : let _ = op , assoc , comm in ∀{a b c d} → ((a ▫ b) ▫ (c ▫ d) ≡ (a ▫ c) ▫ (b ▫ d)) associate-commute4-c = associate-commute4(commutativity(_▫_)) associate4-123-321 : let _ = op , assoc in ∀{a b c d} → (((a ▫ b) ▫ c) ▫ d ≡ a ▫ (b ▫ (c ▫ d))) associate4-123-321 {a}{b}{c}{d} = associativity(_▫_) 🝖 associativity(_▫_) associate4-123-213 : let _ = op , assoc in ∀{a b c d} → (((a ▫ b) ▫ c) ▫ d ≡ (a ▫ (b ▫ c)) ▫ d) associate4-123-213 {a}{b}{c}{d} = congruence₂ₗ(_▫_)(_) (associativity(_▫_)) associate4-321-231 : let _ = op , assoc in ∀{a b c d} → (a ▫ (b ▫ (c ▫ d)) ≡ a ▫ ((b ▫ c) ▫ d)) associate4-321-231 {a}{b}{c}{d} = congruence₂ᵣ(_▫_)(_) (symmetry(_≡_) (associativity(_▫_))) associate4-231-222 : let _ = op , assoc in ∀{a b c d} → (a ▫ ((b ▫ c) ▫ d) ≡ (a ▫ b) ▫ (c ▫ d)) associate4-231-222 {a}{b}{c}{d} = symmetry(_≡_) associate4-321-231 🝖 symmetry(_≡_) associate4-123-321 🝖 associativity(_▫_) associate4-213-222 : let _ = op , assoc in ∀{a b c d} → ((a ▫ (b ▫ c)) ▫ d ≡ (a ▫ b) ▫ (c ▫ d)) associate4-213-222 {a}{b}{c}{d} = associativity(_▫_) 🝖 associate4-231-222 commuteᵣ-assocₗ : let _ = op , assoc , comm in ∀{a b c} → (((a ▫ b) ▫ c) ≡ ((a ▫ c) ▫ b)) commuteᵣ-assocₗ {a}{b}{c} = (a ▫ b) ▫ c 🝖-[ associativity(_▫_) ] a ▫ (b ▫ c) 🝖-[ congruence₂ᵣ(_▫_)(_) (commutativity(_▫_)) ] a ▫ (c ▫ b) 🝖-[ associativity(_▫_) ]-sym (a ▫ c) ▫ b 🝖-end commuteₗ-assocᵣ : let _ = op , assoc , comm in ∀{a b c} → ((a ▫ (b ▫ c)) ≡ (b ▫ (a ▫ c))) commuteₗ-assocᵣ {a}{b}{c} = a ▫ (b ▫ c) 🝖-[ associativity(_▫_) ]-sym (a ▫ b) ▫ c 🝖-[ congruence₂ₗ(_▫_)(_) (commutativity(_▫_)) ] (b ▫ a) ▫ c 🝖-[ associativity(_▫_) ] b ▫ (a ▫ c) 🝖-end commuteᵣ-assocᵣ : let _ = op , assoc , comm in ∀{a b c} → ((a ▫ (b ▫ c)) ≡ ((a ▫ c) ▫ b)) commuteᵣ-assocᵣ = symmetry(_≡_) (associativity(_▫_)) 🝖 commuteᵣ-assocₗ -- TODO: Rename and generalize this (See commuteBoth in Structure.Operator.Properties) commuteBothTemp : let _ = comm in ∀{a₁ a₂ b₁ b₂} → (a₁ ▫ a₂ ≡ b₁ ▫ b₂) → (a₂ ▫ a₁ ≡ b₂ ▫ b₁) commuteBothTemp {a₁} {a₂} {b₁} {b₂} p = a₂ ▫ a₁ 🝖-[ commutativity(_▫_) ]-sym a₁ ▫ a₂ 🝖-[ p ] b₁ ▫ b₂ 🝖-[ commutativity(_▫_) ] b₂ ▫ b₁ 🝖-end moveₗ-to-inv : let _ = op , assoc , select-invₗ(idₗ)(identₗ)(invₗ)(inverₗ) in ∀{a b c} → (a ▫ b ≡ c) → (b ≡ invₗ(a) ▫ c) moveₗ-to-inv {idₗ = idₗ} {invₗ = invₗ} {a = a} {b} {c} abc = b 🝖-[ identityₗ(_▫_)(idₗ) ]-sym idₗ ▫ b 🝖-[ congruence₂ₗ(_▫_)(b) (inverseFunctionₗ(_▫_)(invₗ)) ]-sym (invₗ a ▫ a) ▫ b 🝖-[ associativity(_▫_) ] invₗ a ▫ (a ▫ b) 🝖-[ congruence₂ᵣ(_▫_)(invₗ a) abc ] invₗ a ▫ c 🝖-end moveᵣ-to-inv : let _ = op , assoc , select-invᵣ(idᵣ)(identᵣ)(invᵣ)(inverᵣ) in ∀{a b c} → (a ▫ b ≡ c) → (a ≡ c ▫ invᵣ(b)) moveᵣ-to-inv {idᵣ = idᵣ} {invᵣ = invᵣ} {a = a} {b} {c} abc = a 🝖-[ identityᵣ(_▫_)(idᵣ) ]-sym a ▫ idᵣ 🝖-[ congruence₂ᵣ(_▫_)(a) (inverseFunctionᵣ(_▫_)(invᵣ)) ]-sym a ▫ (b ▫ invᵣ b) 🝖-[ associativity(_▫_) ]-sym (a ▫ b) ▫ invᵣ b 🝖-[ congruence₂ₗ(_▫_)(invᵣ b) abc ] c ▫ invᵣ b 🝖-end moveₗ-from-inv : let _ = op , assoc , select-idₗ(id)(identₗ) , select-invᵣ(id)(identᵣ)(invᵣ)(inverᵣ) in ∀{a b c} → (a ▫ b ≡ c) ← (b ≡ invᵣ(a) ▫ c) moveₗ-from-inv {id = id} {invᵣ = invᵣ} {a = a} {b} {c} bac = a ▫ b 🝖-[ congruence₂ᵣ(_▫_)(a) bac ] a ▫ (invᵣ a ▫ c) 🝖-[ associativity(_▫_) ]-sym (a ▫ invᵣ a) ▫ c 🝖-[ congruence₂ₗ(_▫_)(c) (inverseFunctionᵣ(_▫_)(invᵣ)) ] id ▫ c 🝖-[ identityₗ(_▫_)(id) ] c 🝖-end moveᵣ-from-inv : let _ = op , assoc , select-idᵣ(id)(identᵣ) , select-invₗ(id)(identₗ)(invₗ)(inverₗ) in ∀{a b c} → (a ▫ b ≡ c) ← (a ≡ c ▫ invₗ(b)) moveᵣ-from-inv {id = id} {invₗ = invₗ} {a = a} {b} {c} acb = a ▫ b 🝖-[ congruence₂ₗ(_▫_)(b) acb ] (c ▫ invₗ b) ▫ b 🝖-[ associativity(_▫_) ] c ▫ (invₗ b ▫ b) 🝖-[ congruence₂ᵣ(_▫_)(c) (inverseFunctionₗ(_▫_)(invₗ)) ] c ▫ id 🝖-[ identityᵣ(_▫_)(id) ] c 🝖-end module OneTypeTwoOp {ℓ ℓₑ} {T : Type{ℓ}} ⦃ equiv : Equiv{ℓₑ}(T) ⦄ {_▫₁_ _▫₂_ : T → T → T} where open Lang.Vars.Structure.Operator.OneTypeTwoOp ⦃ equiv = equiv ⦄ {_▫₁_ = _▫₁_} {_▫₂_ = _▫₂_} cross-distribute : let _ = op₂ , distriₗ , distriᵣ in ∀{a b c d} → (a ▫₂ b) ▫₁ (c ▫₂ d) ≡ ((a ▫₁ c) ▫₂ (b ▫₁ c)) ▫₂ ((a ▫₁ d) ▫₂ (b ▫₁ d)) cross-distribute {a = a}{b}{c}{d} = (a ▫₂ b) ▫₁ (c ▫₂ d) 🝖-[ distributivityₗ(_▫₁_)(_▫₂_) ] ((a ▫₂ b) ▫₁ c) ▫₂ ((a ▫₂ b) ▫₁ d) 🝖-[ congruence₂(_▫₂_) (distributivityᵣ(_▫₁_)(_▫₂_)) (distributivityᵣ(_▫₁_)(_▫₂_)) ] ((a ▫₁ c) ▫₂ (b ▫₁ c)) ▫₂ ((a ▫₁ d) ▫₂ (b ▫₁ d)) 🝖-end moveₗ-to-invOp : let _ = op₂ , inverOpₗ in ∀{a b c} → (a ▫₁ b ≡ c) → (b ≡ a ▫₂ c) moveₗ-to-invOp {a = a} {b} {c} abc = b 🝖[ _≡_ ]-[ inverseOperₗ(_▫₁_)(_▫₂_) ]-sym a ▫₂ (a ▫₁ b) 🝖[ _≡_ ]-[ congruence₂ᵣ(_▫₂_)(a) abc ] a ▫₂ c 🝖-end moveᵣ-to-invOp : let _ = op₂ , inverOpᵣ in ∀{a b c} → (a ▫₁ b ≡ c) → (a ≡ c ▫₂ b) moveᵣ-to-invOp {a = a} {b} {c} abc = a 🝖[ _≡_ ]-[ inverseOperᵣ(_▫₁_)(_▫₂_) ]-sym (a ▫₁ b) ▫₂ b 🝖[ _≡_ ]-[ congruence₂ₗ(_▫₂_)(b) abc ] c ▫₂ b 🝖-end
51.242424
148
0.524837
9aaa364f784d33abfae3f2fd8fc3eeede3ddc349
913
agda
Agda
Cubical/Relation/Binary/Base.agda
limemloh/cubical
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
[ "MIT" ]
1
2020-03-23T23:52:11.000Z
2020-03-23T23:52:11.000Z
Cubical/Relation/Binary/Base.agda
limemloh/cubical
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
[ "MIT" ]
null
null
null
Cubical/Relation/Binary/Base.agda
limemloh/cubical
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --safe #-} module Cubical.Relation.Binary.Base where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.HITs.SetQuotients.Base module BinaryRelation {ℓ ℓ' : Level} {A : Type ℓ} (R : A → A → Type ℓ') where isRefl : Type (ℓ-max ℓ ℓ') isRefl = (a : A) → R a a isSym : Type (ℓ-max ℓ ℓ') isSym = (a b : A) → R a b → R b a isTrans : Type (ℓ-max ℓ ℓ') isTrans = (a b c : A) → R a b → R b c → R a c record isEquivRel : Type (ℓ-max ℓ ℓ') where constructor EquivRel field reflexive : isRefl symmetric : isSym transitive : isTrans isPropValued : Type (ℓ-max ℓ ℓ') isPropValued = (a b : A) → isProp (R a b) isEffective : Type (ℓ-max ℓ ℓ') isEffective = (a b : A) → let x : A / R x = [ a ] y : A / R y = [ b ] in (x ≡ y) ≃ R a b
24.026316
77
0.58379
13624c09ce2f7c423de248749c6c016075f3c7a8
13,709
agda
Agda
04-cubical-type-theory/material/Part1.agda
williamdemeo/EPIT-2020
19d72759e18e05d2c509f62d23a998573270140c
[ "MIT" ]
null
null
null
04-cubical-type-theory/material/Part1.agda
williamdemeo/EPIT-2020
19d72759e18e05d2c509f62d23a998573270140c
[ "MIT" ]
null
null
null
04-cubical-type-theory/material/Part1.agda
williamdemeo/EPIT-2020
19d72759e18e05d2c509f62d23a998573270140c
[ "MIT" ]
1
2021-08-02T16:16:34.000Z
2021-08-02T16:16:34.000Z
{- Part 1: The interval and path types • The interval in Cubical Agda • Path and PathP types • Function extensionality • Equality in Σ-types -} -- To make Agda cubical add the following option {-# OPTIONS --cubical #-} module Part1 where open import Cubical.Core.Primitives public -- To load an Agda file type "C-c C-l" in emacs (the notation "C-c" -- means that one should hold "CTRL" and press "c", for general -- documentation about emacs keybindings see: -- https://www.gnu.org/software/emacs/manual/html_node/efaq/Basic-keys.html) -- The "Core" package of the agda/cubical library sets things for us open import Cubical.Core.Primitives public -- The "Foundations" package of agda/cubical contains a lot of -- important results (in particular the univalence theorem). As we -- will develop many things from scratch we don't import it here, but -- a typical file in the library would import various files from -- Foundations. To get everything in Foundations write: -- -- open import Cubical.Foundations.Everything -- To search for something among the imported files press C-s C-z and -- then write what you want to search for. -- Documentation of the Cubical Agda mode can be found at: -- https://agda.readthedocs.io/en/v2.6.1.3/language/cubical.html ------------------------------------------------------------------------------ -- Agda Basics -- ------------------------------------------------------------------------------ -- We parametrize everything by some universe levels (as opposed to -- Coq we always have to give these explicitly unless we work with the -- lowest universe) variable ℓ ℓ' ℓ'' : Level -- Universes in Agda are called "Set", but in order to avoid confusion -- with h-sets we rename them to "Type" in agda/cubical. -- Functions in Agda are written using equations: id : {A : Type ℓ} → A → A id x = x -- The {A : Type ℓ} notation says that A is an implicit argument of Type ℓ. -- The notation (x : A) → B and {x : A} → B denotes dependent -- functions (so B might mention x : A), in other words, Π-types -- We could also write this using λ-abstraction: id' : {A : Type ℓ} → A → A id' = λ x → x -- To write the nice symbol for the lambda type in "\lambda". To write -- "ℓ" type in "\ell" -- Agda supports Unicode symbols natively: -- https://agda.readthedocs.io/en/latest/tools/emacs-mode.html#unicode-input -- Agda has no tactics (as opposed to Coq), but we can build Agda -- terms interactively in emacs by writing a ? as RHS: -- -- id'' : {A : Type ℓ} → A → A -- id'' = ? -- -- Try uncommenting this and pressing "C-c C-l". This will give us a -- hole and by entering it with the cursor we can get information -- about what Agda expects us to provide and get help from Agda in -- providing this. -- -- By pressing "C-c C-," while having the cursor in the goal Agda -- shows us the current context and goal. As we're trying to write a -- function we can press "C-c C-r" (for refine) to have Agda write the -- λ-abstraction "λ x → ?" automatically for us. If one presses "C-c C-," -- in the hole again "x : A" will now be in the context. If we type -- "x" in the hole and press "C-c C-." Agda will show us that we have -- an A, which is exactly what we want to provide to fill the goal. By -- pressing "C-c C-SPACE" Agda will then fill the hole with "x" for us. -- -- Agda has lots of handy commands like this for manipulating goals: -- -- https://agda.readthedocs.io/en/latest/tools/emacs-mode.html#commands-in-context-of-a-goal -- A good resource to get start with Agda is the documentation: -- -- https://agda.readthedocs.io/en/latest/getting-started/index.html ------------------------------------------------------------------------------ -- The interval and path types -- ------------------------------------------------------------------------------ -- The interval in Cubical Agda is written I and the endpoints are -- -- i0 : I -- i1 : I -- -- These stand for "interval 0" and "interval 1". -- We can apply a function out of the interval to an endpoint just -- like we would apply any Agda function: apply0 : (A : Type ℓ) (p : I → A) → A apply0 A p = p i0 -- The equality type _≡_ is not inductively defined in Cubical Agda, -- instead it's a builtin primitive. An element of x ≡ y consists of a -- function p : I → A such that p i0 is definitionally x and p i1 is -- definitionally y. The check that the endpoints are correct when we -- provide a p : I → A is automatically performed by Agda during -- typechecking, so introducing an element of x ≡ y is done just like -- how we introduce elements of I → A but Agda will check the side -- conditions. -- -- We can hence write paths using λ-abstraction: path1 : {A : Type ℓ} (x : A) → x ≡ x path1 x = λ i → x -- As explained above Agda checks that whatever we write as definition -- matches the path that we have written (so the endpoints have to be -- correct). In this case everything is fine and path1 can be thought -- of as a proof reflexivity. Let's give it a nicer name and more -- implicit arguments: refl : {A : Type ℓ} {x : A} → x ≡ x refl {x = x} = λ i → x -- The notation {x = x} lets us access the implicit argument x (the x -- in the LHS of x = x) and rename it to x (the x in the RHS x = x) in -- the body of refl. We could just as well have written: -- -- refl : {A : Type ℓ} {x : A} → x ≡ x -- refl {x = y} = λ i → y -- Note that we cannot pattern-match on interval variables as I is not -- inductively defined: -- -- foo : {A : Type} → I → A -- foo r = {!r!} -- Try typing C-c C-c -- It often gets tiring to write {A : Type ℓ} everywhere, so let's -- assume that we have some types: variable A B : Type ℓ -- This will make A and B elements of different universes (all -- arguments is maximally generalized) and all definitions that use -- them will have them as implicit arguments. -- We can now implement some basic operations on _≡_. Let's start with -- cong (called "ap" in the HoTT book): cong : (f : A → B) {x y : A} → x ≡ y → f x ≡ f y cong f p i = f (p i) -- Note that the definition differs from the HoTT definition in that -- it is not defined by J or pattern-matching on p, but rather it's -- just a direct definition as a composition of functions. Agda treats -- p : x ≡ y like any function, so we can apply it to i to get an -- element of A which at i0 is x and at i1 is y. By applying f to this -- element we hence get an element of B which at i0 is f x and at i1 -- is f y. -- As this is just function composition it satisfies lots of nice -- definitional equalities, see the Warmup.agda file. Some of these -- are not satisfied by the HoTT definition of cong/ap. -- In HoTT function extensionality is proved as a consequence of -- univalence using a rather ingenious proof due to Voevodsky, but in -- cubical systems it has a much more direct proof. As paths are just -- functions we can get it by swapping the arguments to p: funExt : {f g : A → B} (p : (x : A) → f x ≡ g x) → f ≡ g funExt p i x = p x i -- To see that this has the correct type, note that when i is i0 we -- have "p x i0 = f x" and when i is i1 we have "p x i1 = g x", so by -- η for function types we have a path f ≡ g as desired. -- The interval has additional operations: -- -- Minimum: _∧_ : I → I → I (corresponds to min(i,j)) -- Maximum: _∨_ : I → I → I (corresponds to max(i,j)) -- Symmetry: ~_ : I → I (corresponds to 1 - i) -- -- Agda remark: the _ in the operator names indicates where arguments -- should go. -- -- These satisfy the equations of a De Morgan algebra (i.e. a -- distributive lattice (_∧_ , _∨_ , i0 , i1) with an "De Morgan" -- involution ~). This just means that we have the following kinds of -- equations definitionally: -- -- i0 ∨ i = i -- i ∨ i1 = i1 -- i ∨ j = j ∨ i -- i0 ∧ i = i0 -- i1 ∧ i = i -- i ∧ j = j ∧ i -- ~ (~ i) = i -- i0 = ~ i1 -- ~ (i ∨ j) = ~ i ∧ ~ j -- ~ (i ∧ j) = ~ i ∨ ~ j -- -- However, we do not have i ∨ ~ i = i1 and i ∧ ~ i = i0. The reason -- is that I represents an abstract interval, so we if we think of it -- as the real interval [0,1] ⊂ ℝ we clearly don't always have -- "max(i,1-i) = 1" or "min(i,1-i) = 0)" for all i ∈ [0,1]. -- These operations on I are very useful as they let us define even -- more things directly. For example symmetry of paths is easily -- defined using ~_ sym : {x y : A} → x ≡ y → y ≡ x sym p i = p (~ i) -- The operations _∧_ and _∨_ are called "connections" and let us -- build higher dimensional cubes from lower dimensional ones, for -- example if we have a path p : x ≡ y then -- -- sq i j = p (i ∧ j) -- -- is a square (as we've parametrized by i and j) with the following -- boundary: -- -- sq i0 j = p (i0 ∧ j) = p i0 = x -- sq i1 j = p (i1 ∧ j) = p j -- sq i i0 = p (i ∧ i0) = p i0 = x -- sq i i1 = p (i ∧ i1) = p i -- -- If we draw this we get: -- -- p -- x --------> y -- ^ ^ -- ¦ ¦ -- refl ¦ sq ¦ p -- ¦ ¦ -- ¦ ¦ -- x --------> x -- refl -- -- Being able to make this square directly is very useful. It for -- example let's prove that singletons are contractible (aka based -- path induction). -- -- We first need the notion of contractible types. For this we need -- to use a Σ-type: isContr : Type ℓ → Type ℓ isContr A = Σ[ x ∈ A ] ((y : A) → x ≡ y) -- Σ-types are introduced in the file Agda.Builtin.Sigma as the record -- -- record Σ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') : Type (ℓ-max ℓ ℓ') where -- constructor _,_ -- field -- fst : A -- snd : B fst -- -- So the projections are fst/snd and the constructor is _,_. We -- also define non-dependent product as a special case of Σ-types in -- Cubical.Data.Sigma.Base as: -- -- _×_ : ∀ {ℓ ℓ'} (A : Type ℓ) (B : Type ℓ') → Type (ℓ-max ℓ ℓ') -- A × B = Σ A (λ _ → B) -- -- The notation ∀ {ℓ ℓ'} lets us omit the type of ℓ and ℓ' in the -- definition. -- We define the type of singletons as follows singl : {A : Type ℓ} (a : A) → Type ℓ singl {A = A} a = Σ[ x ∈ A ] a ≡ x -- To show that this type is contractible we need to provide a center -- of contraction and the fact that any element of it is path-equal to -- the center isContrSingl : (x : A) → isContr (singl x) isContrSingl x = ctr , prf where -- The center is just a pair with x and refl ctr : singl x ctr = x , refl -- We then need to prove that ctr is equal to any element s : singl x. -- This is an equality in a Σ-type, so the first component is a path -- and the second is a path over the path we pick as first argument, -- i.e. the second component is a square. In fact, we need a square -- relating refl and pax over a path between refl and pax, so we can -- use an _∧_ connection. prf : (s : singl x) → ctr ≡ s prf (y , pax) i = (pax i) , λ j → pax (i ∧ j) -- Agda tip: in order to automatically destruct an argument x -- (like (y , pax) in prf) write x in the hole and type -- C-c C-c. Agda might pick silly names, but it's still very -- convenient. -- As we saw in the second component of prf we often need squares when -- proving things. In fact, pax (i ∧ j) is a path relating refl to pax -- *over* another path "λ j → x ≡ pax j". This notion of path over a -- path is very useful when working in HoTT as well as cubically. In -- HoTT these are called path-overs and are defined using transport, -- but in Cubical Agda they are a primitive notion called PathP ("Path -- over a Path"). In general PathP A x y has -- -- A : I → Type ℓ -- x : A i0 -- y : A i1 -- -- So PathP lets us natively define heteorgeneous paths, i.e. paths -- where the endpoints are in different types. This allows us to -- specify the type of the second component of prf: prf' : (x : A) (s : singl x) → (x , refl) ≡ s prf' x (y , pax) i = (pax i) , λ j → goal i j where goal : PathP (λ j → x ≡ pax j) refl pax goal i j = pax (i ∧ j) -- Just like _×_ is a special case of Σ-types we have that _≡_ is a -- special case of PathP. In fact, x ≡ y is just short for PathP (λ _ → A) x y: reflP : {x : A} → PathP (λ _ → A) x x reflP = refl -- Having the primitive notion of equality be heterogeneous is an -- easily overlooked, but very important, strength of cubical type -- theory. This allows us to work directly with equality in Σ-types -- without using transport: module _ {A : Type ℓ} {B : A → Type ℓ'} {x y : Σ A B} where ΣPathP : Σ[ p ∈ fst x ≡ fst y ] PathP (λ i → B (p i)) (snd x) (snd y) → x ≡ y ΣPathP eq i = fst eq i , snd eq i PathPΣ : x ≡ y → Σ[ p ∈ fst x ≡ fst y ] PathP (λ i → B (p i)) (snd x) (snd y) PathPΣ eq = (λ i → fst (eq i)) , (λ i → snd (eq i)) -- The fact that these cancel is proved by refl -- If one looks carefully the proof of prf uses ΣPathP inlined, in -- fact this is used all over the place when working cubically and -- simplifies many proofs which in HoTT requires long complicated -- reasoning about transport. isContrΠ : {B : A → Type ℓ'} (h : (x : A) → isContr (B x)) → isContr ((x : A) → B x) isContrΠ h = (λ x → fst (h x)) , (λ f i x → snd (h x) (f x) i) -- Let us end this session with defining propositions and sets isProp : Type ℓ → Type ℓ isProp A = (x y : A) → x ≡ y isSet : Type ℓ → Type ℓ isSet A = (x y : A) → isProp (x ≡ y) -- In the agda/cubical library we call these h-levels following -- Voevodsky instead of n-types and index by natural numbers instead -- of ℕ₋₂. So isContr is isOfHLevel 0, isProp is isOfHLevel 1, isSet -- is isOfHLevel 2, etc. For details see Cubical/Foundations/HLevels.agda
36.557333
92
0.626231
381279f4ca0d9db5daf48305658a115e56587cf6
4,094
agda
Agda
Cubical/Data/Nat/Properties.agda
knrafto/cubical
f6771617374bfe65a7043d00731fed5a673aa729
[ "MIT" ]
null
null
null
Cubical/Data/Nat/Properties.agda
knrafto/cubical
f6771617374bfe65a7043d00731fed5a673aa729
[ "MIT" ]
null
null
null
Cubical/Data/Nat/Properties.agda
knrafto/cubical
f6771617374bfe65a7043d00731fed5a673aa729
[ "MIT" ]
1
2021-11-22T02:02:01.000Z
2021-11-22T02:02:01.000Z
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-} module Cubical.Data.Nat.Properties where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Data.Nat.Base open import Cubical.Data.Empty as ⊥ open import Cubical.Data.Sigma open import Cubical.Relation.Nullary open import Cubical.Relation.Nullary.DecidableEq private variable l m n : ℕ znots : ¬ (0 ≡ suc n) znots eq = subst (caseNat ℕ ⊥) eq 0 snotz : ¬ (suc n ≡ 0) snotz eq = subst (caseNat ⊥ ℕ) eq 0 injSuc : suc m ≡ suc n → m ≡ n injSuc p = cong predℕ p discreteℕ : Discrete ℕ discreteℕ zero zero = yes refl discreteℕ zero (suc n) = no znots discreteℕ (suc m) zero = no snotz discreteℕ (suc m) (suc n) with discreteℕ m n ... | yes p = yes (cong suc p) ... | no p = no (λ x → p (injSuc x)) isSetℕ : isSet ℕ isSetℕ = Discrete→isSet discreteℕ -- Arithmetic facts about predℕ suc-predℕ : ∀ n → ¬ n ≡ 0 → n ≡ suc (predℕ n) suc-predℕ zero p = ⊥.rec (p refl) suc-predℕ (suc n) p = refl -- Arithmetic facts about + +-zero : ∀ m → m + 0 ≡ m +-zero zero = refl +-zero (suc m) = cong suc (+-zero m) +-suc : ∀ m n → m + suc n ≡ suc (m + n) +-suc zero n = refl +-suc (suc m) n = cong suc (+-suc m n) +-comm : ∀ m n → m + n ≡ n + m +-comm m zero = +-zero m +-comm m (suc n) = (+-suc m n) ∙ (cong suc (+-comm m n)) -- Addition is associative +-assoc : ∀ m n o → m + (n + o) ≡ (m + n) + o +-assoc zero _ _ = refl +-assoc (suc m) n o = cong suc (+-assoc m n o) inj-m+ : m + l ≡ m + n → l ≡ n inj-m+ {zero} p = p inj-m+ {suc m} p = inj-m+ (injSuc p) inj-+m : l + m ≡ n + m → l ≡ n inj-+m {l} {m} {n} p = inj-m+ ((+-comm m l) ∙ (p ∙ (+-comm n m))) m+n≡n→m≡0 : m + n ≡ n → m ≡ 0 m+n≡n→m≡0 {n = zero} = λ p → (sym (+-zero _)) ∙ p m+n≡n→m≡0 {n = suc n} p = m+n≡n→m≡0 (injSuc ((sym (+-suc _ n)) ∙ p)) m+n≡0→m≡0×n≡0 : m + n ≡ 0 → (m ≡ 0) × (n ≡ 0) m+n≡0→m≡0×n≡0 {zero} = refl ,_ m+n≡0→m≡0×n≡0 {suc m} p = ⊥.rec (snotz p) -- Arithmetic facts about * 0≡m*0 : ∀ m → 0 ≡ m * 0 0≡m*0 zero = refl 0≡m*0 (suc m) = 0≡m*0 m *-suc : ∀ m n → m * suc n ≡ m + m * n *-suc zero n = refl *-suc (suc m) n = cong suc ( n + m * suc n ≡⟨ cong (n +_) (*-suc m n) ⟩ n + (m + m * n) ≡⟨ +-assoc n m (m * n) ⟩ (n + m) + m * n ≡⟨ cong (_+ m * n) (+-comm n m) ⟩ (m + n) + m * n ≡⟨ sym (+-assoc m n (m * n)) ⟩ m + (n + m * n) ∎ ) *-comm : ∀ m n → m * n ≡ n * m *-comm zero n = 0≡m*0 n *-comm (suc m) n = cong (n +_) (*-comm m n) ∙ sym (*-suc n m) *-distribʳ : ∀ m n o → (m * o) + (n * o) ≡ (m + n) * o *-distribʳ zero _ _ = refl *-distribʳ (suc m) n o = sym (+-assoc o (m * o) (n * o)) ∙ cong (o +_) (*-distribʳ m n o) *-distribˡ : ∀ o m n → (o * m) + (o * n) ≡ o * (m + n) *-distribˡ o m n = (λ i → *-comm o m i + *-comm o n i) ∙ *-distribʳ m n o ∙ *-comm (m + n) o *-assoc : ∀ m n o → m * (n * o) ≡ (m * n) * o *-assoc zero _ _ = refl *-assoc (suc m) n o = cong (n * o +_) (*-assoc m n o) ∙ *-distribʳ n (m * n) o *-identityˡ : ∀ m → 1 * m ≡ m *-identityˡ m = +-zero m *-identityʳ : ∀ m → m * 1 ≡ m *-identityʳ zero = refl *-identityʳ (suc m) = cong suc (*-identityʳ m) 0≡n*sm→0≡n : 0 ≡ n * suc m → 0 ≡ n 0≡n*sm→0≡n {n = zero} p = refl 0≡n*sm→0≡n {n = suc n} p = ⊥.rec (znots p) inj-*sm : l * suc m ≡ n * suc m → l ≡ n inj-*sm {zero} {m} {n} p = 0≡n*sm→0≡n p inj-*sm {l} {m} {zero} p = sym (0≡n*sm→0≡n (sym p)) inj-*sm {suc l} {m} {suc n} p = cong suc (inj-*sm (inj-m+ {m = suc m} p)) inj-sm* : suc m * l ≡ suc m * n → l ≡ n inj-sm* {m} {l} {n} p = inj-*sm (*-comm l (suc m) ∙ p ∙ *-comm (suc m) n) -- Arithmetic facts about ∸ zero∸ : ∀ n → zero ∸ n ≡ zero zero∸ zero = refl zero∸ (suc _) = refl ∸-cancelˡ : ∀ k m n → (k + m) ∸ (k + n) ≡ m ∸ n ∸-cancelˡ zero = λ _ _ → refl ∸-cancelˡ (suc k) = ∸-cancelˡ k ∸-cancelʳ : ∀ m n k → (m + k) ∸ (n + k) ≡ m ∸ n ∸-cancelʳ m n k = (λ i → +-comm m k i ∸ +-comm n k i) ∙ ∸-cancelˡ k m n ∸-distribʳ : ∀ m n k → (m ∸ n) * k ≡ m * k ∸ n * k ∸-distribʳ m zero k = refl ∸-distribʳ zero (suc n) k = sym (zero∸ (k + n * k)) ∸-distribʳ (suc m) (suc n) k = ∸-distribʳ m n k ∙ sym (∸-cancelˡ k (m * k) (n * k))
27.85034
92
0.510747
c780d14c3775dfa076deb51d20ddf11a14e60521
492
agda
Agda
test/Fail/Issue2480false2.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue2480false2.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue2480false2.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Exploit by Jesper Cockx open import Agda.Builtin.Equality data Bool : Set where tt ff : Bool const : Bool → (Bool → Bool) const = λ x _ → x mutual Bool→cBool : Set Bool→cBool = _ const-tt : Bool→cBool const-tt = const tt constant : (f : Bool→cBool) (x y : Bool) → f x ≡ f y constant f x y = refl constant' : (f : Bool → Bool) (x y : Bool) → f x ≡ f y constant' = constant swap : Bool → Bool swap tt = ff swap ff = tt fireworks : tt ≡ ff fireworks = constant' swap ff tt
16.4
54
0.628049
fb2b30241d5cbd244725759d74a9a7b68e4f7c32
5,361
agda
Agda
test/Test.agda
ioanasv/agda2hs
17cdbeb36af3d0b735c5db83bb811034c39a19cd
[ "MIT" ]
1
2021-05-25T09:41:34.000Z
2021-05-25T09:41:34.000Z
test/Test.agda
ioanasv/agda2hs
17cdbeb36af3d0b735c5db83bb811034c39a19cd
[ "MIT" ]
null
null
null
test/Test.agda
ioanasv/agda2hs
17cdbeb36af3d0b735c5db83bb811034c39a19cd
[ "MIT" ]
null
null
null
module _ where open import Haskell.Prelude open import Agda.Builtin.Equality -- ** Foreign HS code -- language extensions {-# FOREIGN AGDA2HS {-# LANGUAGE LambdaCase #-} {-# LANGUAGE FlexibleInstances #-} #-} -- imports {-# FOREIGN AGDA2HS import Data.Monoid #-} -- ** Datatypes & functions data Exp (v : Set) : Set where Plus : Exp v → Exp v → Exp v Lit : Nat → Exp v Var : v → Exp v {-# COMPILE AGDA2HS Exp deriving (Show,Eq) #-} eval : (a → Nat) → Exp a → Nat eval env (Plus a b) = eval env a + eval env b eval env (Lit n) = n eval env (Var x) = env x {-# COMPILE AGDA2HS eval #-} -- ** Natural numbers listSum : List Int → Int listSum [] = 0 listSum (x ∷ xs) = x + sum xs {-# COMPILE AGDA2HS listSum #-} monoSum : List Integer → Integer monoSum xs = sum xs {-# COMPILE AGDA2HS monoSum #-} polySum : ⦃ iNum : Num a ⦄ → List a → a polySum xs = sum xs {-# COMPILE AGDA2HS polySum #-} {-# FOREIGN AGDA2HS -- comment -- another comment bla :: Int -> Int bla n = n * 4 {- multi line comment -} #-} -- ** Extra builtins ex_float : Double ex_float = 0.0 {-# COMPILE AGDA2HS ex_float #-} -- postulate -- toInteger : Word → Integer ex_word : Word ex_word = fromInteger 0 {-# COMPILE AGDA2HS ex_word #-} ex_char : Char ex_char = 'a' {-# COMPILE AGDA2HS ex_char #-} char_d : Char char_d = toEnum 100 {-# COMPILE AGDA2HS char_d #-} -- ** Polymorphic functions _+++_ : List a → List a → List a [] +++ ys = ys (x ∷ xs) +++ ys = x ∷ (xs +++ ys) {-# COMPILE AGDA2HS _+++_ #-} listMap : (a → b) → List a → List b listMap f [] = [] listMap f (x ∷ xs) = f x ∷ listMap f xs {-# COMPILE AGDA2HS listMap #-} mapTest : List Nat → List Nat mapTest = map (id ∘ _+_ 5) {-# COMPILE AGDA2HS mapTest #-} -- ** Lambdas plus3 : List Nat → List Nat plus3 = map (λ n → n + 3) {-# COMPILE AGDA2HS plus3 #-} doubleLambda : Nat → Nat → Nat doubleLambda = λ a b → a + 2 * b {-# COMPILE AGDA2HS doubleLambda #-} cnst : a → b → a cnst = λ x _ → x {-# COMPILE AGDA2HS cnst #-} -- ** Constraints second : (b → c) → a × b → a × c second f (x , y) = x , f y {-# COMPILE AGDA2HS second #-} doubleTake : (n m : Int) → ⦃ IsNonNegativeInt n ⦄ → ⦃ IsNonNegativeInt m ⦄ → List a → List a × List a doubleTake n m = second (take m) ∘ splitAt n {-# COMPILE AGDA2HS doubleTake #-} initLast : (xs : List a) → ⦃ NonEmpty xs ⦄ → List a × a initLast xs = init xs , last xs {-# COMPILE AGDA2HS initLast #-} -- ** Proofs assoc : (a b c : Nat) → a + (b + c) ≡ (a + b) + c assoc zero b c = refl assoc (suc a) b c rewrite assoc a b c = refl thm : (xs ys : List Nat) → sum (xs ++ ys) ≡ sum xs + sum ys thm [] ys = refl thm (x ∷ xs) ys rewrite thm xs ys | assoc x (sum xs) (sum ys) = refl -- (custom) Monoid class record MonoidX (a : Set) : Set where field memptyX : a mappendX : a → a → a open MonoidX {{...}} public {-# COMPILE AGDA2HS MonoidX class #-} instance MonoidNat : MonoidX Nat memptyX {{MonoidNat}} = 0 mappendX {{MonoidNat}} i j = i + j {-# COMPILE AGDA2HS MonoidNat #-} instance MonoidFunNat : {a : Set} → MonoidX (a → Nat) memptyX {{MonoidFunNat}} _ = memptyX mappendX {{MonoidFunNat}} f g x = mappendX (f x) (g x) {-# COMPILE AGDA2HS MonoidFunNat #-} instance MonoidFun : {a b : Set} → {{MonoidX b}} → MonoidX (a → b) memptyX {{MonoidFun}} _ = memptyX mappendX {{MonoidFun}} f g x = mappendX (f x) (g x) {-# COMPILE AGDA2HS MonoidFun #-} sumMonX : ∀{a} → {{MonoidX a}} → List a → a sumMonX [] = memptyX sumMonX (x ∷ xs) = mappendX x (sumMonX xs) {-# COMPILE AGDA2HS sumMonX #-} sumMon : ∀{a} → {{Monoid a}} → List a → a sumMon [] = mempty sumMon (x ∷ xs) = x <> sumMon xs {-# COMPILE AGDA2HS sumMon #-} -- Using the Monoid class from the Prelude data NatSum : Set where MkSum : Nat → NatSum {-# COMPILE AGDA2HS NatSum #-} instance SemigroupNatSum : Semigroup NatSum SemigroupNatSum ._<>_ (MkSum a) (MkSum b) = MkSum (a + b) MonoidNatSum : Monoid NatSum MonoidNatSum .mempty = MkSum 0 double : ⦃ Monoid a ⦄ → a → a double x = x <> x doubleSum : NatSum → NatSum doubleSum = double {-# COMPILE AGDA2HS SemigroupNatSum #-} {-# COMPILE AGDA2HS MonoidNatSum #-} {-# COMPILE AGDA2HS double #-} {-# COMPILE AGDA2HS doubleSum #-} -- Instance argument proof obligation that should not turn into a class constraint hd : (xs : List a) → ⦃ NonEmpty xs ⦄ → a hd [] = error "hd: empty list" hd (x ∷ _) = x {-# COMPILE AGDA2HS hd #-} five : Int five = hd (5 ∷ 3 ∷ []) {-# COMPILE AGDA2HS five #-} -- ** Booleans ex_bool : Bool ex_bool = true {-# COMPILE AGDA2HS ex_bool #-} ex_if : Nat ex_if = if true then 1 else 0 {-# COMPILE AGDA2HS ex_if #-} if_over : Nat if_over = (if true then (λ x → x) else (λ x → x + 1)) 0 {-# COMPILE AGDA2HS if_over #-} if_partial₁ : List Nat → List Nat if_partial₁ = map (if true then 1 else_) {-# COMPILE AGDA2HS if_partial₁ #-} if_partial₂ : List Nat → List (Nat → Nat) if_partial₂ = map (if true then_else_) {-# COMPILE AGDA2HS if_partial₂ #-} if_partial₃ : List Bool → List (Nat → Nat → Nat) if_partial₃ = map if_then_else_ {-# COMPILE AGDA2HS if_partial₃ #-} if_partial₄ : List Bool → List (Nat → Nat) if_partial₄ = map (if_then 1 else_) {-# COMPILE AGDA2HS if_partial₄ #-} if_partial₅ : Bool → Nat → List Nat → List Nat if_partial₅ b f = map (if b then f else_) {-# COMPILE AGDA2HS if_partial₅ #-}
21.971311
101
0.616116
4b57ce2608000113c7ca2e8e444729b5d3be0268
301
agda
Agda
test/interaction/Issue2303.agda
hborum/agda
aac88412199dd4cbcb041aab499d8a6b7e3f4a2e
[ "BSD-3-Clause" ]
3
2015-03-28T14:51:03.000Z
2015-12-07T20:14:00.000Z
test/interaction/Issue2303.agda
andersk/agda
56928ff709dcb931cb9a48c4790e5ed3739e3032
[ "BSD-3-Clause" ]
null
null
null
test/interaction/Issue2303.agda
andersk/agda
56928ff709dcb931cb9a48c4790e5ed3739e3032
[ "BSD-3-Clause" ]
1
2019-03-05T20:02:38.000Z
2019-03-05T20:02:38.000Z
postulate A : Set data D : Set where c : A → D data P : D → Set where d : (x : A) → P (c x) g : (x : D) → P x → D g blargh (d y) with Set g glurph (d y) | w = {!!} -- Expected: glurph = c y : D, y : A, w : Set₁ h : D → D h x@(c y) with Set h (c z) | w = {!!} -- Expected: z : A, w : Set₁
15.842105
48
0.458472
04bcb87c805c16a84c39481725d0755466200a58
10,834
agda
Agda
src/SecondOrder/Instantiation.agda
cilinder/formaltt
0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb
[ "MIT" ]
21
2021-02-16T14:07:06.000Z
2021-11-19T15:50:08.000Z
src/SecondOrder/Instantiation.agda
cilinder/formaltt
0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb
[ "MIT" ]
1
2021-04-30T14:18:25.000Z
2021-05-14T16:15:17.000Z
src/SecondOrder/Instantiation.agda
cilinder/formaltt
0a9d25e6e3965913d9b49a47c88cdfb94b55ffeb
[ "MIT" ]
6
2021-02-16T13:43:07.000Z
2021-05-24T02:51:43.000Z
open import Agda.Primitive using (lzero; lsuc; _⊔_) open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong; subst) import SecondOrder.Arity import SecondOrder.Signature import SecondOrder.Metavariable import SecondOrder.VRenaming import SecondOrder.MRenaming import SecondOrder.Term import SecondOrder.Substitution import SecondOrder.RelativeMonadMorphism module SecondOrder.Instantiation {ℓ} {𝔸 : SecondOrder.Arity.Arity} (Σ : SecondOrder.Signature.Signature ℓ 𝔸) where open SecondOrder.Signature.Signature Σ open SecondOrder.Metavariable Σ open SecondOrder.Term Σ open SecondOrder.VRenaming Σ open SecondOrder.MRenaming Σ open SecondOrder.Substitution Σ open import SecondOrder.RelativeMonadMorphism -- metavariable instantiation _⇒ⁱ_⊕_ : MContext → MContext → VContext → Set ℓ Θ ⇒ⁱ Ξ ⊕ Γ = ∀ {Γᴹ Aᴹ} (M : [ Γᴹ , Aᴹ ]∈ Θ) → Term Ξ (Γ ,, Γᴹ) Aᴹ -- instantiation respects propositionnal equality I-resp-≡ : ∀ {Θ Ω Γ Δ A} {M N : [ Δ , A ]∈ Θ} {I : Θ ⇒ⁱ Ω ⊕ Γ} → M ≡ N → I M ≡ I N I-resp-≡ refl = refl -- syntactic equality of instantiations infix 5 _≈ⁱ_ _≈ⁱ_ : ∀ {Θ Ψ Γ} (I J : Θ ⇒ⁱ Ψ ⊕ Γ) → Set ℓ _≈ⁱ_ {Θ} I J = ∀ {Γᴹ Aᴹ} (M : [ Γᴹ , Aᴹ ]∈ Θ) → I M ≈ J M -- equality of instantiations is an equivalence relation ≈ⁱ-refl : ∀ {Θ Ψ Γ} {I : Θ ⇒ⁱ Ψ ⊕ Γ} → I ≈ⁱ I ≈ⁱ-refl M = ≈-refl ≈ⁱ-sym : ∀ {Θ Ψ Γ} {I J : Θ ⇒ⁱ Ψ ⊕ Γ} → I ≈ⁱ J → J ≈ⁱ I ≈ⁱ-sym ξ M = ≈-sym (ξ M) ≈ⁱ-trans : ∀ {Θ Ψ Γ} {I J K : Θ ⇒ⁱ Ψ ⊕ Γ} → I ≈ⁱ J → J ≈ⁱ K → I ≈ⁱ K ≈ⁱ-trans ζ ξ M = ≈-trans (ζ M) (ξ M) -- extension of an instantiation ⇑ⁱ : ∀ {Θ Ψ Γ Δ} → Θ ⇒ⁱ Ψ ⊕ Γ → Θ ⇒ⁱ Ψ ⊕ (Γ ,, Δ) ⇑ⁱ I M = [ ⇑ᵛ var-inl ]ᵛ I M -- extension of instantiations preserve equality of instantiations ⇑ⁱ-resp-≈ⁱ : ∀ {Θ Ψ Γ Δ} (I J : Θ ⇒ⁱ Ψ ⊕ Γ) → (I ≈ⁱ J) → (⇑ⁱ {Δ = Δ} I ≈ⁱ ⇑ⁱ J) ⇑ⁱ-resp-≈ⁱ I J ξ M = []ᵛ-resp-≈ (ξ M) -- action of a metavariable instantiation on terms infixr 6 [_]ⁱ_ [_]ⁱ_ : ∀ {Θ ψ Γ} → ψ ⇒ⁱ Θ ⊕ Γ → ∀ {A} → Term ψ Γ A → Term Θ Γ A [ I ]ⁱ (tm-var x) = tm-var x [ I ]ⁱ (tm-meta M ts) = [ [ idˢ , (λ i → [ I ]ⁱ ts i) ]ˢ ]ˢ (I M) [ I ]ⁱ (tm-oper f es) = tm-oper f λ i → [ ⇑ⁱ I ]ⁱ es i -- instantiation preserves equality of terms []ⁱ-resp-≈ : ∀ {Θ Ξ Γ} (I : Ξ ⇒ⁱ Θ ⊕ Γ) → ∀ {A} {t u : Term Ξ Γ A} → t ≈ u → [ I ]ⁱ t ≈ [ I ]ⁱ u []ⁱ-resp-≈ I (≈-≡ refl) = ≈-refl []ⁱ-resp-≈ I (≈-meta {M = M} ξ) = []ˢ-resp-≈ˢ (I M) ([,]ˢ-resp-≈ˢ (λ x → ≈-refl) λ i → []ⁱ-resp-≈ I (ξ i)) []ⁱ-resp-≈ I (≈-oper ξ) = ≈-oper λ i → []ⁱ-resp-≈ (⇑ⁱ I) (ξ i) -- action preserves equality of instantiation []ⁱ-resp-≈ⁱ : ∀ {Θ Ξ Γ} {I J : Ξ ⇒ⁱ Θ ⊕ Γ} → ∀ {A} (t : Term Ξ Γ A) → I ≈ⁱ J → [ I ]ⁱ t ≈ [ J ]ⁱ t []ⁱ-resp-≈ⁱ (tm-var x) ξ = ≈-refl []ⁱ-resp-≈ⁱ (tm-meta M ts) ξ = []ˢ-resp-≈ˢ-≈ ([,]ˢ-resp-≈ˢ (λ x → ≈-refl) λ i → []ⁱ-resp-≈ⁱ (ts i) ξ) (ξ M) []ⁱ-resp-≈ⁱ {I = I} {J = J} (tm-oper f es) ξ = ≈-oper λ i → []ⁱ-resp-≈ⁱ (es i) (⇑ⁱ-resp-≈ⁱ I J ξ) -- generically applied metavariable tm-meta-generic : ∀ {Θ} {Γ} {Γᴹ Aᴹ} (M : [ Γᴹ , Aᴹ ]∈ Θ) → Term Θ (Γ ,, Γᴹ) Aᴹ tm-meta-generic M = tm-meta M λ i → tm-var (var-inr i) -- the action of an instantiation on a generically applied metavariable []ⁱ-generic : ∀ {Θ Ξ} {Γ} {I : Θ ⇒ⁱ Ξ ⊕ Γ} {Γᴹ Aᴹ} {M : [ Γᴹ , Aᴹ ]∈ Θ} → [ ⇑ⁱ {Δ = Γᴹ} I ]ⁱ tm-meta-generic M ≈ I M []ⁱ-generic {Θ = Θ} {Ξ = Ξ} {Γ = Γ} {I = I} {Γᴹ = Γᴹ} {M = M} = ≈-trans (≈-sym ([ˢ∘ᵛ] (I M))) (≈ˢ-idˢ-[]ˢ (λ { (var-inl _) → ≈-refl ; (var-inr _) → ≈-refl})) -- Interactions involving instantiations -- the identity metavariable instantiation idⁱ : ∀ {Θ Γ} → Θ ⇒ⁱ Θ ⊕ Γ idⁱ M = tm-meta-generic M -- composition of metavariable instantiations infixl 6 _∘ⁱ_ _∘ⁱ_ : ∀ {Θ Ξ Ω Γ} → Ξ ⇒ⁱ Ω ⊕ Γ → Θ ⇒ⁱ Ξ ⊕ Γ → (Θ ⇒ⁱ Ω ⊕ Γ) (I ∘ⁱ J) M = [ ⇑ⁱ I ]ⁱ J M -- composition of a renaming and an instantiation _ᵛ∘ⁱ_ : ∀ {Θ ψ Γ Δ} → Γ ⇒ᵛ Δ → Θ ⇒ⁱ ψ ⊕ Γ → Θ ⇒ⁱ ψ ⊕ Δ (ρ ᵛ∘ⁱ I) M = [ ⇑ᵛ ρ ]ᵛ I M -- composition of a substitution and an instantiation _ˢ∘ⁱ_ : ∀ {Θ ψ Γ Δ} → ψ ⊕ Γ ⇒ˢ Δ → Θ ⇒ⁱ ψ ⊕ Γ → Θ ⇒ⁱ ψ ⊕ Δ (σ ˢ∘ⁱ I) M = [ ⇑ˢ σ ]ˢ I M -- composition of an instantiation and a substitution _ⁱ∘ˢ_ : ∀ {Θ ψ Γ Δ} → Θ ⇒ⁱ ψ ⊕ Δ → Θ ⊕ Γ ⇒ˢ Δ → ψ ⊕ Γ ⇒ˢ Δ (I ⁱ∘ˢ σ) x = [ I ]ⁱ σ x -- composition of a renaming and an instantiation preerve equality of instantiations [ᵛ∘ⁱ]-resp-≈ⁱ : ∀ {Θ ψ Γ Δ} (ρ : Γ ⇒ᵛ Δ) (I J : Θ ⇒ⁱ ψ ⊕ Γ) → (I ≈ⁱ J) → (ρ ᵛ∘ⁱ I) ≈ⁱ (ρ ᵛ∘ⁱ J) [ᵛ∘ⁱ]-resp-≈ⁱ σ I J ξ M = []ᵛ-resp-≈ (ξ M) -- composition of a renaming and an instantiation preserve equality of instantiations [ˢ∘ⁱ]-resp-≈ⁱ : ∀ {Θ ψ Γ Δ} (σ : ψ ⊕ Γ ⇒ˢ Δ) (I J : Θ ⇒ⁱ ψ ⊕ Γ) → (I ≈ⁱ J) → (σ ˢ∘ⁱ I) ≈ⁱ (σ ˢ∘ⁱ J) [ˢ∘ⁱ]-resp-≈ⁱ σ I J ξ M = []ˢ-resp-≈ (⇑ˢ σ) (ξ M) -- Actions correspondig to the interactions -- the action of the identity [idⁱ] : ∀ {Θ Γ A Δ} {t : Term Θ (Γ ,, Δ) A} → [ idⁱ ]ⁱ t ≈ t [idⁱ] {t = tm-var x} = ≈-refl [idⁱ] {t = tm-meta M ts} = ≈-meta (λ i → [idⁱ]) [idⁱ] {t = tm-oper f es} = ≈-oper (λ i → [idⁱ]) -- extension commutes with composition of renaming and substitution ⇑ⁱ-resp-ᵛ∘ⁱ : ∀ {Θ ψ} {Γ Δ Ξ} {I : Θ ⇒ⁱ ψ ⊕ Γ} {ρ : Γ ⇒ᵛ Δ} → ⇑ⁱ {Δ = Ξ} (ρ ᵛ∘ⁱ I) ≈ⁱ ⇑ᵛ ρ ᵛ∘ⁱ ⇑ⁱ I ⇑ⁱ-resp-ᵛ∘ⁱ {ρ = ρ} M = ≈-trans (≈-sym [∘ᵛ]) (≈-trans ([]ᵛ-resp-≡ᵛ λ {(var-inl _) → refl ; (var-inr x) → refl}) [∘ᵛ]) -- the action of the composition of an instantiation and a renaming [ᵛ∘ⁱ] : ∀ {Θ Ψ Γ Δ A} {ρ : Γ ⇒ᵛ Δ} {I : Θ ⇒ⁱ Ψ ⊕ Γ} (t : Term Θ Γ A) → [ ρ ]ᵛ [ I ]ⁱ t ≈ [ ρ ᵛ∘ⁱ I ]ⁱ [ ρ ]ᵛ t [ᵛ∘ⁱ] (tm-var x) = ≈-refl [ᵛ∘ⁱ] {I = I} (tm-meta M ts) = ≈-trans (≈-sym ([ᵛ∘ˢ] (I M))) (≈-trans ([]ˢ-resp-≈ˢ (I M) (λ { (var-inl _) → ≈-refl ; (var-inr j) → [ᵛ∘ⁱ] (ts j)})) ([ˢ∘ᵛ] (I M))) [ᵛ∘ⁱ] {ρ = ρ} {I = I} (tm-oper f es) = ≈-oper λ i → ≈-trans ([ᵛ∘ⁱ] (es i)) ([]ⁱ-resp-≈ⁱ ([ ⇑ᵛ ρ ]ᵛ es i) (≈ⁱ-sym (⇑ⁱ-resp-ᵛ∘ⁱ {I = I}))) -- extension commutes with composition ⇑ⁱ-resp-∘ⁱ : ∀ {Θ Ξ Ω} {Γ Δ} {I : Θ ⇒ⁱ Ξ ⊕ Γ} {J : Ξ ⇒ⁱ Ω ⊕ Γ} → ⇑ⁱ {Δ = Δ} (J ∘ⁱ I) ≈ⁱ ⇑ⁱ J ∘ⁱ ⇑ⁱ I ⇑ⁱ-resp-∘ⁱ {I = I} {J = J} M = ≈-trans ([ᵛ∘ⁱ] (I M)) ([]ⁱ-resp-≈ⁱ ([ ⇑ᵛ var-inl ]ᵛ I M) (λ N → ≈-trans (≈-sym [∘ᵛ]) (≈-trans ([]ᵛ-resp-≡ᵛ (λ { (var-inl x) → refl ; (var-inr x) → refl })) [∘ᵛ]))) ⇑ˢ-resp-ⁱ∘ˢ : ∀ {Θ ψ Γ Δ Ξ} → {I : Θ ⇒ⁱ ψ ⊕ Δ} → {σ : Θ ⊕ Γ ⇒ˢ Δ} → ⇑ˢ {Ξ = Ξ} (I ⁱ∘ˢ σ) ≈ˢ ⇑ⁱ I ⁱ∘ˢ ⇑ˢ σ ⇑ˢ-resp-ⁱ∘ˢ {σ = σ} (var-inl x) = [ᵛ∘ⁱ] (σ x) ⇑ˢ-resp-ⁱ∘ˢ (var-inr x) = ≈-refl -- interaction lemma []ⁱ-[]ˢ : ∀ {Θ Ψ Γ Δ A} {I : Θ ⇒ⁱ Ψ ⊕ Δ} {σ : Θ ⊕ Γ ⇒ˢ Δ} {ρ : Δ ⇒ᵛ Γ} (t : Term Θ Γ A) → σ ˢ∘ᵛ ρ ≈ˢ idˢ → ([ I ]ⁱ ([ σ ]ˢ t)) ≈ ([ I ⁱ∘ˢ σ ]ˢ [ ρ ᵛ∘ⁱ I ]ⁱ t) []ⁱ-[]ˢ (tm-var x) ξ = ≈-refl []ⁱ-[]ˢ {I = I} {σ = σ} {ρ = ρ} (tm-meta M ts) ξ = ≈-trans ([]ˢ-resp-≈ˢ (I M) (λ { (var-inl i) → []ⁱ-resp-≈ I (≈-sym (ξ i)) ; (var-inr j) → []ⁱ-[]ˢ (ts j) ξ})) (≈-trans ([ˢ∘ᵛ] (I M)) ([∘ˢ] ((ρ ᵛ∘ⁱ I) M))) []ⁱ-[]ˢ {I = I} {σ = σ} {ρ = ρ} (tm-oper f es) ξ = ≈-oper λ i → ≈-trans ([]ⁱ-[]ˢ {σ = ⇑ˢ σ} {ρ = ⇑ᵛ ρ} (es i) (≈ˢ-trans (≈ˢ-sym (⇑ˢ-resp-ˢ∘ᵛ {ρ = ρ} {σ = σ})) (≈ˢ-trans (⇑ˢ-resp-≈ˢ ξ) ⇑ˢ-resp-idˢ))) ([]ˢ-resp-≈ˢ-≈ {σ = ⇑ⁱ I ⁱ∘ˢ ⇑ˢ σ } {τ = ⇑ˢ (I ⁱ∘ˢ σ)} {t = ([ ⇑ᵛ ρ ᵛ∘ⁱ ⇑ⁱ I ]ⁱ es i)} {u = ([ ⇑ⁱ (ρ ᵛ∘ⁱ I) ]ⁱ es i)} (≈ˢ-sym ⇑ˢ-resp-ⁱ∘ˢ) ([]ⁱ-resp-≈ⁱ (es i) (≈ⁱ-sym (⇑ⁱ-resp-ᵛ∘ⁱ {I = I})))) -- the action of a composition is functorial [∘ⁱ] : ∀ {Θ Ξ Ω Γ} → {I : Θ ⇒ⁱ Ξ ⊕ Γ} → {J : Ξ ⇒ⁱ Ω ⊕ Γ} → ∀ {A} → ∀ (t : Term Θ Γ A) → [ J ∘ⁱ I ]ⁱ t ≈ [ J ]ⁱ [ I ]ⁱ t [∘ⁱ] (tm-var x) = ≈-refl [∘ⁱ] {Θ = Θ} {Ξ = Ξ} {Γ = Γ} {I = I} {J = J} (tm-meta {Γᴹ = Γᴹ} M ts) = ≈-trans ([]ˢ-resp-≈ˢ ([ ⇑ⁱ J ]ⁱ (I M)) ([,]ˢ-resp-≈ˢ (λ x → ≈-refl) (λ i → [∘ⁱ] {I = I} {J = J} (ts i)))) (≈-trans ([]ˢ-resp-≈ˢ {τ = λ i → [ J ]ⁱ var-or-ts i} ([ ⇑ⁱ J ]ⁱ (I M)) λ {(var-inl x) → ≈-refl ; (var-inr y) → ≈-refl}) (≈-trans (≈-sym ([]ⁱ-[]ˢ {I = J} {σ = var-or-ts} {ρ = var-inl} (I M) λ x → ≈-refl)) ([]ⁱ-resp-≈ J ([]ˢ-resp-≈ˢ (I M) λ { (var-inl x) → ≈-refl ; (var-inr x) → ≈-refl})))) where var-or-ts : ∀ {A} → A ∈ (Γ ,, Γᴹ) → Term Ξ Γ A var-or-ts (var-inl x) = tm-var x var-or-ts (var-inr y) = [ I ]ⁱ ts y [∘ⁱ] {I = I} {J = J} (tm-oper f es) = ≈-oper (λ i → ≈-trans ([]ⁱ-resp-≈ⁱ (es i) (⇑ⁱ-resp-∘ⁱ {I = I})) ([∘ⁱ] (es i))) -- The category of metacontext and instantiations module _ {Γ} where open import Categories.Category Metacontexts-Insts : Category ℓ ℓ ℓ Metacontexts-Insts = record { Obj = MContext --VContext ; _⇒_ = _⇒ⁱ_⊕ Γ ; _≈_ = _≈ⁱ_ ; id = idⁱ ; _∘_ = _∘ⁱ_ ; assoc = λ {Θ} {Ω} {ψ} {Ξ} {K} {J} {I} {Γᴹ} {Aᴹ} M → ≈-trans ([]ⁱ-resp-≈ⁱ (K M) (⇑ⁱ-resp-∘ⁱ {Δ = Γᴹ} {I = J} {J = I})) ([∘ⁱ] (K M)) ; sym-assoc = λ {Θ} {Ω} {ψ} {Ξ} {K} {J} {I} {Γᴹ} {Aᴹ} M → ≈-sym ( ≈-trans ([]ⁱ-resp-≈ⁱ (K M) (⇑ⁱ-resp-∘ⁱ {Δ = Γᴹ} {I = J} {J = I})) ([∘ⁱ] (K M))) ; identityˡ = λ M → [idⁱ] ; identityʳ = λ {A} {B} {I} M → ≈-trans (≈-trans (≈-sym ([ˢ∘ᵛ] (I M))) ([]ˢ-resp-≈ˢ (I M) λ x → idʳ x)) [idˢ] ; identity² = λ M → ≈-refl ; equiv = record { refl = λ {I} → ≈ⁱ-refl {I = I} ; sym = ≈ⁱ-sym ; trans = ≈ⁱ-trans } ; ∘-resp-≈ = λ {Θ} {Ω} {ψ} {I} {J} {K} {L} ξ₁ ξ₂ M → ≈-trans ([]ⁱ-resp-≈ (⇑ⁱ I) (ξ₂ M)) ([]ⁱ-resp-≈ⁱ (L M) (⇑ⁱ-resp-≈ⁱ I J ξ₁)) } where idʳ : ∀ {Θ Δ A} (x : A ∈ (Γ ,, Δ)) → [ tm-var , (λ i → tm-var (var-inr i)) ]ˢ ([ (λ x₁ → var-inl {Γ = Γ ,, Δ} (var-inl x₁)) , (λ x₁ → var-inr x₁) ]ᵛ x) ≈ tm-var {Θ = Θ} x idʳ (var-inl x) = ≈-refl idʳ (var-inr x) = ≈-refl
36.478114
119
0.415451
58b945f0a631db5bfeef6051330b42426579cf35
11,639
agda
Agda
Cubical/Algebra/Ring/QuotientRing.agda
thomas-lamiaux/cubical
58c0b83bb0fed0dc683f3d29b1709effe51c1689
[ "MIT" ]
null
null
null
Cubical/Algebra/Ring/QuotientRing.agda
thomas-lamiaux/cubical
58c0b83bb0fed0dc683f3d29b1709effe51c1689
[ "MIT" ]
null
null
null
Cubical/Algebra/Ring/QuotientRing.agda
thomas-lamiaux/cubical
58c0b83bb0fed0dc683f3d29b1709effe51c1689
[ "MIT" ]
null
null
null
{-# OPTIONS --safe #-} module Cubical.Algebra.Ring.QuotientRing where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Structure open import Cubical.Foundations.Powerset using (_∈_; _⊆_; ⊆-extensionality) -- \in, \sub= open import Cubical.Data.Sigma using (Σ≡Prop) open import Cubical.Relation.Binary open import Cubical.HITs.SetQuotients.Base renaming (_/_ to _/ₛ_) open import Cubical.HITs.SetQuotients.Properties open import Cubical.Algebra.Ring open import Cubical.Algebra.Ring.Ideal open import Cubical.Algebra.Ring.Kernel open import Cubical.Algebra.CommRingSolver.Reflection private variable ℓ ℓ' : Level module _ (R' : Ring ℓ) (I : ⟨ R' ⟩ → hProp ℓ) (I-isIdeal : isIdeal R' I) where open RingStr (snd R') private R = ⟨ R' ⟩ open isIdeal I-isIdeal open RingTheory R' R/I : Type ℓ R/I = R /ₛ (λ x y → x - y ∈ I) private homogeneity : ∀ (x a b : R) → (a - b ∈ I) → (x + a) - (x + b) ∈ I homogeneity x a b p = subst (λ u → u ∈ I) (translatedDifference x a b) p isSetR/I : isSet R/I isSetR/I = squash/ [_]/I : (a : R) → R/I [ a ]/I = [ a ] lemma : (x y a : R) → x - y ∈ I → [ x + a ]/I ≡ [ y + a ]/I lemma x y a x-y∈I = eq/ (x + a) (y + a) (subst (λ u → u ∈ I) calculate x-y∈I) where calculate : x - y ≡ (x + a) - (y + a) calculate = x - y ≡⟨ translatedDifference a x y ⟩ ((a + x) - (a + y)) ≡⟨ cong (λ u → u - (a + y)) (+Comm _ _) ⟩ ((x + a) - (a + y)) ≡⟨ cong (λ u → (x + a) - u) (+Comm _ _) ⟩ ((x + a) - (y + a)) ∎ pre-+/I : R → R/I → R/I pre-+/I x = elim (λ _ → squash/) (λ y → [ x + y ]) λ y y' diffrenceInIdeal → eq/ (x + y) (x + y') (homogeneity x y y' diffrenceInIdeal) pre-+/I-DescendsToQuotient : (x y : R) → (x - y ∈ I) → pre-+/I x ≡ pre-+/I y pre-+/I-DescendsToQuotient x y x-y∈I i r = pointwise-equal r i where pointwise-equal : ∀ (u : R/I) → pre-+/I x u ≡ pre-+/I y u pointwise-equal = elimProp (λ u → isSetR/I (pre-+/I x u) (pre-+/I y u)) (λ a → lemma x y a x-y∈I) _+/I_ : R/I → R/I → R/I x +/I y = (elim R/I→R/I-isSet pre-+/I pre-+/I-DescendsToQuotient x) y where R/I→R/I-isSet : R/I → isSet (R/I → R/I) R/I→R/I-isSet _ = isSetΠ (λ _ → squash/) -- Note that _+/I_ reduces in this case: _ : (x y : R) → [ x ] +/I [ y ] ≡ [ x + y ] _ = λ x y → refl +/I-comm : (x y : R/I) → x +/I y ≡ y +/I x +/I-comm = elimProp2 (λ _ _ → squash/ _ _) eq where eq : (x y : R) → [ x ] +/I [ y ] ≡ [ y ] +/I [ x ] eq x y i = [ +Comm x y i ] +/I-assoc : (x y z : R/I) → x +/I (y +/I z) ≡ (x +/I y) +/I z +/I-assoc = elimProp3 (λ _ _ _ → squash/ _ _) eq where eq : (x y z : R) → [ x ] +/I ([ y ] +/I [ z ]) ≡ ([ x ] +/I [ y ]) +/I [ z ] eq x y z i = [ +Assoc x y z i ] 0/I : R/I 0/I = [ 0r ] 1/I : R/I 1/I = [ 1r ] -/I : R/I → R/I -/I = elim (λ _ → squash/) (λ x' → [ - x' ]) eq where eq : (x y : R) → (x - y ∈ I) → [ - x ] ≡ [ - y ] eq x y x-y∈I = eq/ (- x) (- y) (subst (λ u → u ∈ I) eq' (isIdeal.-closed I-isIdeal x-y∈I)) where eq' = - (x + (- y)) ≡⟨ sym (-Dist _ _) ⟩ (- x) - (- y) ∎ +/I-rinv : (x : R/I) → x +/I (-/I x) ≡ 0/I +/I-rinv = elimProp (λ x → squash/ _ _) eq where eq : (x : R) → [ x ] +/I (-/I [ x ]) ≡ 0/I eq x i = [ +InvR x i ] +/I-rid : (x : R/I) → x +/I 0/I ≡ x +/I-rid = elimProp (λ x → squash/ _ _) eq where eq : (x : R) → [ x ] +/I 0/I ≡ [ x ] eq x i = [ +IdR x i ] _·/I_ : R/I → R/I → R/I _·/I_ = elim (λ _ → isSetΠ (λ _ → squash/)) (λ x → left· x) eq' where eq : (x y y' : R) → (y - y' ∈ I) → [ x · y ] ≡ [ x · y' ] eq x y y' y-y'∈I = eq/ _ _ (subst (λ u → u ∈ I) (x · (y - y') ≡⟨ ·DistR+ _ _ _ ⟩ ((x · y) + x · (- y')) ≡⟨ cong (λ u → (x · y) + u) (-DistR· x y') ⟩ (x · y) - (x · y') ∎) (isIdeal.·-closedLeft I-isIdeal x y-y'∈I)) left· : (x : R) → R/I → R/I left· x = elim (λ y → squash/) (λ y → [ x · y ]) (eq x) eq' : (x x' : R) → (x - x' ∈ I) → left· x ≡ left· x' eq' x x' x-x'∈I i y = elimProp (λ y → squash/ (left· x y) (left· x' y)) (λ y → eq′ y) y i where eq′ : (y : R) → left· x [ y ] ≡ left· x' [ y ] eq′ y = eq/ (x · y) (x' · y) (subst (λ u → u ∈ I) ((x - x') · y ≡⟨ ·DistL+ x (- x') y ⟩ x · y + (- x') · y ≡⟨ cong (λ u → x · y + u) (-DistL· x' y) ⟩ x · y - x' · y ∎) (isIdeal.·-closedRight I-isIdeal y x-x'∈I)) -- more or less copy paste from '+/I' - this is preliminary anyway ·/I-assoc : (x y z : R/I) → x ·/I (y ·/I z) ≡ (x ·/I y) ·/I z ·/I-assoc = elimProp3 (λ _ _ _ → squash/ _ _) eq where eq : (x y z : R) → [ x ] ·/I ([ y ] ·/I [ z ]) ≡ ([ x ] ·/I [ y ]) ·/I [ z ] eq x y z i = [ ·Assoc x y z i ] ·/I-lid : (x : R/I) → 1/I ·/I x ≡ x ·/I-lid = elimProp (λ x → squash/ _ _) eq where eq : (x : R) → 1/I ·/I [ x ] ≡ [ x ] eq x i = [ ·IdL x i ] ·/I-rid : (x : R/I) → x ·/I 1/I ≡ x ·/I-rid = elimProp (λ x → squash/ _ _) eq where eq : (x : R) → [ x ] ·/I 1/I ≡ [ x ] eq x i = [ ·IdR x i ] /I-ldist : (x y z : R/I) → (x +/I y) ·/I z ≡ (x ·/I z) +/I (y ·/I z) /I-ldist = elimProp3 (λ _ _ _ → squash/ _ _) eq where eq : (x y z : R) → ([ x ] +/I [ y ]) ·/I [ z ] ≡ ([ x ] ·/I [ z ]) +/I ([ y ] ·/I [ z ]) eq x y z i = [ ·DistL+ x y z i ] /I-rdist : (x y z : R/I) → x ·/I (y +/I z) ≡ (x ·/I y) +/I (x ·/I z) /I-rdist = elimProp3 (λ _ _ _ → squash/ _ _) eq where eq : (x y z : R) → [ x ] ·/I ([ y ] +/I [ z ]) ≡ ([ x ] ·/I [ y ]) +/I ([ x ] ·/I [ z ]) eq x y z i = [ ·DistR+ x y z i ] asRing : Ring ℓ asRing = makeRing 0/I 1/I _+/I_ _·/I_ -/I isSetR/I +/I-assoc +/I-rid +/I-rinv +/I-comm ·/I-assoc ·/I-rid ·/I-lid /I-rdist /I-ldist _/_ : (R : Ring ℓ) → (I : IdealsIn R) → Ring ℓ R / (I , IisIdeal) = asRing R I IisIdeal [_]/I : {R : Ring ℓ} {I : IdealsIn R} → (a : ⟨ R ⟩) → ⟨ R / I ⟩ [ a ]/I = [ a ] quotientHom : (R : Ring ℓ) → (I : IdealsIn R) → RingHom R (R / I) fst (quotientHom R I) = [_] IsRingHom.pres0 (snd (quotientHom R I)) = refl IsRingHom.pres1 (snd (quotientHom R I)) = refl IsRingHom.pres+ (snd (quotientHom R I)) _ _ = refl IsRingHom.pres· (snd (quotientHom R I)) _ _ = refl IsRingHom.pres- (snd (quotientHom R I)) _ = refl module UniversalProperty (R : Ring ℓ) (I : IdealsIn R) where open RingStr ⦃...⦄ open RingTheory ⦃...⦄ Iₛ = fst I private instance _ = R _ = snd R module _ {S : Ring ℓ'} (φ : RingHom R S) where open IsRingHom open RingHomTheory φ private instance _ = S _ = snd S f = fst φ module φ = IsRingHom (snd φ) {- We do not use the kernel ideal, since it is *not* an ideal in R, if S is from a different universe. Instead, the condition, that Iₛ is contained in the kernel of φ is rephrased explicitly. -} inducedHom : ((x : ⟨ R ⟩) → x ∈ Iₛ → φ $ x ≡ 0r) → RingHom (R / I) S fst (inducedHom Iₛ⊆kernel) = elim (λ _ → isSetRing S) f λ r₁ r₂ r₁-r₂∈I → equalByDifference (f r₁) (f r₂) (f r₁ - f r₂ ≡⟨ cong (λ u → f r₁ + u) (sym (φ.pres- _)) ⟩ f r₁ + f (- r₂) ≡⟨ sym (φ.pres+ _ _) ⟩ f (r₁ - r₂) ≡⟨ Iₛ⊆kernel (r₁ - r₂) r₁-r₂∈I ⟩ 0r ∎) pres0 (snd (inducedHom Iₛ⊆kernel)) = φ.pres0 pres1 (snd (inducedHom Iₛ⊆kernel)) = φ.pres1 pres+ (snd (inducedHom Iₛ⊆kernel)) = elimProp2 (λ _ _ → isSetRing S _ _) φ.pres+ pres· (snd (inducedHom Iₛ⊆kernel)) = elimProp2 (λ _ _ → isSetRing S _ _) φ.pres· pres- (snd (inducedHom Iₛ⊆kernel)) = elimProp (λ _ → isSetRing S _ _) φ.pres- solution : (p : ((x : ⟨ R ⟩) → x ∈ Iₛ → φ $ x ≡ 0r)) → (x : ⟨ R ⟩) → inducedHom p $ [ x ] ≡ φ $ x solution p x = refl unique : (p : ((x : ⟨ R ⟩) → x ∈ Iₛ → φ $ x ≡ 0r)) → (ψ : RingHom (R / I) S) → (ψIsSolution : (x : ⟨ R ⟩) → ψ $ [ x ] ≡ φ $ x) → (x : ⟨ R ⟩) → ψ $ [ x ] ≡ inducedHom p $ [ x ] unique p ψ ψIsSolution x = ψIsSolution x {- Show that the kernel of the quotient map π : R ─→ R/I is the given ideal I. -} module idealIsKernel {R : Ring ℓ} (I : IdealsIn R) where open RingStr (snd R) open isIdeal (snd I) open BinaryRelation.isEquivRel private π = quotientHom R I x-0≡x : (x : ⟨ R ⟩) → x - 0r ≡ x x-0≡x x = x - 0r ≡⟨ cong (x +_) (RingTheory.0Selfinverse R) ⟩ x + 0r ≡⟨ +IdR x ⟩ x ∎ I⊆ker : fst I ⊆ kernel π I⊆ker x x∈I = eq/ _ _ (subst (_∈ fst I) (sym (x-0≡x x)) x∈I) private _~_ : Rel ⟨ R ⟩ ⟨ R ⟩ ℓ x ~ y = x - y ∈ fst I ~IsPropValued : BinaryRelation.isPropValued _~_ ~IsPropValued x y = snd (fst I (x - y)) -- _~_ is an equivalence relation. -- Note: This could be proved in the general setting of a subgroup of a group. -[x-y]≡y-x : {x y : ⟨ R ⟩} → - (x - y) ≡ y - x -[x-y]≡y-x {x} {y} = - (x - y) ≡⟨ sym (-Dist _ _) ⟩ - x + - (- y) ≡⟨ cong (- x +_) (-Idempotent _) ⟩ - x + y ≡⟨ +Comm _ _ ⟩ y - x ∎ where open RingTheory R x-y+y-z≡x-z : {x y z : ⟨ R ⟩} → (x - y) + (y - z) ≡ x - z x-y+y-z≡x-z {x} {y} {z} = (x + - y) + (y + - z) ≡⟨ +Assoc _ _ _ ⟩ ((x + - y) + y) + - z ≡⟨ cong (_+ - z) (sym (+Assoc _ _ _)) ⟩ (x + (- y + y)) + - z ≡⟨ cong (λ -y+y → (x + -y+y) + - z) (+InvL _) ⟩ (x + 0r) + - z ≡⟨ cong (_+ - z) (+IdR _) ⟩ x - z ∎ ~IsEquivRel : BinaryRelation.isEquivRel _~_ reflexive ~IsEquivRel x = subst (_∈ fst I) (sym (+InvR x)) 0r-closed symmetric ~IsEquivRel x y x~y = subst (_∈ fst I) -[x-y]≡y-x (-closed x~y) transitive ~IsEquivRel x y z x~y y~z = subst (_∈ fst I) x-y+y-z≡x-z (+-closed x~y y~z) ker⊆I : kernel π ⊆ fst I ker⊆I x x∈ker = subst (_∈ fst I) (x-0≡x x) x-0∈I where x-0∈I : x - 0r ∈ fst I x-0∈I = effective ~IsPropValued ~IsEquivRel x 0r x∈ker kernel≡I : {R : Ring ℓ} (I : IdealsIn R) → kernelIdeal (quotientHom R I) ≡ I kernel≡I {R = R} I = Σ≡Prop (isPropIsIdeal R) (⊆-extensionality _ _ (ker⊆I , I⊆ker)) where open idealIsKernel I
36.258567
98
0.414383
c79988714b1e3b49fb174545a05e11b9850746f4
1,590
agda
Agda
src/sets/int/utils.agda
pcapriotti/agda-base
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
[ "BSD-3-Clause" ]
20
2015-06-12T12:20:17.000Z
2022-02-01T11:25:54.000Z
src/sets/int/utils.agda
pcapriotti/agda-base
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
[ "BSD-3-Clause" ]
4
2015-02-02T14:32:16.000Z
2016-10-26T11:57:26.000Z
src/sets/int/utils.agda
pcapriotti/agda-base
bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c
[ "BSD-3-Clause" ]
4
2015-02-02T12:17:00.000Z
2019-05-04T19:31:00.000Z
{-# OPTIONS --without-K #-} module sets.int.utils where open import sum open import equality open import function open import sets.nat.core open import sets.int.definition open import hott.level module _ {i}{X : Set i}(hX : h 2 X) (f : ℕ → ℕ → ℕ → ℕ → X) (u : ∀ n n' d m m' e → f n n' m m' ≡ f (d + n) (d + n') (e + m) (e + m')) where private g : ℕ → ℕ → ℤ → X g n n' = elim-ℤ hX (f n n' , u n n' 0) lem : (n n' d m m' : ℕ) → g n n' (m [-] m') ≡ g (d + n) (d + n') (m [-] m') lem n n' d m m' = u n n' d m m' 0 v : (n n' d : ℕ) → g n n' ≡ g (d + n) (d + n') v n n' d = funext λ m → elim-prop-ℤ (λ m → hX (g n n' m) (g (d + n) (d + n') m)) (lem n n' d) m hX' : h 2 (ℤ → X) hX' = Π-level λ _ → hX elim₂-ℤ : ℤ → ℤ → X elim₂-ℤ = elim-ℤ hX' (g , v) elim₂-prop-ℤ : ∀ {i}{X : ℤ → ℤ → Set i} → (∀ n m → h 1 (X n m)) → ((n n' m m' : ℕ) → X (n [-] n') (m [-] m')) → ∀ n m → X n m elim₂-prop-ℤ {i}{X} hX f = elim-prop-ℤ hX' g where g : (n n' : ℕ) → ∀ m → X (n [-] n') m g n n' = elim-prop-ℤ (hX (n [-] n')) (f n n') hX' : ∀ n → h 1 (∀ m → X n m) hX' n = Π-level λ m → hX n m elim₃-prop-ℤ : ∀ {i}{X : ℤ → ℤ → ℤ → Set i} → (∀ n m p → h 1 (X n m p)) → ((n n' m m' p p' : ℕ) → X (n [-] n') (m [-] m') (p [-] p')) → ∀ n m p → X n m p elim₃-prop-ℤ {i}{X} hX f = elim-prop-ℤ hX' g where g : (n n' : ℕ) → ∀ m p → X (n [-] n') m p g n n' = elim₂-prop-ℤ (hX (n [-] n')) (f n n') hX' : ∀ n → h 1 (∀ m p → X n m p) hX' n = Π-level λ m → Π-level λ p → hX n m p
28.909091
81
0.400629
06d30e15542d2eb3b625e0dcfb0f494f80aa1277
1,233
agda
Agda
test/Fail/Issue2944.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue2944.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue2944.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module _ where open import Agda.Primitive open import Agda.Builtin.List open import Agda.Builtin.Nat hiding (_==_) open import Agda.Builtin.Equality open import Agda.Builtin.Unit open import Agda.Builtin.Bool infix -1 _,_ record _×_ {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where constructor _,_ field fst : A snd : B open _×_ data Constraint : Set₁ where mkConstraint : {A : Set} (x y : A) → x ≡ y → Constraint infix 0 _==_ pattern _==_ x y = mkConstraint x y refl T : Bool → Set T false = Nat T true = Nat → Nat bla : (Nat → Nat) → Nat → Nat bla f zero = zero bla f = f -- underapplied clause! pred : Nat → Nat pred zero = zero pred (suc n) = n -- 0 and 1 are both solutions, so should not be solved. bad! : Constraint bad! = bla pred _ == zero -- Should not fail, since 2 is a solution! more-bad! : Constraint more-bad! = bla pred _ == 1 -- Same thing for projections blabla : Nat → Nat × Nat blabla zero = 1 , 1 blabla (suc n) = 0 , n -- Don't fail: 0 is a valid solution oops : Constraint oops = fst (blabla _) == 1 bla₂ : Bool → Nat × Nat bla₂ false = 0 , 1 bla₂ true .fst = 0 bla₂ true .snd = 1 -- Don't solve: false and true are both solutions wrong : Constraint wrong = bla₂ _ .fst == 0
19.887097
60
0.651257
23a2adde7eeb41123fcb8ecc31d928009d4a8a29
1,632
agda
Agda
Parametric/Denotation/MValue.agda
inc-lc/ilc-agda
39bb081c6f192bdb87bd58b4a89291686d2d7d03
[ "MIT" ]
10
2015-03-04T06:09:20.000Z
2019-07-19T07:06:59.000Z
Parametric/Denotation/MValue.agda
inc-lc/ilc-agda
39bb081c6f192bdb87bd58b4a89291686d2d7d03
[ "MIT" ]
6
2015-07-01T18:09:31.000Z
2017-05-04T13:53:59.000Z
Parametric/Denotation/MValue.agda
inc-lc/ilc-agda
39bb081c6f192bdb87bd58b4a89291686d2d7d03
[ "MIT" ]
1
2016-02-18T12:26:44.000Z
2016-02-18T12:26:44.000Z
------------------------------------------------------------------------ -- 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 )
29.672727
72
0.626838
58028dbd789ddc0f6b24a01e10c5419c3bad3a56
683
agda
Agda
UniDB/Subst/Subs.agda
skeuchel/unidb-agda
7ae52205db44ad4f463882ba7e5082120fb76349
[ "MIT" ]
null
null
null
UniDB/Subst/Subs.agda
skeuchel/unidb-agda
7ae52205db44ad4f463882ba7e5082120fb76349
[ "MIT" ]
null
null
null
UniDB/Subst/Subs.agda
skeuchel/unidb-agda
7ae52205db44ad4f463882ba7e5082120fb76349
[ "MIT" ]
null
null
null
module UniDB.Subst.Subs where open import UniDB.Subst.Core open import UniDB.Morph.Subs -------------------------------------------------------------------------------- module _ {T : STX} {{vrT : Vr T}} {{wkT : Wk T}} {{apTT : Ap T T}} where instance iCompSubs : Comp (Subs T) _⊙_ {{iCompSubs}} (refl) ξ₂ = ξ₂ _⊙_ {{iCompSubs}} (step ξ₁ t) ξ₂ = step (ξ₁ ⊙ ξ₂) (ap {T} ξ₂ t ) _⊙_ {{iCompSubs}} (skip ξ₁) refl = skip ξ₁ _⊙_ {{iCompSubs}} (skip ξ₁) (step ξ₂ t) = step (ξ₁ ⊙ ξ₂) t _⊙_ {{iCompSubs}} (skip ξ₁) (skip ξ₂) = skip (ξ₁ ⊙ ξ₂) --------------------------------------------------------------------------------
34.15
80
0.408492
3d786101983b5e69d4e3a970b3dee3b8422bcb13
254
agda
Agda
theorems/cw/examples/Unit.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
294
2015-01-09T16:23:23.000Z
2022-03-20T13:54:45.000Z
theorems/cw/examples/Unit.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
31
2015-03-05T20:09:00.000Z
2021-10-03T19:15:25.000Z
theorems/cw/examples/Unit.agda
AntoineAllioux/HoTT-Agda
1037d82edcf29b620677a311dcfd4fc2ade2faa6
[ "MIT" ]
50
2015-01-10T01:48:08.000Z
2022-02-14T03:03:25.000Z
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import cw.CW module cw.examples.Unit where cw-unit-skel : Skeleton {lzero} 0 cw-unit-skel = Unit , ⟨⟩ CWUnit = ⟦ cw-unit-skel ⟧ CWUnit-equiv-Unit : CWUnit ≃ Unit CWUnit-equiv-Unit = ide _
18.142857
39
0.688976
ad55d2e15966bb2e23dc184372bb7667296ec66d
1,070
agda
Agda
test/Fail/Issue1342a.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue1342a.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue1342a.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- {-# OPTIONS --show-implicit #-} -- {-# OPTIONS -v tc.with.top:25 #-} -- {-# OPTIONS -v tc.with:40 -v tc.interaction:20 -v interaction.give:20 -v tc:10 #-} open import Common.Equality data Unit : Set where unit : Unit id : (A : Set) → A → A id A a = a module Works where dx : (x : Unit) → Unit → Unit dx x unit = x g : (x : Unit) → ∀ u → x ≡ dx x u g x with x g x | unit = id ((u : Unit) → unit ≡ dx unit u) ? -- Now if we make (x : Unit) a module parameter -- then we turn all applications (dx _) into just dx, -- which actually means (dx x), i.e., dx applied to -- the module free variables. -- This leads to an incomprehendable rejection -- of the following code (culprit is the first argument to id). module M (x : Unit) where dx : Unit → Unit dx unit = x g : ∀ u → x ≡ dx u g with x g | unit = id ((u : Unit) → unit ≡ dx u) ? -- Now, `with x` is a plain error. -- Also in harmless cases like the one below: module CollateralDamage (x : Unit) where x′ = x bla : x ≡ x′ bla with x bla | unit = id (unit ≡ unit) refl
20.980392
85
0.593458
220deb7d7d11cc35f29c7787ee41821e43da0002
693
agda
Agda
old/Structure/Logic/Classical/SetTheory/ZFC/Finite.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
6
2020-04-07T17:58:13.000Z
2022-02-05T06:53:22.000Z
old/Structure/Logic/Classical/SetTheory/ZFC/Finite.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
old/Structure/Logic/Classical/SetTheory/ZFC/Finite.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
Finite : Domain → Formula Finite(s) = ∃ₛ(ℕ)(n ↦ s ≼ 𝕟(n)) -- TODO: Now this means that there is an injection (s → 𝕟(n)), which is equivalent to the existance of an surjection (𝕟(n) → s) because stuff that follows from excluded middle (more specifically ((s ≼ 𝕟(n)) ↔ (𝕟(n) ≽ s))). Define ∑ (summation over finite sets) by using the existance of a finite sequence -- reduce : (_▫_ : Domain → Domain → Domain) → ⦃ _ : Commutativity(_▫_) ⦄ → ⦃ _ : Associativity(_▫_) ⦄ → ⦃ _ : Identity(_▫_) ⦄ → (s : Domain) → ⦃ _ : Finite(s) ⦄ → Domain -- reduce₀ : (_▫_ : Domain → Domain → Domain) → ⦃ _ : Commutativity(_▫_) ⦄ → ⦃ _ : Associativity(_▫_) ⦄ → (s : Domain) → ⦃ _ : Finite(s) ⦄ → Domain → Domain
99
336
0.613276
22006800de83af86f9d3e258bb447593fb46cc7d
1,540
agda
Agda
src/STLC/Type/Relation.agda
johnyob/agda-types
aeb2be63381d891fabe5317e3c27553deb6bca6d
[ "MIT" ]
null
null
null
src/STLC/Type/Relation.agda
johnyob/agda-types
aeb2be63381d891fabe5317e3c27553deb6bca6d
[ "MIT" ]
null
null
null
src/STLC/Type/Relation.agda
johnyob/agda-types
aeb2be63381d891fabe5317e3c27553deb6bca6d
[ "MIT" ]
null
null
null
module STLC.Type.Relation where open import Data.Nat using (ℕ) open import Data.Fin using (Fin) open import STLC.Term open import STLC.Type open import STLC.Type.Context using (Ctxt) open import Data.Vec using (_∷_; lookup) open import Relation.Nullary using (¬_) open import Relation.Binary.PropositionalEquality as Eq using (refl; _≡_; sym; cong) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎) infix 4 _⊢_⦂_ data _⊢_⦂_ { m n } (Γ : Ctxt m n) : Term m -> Type n -> Set where ⊢# : ∀ { x : Fin m } -- --------------- -> Γ ⊢ # x ⦂ lookup Γ x ⊢ƛ : ∀ { t τ₁ τ₂ } -> τ₁ ∷ Γ ⊢ t ⦂ τ₂ -- ----------------- -> Γ ⊢ ƛ t ⦂ τ₁ ⇒ τ₂ ⊢_·_ : ∀ { t₁ t₂ τ₁ τ₂ } -> Γ ⊢ t₁ ⦂ τ₁ ⇒ τ₂ -> Γ ⊢ t₂ ⦂ τ₁ -- ------------------ -> Γ ⊢ t₁ · t₂ ⦂ τ₂ _⊬_⦂_ : ∀ { m n } -> Ctxt m n -> Term m -> Type n -> Set Γ ⊬ t ⦂ τ = ¬ (Γ ⊢ t ⦂ τ) module Lemmas₀ where ⊢-subst : ∀ { m n } { Γ₁ Γ₂ : Ctxt m n } { t₁ t₂ : Term m } { τ₁ τ₂ : Type n } -> Γ₁ ≡ Γ₂ -> t₁ ≡ t₂ -> τ₁ ≡ τ₂ -> Γ₁ ⊢ t₁ ⦂ τ₁ -> Γ₂ ⊢ t₂ ⦂ τ₂ ⊢-subst refl refl refl hyp = hyp ⊢-Γ-subst : ∀ { m n } { Γ₁ Γ₂ : Ctxt m n } { t : Term m } { τ : Type n } -> Γ₁ ≡ Γ₂ -> Γ₁ ⊢ t ⦂ τ -> Γ₂ ⊢ t ⦂ τ ⊢-Γ-subst ≡-Γ hyp = ⊢-subst ≡-Γ refl refl hyp ⊢-τ-subst : ∀ { m n } { Γ : Ctxt m n } { t : Term m } { τ₁ τ₂ : Type n } -> τ₁ ≡ τ₂ -> Γ ⊢ t ⦂ τ₁ -> Γ ⊢ t ⦂ τ₂ ⊢-τ-subst ≡-τ hyp = ⊢-subst refl refl ≡-τ hyp -- TODO: Substitutions on typing derivations -- TODO: Equivalent for Value e.g. value ⦂ τ relation w/ some lemmas :)
25.666667
81
0.496753
d07aa9ede46b1aa632e5a278ba01a4bce807583e
3,673
agda
Agda
Cubical/Codata/M/AsLimit/helper.agda
ryanorendorff/cubical
c67854d2e11aafa5677e25a09087e176fafd3e43
[ "MIT" ]
1
2020-03-23T23:52:11.000Z
2020-03-23T23:52:11.000Z
Cubical/Codata/M/AsLimit/helper.agda
ryanorendorff/cubical
c67854d2e11aafa5677e25a09087e176fafd3e43
[ "MIT" ]
null
null
null
Cubical/Codata/M/AsLimit/helper.agda
ryanorendorff/cubical
c67854d2e11aafa5677e25a09087e176fafd3e43
[ "MIT" ]
null
null
null
{-# OPTIONS --cubical --guardedness --safe #-} module Cubical.Codata.M.AsLimit.helper where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv using (_≃_) open import Cubical.Foundations.Function using (_∘_) open import Cubical.Data.Unit open import Cubical.Data.Prod open import Cubical.Data.Nat as ℕ using (ℕ ; suc ; _+_ ) open import Cubical.Data.Sigma hiding (_×_) open import Cubical.Foundations.Transport open import Cubical.Foundations.Univalence open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Path open import Cubical.Functions.Embedding open import Cubical.Functions.FunExtEquiv open Iso -- General iso→fun-Injection : ∀ {ℓ} {A B C : Type ℓ} (isom : Iso A B) → ∀ {f g : C -> A} → (x : C) → (Iso.fun isom (f x) ≡ Iso.fun isom (g x)) ≡ (f x ≡ g x) iso→fun-Injection {A = A} {B} {C} isom {f = f} {g} = isEmbedding→Injection {A = A} {B} {C} (Iso.fun isom) (iso→isEmbedding {A = A} {B} isom) {f = f} {g = g} abstract iso→Pi-fun-Injection : ∀ {ℓ} {A B C : Type ℓ} (isom : Iso A B) → ∀ {f g : C -> A} → Iso (∀ x → (fun isom) (f x) ≡ (fun isom) (g x)) (∀ x → f x ≡ g x) iso→Pi-fun-Injection {A = A} {B} {C} isom {f = f} {g} = pathToIso (cong (λ k → ∀ x → k x) (funExt (iso→fun-Injection isom {f = f} {g = g}))) iso→fun-Injection-Iso : ∀ {ℓ} {A B C : Type ℓ} (isom : Iso A B) → ∀ {f g : C -> A} → Iso (fun isom ∘ f ≡ fun isom ∘ g) (f ≡ g) iso→fun-Injection-Iso {A = A} {B} {C} isom {f = f} {g} = (fun isom) ∘ f ≡ (fun isom) ∘ g Iso⟨ invIso funExtIso ⟩ (∀ x → (fun isom) (f x) ≡ (fun isom) (g x)) Iso⟨ iso→Pi-fun-Injection isom ⟩ (∀ x → f x ≡ g x) Iso⟨ funExtIso ⟩ f ≡ g ∎Iso iso→fun-Injection-Path : ∀ {ℓ} {A B C : Type ℓ} (isom : Iso A B) → ∀ {f g : C -> A} → (fun isom ∘ f ≡ fun isom ∘ g) ≡ (f ≡ g) iso→fun-Injection-Path {A = A} {B} {C} isom {f = f} {g} = isoToPath (iso→fun-Injection-Iso isom) iso→inv-Injection-Path : ∀ {ℓ} {A B C : Type ℓ} (isom : Iso A B) → ∀ {f g : C -> B} → ----------------------- ((inv isom) ∘ f ≡ (inv isom) ∘ g) ≡ (f ≡ g) iso→inv-Injection-Path {A = A} {B} {C} isom {f = f} {g} = iso→fun-Injection-Path (invIso isom) iso→fun-Injection-Iso-x : ∀ {ℓ} {A B : Type ℓ} → (isom : Iso A B) → ∀ {x y : A} → Iso ((fun isom) x ≡ (fun isom) y) (x ≡ y) iso→fun-Injection-Iso-x isom {x} {y} = let tempx = λ {(lift tt) → x} tempy = λ {(lift tt) → y} in fun isom x ≡ fun isom y Iso⟨ iso (λ x₁ t → x₁) (λ x₁ → x₁ (lift tt)) (λ x → refl) (λ x → refl) ⟩ (∀ (t : Lift Unit) -> (((fun isom) ∘ tempx) t ≡ ((fun isom) ∘ tempy) t)) Iso⟨ iso→Pi-fun-Injection isom ⟩ (∀ (t : Lift Unit) -> tempx t ≡ tempy t) Iso⟨ iso (λ x₁ → x₁ (lift tt)) (λ x₁ t → x₁) (λ x → refl) (λ x → refl) ⟩ x ≡ y ∎Iso iso→inv-Injection-Iso-x : ∀ {ℓ} {A B : Type ℓ} → (isom : Iso A B) → ∀ {x y : B} → Iso ((inv isom) x ≡ (inv isom) y) (x ≡ y) iso→inv-Injection-Iso-x {A = A} {B = B} isom = iso→fun-Injection-Iso-x {A = B} {B = A} (invIso isom) iso→fun-Injection-Path-x : ∀ {ℓ} {A B : Type ℓ} → (isom : Iso A B) → ∀ {x y : A} → ((fun isom) x ≡ (fun isom) y) ≡ (x ≡ y) iso→fun-Injection-Path-x isom {x} {y} = isoToPath (iso→fun-Injection-Iso-x isom) iso→inv-Injection-Path-x : ∀ {ℓ} {A B : Type ℓ} → (isom : Iso A B) → ∀ {x y : B} → ((inv isom) x ≡ (inv isom) y) ≡ (x ≡ y) iso→inv-Injection-Path-x isom = isoToPath (iso→inv-Injection-Iso-x isom)
31.393162
105
0.548053
044fcacf66a805f329b9f447583227ade1d049d3
1,266
agda
Agda
test/Compiler/simple/Issue3410.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Compiler/simple/Issue3410.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Compiler/simple/Issue3410.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
open import Common.IO open import Agda.Builtin.String open import Agda.Builtin.Unit open import Agda.Builtin.Nat open import Agda.Builtin.Sigma open import Agda.Builtin.Equality open import Agda.Builtin.Bool open import Agda.Builtin.Strict data ∋⋆ : Set where Z : ∋⋆ data ⊢⋆ : Set where size⋆ : Nat → ⊢⋆ ⋆Sub : Set ⋆Sub = ∋⋆ → ⊢⋆ data TermCon : ⊢⋆ → Set where integer : (s : Nat) → TermCon (size⋆ s) data ⊢_ : ⊢⋆ → Set where con : ∀ {s} → TermCon (size⋆ s) → ⊢ size⋆ s data Value : {A : ⊢⋆} → ⊢ A → Set where V-con : ∀ {n} → (cn : TermCon (size⋆ n)) → Value (con cn) notErased : Nat → Bool notErased n = primForce n λ _ → true BUILTIN : (σ : ⋆Sub) (vtel : Σ (⊢ σ Z) Value) → Bool BUILTIN σ vtel with σ Z BUILTIN σ (_ , V-con (integer s)) | _ = notErased s -- Either of these work: -- BUILTIN σ (_ , V-con (integer s)) | size⋆ s = notErased s -- BUILTIN σ (con (integer s) , V-con (integer s)) | _ = notErased s con2 : ⊢ size⋆ 8 con2 = con (integer 8) vcon2 : Value con2 vcon2 = V-con (integer 8) builtin2plus2 : Bool builtin2plus2 = BUILTIN (λ _ → size⋆ 8) (con2 , vcon2) help : Bool → String help true = "4" help false = "something went wrong" check : "4" ≡ help builtin2plus2 check = refl main : IO ⊤ main = putStrLn (help builtin2plus2)
22.210526
68
0.635861
41cb555255f3ad06d5fb21fa219d40e90294d2f8
15,950
agda
Agda
src/toplevel-state.agda
CarlOlson/cedille
f5ce42258b7d9bc66f75cd679c785d6133b82b58
[ "MIT" ]
null
null
null
src/toplevel-state.agda
CarlOlson/cedille
f5ce42258b7d9bc66f75cd679c785d6133b82b58
[ "MIT" ]
null
null
null
src/toplevel-state.agda
CarlOlson/cedille
f5ce42258b7d9bc66f75cd679c785d6133b82b58
[ "MIT" ]
null
null
null
import cedille-options open import general-util module toplevel-state (options : cedille-options.options) {mF : Set → Set} {{_ : monad mF}} where open import lib open import cedille-types open import classify options {mF} open import ctxt open import constants open import conversion open import rename open import spans options {mF} open import syntax-util open import to-string options open import string-format open import subst open import json import cws-types record include-elt : Set where field ast : maybe start cwst : maybe cws-types.start deps : 𝕃 string {- dependencies -} import-to-dep : trie string {- map import strings in the file to their full paths -} ss : spans ⊎ string {- spans in string form (read from disk) -} err : 𝔹 -- is ss reporting an error need-to-add-symbols-to-context : 𝔹 do-type-check : 𝔹 inv : do-type-check imp need-to-add-symbols-to-context ≡ tt last-parse-time : maybe UTC cede-up-to-date : 𝔹 rkt-up-to-date : 𝔹 source : string blank-include-elt : include-elt blank-include-elt = record { ast = nothing ; cwst = nothing; deps = [] ; import-to-dep = empty-trie ; ss = inj₂ "" ; err = ff ; need-to-add-symbols-to-context = tt ; do-type-check = tt ; inv = refl ; last-parse-time = nothing; cede-up-to-date = ff ; rkt-up-to-date = ff ; source = "" } -- the dependencies should pair import strings found in the file with the full paths to those imported files new-include-elt : filepath → (dependencies : 𝕃 (string × string)) → (ast : start) → cws-types.start → maybe UTC → include-elt new-include-elt filename deps x y time = record { ast = just x ; cwst = just y ; deps = map snd deps ; import-to-dep = trie-fill empty-trie deps ; ss = inj₂ "" ; err = ff ; need-to-add-symbols-to-context = tt ; do-type-check = tt ; inv = refl ; last-parse-time = time ; cede-up-to-date = ff ; rkt-up-to-date = ff ; source = "" } error-include-elt : string → include-elt error-include-elt err = record blank-include-elt { ss = inj₂ (global-error-string err) ; err = tt } error-span-include-elt : string → string → posinfo → include-elt error-span-include-elt err errSpan pos = record blank-include-elt { ss = inj₁ (add-span (span.mk-span err pos (posinfo-plus pos 1) [] (just errSpan) ) empty-spans ) ; err = tt } set-do-type-check-include-elt : include-elt → 𝔹 → include-elt set-do-type-check-include-elt ie b = record ie { need-to-add-symbols-to-context = (b || include-elt.need-to-add-symbols-to-context ie) ; do-type-check = b ; inv = lem b } where lem : (b : 𝔹) → b imp (b || include-elt.need-to-add-symbols-to-context ie) ≡ tt lem tt = refl lem ff = refl set-need-to-add-symbols-to-context-include-elt : include-elt → 𝔹 → include-elt set-need-to-add-symbols-to-context-include-elt ie b = record ie { need-to-add-symbols-to-context = b ; do-type-check = b && include-elt.do-type-check ie ; inv = lem b } where lem : ∀(b : 𝔹){b' : 𝔹} → b && b' imp b ≡ tt lem tt {tt} = refl lem tt {ff} = refl lem ff {tt} = refl lem ff {ff} = refl set-spans-include-elt : include-elt → spans → include-elt set-spans-include-elt ie ss = record ie { ss = inj₁ ss ; err = spans-have-error ss } set-last-parse-time-include-elt : include-elt → UTC → include-elt set-last-parse-time-include-elt ie time = record ie { last-parse-time = just time } set-cede-file-up-to-date-include-elt : include-elt → 𝔹 → include-elt set-cede-file-up-to-date-include-elt ie up-to-date = record ie { cede-up-to-date = up-to-date } set-rkt-file-up-to-date-include-elt : include-elt → 𝔹 → include-elt set-rkt-file-up-to-date-include-elt ie up-to-date = record ie { rkt-up-to-date = up-to-date } set-spans-string-include-elt : include-elt → (err : 𝔹) → string → include-elt set-spans-string-include-elt ie err ss = record ie { ss = inj₂ ss ; err = err } set-source-include-elt : include-elt → string → include-elt set-source-include-elt ie source = record ie { source = source } record toplevel-state : Set where constructor mk-toplevel-state field include-path : 𝕃 string × stringset files-with-updated-spans : 𝕃 string is : trie include-elt {- keeps track of files we have parsed and/or processed -} Γ : ctxt new-toplevel-state : (include-path : 𝕃 string × stringset) → toplevel-state new-toplevel-state ip = record { include-path = ip ; files-with-updated-spans = [] ; is = empty-trie ; Γ = new-ctxt "[nofile]" "[nomod]" } toplevel-state-lookup-occurrences : var → toplevel-state → 𝕃 (var × posinfo × string) toplevel-state-lookup-occurrences symb (mk-toplevel-state _ _ _ Γ) = ctxt-lookup-occurrences Γ symb get-include-elt-if : toplevel-state → filepath → maybe include-elt get-include-elt-if s filename = trie-lookup (toplevel-state.is s) filename -- get an include-elt assuming it will be there get-include-elt : toplevel-state → filepath → include-elt get-include-elt s filename with get-include-elt-if s filename get-include-elt s filename | nothing = blank-include-elt {- should not happen -} get-include-elt s filename | just ie = ie set-include-elt : toplevel-state → filepath → include-elt → toplevel-state set-include-elt s f ie = record s { is = trie-insert (toplevel-state.is s) f ie } set-include-path : toplevel-state → 𝕃 string × stringset → toplevel-state set-include-path s ip = record s { include-path = ip } get-do-type-check : toplevel-state → string → 𝔹 get-do-type-check s filename = include-elt.do-type-check (get-include-elt s filename) include-elt-spans-to-rope : include-elt → rope include-elt-spans-to-rope ie with (include-elt.ss ie) include-elt-spans-to-rope ie | inj₁ ss = spans-to-rope ss include-elt-spans-to-rope ie | inj₂ ss = [[ ss ]] include-elt-to-archive : include-elt → json include-elt-to-archive ie with (include-elt.ss ie) | (include-elt.source ie) include-elt-to-archive ie | inj₁ ss | source = json-new $ ("source" , json-string source) :: ("spans" , json-raw (spans-to-rope ss)) :: [] include-elt-to-archive ie | inj₂ ss | source = json-new $ ("source" , json-string source) :: ("spans" , json-raw [[ ss ]]) :: [] include-elt-to-string : include-elt → string include-elt-to-string ie = " deps: " ^ (𝕃-to-string (λ x → x) "," (include-elt.deps ie)) ^ -- ast ", ast: " ^ maybe-else "not parsed" (λ ast → "parsed") (include-elt.ast ie) ^ ", " ^ " import-to-dep: " ^ (trie-to-string "," (format "filename: %s") (include-elt.import-to-dep ie)) ^ -- spans " err: " ^ (𝔹-to-string (include-elt.err ie)) ^ ", need-to-add-symbols-to-context: " ^ (𝔹-to-string (include-elt.need-to-add-symbols-to-context ie)) ^ ", do-type-check: " ^ (𝔹-to-string (include-elt.do-type-check ie)) ^ ", last-parse-time: " ^ (maybe-else "" utcToString (include-elt.last-parse-time ie)) params-to-string'' : params → string params-to-string'' [] = "" -- TODO print erased vs non-erased? params-to-string'' ((Decl pi pi' me v t-k pi'') :: pms) = "{var: " ^ v ^ ", tk: " ^ rope-to-string (tk-to-string empty-ctxt t-k) ^ "}" ^ ", " ^ (params-to-string'' pms) defParams-to-string : defParams → string defParams-to-string (just pms) = params-to-string'' pms defParams-to-string nothing = "" -- TODO also print modname? syms-to-string : trie (string × 𝕃 string) → string syms-to-string = trie-to-string ", " (λ l → "{" ^ (𝕃-to-string (λ s → s) ", " (snd l)) ^ "}") ctxt-info-to-string : ctxt-info → string ctxt-info-to-string (term-decl tp) = "term-decl: {type: " ^ rope-to-string (to-string empty-ctxt tp) ^ "}" ctxt-info-to-string (term-def dp opac t tp) = "term-def: {defParams: {" ^ (defParams-to-string dp) ^ "}, opacity: " ^ (opacity-to-string opac) ^ ", maybe term: " ^ maybe-else' t "nothing" (λ t → "just " ^ rope-to-string (to-string empty-ctxt t)) ^ ", type: " ^ rope-to-string (to-string empty-ctxt tp) ^ "}" ctxt-info-to-string (term-udef dp opac t) = "term-udef: {defParams: {" ^ (defParams-to-string dp) ^ "}, opacity: " ^ (opacity-to-string opac) ^ ", term: " ^ rope-to-string (to-string empty-ctxt t) ^ "}" ctxt-info-to-string (type-decl k) = "type-decl: {kind: " ^ rope-to-string (to-string empty-ctxt k) ^ "}" ctxt-info-to-string (type-def dp opac tp k) = "type-def: {defParams: {" ^ (defParams-to-string dp) ^ "}, opacity: " ^ (opacity-to-string opac) ^ ", maybe type: " ^ maybe-else' tp "nothing" (λ tp → "just " ^ rope-to-string (to-string empty-ctxt tp)) ^ ", kind: " ^ rope-to-string (to-string empty-ctxt k) ^ "}" ctxt-info-to-string (kind-def pms k) = "kind-def: {pms: " ^ (params-to-string'' pms) ^ "kind: " ^ rope-to-string (to-string empty-ctxt k) ^ "}" ctxt-info-to-string (rename-def v) = "rename-def: {var: " ^ v ^ "}" ctxt-info-to-string (var-decl) = "var-decl" ctxt-info-to-string (ctr-def _ _ _ _ _) = "ctr-def" --ctxt-info-to-string (mu-def x) = "mu-def: {var: " ^ x ^ "}" --ctxt-info-to-string (datatype-def ps kᵢ k cs) = "datatype-def: {defParams: {" ^ defParams-to-string ps ^ "}, inductive hypothesis kind: " ^ rope-to-string (to-string empty-ctxt kᵢ) ^ ", kind: " ^ rope-to-string (to-string empty-ctxt k) ^ ", cs: " ^ "TODO" ^ "}" --ctxt-info-to-string (mu-def ps x k) = "mu-def: {defParams: {" ^ defParams-to-string ps ^ "}, datatype var: " ^ x ^ ", kind: " ^ rope-to-string (to-string empty-ctxt k) ^ "}" sym-info-to-string : sym-info → string sym-info-to-string (ci , (fn , pi)) = "{ctxt-info: " ^ (ctxt-info-to-string ci) ^ ", location: {filename: " ^ fn ^ ", posinfo: " ^ pi ^ "}}" sym-infos-to-string : trie sym-info → string sym-infos-to-string = trie-to-string ", " sym-info-to-string occ-to-string : var × posinfo × string → string occ-to-string (v , pi , s) = "var: " ^ v ^ ", posinfo: " ^ pi ^ ", string: " ^ s sym-occs-to-string : trie (𝕃 (var × posinfo × string)) → string sym-occs-to-string = trie-to-string ", " (λ l → "{" ^ (𝕃-to-string occ-to-string ", " l) ^ "}") qualif-to-string : qualif-info → string qualif-to-string (x , as) = x ^ rope-to-string (fst (args-to-string as {TERM} [[]] 0 [] (new-ctxt "" "") nothing neither)) mod-info-to-string : mod-info → string mod-info-to-string (fn , mn , pms , q) = "filename: " ^ fn ^ ", modname: " ^ mn ^ ", pms: {" ^ (params-to-string'' pms) ^ "}" ^ ", qualif: {" ^ (trie-to-string ", " qualif-to-string q) ^ "}" ctxt-to-string : ctxt → string ctxt-to-string (mk-ctxt mi (ss , mn-fn) is os Δ) = "mod-info: {" ^ (mod-info-to-string mi) ^ "}, syms: {" ^ (syms-to-string ss) ^ "}, i: {" ^ (sym-infos-to-string is) ^ "}, sym-occs: {" ^ (sym-occs-to-string os) ^ "}" toplevel-state-to-string : toplevel-state → string toplevel-state-to-string (mk-toplevel-state include-path files is context) = "\ninclude-path: {\n" ^ (𝕃-to-string (λ x → x) "\n" (fst include-path)) ^ "\n}\nis: {" ^ (trie-to-string "\n" include-elt-to-string is) ^ "\n}\nΓ: {" ^ (ctxt-to-string context) ^ "}" -- check if a variable is being redefined, and if so return the first given state; otherwise the second (in the monad) check-redefined : posinfo → var → toplevel-state → spanM toplevel-state → spanM toplevel-state check-redefined pi x s c = get-ctxt (λ Γ → if ctxt-binds-var Γ x then (spanM-add (redefined-var-span Γ pi x) ≫span spanMr s) else c) import-as : var → optAs → var import-as v NoOptAs = v import-as v (SomeOptAs pi pfx) = pfx # v error-in-import-string = "There is an error in the imported file" -- Traverse all imports, returning an error if we encounter the same file twice {-# TERMINATING #-} check-cyclic-imports : (original current : filepath) → stringset → (path : 𝕃 string) → toplevel-state → err-m check-cyclic-imports fnₒ fn fs path s with stringset-contains fs fn ...| ff = foldr (λ fnᵢ x → x maybe-or check-cyclic-imports fnₒ fnᵢ (stringset-insert fs fn) (fn :: path) s) nothing (include-elt.deps (get-include-elt s fn)) ...| tt with fnₒ =string fn ...| tt = just (foldr (λ fnᵢ x → x ^ " → " ^ fnᵢ) ("Cyclic dependencies (" ^ fn) path ^ " → " ^ fn ^ ")") ...| ff = just error-in-import-string scope-t : Set → Set scope-t X = filepath → string → optAs → params → args → X → toplevel-state → toplevel-state × err-m infixl 0 _≫=scope_ _≫=scope_ : toplevel-state × err-m → (toplevel-state → toplevel-state × err-m) → toplevel-state × err-m _≫=scope_ (ts , err) f with f ts ...| ts' , err' = ts' , err maybe-or err' {-# TERMINATING #-} scope-file : toplevel-state → (original imported : filepath) → optAs → args → toplevel-state × err-m scope-file' : scope-t ⊤ scope-cmds : scope-t cmds scope-cmd : scope-t cmd scope-var : scope-t var scope-ctrs : scope-t ctrs scope-datatype-names : scope-t var scope-file ts fnₒ fnᵢ oa as with check-cyclic-imports fnₒ fnᵢ (trie-single fnₒ triv) [] ts ...| just e = ts , just e ...| nothing = scope-file' fnₒ fnᵢ oa [] as triv ts scope-file' fnₒ fn oa psₒ as triv s with get-include-elt s fn ...| ie with include-elt.err ie | include-elt.ast ie ...| e | nothing = s , (maybe-if e) ≫maybe just error-in-import-string ...| e | just (File is pi1 pi2 mn ps cs pi3) = (s , (maybe-if e) ≫maybe just error-in-import-string) ≫=scope scope-cmds fn mn oa ps as (imps-to-cmds is) ≫=scope scope-cmds fn mn oa ps as cs scope-cmds fn mn oa ps as (c :: cs) s = scope-cmd fn mn oa ps as c s ≫=scope scope-cmds fn mn oa ps as cs scope-cmds fn mn oa ps as [] s = s , nothing scope-cmd fn mn oa ps as (ImportCmd (Import pi NotPublic pi' ifn oa' as' pi'')) s = s , nothing scope-cmd fn mn oa psₒ asₒ (ImportCmd (Import pi IsPublic pi' ifn oa' asᵢ' pi'')) s = let ifn' = trie-lookup-else ifn (include-elt.import-to-dep (get-include-elt s fn)) ifn in scope-file' fn ifn' oa psₒ asᵢ triv s -- ^ oa' should be NoOptAs, so we can use oa ^ where merged : trie (maybe arg) → params → args → trie (maybe arg) merged σ ((Decl _ _ me x atk _) :: ps) (a :: as) = merged (trie-insert σ x $ just a) ps as merged σ ((Decl _ _ me x atk _) :: ps) ArgsNil = merged (trie-insert σ x nothing) ps ArgsNil merged σ _ _ = σ arg-var : arg → maybe var arg-var (TermArg me (Var pi x)) = just x arg-var (TypeArg (TpVar pi x)) = just x arg-var _ = nothing σ = merged empty-trie psₒ asₒ reorder : args → args reorder (a :: as) = maybe-else' (arg-var a ≫=maybe trie-lookup σ) (a :: reorder as) λ ma → maybe-else' ma [] λ a → a :: reorder as reorder [] = [] asᵢ = reorder $ qualif-args (toplevel-state.Γ s) asᵢ' scope-cmd fn mn oa ps as (DefKind _ v _ _ _) = scope-var fn mn oa ps as v scope-cmd fn mn oa ps as (DefTermOrType _ (DefTerm _ v _ _) _) = scope-var fn mn oa ps as v scope-cmd fn mn oa ps as (DefTermOrType _ (DefType _ v _ _) _) = scope-var fn mn oa ps as v scope-cmd fn mn oa ps as (DefDatatype (Datatype _ _ v _ _ cs) _) s = scope-var fn mn oa ps as v s ≫=scope scope-ctrs fn mn oa ps as cs ≫=scope scope-datatype-names fn mn oa ps as v scope-ctrs fn mn oa ps as [] s = s , nothing scope-ctrs fn mn oa ps as ((Ctr pi x T) :: ds) s = scope-var fn mn oa ps as x s ≫=scope scope-ctrs fn mn oa ps as ds scope-datatype-names fn mn oa ps as x s = scope-var fn mn oa ps as (data-Is/ x) s ≫=scope scope-var fn mn oa ps as (data-is/ x) ≫=scope scope-var fn mn oa ps as (data-to/ x) scope-var _ mn oa ps as v s with import-as v oa | s ...| v' | mk-toplevel-state ip fns is (mk-ctxt (mn' , fn , pms , q) ss sis os Δ) = mk-toplevel-state ip fns is (mk-ctxt (mn' , fn , pms , trie-insert q v' (mn # v , as)) ss sis os Δ) , flip maybe-map (trie-lookup q v') (uncurry λ v'' as' → "Multiple definitions of variable " ^ v' ^ " as " ^ v'' ^ " and " ^ (mn # v) ^ (if (mn # v =string v'') then " (perhaps it was already imported?)" else ""))
50.315457
309
0.632163
1aa39ecfd1ffbe837bdc9b7b814d4356a80bab08
3,695
agda
Agda
src/Data/Fin/PigeonHole.agda
tizmd/agda-finitary
abacd166f63582b7395d9cc10b6323c0f69649e5
[ "MIT" ]
null
null
null
src/Data/Fin/PigeonHole.agda
tizmd/agda-finitary
abacd166f63582b7395d9cc10b6323c0f69649e5
[ "MIT" ]
null
null
null
src/Data/Fin/PigeonHole.agda
tizmd/agda-finitary
abacd166f63582b7395d9cc10b6323c0f69649e5
[ "MIT" ]
null
null
null
{-# OPTIONS --safe --without-K #-} module Data.Fin.PigeonHole where open import Data.Fin as Fin open import Data.Fin.Properties open import Data.Product hiding (swap) open import Relation.Nullary import Data.Nat as ℕ import Data.Nat.Properties as ℕ open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; _≢_) open import Function.Equality as Fun open import Function.Injection renaming (_∘_ to _⟨∘⟩_) open import Function.LeftInverse hiding (id ; _∘_ ) open import Function.Surjection hiding (id ; _∘_ ) open import Function.Related open import Data.Unit using (⊤; tt) open import Data.Empty using (⊥-elim; ⊥) inj→≤ : ∀ {n m} → (Fin n ↣ Fin m) → n ℕ.≤ m inj→≤ {n}{m} f = ℕ.≮⇒≥ (contra f) where inject≤I : ∀ {m n} → m ℕ.≤ n → (Fin m ↣ Fin n) inject≤I m≤n = record { to = PropEq.→-to-⟶ (λ i → inject≤ i m≤n ) ; injective = injective m≤n } where injective : ∀ {n m} → (m≤n : m ℕ.≤ n) → ∀ {i j} → inject≤ i m≤n ≡ inject≤ j m≤n → i ≡ j injective (ℕ.s≤s m≤n) {zero} {zero} PropEq.refl = PropEq.refl injective (ℕ.s≤s m≤n) {zero} {suc j} () injective (ℕ.s≤s m≤n) {suc i} {zero} () injective (ℕ.s≤s m≤n) {suc i} {suc j} feq = PropEq.cong suc (injective m≤n (suc-injective feq)) contra₁ : ∀ {m} → (Fin (ℕ.suc m) ↣ Fin m) → ⊥ contra₁ {m = ℕ.zero} f with Injection.to f ⟨$⟩ # 0 contra₁ {ℕ.zero} f | () contra₁ {m = ℕ.suc m} f = contra₁ h where k : Fin (ℕ.suc m) k = Injection.to f ⟨$⟩ # 0 sucI : Fin (ℕ.suc m) ↣ Fin (ℕ.suc (ℕ.suc m)) sucI = record { to = PropEq.→-to-⟶ suc ; injective = suc-injective } g : Fin (ℕ.suc m) ↣ Fin (ℕ.suc m) g = f ⟨∘⟩ sucI k≢g : ∀ (i : Fin (ℕ.suc m)) → k ≢ Injection.to g ⟨$⟩ i k≢g i = contraposition (Injection.injective f) λ () where open import Relation.Nullary.Negation h : Fin (ℕ.suc m) ↣ Fin m h = record { to = PropEq.→-to-⟶ to ; injective = to-injective } where to : Fin (ℕ.suc m) → Fin m to i = punchOut (k≢g i) to-injective : ∀ {i j} → to i ≡ to j → i ≡ j to-injective {i}{j} eq = Injection.injective g (punchOut-injective (k≢g i) (k≢g j) eq) contra : ∀ {n m} → (Fin n ↣ Fin m) → n ℕ.≯ m contra {ℕ.zero} {m} f () contra {ℕ.suc n} {ℕ.zero} f n>m with Injection.to f ⟨$⟩ # 0 contra {ℕ.suc n} {ℕ.zero} f n>m | () contra {ℕ.suc n} {ℕ.suc m} f n>m = contra₁ (f ⟨∘⟩ inject≤I n>m) FinRelated : ∀ {n m k} → Fin n ∼[ k ] Fin m → Set FinRelated {n} {m} {implication} f = ⊤ FinRelated {n} {m} {reverse-implication} f = ⊤ FinRelated {n} {m} {equivalence} f = ⊤ FinRelated {n} {m} {injection} f = n ℕ.≤ m FinRelated {n} {m} {reverse-injection} f = n ℕ.≥ m FinRelated {n} {m} {left-inverse} f = n ℕ.≤ m FinRelated {n} {m} {surjection} f = n ℕ.≥ m FinRelated {n} {m} {bijection} f = n ≡ m ⇒Fin∼Fin : ∀ {n m k} (f : Fin n ∼[ k ] Fin m) → FinRelated f ⇒Fin∼Fin {n} {m} {implication} f = tt ⇒Fin∼Fin {n} {m} {reverse-implication} f = tt ⇒Fin∼Fin {n} {m} {equivalence} f = tt ⇒Fin∼Fin {n} {m} {injection} f = inj→≤ f ⇒Fin∼Fin {n} {m} {reverse-injection} f = inj→≤ (app-↢ f) ⇒Fin∼Fin {n} {m} {left-inverse} f = inj→≤ (LeftInverse.injection f) ⇒Fin∼Fin {n} {m} {surjection} f = inj→≤ (Surjection.injection f) ⇒Fin∼Fin {n} {m} {bijection} f = ℕ.≤-antisym (inj→≤ (↔⇒ f)) (inj→≤ (app-↢ (↔⇒ f)))
36.95
109
0.513667
13da9490eb8fc72508f5847c9e946aee00d27773
53
agda
Agda
test/interaction/Issue556.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/interaction/Issue556.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/interaction/Issue556.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module Issue556 (A : Set) (x : A) where y : A y = x
10.6
39
0.54717
2f62246e218b1ba1ed754c081312e897618df54a
6,362
agda
Agda
Categories/Category/Cocartesian.agda
rei1024/agda-categories
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
[ "MIT" ]
null
null
null
Categories/Category/Cocartesian.agda
rei1024/agda-categories
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
[ "MIT" ]
null
null
null
Categories/Category/Cocartesian.agda
rei1024/agda-categories
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K --safe #-} open import Categories.Category -- BinaryCoproducts -- a category with all binary coproducts -- Cocartesian -- a category with all coproducts -- since most of the work is dual to Categories.Category.Cartesian, so the idea -- in this module is to make use of duality module Categories.Category.Cocartesian {o ℓ e} (𝒞 : Category o ℓ e) where open import Level private module 𝒞 = Category 𝒞 open Category 𝒞 open HomReasoning variable A B C D : Obj f g h i : A ⇒ B open import Categories.Object.Initial 𝒞 open import Categories.Object.Coproduct 𝒞 open import Categories.Object.Duality 𝒞 open import Categories.Category.Monoidal open import Categories.Category.Monoidal.Symmetric open import Categories.Category.Cartesian 𝒞.op open import Categories.Morphism 𝒞 open import Categories.Morphism.Properties 𝒞 open import Categories.Morphism.Duality 𝒞 open import Categories.Morphism.Reasoning 𝒞 open import Categories.Functor renaming (id to idF) open import Categories.Functor.Properties open import Categories.Functor.Bifunctor record BinaryCoproducts : Set (levelOfTerm 𝒞) where infixr 6 _+_ infixr 7 _+₁_ field coproduct : ∀ {A B} → Coproduct A B module coproduct {A} {B} = Coproduct (coproduct {A} {B}) _+_ : Obj → Obj → Obj A + B = coproduct.A+B {A} {B} open coproduct using (i₁; i₂; [_,_]; inject₁; inject₂; []-cong₂) renaming (unique to +-unique; η to +-η; g-η to +-g-η) public module Dual where op-binaryProducts : BinaryProducts op-binaryProducts = record { product = coproduct→product coproduct } module op-binaryProducts = BinaryProducts op-binaryProducts open Dual +-comm : A + B ≅ B + A +-comm = op-≅⇒≅ (op-binaryProducts.×-comm) +-assoc : A + B + C ≅ (A + B) + C +-assoc = op-≅⇒≅ (op-binaryProducts.×-assoc) _+₁_ : A ⇒ B → C ⇒ D → A + C ⇒ B + D _+₁_ = op-binaryProducts._⁂_ open op-binaryProducts using () renaming ( ⟨⟩-congʳ to []-congʳ ; ⟨⟩-congˡ to []-congˡ ; assocˡ to +-assocʳ ; assocʳ to +-assocˡ ; swap to +-swap ; first to +-first ; second to +-second ; π₁∘⁂ to +₁∘i₁ ; π₂∘⁂ to +₁∘i₂ ; ⁂-cong₂ to +₁-cong₂ ; ⁂∘⟨⟩ to []∘+₁ ; ⁂∘⁂ to +₁∘+₁ ; ⟨⟩∘ to ∘[] ; first↔second to +-second↔first ; swap∘⁂ to +₁∘+-swap ; swap∘swap to +-swap∘swap ) public -- since op-×- has type Bifunctor 𝒞.op 𝒞.op 𝒞.op, -- need to rewrap in order to type check -+- : Bifunctor 𝒞 𝒞 𝒞 -+- = record { F₀ = op-×-.F₀ ; F₁ = op-×-.F₁ ; identity = op-×-.identity ; homomorphism = op-×-.homomorphism ; F-resp-≈ = op-×-.F-resp-≈ } where op-×- = op-binaryProducts.-×- module op-×- = Functor op-×- -+_ : Obj → Functor 𝒞 𝒞 -+_ = appʳ -+- _+- : Obj → Functor 𝒞 𝒞 _+- = appˡ -+- record Cocartesian : Set (levelOfTerm 𝒞) where field initial : Initial coproducts : BinaryCoproducts module initial = Initial initial module coproducts = BinaryCoproducts coproducts open initial renaming (! to ¡; !-unique to ¡-unique; !-unique₂ to ¡-unique₂) public open coproducts hiding (module Dual) public module Dual where open coproducts.Dual public op-cartesian : Cartesian op-cartesian = record { terminal = ⊥⇒op⊤ initial ; products = op-binaryProducts } module op-cartesian = Cartesian op-cartesian open Dual ⊥+A≅A : ⊥ + A ≅ A ⊥+A≅A = op-≅⇒≅ (op-cartesian.⊤×A≅A) A+⊥≅A : A + ⊥ ≅ A A+⊥≅A = op-≅⇒≅ (op-cartesian.A×⊤≅A) open op-cartesian using () -- both are natural isomorphism renaming (⊤×--id to ⊥+--id; -×⊤-id to -+⊥-id) public +-monoidal : Monoidal 𝒞 +-monoidal = record { ⊗ = -+- ; unit = unit ; unitorˡ = ⊥+A≅A ; unitorʳ = A+⊥≅A ; associator = ≅.sym +-assoc ; unitorˡ-commute-from = ⟺ unitorˡ-commute-to ; unitorˡ-commute-to = ⟺ unitorˡ-commute-from ; unitorʳ-commute-from = ⟺ unitorʳ-commute-to ; unitorʳ-commute-to = ⟺ unitorʳ-commute-from ; assoc-commute-from = ⟺ assoc-commute-to ; assoc-commute-to = ⟺ assoc-commute-from -- the proof idea of triangle is that the opposite triangle is obtained for free, -- but notice that triangle and the opposite triangle form isomorphism. ; triangle = λ {X Y} → Iso-≈ triangle (Iso-∘ ([ X +- ]-resp-Iso (Iso-swap (iso ⊥+A≅A))) (iso +-assoc)) ([ -+ Y ]-resp-Iso (Iso-swap (iso A+⊥≅A))) ; pentagon = λ {X Y Z W} → Iso-≈ pentagon (Iso-∘ ([ X +- ]-resp-Iso (iso +-assoc)) (Iso-∘ (iso +-assoc) ([ -+ W ]-resp-Iso (iso +-assoc)))) (Iso-∘ (iso +-assoc) (iso +-assoc)) } where op-monoidal = op-cartesian.monoidal open Monoidal op-monoidal open _≅_ module +-monoidal = Monoidal +-monoidal +-symmetric : Symmetric +-monoidal +-symmetric = record { braided = record { braiding = record { F⇒G = record { η = λ _ → +-swap ; commute = λ _ → ⟺ +₁∘+-swap ; sym-commute = λ _ → +₁∘+-swap } ; F⇐G = record { η = λ _ → +-swap ; commute = λ _ → ⟺ +₁∘+-swap ; sym-commute = λ _ → +₁∘+-swap } ; iso = λ _ → iso +-comm } ; hexagon₁ = ⟺ assoc ○ braided.hexagon₂ ○ assoc ; hexagon₂ = ⟺ assoc ○ braided.hexagon₁ ○ assoc } ; commutative = commutative } where op-symmetric = op-cartesian.symmetric open Symmetric op-symmetric open _≅_ -- we don't open this module publicly in order to prevent introducing conflicts -- with Cartesian category module +-symmetric = Symmetric +-symmetric
30.009434
86
0.533952
0465f529e3a64b8c5e1445b6895e21646753bd06
352
agda
Agda
test/Succeed/HORewritingInParametrizedModule.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/HORewritingInParametrizedModule.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/HORewritingInParametrizedModule.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
{-# OPTIONS --rewriting --confluence-check #-} open import Agda.Builtin.Equality postulate _↦_ : ∀ {a} {A : Set a} → A → A → Set {-# BUILTIN REWRITE _↦_ #-} postulate T : (Set → Set → Set) → Set T₀ : Set module _ (F : Set → Set) where postulate rew : T (λ X Y → F X) ↦ T₀ {-# REWRITE rew #-} test : T (λ X Y → F X) ≡ T₀ test = refl
17.6
47
0.551136
cbab83617dcf951148c2f949263cc1860ba3cecc
1,483
agda
Agda
Categories/Bifunctor/NaturalTransformation.agda
copumpkin/categories
36f4181d751e2ecb54db219911d8c69afe8ba892
[ "BSD-3-Clause" ]
98
2015-04-15T14:57:33.000Z
2022-03-08T05:20:36.000Z
Categories/Bifunctor/NaturalTransformation.agda
p-pavel/categories
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
[ "BSD-3-Clause" ]
19
2015-05-23T06:47:10.000Z
2019-08-09T16:31:40.000Z
Categories/Bifunctor/NaturalTransformation.agda
p-pavel/categories
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
[ "BSD-3-Clause" ]
23
2015-02-05T13:03:09.000Z
2021-11-11T13:50:56.000Z
{-# OPTIONS --universe-polymorphism #-} module Categories.Bifunctor.NaturalTransformation where open import Level open import Categories.Category open import Categories.Bifunctor open import Categories.Product open import Categories.NaturalTransformation public -- just for completeness ... BiNaturalTransformation : ∀ {o ℓ e} {o′ ℓ′ e′} {o′′ ℓ′′ e′′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {E : Category o′′ ℓ′′ e′′} → Bifunctor C D E → Bifunctor C D E → Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′ ⊔ o′′ ⊔ ℓ′′ ⊔ e′′) BiNaturalTransformation F G = NaturalTransformation F G reduceN-× : ∀ {o ℓ e} {o′₁ ℓ′₁ e′₁} {o′₂ ℓ′₂ e′₂} {C : Category o ℓ e} {D₁ : Category o′₁ ℓ′₁ e′₁} {D₂ : Category o′₂ ℓ′₂ e′₂} (H : Bifunctor D₁ D₂ C) {o″₁ ℓ″₁ e″₁} {E₁ : Category o″₁ ℓ″₁ e″₁} {F F′ : Functor E₁ D₁} (φ : NaturalTransformation F F′) {o″₂ ℓ″₂ e″₂} {E₂ : Category o″₂ ℓ″₂ e″₂} {G G′ : Functor E₂ D₂} (γ : NaturalTransformation G G′) → NaturalTransformation (reduce-× {D₁ = D₁} {D₂ = D₂} H F G) (reduce-× {D₁ = D₁} {D₂ = D₂} H F′ G′) reduceN-× H φ γ = H ∘ˡ (φ ⁂ⁿ γ) overlapN-× : ∀ {o ℓ e} {o′₁ ℓ′₁ e′₁} {o′₂ ℓ′₂ e′₂} {C : Category o ℓ e} {D₁ : Category o′₁ ℓ′₁ e′₁} {D₂ : Category o′₂ ℓ′₂ e′₂} (H : Bifunctor D₁ D₂ C) {o″ ℓ″ e″} {E : Category o″ ℓ″ e″} {F F′ : Functor E D₁} (φ : NaturalTransformation F F′) {G G′ : Functor E D₂} (γ : NaturalTransformation G G′) → NaturalTransformation (overlap-× {D₁ = D₁} {D₂ = D₂} H F G) (overlap-× {D₁ = D₁} {D₂ = D₂} H F′ G′) overlapN-× H φ γ = H ∘ˡ (φ ※ⁿ γ)
74.15
446
0.610924
4b0463484a089daa23f16ac115989e9bd653dd89
732
agda
Agda
test/interaction/Issue2872.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/interaction/Issue2872.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/interaction/Issue2872.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
open import Agda.Builtin.List open import Agda.Builtin.Char foo : Char → List Char foo c = c ∷ [] -- Step 1: case split on foo-ls case-split-test₁ : List Char → List Char case-split-test₁ ('-' ∷ ls) with (foo '+') ... | foo-ls = {!foo-ls!} case-split-test₁ ls = ls -- Step 2: expand ellipsis case-split-test₂ : List Char → List Char case-split-test₂ ('-' ∷ ls) with (foo '+') ... | [] = {!.!} ... | x ∷ foo-ls = {!.!} case-split-test₂ ls = ls -- WAS: case splitting on foo-ls produces: -- case-split-test (.'-' ∷ ls) | [] = ? -- case-split-test (.'-' ∷ ls) | x ∷ foo-ls = ? -- SHOULD: not put dots in front of literal patterns: -- case-split-test ('-' ∷ ls) | [] = {!!} -- case-split-test ('-' ∷ ls) | x ∷ foo-ls = {!!}
28.153846
53
0.561475
50206c3d585f49f311cb8baf6c38a81f1b47c9b3
984
agda
Agda
src/agda/FRP/JS/True.agda
agda/agda-frp-js
c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72
[ "MIT", "BSD-3-Clause" ]
63
2015-04-20T21:47:00.000Z
2022-02-28T09:46:14.000Z
src/agda/FRP/JS/True.agda
agda/agda-frp-js
c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72
[ "MIT", "BSD-3-Clause" ]
null
null
null
src/agda/FRP/JS/True.agda
agda/agda-frp-js
c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72
[ "MIT", "BSD-3-Clause" ]
7
2016-11-07T21:50:58.000Z
2022-03-12T11:39:38.000Z
{-# OPTIONS --universe-polymorphism #-} open import FRP.JS.Bool using ( Bool ; true ; false ; if_then_else_ ; not ; _∧_ ) module FRP.JS.True where record ⊤ : Set where constructor tt data ⊥ : Set where contradiction : ∀ {α} {A : Set α} → ⊥ → A contradiction () True : Bool → Set True true = ⊤ True false = ⊥ False : Bool → Set False b = True b → ⊥ ∧-intro : ∀ {a b} → True a → True b → True (a ∧ b) ∧-intro {false} () b ∧-intro {true} {false} tt () ∧-intro {true} {true} tt tt = tt ∧-elim₁ : ∀ {a b} → True (a ∧ b) → True a ∧-elim₁ {false} () ∧-elim₁ {true} b = tt ∧-elim₂ : ∀ {a b} → True (a ∧ b) → True b ∧-elim₂ {false} () ∧-elim₂ {true} b = b data Dec (b : Bool) : Set where yes : True b → Dec b no : False b → Dec b {-# COMPILED_JS Dec function(x,v) { if (x) { return v.yes(null); } else { return v.no(null); } } #-} {-# COMPILED_JS yes true #-} {-# COMPILED_JS no false #-} dec : ∀ b → Dec b dec true = yes tt dec false = no contradiction
20.5
81
0.563008
aded8f02fadce4288b2c61a3973bea070c18c5a2
5,459
agda
Agda
Cubical/Relation/ZigZag/Base.agda
Schippmunk/cubical
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
[ "MIT" ]
null
null
null
Cubical/Relation/ZigZag/Base.agda
Schippmunk/cubical
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
[ "MIT" ]
null
null
null
Cubical/Relation/ZigZag/Base.agda
Schippmunk/cubical
c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a
[ "MIT" ]
null
null
null
-- We define ZigZag-complete relations and prove that quasi equivalence relations -- give rise to equivalences on the set quotients. {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Relation.ZigZag.Base where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Foundations.Function open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.HLevels open import Cubical.Data.Sigma open import Cubical.HITs.SetQuotients open import Cubical.HITs.PropositionalTruncation as Trunc open import Cubical.Relation.Binary.Base open isEquivRel private variable ℓ ℓ' : Level isZigZagComplete : {A B : Type ℓ} (R : A → B → Type ℓ') → Type (ℓ-max ℓ ℓ') isZigZagComplete R = ∀ {a b a' b'} → R a b → R a' b → R a' b' → R a b' ZigZagRel : (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ')) ZigZagRel A B ℓ' = Σ[ R ∈ (A → B → Type ℓ') ] (isZigZagComplete R) record isQuasiEquivRel {A B : Type ℓ} (R : A → B → Type ℓ') : Type (ℓ-max ℓ ℓ') where field zigzag : isZigZagComplete R fwd : (a : A) → ∃[ b ∈ B ] R a b bwd : (b : B) → ∃[ a ∈ A ] R a b open isQuasiEquivRel QuasiEquivRel : (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ')) QuasiEquivRel A B ℓ' = Σ[ R ∈ PropRel A B ℓ' ] isQuasiEquivRel (R .fst) invQER : {A B : Type ℓ} {ℓ' : Level} → QuasiEquivRel A B ℓ' → QuasiEquivRel B A ℓ' invQER (R , qer) .fst = invPropRel R invQER (R , qer) .snd .zigzag aRb aRb' a'Rb' = qer .zigzag a'Rb' aRb' aRb invQER (R , qer) .snd .fwd = qer .bwd invQER (R , qer) .snd .bwd = qer .fwd QER→EquivRel : {A B : Type ℓ} → QuasiEquivRel A B ℓ' → EquivPropRel A (ℓ-max ℓ ℓ') QER→EquivRel (R , sim) .fst = compPropRel R (invPropRel R) QER→EquivRel (R , sim) .snd .reflexive a = Trunc.map (λ {(b , r) → b , r , r}) (sim .fwd a) QER→EquivRel (R , sim) .snd .symmetric _ _ = Trunc.map (λ {(b , r₀ , r₁) → b , r₁ , r₀}) QER→EquivRel (R , sim) .snd .transitive _ _ _ = Trunc.map2 (λ {(b , r₀ , r₁) (b' , r₀' , r₁') → b , r₀ , sim .zigzag r₁' r₀' r₁}) -- The following result is due to Carlo Angiuli module QER→Equiv {A B : Type ℓ} (R : QuasiEquivRel A B ℓ') where Rᴸ = QER→EquivRel R .fst .fst Rᴿ = QER→EquivRel (invQER R) .fst .fst private sim = R .snd private f : (a : A) → ∃[ b ∈ B ] R .fst .fst a b → B / Rᴿ f a = Trunc.rec→Set squash/ ([_] ∘ fst) (λ {(b , r) (b' , r') → eq/ b b' ∣ a , r , r' ∣}) fPath : (a₀ : A) (s₀ : ∃[ b ∈ B ] R .fst .fst a₀ b) (a₁ : A) (s₁ : ∃[ b ∈ B ] R .fst .fst a₁ b) → Rᴸ a₀ a₁ → f a₀ s₀ ≡ f a₁ s₁ fPath a₀ = Trunc.elim (λ _ → isPropΠ3 λ _ _ _ → squash/ _ _) (λ {(b₀ , r₀) a₁ → Trunc.elim (λ _ → isPropΠ λ _ → squash/ _ _) (λ {(b₁ , r₁) → Trunc.elim (λ _ → squash/ _ _) (λ {(b' , r₀' , r₁') → eq/ b₀ b₁ ∣ a₀ , r₀ , sim .zigzag r₀' r₁' r₁ ∣})})}) φ : A / Rᴸ → B / Rᴿ φ [ a ] = f a (sim .fwd a) φ (eq/ a₀ a₁ r i) = fPath a₀ (sim .fwd a₀) a₁ (sim .fwd a₁) r i φ (squash/ _ _ p q j i) = squash/ _ _ (cong φ p) (cong φ q) j i relToFwd≡ : ∀ {a b} → R .fst .fst a b → φ [ a ] ≡ [ b ] relToFwd≡ {a} {b} r = Trunc.elim {P = λ s → f a s ≡ [ b ]} (λ _ → squash/ _ _) (λ {(b' , r') → eq/ b' b ∣ a , r' , r ∣}) (sim .fwd a) fwd≡ToRel : ∀ {a b} → φ [ a ] ≡ [ b ] → R .fst .fst a b fwd≡ToRel {a} {b} = Trunc.elim {P = λ s → f a s ≡ [ b ] → R .fst .fst a b} (λ _ → isPropΠ λ _ → R .fst .snd _ _) (λ {(b' , r') p → Trunc.rec (R .fst .snd _ _) (λ {(a' , s' , s) → R .snd .zigzag r' s' s}) (effective (QER→EquivRel (invQER R) .fst .snd) (QER→EquivRel (invQER R) .snd) b' b p)}) (sim .fwd a) private g : (b : B) → ∃[ a ∈ A ] R .fst .fst a b → A / Rᴸ g b = Trunc.rec→Set squash/ ([_] ∘ fst) (λ {(a , r) (a' , r') → eq/ a a' ∣ b , r , r' ∣}) gPath : (b₀ : B) (s₀ : ∃[ a ∈ A ] R .fst .fst a b₀) (b₁ : B) (s₁ : ∃[ a ∈ A ] R .fst .fst a b₁) → Rᴿ b₀ b₁ → g b₀ s₀ ≡ g b₁ s₁ gPath b₀ = Trunc.elim (λ _ → isPropΠ3 λ _ _ _ → squash/ _ _) (λ {(a₀ , r₀) b₁ → Trunc.elim (λ _ → isPropΠ λ _ → squash/ _ _) (λ {(a₁ , r₁) → Trunc.elim (λ _ → squash/ _ _) (λ {(a' , r₀' , r₁') → eq/ a₀ a₁ ∣ b₀ , r₀ , sim .zigzag r₁ r₁' r₀' ∣})})}) ψ : B / Rᴿ → A / Rᴸ ψ [ b ] = g b (sim .bwd b) ψ (eq/ b₀ b₁ r i) = gPath b₀ (sim .bwd b₀) b₁ (sim .bwd b₁) r i ψ (squash/ _ _ p q j i) = squash/ _ _ (cong ψ p) (cong ψ q) j i relToBwd≡ : ∀ {a b} → R .fst .fst a b → ψ [ b ] ≡ [ a ] relToBwd≡ {a} {b} r = Trunc.elim {P = λ s → g b s ≡ [ a ]} (λ _ → squash/ _ _) (λ {(a' , r') → eq/ a' a ∣ b , r' , r ∣}) (sim .bwd b) private η : ∀ qb → φ (ψ qb) ≡ qb η = elimProp (λ _ → squash/ _ _) (λ b → Trunc.elim {P = λ s → φ (g b s) ≡ [ b ]} (λ _ → squash/ _ _) (λ {(a , r) → relToFwd≡ r}) (sim .bwd b)) ε : ∀ qa → ψ (φ qa) ≡ qa ε = elimProp (λ _ → squash/ _ _) (λ a → Trunc.elim {P = λ s → ψ (f a s) ≡ [ a ]} (λ _ → squash/ _ _) (λ {(b , r) → relToBwd≡ r}) (sim .fwd a)) bwd≡ToRel : ∀ {a b} → ψ [ b ] ≡ [ a ] → R .fst .fst a b bwd≡ToRel {a} {b} p = fwd≡ToRel (cong φ (sym p) ∙ η [ b ]) Thm : (A / Rᴸ) ≃ (B / Rᴿ) Thm = isoToEquiv (iso φ ψ η ε)
33.697531
91
0.491299
0460e509ce6d2a6e2d055e298a54187a8b80e077
3,230
agda
Agda
src/sigmatypes/ITypes.agda
kcaliban/ldlc
a87fb6402639c3d2bb393cc5466426c28e7a0398
[ "BSD-3-Clause" ]
null
null
null
src/sigmatypes/ITypes.agda
kcaliban/ldlc
a87fb6402639c3d2bb393cc5466426c28e7a0398
[ "BSD-3-Clause" ]
null
null
null
src/sigmatypes/ITypes.agda
kcaliban/ldlc
a87fb6402639c3d2bb393cc5466426c28e7a0398
[ "BSD-3-Clause" ]
1
2019-03-14T17:52:29.000Z
2019-03-14T17:52:29.000Z
-- Inductive types -- See Chapter 15 of "Practical Foundations for Programming Languages" by Robert Harper module ITypes where open import Data.Vec open import Data.Nat open import Data.List open import Data.Fin.Base -- auxiliary data Bool : Set where True False : Bool _if_else_ : {A : Set} → A → Bool → A → A A if True else B = A A if False else B = B -- end of auxiliary {-- required later on data IType' (n : ℕ) : Set data IType' n where Unit Nat : IType' n Pair Sum : IType n → IType n → IType' n Map'[_,_]_ : ∀ {n} → Fin n → IType' n → IType n → IType' n Map'[ var , Unit ] type' = Unit Map'[ var , Nat ] type' = Nat Map'[ var , Pair x x₁ ] type' = Pair (Map[ var , x ] type') (Map[ var , x₁ ] type') Map'[ var , Sum x x₁ ] type' = Sum (Map[ var , x ] type') (Map[ var , x₁ ] type') --} data IType (n : ℕ) : Set data IType n where Unit Nat : IType n Pair Sum : IType n → IType n → IType n Ind : IType (suc n) → IType n Var : Fin n → IType n Func : IType n → IType n → IType n FinEq : ∀ {n} → Fin n → Fin n → Bool FinEq zero zero = True FinEq zero (suc b) = False FinEq (suc a) zero = False FinEq (suc a) (suc b) = FinEq a b -- Substitute type' for var in type Map[_,_]_ : ∀ {n} → Fin (suc n) → IType (suc n) → IType n → IType n Map[ var , Unit ] type' = Unit Map[ var , Nat ] type' = Nat Map[ var , Pair type type₁ ] type' = Pair (Map[ var , type ] type') (Map[ var , type₁ ] type') Map[ var , Sum type type₁ ] type' = Pair (Map[ var , type ] type') (Map[ var , type₁ ] type') Map[ var , Ind x ] type' = {!!} --Ind (Map[ var , x ] type') Map[ var , Func a b ] type' = Func (Map[ var , a ] type') (Map[ var , b ] type') Map[ var , Var x ] type' = type' if (FinEq var x) else Var {!!} -- Alternative notation [_/_]_ : ∀ {n} → IType n → Fin (suc n) → IType (suc n) → IType n [ type' / var ] type = Map[ var , type ] type' Env : ℕ → Set Env n = List (IType n) -- Environment lookup data _∈`_ {n} : IType n → Env n → Set where here : ∀ {φ A} → A ∈` (A ∷ φ) there : ∀ {φ A A'} → A ∈` φ → A ∈` (A' ∷ φ) -- Expressions data Expr {n} : Env n → IType n → Set where -- Fold : ∀ {ϕ t τ} → Expr ϕ ([ Ind τ / t ] τ) → Expr ϕ (Ind τ) -- Rec : ∀ {ϕ t τ ρ} → Expr ((Map[ t , τ ] ρ) ∷ ϕ) ρ → Expr ϕ (Ind τ) → {!!} FoldNat : ∀ {ϕ} → Expr ϕ (Sum Unit Nat) → Expr ϕ Nat RecNat : ∀ {ϕ} → Expr (Sum Unit Nat ∷ ϕ) Nat → Expr ϕ Nat → Expr ϕ Nat Var : ∀ {φ τ} → τ ∈` φ → Expr φ τ Abs : ∀ {φ τ τ'} → Expr (τ ∷ φ) τ' → Expr φ (Func τ τ') App : ∀ {φ τ τ'} → Expr φ (Func τ τ') → Expr φ τ → Expr φ τ' -- Expression substitution [_//_] : ∀ {n ϕ} {τ τ' : IType n} → Expr (τ' ∷ ϕ) τ → Expr ϕ τ' → Expr ϕ τ -- TODO data _↦_ {n ϕ} : {τ : IType n} → Expr ϕ τ → Expr ϕ τ → Set where ξ-RecNat : ∀ {e} {e' e''} → e' ↦ e'' → _↦_ {τ = Nat} (RecNat e e') (RecNat e e'') β-RecNat : ∀ {e e'} → _↦_ {τ = Nat} (RecNat e (FoldNat e')) [ e // e' ] -- IValue -- data IValue (n : ℕ) : Set where -- Interpreter -- int : ∀ {n} → IType n → Set -- int' : ∀ {n} → IType' n → Set --- int {n} (Ind it') = IValue n (int' it')
31.980198
94
0.514551
4bbb872c92577ccd709cedcf49fdb0fc83f42f95
721
agda
Agda
src/Categories/Minus2-Category/Construction/Indiscrete.agda
jaykru/agda-categories
a4053cf700bcefdf73b857c3352f1eae29382a60
[ "MIT" ]
279
2019-06-01T14:36:40.000Z
2022-03-22T00:40:14.000Z
src/Categories/Minus2-Category/Construction/Indiscrete.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
236
2019-06-01T14:53:54.000Z
2022-03-28T14:31:43.000Z
src/Categories/Minus2-Category/Construction/Indiscrete.agda
seanpm2001/agda-categories
d9e4f578b126313058d105c61707d8c8ae987fa8
[ "MIT" ]
64
2019-06-02T16:58:15.000Z
2022-03-14T02:00:59.000Z
{-# OPTIONS --without-K --safe #-} -- An inhabited Indiscrete category is a -2-Category module Categories.Minus2-Category.Construction.Indiscrete where open import Level open import Data.Unit using (tt) open import Data.Product using (_,_) open import Relation.Binary.PropositionalEquality using (refl) open import Categories.Minus2-Category open import Categories.Category.Indiscrete open import Categories.Morphism using (_≅_) InhIndIs-2 : ∀ {o ℓ} → (X : Set o) → (x : X) → -2-Category {o} {ℓ} {ℓ} InhIndIs-2 X x = record { cat = Indiscrete X ; Obj-Contr = x , λ y → record { from = lift tt ; to = lift tt ; iso = record { isoˡ = refl ; isoʳ = refl } } ; Hom-Conn = refl }
25.75
70
0.662968
043a0dfed806279cb8335f6fc9f7edeae88ec14a
1,899
agda
Agda
Cubical/Foundations/Powerset.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
301
2018-10-17T18:00:24.000Z
2022-03-24T02:10:47.000Z
Cubical/Foundations/Powerset.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
584
2018-10-15T09:49:02.000Z
2022-03-30T12:09:17.000Z
Cubical/Foundations/Powerset.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
134
2018-11-16T06:11:03.000Z
2022-03-23T16:22:13.000Z
{- This file introduces the "powerset" of a type in the style of Escardó's lecture notes: https://www.cs.bham.ac.uk/~mhe/HoTT-UF-in-Agda-Lecture-Notes/HoTT-UF-Agda.html#propositionalextensionality -} {-# OPTIONS --safe #-} module Cubical.Foundations.Powerset 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.Structure open import Cubical.Foundations.Function open import Cubical.Foundations.Univalence using (hPropExt) open import Cubical.Data.Sigma private variable ℓ : Level X : Type ℓ ℙ : Type ℓ → Type (ℓ-suc ℓ) ℙ X = X → hProp _ isSetℙ : isSet (ℙ X) isSetℙ = isSetΠ λ x → isSetHProp infix 5 _∈_ _∈_ : {X : Type ℓ} → X → ℙ X → Type ℓ x ∈ A = ⟨ A x ⟩ _⊆_ : {X : Type ℓ} → ℙ X → ℙ X → Type ℓ A ⊆ B = ∀ x → x ∈ A → x ∈ B ∈-isProp : (A : ℙ X) (x : X) → isProp (x ∈ A) ∈-isProp A = snd ∘ A ⊆-isProp : (A B : ℙ X) → isProp (A ⊆ B) ⊆-isProp A B = isPropΠ2 (λ x _ → ∈-isProp B x) ⊆-refl : (A : ℙ X) → A ⊆ A ⊆-refl A x = idfun (x ∈ A) subst-∈ : (A : ℙ X) {x y : X} → x ≡ y → x ∈ A → y ∈ A subst-∈ A = subst (_∈ A) ⊆-refl-consequence : (A B : ℙ X) → A ≡ B → (A ⊆ B) × (B ⊆ A) ⊆-refl-consequence A B p = subst (A ⊆_) p (⊆-refl A) , subst (B ⊆_) (sym p) (⊆-refl B) ⊆-extensionality : (A B : ℙ X) → (A ⊆ B) × (B ⊆ A) → A ≡ B ⊆-extensionality A B (φ , ψ) = funExt (λ x → TypeOfHLevel≡ 1 (hPropExt (A x .snd) (B x .snd) (φ x) (ψ x))) ⊆-extensionalityEquiv : (A B : ℙ X) → (A ⊆ B) × (B ⊆ A) ≃ (A ≡ B) ⊆-extensionalityEquiv A B = isoToEquiv (iso (⊆-extensionality A B) (⊆-refl-consequence A B) (λ _ → isSetℙ A B _ _) (λ _ → isPropΣ (⊆-isProp A B) (λ _ → ⊆-isProp B A) _ _))
28.772727
106
0.555556
1a1dbcc4e58556300590e52c45a513493f7bb45d
2,045
agda
Agda
complete-progress.agda
hazelgrove/hazelnut-agda
a3640d7b0f76cdac193afd382694197729ed6d57
[ "MIT" ]
null
null
null
complete-progress.agda
hazelgrove/hazelnut-agda
a3640d7b0f76cdac193afd382694197729ed6d57
[ "MIT" ]
null
null
null
complete-progress.agda
hazelgrove/hazelnut-agda
a3640d7b0f76cdac193afd382694197729ed6d57
[ "MIT" ]
null
null
null
open import Nat open import Prelude open import dynamics-core open import contexts open import progress open import htype-decidable open import lemmas-complete module complete-progress where -- as in progress, we define a datatype for the possible outcomes of -- progress for readability. data okc : (d : ihexp) (Δ : hctx) → Set where V : ∀{d Δ} → d val → okc d Δ S : ∀{d Δ} → Σ[ d' ∈ ihexp ] (d ↦ d') → okc d Δ complete-progress : {Δ : hctx} {d : ihexp} {τ : htyp} → Δ , ∅ ⊢ d :: τ → d dcomplete → okc d Δ complete-progress wt comp with progress wt complete-progress wt comp | I x = abort (lem-ind-comp comp x) complete-progress wt comp | S x = S x complete-progress wt comp | BV (BVVal x) = V x complete-progress wt (DCCast comp x₂ ()) | BV (BVHoleCast x x₁) complete-progress (TACast wt x) (DCCast comp x₃ x₄) | BV (BVArrCast x₁ x₂) = abort (x₁ (complete-consistency x x₃ x₄)) complete-progress (TACast wt x) (DCCast comp x₃ x₄) | BV (BVSumCast x₁ x₂) = abort (x₁ (complete-consistency x x₃ x₄)) complete-progress (TAInl wt) (DCInl x₁ comp) | BV (BVInl x) with complete-progress wt comp ... | V v = V (VInl v) ... | S (_ , Step x₂ x₃ x₄) = S (_ , Step (FHInl x₂) x₃ (FHInl x₄)) complete-progress (TAInr wt) (DCInr x₁ comp) | BV (BVInr x) with complete-progress wt comp ... | V v = V (VInr v) ... | S (_ , Step x₂ x₃ x₄) = S (_ , Step (FHInr x₂) x₃ (FHInr x₄)) complete-progress (TAPair wt wt₁) (DCPair comp comp₁) | BV (BVPair x x₁) with complete-progress wt comp | complete-progress wt₁ comp₁ ... | V v | V v₁ = V (VPair v v₁) ... | V v | S (_ , Step x₁ x₂ x₃) = S (_ , Step (FHPair2 x₁) x₂ (FHPair2 x₃)) ... | S (_ , Step x₁ x₂ x₃) | V v = S (_ , Step (FHPair1 x₁) x₂ (FHPair1 x₃)) ... | S (_ , Step x₁ x₂ x₃) | S (_ , Step x₄ x₅ x₆) = S (_ , Step (FHPair1 x₁) x₂ (FHPair1 x₃)) complete-progress (TACast wt x₁) (DCCast comp x₂ x₃) | BV (BVProdCast x x₄) = abort (x (complete-consistency x₁ x₂ x₃))
45.444444
121
0.610758
2ec4dcad661994ef5487879a38414a5aa9ff9cef
6,407
agda
Agda
src/Categories/Morphism/Reasoning/Core.agda
MirceaS/agda-categories
58e5ec015781be5413bdf968f7ec4fdae0ab4b21
[ "MIT" ]
null
null
null
src/Categories/Morphism/Reasoning/Core.agda
MirceaS/agda-categories
58e5ec015781be5413bdf968f7ec4fdae0ab4b21
[ "MIT" ]
null
null
null
src/Categories/Morphism/Reasoning/Core.agda
MirceaS/agda-categories
58e5ec015781be5413bdf968f7ec4fdae0ab4b21
[ "MIT" ]
null
null
null
{-# OPTIONS --without-K --safe #-} open import Categories.Category {- Helper routines most often used in reasoning with commutative squares, at the level of arrows in categories. Basic : reasoning about identity Pulls : use a ∘ b ≈ c as left-to-right rewrite Pushes : use c ≈ a ∘ b as a left-to-right rewrite IntroElim : introduce/eliminate an equivalent-to-id arrow Extend : 'extends' a commutative square with an equality on left/right/both -} module Categories.Morphism.Reasoning.Core {o ℓ e} (C : Category o ℓ e) where open import Level open import Function renaming (id to idᶠ; _∘_ to _∙_) open import Relation.Binary hiding (_⇒_) open Category C private variable X Y : Obj a a′ a″ b b′ b″ c c′ c″ : X ⇒ Y f g h i : X ⇒ Y open HomReasoning module Basic where id-unique : ∀ {o} {f : o ⇒ o} → (∀ g → g ∘ f ≈ g) → f ≈ id id-unique g∘f≈g = trans (sym identityˡ) (g∘f≈g id) id-comm : ∀ {a b} {f : a ⇒ b} → f ∘ id ≈ id ∘ f id-comm = trans identityʳ (sym identityˡ) id-comm-sym : ∀ {a b} {f : a ⇒ b} → id ∘ f ≈ f ∘ id id-comm-sym = trans identityˡ (sym identityʳ) open Basic public module Utils where assoc² : ((i ∘ h) ∘ g) ∘ f ≈ i ∘ (h ∘ (g ∘ f)) assoc² = trans assoc assoc assoc²' : (i ∘ (h ∘ g)) ∘ f ≈ i ∘ (h ∘ (g ∘ f)) assoc²' = trans assoc (∘-resp-≈ʳ assoc) open Utils public module Pulls (ab≡c : a ∘ b ≈ c) where pullʳ : (f ∘ a) ∘ b ≈ f ∘ c pullʳ {f = f} = begin (f ∘ a) ∘ b ≈⟨ assoc ⟩ f ∘ (a ∘ b) ≈⟨ refl⟩∘⟨ ab≡c ⟩ f ∘ c ∎ pullˡ : a ∘ b ∘ f ≈ c ∘ f pullˡ {f = f} = begin a ∘ b ∘ f ≈⟨ sym-assoc ⟩ (a ∘ b) ∘ f ≈⟨ ab≡c ⟩∘⟨refl ⟩ c ∘ f ∎ open Pulls public module Pushes (c≡ab : c ≈ a ∘ b) where pushʳ : f ∘ c ≈ (f ∘ a) ∘ b pushʳ {f = f} = begin f ∘ c ≈⟨ refl⟩∘⟨ c≡ab ⟩ f ∘ (a ∘ b) ≈⟨ sym-assoc ⟩ (f ∘ a) ∘ b ∎ pushˡ : c ∘ f ≈ a ∘ (b ∘ f) pushˡ {f = f} = begin c ∘ f ≈⟨ c≡ab ⟩∘⟨refl ⟩ (a ∘ b) ∘ f ≈⟨ assoc ⟩ a ∘ (b ∘ f) ∎ open Pushes public module IntroElim (a≡id : a ≈ id) where elimʳ : f ∘ a ≈ f elimʳ {f = f} = begin f ∘ a ≈⟨ refl⟩∘⟨ a≡id ⟩ f ∘ id ≈⟨ identityʳ ⟩ f ∎ introʳ : f ≈ f ∘ a introʳ = Equiv.sym elimʳ elimˡ : (a ∘ f) ≈ f elimˡ {f = f} = begin a ∘ f ≈⟨ a≡id ⟩∘⟨refl ⟩ id ∘ f ≈⟨ identityˡ ⟩ f ∎ introˡ : f ≈ a ∘ f introˡ = Equiv.sym elimˡ open IntroElim public module Extends (s : CommutativeSquare f g h i) where extendˡ : CommutativeSquare f g (a ∘ h) (a ∘ i) extendˡ {a = a} = begin (a ∘ h) ∘ f ≈⟨ pullʳ s ⟩ a ∘ i ∘ g ≈⟨ sym-assoc ⟩ (a ∘ i) ∘ g ∎ extendʳ : CommutativeSquare (f ∘ a) (g ∘ a) h i extendʳ {a = a} = begin h ∘ (f ∘ a) ≈⟨ pullˡ s ⟩ (i ∘ g) ∘ a ≈⟨ assoc ⟩ i ∘ (g ∘ a) ∎ extend² : CommutativeSquare (f ∘ b) (g ∘ b) (a ∘ h) (a ∘ i) extend² {b = b} {a = a } = begin (a ∘ h) ∘ (f ∘ b) ≈⟨ pullʳ extendʳ ⟩ a ∘ (i ∘ (g ∘ b)) ≈⟨ sym-assoc ⟩ (a ∘ i) ∘ (g ∘ b) ∎ open Extends public -- essentially composition in the arrow category {- A₁ -- c --> B₁ | | b′ comm b | | V V A₂ -- c′ -> B₂ | | a′ comm a | | V V A₃ -- c″ -> B₃ then the whole diagram commutes -} glue : CommutativeSquare c′ a′ a c″ → CommutativeSquare c b′ b c′ → CommutativeSquare c (a′ ∘ b′) (a ∘ b) c″ glue {c′ = c′} {a′ = a′} {a = a} {c″ = c″} {c = c} {b′ = b′} {b = b} sq-a sq-b = begin (a ∘ b) ∘ c ≈⟨ pullʳ sq-b ⟩ a ∘ (c′ ∘ b′) ≈⟨ pullˡ sq-a ⟩ (c″ ∘ a′) ∘ b′ ≈⟨ assoc ⟩ c″ ∘ (a′ ∘ b′) ∎ glue◃◽ : a ∘ c′ ≈ c″ → CommutativeSquare c b′ b c′ → CommutativeSquare c b′ (a ∘ b) c″ glue◃◽ {a = a} {c′ = c′} {c″ = c″} {c = c} {b′ = b′} {b = b} tri-a sq-b = begin (a ∘ b) ∘ c ≈⟨ pullʳ sq-b ⟩ a ∘ (c′ ∘ b′) ≈⟨ pullˡ tri-a ⟩ c″ ∘ b′ ∎ glue◃◽′ : c ∘ c′ ≈ a′ → CommutativeSquare a b a′ b′ → CommutativeSquare (c′ ∘ a) b c b′ glue◃◽′ {c = c} {c′ = c′} {a′ = a′} {a = a} {b = b} {b′ = b′} tri sq = begin c ∘ c′ ∘ a ≈⟨ pullˡ tri ⟩ a′ ∘ a ≈⟨ sq ⟩ b′ ∘ b ∎ glue◽◃ : CommutativeSquare a b a′ b′ → b ∘ c ≈ c′ → CommutativeSquare (a ∘ c) c′ a′ b′ glue◽◃ {a = a} {b = b} {a′ = a′} {b′ = b′} {c = c} {c′ = c′} sq tri = begin a′ ∘ a ∘ c ≈⟨ pullˡ sq ⟩ (b′ ∘ b) ∘ c ≈⟨ pullʳ tri ⟩ b′ ∘ c′ ∎ glue▹◽ : b ∘ a″ ≈ c → CommutativeSquare a b a′ b′ → CommutativeSquare (a ∘ a″) c a′ b′ glue▹◽ {b = b} {a″ = a″} {c = c} {a = a} {a′ = a′} {b′ = b′} tri sq = begin a′ ∘ a ∘ a″ ≈⟨ pullˡ sq ⟩ (b′ ∘ b) ∘ a″ ≈⟨ pullʳ tri ⟩ b′ ∘ c ∎ -- essentially composition in the over category glueTrianglesʳ : a ∘ b ≈ a′ → a′ ∘ b′ ≈ a″ → a ∘ (b ∘ b′) ≈ a″ glueTrianglesʳ {a = a} {b = b} {a′ = a′} {b′ = b′} {a″ = a″} a∘b≡a′ a′∘b′≡a″ = begin a ∘ (b ∘ b′) ≈⟨ pullˡ a∘b≡a′ ⟩ a′ ∘ b′ ≈⟨ a′∘b′≡a″ ⟩ a″ ∎ -- essentially composition in the under category glueTrianglesˡ : a′ ∘ b′ ≈ b″ → a ∘ b ≈ b′ → (a′ ∘ a) ∘ b ≈ b″ glueTrianglesˡ {a′ = a′} {b′ = b′} {b″ = b″} {a = a} {b = b} a′∘b′≡b″ a∘b≡b′ = begin (a′ ∘ a) ∘ b ≈⟨ pullʳ a∘b≡b′ ⟩ a′ ∘ b′ ≈⟨ a′∘b′≡b″ ⟩ b″ ∎ module Cancellers (inv : h ∘ i ≈ id) where cancelʳ : (f ∘ h) ∘ i ≈ f cancelʳ {f = f} = begin (f ∘ h) ∘ i ≈⟨ pullʳ inv ⟩ f ∘ id ≈⟨ identityʳ ⟩ f ∎ cancelˡ : h ∘ (i ∘ f) ≈ f cancelˡ {f = f} = begin h ∘ (i ∘ f) ≈⟨ pullˡ inv ⟩ id ∘ f ≈⟨ identityˡ ⟩ f ∎ cancelInner : (f ∘ h) ∘ (i ∘ g) ≈ f ∘ g cancelInner {f = f} {g = g} = begin (f ∘ h) ∘ (i ∘ g) ≈⟨ pullˡ cancelʳ ⟩ f ∘ g ∎ open Cancellers public center : g ∘ h ≈ a → (f ∘ g) ∘ h ∘ i ≈ f ∘ a ∘ i center {g = g} {h = h} {a = a} {f = f} {i = i} eq = begin (f ∘ g) ∘ h ∘ i ≈⟨ assoc ⟩ f ∘ g ∘ h ∘ i ≈⟨ refl⟩∘⟨ pullˡ eq ⟩ f ∘ a ∘ i ∎ center⁻¹ : f ∘ g ≈ a → h ∘ i ≈ b → f ∘ (g ∘ h) ∘ i ≈ a ∘ b center⁻¹ {f = f} {g = g} {a = a} {h = h} {i = i} {b = b} eq eq′ = begin f ∘ (g ∘ h) ∘ i ≈⟨ refl⟩∘⟨ pullʳ eq′ ⟩ f ∘ g ∘ b ≈⟨ pullˡ eq ⟩ a ∘ b ∎ pull-last : h ∘ i ≈ a → (f ∘ g ∘ h) ∘ i ≈ f ∘ g ∘ a pull-last {h = h} {i = i} {a = a} {f = f} {g = g} eq = begin (f ∘ g ∘ h) ∘ i ≈⟨ assoc ⟩ f ∘ (g ∘ h) ∘ i ≈⟨ refl⟩∘⟨ pullʳ eq ⟩ f ∘ g ∘ a ∎ pull-first : f ∘ g ≈ a → f ∘ (g ∘ h) ∘ i ≈ a ∘ h ∘ i pull-first {f = f} {g = g} {a = a} {h = h} {i = i} eq = begin f ∘ (g ∘ h) ∘ i ≈⟨ refl⟩∘⟨ assoc ⟩ f ∘ g ∘ h ∘ i ≈⟨ pullˡ eq ⟩ a ∘ h ∘ i ∎
27.616379
87
0.449196
1d3fafbc65b79b7f5ece5f92c55e319d1ad1db21
7,220
agda
Agda
TotalParserCombinators/Derivative/SoundComplete.agda
yurrriq/parser-combinators
b396d35cc2cb7e8aea50b982429ee385f001aa88
[ "MIT" ]
7
2016-12-13T05:23:14.000Z
2021-06-22T05:35:31.000Z
TotalParserCombinators/Derivative/SoundComplete.agda
yurrriq/parser-combinators
b396d35cc2cb7e8aea50b982429ee385f001aa88
[ "MIT" ]
1
2018-01-22T22:21:41.000Z
2018-01-24T16:39:37.000Z
TotalParserCombinators/Derivative/SoundComplete.agda
yurrriq/parser-combinators
b396d35cc2cb7e8aea50b982429ee385f001aa88
[ "MIT" ]
null
null
null
------------------------------------------------------------------------ -- Soundness and completeness ------------------------------------------------------------------------ module TotalParserCombinators.Derivative.SoundComplete where open import Category.Monad open import Coinduction open import Data.List import Data.List.Categorical open import Data.Maybe open import Data.Product open import Level open import Relation.Binary.PropositionalEquality open RawMonad {f = zero} Data.List.Categorical.monad using () renaming (_>>=_ to _>>=′_; _⊛_ to _⊛′_) open import TotalParserCombinators.Derivative.Definition import TotalParserCombinators.InitialBag as I open import TotalParserCombinators.Lib open import TotalParserCombinators.Parser open import TotalParserCombinators.Semantics ------------------------------------------------------------------------ -- Soundness sound : ∀ {Tok R xs x s} {t} (p : Parser Tok R xs) → x ∈ D t p · s → x ∈ p · t ∷ s sound token return = token sound (p₁ ∣ p₂) (∣-left x∈p₁) = ∣-left (sound p₁ x∈p₁) sound (_∣_ {xs₁ = xs₁} p₁ p₂) (∣-right ._ x∈p₂) = ∣-right xs₁ (sound p₂ x∈p₂) sound (f <$> p) (<$> x∈p) = <$> sound p x∈p sound (_⊛_ {fs = nothing} {xs = just _} p₁ p₂) (f∈p₁′ ⊛ x∈p₂) = [ ○ - ◌ ] sound p₁ f∈p₁′ ⊛ x∈p₂ sound (_⊛_ {fs = just _} {xs = just _} p₁ p₂) (∣-left (f∈p₁′ ⊛ x∈p₂)) = [ ○ - ○ ] sound p₁ f∈p₁′ ⊛ x∈p₂ sound (_⊛_ {fs = just fs} {xs = just _} p₁ p₂) (∣-right ._ (f∈ret⋆ ⊛ x∈p₂′)) with Return⋆.sound fs f∈ret⋆ sound (_⊛_ {fs = just fs} {xs = just _} p₁ p₂) (∣-right ._ (f∈ret⋆ ⊛ x∈p₂′)) | (refl , f∈fs) = [ ○ - ○ ] I.sound p₁ f∈fs ⊛ sound p₂ x∈p₂′ sound (_⊛_ {fs = nothing} {xs = nothing} p₁ p₂) (f∈p₁′ ⊛ x∈p₂) = [ ◌ - ◌ ] sound (♭ p₁) f∈p₁′ ⊛ x∈p₂ sound (_⊛_ {fs = just _} {xs = nothing} p₁ p₂) (∣-left (f∈p₁′ ⊛ x∈p₂)) = [ ◌ - ○ ] sound (♭ p₁) f∈p₁′ ⊛ x∈p₂ sound (_⊛_ {fs = just fs} {xs = nothing} p₁ p₂) (∣-right ._ (f∈ret⋆ ⊛ x∈p₂′)) with Return⋆.sound fs f∈ret⋆ sound (_⊛_ {fs = just fs} {xs = nothing} p₁ p₂) (∣-right ._ (f∈ret⋆ ⊛ x∈p₂′)) | (refl , f∈fs) = [ ◌ - ○ ] I.sound (♭ p₁) f∈fs ⊛ sound p₂ x∈p₂′ sound (_>>=_ {xs = nothing} {f = just _} p₁ p₂) (x∈p₁′ >>= y∈p₂x) = [ ○ - ◌ ] sound p₁ x∈p₁′ >>= y∈p₂x sound (_>>=_ {xs = just xs} {f = just _} p₁ p₂) (∣-right ._ (y∈ret⋆ >>= z∈p₂′y)) with Return⋆.sound xs y∈ret⋆ sound (_>>=_ {xs = just xs} {f = just _} p₁ p₂) (∣-right ._ (y∈ret⋆ >>= z∈p₂′y)) | (refl , y∈xs) = [ ○ - ○ ] I.sound p₁ y∈xs >>= sound (p₂ _) z∈p₂′y sound (_>>=_ {xs = just xs} {f = just _} p₁ p₂) (∣-left (x∈p₁′ >>= y∈p₂x)) = [ ○ - ○ ] sound p₁ x∈p₁′ >>= y∈p₂x sound (_>>=_ {xs = nothing} {f = nothing} p₁ p₂) (x∈p₁′ >>= y∈p₂x) = [ ◌ - ◌ ] sound (♭ p₁) x∈p₁′ >>= y∈p₂x sound (_>>=_ {xs = just xs} {f = nothing} p₁ p₂) (∣-right ._ (y∈ret⋆ >>= z∈p₂′y)) with Return⋆.sound xs y∈ret⋆ sound (_>>=_ {xs = just xs} {f = nothing} p₁ p₂) (∣-right ._ (y∈ret⋆ >>= z∈p₂′y)) | (refl , y∈xs) = [ ◌ - ○ ] I.sound (♭ p₁) y∈xs >>= sound (p₂ _) z∈p₂′y sound (_>>=_ {xs = just xs} {f = nothing} p₁ p₂) (∣-left (x∈p₁′ >>= y∈p₂x)) = [ ◌ - ○ ] sound (♭ p₁) x∈p₁′ >>= y∈p₂x sound (nonempty p) x∈p = nonempty (sound p x∈p) sound (cast _ p) x∈p = cast (sound p x∈p) sound (return _) () sound fail () ------------------------------------------------------------------------ -- Completeness mutual complete : ∀ {Tok R xs x s t} {p : Parser Tok R xs} → x ∈ p · t ∷ s → x ∈ D t p · s complete x∈p = complete′ _ x∈p refl complete′ : ∀ {Tok R xs x s s′ t} (p : Parser Tok R xs) → x ∈ p · s′ → s′ ≡ t ∷ s → x ∈ D t p · s complete′ token token refl = return complete′ (p₁ ∣ p₂) (∣-left x∈p₁) refl = ∣-left (complete x∈p₁) complete′ (p₁ ∣ p₂) (∣-right _ x∈p₂) refl = ∣-right (D-bag _ p₁) (complete x∈p₂) complete′ (f <$> p) (<$> x∈p) refl = <$> complete x∈p complete′ (_⊛_ {fs = nothing} {xs = just _} p₁ p₂) (_⊛_ {s₁ = _ ∷ _} f∈p₁ x∈p₂) refl = _⊛_ {fs = ○} {xs = ○} (complete f∈p₁) x∈p₂ complete′ (_⊛_ {fs = just _} {xs = just _} p₁ p₂) (_⊛_ {s₁ = _ ∷ _} f∈p₁ x∈p₂) refl = ∣-left (_⊛_ {fs = ○} {xs = ○} (complete f∈p₁) x∈p₂) complete′ (_⊛_ {fs = just _} {xs = just xs} p₁ p₂) (_⊛_ {s₁ = []} f∈p₁ x∈p₂) refl = ∣-right (D-bag _ p₁ ⊛′ xs) (_⊛_ {fs = ○} {xs = ○} (Return⋆.complete (I.complete f∈p₁)) (complete x∈p₂)) complete′ (_⊛_ {fs = nothing} {xs = nothing} p₁ p₂) (_⊛_ {s₁ = _ ∷ _} f∈p₁ x∈p₂) refl = _⊛_ {fs = ○} {xs = ◌} (complete f∈p₁) x∈p₂ complete′ (_⊛_ {fs = just _} {xs = nothing} p₁ p₂) (_⊛_ {s₁ = _ ∷ _} f∈p₁ x∈p₂) refl = ∣-left (_⊛_ {fs = ○} {xs = ◌} (complete f∈p₁) x∈p₂) complete′ (_⊛_ {fs = just _} {xs = nothing} p₁ p₂) (_⊛_ {s₁ = []} f∈p₁ x∈p₂) refl = ∣-right [] (_⊛_ {fs = ○} {xs = ○} (Return⋆.complete (I.complete f∈p₁)) (complete x∈p₂)) complete′ (_>>=_ {xs = nothing} {f = just _} p₁ p₂) (_>>=_ {s₁ = _ ∷ _} x∈p₁ y∈p₂x) refl = _>>=_ {xs = ○} {f = ○} (complete x∈p₁) y∈p₂x complete′ (_>>=_ {xs = just _} {f = just _} p₁ p₂) (_>>=_ {s₁ = _ ∷ _} x∈p₁ y∈p₂x) refl = ∣-left (_>>=_ {xs = ○} {f = ○} (complete x∈p₁) y∈p₂x) complete′ (_>>=_ {xs = just _} {f = just f} p₁ p₂) (_>>=_ {s₁ = []} x∈p₁ y∈p₂x) refl = ∣-right (D-bag _ p₁ >>=′ f) (_>>=_ {xs = ○} {f = ○} (Return⋆.complete (I.complete x∈p₁)) (complete y∈p₂x)) complete′ (_>>=_ {xs = nothing} {f = nothing} p₁ p₂) (_>>=_ {s₁ = _ ∷ _} x∈p₁ y∈p₂x) refl = _>>=_ {xs = ○} {f = ◌} (complete x∈p₁) y∈p₂x complete′ (_>>=_ {xs = just _} {f = nothing} p₁ p₂) (_>>=_ {s₁ = _ ∷ _} x∈p₁ y∈p₂x) refl = ∣-left (_>>=_ {xs = ○} {f = ◌} (complete x∈p₁) y∈p₂x) complete′ (_>>=_ {xs = just _} {f = nothing} p₁ p₂) (_>>=_ {s₁ = []} x∈p₁ y∈p₂x) refl = ∣-right [] (_>>=_ {xs = ○} {f = ○} (Return⋆.complete (I.complete x∈p₁)) (complete y∈p₂x)) complete′ (nonempty p) (nonempty x∈p) refl = complete x∈p complete′ (cast _ p) (cast x∈p) refl = complete x∈p complete′ (return _) () refl complete′ fail () refl complete′ (_⊛_ {fs = nothing} _ _) (_⊛_ {s₁ = []} f∈p₁ _) _ with I.complete f∈p₁ ... | () complete′ (_>>=_ {xs = nothing} _ _) (_>>=_ {s₁ = []} x∈p₁ _) _ with I.complete x∈p₁ ... | ()
58.699187
137
0.426177
58c0677a1cd94bf70b50a3479d620f9a0c0934e9
264
agda
Agda
test/Compiler/simple/InlineRecursive.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Compiler/simple/InlineRecursive.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Compiler/simple/InlineRecursive.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
{-# OPTIONS -v treeless.opt:20 #-} -- Test that inlining a recursive function doesn't throw -- the compiler into a loop. module _ where open import Common.Prelude f : Nat → Nat f zero = zero f (suc n) = f n {-# INLINE f #-} main : IO Unit main = printNat (f 4)
17.6
56
0.662879
4de90ab092599afec6a90e58f3095d391707d8ec
1,309
agda
Agda
test/asset/agda-stdlib-1.0/Data/Container/Relation/Unary/Any.agda
omega12345/agda-mode
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
[ "MIT" ]
5
2020-10-07T12:07:53.000Z
2020-10-10T21:41:32.000Z
test/asset/agda-stdlib-1.0/Data/Container/Relation/Unary/Any.agda
omega12345/agda-mode
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
[ "MIT" ]
null
null
null
test/asset/agda-stdlib-1.0/Data/Container/Relation/Unary/Any.agda
omega12345/agda-mode
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
[ "MIT" ]
1
2021-11-04T06:54:45.000Z
2021-11-04T06:54:45.000Z
------------------------------------------------------------------------ -- The Agda standard library -- -- Any (◇) for containers ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Container.Relation.Unary.Any where open import Level using (_⊔_) open import Relation.Unary using (Pred; _⊆_) open import Data.Product as Prod using (_,_; proj₂; ∃) open import Function open import Data.Container.Core hiding (map) import Data.Container.Morphism as M record ◇ {s p} (C : Container s p) {x ℓ} {X : Set x} (P : Pred X ℓ) (cx : ⟦ C ⟧ X) : Set (p ⊔ ℓ) where constructor any field proof : ∃ λ p → P (proj₂ cx p) module _ {s₁ p₁ s₂ p₂} {C : Container s₁ p₁} {D : Container s₂ p₂} {x ℓ ℓ′} {X : Set x} {P : Pred X ℓ} {Q : Pred X ℓ′} where map : (f : C ⇒ D) → P ⊆ Q → ◇ D P ∘′ ⟪ f ⟫ ⊆ ◇ C Q map f P⊆Q (any (p , P)) .◇.proof = f .position p , P⊆Q P module _ {s₁ p₁ s₂ p₂} {C : Container s₁ p₁} {D : Container s₂ p₂} {x ℓ} {X : Set x} {P : Pred X ℓ} where map₁ : (f : C ⇒ D) → ◇ D P ∘′ ⟪ f ⟫ ⊆ ◇ C P map₁ f = map f id module _ {s p} {C : Container s p} {x ℓ ℓ′} {X : Set x} {P : Pred X ℓ} {Q : Pred X ℓ′} where map₂ : P ⊆ Q → ◇ C P ⊆ ◇ C Q map₂ = map (M.id C)
28.456522
72
0.477464
586de4986a9e42518fc3bdb5129fa5ce68d0cdf5
588
agda
Agda
agda-stdlib/src/Relation/Binary/EquivalenceClosure.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
5
2020-10-07T12:07:53.000Z
2020-10-10T21:41:32.000Z
agda-stdlib/src/Relation/Binary/EquivalenceClosure.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
null
null
null
agda-stdlib/src/Relation/Binary/EquivalenceClosure.agda
DreamLinuxer/popl21-artifact
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
[ "MIT" ]
1
2021-11-04T06:54:45.000Z
2021-11-04T06:54:45.000Z
------------------------------------------------------------------------ -- The Agda standard library -- -- This module is DEPRECATED. Please use the -- Relation.Binary.Construct.Closure.Equivalence module directly. ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Relation.Binary.EquivalenceClosure where open import Relation.Binary.Construct.Closure.Equivalence public {-# WARNING_ON_IMPORT "Relation.Binary.EquivalenceClosure was deprecated in v0.16. Use Relation.Binary.Construct.Closure.Equivalence instead." #-}
32.666667
72
0.593537
2eeb0d89fe4b149af2a4427b4baa901f6101d5ef
1,161
agda
Agda
src/fot/Agsy/DistributiveLaws/TaskB.agda
asr/fotc
2fc9f2b81052a2e0822669f02036c5750371b72d
[ "MIT" ]
11
2015-09-03T20:53:42.000Z
2021-09-12T16:09:54.000Z
src/fot/Agsy/DistributiveLaws/TaskB.agda
asr/fotc
2fc9f2b81052a2e0822669f02036c5750371b72d
[ "MIT" ]
2
2016-10-12T17:28:16.000Z
2017-01-01T14:34:26.000Z
src/fot/Agsy/DistributiveLaws/TaskB.agda
asr/fotc
2fc9f2b81052a2e0822669f02036c5750371b72d
[ "MIT" ]
3
2016-09-19T14:18:30.000Z
2018-03-14T08:50:00.000Z
------------------------------------------------------------------------------ -- Example using distributive laws on a binary operation via Agsy ------------------------------------------------------------------------------ {-# OPTIONS --allow-unsolved-metas #-} {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- Tested with the development version of the Agda standard library on -- 02 February 2012. module Agsy.DistributiveLaws.TaskB where open import Relation.Binary.PropositionalEquality open ≡-Reasoning infixl 7 _·_ ------------------------------------------------------------------------------ -- Distributive laws axioms postulate D : Set -- The universe _·_ : D → D → D -- The binary operation. leftDistributive : ∀ x y z → x · (y · z) ≡ (x · y) · (x · z) rightDistributive : ∀ x y z → (x · y) · z ≡ (x · z) · (y · z) -- Properties taskB : ∀ u x y z → (x · y · (z · u)) · ((x · y · ( z · u)) · (x · z · (y · u))) ≡ x · z · (y · u) taskB u x y z = {!-t 20 -m!} -- Agsy fails
31.378378
78
0.440138
1a3a6b01e159cb89dfc9c01f08d696c48533c814
3,049
agda
Agda
BasicIS4/Metatheory/DyadicGentzen-TarskiGluedDyadicImplicit.agda
mietek/hilbert-gentzen
fcd187db70f0a39b894fe44fad0107f61849405c
[ "X11" ]
29
2016-07-03T18:51:56.000Z
2022-01-01T10:29:18.000Z
BasicIS4/Metatheory/DyadicGentzen-TarskiGluedDyadicImplicit.agda
mietek/hilbert-gentzen
fcd187db70f0a39b894fe44fad0107f61849405c
[ "X11" ]
1
2018-06-10T09:11:22.000Z
2018-06-10T09:11:22.000Z
BasicIS4/Metatheory/DyadicGentzen-TarskiGluedDyadicImplicit.agda
mietek/hilbert-gentzen
fcd187db70f0a39b894fe44fad0107f61849405c
[ "X11" ]
null
null
null
module BasicIS4.Metatheory.DyadicGentzen-TarskiGluedDyadicImplicit where open import BasicIS4.Syntax.DyadicGentzen public open import BasicIS4.Semantics.TarskiGluedDyadicImplicit public open ImplicitSyntax (_⊢_) public -- Soundness with respect to all models, or evaluation. -- FIXME postulate reify⋆ : ∀ {{_ : Model}} {Ξ Γ Δ} → Γ ⁏ Δ ⊩⋆ Ξ → Γ ⁏ Δ ⊢⋆ Ξ eval : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊨ A eval (var i) γ δ = lookup i γ eval (lam t) γ δ = λ ψ a → eval t (mono²⊩⋆ ψ γ , a) (mono²⊩⋆ ψ δ) eval (app {A} {B} t u) γ δ = _⟪$⟫_ {A} {B} (eval t γ δ) (eval u γ δ) eval (mvar i) γ δ = mlookup i δ eval (box t) γ δ = λ ψ → let δ′ = mono²⊩⋆ ψ δ in mmulticut (reify⋆ δ′) (box t) ⅋ eval t ∙ δ′ eval (unbox t u) γ δ = eval u γ (δ , λ ψ → let γ′ = mono²⊩⋆ ψ γ δ′ = mono²⊩⋆ ψ δ in multicut² (reify⋆ γ′) (reify⋆ δ′) t ⅋ ⟪↓⟫ (eval t γ′ δ′)) eval (pair t u) γ δ = eval t γ δ , eval u γ δ eval (fst t) γ δ = π₁ (eval t γ δ) eval (snd t) γ δ = π₂ (eval t γ δ) eval unit γ δ = ∙ -- TODO: Correctness of evaluation with respect to conversion. -- The canonical model. private instance canon : Model canon = record { _⊩ᵅ_ = λ Π P → Π ⊢ α P ; mono²⊩ᵅ = mono²⊢ } -- Soundness and completeness with respect to the canonical model. mutual reflectᶜ : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊩ A reflectᶜ {α P} t = t reflectᶜ {A ▻ B} t = λ ψ → let t′ = mono²⊢ ψ t in λ a → reflectᶜ (app t′ (reifyᶜ a)) reflectᶜ {□ A} t = λ ψ → let t′ = mono²⊢ ψ t in t′ ⅋ reflectᶜ (down t′) reflectᶜ {A ∧ B} t = reflectᶜ (fst t) , reflectᶜ (snd t) reflectᶜ {⊤} t = ∙ reifyᶜ : ∀ {A Γ Δ} → Γ ⁏ Δ ⊩ A → Γ ⁏ Δ ⊢ A reifyᶜ {α P} s = s reifyᶜ {A ▻ B} s = lam (reifyᶜ (s (weak⊆²₁) (reflectᶜ {A} v₀))) reifyᶜ {□ A} s = syn (s refl⊆²) reifyᶜ {A ∧ B} s = pair (reifyᶜ (π₁ s)) (reifyᶜ (π₂ s)) reifyᶜ {⊤} s = unit reflectᶜ⋆ : ∀ {Ξ Γ Δ} → Γ ⁏ Δ ⊢⋆ Ξ → Γ ⁏ Δ ⊩⋆ Ξ reflectᶜ⋆ {∅} ∙ = ∙ reflectᶜ⋆ {Ξ , A} (ts , t) = reflectᶜ⋆ ts , reflectᶜ t reifyᶜ⋆ : ∀ {Ξ Γ Δ} → Γ ⁏ Δ ⊩⋆ Ξ → Γ ⁏ Δ ⊢⋆ Ξ reifyᶜ⋆ {∅} ∙ = ∙ reifyᶜ⋆ {Ξ , A} (ts , t) = reifyᶜ⋆ ts , reifyᶜ t -- Reflexivity and transitivity. refl⊩⋆ : ∀ {Γ Δ} → Γ ⁏ Δ ⊩⋆ Γ refl⊩⋆ = reflectᶜ⋆ refl⊢⋆ mrefl⊩⋆ : ∀ {Γ Δ} → Γ ⁏ Δ ⊩⋆ □⋆ Δ mrefl⊩⋆ = reflectᶜ⋆ mrefl⊢⋆ trans⊩⋆ : ∀ {Γ Γ′ Δ Δ′ Ξ} → Γ ⁏ Δ ⊩⋆ Γ′ ⧺ (□⋆ Δ′) → Γ′ ⁏ Δ′ ⊩⋆ Ξ → Γ ⁏ Δ ⊩⋆ Ξ trans⊩⋆ ts us = reflectᶜ⋆ (trans⊢⋆ (reifyᶜ⋆ ts) (reifyᶜ⋆ us)) -- Completeness with respect to all models, or quotation. quot : ∀ {A Γ Δ} → Γ ⁏ Δ ⊨ A → Γ ⁏ Δ ⊢ A quot s = reifyᶜ (s refl⊩⋆ mrefl⊩⋆) -- Normalisation by evaluation. norm : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ A norm = quot ∘ eval -- TODO: Correctness of normalisation with respect to conversion.
30.188119
77
0.481141
adbd019ac945713a2a91f5cb79399ecf0347b7fc
10,798
agda
Agda
Univalence/Obsolete/SEquivSCPermEquiv.agda
JacquesCarette/pi-dual
003835484facfde0b770bc2b3d781b42b76184c1
[ "BSD-2-Clause" ]
14
2015-08-18T21:40:15.000Z
2021-05-05T01:07:57.000Z
Univalence/Obsolete/SEquivSCPermEquiv.agda
JacquesCarette/pi-dual
003835484facfde0b770bc2b3d781b42b76184c1
[ "BSD-2-Clause" ]
4
2018-06-07T16:27:41.000Z
2021-10-29T20:41:23.000Z
Univalence/Obsolete/SEquivSCPermEquiv.agda
JacquesCarette/pi-dual
003835484facfde0b770bc2b3d781b42b76184c1
[ "BSD-2-Clause" ]
3
2016-05-29T01:56:33.000Z
2019-09-10T09:47:13.000Z
{-# OPTIONS --without-K #-} module SEquivSCPermEquiv where -- Data types from standard library open import Level using (zero) open import Data.Nat using (ℕ; _+_) open import Data.Fin using (Fin; inject+; raise) open import Data.Sum using (inj₁; inj₂) open import Data.Product using (_,_; proj₁; proj₂) open import Data.Vec using (tabulate) renaming (_++_ to _++V_) open import Function using (_∘_; id) -- Properties from standard library open import Data.Vec.Properties using (lookup∘tabulate) open import Relation.Binary using (Setoid) open import Function.Equality using (_⇨_; _⟨$⟩_; _⟶_) renaming (_∘_ to _⊚_; id to id⊚) open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; cong; cong₂; setoid; →-to-⟶; module ≡-Reasoning) -- Next are imports from our libraries of Proofs (FiniteFunctions and -- VectorLemmas) open import Proofs using (finext; _!!_; tabulate-split) -- Next we import our notions of equivalences open import Equiv using (_∼_; module qinv; mkqinv; _≃_) -- Next we import sets equipped with equivalence relations and -- specialize to our notions of equivalence open import SetoidEquiv using ( ≃S-Setoid; -- statement of thm2 _≃S_; -- statement of thm2 module _≃S_; -- proof of thm2 module _≋_; -- proof of thm2 equiv; -- proof of thm2 equivS; -- proof of thm2 _≋_ -- proof of thm2 -- id≃S; -- 0≃S; -- _≃S≡_; -- _⊎≃S_ ) -- Finally we import our definition of permutations. We start with Vec -- (Fin m) n for arbitrary m and n which---if well-formed---would -- define a permutation in the Cauchy representation. These vectors -- assume a canonical enumeration of the finite sets which we make -- explicit in the module Enumeration. To ensure these vectors are -- well-formed, we define a concrete permutation as a pair of two such -- vectors with two proofs that they compose to the identity -- permutation. open import FinVec using (module F) open F using (~⇒≡; !!⇒∘̂; _∘̂_; 1C!!i≡i; cauchyext) open import EnumEquiv using (Enum; 0E; _⊕e_; eval-left; eval-right) open import ConcretePermutation using (CPerm; cp; p≡; 0p; idp; _⊎p_) -- ; SCPerm) ------------------------------------------------------------------------------ -- The big (semantic) theorem! SCPerm : ℕ → ℕ → Setoid zero zero SCPerm m n = setoid (CPerm m n) -- For convenience, use only a single size, even though we could use 2. thm2 : ∀ {n} {A B : Set} → Enum A n → Enum B n → (≃S-Setoid A B) ≃S (SCPerm n n) thm2 {n} {A} {B} (enumA , mkqinv labelA αA βA) (enumB , mkqinv labelB αB βB) = equiv fwd' bwd' α β where open ≡-Reasoning AS = setoid A BS = setoid B A≃Fn : A ≃ Fin n A≃Fn = (enumA , mkqinv labelA αA βA) B≃Fn : B ≃ Fin n B≃Fn = (enumB , mkqinv labelB αB βB) CP⇨ = SCPerm n n ⇨ SCPerm n n fwd : (AS ≃S BS) → CPerm n n fwd A≃B = cp (tabulate f) (tabulate g) (~⇒≡ β) (~⇒≡ α) where module A≃SB = _≃S_ A≃B f : Fin n → Fin n f j = enumB (A≃SB.f ⟨$⟩ labelA j) g : Fin n → Fin n g j = enumA (A≃SB.g ⟨$⟩ labelB j) α : f ∘ g ∼ id α i = begin (enumB (A≃SB.f ⟨$⟩ (labelA (enumA (A≃SB.g ⟨$⟩ labelB i)))) ≡⟨ cong (λ x → enumB (A≃SB.f ⟨$⟩ x)) (βA ((A≃SB.g ⟨$⟩ labelB i))) ⟩ enumB (A≃SB.f ⟨$⟩ (A≃SB.g ⟨$⟩ labelB i)) ≡⟨ cong enumB (A≃SB.α refl) ⟩ enumB (labelB i) ≡⟨ αB i ⟩ i ∎) β : g ∘ f ∼ id β i = begin ( enumA (A≃SB.g ⟨$⟩ labelB (enumB (A≃SB.f ⟨$⟩ labelA i))) ≡⟨ cong (λ x → enumA (A≃SB.g ⟨$⟩ x)) (βB _) ⟩ enumA (A≃SB.g ⟨$⟩ (A≃SB.f ⟨$⟩ labelA i)) ≡⟨ cong enumA (A≃SB.β refl) ⟩ enumA (labelA i) ≡⟨ αA i ⟩ i ∎) fwd' : ≃S-Setoid A B ⟶ setoid (CPerm n n) fwd' = record { _⟨$⟩_ = fwd ; cong = λ {i} {j} i≋j → p≡ (finext (λ k → cong enumB (f≡ i≋j (labelA k)) )) } where open _≋_ bwd : CPerm n n → (AS ≃S BS) bwd (cp p₁ p₂ αp βp) = equiv f g α β where f : AS ⟶ BS f = →-to-⟶ (λ a → labelB (p₁ !! enumA a)) g : BS ⟶ AS g = →-to-⟶ (λ b → labelA (p₂ !! (enumB b))) α : Setoid._≈_ (BS ⇨ BS) (f ⊚ g) id⊚ α {b} {.b} refl = begin ( labelB (p₁ !! (enumA (labelA (p₂ !! (enumB b))))) ≡⟨ cong (λ x → labelB (p₁ !! x)) (αA _) ⟩ labelB (p₁ !! (p₂ !! enumB b)) ≡⟨ cong labelB (!!⇒∘̂ _ _ (enumB b)) ⟩ labelB ((p₂ ∘̂ p₁) !! enumB b) ≡⟨ cong (λ x → (labelB (x !! enumB b))) βp ⟩ labelB (F.1C !! enumB b) ≡⟨ cong labelB 1C!!i≡i ⟩ labelB (enumB b) ≡⟨ βB b ⟩ b ∎) β : Setoid._≈_ (AS ⇨ AS) (g ⊚ f) id⊚ β {a} {.a} refl = begin ( labelA (p₂ !! (enumB (labelB (p₁ !! enumA a)))) ≡⟨ cong (λ x → labelA (p₂ !! x)) (αB _) ⟩ labelA (p₂ !! (p₁ !! enumA a)) ≡⟨ cong labelA (!!⇒∘̂ _ _ (enumA a)) ⟩ labelA ((p₁ ∘̂ p₂) !! enumA a) ≡⟨ cong (λ x → labelA (x !! enumA a)) αp ⟩ labelA (F.1C !! enumA a) ≡⟨ cong labelA 1C!!i≡i ⟩ labelA (enumA a) ≡⟨ βA a ⟩ a ∎) bwd' : setoid (CPerm n n) ⟶ ≃S-Setoid A B bwd' = record { _⟨$⟩_ = bwd ; cong = λ { {π} {.π} refl → equivS (λ _ → refl) (λ _ → refl) } } α : Setoid._≈_ CP⇨ (fwd' ⊚ bwd') id⊚ α {cp π πᵒ αp βp} refl = p≡ (trans (finext pf₁) (cauchyext π)) where pf₁ : (j : Fin n) → enumB (labelB (π !! enumA (labelA j))) ≡ π !! j pf₁ j = begin ( enumB (labelB (π !! enumA (labelA j))) ≡⟨ αB _ ⟩ π !! enumA (labelA j) ≡⟨ cong (_!!_ π) (αA _) ⟩ π !! j ∎) β : {x y : AS ≃S BS} → x ≋ y → ((bwd' ⊚ fwd') ⟨$⟩ x) ≋ y β {equiv f g α β} {equiv f₁ g₁ α₁ β₁} (equivS f≡ g≡) = equivS (λ a → trans (pf₁ a) (f≡ a)) (λ b → trans (pf₂ b) (g≡ b)) where pf₁ : ∀ a → labelB (tabulate (λ j → enumB (f ⟨$⟩ labelA j)) !! (enumA a)) ≡ f ⟨$⟩ a pf₁ a = begin ( labelB (tabulate (λ j → enumB (f ⟨$⟩ labelA j)) !! enumA a) ≡⟨ cong labelB (lookup∘tabulate _ (enumA a)) ⟩ labelB (enumB (f ⟨$⟩ labelA (enumA a))) ≡⟨ βB _ ⟩ f ⟨$⟩ labelA (enumA a) ≡⟨ cong (_⟨$⟩_ f) (βA _) ⟩ f ⟨$⟩ a ∎) pf₂ : ∀ b → labelA (tabulate (λ j → enumA (g ⟨$⟩ labelB j)) !! (enumB b)) ≡ g ⟨$⟩ b pf₂ b = begin ( labelA (tabulate (λ j → enumA (g ⟨$⟩ labelB j)) !! enumB b) ≡⟨ cong labelA (lookup∘tabulate _ (enumB b)) ⟩ labelA (enumA (g ⟨$⟩ labelB (enumB b))) ≡⟨ βA _ ⟩ g ⟨$⟩ labelB (enumB b) ≡⟨ cong (_⟨$⟩_ g) (βB _) ⟩ g ⟨$⟩ b ∎ ) -- Start proving some of the transport lemmas. -- Need to do: -- 1. prove that we have a bijective morphism of carriers: done, this is thm2 (fwd is the morphism) -- 2. prove that it preserves: -- a. id (done) -- b. 0 (done) -- c. + (done) -- d. * {-- Is this still important or has it been subsumed by the categorical work ??? open _≃S_ lemma_1a : ∀ {n} {A : Set} → (EA : Enum A n) → f (thm2 EA EA) ⟨$⟩ id≃S ≡ idp lemma_1a (f' , mkqinv g α _) = p≡ (trans (finext α) F.reveal1C) -- this is redundant, as it follows from lemma_1a. lemma_1b : ∀ {n} {A : Set} → (EA : Enum A n) → (g (thm2 EA EA) ⟨$⟩ idp) ≋ id≃S lemma_1b (enumA , mkqinv g _ β) = equivS (λ x → trans (cong g 1C!!i≡i) (β x)) (λ x → trans (cong g 1C!!i≡i) (β x)) lemma2 : f (thm2 0E 0E) ⟨$⟩ 0≃S ≡ 0p lemma2 = p≡ F.reveal0C -- p≡ refl lemma3 : ∀ {n₁ n₂} {A B C D : Set} {EA : Enum A n₁} {EB : Enum B n₁} {EC : Enum C n₂} {ED : Enum D n₂} → (x : A ≃S≡ B) → (y : C ≃S≡ D) → f (thm2 (EA ⊕e EC) (EB ⊕e ED)) ⟨$⟩ (x ⊎≃S y) ≡ (f (thm2 EA EB) ⟨$⟩ x) ⊎p (f (thm2 EC ED) ⟨$⟩ y) lemma3 {n₁} {n₂} {EA = EA} {EB} {EC} {ED} (equiv f₄ g₄ α₄ β₄) (equiv f₅ g₅ α₅ β₅) = p≡ ( begin ( CPerm.π (f (thm2 (EA ⊕e EC) (EB ⊕e ED)) ⟨$⟩ (x ⊎≃S y)) ≡⟨ refl ⟩ -- inline f, fwd and π tabulate {n₁ + n₂} (λ j → enumBD (x⊎y.f ⟨$⟩ qAC.g j)) ≡⟨ tabulate-split {n₁} {n₂} {f = λ j → enumBD (x⊎y.f ⟨$⟩ qAC.g j)} ⟩ tabulate {n₁} (λ j → enumBD (x⊎y.f ⟨$⟩ qAC.g (inject+ n₂ j))) ++V tabulate {n₂} (λ j → enumBD (x⊎y.f ⟨$⟩ qAC.g (raise n₁ j))) ≡⟨ cong₂ _++V_ (finext {n₁} pf₁) (finext pf₂) ⟩ tabulate {n₁} (λ j → inject+ n₂ (tabulate (λ i → enumB (f₄ ⟨$⟩ qA.g i)) !! j)) ++V tabulate {n₂} (λ j → raise n₁ (tabulate (λ i → enumD (f₅ ⟨$⟩ qC.g i)) !! j)) ≡⟨ sym F.reveal⊎c ⟩ -- going up, inline f, fwd, ⊎p and π CPerm.π ((f (thm2 EA EB) ⟨$⟩ x) ⊎p (f (thm2 EC ED) ⟨$⟩ y)) ∎)) where open ≡-Reasoning x = equiv f₄ g₄ α₄ β₄ y = equiv f₅ g₅ α₅ β₅ enumB = proj₁ EB enumD = proj₁ ED enumAC = proj₁ (EA ⊕e EC) module qAC = qinv (proj₂ (EA ⊕e EC)) module qA = qinv (proj₂ EA) module qC = qinv (proj₂ EC) enumBD = proj₁ (EB ⊕e ED) module x⊎y = _≃S_ (x ⊎≃S y) pf₁ : (i : Fin n₁) → enumBD (x⊎y.f ⟨$⟩ qAC.g (inject+ n₂ i)) ≡ inject+ n₂ (tabulate (λ i₁ → enumB (f₄ ⟨$⟩ qA.g i₁)) !! i) pf₁ i = begin ( enumBD (x⊎y.f ⟨$⟩ qAC.g (inject+ n₂ i)) ≡⟨ cong (λ j → enumBD (x⊎y.f ⟨$⟩ j)) (eval-left {eA = EA} {EC} i) ⟩ enumBD (x⊎y.f ⟨$⟩ inj₁ (qA.g i)) ≡⟨ refl ⟩ -- once the inj₁ is exposed, the rest happens by β-reduction inject+ n₂ (enumB (f₄ ⟨$⟩ qA.g i)) ≡⟨ cong (inject+ n₂) (sym (lookup∘tabulate _ i)) ⟩ inject+ n₂ (tabulate (λ j → enumB (f₄ ⟨$⟩ qA.g j)) !! i) ∎) pf₂ : (i : Fin n₂) → enumBD (x⊎y.f ⟨$⟩ qAC.g (raise n₁ i)) ≡ raise n₁ (tabulate (λ i₁ → enumD (f₅ ⟨$⟩ qC.g i₁)) !! i) pf₂ i = begin ( enumBD (x⊎y.f ⟨$⟩ qAC.g (raise n₁ i)) ≡⟨ cong (λ j → enumBD (x⊎y.f ⟨$⟩ j)) (eval-right {eA = EA} {EC} i) ⟩ enumBD (x⊎y.f ⟨$⟩ inj₂ (qC.g i)) ≡⟨ refl ⟩ raise n₁ (enumD (f₅ ⟨$⟩ qC.g i)) ≡⟨ cong (raise n₁) (sym (lookup∘tabulate _ i)) ⟩ raise n₁ (tabulate (λ i₁ → enumD (f₅ ⟨$⟩ qC.g i₁)) !! i) ∎) --}
36.47973
100
0.469439
4b6845344d2d786f69700774b113cbba2fd22043
1,140
agda
Agda
Cubical/HITs/Truncation/Base.agda
L-TChen/cubical
60226aacd7b386aef95d43a0c29c4eec996348a8
[ "MIT" ]
null
null
null
Cubical/HITs/Truncation/Base.agda
L-TChen/cubical
60226aacd7b386aef95d43a0c29c4eec996348a8
[ "MIT" ]
null
null
null
Cubical/HITs/Truncation/Base.agda
L-TChen/cubical
60226aacd7b386aef95d43a0c29c4eec996348a8
[ "MIT" ]
null
null
null
{- A simpler definition of truncation ∥ A ∥ n from n ≥ -1 Note that this uses the HoTT book's indexing, so it will be off from `∥_∥_` in HITs.Truncation.Base by -2 -} {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.HITs.Truncation.Base where open import Cubical.Data.NatMinusOne renaming (suc₋₁ to suc) open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.HITs.Sn.Base open import Cubical.Data.Nat.Base open import Cubical.Data.Unit.Base open import Cubical.Data.Empty -- this definition is off by one. Use hLevelTrunc or ∥_∥ for truncations -- (off by 2 w.r.t. the HoTT-book) data HubAndSpoke {ℓ} (A : Type ℓ) (n : ℕ) : Type ℓ where ∣_∣ : A → HubAndSpoke A n hub : (f : S₊ n → HubAndSpoke A n) → HubAndSpoke A n spoke : (f : S₊ n → HubAndSpoke A n) (x : S₊ n) → hub f ≡ f x hLevelTrunc : ∀ {ℓ} (n : ℕ) (A : Type ℓ) → Type ℓ hLevelTrunc zero A = Unit* hLevelTrunc (suc n) A = HubAndSpoke A n ∥_∥_ : ∀ {ℓ} (A : Type ℓ) (n : ℕ) → Type ℓ ∥ A ∥ n = hLevelTrunc n A ∣_∣ₕ : ∀ {ℓ} {A : Type ℓ} {n : ℕ} → A → ∥ A ∥ n ∣_∣ₕ {n = zero} a = tt* ∣_∣ₕ {n = suc n} a = ∣ a ∣
30.810811
72
0.645614
04de9d8cc372135f00b2c50a1c59af7562a119ad
501
agda
Agda
Source/ALL/Utils/HaskellTypes.agda
heades/Agda-LLS
c83f5d8201362b26a749138f6dbff2dd509f85b1
[ "BSD-3-Clause" ]
3
2017-04-09T20:53:53.000Z
2019-08-02T23:41:23.000Z
Source/ALL/Utils/HaskellTypes.agda
heades/Agda-LLS
c83f5d8201362b26a749138f6dbff2dd509f85b1
[ "BSD-3-Clause" ]
2
2017-03-27T14:52:46.000Z
2017-04-05T17:30:16.000Z
Source/ALL/Utils/HaskellTypes.agda
heades/Agda-LLS
c83f5d8201362b26a749138f6dbff2dd509f85b1
[ "BSD-3-Clause" ]
null
null
null
module Utils.HaskellTypes where postulate String : Set {-# BUILTIN STRING String #-} data Unit : Set where triv : Unit {-# COMPILED_DATA Unit () () #-} data Prod (A : Set) (B : Set) : Set where _,_ : A → B → Prod A B {-# COMPILED_DATA Prod (,) (,) #-} data Triple (A B C : Set) : Set where triple : A → B → C → Triple A B C {-# COMPILED_DATA Triple (,,) (,,) #-} infixr 20 _::_ data List (A : Set) : Set where [] : List A _::_ : A → List A → List A {-# COMPILED_DATA List [] [] (:) #-}
21.782609
41
0.56487
3dc3adc5cbfe1da27b25fcc6759401e3b85c90a6
618
agda
Agda
Data/List/Sorting/SelectionSort.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
6
2020-04-07T17:58:13.000Z
2022-02-05T06:53:22.000Z
Data/List/Sorting/SelectionSort.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
Data/List/Sorting/SelectionSort.agda
Lolirofle/stuff-in-agda
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
[ "MIT" ]
null
null
null
open import Data.Boolean open import Type module Data.List.Sorting.SelectionSort {ℓ} {T : Type{ℓ}} (_≤?_ : T → T → Bool) where import Lvl open import Data.List open import Data.List.Functions as List using (_++_) import Data.List.Functions.Multi as List open import Data.List.Sorting.Functions(_≤?_) open import Data.Option open import Data.Tuple import Numeral.Finite.Conversions as 𝕟 open import Functional using (_∘_) {-# TERMINATING #-} selectionSort : List(T) → List(T) selectionSort l with extractMinimal l ... | Some(x , xs) = x ⊰ selectionSort(xs) ... | None = l module Proofs where
26.869565
84
0.70712
1afb832a9857e1dcc9fdb6381c6eb24d0e74368e
506
agda
Agda
src/Auto.agda
wenkokke/AutoInAgda
f384b5c236645fcf8ab93179723a7355383a8716
[ "MIT" ]
22
2017-07-18T18:14:09.000Z
2021-03-20T15:04:47.000Z
src/Auto.agda
wenkokke/AutoInAgda
f384b5c236645fcf8ab93179723a7355383a8716
[ "MIT" ]
1
2017-11-03T09:46:19.000Z
2017-11-06T16:49:27.000Z
src/Auto.agda
wenkokke/AutoInAgda
f384b5c236645fcf8ab93179723a7355383a8716
[ "MIT" ]
2
2018-07-10T10:47:30.000Z
2019-07-07T07:37:07.000Z
open import Function using (const; id) open import Auto.Core using (IsHintDB; simpleHintDB; Rules; Rule; name2rule) open import Data.List using ([]; [_]; _++_) open import Data.Nat using (ℕ) open import Data.Product using (_,_) open import Data.Sum using (inj₁; inj₂) open import Reflection using (Name; Term; TC) module Auto where open import Auto.Extensible simpleHintDB public renaming (auto to auto′) auto : ℕ → HintDB → Term → TC Term auto = auto′ dfs macro autoMacro = auto
28.111111
79
0.70751
c78b306ed1883b37dfd5ffa6ceed128819aa1243
7,234
agda
Agda
src/LibraBFT/Impl/IO/OBM/Properties/InputOutputHandlers.agda
LaudateCorpus1/bft-consensus-agda
a4674fc473f2457fd3fe5123af48253cfb2404ef
[ "UPL-1.0" ]
null
null
null
src/LibraBFT/Impl/IO/OBM/Properties/InputOutputHandlers.agda
LaudateCorpus1/bft-consensus-agda
a4674fc473f2457fd3fe5123af48253cfb2404ef
[ "UPL-1.0" ]
null
null
null
src/LibraBFT/Impl/IO/OBM/Properties/InputOutputHandlers.agda
LaudateCorpus1/bft-consensus-agda
a4674fc473f2457fd3fe5123af48253cfb2404ef
[ "UPL-1.0" ]
null
null
null
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9. Copyright (c) 2021, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl -} open import LibraBFT.Base.Types open import LibraBFT.Concrete.Records open import LibraBFT.Concrete.System open import LibraBFT.Concrete.System.Parameters open import LibraBFT.Impl.Consensus.Network as Network open import LibraBFT.Impl.Consensus.Network.Properties as NetworkProps open import LibraBFT.Impl.Consensus.RoundManager as RoundManager open import LibraBFT.Impl.Consensus.RoundManager.Properties open import LibraBFT.Impl.IO.OBM.InputOutputHandlers open import LibraBFT.Impl.OBM.Logging.Logging open import LibraBFT.Impl.Properties.Util open import LibraBFT.ImplShared.Base.Types open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.Interface.Output open import LibraBFT.ImplShared.NetworkMsg open import LibraBFT.ImplShared.Util.Dijkstra.All open import Optics.All open import Util.Prelude open import Yasm.System ℓ-RoundManager ℓ-VSFP ConcSysParms open Invariants open RoundManagerTransProps module LibraBFT.Impl.IO.OBM.Properties.InputOutputHandlers where module epvvSpec where contract : ∀ pre Post → let ep = pre ^∙ pssSafetyData-rm ∙ sdEpoch vv = pre ^∙ rmEpochState ∙ esVerifier in (Post (ep , vv) pre []) → LBFT-weakestPre epvv Post pre contract pre Post pf ._ refl ._ refl ._ refl ._ refl = pf module handleProposalSpec (now : Instant) (pm : ProposalMsg) where open handleProposal now pm module _ (pool : SentMessages) (pre : RoundManager) where open Invariants.Reqs (pm ^∙ pmProposal) (pre ^∙ lBlockTree) record Contract (_ : Unit) (post : RoundManager) (outs : List Output) : Set where constructor mkContract field -- General properties / invariants rmInv : Preserves RoundManagerInv pre post invalidProposal : ¬ (BlockId-correct (pm ^∙ pmProposal)) → pre ≡ post × OutputProps.NoVotes outs noEpochChange : NoEpochChange pre post -- Voting voteAttemptCorrect : BlockId-correct (pm ^∙ pmProposal) → NoHC1 → Voting.VoteAttemptCorrectWithEpochReq pre post outs (pm ^∙ pmProposal) -- voteBuildsOnRC : TODO-2: We will need to know that, if we're sending a Vote, then there -- is a Block b such that the Vote's proposed id is bId B and there -- is a RecordChain (B b) and all the Records in that RecordChain -- are InSys. This is needed to prove ImplObligation-RC. However, -- before doing so, it may be worth considering strengthening the -- Concrete PreferredRound proof, so that only IsValidVote is -- required of the implementation, and that is used to construct -- the required RecordChain, independently of the implementation. -- QCs outQcs∈RM : QCProps.OutputQc∈RoundManager outs post qcPost : QCProps.∈Post⇒∈PreOr (_QC∈NM (P pm)) pre post contract : LBFT-weakestPre (handleProposal now pm) Contract pre contract = epvvSpec.contract pre Post-epvv contract-step₁ where Post-epvv : LBFT-Post (Epoch × ValidatorVerifier) Post-epvv = RWS-weakestPre-bindPost unit (λ where (myEpoch , vv) → step₁ myEpoch vv) Contract myEpoch = pre ^∙ pssSafetyData-rm ∙ sdEpoch vv = pre ^∙ rmEpochState ∙ esVerifier contractBail : ∀ outs → OutputProps.NoMsgs outs → Contract unit pre outs contractBail outs noMsgs = mkContract reflPreservesRoundManagerInv (const $ refl , OutputProps.NoMsgs⇒NoVotes outs noMsgs) (reflNoEpochChange{pre}) vac outQcs∈RM qcPost where vac : BlockId-correct (pm ^∙ pmProposal) → NoHC1 → Voting.VoteAttemptCorrectWithEpochReq pre pre outs (pm ^∙ pmProposal) vac _ _ = Voting.mkVoteAttemptCorrectWithEpochReq (Voting.voteAttemptBailed outs (OutputProps.NoMsgs⇒NoVotes outs noMsgs)) tt outQcs∈RM : QCProps.OutputQc∈RoundManager outs pre outQcs∈RM = QCProps.NoMsgs⇒OutputQc∈RoundManager outs pre noMsgs qcPost : QCProps.∈Post⇒∈PreOr _ pre pre qcPost qc = Left contract-step₁ : Post-epvv (myEpoch , vv) pre [] proj₁ (contract-step₁ (myEpoch@._ , vv@._) refl) (inj₁ e) pp≡Left = contractBail _ refl proj₁ (contract-step₁ (myEpoch@._ , vv@._) refl) (inj₂ i) pp≡Left = contractBail _ refl proj₂ (contract-step₁ (myEpoch@._ , vv@._) refl) unit pp≡Right = processProposalMsgMSpec.contract now pm proposalId≡ pre Contract pf where sdEpoch≡ : pre ^∙ pssSafetyData-rm ∙ sdEpoch ≡ pm ^∙ pmProposal ∙ bEpoch sdEpoch≡ with processProposalSpec.contract pm myEpoch vv ...| con rewrite pp≡Right = sym (proj₁ con) proposalId≡ : BlockId-correct (pm ^∙ pmProposal) proposalId≡ with processProposalSpec.contract pm myEpoch vv ...| con rewrite pp≡Right = proj₂ con module PPM = processProposalMsgMSpec now pm proposalId≡ pf : RWS-Post-⇒ (PPM.Contract pre) Contract pf unit st outs con = mkContract PPMSpec.rmInv (λ x → ⊥-elim (x proposalId≡)) PPMSpec.noEpochChange vac PPMSpec.outQcs∈RM PPMSpec.qcPost where module PPMSpec = processProposalMsgMSpec.Contract con vac : BlockId-correct (pm ^∙ pmProposal) → NoHC1 → Voting.VoteAttemptCorrectWithEpochReq pre st outs (pm ^∙ pmProposal) vac _ nohc = Voting.mkVoteAttemptCorrectWithEpochReq (PPMSpec.voteAttemptCorrect nohc) (Voting.voteAttemptEpochReq! (PPMSpec.voteAttemptCorrect nohc) sdEpoch≡) contract! : LBFT-Post-True Contract (handleProposal now pm) pre contract! = LBFT-contract (handleProposal now pm) Contract pre contract module handleVoteSpec (now : Instant) (vm : VoteMsg) where open handleVote now vm module _ (pool : SentMessages) (pre : RoundManager) where record Contract (_ : Unit) (post : RoundManager) (outs : List Output) : Set where constructor mkContract field -- General properties / invariants rmInv : Preserves RoundManagerInv pre post noEpochChange : NoEpochChange pre post noSDChange : NoSafetyDataChange pre post -- Output noVotes : OutputProps.NoVotes outs -- Signatures outQcs∈RM : QCProps.OutputQc∈RoundManager outs post qcPost : QCProps.∈Post⇒∈PreOr (_QC∈NM (V vm)) pre post -- TODO-2: `handleVote` can create a new QC once it receives enough -- votes. We need to be tracking /votes/ here, not QCs postulate -- TODO-2: prove (waiting on: refinement of `Contract`) contract : LBFT-weakestPre (handleVote now vm) Contract pre contract! : LBFT-Post-True Contract (handleVote now vm) pre contract! = LBFT-contract (handleVote now vm) Contract pre contract
45.78481
128
0.671136
411c77fb15c95db9c0c3ad1d95e1cf3b752b26d5
753
agda
Agda
test/Succeed/Hurkens.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Hurkens.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Hurkens.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Hurkens' paradox [1]. -- [1] A. Hurkens, A simplification of Girard's paradox. {-# OPTIONS --type-in-type #-} module Hurkens where ⊥ : Set ⊥ = (A : Set) -> A ¬_ : Set -> Set ¬ A = A -> ⊥ P : Set -> Set P A = A -> Set U : Set U = (X : Set) -> (P (P X) -> X) -> P (P X) τ : P (P U) -> U τ t = \X f p -> t \x -> p (f (x X f)) σ : U -> P (P U) σ s = s U \t -> τ t Δ : P U Δ = \y -> ¬ ((p : P U) -> σ y p -> p (τ (σ y))) Ω : U Ω = τ \p -> (x : U) -> σ x p -> p x D : Set D = (p : P U) -> σ Ω p -> p (τ (σ Ω)) lem₁ : (p : P U) -> ((x : U) -> σ x p -> p x) -> p Ω lem₁ p H1 = H1 Ω \x -> H1 (τ (σ x)) lem₂ : ¬ D lem₂ = lem₁ Δ \x H2 H3 -> H3 Δ H2 \p -> H3 \y -> p (τ (σ y)) lem₃ : D lem₃ p = lem₁ \y -> p (τ (σ y)) loop : ⊥ loop = lem₂ lem₃
15.6875
60
0.406375
adfdbf10459fc15df3310716f2fdd63451580bbb
3,059
agda
Agda
Definition/Conversion/Whnf.agda
CoqHott/logrel-mltt
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
[ "MIT" ]
2
2018-06-21T08:39:01.000Z
2022-01-17T16:13:53.000Z
Definition/Conversion/Whnf.agda
CoqHott/logrel-mltt
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
[ "MIT" ]
null
null
null
Definition/Conversion/Whnf.agda
CoqHott/logrel-mltt
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
[ "MIT" ]
2
2022-01-26T14:55:51.000Z
2022-02-15T19:42:19.000Z
{-# OPTIONS --safe #-} module Definition.Conversion.Whnf where open import Definition.Untyped open import Definition.Typed open import Definition.Conversion open import Tools.Product mutual -- Extraction of neutrality from algorithmic equality of neutrals. ne~↑! : ∀ {t u A Γ l} → Γ ⊢ t ~ u ↑! A ^ l → Neutral t × Neutral u ne~↑! (var-refl x₁ x≡y) = var _ , var _ ne~↑! (app-cong x x₁) = let _ , q , w = ne~↓! x in ∘ₙ q , ∘ₙ w ne~↑! (natrec-cong x x₁ x₂ x₃) = let _ , q , w = ne~↓! x₃ in natrecₙ q , natrecₙ w ne~↑! (Emptyrec-cong x x₁) = Emptyrecₙ , Emptyrecₙ ne~↑! (Id-cong X x x₁) = let _ , nt , nu = ne~↓! X in Idₙ nt , Idₙ nu ne~↑! (Id-ℕ X x) = let _ , nt , nu = ne~↓! X in Idℕₙ nt , Idℕₙ nu ne~↑! (Id-ℕ0 X) = let _ , nt , nu = ne~↓! X in Idℕ0ₙ nt , Idℕ0ₙ nu ne~↑! (Id-ℕS x X) = let _ , nt , nu = ne~↓! X in IdℕSₙ nt , IdℕSₙ nu ne~↑! (Id-U X x) = let _ , nt , nu = ne~↓! X in IdUₙ nt , IdUₙ nu ne~↑! (Id-Uℕ X) = let _ , nt , nu = ne~↓! X in IdUℕₙ nt , IdUℕₙ nu ne~↑! (Id-UΠ x X) = let _ , nt , nu = ne~↓! X in IdUΠₙ nt , IdUΠₙ nu ne~↑! (cast-cong X x x₁ x₂ x₃) = let _ , nt , nu = ne~↓! X in castₙ nt , castₙ nu ne~↑! (cast-ℕ X x x₁ x₂) = let _ , nt , nu = ne~↓! X in castℕₙ nt , castℕₙ nu ne~↑! (cast-ℕℕ X x x₁) = let _ , nt , nu = ne~↓! X in castℕℕₙ nt , castℕℕₙ nu ne~↑! (cast-Π x X x₁ x₂ x₃) = let _ , nt , nu = ne~↓! X in castΠₙ nt , castΠₙ nu ne~↑! (cast-Πℕ x x₁ x₂ x₃) = castΠℕₙ , castΠℕₙ ne~↑! (cast-ℕΠ x x₁ x₂ x₃) = castℕΠₙ , castℕΠₙ ne~↑! (cast-ΠΠ%! x x₁ x₂ x₃ x₄) = castΠΠ%!ₙ , castΠΠ%!ₙ ne~↑! (cast-ΠΠ!% x x₁ x₂ x₃ x₄) = castΠΠ!%ₙ , castΠΠ!%ₙ ne~↓! : ∀ {t u A Γ l} → Γ ⊢ t ~ u ↓! A ^ l → Whnf A × Neutral t × Neutral u ne~↓! ([~] A D whnfB k~l) = whnfB , ne~↑! k~l -- Extraction of WHNF from algorithmic equality of terms in WHNF. whnfConv↓Term : ∀ {t u A Γ l} → Γ ⊢ t [conv↓] u ∷ A ^ l → Whnf A × Whnf t × Whnf u whnfConv↓Term (ℕ-ins x) = let _ , neT , neU = ne~↓! x in ℕₙ , ne neT , ne neU -- whnfConv↓Term (Empty-ins x) = let _ , neT , neU = ne~↓% x -- in Emptyₙ , ne neT , ne neU whnfConv↓Term (ne x) = let wA , nt , nu = ne~↓! x in wA , ne nt , ne nu whnfConv↓Term (ne-ins t u x x₁) = let _ , neT , neU = ne~↓! x₁ in ne x , ne neT , ne neU whnfConv↓Term (ℕ-refl x) = Uₙ , ℕₙ , ℕₙ whnfConv↓Term (Empty-refl x x₁) = Uₙ , Emptyₙ , Emptyₙ whnfConv↓Term (Π-cong _ _ _ _ _ _ x x₁ x₂) = Uₙ , Πₙ , Πₙ whnfConv↓Term (∃-cong _ x x₁ x₂) = Uₙ , ∃ₙ , ∃ₙ whnfConv↓Term (U-refl _ _) = Uₙ , Uₙ , Uₙ whnfConv↓Term (zero-refl x) = ℕₙ , zeroₙ , zeroₙ whnfConv↓Term (suc-cong x) = ℕₙ , sucₙ , sucₙ whnfConv↓Term (η-eq _ _ x x₁ x₂ y y₁ x₃) = Πₙ , functionWhnf y , functionWhnf y₁ -- Extraction of WHNF from algorithmic equality of types in WHNF. whnfConv↓ : ∀ {A B rA Γ} → Γ ⊢ A [conv↓] B ^ rA → Whnf A × Whnf B whnfConv↓ (U-refl _ _) = Uₙ , Uₙ whnfConv↓ (univ x₂) = let _ , A , B = whnfConv↓Term x₂ in A , B
43.084507
83
0.535796
2ed424afe816469802c1e69fcbc6c435ee3922ee
8,644
agda
Agda
Cubical/Algebra/CommRing/Properties.agda
ByteBucket123/cubical
aeaa15fb846a3e8bda73635dc7462ae3813b4b1b
[ "MIT" ]
null
null
null
Cubical/Algebra/CommRing/Properties.agda
ByteBucket123/cubical
aeaa15fb846a3e8bda73635dc7462ae3813b4b1b
[ "MIT" ]
null
null
null
Cubical/Algebra/CommRing/Properties.agda
ByteBucket123/cubical
aeaa15fb846a3e8bda73635dc7462ae3813b4b1b
[ "MIT" ]
1
2021-03-12T20:08:45.000Z
2021-03-12T20:08:45.000Z
{-# OPTIONS --safe #-} module Cubical.Algebra.CommRing.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Equiv.HalfAdjoint open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.Transport open import Cubical.Foundations.SIP open import Cubical.Foundations.Powerset open import Cubical.Data.Sigma open import Cubical.Data.Nat renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_ ; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm) open import Cubical.Structures.Axioms open import Cubical.Structures.Auto open import Cubical.Structures.Macro open import Cubical.Algebra.Semigroup open import Cubical.Algebra.Monoid open import Cubical.Algebra.AbGroup open import Cubical.Algebra.Ring open import Cubical.Algebra.CommRing.Base private variable ℓ : Level module Units (R' : CommRing ℓ) where open CommRingStr (snd R') open RingTheory (CommRing→Ring R') private R = fst R' inverseUniqueness : (r : R) → isProp (Σ[ r' ∈ R ] r · r' ≡ 1r) inverseUniqueness r (r' , rr'≡1) (r'' , rr''≡1) = Σ≡Prop (λ _ → is-set _ _) path where path : r' ≡ r'' path = r' ≡⟨ sym (·Rid _) ⟩ r' · 1r ≡⟨ cong (r' ·_) (sym rr''≡1) ⟩ r' · (r · r'') ≡⟨ ·Assoc _ _ _ ⟩ (r' · r) · r'' ≡⟨ cong (_· r'') (·-comm _ _) ⟩ (r · r') · r'' ≡⟨ cong (_· r'') rr'≡1 ⟩ 1r · r'' ≡⟨ ·Lid _ ⟩ r'' ∎ Rˣ : ℙ R Rˣ r = (Σ[ r' ∈ R ] r · r' ≡ 1r) , inverseUniqueness r -- some notation using instance arguments _⁻¹ : (r : R) → ⦃ r ∈ Rˣ ⦄ → R _⁻¹ r ⦃ r∈Rˣ ⦄ = r∈Rˣ .fst infix 9 _⁻¹ -- some results about inverses ·-rinv : (r : R) ⦃ r∈Rˣ : r ∈ Rˣ ⦄ → r · r ⁻¹ ≡ 1r ·-rinv r ⦃ r∈Rˣ ⦄ = r∈Rˣ .snd ·-linv : (r : R) ⦃ r∈Rˣ : r ∈ Rˣ ⦄ → r ⁻¹ · r ≡ 1r ·-linv r ⦃ r∈Rˣ ⦄ = ·-comm _ _ ∙ r∈Rˣ .snd RˣMultClosed : (r r' : R) ⦃ r∈Rˣ : r ∈ Rˣ ⦄ ⦃ r'∈Rˣ : r' ∈ Rˣ ⦄ → (r · r') ∈ Rˣ RˣMultClosed r r' = (r ⁻¹ · r' ⁻¹) , path where path : r · r' · (r ⁻¹ · r' ⁻¹) ≡ 1r path = r · r' · (r ⁻¹ · r' ⁻¹) ≡⟨ cong (_· (r ⁻¹ · r' ⁻¹)) (·-comm _ _) ⟩ r' · r · (r ⁻¹ · r' ⁻¹) ≡⟨ ·Assoc _ _ _ ⟩ r' · r · r ⁻¹ · r' ⁻¹ ≡⟨ cong (_· r' ⁻¹) (sym (·Assoc _ _ _)) ⟩ r' · (r · r ⁻¹) · r' ⁻¹ ≡⟨ cong (λ x → r' · x · r' ⁻¹) (·-rinv _) ⟩ r' · 1r · r' ⁻¹ ≡⟨ cong (_· r' ⁻¹) (·Rid _) ⟩ r' · r' ⁻¹ ≡⟨ ·-rinv _ ⟩ 1r ∎ RˣContainsOne : 1r ∈ Rˣ RˣContainsOne = 1r , ·Lid _ RˣInvClosed : (r : R) ⦃ _ : r ∈ Rˣ ⦄ → r ⁻¹ ∈ Rˣ RˣInvClosed r = r , ·-linv _ UnitsAreNotZeroDivisors : (r : R) ⦃ _ : r ∈ Rˣ ⦄ → ∀ r' → r' · r ≡ 0r → r' ≡ 0r UnitsAreNotZeroDivisors r r' p = r' ≡⟨ sym (·Rid _) ⟩ r' · 1r ≡⟨ cong (r' ·_) (sym (·-rinv _)) ⟩ r' · (r · r ⁻¹) ≡⟨ ·Assoc _ _ _ ⟩ r' · r · r ⁻¹ ≡⟨ cong (_· r ⁻¹) p ⟩ 0r · r ⁻¹ ≡⟨ 0LeftAnnihilates _ ⟩ 0r ∎ -- laws keeping the instance arguments 1⁻¹≡1 : ⦃ 1∈Rˣ' : 1r ∈ Rˣ ⦄ → 1r ⁻¹ ≡ 1r 1⁻¹≡1 ⦃ 1∈Rˣ' ⦄ = (sym (·Lid _)) ∙ 1∈Rˣ' .snd ⁻¹-dist-· : (r r' : R) ⦃ r∈Rˣ : r ∈ Rˣ ⦄ ⦃ r'∈Rˣ : r' ∈ Rˣ ⦄ ⦃ rr'∈Rˣ : (r · r') ∈ Rˣ ⦄ → (r · r') ⁻¹ ≡ r ⁻¹ · r' ⁻¹ ⁻¹-dist-· r r' ⦃ r∈Rˣ ⦄ ⦃ r'∈Rˣ ⦄ ⦃ rr'∈Rˣ ⦄ = sym path ∙∙ cong (r ⁻¹ · r' ⁻¹ ·_) (rr'∈Rˣ .snd) ∙∙ (·Rid _) where path : r ⁻¹ · r' ⁻¹ · (r · r' · (r · r') ⁻¹) ≡ (r · r') ⁻¹ path = r ⁻¹ · r' ⁻¹ · (r · r' · (r · r') ⁻¹) ≡⟨ ·Assoc _ _ _ ⟩ r ⁻¹ · r' ⁻¹ · (r · r') · (r · r') ⁻¹ ≡⟨ cong (λ x → r ⁻¹ · r' ⁻¹ · x · (r · r') ⁻¹) (·-comm _ _) ⟩ r ⁻¹ · r' ⁻¹ · (r' · r) · (r · r') ⁻¹ ≡⟨ cong (_· (r · r') ⁻¹) (sym (·Assoc _ _ _)) ⟩ r ⁻¹ · (r' ⁻¹ · (r' · r)) · (r · r') ⁻¹ ≡⟨ cong (λ x → r ⁻¹ · x · (r · r') ⁻¹) (·Assoc _ _ _) ⟩ r ⁻¹ · (r' ⁻¹ · r' · r) · (r · r') ⁻¹ ≡⟨ cong (λ x → r ⁻¹ · (x · r) · (r · r') ⁻¹) (·-linv _) ⟩ r ⁻¹ · (1r · r) · (r · r') ⁻¹ ≡⟨ cong (λ x → r ⁻¹ · x · (r · r') ⁻¹) (·Lid _) ⟩ r ⁻¹ · r · (r · r') ⁻¹ ≡⟨ cong (_· (r · r') ⁻¹) (·-linv _) ⟩ 1r · (r · r') ⁻¹ ≡⟨ ·Lid _ ⟩ (r · r') ⁻¹ ∎ unitCong : {r r' : R} → r ≡ r' → ⦃ r∈Rˣ : r ∈ Rˣ ⦄ ⦃ r'∈Rˣ : r' ∈ Rˣ ⦄ → r ⁻¹ ≡ r' ⁻¹ unitCong {r = r} {r' = r'} p ⦃ r∈Rˣ ⦄ ⦃ r'∈Rˣ ⦄ = PathPΣ (inverseUniqueness r' (r ⁻¹ , subst (λ x → x · r ⁻¹ ≡ 1r) p (r∈Rˣ .snd)) r'∈Rˣ) .fst ⁻¹-eq-elim : {r r' r'' : R} ⦃ r∈Rˣ : r ∈ Rˣ ⦄ → r' ≡ r'' · r → r' · r ⁻¹ ≡ r'' ⁻¹-eq-elim {r = r} {r'' = r''} p = cong (_· r ⁻¹) p ∙ sym (·Assoc _ _ _) ∙ cong (r'' ·_) (·-rinv _) ∙ ·Rid _ -- some convenient notation _ˣ : (R' : CommRing ℓ) → ℙ (R' .fst) R' ˣ = Units.Rˣ R' module RingHomRespUnits {A' B' : CommRing ℓ} (φ : CommRingHom A' B') where open Units A' renaming (Rˣ to Aˣ ; _⁻¹ to _⁻¹ᵃ ; ·-rinv to ·A-rinv ; ·-linv to ·A-linv) private A = fst A' open CommRingStr (snd A') renaming (_·_ to _·A_ ; 1r to 1a) open Units B' renaming (Rˣ to Bˣ ; _⁻¹ to _⁻¹ᵇ ; ·-rinv to ·B-rinv) open CommRingStr (snd B') renaming ( _·_ to _·B_ ; 1r to 1b ; ·Lid to ·B-lid ; ·Rid to ·B-rid ; ·Assoc to ·B-assoc) private f = fst φ open IsRingHom (φ .snd) RingHomRespInv : (r : A) ⦃ r∈Aˣ : r ∈ Aˣ ⦄ → f r ∈ Bˣ RingHomRespInv r = f (r ⁻¹ᵃ) , (sym (pres· r (r ⁻¹ᵃ)) ∙∙ cong (f) (·A-rinv r) ∙∙ pres1) φ[x⁻¹]≡φ[x]⁻¹ : (r : A) ⦃ r∈Aˣ : r ∈ Aˣ ⦄ ⦃ φr∈Bˣ : f r ∈ Bˣ ⦄ → f (r ⁻¹ᵃ) ≡ (f r) ⁻¹ᵇ φ[x⁻¹]≡φ[x]⁻¹ r ⦃ r∈Aˣ ⦄ ⦃ φr∈Bˣ ⦄ = f (r ⁻¹ᵃ) ≡⟨ sym (·B-rid _) ⟩ f (r ⁻¹ᵃ) ·B 1b ≡⟨ cong (f (r ⁻¹ᵃ) ·B_) (sym (·B-rinv _)) ⟩ f (r ⁻¹ᵃ) ·B ((f r) ·B (f r) ⁻¹ᵇ) ≡⟨ ·B-assoc _ _ _ ⟩ f (r ⁻¹ᵃ) ·B (f r) ·B (f r) ⁻¹ᵇ ≡⟨ cong (_·B (f r) ⁻¹ᵇ) (sym (pres· _ _)) ⟩ f (r ⁻¹ᵃ ·A r) ·B (f r) ⁻¹ᵇ ≡⟨ cong (λ x → f x ·B (f r) ⁻¹ᵇ) (·A-linv _) ⟩ f 1a ·B (f r) ⁻¹ᵇ ≡⟨ cong (_·B (f r) ⁻¹ᵇ) (pres1) ⟩ 1b ·B (f r) ⁻¹ᵇ ≡⟨ ·B-lid _ ⟩ (f r) ⁻¹ᵇ ∎ module Exponentiation (R' : CommRing ℓ) where open CommRingStr (snd R') private R = fst R' -- introduce exponentiation _^_ : R → ℕ → R f ^ zero = 1r f ^ suc n = f · (f ^ n) infix 9 _^_ -- and prove some laws 1ⁿ≡1 : (n : ℕ) → 1r ^ n ≡ 1r 1ⁿ≡1 zero = refl 1ⁿ≡1 (suc n) = ·Lid _ ∙ 1ⁿ≡1 n ·-of-^-is-^-of-+ : (f : R) (m n : ℕ) → (f ^ m) · (f ^ n) ≡ f ^ (m +ℕ n) ·-of-^-is-^-of-+ f zero n = ·Lid _ ·-of-^-is-^-of-+ f (suc m) n = sym (·Assoc _ _ _) ∙ cong (f ·_) (·-of-^-is-^-of-+ f m n) ^-ldist-· : (f g : R) (n : ℕ) → (f · g) ^ n ≡ (f ^ n) · (g ^ n) ^-ldist-· f g zero = sym (·Lid 1r) ^-ldist-· f g (suc n) = path where path : f · g · ((f · g) ^ n) ≡ f · (f ^ n) · (g · (g ^ n)) path = f · g · ((f · g) ^ n) ≡⟨ cong (f · g ·_) (^-ldist-· f g n) ⟩ f · g · ((f ^ n) · (g ^ n)) ≡⟨ ·Assoc _ _ _ ⟩ f · g · (f ^ n) · (g ^ n) ≡⟨ cong (_· (g ^ n)) (sym (·Assoc _ _ _)) ⟩ f · (g · (f ^ n)) · (g ^ n) ≡⟨ cong (λ r → (f · r) · (g ^ n)) (·-comm _ _) ⟩ f · ((f ^ n) · g) · (g ^ n) ≡⟨ cong (_· (g ^ n)) (·Assoc _ _ _) ⟩ f · (f ^ n) · g · (g ^ n) ≡⟨ sym (·Assoc _ _ _) ⟩ f · (f ^ n) · (g · (g ^ n)) ∎ ^-rdist-·ℕ : (f : R) (n m : ℕ) → f ^ (n ·ℕ m) ≡ (f ^ n) ^ m ^-rdist-·ℕ f zero m = sym (1ⁿ≡1 m) ^-rdist-·ℕ f (suc n) m = sym (·-of-^-is-^-of-+ f m (n ·ℕ m)) ∙∙ cong (f ^ m ·_) (^-rdist-·ℕ f n m) ∙∙ sym (^-ldist-· f (f ^ n) m) -- like in Ring.Properties we provide helpful lemmas here module CommRingTheory (R' : CommRing ℓ) where open CommRingStr (snd R') private R = fst R' ·-commAssocl : (x y z : R) → x · (y · z) ≡ y · (x · z) ·-commAssocl x y z = ·Assoc x y z ∙∙ cong (_· z) (·-comm x y) ∙∙ sym (·Assoc y x z) ·-commAssocr : (x y z : R) → x · y · z ≡ x · z · y ·-commAssocr x y z = sym (·Assoc x y z) ∙∙ cong (x ·_) (·-comm y z) ∙∙ ·Assoc x z y ·-commAssocr2 : (x y z : R) → x · y · z ≡ z · y · x ·-commAssocr2 x y z = ·-commAssocr _ _ _ ∙∙ cong (_· y) (·-comm _ _) ∙∙ ·-commAssocr _ _ _ ·-commAssocSwap : (x y z w : R) → (x · y) · (z · w) ≡ (x · z) · (y · w) ·-commAssocSwap x y z w = ·Assoc (x · y) z w ∙∙ cong (_· w) (·-commAssocr x y z) ∙∙ sym (·Assoc (x · z) y w)
38.417778
101
0.421911
1381ae464aced8d8bf9118c4535bdc95751a9d8f
1,079
agda
Agda
test/Succeed/fol-theorems/Definition08.agda
asr/apia
a66c5ddca2ab470539fd68c42c4fbd45f720d682
[ "MIT" ]
10
2015-09-03T20:54:16.000Z
2019-12-03T13:44:25.000Z
test/Succeed/fol-theorems/Definition08.agda
asr/apia
a66c5ddca2ab470539fd68c42c4fbd45f720d682
[ "MIT" ]
121
2015-01-25T13:22:12.000Z
2018-04-22T06:01:44.000Z
test/Succeed/fol-theorems/Definition08.agda
asr/apia
a66c5ddca2ab470539fd68c42c4fbd45f720d682
[ "MIT" ]
4
2016-05-10T23:06:19.000Z
2016-08-03T03:54:55.000Z
------------------------------------------------------------------------------ -- Testing the translation of definitions ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module Definition08 where open import Common.FOL postulate P : D → Set op : D → D -- In this case the proof term `Pb` is referenced in the types of the -- definitions of `c` and `d` via the `where` clause. Therefore in the -- translation of `c` and `d`, we need to erase this proof term. -- TODO (2016-04-02): This test case is invalid after fixing #22. -- foo : D → ∀ {b} → P b → D -- foo a Pb = a -- where -- c : D -- c = a -- {-# ATP definition c #-} -- d : D -- d = op c -- {-# ATP definition d #-} -- postulate bar : d ≡ op a -- {-# ATP prove bar #-} -- We need to have at least one conjecture to generate a TPTP file. postulate bar : ∀ d → d ≡ d {-# ATP prove bar #-}
26.317073
78
0.487488
29f7a5ef7fe115b95bcce393438d8586ec3f3aad
263
agda
Agda
test/Fail/WrongNamedArgument.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/WrongNamedArgument.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/WrongNamedArgument.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module WrongNamedArgument where postulate f : {A : Set₁} → A → A test : Set → Set test = f {B = Set} -- Good error: -- Function does not accept argument {B = _} -- when checking that {B = Set} are valid arguments to a function of -- type {A : Set₁} → A → A
18.785714
68
0.631179
06bdb42614b559381ad9e36f7509664157fe9866
355
agda
Agda
src/rtn.agda
xoltar/cedille
acf691e37210607d028f4b19f98ec26c4353bfb5
[ "MIT" ]
null
null
null
src/rtn.agda
xoltar/cedille
acf691e37210607d028f4b19f98ec26c4353bfb5
[ "MIT" ]
null
null
null
src/rtn.agda
xoltar/cedille
acf691e37210607d028f4b19f98ec26c4353bfb5
[ "MIT" ]
null
null
null
open import lib module rtn (gratr2-nt : Set) where gratr2-rule : Set gratr2-rule = maybe string × maybe string × maybe gratr2-nt × 𝕃 (gratr2-nt ⊎ char) record gratr2-rtn : Set where field start : gratr2-nt _eq_ : gratr2-nt → gratr2-nt → 𝔹 gratr2-start : gratr2-nt → 𝕃 gratr2-rule gratr2-return : maybe gratr2-nt → 𝕃 gratr2-rule
25.357143
83
0.667606
c7428081900a4a5c049e0b4e41698a4cfab79a72
801
agda
Agda
notes/papers/implicit/examples/Example.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
notes/papers/implicit/examples/Example.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
notes/papers/implicit/examples/Example.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
module Example where data Nat : Set where zero : Nat suc : Nat -> Nat postulate case-Nat : (P : Nat -> Set) -> P zero -> ((n:Nat) -> P (suc n)) -> (n : Nat) -> P n -- test : Nat -> Nat test = case-Nat _ zero (\n -> n) {- data Size : Set where empty : Size nonempty : Size whatever : Size data Nat : Set where zero : Nat suc : Nat -> Nat data List (A:Set) : Set where nil : List A (::) : A -> List A -> List A data Monad (M:Set -> Set) : Set1 where monad : Monad M postulate build : {M:Set -> Set} -> Monad M -> {C:Size -> Set} -> (A:Set) -> (A -> C nonempty) -> ((n:Size) -> List (C n) -> M (List A)) -> List A -> M (C whatever) test : (A:Set) -> Nat test A = build monad A (\x -> x) (\n xs -> xs) nil -}
19.071429
68
0.490637
042290023855f036d3002f5dade79a0d07b6d6d1
438
agda
Agda
src/MLib/Semirings.agda
bch29/agda-matrices
e26ae2e0aa7721cb89865aae78625a2f3fd2b574
[ "MIT" ]
null
null
null
src/MLib/Semirings.agda
bch29/agda-matrices
e26ae2e0aa7721cb89865aae78625a2f3fd2b574
[ "MIT" ]
null
null
null
src/MLib/Semirings.agda
bch29/agda-matrices
e26ae2e0aa7721cb89865aae78625a2f3fd2b574
[ "MIT" ]
null
null
null
module MLib.Semirings where open import MLib.Prelude open Algebra using (Semiring) module _ {ℓ p} (semiring : Semiring ℓ p) where open Semiring semiring renaming (Carrier to S) pow : ℕ → S → S pow Nat.zero x = 1# pow (Nat.suc n) x = x * pow n x powsum : ℕ → S → S powsum Nat.zero x = 1# powsum (Nat.suc n) x = pow (Nat.suc n) x + powsum n x Q-stable : ℕ → S → Set p Q-stable q x = powsum (1 Nat.+ q) x ≈ powsum q x
23.052632
55
0.623288
9ac96dc145d7c956b0423f87042d0748c00caba5
664
agda
Agda
test/Succeed/Issue3972.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Succeed/Issue3972.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Succeed/Issue3972.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Andreas, 2019-08-08, issue #3972 (and #3967) -- In the presence of an unreachable clause, the serializer crashed on a unsolve meta. -- It seems this issue was fixed along #3966: only the ranges of unreachable clauses -- are now serialized. open import Agda.Builtin.Equality public postulate List : Set → Set data Coo {A} (xs : List A) : Set where coo : Coo xs → Coo xs test : {A : Set} (xs : List A) (z : Coo xs) → Set₁ test xs z = cs xs z refl where cs : (xs : List _) -- filling this meta _=A removes the internal error (z : Coo xs) (eq : xs ≡ xs) → Set₁ cs xs (coo z) refl = Set cs xs (coo z) eq = Set -- unreachable
26.56
86
0.634036
ad158fa1f0800d23e23787e7ae796fbcd266c652
3,480
agda
Agda
Cubical/Categories/Category/Properties.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
1
2022-03-05T00:28:39.000Z
2022-03-05T00:28:39.000Z
Cubical/Categories/Category/Properties.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
null
null
null
Cubical/Categories/Category/Properties.agda
FernandoLarrain/cubical
9acdecfa6437ec455568be4e5ff04849cc2bc13b
[ "MIT" ]
null
null
null
{-# OPTIONS --safe #-} module Cubical.Categories.Category.Properties where open import Cubical.Foundations.Prelude open import Cubical.Foundations.HLevels open import Cubical.Categories.Category.Base open Category private variable ℓ ℓ' : Level module _ {C : Category ℓ ℓ'} where -- isSet where your allowed to compare paths where one side is only -- equal up to path. Is there a generalization of this? isSetHomP1 : ∀ {x y : C .ob} {n : C [ x , y ]} → isOfHLevelDep 1 (λ m → m ≡ n) isSetHomP1 {x = x} {y} {n} = isOfHLevel→isOfHLevelDep 1 (λ m → isSetHom C m n) -- isSet where the arrows can be between non-definitionally equal obs isSetHomP2l : ∀ {y : C .ob} → isOfHLevelDep 2 (λ x → C [ x , y ]) isSetHomP2l = isOfHLevel→isOfHLevelDep 2 (λ a → isSetHom C {x = a}) isSetHomP2r : ∀ {x : C .ob} → isOfHLevelDep 2 (λ y → C [ x , y ]) isSetHomP2r = isOfHLevel→isOfHLevelDep 2 (λ a → isSetHom C {y = a}) -- opposite of opposite is definitionally equal to itself involutiveOp : ∀ {C : Category ℓ ℓ'} → C ^op ^op ≡ C involutiveOp = refl module _ {C : Category ℓ ℓ'} where -- Other useful operations on categories -- whisker the parallel morphisms g and g' with f lCatWhisker : {x y z : C .ob} (f : C [ x , y ]) (g g' : C [ y , z ]) (p : g ≡ g') → f ⋆⟨ C ⟩ g ≡ f ⋆⟨ C ⟩ g' lCatWhisker f _ _ p = cong (_⋆_ C f) p rCatWhisker : {x y z : C .ob} (f f' : C [ x , y ]) (g : C [ y , z ]) (p : f ≡ f') → f ⋆⟨ C ⟩ g ≡ f' ⋆⟨ C ⟩ g rCatWhisker _ _ g p = cong (λ v → v ⋆⟨ C ⟩ g) p -- working with equal objects idP : ∀ {x x'} {p : x ≡ x'} → C [ x , x' ] idP {x} {x'} {p} = subst (λ v → C [ x , v ]) p (C .id) -- heterogeneous seq seqP : ∀ {x y y' z} {p : y ≡ y'} → (f : C [ x , y ]) (g : C [ y' , z ]) → C [ x , z ] seqP {x} {_} {_} {z} {p} f g = f ⋆⟨ C ⟩ (subst (λ a → C [ a , z ]) (sym p) g) -- also heterogeneous seq, but substituting on the left seqP' : ∀ {x y y' z} {p : y ≡ y'} → (f : C [ x , y ]) (g : C [ y' , z ]) → C [ x , z ] seqP' {x} {_} {_} {z} {p} f g = subst (λ a → C [ x , a ]) p f ⋆⟨ C ⟩ g -- show that they're equal seqP≡seqP' : ∀ {x y y' z} {p : y ≡ y'} → (f : C [ x , y ]) (g : C [ y' , z ]) → seqP {p = p} f g ≡ seqP' {p = p} f g seqP≡seqP' {x = x} {z = z} {p = p} f g i = (toPathP {A = λ i' → C [ x , p i' ]} {f} refl i) ⋆⟨ C ⟩ (toPathP {A = λ i' → C [ p (~ i') , z ]} {x = g} (sym refl) (~ i)) -- seqP is equal to normal seq when y ≡ y' seqP≡seq : ∀ {x y z} → (f : C [ x , y ]) (g : C [ y , z ]) → seqP {p = refl} f g ≡ f ⋆⟨ C ⟩ g seqP≡seq {y = y} {z} f g i = f ⋆⟨ C ⟩ toPathP {A = λ _ → C [ y , z ]} {x = g} refl (~ i) -- whiskering with heterogenous seq -- (maybe should let z be heterogeneous too) lCatWhiskerP : {x y z y' : C .ob} {p : y ≡ y'} → (f : C [ x , y ]) (g : C [ y , z ]) (g' : C [ y' , z ]) → (r : PathP (λ i → C [ p i , z ]) g g') → f ⋆⟨ C ⟩ g ≡ seqP {p = p} f g' lCatWhiskerP f g g' r = cong (λ v → f ⋆⟨ C ⟩ v) (sym (fromPathP (symP r))) rCatWhiskerP : {x y' y z : C .ob} {p : y' ≡ y} → (f' : C [ x , y' ]) (f : C [ x , y ]) (g : C [ y , z ]) → (r : PathP (λ i → C [ x , p i ]) f' f) → f ⋆⟨ C ⟩ g ≡ seqP' {p = p} f' g rCatWhiskerP f' f g r = cong (λ v → v ⋆⟨ C ⟩ g) (sym (fromPathP r))
37.419355
90
0.46408
3d9d0de31464a2482b9e2b691f17ab084ad8c6d1
9,854
agda
Agda
TypeTheory/FibDataTypes/Types.agda
hbasold/Sandbox
8fc7a6cd878f37f9595124ee8dea62258da28aa4
[ "MIT" ]
null
null
null
TypeTheory/FibDataTypes/Types.agda
hbasold/Sandbox
8fc7a6cd878f37f9595124ee8dea62258da28aa4
[ "MIT" ]
null
null
null
TypeTheory/FibDataTypes/Types.agda
hbasold/Sandbox
8fc7a6cd878f37f9595124ee8dea62258da28aa4
[ "MIT" ]
null
null
null
module Types where import Level open import Data.Unit as Unit renaming (tt to ∗) open import Data.List as List open import Data.Product open import Categories.Category using (Category) open import Function open import Relation.Binary.PropositionalEquality as PE hiding ([_]; subst) open import Relation.Binary using (module IsEquivalence; Setoid; module Setoid) open ≡-Reasoning open import Common.Context as Context -- open import Categories.Object.BinaryCoproducts ctx-cat -- Codes mutual data TermCtxCode : Set where emptyC : TermCtxCode cCtxC : (γ : TermCtxCode) → TypeCode γ → TermCtxCode TyCtxCode : Set data TypeCode (δ : TyCtxCode) (γ : TermCtxCode) : Set where closeAppTyC : TypeCode δ γ data TyFormerCode (γ : TermCtxCode) : Set where univ : TyFormerCode γ abs : (A : TypeCode γ) → (TyFormerCode (cCtxC γ A)) → TyFormerCode γ TyCtxCode = Ctx (Σ TermCtxCode TyFormerCode) TyVarCode : TyCtxCode → {γ : TermCtxCode} → TyFormerCode γ → Set TyVarCode δ {γ} T = Var δ (γ , T) emptyTy : TyCtxCode emptyTy = [] {- ctxTyFormer : (γ : TermCtxCode) → TyFormerCode γ → TyFormerCode emptyC ctxTyFormer = ? -} data AppTypeCode (δ : TyCtxCode) (γ : TermCtxCode) : Set where varC : (T : TyFormerCode γ) → (x : TyVarCode δ T) → AppTypeCode δ γ appTyC : (T : TyFormerCode γ) → AppTypeCode δ γ T μC : (γ₁ : TermCtxCode) → (t : TypeCode (ctxTyFormer γ univ ∷ δ) γ₁) → AppTypeCode δ γ {- (T : TyFormerCode) → (A : TypeCode δ γ univ) → (B : TypeCode δ γ (cCtxC γ A T)) → (t : TermCode γ A) → Type Δ Γ (subst B t) -} {- -- Just one constructor/destructor for now μ : (Γ Γ₁ : TermCtx) → (t : Type (ctxTyFormer Γ univ ∷ Δ) Γ₁ univ) → Type Δ Γ (ctxTyFormer Γ univ) ν : (Γ Γ₁ : TermCtx) → (t : Type (ctxTyFormer Γ univ ∷ Δ) Γ₁ univ) → Type Δ Γ (ctxTyFormer Γ univ) -} {- mutual data TermCtx : Set where empty : TermCtx cCtx : (Γ : TermCtx) → TypeCode Γ → TermCtx data TypeCode (Γ : TermCtx) : Set where appTy : TypeCode Γ Type : (Γ : TermCtx) → TypeCode Γ → Set data Term : (Γ : TermCtx) → TypeCode Γ → Set where data TyFormer (Γ : TermCtx) : Set where univ : TyFormer Γ abs : (A : TypeCode Γ) → (TyFormer (cCtx Γ A)) → TyFormer Γ subst : {Γ : TermCtx} → {A : TypeCode Γ} → TyFormer (cCtx Γ A) → Term Γ A → TyFormer Γ subst = {!!} Type Γ appTy = Σ (TypeCode Γ) (λ A → Σ (AppType emptyTy Γ (abs A univ)) (λ B → Term Γ A)) ctxTyFormer : (Γ : TermCtx) → TyFormer Γ → TyFormer ctxTyFormer empty T = T ctxTyFormer (cCtx Γ A) T = ctxTyFormer Γ (abs Γ A) TyCtx : Set TyCtx = Ctx (Σ TermCtx TyFormer) TyVar : TyCtx → {Γ : TermCtx} → TyFormer Γ → Set TyVar Δ {Γ} T = Var Δ (Γ , T) emptyTy : TyCtx emptyTy = [] -- | Type syntax data AppType (Δ : TyCtx) : (Γ : TermCtx) → TyFormer Γ → Set where var : (Γ : TermCtx) → (T : TyFormer Γ) → (x : TyVar Δ T) → AppType Δ Γ T appTy : (Γ : TermCtx) → (T : TyFormer) → (A : Type Δ Γ univ) → (B : Type Δ Γ (cCtx Γ A T)) → (t : Term Γ) → Type Δ Γ (subst B t) -- Just one constructor/destructor for now μ : (Γ Γ₁ : TermCtx) → (t : Type (ctxTyFormer Γ univ ∷ Δ) Γ₁ univ) → Type Δ Γ (ctxTyFormer Γ univ) ν : (Γ Γ₁ : TermCtx) → (t : Type (ctxTyFormer Γ univ ∷ Δ) Γ₁ univ) → Type Δ Γ (ctxTyFormer Γ univ) -} {- succ' : ∀{Δ} (x : TyVar Δ) → TyVar (∗ ∷ Δ) succ' = Context.succ ∗ -} {- -- | Congruence for types data _≅T_ {Γ Γ' : Ctx} : Type Γ → Type Γ' → Set where unit : unit ≅T unit var : ∀{x : TyVar Γ} {x' : TyVar Γ'} → (x ≅V x') → var x ≅T var x' _⊕_ : ∀{t₁ t₂ : Type Γ} {t₁' t₂' : Type Γ'} → (t₁ ≅T t₁') → (t₂ ≅T t₂') → (t₁ ⊕ t₂) ≅T (t₁' ⊕ t₂') _⊗_ : ∀{t₁ t₂ : Type Γ} {t₁' t₂' : Type Γ'} → (t₁ ≅T t₁') → (t₂ ≅T t₂') → (t₁ ⊗ t₂) ≅T (t₁' ⊗ t₂') μ : ∀{t : Type (∗ ∷ Γ)} {t' : Type (∗ ∷ Γ')} → (t ≅T t') → (μ t) ≅T (μ t') _⇒_ : ∀{t₁ t₁' : Type []} {t₂ : Type Γ} {t₂' : Type Γ'} → (t₁ ≅T t₁') → (t₂ ≅T t₂') → (t₁ ⇒ t₂) ≅T (t₁' ⇒ t₂') ν : ∀{t : Type (∗ ∷ Γ)} {t' : Type (∗ ∷ Γ')} → (t ≅T t') → (ν t) ≅T (ν t') Trefl : ∀ {Γ : Ctx} {t : Type Γ} → t ≅T t Trefl {t = unit} = unit Trefl {t = var x} = var e.refl where module s = Setoid module e = IsEquivalence (s.isEquivalence ≅V-setoid) Trefl {t = t₁ ⊕ t₂} = Trefl ⊕ Trefl Trefl {t = μ t} = μ Trefl Trefl {t = t ⊗ t₁} = Trefl ⊗ Trefl Trefl {t = t ⇒ t₁} = Trefl ⇒ Trefl Trefl {t = ν t} = ν Trefl Tsym : ∀ {Γ Γ' : Ctx} {t : Type Γ} {t' : Type Γ'} → t ≅T t' → t' ≅T t Tsym unit = unit Tsym (var u) = var (Vsym u) Tsym (u₁ ⊕ u₂) = Tsym u₁ ⊕ Tsym u₂ Tsym (u₁ ⊗ u₂) = Tsym u₁ ⊗ Tsym u₂ Tsym (μ u) = μ (Tsym u) Tsym (u₁ ⇒ u₂) = Tsym u₁ ⇒ Tsym u₂ Tsym (ν u) = ν (Tsym u) Ttrans : ∀ {Γ₁ Γ₂ Γ₃ : Ctx} {t₁ : Type Γ₁} {t₂ : Type Γ₂} {t₃ : Type Γ₃} → t₁ ≅T t₂ → t₂ ≅T t₃ → t₁ ≅T t₃ Ttrans unit unit = unit Ttrans (var u₁) (var u₂) = var (Vtrans u₁ u₂) Ttrans (u₁ ⊕ u₂) (u₃ ⊕ u₄) = Ttrans u₁ u₃ ⊕ Ttrans u₂ u₄ Ttrans (u₁ ⊗ u₂) (u₃ ⊗ u₄) = Ttrans u₁ u₃ ⊗ Ttrans u₂ u₄ Ttrans (μ u₁) (μ u₂) = μ (Ttrans u₁ u₂) Ttrans (u₁ ⇒ u₂) (u₃ ⇒ u₄) = Ttrans u₁ u₃ ⇒ Ttrans u₂ u₄ Ttrans (ν u₁) (ν u₂) = ν (Ttrans u₁ u₂) ≡→≅T : ∀ {Γ : Ctx} {t₁ t₂ : Type Γ} → t₁ ≡ t₂ → t₁ ≅T t₂ ≡→≅T {Γ} {t₁} {.t₁} refl = Trefl -- Note: makes the equality homogeneous in Γ ≅T-setoid : ∀ {Γ} → Setoid _ _ ≅T-setoid {Γ} = record { Carrier = Type Γ ; _≈_ = _≅T_ ; isEquivalence = record { refl = Trefl ; sym = Tsym ; trans = Ttrans } } -- | Ground type GType = Type [] unit′ : GType unit′ = unit -- | Variable renaming in types rename : {Γ Δ : TyCtx} → (ρ : Γ ▹ Δ) → Type Γ → Type Δ rename ρ unit = unit rename ρ (var x) = var (ρ ∗ x) rename ρ (t₁ ⊕ t₂) = rename ρ t₁ ⊕ rename ρ t₂ rename {Γ} {Δ} ρ (μ t) = μ (rename ρ' t) where ρ' : (∗ ∷ Γ) ▹ (∗ ∷ Δ) ρ' = ctx-id {[ ∗ ]} ⧻ ρ rename ρ (t₁ ⊗ t₂) = rename ρ t₁ ⊗ rename ρ t₂ rename ρ (t₁ ⇒ t₂) = t₁ ⇒ rename ρ t₂ rename {Γ} {Δ} ρ (ν t) = ν (rename ρ' t) where ρ' : (∗ ∷ Γ) ▹ (∗ ∷ Δ) ρ' = ctx-id {[ ∗ ]} ⧻ ρ ------------------------- ---- Generating structure on contexts (derived from renaming) weaken : {Γ : TyCtx} (Δ : TyCtx) → Type Γ -> Type (Δ ∐ Γ) weaken {Γ} Δ = rename {Γ} {Δ ∐ Γ} (i₂ {Δ} {Γ}) exchange : (Γ Δ : TyCtx) → Type (Γ ∐ Δ) -> Type (Δ ∐ Γ) exchange Γ Δ = rename [ i₂ {Δ} {Γ} , i₁ {Δ} {Γ} ] contract : {Γ : TyCtx} → Type (Γ ∐ Γ) -> Type Γ contract = rename [ ctx-id , ctx-id ] -- weaken-id-empty-ctx : (Δ : TyCtx) (t : GType) → weaken {[]} Δ t ≡ t -- weaken-id-empty-ctx = ? Subst : TyCtx → TyCtx → Set Subst Γ Δ = TyVar Γ → Type Δ id-subst : ∀{Γ : TyCtx} → Subst Γ Γ id-subst x = var x update : ∀{Γ Δ : TyCtx} → Subst Γ Δ → Type Δ → (Subst (∗ ∷ Γ) Δ) update σ a zero = a update σ _ (succ′ _ x) = σ x single-subst : ∀{Γ : TyCtx} → Type Γ → (Subst (∗ ∷ Γ) Γ) single-subst a zero = a single-subst _ (succ′ _ x) = var x lift : ∀{Γ Δ} → Subst Γ Δ → Subst (∗ ∷ Γ) (∗ ∷ Δ) lift σ = update (weaken [ ∗ ] ∘ σ) (var zero) -- | Simultaneous substitution subst : {Γ Δ : TyCtx} → (σ : Subst Γ Δ) → Type Γ → Type Δ subst σ unit = unit subst σ (var x) = σ x subst σ (t₁ ⊕ t₂) = subst σ t₁ ⊕ subst σ t₂ subst {Γ} {Δ} σ (μ t) = μ (subst (lift σ) t) subst σ (t₁ ⊗ t₂) = subst σ t₁ ⊗ subst σ t₂ subst σ (t₁ ⇒ t₂) = t₁ ⇒ subst σ t₂ subst {Γ} {Δ} σ (ν t) = ν (subst (lift σ) t) subst₀ : {Γ : TyCtx} → Type Γ → Type (∗ ∷ Γ) → Type Γ subst₀ {Γ} a = subst (update id-subst a) rename′ : {Γ Δ : TyCtx} → (ρ : Γ ▹ Δ) → Type Γ → Type Δ rename′ ρ = subst (var ∘ (ρ ∗)) -- | Unfold lfp unfold-μ : (Type [ ∗ ]) → GType unfold-μ a = subst₀ (μ a) a -- | Unfold gfp unfold-ν : (Type [ ∗ ]) → GType unfold-ν a = subst₀ (ν a) a -------------------------------------------------- ---- Examples Nat : Type [] Nat = μ (unit ⊕ x) where x = var zero Str-Fun : {Γ : TyCtx} → Type Γ → Type (∗ ∷ Γ) Str-Fun a = (weaken [ ∗ ] a ⊗ x) where x = var zero Str : {Γ : TyCtx} → Type Γ → Type Γ Str a = ν (Str-Fun a) lemma : ∀ {Γ : Ctx} {a b : Type Γ} {σ : Subst Γ Γ} → subst (update σ b) (weaken [ ∗ ] a) ≅T subst σ a lemma {a = unit} = unit lemma {a = var x} = Trefl lemma {a = a₁ ⊕ a₂} = lemma {a = a₁} ⊕ lemma {a = a₂} lemma {a = μ a} = μ {!!} lemma {a = a₁ ⊗ a₂} = lemma {a = a₁} ⊗ lemma {a = a₂} lemma {a = a₁ ⇒ a₂} = Trefl ⇒ lemma {a = a₂} lemma {a = ν a} = ν {!!} lift-id-is-id-ext : ∀ {Γ : Ctx} (x : TyVar (∗ ∷ Γ)) → (lift (id-subst {Γ})) x ≡ id-subst x lift-id-is-id-ext zero = refl lift-id-is-id-ext (succ′ ∗ x) = refl lift-id-is-id : ∀ {Γ : Ctx} → lift (id-subst {Γ}) ≡ id-subst lift-id-is-id = η-≡ lift-id-is-id-ext id-subst-id : ∀ {Γ : Ctx} {a : Type Γ} → subst id-subst a ≅T a id-subst-id {a = unit} = unit id-subst-id {a = var x} = var Vrefl id-subst-id {a = a ⊕ a₁} = id-subst-id ⊕ id-subst-id id-subst-id {a = μ a} = μ (Ttrans (≡→≅T (cong (λ u → subst u a) lift-id-is-id)) id-subst-id) id-subst-id {a = a ⊗ a₁} = id-subst-id ⊗ id-subst-id id-subst-id {a = a ⇒ a₁} = Trefl ⇒ id-subst-id id-subst-id {a = ν a} = ν (Ttrans (≡→≅T (cong (λ u → subst u a) lift-id-is-id)) id-subst-id) lemma₂ : ∀ {Γ : Ctx} {a b : Type Γ} → subst (update id-subst b) (weaken [ ∗ ] a) ≅T a lemma₂ {Γ} {a} {b} = Ttrans (lemma {Γ} {a} {b} {σ = id-subst}) id-subst-id unfold-str : ∀{a : Type []} → (unfold-ν (Str-Fun a)) ≅T (a ⊗ Str a) unfold-str {a} = lemma₂ ⊗ Trefl LFair : {Γ : TyCtx} → Type Γ → Type Γ → Type Γ LFair a b = ν (μ ((w a ⊗ x) ⊕ (w b ⊗ y))) where x = var zero y = var (succ zero) Δ = ∗ ∷ [ ∗ ] w = weaken Δ -}
30.79375
79
0.525472
067a652df04367267bc7303c5c5d3faa62df2f68
1,484
agda
Agda
GSeTT/Typed-Syntax.agda
thibautbenjamin/catt-formalization
3a02010a869697f4833c9bc6047d66ca27b87cf2
[ "MIT" ]
null
null
null
GSeTT/Typed-Syntax.agda
thibautbenjamin/catt-formalization
3a02010a869697f4833c9bc6047d66ca27b87cf2
[ "MIT" ]
null
null
null
GSeTT/Typed-Syntax.agda
thibautbenjamin/catt-formalization
3a02010a869697f4833c9bc6047d66ca27b87cf2
[ "MIT" ]
null
null
null
{-# OPTIONS --rewriting --without-K #-} open import Agda.Primitive open import Prelude open import GSeTT.Syntax open import GSeTT.Rules open import GSeTT.CwF-structure open import GSeTT.Uniqueness-Derivations {- Typed syntax for type theory for globular sets -} module GSeTT.Typed-Syntax where Ctx : Set₁ Ctx = Σ Pre-Ctx (λ Γ → Γ ⊢C) Ty : Ctx → Set₁ Ty (Γ , _) = Σ Pre-Ty (λ A → Γ ⊢T A) Tm : ∀ (Γ : Ctx) → Ty Γ → Set₁ Tm (Γ , _) (A , _) = Σ Pre-Tm (λ t → Γ ⊢t t # A) Sub : ∀ (Δ : Ctx) (Γ : Ctx) → Set₁ Sub (Δ , _) (Γ , _) = Σ Pre-Sub (λ γ → Δ ⊢S γ > Γ) eqC : ∀ (Γ Δ : Ctx) → fst Γ == fst Δ → Γ == Δ eqC (Γ , Γ⊢) (.Γ , Γ⊢') idp = Σ= idp (has-all-paths-⊢C _ _) eqT : ∀ {Γ} (A B : Ty Γ) → fst A == fst B → A == B eqT (A , Γ⊢A) (.A , Γ⊢'A) idp = Σ= idp (has-all-paths-⊢T _ _) eqt : ∀ {Γ A} (t u : Tm Γ A) → fst t == fst u → t == u eqt (t , Γ⊢t:A) (.t , Γ⊢':A) idp = Σ= idp (has-all-paths-⊢t _ _) eqS : ∀ {Γ Δ} (γ δ : Sub Γ Δ) → fst γ == fst δ → γ == δ eqS (γ , Γ⊢γ:Δ) (.γ , Γ⊢'γ:Δ) idp = Σ= idp (has-all-paths-⊢S _ _) trS : ∀ {Γ Δ Θ : Ctx} → (p : Δ == Θ) → {γ : Sub Γ Δ} → {δ : Sub Γ Θ} → fst γ == fst δ → transport p γ == δ trS {Γ} {Δ} {Θ} idp {γ} {δ} x = eqS {Γ} {Θ} γ δ x eqdec-Ty : ∀ Γ → eqdec (Ty Γ) eqdec-Ty Γ (A , Γ⊢A) (B , Γ⊢B) with eqdec-PreTy A B ... | inl idp = inl (eqT {Γ} (A , Γ⊢A) (B , Γ⊢B) idp) ... | inr A≠B = inr λ p → A≠B (fst-is-inj p) is-set-Ty : ∀ Γ → is-set (Ty Γ) is-set-Ty Γ = eqdec-is-set (eqdec-Ty Γ)
32.26087
108
0.499326
3dd93087ff10e4006a29e66e76ab29434131b090
206
agda
Agda
test/Fail/Issue799a.agda
mdimjasevic/agda
8fb548356b275c7a1e79b768b64511ae937c738b
[ "BSD-3-Clause" ]
1,989
2015-01-09T23:51:16.000Z
2022-03-30T18:20:48.000Z
test/Fail/Issue799a.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
4,066
2015-01-10T11:24:51.000Z
2022-03-31T21:14:49.000Z
test/Fail/Issue799a.agda
Seanpm2001-languages/agda
9911f73061e21a87fad76c662463257afe02c861
[ "BSD-2-Clause" ]
371
2015-01-03T14:04:08.000Z
2022-03-30T19:00:30.000Z
-- Andreas, 2013-02-26 module Issue799a where data D (A : Set1) : Set where d : D A x : D Set x = d {A = _} -- correct parameter name y : D Set y = d {B = _} -- wrong parameter name, should give error
17.166667
56
0.616505