Search is not available for this dataset
text
string
meta
dict
-- Andreas, fixed #1349 on 2016-06-08 -- {-# OPTIONS -v tc.term.exlam:50 -v scope.extendedLambda:10 #-} module Issue1349 where open import Common.Prelude module Logic {s} (F : Set s) (arF : F → Nat) where data Term : Nat → Set s where var : ∀ n → Term (suc n) d : Unit → Nat d = \ {unit → zero} -- fails -- d unit = zero -- works module M = Logic Unit d -- (λ{unit -> zero}) test : Logic.Term Unit {!!} (suc zero) test = M.var zero -- WAS: -- Agda2> Ambiguous name: Issue1349._..extendedlambda0 -- (agda2-info-action "*Error*" "An internal error has occurred. Please report this as a bug. Location of the error: src/full/Agda/TypeChecking/Reduce/Monad.hs:172" nil) -- Gives proper error now.
{ "alphanum_fraction": 0.6507713885, "avg_line_length": 25.4642857143, "ext": "agda", "hexsha": "12e5a9c994a5707a62a7ef60229bfd843fd075df", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/Issue1349.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/Issue1349.agda", "max_line_length": 169, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/Issue1349.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 226, "size": 713 }
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
{ "alphanum_fraction": 0.6066887783, "avg_line_length": 36.9183673469, "ext": "agda", "hexsha": "dc64a93a989bb7fc8c88b79407f0607e984ff4a3", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:37:59.000Z", "max_forks_repo_forks_event_min_datetime": "2022-03-12T11:37:59.000Z", "max_forks_repo_head_hexsha": "8ced22124dbe12fa820699bb362247a96d592c03", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "agda/agda-web-uri", "max_forks_repo_path": "src/Web/URI.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "8ced22124dbe12fa820699bb362247a96d592c03", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "agda/agda-web-uri", "max_issues_repo_path": "src/Web/URI.agda", "max_line_length": 120, "max_stars_count": 1, "max_stars_repo_head_hexsha": "8ced22124dbe12fa820699bb362247a96d592c03", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "agda/agda-web-uri", "max_stars_repo_path": "src/Web/URI.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-23T04:56:25.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-23T04:56:25.000Z", "num_tokens": 1293, "size": 3618 }
open import Oscar.Prelude open import Oscar.Data.Constraint module Oscar.Class where record InnerClass {ℓ} {𝔢} {CONSTRAINTS : Ø 𝔢} (constraints : CONSTRAINTS) (_ : Constraint constraints) (SET-METHOD : Ø ℓ) : Ø ℓ where constructor ∁ field ⋆ : SET-METHOD open InnerClass public module ℭLASS {ℓ} {𝔢} {CONSTRAINTS : Ø 𝔢} (constraints : CONSTRAINTS) (c : Ø ℓ) where class = InnerClass constraints ∅ c type = c method : ⦃ _ : class ⦄ → type method ⦃ ⌶ ⦄ = InnerClass.⋆ ⌶ record Rℭlass {ℓ 𝔯} {𝔢} {CONSTRAINTS : Ø 𝔢} (constraints : CONSTRAINTS) : Ø ↑̂ (ℓ ∙̂ 𝔯) where constructor ∁ field SET-METHOD : Ø ℓ SET-R : SET-METHOD → Ø 𝔯 record SET-CLASS ⦃ _ : Constraint constraints ⦄ : Ø ℓ ∙̂ 𝔯 where constructor ∁ field ⋆ : SET-METHOD ⦃ ⋆⋆ ⦄ : SET-R ⋆ open SET-CLASS public GET-CLASS : Ø _ GET-CLASS = SET-CLASS GET-METHOD : ⦃ _ : GET-CLASS ⦄ → SET-METHOD GET-METHOD ⦃ ⌶ ⦄ = SET-CLASS.⋆ ⌶ open Rℭlass using (⋆; ∁) public
{ "alphanum_fraction": 0.6065411298, "avg_line_length": 19.7843137255, "ext": "agda", "hexsha": "8d301480f70718ae3b09a79bf5a7dc8f907e36cb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-3/src/Oscar/Class.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-3/src/Oscar/Class.agda", "max_line_length": 133, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-3/src/Oscar/Class.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 428, "size": 1009 }
{-# OPTIONS --without-K #-} module algebra.group.morphism where open import level open import algebra.group.core open import algebra.monoid.morphism module _ {i}{j} {X : Set i}⦃ sX : IsGroup X ⦄ {Y : Set j}⦃ sY : IsGroup Y ⦄ where open IsGroup ⦃ ... ⦄ IsGroupMorphism : (X → Y) → Set (i ⊔ j) IsGroupMorphism f = IsMonoidMorphism f
{ "alphanum_fraction": 0.635097493, "avg_line_length": 23.9333333333, "ext": "agda", "hexsha": "4bbb6558e758119b6fd500da4dbe716715d49cc6", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_path": "src/algebra/group/morphism.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/algebra/group/morphism.agda", "max_line_length": 44, "max_stars_count": 20, "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_path": "src/algebra/group/morphism.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "num_tokens": 125, "size": 359 }
-- Andreas, 2016-07-21 adapted from MagicWith.agda -- Testing correct printing of postfix projections. {-# OPTIONS --postfix-projections #-} -- {-# OPTIONS -v tc.cc:60 #-} -- {-# OPTIONS -v tc.conv.elim:50 #-} open import Common.Product open import Common.Nat record True : Set where data False : Set where IsZero : Nat → Set IsZero zero = True IsZero (suc _) = False Uncurry : {A : Set}{B : A → Set} → ((x : A) → B x → Set) → Σ A B → Set Uncurry F p = F (p .proj₁) (p .proj₂) F : (n : Nat) → IsZero n → Set F zero _ = True F (suc _) () -- Trying to match only on p .proj₁ doesn't work since we can't abstract -- p .proj₁ without also abstracting p .proj₂. f : (p : Σ Nat IsZero) → Uncurry F p f p with p .proj₁ f p | zero = _ f p | suc _ = ?
{ "alphanum_fraction": 0.6240105541, "avg_line_length": 23.6875, "ext": "agda", "hexsha": "2d7096946fa6bfab9ca8acd11349703516172d0a", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Fail/Issue1963MagicWith.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Fail/Issue1963MagicWith.agda", "max_line_length": 72, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Fail/Issue1963MagicWith.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 255, "size": 758 }
{-# OPTIONS --allow-unsolved-metas --no-termination-check #-} module TT where module Prelude where -- Props ------------------------------------------------------------------ data True : Set where tt : True data False : Set where postulate falseE : (A : Set) -> False -> A infix 3 _/\_ data _/\_ (P Q : Set) : Set where andI : P -> Q -> P /\ Q -- Zero and One ----------------------------------------------------------- data Zero : Set where data One : Set where unit : One -- Natural numbers -------------------------------------------------------- data Nat : Set where zero : Nat suc : Nat -> Nat _+_ : Nat -> Nat -> Nat zero + m = m suc n + m = suc (n + m) module NatEq where infix 5 _==_ _==_ : Nat -> Nat -> Set zero == zero = True suc n == suc m = n == m _ == _ = False rewriteEq : (C : Nat -> Set){m n : Nat} -> m == n -> C n -> C m rewriteEq C {zero} {zero} _ x = x rewriteEq C {suc _} {suc _} eq x = rewriteEq (\z -> C (suc z)) eq x rewriteEq C {zero} {suc _} () _ rewriteEq C {suc _} {zero} () _ module Chain {A : Set}(_==_ : A -> A -> Set) (_trans_ : {x y z : A} -> x == y -> y == z -> x == z) where infixl 4 _=-=_ infixl 4 _===_ infixr 8 _since_ _=-=_ : (x : A){y : A} -> x == y -> x == y x =-= xy = xy _===_ : {x y z : A} -> x == y -> y == z -> x == z xy === yz = xy trans yz _since_ : {x : A}(y : A) -> x == y -> x == y y since xy = xy module Fin where open Prelude -- Finite sets ------------------------------------------------------------ data Suc (A : Set) : Set where fzero' : Suc A fsuc' : A -> Suc A mutual data Fin (n : Nat) : Set where finI : Fin' n -> Fin n Fin' : Nat -> Set Fin' zero = Zero Fin' (suc n) = Suc (Fin n) fzero : {n : Nat} -> Fin (suc n) fzero = finI fzero' fsuc : {n : Nat} -> Fin n -> Fin (suc n) fsuc i = finI (fsuc' i) finE : {n : Nat} -> Fin n -> Fin' n finE (finI i) = i module FinEq where infix 5 _==_ _==_ : {n : Nat} -> Fin n -> Fin n -> Set _==_ {suc _} (finI fzero' ) (finI fzero' ) = True _==_ {suc _} (finI (fsuc' i)) (finI (fsuc' j)) = i == j _==_ _ _ = False rewriteEq : {n : Nat}(C : Fin n -> Set){i j : Fin n} -> i == j -> C j -> C i rewriteEq {suc _} C {finI fzero' } {finI fzero' } eq x = x rewriteEq {suc _} C {finI (fsuc' i)} {finI (fsuc' j)} eq x = rewriteEq (\z -> C (fsuc z)) eq x rewriteEq {suc _} C {finI (fsuc' _)} {finI fzero' } () _ rewriteEq {suc _} C {finI fzero' } {finI (fsuc' _)} () _ rewriteEq {zero} C {finI ()} {_} _ _ module Vec where open Prelude open Fin infixr 15 _::_ -- Vectors ---------------------------------------------------------------- data Nil : Set where nil' : Nil data Cons (A As : Set) : Set where cons' : A -> As -> Cons A As mutual data Vec (A : Set)(n : Nat) : Set where vecI : Vec' A n -> Vec A n Vec' : Set -> Nat -> Set Vec' A zero = Nil Vec' A (suc n) = Cons A (Vec A n) nil : {A : Set} -> Vec A zero nil = vecI nil' _::_ : {A : Set}{n : Nat} -> A -> Vec A n -> Vec A (suc n) x :: xs = vecI (cons' x xs) vecE : {A : Set}{n : Nat} -> Vec A n -> Vec' A n vecE (vecI xs) = xs vec : {A : Set}(n : Nat) -> A -> Vec A n vec zero _ = nil vec (suc n) x = x :: vec n x map : {n : Nat}{A B : Set} -> (A -> B) -> Vec A n -> Vec B n map {zero} f (vecI nil') = nil map {suc n} f (vecI (cons' x xs)) = f x :: map f xs _!_ : {n : Nat}{A : Set} -> Vec A n -> Fin n -> A _!_ {zero } _ (finI ()) _!_ {suc n} (vecI (cons' x _ )) (finI fzero') = x _!_ {suc n} (vecI (cons' _ xs)) (finI (fsuc' i)) = xs ! i tabulate : {n : Nat}{A : Set} -> (Fin n -> A) -> Vec A n tabulate {zero} f = nil tabulate {suc n} f = f fzero :: tabulate (\x -> f (fsuc x)) module Untyped where open Prelude open Fin open Vec Name = Nat data Expr (n : Nat) : Set where eVar : Fin n -> Expr n eApp : Expr n -> Expr n -> Expr n eLam : Expr (suc n) -> Expr n eSet : Expr n eEl : Expr n ePi : Expr n eCon : Name -> Expr n module ExprEq where infix 5 _==_ _==_ : {n : Nat} -> Expr n -> Expr n -> Set eVar i == eVar j = FinEq._==_ i j eApp e1 e2 == eApp e3 e4 = e1 == e3 /\ e2 == e4 eLam e1 == eLam e2 = e1 == e2 eSet == eSet = True eEl == eEl = True ePi == ePi = True eCon f == eCon g = NatEq._==_ f g _ == _ = False rewriteEq : {n : Nat}(C : Expr n -> Set){r s : Expr n} -> r == s -> C s -> C r rewriteEq C {eVar i } {eVar j } eq x = FinEq.rewriteEq (\z -> C (eVar z)) eq x rewriteEq C {eLam e1 } {eLam e2 } eq x = rewriteEq (\z -> C (eLam z)) eq x rewriteEq C {eSet } {eSet } eq x = x rewriteEq C {eEl } {eEl } eq x = x rewriteEq C {ePi } {ePi } eq x = x rewriteEq C {eCon f } {eCon g } eq x = NatEq.rewriteEq (\z -> C (eCon z)) eq x rewriteEq C {eApp e1 e2} {eApp e3 e4} (andI eq13 eq24) x = rewriteEq (\z -> C (eApp z e2)) eq13 ( rewriteEq (\z -> C (eApp e3 z)) eq24 x ) rewriteEq C {eVar _} {eLam _ } () _ rewriteEq C {eVar _} {eSet } () _ rewriteEq C {eVar _} {eEl } () _ rewriteEq C {eVar _} {eCon _ } () _ rewriteEq C {eVar _} {ePi } () _ rewriteEq C {eVar _} {eApp _ _} () _ rewriteEq C {eLam _} {eVar _ } () _ rewriteEq C {eLam _} {eSet } () _ rewriteEq C {eLam _} {eEl } () _ rewriteEq C {eLam _} {eCon _ } () _ rewriteEq C {eLam _} {ePi } () _ rewriteEq C {eLam _} {eApp _ _} () _ rewriteEq C {eSet } {eLam _ } () _ rewriteEq C {eSet } {eVar _ } () _ rewriteEq C {eSet } {eEl } () _ rewriteEq C {eSet } {eCon _ } () _ rewriteEq C {eSet } {ePi } () _ rewriteEq C {eSet } {eApp _ _} () _ rewriteEq C {eEl } {eLam _ } () _ rewriteEq C {eEl } {eSet } () _ rewriteEq C {eEl } {eVar _ } () _ rewriteEq C {eEl } {eCon _ } () _ rewriteEq C {eEl } {ePi } () _ rewriteEq C {eEl } {eApp _ _} () _ rewriteEq C {eCon _} {eLam _ } () _ rewriteEq C {eCon _} {eSet } () _ rewriteEq C {eCon _} {eEl } () _ rewriteEq C {eCon _} {eVar _ } () _ rewriteEq C {eCon _} {ePi } () _ rewriteEq C {eCon _} {eApp _ _} () _ rewriteEq C {ePi } {eLam _ } () _ rewriteEq C {ePi } {eSet } () _ rewriteEq C {ePi } {eEl } () _ rewriteEq C {ePi } {eCon _ } () _ rewriteEq C {ePi } {eVar _ } () _ rewriteEq C {ePi } {eApp _ _} () _ rewriteEq C {eApp _ _} {eLam _ } () _ rewriteEq C {eApp _ _} {eSet } () _ rewriteEq C {eApp _ _} {eEl } () _ rewriteEq C {eApp _ _} {eCon _ } () _ rewriteEq C {eApp _ _} {ePi } () _ rewriteEq C {eApp _ _} {eVar _ } () _ module Typed where open Prelude open Fin open Vec infixl 15 _&_ infix 13 _!!_ infix 5 _==_ -- Contexts --------------------------------------------------------------- data CSuc (n : Nat) : Set Context' : Nat -> Set Context' zero = Nil Context' (suc n) = CSuc n data Context (n : Nat) : Set data Type {n : Nat}(Γ : Context n) : Set data CSuc n where ext : (Γ : Context n) -> Type Γ -> Context' (suc n) data Context n where ctxI : Context' n -> Context n -- Types ------------------------------------------------------------------ _&_ : {n : Nat}(Γ : Context n) -> Type Γ -> Context (suc n) data Term {n : Nat}(Γ : Context n)(A : Type Γ) : Set data Type {n} Γ where SET : Type Γ Pi : (A : Type Γ) -> Type (Γ & A) -> Type Γ El : Term Γ SET -> Type Γ Γ & A = ctxI (ext Γ A) -- Variables -------------------------------------------------------------- data VarSuc {n : Nat}(Γ : Context n)(B : Type Γ)(A : Type (Γ & B)) : Set Var' : {n : Nat}(Γ : Context n) -> Type Γ -> Set Var' {zero} Γ A = Zero Var' {suc n} (ctxI (ext Γ B)) A = VarSuc Γ B A _==_ : {n : Nat}{Γ : Context n} -> Type Γ -> Type Γ -> Set data Ren {n m : Nat}(Γ : Context n)(Δ : Context m) : Set rename : {n m : Nat}{Γ : Context n}{Δ : Context m} -> Ren Γ Δ -> Type Γ -> Type Δ upR : {n : Nat}{Γ : Context n}{A : Type Γ} -> Ren Γ (Γ & A) data Var {n : Nat}(Γ : Context n)(A : Type Γ) : Set data VarSuc {n} Γ B A where vzero_ : A == rename upR B -> Var' (Γ & B) A vsuc_ : (C : Type Γ) -> A == rename upR C -> Var Γ C -> Var' (Γ & B) A data Var {n} Γ A where varI : Var' Γ A -> Var Γ A -- Terms ------------------------------------------------------------------ data Sub {n m : Nat}(Γ : Context n)(Δ : Context m) : Set subst : {n m : Nat}{Γ : Context n}{Δ : Context m} -> Sub Γ Δ -> Type Γ -> Type Δ down : {n : Nat}{Γ : Context n}{A : Type Γ} -> Term Γ A -> Sub (Γ & A) Γ data Term {n} Γ A where var : (x : Var Γ A) -> Term Γ A app : {B : Type Γ}{C : Type (Γ & B)} -> Term Γ (Pi B C) -> (t : Term Γ B) -> A == subst (down t) C -> Term Γ A lam : {B : Type Γ}{C : Type (Γ & B)} -> Term (Γ & B) C -> A == Pi B C -> Term Γ A -- Context manipulation --------------------------------------------------- ∅ : Context zero ∅ = ctxI nil' _!!_ : {n : Nat}(Γ : Context n) -> Fin n -> Type Γ _!!_ {zero} _ (finI ()) _!!_ {suc _} (ctxI (ext Γ A)) (finI fzero') = rename upR A _!!_ {suc _} (ctxI (ext Γ A)) (finI (fsuc' i)) = rename upR (Γ !! i) -- Renamings -------------------------------------------------------------- data ConsRen {n m : Nat}(Γ : Context n)(A : Type Γ)(Δ : Context m) : Set Ren' : {n m : Nat} -> Context n -> Context m -> Set Ren' {zero} {m} (ctxI nil') Δ = Nil Ren' {suc n} {m} (ctxI (ext Γ A)) Δ = ConsRen Γ A Δ data ConsRen {n m} Γ A Δ where extRen' : (ρ : Ren Γ Δ) -> Var Δ (rename ρ A) -> Ren' (Γ & A) Δ data Ren {n m} Γ Δ where renI : Ren' Γ Δ -> Ren Γ Δ -- Performing renamings --------------------------------------------------- rename' : {n m : Nat}{Γ : Context n}{Δ : Context m} -> Ren Γ Δ -> Type Γ -> Type Δ rename ρ SET = SET rename ρ A = rename' ρ A liftR : {n m : Nat}{Γ : Context n}{A : Type Γ}{Δ : Context m} -> (ρ : Ren Γ Δ) -> Ren (Γ & A) (Δ & rename ρ A) renameTerm : {n m : Nat}{Γ : Context n}{Δ : Context m}{A : Type Γ} (ρ : Ren Γ Δ) -> Term Γ A -> Term Δ (rename ρ A) rename' ρ SET = SET rename' ρ (Pi A B) = Pi (rename ρ A) (rename (liftR ρ) B) rename' ρ (El t) = El (renameTerm ρ t) lookupR : {n m : Nat}{Γ : Context n}{A : Type Γ}{Δ : Context m} (ρ : Ren Γ Δ)(x : Var Γ A) -> Var Δ (rename ρ A) cong : {n m : Nat}{Γ : Context n}{Δ : Context m}(f : Type Γ -> Type Δ) {A B : Type Γ} -> A == B -> f A == f B _trans_ : {n : Nat}{Γ : Context n}{A B C : Type Γ} -> A == B -> B == C -> A == C renameSubstCommute : {n m : Nat}{Γ : Context n}{Δ : Context m}{A : Type Γ}{B : Type (Γ & A)} {ρ : Ren Γ Δ}{t : Term Γ A} -> rename ρ (subst (down t) B) == subst (down (renameTerm ρ t)) (rename (liftR ρ) B) renameTerm ρ (var x) = var (lookupR ρ x) renameTerm {_}{_}{_}{_}{A} ρ (app{_}{C} s t eq) = app (renameTerm ρ s) (renameTerm ρ t) (cong (rename ρ) eq trans renameSubstCommute) renameTerm ρ (lam t eq) = lam (renameTerm (liftR ρ) t) (cong (rename ρ) eq) lookupR {zero} _ (varI ()) lookupR {suc n} {_} {ctxI (ext Γ B)} {A} {Δ} (renI (extRen' ρ z)) (varI (vzero_ eq)) = {!!} lookupR {suc n} {_} {ctxI (ext Γ B)} {A} {Δ} (renI (extRen' ρ z)) (varI (vsuc_ C eq x)) = {!!} -- Building renamings ----------------------------------------------------- extRen : {n m : Nat}{Γ : Context n}{A : Type Γ}{Δ : Context m} (ρ : Ren Γ Δ) -> Var Δ (rename ρ A) -> Ren (Γ & A) Δ extRen ρ x = renI (extRen' ρ x) _coR_ : {n m p : Nat}{Γ : Context n}{Δ : Context m}{Θ : Context p} -> Ren Δ Θ -> Ren Γ Δ -> Ren Γ Θ liftR {_}{_}{_}{A} ρ = extRen (upR coR ρ) (varI {!!}) idR : {n : Nat} {Γ : Context n} -> Ren Γ Γ idR = {!!} _coR_ = {!!} upR = {!!} -- Substitutions ---------------------------------------------------------- data ConsSub {n m : Nat}(Γ : Context n)(A : Type Γ)(Δ : Context m) : Set Sub' : {n m : Nat} -> Context n -> Context m -> Set Sub' {zero} {m} (ctxI nil') Δ = Nil Sub' {suc n} {m} (ctxI (ext Γ A)) Δ = ConsSub Γ A Δ data ConsSub {n m} Γ A Δ where extSub' : (σ : Sub Γ Δ) -> Term Δ (subst σ A) -> Sub' (Γ & A) Δ data Sub {n m} Γ Δ where subI : Sub' Γ Δ -> Sub Γ Δ -- Performing substitution ------------------------------------------------ subst' : {n m : Nat}{Γ : Context n}{Δ : Context m} -> Sub Γ Δ -> Type Γ -> Type Δ subst σ SET = SET subst σ A = subst' σ A liftS : {n m : Nat}{Γ : Context n}{A : Type Γ}{Δ : Context m} -> (σ : Sub Γ Δ) -> Sub (Γ & A) (Δ & subst σ A) substTerm : {n m : Nat}{Γ : Context n}{Δ : Context m}{A : Type Γ} -> (σ : Sub Γ Δ) -> Term Γ A -> Term Δ (subst σ A) subst' σ (Pi A B) = Pi (subst σ A) (subst (liftS σ) B) subst' σ (El t) = El (substTerm σ t) subst' σ SET = SET substTerm σ (var x) = {!!} substTerm σ (app s t eq) = {!!} substTerm σ (lam t eq) = {!!} -- Building substitutions ------------------------------------------------- liftS {_}{_}{_}{A} σ = {!!} -- extSub (upS ∘ σ) (var fzero (substCompose upS σ A)) -- Works with hidden args to substCompose when inlined in subst -- but not here. Weird. topS : {n : Nat}{Γ : Context n} -> Sub ∅ Γ topS = subI nil' extSub : {n m : Nat}{Γ : Context n}{A : Type Γ}{Δ : Context m} (σ : Sub Γ Δ) -> Term Δ (subst σ A) -> Sub (Γ & A) Δ extSub σ t = subI (extSub' σ t) idS : {n : Nat}{Γ : Context n} -> Sub Γ Γ idS {zero} {ctxI nil'} = topS idS {suc _} {ctxI (ext Γ A)} = {!!} -- extSub upS (var fzero refl) convert : {n : Nat}{Γ : Context n}{A B : Type Γ} -> A == B -> Term Γ B -> Term Γ A _∘_ : {n m p : Nat}{Γ : Context n}{Δ : Context m}{Θ : Context p} -> Sub Δ Θ -> Sub Γ Δ -> Sub Γ Θ substCompose : {n m p : Nat}{Γ : Context n}{Δ : Context m}{Θ : Context p} (σ : Sub Δ Θ)(δ : Sub Γ Δ)(A : Type Γ) -> subst (σ ∘ δ) A == subst σ (subst δ A) _∘_ {zero} {_}{_} {ctxI nil'} _ _ = topS _∘_ {suc _}{_}{_} {ctxI (ext Γ A)} σ (subI (extSub' δ t)) = extSub (σ ∘ δ) (convert (substCompose σ δ A) (substTerm σ t)) upS : {n : Nat}{Γ : Context n}{A : Type Γ} -> Sub Γ (Γ & A) upS = {!!} substId : {n : Nat}{Γ : Context n}{A : Type Γ} -> subst idS A == A down t = extSub idS (convert substId t) -- Convertibility --------------------------------------------------------- A == B = {!!} refl : {n : Nat}{Γ : Context n}{A : Type Γ} -> A == A refl = {!!} cong f eq = {!!} ab trans bc = {!!} convert eq t = {!!} -- Properties ------------------------------------------------------------- renameId : {n : Nat}{Γ : Context n}{A : Type Γ} -> rename idR A == A renameId = {!!} renameCompose : {n m p : Nat}{Γ : Context n}{Δ : Context m}{Θ : Context p} (σ : Ren Δ Θ)(δ : Ren Γ Δ)(A : Type Γ) -> rename (σ coR δ) A == rename σ (rename δ A) renameCompose σ δ A = {!!} substId = {!!} substCompose σ δ A = {!!} renameSubstCommute = {!!}
{ "alphanum_fraction": 0.4462977003, "avg_line_length": 31.5928143713, "ext": "agda", "hexsha": "e7d4f5836bb5effcd768421a2386afd2f7740acb", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "examples/TT.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "examples/TT.agda", "max_line_length": 101, "max_stars_count": 1, "max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/agda-kanso", "max_stars_repo_path": "examples/TT.agda", "max_stars_repo_stars_event_max_datetime": "2019-11-27T04:41:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-11-27T04:41:05.000Z", "num_tokens": 5842, "size": 15828 }
module Data.BinaryTree where import Lvl open import Type private variable ℓ ℓᵢ ℓₗ ℓₙ ℓₒ : Lvl.Level private variable N N₁ N₂ L T A B : Type{ℓ} data BinaryTree (L : Type{ℓₗ}) (N : Type{ℓₙ}) : Type{ℓₗ Lvl.⊔ ℓₙ} where Leaf : L → BinaryTree L N Node : N → BinaryTree L N → BinaryTree L N → BinaryTree L N elim : (P : BinaryTree L N → Type{ℓ}) → ((l : L) → P(Leaf l)) → (∀{tl tr} → (n : N) → (pl : P(tl)) → (pr : P(tr)) → P(Node n tl tr)) → ((t : BinaryTree L N) → P(t)) elim P pl pn (Leaf l) = pl l elim P pl pn (Node n l r) = pn n (elim P pl pn l) (elim P pl pn r) open import Data using (Unit ; <>) open import Data.Boolean open import Data.Option open import Data.Tuple using (_⨯_ ; _,_) open import Functional as Fn using (_$_) open import Numeral.Natural open import Numeral.Natural.Function open import Numeral.Natural.Oper hiding (_^_) emptyTree : BinaryTree{ℓₗ} Unit N emptyTree = Leaf <> singleton : N → BinaryTree{ℓₗ} Unit N singleton a = Node a emptyTree emptyTree isLeaf : BinaryTree L N → Bool isLeaf (Leaf _) = 𝑇 isLeaf (Node _ _ _) = 𝐹 isNode : BinaryTree L N → Bool isNode (Leaf _) = 𝐹 isNode (Node _ _ _) = 𝑇 root : BinaryTree L N → Option(N) root (Leaf _) = None root (Node a _ _) = Some a flip : BinaryTree L N → BinaryTree L N flip (Leaf l) = Leaf l flip (Node n l r) = Node n (flip r) (flip l) foldPreOrderDepthFirst : (L → T → T) → (N → T → T) → T → BinaryTree L N → T foldPreOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Leaf a) = a ▫ₗ id foldPreOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Node a l r) = a ▫ₙ_ $ Fn.swap(foldPreOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) l $ Fn.swap(foldPreOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) r $ id foldInOrderDepthFirst : (L → T → T) → (N → T → T) → T → BinaryTree L N → T foldInOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Leaf a) = a ▫ₗ id foldInOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Node a l r) = Fn.swap(foldInOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) l $ a ▫ₙ_ $ Fn.swap(foldInOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) r $ id foldPostOrderDepthFirst : (L → T → T) → (N → T → T) → T → BinaryTree L N → T foldPostOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Leaf a) = a ▫ₗ id foldPostOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Node a l r) = Fn.swap(foldPostOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) l $ Fn.swap(foldPostOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) r $ a ▫ₙ_ $ id foldReversedPreOrderDepthFirst : (L → T → T) → (N → T → T) → T → BinaryTree L N → T foldReversedPreOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Leaf a) = a ▫ₗ id foldReversedPreOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Node a l r) = a ▫ₙ_ $ Fn.swap(foldReversedPreOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) r $ Fn.swap(foldReversedPreOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) l $ id foldReversedInOrderDepthFirst : (L → T → T) → (N → T → T) → T → BinaryTree L N → T foldReversedInOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Leaf a) = a ▫ₗ id foldReversedInOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Node a l r) = Fn.swap(foldReversedInOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) r $ a ▫ₙ_ $ Fn.swap(foldReversedInOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) l $ id foldReversedPostOrderDepthFirst : (L → T → T) → (N → T → T) → T → BinaryTree L N → T foldReversedPostOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Leaf a) = a ▫ₗ id foldReversedPostOrderDepthFirst(_▫ₗ_)(_▫ₙ_) id (Node a l r) = Fn.swap(foldReversedPostOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) r $ Fn.swap(foldReversedPostOrderDepthFirst(_▫ₗ_)(_▫ₙ_)) l $ a ▫ₙ_ $ id -- The size is the number of nodes in the tree. size : BinaryTree L N → ℕ size (Leaf _) = 𝟎 size (Node _ l r) = 𝐒(size(l) + size(r)) -- The number of leaves in the tree. numberOfLeaves : BinaryTree L N → ℕ numberOfLeaves (Leaf _) = 1 numberOfLeaves (Node _ l r) = numberOfLeaves(l) + numberOfLeaves(r) -- The height is the length of the longest path from the root. height : BinaryTree L N → ℕ height (Leaf _) = 𝟎 height (Node _ l r) = 𝐒(max (height l) (height r)) open import Data.Boolean.Operators open Data.Boolean.Operators.Programming isFull : BinaryTree L N → Bool isFull (Leaf _) = 𝑇 isFull (Node _ (Leaf _) (Leaf _)) = 𝑇 isFull (Node _ (Node _ _ _) (Leaf _)) = 𝐹 isFull (Node _ (Leaf _) (Node _ _ _)) = 𝐹 isFull (Node _ l@(Node _ _ _) r@(Node _ _ _)) = isFull l && isFull r open import Data.List import Data.List.Functions as List treesOfDepth : ℕ → BinaryTree L N → List(BinaryTree L N) treesOfDepth 𝟎 tree = tree ⊰ ∅ treesOfDepth (𝐒(_)) (Leaf _) = ∅ treesOfDepth (𝐒(n)) (Node _ l r) = (treesOfDepth n l) List.++ (treesOfDepth n r)
{ "alphanum_fraction": 0.6048335807, "avg_line_length": 36.8515625, "ext": "agda", "hexsha": "4e6418adb454b55ce849243a3c635fb0d2af934d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Data/BinaryTree.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Data/BinaryTree.agda", "max_line_length": 164, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Data/BinaryTree.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 1761, "size": 4717 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.Vec.NAry where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Data.Nat open import Cubical.Data.Vec.Base private variable ℓ ℓ' : Level A : Type ℓ B : Type ℓ' nAryLevel : Level → Level → ℕ → Level nAryLevel ℓ₁ ℓ₂ zero = ℓ₂ nAryLevel ℓ₁ ℓ₂ (suc n) = ℓ-max ℓ₁ (nAryLevel ℓ₁ ℓ₂ n) nAryOp : (n : ℕ) → Type ℓ → Type ℓ' → Type (nAryLevel ℓ ℓ' n) nAryOp zero A B = B nAryOp (suc n) A B = A → nAryOp n A B _$ⁿ_ : ∀ {n} → nAryOp n A B → (Vec A n → B) f $ⁿ [] = f f $ⁿ (x ∷ xs) = f x $ⁿ xs curryⁿ : ∀ {n} → (Vec A n → B) → nAryOp n A B curryⁿ {n = zero} f = f [] curryⁿ {n = suc n} f x = curryⁿ (λ xs → f (x ∷ xs)) $ⁿ-curryⁿ : ∀ {n} (f : Vec A n → B) → _$ⁿ_ (curryⁿ f) ≡ f $ⁿ-curryⁿ {n = zero} f = funExt λ { [] → refl } $ⁿ-curryⁿ {n = suc n} f = funExt λ { (x ∷ xs) i → $ⁿ-curryⁿ {n = n} (λ ys → f (x ∷ ys)) i xs} curryⁿ-$ⁿ : ∀ {n} (f : nAryOp {ℓ = ℓ} {ℓ' = ℓ'} n A B) → curryⁿ {A = A} {B = B} (_$ⁿ_ f) ≡ f curryⁿ-$ⁿ {n = zero} f = refl curryⁿ-$ⁿ {n = suc n} f = funExt λ x → curryⁿ-$ⁿ {n = n} (f x) nAryOp≃VecFun : ∀ {n} → nAryOp n A B ≃ (Vec A n → B) nAryOp≃VecFun {n = n} = isoToEquiv f where f : Iso (nAryOp n A B) (Vec A n → B) Iso.fun f = _$ⁿ_ Iso.inv f = curryⁿ Iso.rightInv f = $ⁿ-curryⁿ Iso.leftInv f = curryⁿ-$ⁿ {n = n} -- In order to apply ua to nAryOp≃VecFun we probably need to change -- the base-case of nAryLevel to "ℓ-max ℓ₁ ℓ₂". This will make it -- necessary to add lots of Lifts in zero cases so it's not done yet, -- but if the Path is ever needed then it might be worth to do.
{ "alphanum_fraction": 0.5938740783, "avg_line_length": 31.4821428571, "ext": "agda", "hexsha": "0a90a21c982193b1f0abb5439cdc249e9573389a", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Data/Vec/NAry.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Data/Vec/NAry.agda", "max_line_length": 93, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Data/Vec/NAry.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 796, "size": 1763 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Dagger.Construction.Discrete where open import Relation.Binary.PropositionalEquality open import Categories.Category.Dagger open import Categories.Category.Discrete Discrete-HasDagger : ∀ {a} (A : Set a) → HasDagger (Discrete A) Discrete-HasDagger A = record { _† = sym ; †-identity = refl ; †-homomorphism = λ { {f = refl} {g = refl} → refl } ; †-resp-≈ = cong sym ; †-involutive = λ { refl → refl} } Discrete-DaggerCategory : ∀ {a} (A : Set a) → DaggerCategory a a a Discrete-DaggerCategory A = record { hasDagger = Discrete-HasDagger A }
{ "alphanum_fraction": 0.6914378029, "avg_line_length": 30.95, "ext": "agda", "hexsha": "719d3d5db74babcf21e54e1d48a63a6ee2e9d510", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "d07746023503cc8f49670e309a6170dc4b404b95", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "andrejbauer/agda-categories", "max_forks_repo_path": "src/Categories/Category/Dagger/Construction/Discrete.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d07746023503cc8f49670e309a6170dc4b404b95", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "andrejbauer/agda-categories", "max_issues_repo_path": "src/Categories/Category/Dagger/Construction/Discrete.agda", "max_line_length": 71, "max_stars_count": 1, "max_stars_repo_head_hexsha": "f8a33de12956c729c7fb00a302f166a643eb6052", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "TOTBWF/agda-categories", "max_stars_repo_path": "src/Categories/Category/Dagger/Construction/Discrete.agda", "max_stars_repo_stars_event_max_datetime": "2021-04-18T18:21:47.000Z", "max_stars_repo_stars_event_min_datetime": "2021-04-18T18:21:47.000Z", "num_tokens": 192, "size": 619 }
{-# OPTIONS --without-K --safe #-} module Categories.Diagram.Colimit.Lan where open import Level open import Categories.Category open import Categories.Category.Cocomplete open import Categories.Diagram.Duality open import Categories.Diagram.Limit.Ran open import Categories.Functor open import Categories.Kan open import Categories.Kan.Duality private variable o ℓ e : Level C D E : Category o ℓ e module _ {o ℓ e o′ ℓ′ e′} {C : Category o′ ℓ′ e′} {D : Category o ℓ e} (F : Functor C D) (X : Functor C E) (Com : Cocomplete (o′ ⊔ ℓ) (ℓ′ ⊔ e) e′ E) where private module F = Functor F module X = Functor X colimit-is-lan : Lan F X colimit-is-lan = coRan⇒Lan (limit-is-ran F.op X.op λ G → Colimit⇒coLimit E (Com (Functor.op G)))
{ "alphanum_fraction": 0.6871727749, "avg_line_length": 28.2962962963, "ext": "agda", "hexsha": "dcbc27b23f2db53addda787c56f12ff98cde16bf", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Diagram/Colimit/Lan.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Diagram/Colimit/Lan.agda", "max_line_length": 98, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Diagram/Colimit/Lan.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 246, "size": 764 }
-- Possible improvements: -- * Most of the code below is not reachable from main. -- * The following primitives are not used at all: primPOr, primComp, -- primHComp, prim^glueU and prim^unglueU. {-# OPTIONS --erased-cubical #-} -- The code from Agda.Builtin.Cubical.Glue should not be compiled. open import Agda.Builtin.Cubical.Glue open import Agda.Builtin.Cubical.HCompU open import Agda.Builtin.Cubical.Id open import Agda.Builtin.Cubical.Path open import Agda.Builtin.Cubical.Sub open import Agda.Builtin.IO open import Agda.Builtin.Nat open import Agda.Builtin.String open import Agda.Builtin.Unit open import Agda.Primitive.Cubical open import Erased-cubical-Cubical postulate putStr : String → IO ⊤ {-# FOREIGN GHC import qualified Data.Text.IO #-} {-# COMPILE GHC putStr = Data.Text.IO.putStr #-} {-# COMPILE JS putStr = function (x) { return function(cb) { process.stdout.write(x); cb(0); }; } #-} i₁ : I i₁ = primIMax (primIMax (primINeg i0) i1) (primIMin i1 i0) i₁-1 : IsOne i₁ i₁-1 = IsOne1 (primIMax (primINeg i0) i1) (primIMin i1 i0) (IsOne2 (primINeg i0) i1 itIsOne) p₁ : Partial i1 Nat p₁ = λ _ → 12 p₂ : PartialP i1 (λ _ → Nat) p₂ = λ _ → 12 p₃ : PartialP i0 (λ _ → Nat) p₃ = isOneEmpty subst : ∀ {a p} {A : Set a} (P : A → Set p) (f : I → A) → P (f i0) → P (f i1) subst P eq p = primTransp (λ i → P (eq i)) i0 p p₄ : 12 ≡ 12 p₄ = λ _ → 12 n₁ : Nat n₁ = p₄ i0 s : Sub Nat i1 (λ _ → 13) s = inc 13 n₂ : Nat n₂ = primSubOut s i₂ : I i₂ = primFaceForall (λ _ → i1) i₃ : Id 12 12 i₃ = conid i0 p₄ i₄ : I i₄ = primDepIMin i1 (λ _ → i0) i₅ : I i₅ = primIdFace i₃ p₅ : 12 ≡ 12 p₅ = primIdPath i₃ n₃ : Nat n₃ = primIdJ (λ _ _ → Nat) 14 i₃ n₄ : Nat n₄ = primIdElim (λ _ _ → Nat) (λ _ _ _ → 14) i₃ Is-proposition : Set → Set Is-proposition A = (x y : A) → x ≡ y data ∥_∥ (A : Set) : Set where ∣_∣ : A → ∥ A ∥ @0 trivial : Is-proposition ∥ A ∥ rec : {A B : Set} → @0 Is-proposition B → (A → B) → ∥ A ∥ → B rec p f ∣ x ∣ = f x rec p f (trivial x y i) = p (rec p f x) (rec p f y) i main : IO ⊤ main = putStr (rec easy (λ where true → "Success\n" false → "Failure\n") ∣ true ∣) -- It should be possible to mention things that are not compiled in -- type signatures. u₁ : Not-compiled → ⊤ u₁ _ = tt @0 A : Set₁ A = Set u₂ : A → ⊤ u₂ _ = tt
{ "alphanum_fraction": 0.6103896104, "avg_line_length": 20.2288135593, "ext": "agda", "hexsha": "5a0386a30f1d44e653a4add3f4fad7518e1bd46d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-04-18T13:34:07.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Compiler/simple/Erased-cubical.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Compiler/simple/Erased-cubical.agda", "max_line_length": 69, "max_stars_count": null, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Compiler/simple/Erased-cubical.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 950, "size": 2387 }
{- This second-order signature was created from the following second-order syntax description: syntax Unit | U type 𝟙 : 0-ary term unit : 𝟙 theory (𝟙η) u : 𝟙 |> u = unit -} module Unit.Signature where open import SOAS.Context -- Type declaration data UT : Set where 𝟙 : UT open import SOAS.Syntax.Signature UT public open import SOAS.Syntax.Build UT public -- Operator symbols data Uₒ : Set where unitₒ : Uₒ -- Term signature U:Sig : Signature Uₒ U:Sig = sig λ { unitₒ → ⟼₀ 𝟙 } open Signature U:Sig public
{ "alphanum_fraction": 0.6934579439, "avg_line_length": 13.375, "ext": "agda", "hexsha": "9a24aee6ee405e2e043fc6c03b32bf0ad6fb3975", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "out/Unit/Signature.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "out/Unit/Signature.agda", "max_line_length": 91, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "out/Unit/Signature.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 181, "size": 535 }
module Numeric.Nat.Sqrt where open import Prelude hiding (_<?_) open import Numeric.Nat.Properties open import Tactic.Nat open import Numeric.Nat.BinarySearch data Sqrt (n : Nat) : Set where root : ∀ r → r ^ 2 ≤ n → n < suc r ^ 2 → Sqrt n getSqrt : ∀ {n} → Sqrt n → Nat getSqrt (root r _ _) = r private infix 4 _<?_ _<?_ : (a b : Nat) → Dec (a < b) a <? b with compare a b a <? b | less a<b = yes a<b a <? .a | equal refl = no (λ a<a → refute a<a) a <? b | greater a>b = no (λ a<b → less-antisym {A = Nat} a>b a<b) sqrt : (n : Nat) → Sqrt n sqrt 0 = root 0 (diff! 0) (diff! 0) -- just to avoid unfolding neutral application sqrt n with binarySearch 0 n (λ r → n <? r ^ 2) sqrt n | here k !n< n< _ _ = root k (less-raa (λ lt → !n< (by lt))) n< sqrt 0 | none _ = root 0 (diff! 0) (diff! 0) sqrt 1 | none _ = root 1 (diff! 0) (diff! 2) sqrt (suc (suc n)) | none !n<n² = ⊥-elim (!n<n² auto) sqrt n | below (diff _ ()) sqrt n | bad-range (diff _ ()) sqrt! : Nat → Nat sqrt! n = getSqrt (sqrt n) sqrt-below : ∀ n → sqrt! n ^ 2 ≤ n sqrt-below n with sqrt n ... | root _ lo _ = lo sqrt-above : ∀ n → suc (sqrt! n) ^ 2 > n sqrt-above n with sqrt n ... | root _ _ hi = hi
{ "alphanum_fraction": 0.5725062867, "avg_line_length": 27.7441860465, "ext": "agda", "hexsha": "337879a896849ead604cafdae73ffd0458ef7623", "lang": "Agda", "max_forks_count": 24, "max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z", "max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z", "max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "L-TChen/agda-prelude", "max_forks_repo_path": "src/Numeric/Nat/Sqrt.agda", "max_issues_count": 59, "max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z", "max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "L-TChen/agda-prelude", "max_issues_repo_path": "src/Numeric/Nat/Sqrt.agda", "max_line_length": 83, "max_stars_count": 111, "max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "L-TChen/agda-prelude", "max_stars_repo_path": "src/Numeric/Nat/Sqrt.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z", "num_tokens": 467, "size": 1193 }
module Issue561.Core where postulate Char : Set {-# BUILTIN CHAR Char #-} open import Agda.Builtin.IO public postulate return : ∀ {a} {A : Set a} → A → IO A {-# COMPILE GHC return = \_ _ -> return #-} {-# COMPILE UHC return = \_ _ x -> UHC.Agda.Builtins.primReturn x #-} {-# COMPILE JS return = function(u0) { return function(u1) { return function(x) { return function(cb) { cb(x); }; }; }; } #-}
{ "alphanum_fraction": 0.6161369193, "avg_line_length": 25.5625, "ext": "agda", "hexsha": "56c4208efd56d94f42b7a1e496e0a1b953627992", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2015-09-15T14:36:15.000Z", "max_forks_repo_forks_event_min_datetime": "2015-09-15T14:36:15.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Compiler/simple/Issue561/Core.agda", "max_issues_count": 3, "max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z", "max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "hborum/agda", "max_issues_repo_path": "test/Compiler/simple/Issue561/Core.agda", "max_line_length": 105, "max_stars_count": 2, "max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "hborum/agda", "max_stars_repo_path": "test/Compiler/simple/Issue561/Core.agda", "max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z", "max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z", "num_tokens": 122, "size": 409 }
{-# OPTIONS --no-termination-check #-} module Data.Bits where import Prelude import Logic.Base import Data.List as List import Data.Nat as Nat import Data.Bool as Bool open Prelude open Nat open Bool open List Bit = Bool shiftL : Nat -> Nat -> Nat shiftL n i = n * 2 ^ i sucBits : List Bit -> List Bit sucBits [] = true :: [] sucBits (false :: xs) = true :: xs sucBits (true :: xs) = false :: sucBits xs -- Least significant bit first. Last bit (when present) is always one. toBits : Nat -> List Bit toBits zero = [] toBits (suc n) = sucBits (odd n :: toBits (div n 2)) fromBits : List Bit -> Nat fromBits xs = foldr (\b n -> bitValue b + 2 * n) 0 xs where bitValue : Bit -> Nat bitValue b = if b then 1 else 0 nofBits : Nat -> Nat nofBits = length ∘ toBits module Proofs where open Logic.Base -- fromBits∘toBits=id : (n : Nat) -> fromBits (toBits n) ≡ n -- fromBits∘toBits=id zero = tt -- fromBits∘toBits=id (suc n) = ?
{ "alphanum_fraction": 0.6354273944, "avg_line_length": 20.2291666667, "ext": "agda", "hexsha": "78c540e2cee7068ff0f5517ac621fdd0f6641121", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "examples/lib/Data/Bits.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "examples/lib/Data/Bits.agda", "max_line_length": 70, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "examples/lib/Data/Bits.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 318, "size": 971 }
data A : Set where a : A data T : A → Set where t : T a postulate f : ∀ x → T x → Set stuff : Set stuff = f {!!} t -- There should not be a (Checked) status for this module!
{ "alphanum_fraction": 0.5760869565, "avg_line_length": 13.1428571429, "ext": "agda", "hexsha": "9229967475e351bcae406c740dadfdb9b8e923ea", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/interaction/Issue1036.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/interaction/Issue1036.agda", "max_line_length": 58, "max_stars_count": 1, "max_stars_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "masondesu/agda", "max_stars_repo_path": "test/interaction/Issue1036.agda", "max_stars_repo_stars_event_max_datetime": "2018-10-10T17:08:44.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-10T17:08:44.000Z", "num_tokens": 65, "size": 184 }
module Data.Tuple where data _×_ (A B : Set) : Set where <_,_> : A -> B -> A × B fst : {A B : Set} -> A × B -> A fst < x , y > = x snd : {A B : Set} -> A × B -> B snd < x , y > = y
{ "alphanum_fraction": 0.420212766, "avg_line_length": 14.4615384615, "ext": "agda", "hexsha": "d8be8cf2dc05b68f5dfc43f6d4ff8c8706c60146", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Tuple.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Tuple.agda", "max_line_length": 32, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "examples/outdated-and-incorrect/AIM6/Cat/lib/Data/Tuple.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 82, "size": 188 }
-- Basic intuitionistic modal logic S4, without ∨, ⊥, or ◇. -- Hilbert-style formalisation of syntax with context pairs. -- Nested terms. module BasicIS4.Syntax.DyadicHilbert where open import BasicIS4.Syntax.Common public -- Derivations. infix 3 _⊢_ data _⊢_ : Cx² Ty Ty → Ty → Set where var : ∀ {A Γ Δ} → A ∈ Γ → Γ ⁏ Δ ⊢ A app : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A ▻ B → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ B ci : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ A ▻ A ck : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A ▻ B ▻ A cs : ∀ {A B C Γ Δ} → Γ ⁏ Δ ⊢ (A ▻ B ▻ C) ▻ (A ▻ B) ▻ A ▻ C mvar : ∀ {A Γ Δ} → A ∈ Δ → Γ ⁏ Δ ⊢ A box : ∀ {A Γ Δ} → ∅ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ □ A cdist : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ (A ▻ B) ▻ □ A ▻ □ B cup : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ □ A ▻ □ □ A cdown : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ □ A ▻ A cpair : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A ▻ B ▻ A ∧ B cfst : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A ∧ B ▻ A csnd : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A ∧ B ▻ B unit : ∀ {Γ Δ} → Γ ⁏ Δ ⊢ ⊤ infix 3 _⊢⋆_ _⊢⋆_ : Cx² Ty Ty → Cx Ty → Set Γ ⁏ Δ ⊢⋆ ∅ = 𝟙 Γ ⁏ Δ ⊢⋆ Ξ , A = Γ ⁏ Δ ⊢⋆ Ξ × Γ ⁏ Δ ⊢ A -- Monotonicity with respect to context inclusion. mono⊢ : ∀ {A Γ Γ′ Δ} → Γ ⊆ Γ′ → Γ ⁏ Δ ⊢ A → Γ′ ⁏ Δ ⊢ A mono⊢ η (var i) = var (mono∈ η i) mono⊢ η (app t u) = app (mono⊢ η t) (mono⊢ η u) mono⊢ η ci = ci mono⊢ η ck = ck mono⊢ η cs = cs mono⊢ η (mvar i) = mvar i mono⊢ η (box t) = box t mono⊢ η cdist = cdist mono⊢ η cup = cup mono⊢ η cdown = cdown mono⊢ η cpair = cpair mono⊢ η cfst = cfst mono⊢ η csnd = csnd mono⊢ η unit = unit mono⊢⋆ : ∀ {Ξ Γ Γ′ Δ} → Γ ⊆ Γ′ → Γ ⁏ Δ ⊢⋆ Ξ → Γ′ ⁏ Δ ⊢⋆ Ξ mono⊢⋆ {∅} η ∙ = ∙ mono⊢⋆ {Ξ , A} η (ts , t) = mono⊢⋆ η ts , mono⊢ η t -- Monotonicity with respect to modal context inclusion. mmono⊢ : ∀ {A Γ Δ Δ′} → Δ ⊆ Δ′ → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ′ ⊢ A mmono⊢ θ (var i) = var i mmono⊢ θ (app t u) = app (mmono⊢ θ t) (mmono⊢ θ u) mmono⊢ θ ci = ci mmono⊢ θ ck = ck mmono⊢ θ cs = cs mmono⊢ θ (mvar i) = mvar (mono∈ θ i) mmono⊢ θ (box t) = box (mmono⊢ θ t) mmono⊢ θ cdist = cdist mmono⊢ θ cup = cup mmono⊢ θ cdown = cdown mmono⊢ θ cpair = cpair mmono⊢ θ cfst = cfst mmono⊢ θ csnd = csnd mmono⊢ θ unit = unit mmono⊢⋆ : ∀ {Ξ Γ Δ Δ′} → Δ ⊆ Δ′ → Γ ⁏ Δ ⊢⋆ Ξ → Γ ⁏ Δ′ ⊢⋆ Ξ mmono⊢⋆ {∅} θ ∙ = ∙ mmono⊢⋆ {Ξ , A} θ (ts , t) = mmono⊢⋆ θ ts , mmono⊢ θ t -- Monotonicity using context pairs. mono²⊢ : ∀ {A Π Π′} → Π ⊆² Π′ → Π ⊢ A → Π′ ⊢ A mono²⊢ (η , θ) = mono⊢ η ∘ mmono⊢ θ -- Shorthand for variables. v₀ : ∀ {A Γ Δ} → Γ , A ⁏ Δ ⊢ A v₀ = var i₀ v₁ : ∀ {A B Γ Δ} → Γ , A , B ⁏ Δ ⊢ A v₁ = var i₁ v₂ : ∀ {A B C Γ Δ} → Γ , A , B , C ⁏ Δ ⊢ A v₂ = var i₂ mv₀ : ∀ {A Γ Δ} → Γ ⁏ Δ , A ⊢ A mv₀ = mvar i₀ mv₁ : ∀ {A B Γ Δ} → Γ ⁏ Δ , A , B ⊢ A mv₁ = mvar i₁ mv₂ : ∀ {A B C Γ Δ} → Γ ⁏ Δ , A , B , C ⊢ A mv₂ = mvar i₂ -- Reflexivity. refl⊢⋆ : ∀ {Γ Δ} → Γ ⁏ Δ ⊢⋆ Γ refl⊢⋆ {∅} = ∙ refl⊢⋆ {Γ , A} = mono⊢⋆ weak⊆ refl⊢⋆ , v₀ mrefl⊢⋆ : ∀ {Δ Γ} → Γ ⁏ Δ ⊢⋆ □⋆ Δ mrefl⊢⋆ {∅} = ∙ mrefl⊢⋆ {Δ , A} = mmono⊢⋆ weak⊆ mrefl⊢⋆ , box mv₀ -- Deduction theorem. lam : ∀ {A B Γ Δ} → Γ , A ⁏ Δ ⊢ B → Γ ⁏ Δ ⊢ A ▻ B lam (var top) = ci lam (var (pop i)) = app ck (var i) lam (app t u) = app (app cs (lam t)) (lam u) lam ci = app ck ci lam ck = app ck ck lam cs = app ck cs lam (mvar i) = app ck (mvar i) lam (box t) = app ck (box t) lam cdist = app ck cdist lam cup = app ck cup lam cdown = app ck cdown lam cpair = app ck cpair lam cfst = app ck cfst lam csnd = app ck csnd lam unit = app ck unit lam⋆ : ∀ {Ξ A Γ Δ} → Γ ⧺ Ξ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ Ξ ▻⋯▻ A lam⋆ {∅} = I lam⋆ {Ξ , B} = lam⋆ {Ξ} ∘ lam lam⋆₀ : ∀ {Γ A Δ} → Γ ⁏ Δ ⊢ A → ∅ ⁏ Δ ⊢ Γ ▻⋯▻ A lam⋆₀ {∅} = I lam⋆₀ {Γ , B} = lam⋆₀ ∘ lam -- Combined axioms of distribution and transitivity. cdistup : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ (□ A ▻ B) ▻ □ A ▻ □ B cdistup = app (app cs (app (app cs (app ck cs)) (app (app cs (app (app cs (app ck cs)) (lam (lam cdist)))) (app (app cs (app ck ck)) ci)))) (app (app cs (app (app cs (app ck cs)) (lam (lam cup)))) (app ck ci)) -- Modal deduction theorem. mlam : ∀ {A B Γ Δ} → Γ ⁏ Δ , A ⊢ B → Γ ⁏ Δ ⊢ □ A ▻ B mlam (var i) = app ck (var i) mlam (app t u) = app (app cs (mlam t)) (mlam u) mlam ci = app ck ci mlam ck = app ck ck mlam cs = app ck cs mlam (mvar top) = cdown mlam (mvar (pop i)) = app ck (mvar i) mlam (box t) = app cdistup (box (mlam t)) mlam cdist = app ck cdist mlam cup = app ck cup mlam cdown = app ck cdown mlam cpair = app ck cpair mlam cfst = app ck cfst mlam csnd = app ck csnd mlam unit = app ck unit mlam⋆ : ∀ {Ξ A Γ Δ} → Γ ⁏ Δ ⧺ Ξ ⊢ A → Γ ⁏ Δ ⊢ □⋆ Ξ ▻⋯▻ A mlam⋆ {∅} = I mlam⋆ {Ξ , B} = mlam⋆ {Ξ} ∘ mlam mlam⋆₀ : ∀ {Δ A Γ} → Γ ⁏ Δ ⊢ A → Γ ⁏ ∅ ⊢ □⋆ Δ ▻⋯▻ A mlam⋆₀ {∅} = I mlam⋆₀ {Δ , B} = mlam⋆₀ ∘ mlam -- Detachment theorems. det : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A ▻ B → Γ , A ⁏ Δ ⊢ B det t = app (mono⊢ weak⊆ t) v₀ det⋆ : ∀ {Ξ A Γ Δ} → Γ ⁏ Δ ⊢ Ξ ▻⋯▻ A → Γ ⧺ Ξ ⁏ Δ ⊢ A det⋆ {∅} = I det⋆ {Ξ , B} = det ∘ det⋆ {Ξ} det⋆₀ : ∀ {Γ A Δ} → ∅ ⁏ Δ ⊢ Γ ▻⋯▻ A → Γ ⁏ Δ ⊢ A det⋆₀ {∅} = I det⋆₀ {Γ , B} = det ∘ det⋆₀ mdet : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ A ▻ B → Γ ⁏ Δ , A ⊢ B mdet t = app (mmono⊢ weak⊆ t) (box mv₀) mdet⋆ : ∀ {Ξ A Γ Δ} → Γ ⁏ Δ ⊢ □⋆ Ξ ▻⋯▻ A → Γ ⁏ Δ ⧺ Ξ ⊢ A mdet⋆ {∅} = I mdet⋆ {Ξ , B} = mdet ∘ mdet⋆ {Ξ} mdet⋆₀ : ∀ {Δ A Γ} → Γ ⁏ ∅ ⊢ □⋆ Δ ▻⋯▻ A → Γ ⁏ Δ ⊢ A mdet⋆₀ {∅} = I mdet⋆₀ {Δ , B} = mdet ∘ mdet⋆₀ -- Context manipulation. merge : ∀ {Δ A Γ} → Γ ⁏ Δ ⊢ A → Γ ⧺ (□⋆ Δ) ⁏ ∅ ⊢ A merge {Δ} = det⋆ {□⋆ Δ} ∘ mlam⋆₀ mmerge : ∀ {Γ A Δ} → □⋆ Γ ⁏ Δ ⊢ A → ∅ ⁏ Δ ⧺ Γ ⊢ A mmerge {Γ} = mdet⋆ {Γ} ∘ lam⋆₀ split : ∀ {Δ A Γ} → Γ ⧺ (□⋆ Δ) ⁏ ∅ ⊢ A → Γ ⁏ Δ ⊢ A split {Δ} = mdet⋆₀ ∘ lam⋆ {□⋆ Δ} msplit : ∀ {Γ A Δ} → ∅ ⁏ Δ ⧺ Γ ⊢ A → □⋆ Γ ⁏ Δ ⊢ A msplit {Γ} = det⋆₀ ∘ mlam⋆ {Γ} merge⋆ : ∀ {Ξ Δ Γ} → Γ ⁏ Δ ⊢⋆ Ξ → Γ ⧺ (□⋆ Δ) ⁏ ∅ ⊢⋆ Ξ merge⋆ {∅} ∙ = ∙ merge⋆ {Ξ , A} (ts , t) = merge⋆ ts , merge t split⋆ : ∀ {Ξ Δ Γ} → Γ ⧺ (□⋆ Δ) ⁏ ∅ ⊢⋆ Ξ → Γ ⁏ Δ ⊢⋆ Ξ split⋆ {∅} ∙ = ∙ split⋆ {Ξ , A} (ts , t) = split⋆ ts , split t -- Cut and multicut. cut : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A → Γ , A ⁏ Δ ⊢ B → Γ ⁏ Δ ⊢ B cut t u = app (lam u) t mcut : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ A → Γ ⁏ Δ , A ⊢ B → Γ ⁏ Δ ⊢ B mcut t u = app (mlam u) t multicut : ∀ {Ξ A Γ Δ} → Γ ⁏ Δ ⊢⋆ Ξ → Ξ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ A multicut {∅} ∙ u = mono⊢ bot⊆ u multicut {Ξ , B} (ts , t) u = app (multicut ts (lam u)) t mmulticut : ∀ {Ξ A Γ Δ} → Γ ⁏ Δ ⊢⋆ □⋆ Ξ → Γ ⁏ Ξ ⊢ A → Γ ⁏ Δ ⊢ A mmulticut {∅} ∙ u = mmono⊢ bot⊆ u mmulticut {Ξ , B} (ts , t) u = app (mmulticut ts (mlam u)) t -- Transitivity. trans⊢⋆₀ : ∀ {Γ″ Γ′ Γ} → Γ ⁏ ∅ ⊢⋆ Γ′ → Γ′ ⁏ ∅ ⊢⋆ Γ″ → Γ ⁏ ∅ ⊢⋆ Γ″ trans⊢⋆₀ {∅} ts ∙ = ∙ trans⊢⋆₀ {Γ″ , A} ts (us , u) = trans⊢⋆₀ ts us , multicut ts u trans⊢⋆ : ∀ {Ξ Γ Γ′ Δ Δ′} → Γ ⁏ Δ ⊢⋆ Γ′ ⧺ (□⋆ Δ′) → Γ′ ⁏ Δ′ ⊢⋆ Ξ → Γ ⁏ Δ ⊢⋆ Ξ trans⊢⋆ ts us = split⋆ (trans⊢⋆₀ (merge⋆ ts) (merge⋆ us)) -- Contraction. ccont : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ (A ▻ A ▻ B) ▻ A ▻ B ccont = lam (lam (app (app v₁ v₀) v₀)) cont : ∀ {A B Γ Δ} → Γ , A , A ⁏ Δ ⊢ B → Γ , A ⁏ Δ ⊢ B cont t = det (app ccont (lam (lam t))) mcont : ∀ {A B Γ Δ} → Γ ⁏ Δ , A , A ⊢ B → Γ ⁏ Δ , A ⊢ B mcont t = mdet (app ccont (mlam (mlam t))) -- Exchange, or Schönfinkel’s C combinator. cexch : ∀ {A B C Γ Δ} → Γ ⁏ Δ ⊢ (A ▻ B ▻ C) ▻ B ▻ A ▻ C cexch = lam (lam (lam (app (app v₂ v₀) v₁))) exch : ∀ {A B C Γ Δ} → Γ , A , B ⁏ Δ ⊢ C → Γ , B , A ⁏ Δ ⊢ C exch t = det (det (app cexch (lam (lam t)))) mexch : ∀ {A B C Γ Δ} → Γ ⁏ Δ , A , B ⊢ C → Γ ⁏ Δ , B , A ⊢ C mexch t = mdet (mdet (app cexch (mlam (mlam t)))) -- Composition, or Schönfinkel’s B combinator. ccomp : ∀ {A B C Γ Δ} → Γ ⁏ Δ ⊢ (B ▻ C) ▻ (A ▻ B) ▻ A ▻ C ccomp = lam (lam (lam (app v₂ (app v₁ v₀)))) comp : ∀ {A B C Γ Δ} → Γ , B ⁏ Δ ⊢ C → Γ , A ⁏ Δ ⊢ B → Γ , A ⁏ Δ ⊢ C comp t u = det (app (app ccomp (lam t)) (lam u)) mcomp : ∀ {A B C Γ Δ} → Γ ⁏ Δ , B ⊢ □ C → Γ ⁏ Δ , A ⊢ □ B → Γ ⁏ Δ , A ⊢ □ C mcomp t u = mdet (app (app ccomp (mlam t)) (mlam u)) -- Useful theorems in functional form. dist : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ (A ▻ B) → Γ ⁏ Δ ⊢ □ A → Γ ⁏ Δ ⊢ □ B dist t u = app (app cdist t) u up : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ □ A → Γ ⁏ Δ ⊢ □ □ A up t = app cup t down : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ □ A → Γ ⁏ Δ ⊢ A down t = app cdown t distup : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ (□ A ▻ B) → Γ ⁏ Δ ⊢ □ A → Γ ⁏ Δ ⊢ □ B distup t u = dist t (up u) unbox : ∀ {A C Γ Δ} → Γ ⁏ Δ ⊢ □ A → Γ ⁏ Δ , A ⊢ C → Γ ⁏ Δ ⊢ C unbox t u = app (mlam u) t pair : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ B → Γ ⁏ Δ ⊢ A ∧ B pair t u = app (app cpair t) u fst : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A ∧ B → Γ ⁏ Δ ⊢ A fst t = app cfst t snd : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A ∧ B → Γ ⁏ Δ ⊢ B snd t = app csnd t -- Internalisation, or lifting, and additional theorems. lift : ∀ {Γ A Δ} → Γ ⁏ Δ ⊢ A → □⋆ Γ ⁏ Δ ⊢ □ A lift {∅} t = box t lift {Γ , B} t = det (app cdist (lift (lam t))) hypup : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A ▻ B → Γ ⁏ Δ ⊢ □ A ▻ B hypup t = lam (app (mono⊢ weak⊆ t) (down v₀)) hypdown : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ □ A ▻ B → Γ ⁏ Δ ⊢ □ A ▻ B hypdown t = lam (app (mono⊢ weak⊆ t) (up v₀)) cxup : ∀ {Γ A Δ} → Γ ⁏ Δ ⊢ A → □⋆ Γ ⁏ Δ ⊢ A cxup {∅} t = t cxup {Γ , B} t = det (hypup (cxup (lam t))) cxdown : ∀ {Γ A Δ} → □⋆ □⋆ Γ ⁏ Δ ⊢ A → □⋆ Γ ⁏ Δ ⊢ A cxdown {∅} t = t cxdown {Γ , B} t = det (hypdown (cxdown (lam t))) box⋆ : ∀ {Ξ Γ Δ} → ∅ ⁏ Δ ⊢⋆ Ξ → Γ ⁏ Δ ⊢⋆ □⋆ Ξ box⋆ {∅} ∙ = ∙ box⋆ {Ξ , A} (ts , t) = box⋆ ts , box t lift⋆ : ∀ {Ξ Γ Δ} → Γ ⁏ Δ ⊢⋆ Ξ → □⋆ Γ ⁏ Δ ⊢⋆ □⋆ Ξ lift⋆ {∅} ∙ = ∙ lift⋆ {Ξ , A} (ts , t) = lift⋆ ts , lift t up⋆ : ∀ {Ξ Γ Δ} → Γ ⁏ Δ ⊢⋆ □⋆ Ξ → Γ ⁏ Δ ⊢⋆ □⋆ □⋆ Ξ up⋆ {∅} ∙ = ∙ up⋆ {Ξ , A} (ts , t) = up⋆ ts , up t down⋆ : ∀ {Ξ Γ Δ} → Γ ⁏ Δ ⊢⋆ □⋆ Ξ → Γ ⁏ Δ ⊢⋆ Ξ down⋆ {∅} ∙ = ∙ down⋆ {Ξ , A} (ts , t) = down⋆ ts , down t multibox : ∀ {Ξ A Γ Δ} → Γ ⁏ Δ ⊢⋆ □⋆ Ξ → □⋆ Ξ ⁏ ∅ ⊢ A → Γ ⁏ Δ ⊢ □ A multibox ts u = multicut (up⋆ ts) (mmono⊢ bot⊆ (lift u)) dist′ : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ (A ▻ B) → Γ ⁏ Δ ⊢ □ A ▻ □ B dist′ t = lam (dist (mono⊢ weak⊆ t) v₀) mpair : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ A → Γ ⁏ Δ ⊢ □ B → Γ ⁏ Δ ⊢ □ (A ∧ B) mpair t u = dist (dist (box cpair) t) u mfst : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ (A ∧ B) → Γ ⁏ Δ ⊢ □ A mfst t = dist (box cfst) t msnd : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ □ (A ∧ B) → Γ ⁏ Δ ⊢ □ B msnd t = dist (box csnd) t -- Closure under context concatenation. concat : ∀ {A B Γ} Γ′ {Δ} → Γ , A ⁏ Δ ⊢ B → Γ′ ⁏ Δ ⊢ A → Γ ⧺ Γ′ ⁏ Δ ⊢ B concat Γ′ t u = app (mono⊢ (weak⊆⧺₁ Γ′) (lam t)) (mono⊢ weak⊆⧺₂ u) mconcat : ∀ {A B Γ Δ} Δ′ → Γ ⁏ Δ , A ⊢ B → Γ ⁏ Δ′ ⊢ □ A → Γ ⁏ Δ ⧺ Δ′ ⊢ B mconcat Δ′ t u = app (mmono⊢ (weak⊆⧺₁ Δ′) (mlam t)) (mmono⊢ weak⊆⧺₂ u) -- Convertibility. data _⋙_ {Γ Δ : Cx Ty} : ∀ {A} → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ A → Set where refl⋙ : ∀ {A} → {t : Γ ⁏ Δ ⊢ A} → t ⋙ t trans⋙ : ∀ {A} → {t t′ t″ : Γ ⁏ Δ ⊢ A} → t ⋙ t′ → t′ ⋙ t″ → t ⋙ t″ sym⋙ : ∀ {A} → {t t′ : Γ ⁏ Δ ⊢ A} → t ⋙ t′ → t′ ⋙ t congapp⋙ : ∀ {A B} → {t t′ : Γ ⁏ Δ ⊢ A ▻ B} → {u u′ : Γ ⁏ Δ ⊢ A} → t ⋙ t′ → u ⋙ u′ → app t u ⋙ app t′ u′ congi⋙ : ∀ {A} → {t t′ : Γ ⁏ Δ ⊢ A} → t ⋙ t′ → app ci t ⋙ app ci t′ congk⋙ : ∀ {A B} → {t t′ : Γ ⁏ Δ ⊢ A} → {u u′ : Γ ⁏ Δ ⊢ B} → t ⋙ t′ → u ⋙ u′ → app (app ck t) u ⋙ app (app ck t′) u′ congs⋙ : ∀ {A B C} → {t t′ : Γ ⁏ Δ ⊢ A ▻ B ▻ C} → {u u′ : Γ ⁏ Δ ⊢ A ▻ B} → {v v′ : Γ ⁏ Δ ⊢ A} → t ⋙ t′ → u ⋙ u′ → v ⋙ v′ -- NOTE: Rejected by Pfenning and Davies. -- congbox⋙ : ∀ {A} → {t t′ : ∅ ⁏ Δ ⊢ A} -- → t ⋙ t′ -- → box {Γ} t ⋙ box {Γ} t′ congdist⋙ : ∀ {A B} → {t t′ : Γ ⁏ Δ ⊢ □ (A ▻ B)} → {u u′ : Γ ⁏ Δ ⊢ □ A} → t ⋙ t′ → u ⋙ u′ → app (app cdist t) u ⋙ app (app cdist t′) u′ congup⋙ : ∀ {A} → {t t′ : Γ ⁏ Δ ⊢ □ A} → t ⋙ t′ → app cup t ⋙ app cup t′ congdown⋙ : ∀ {A} → {t t′ : Γ ⁏ Δ ⊢ □ A} → t ⋙ t′ → app cdown t ⋙ app cdown t′ congpair⋙ : ∀ {A B} → {t t′ : Γ ⁏ Δ ⊢ A} → {u u′ : Γ ⁏ Δ ⊢ B} → t ⋙ t′ → u ⋙ u′ → app (app cpair t) u ⋙ app (app cpair t′) u′ congfst⋙ : ∀ {A B} → {t t′ : Γ ⁏ Δ ⊢ A ∧ B} → t ⋙ t′ → app cfst t ⋙ app cfst t′ congsnd⋙ : ∀ {A B} → {t t′ : Γ ⁏ Δ ⊢ A ∧ B} → t ⋙ t′ → app csnd t ⋙ app csnd t′ -- TODO: Verify this. beta▻ₖ⋙ : ∀ {A B} → {t : Γ ⁏ Δ ⊢ A} → {u : Γ ⁏ Δ ⊢ B} → app (app ck t) u ⋙ t -- TODO: Verify this. beta▻ₛ⋙ : ∀ {A B C} → {t : Γ ⁏ Δ ⊢ A ▻ B ▻ C} → {u : Γ ⁏ Δ ⊢ A ▻ B} → {v : Γ ⁏ Δ ⊢ A} → app (app (app cs t) u) v ⋙ app (app t v) (app u v) -- TODO: What about eta for ▻? What about beta, eta, and commuting conversions for □? beta∧₁⋙ : ∀ {A B} → {t : Γ ⁏ Δ ⊢ A} → {u : Γ ⁏ Δ ⊢ B} → app cfst (app (app cpair t) u) ⋙ t beta∧₂⋙ : ∀ {A B} → {t : Γ ⁏ Δ ⊢ A} → {u : Γ ⁏ Δ ⊢ B} → app csnd (app (app cpair t) u) ⋙ u eta∧⋙ : ∀ {A B} → {t : Γ ⁏ Δ ⊢ A ∧ B} → t ⋙ app (app cpair (app cfst t)) (app csnd t) eta⊤⋙ : ∀ {t : Γ ⁏ Δ ⊢ ⊤} → t ⋙ unit
{ "alphanum_fraction": 0.3898713826, "avg_line_length": 29.4913793103, "ext": "agda", "hexsha": "ea4ab7f3d38ff72b69c5f02047335c9b20858edc", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/hilbert-gentzen", "max_forks_repo_path": "BasicIS4/Syntax/DyadicHilbert.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/hilbert-gentzen", "max_issues_repo_path": "BasicIS4/Syntax/DyadicHilbert.agda", "max_line_length": 98, "max_stars_count": 29, "max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/hilbert-gentzen", "max_stars_repo_path": "BasicIS4/Syntax/DyadicHilbert.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z", "num_tokens": 7428, "size": 13684 }
{-# OPTIONS --safe --without-K #-} open import Relation.Binary module Data.List.Membership.Setoid.Disjoint {a p} (S : Setoid a p) where open Setoid S renaming (Carrier to A) open import Data.List using (List ; []) open import Data.List.Membership.Setoid (S) open import Data.List.Membership.Setoid.Trans (S) open import Data.Empty open import Function Disjoint : Rel (List A) _ Disjoint xs ys = ∀ {x} → x ∈ xs → x ∈ ys → ⊥ disjoint-sym : Symmetric Disjoint disjoint-sym dis = flip dis disjoint-[]ˡ : ∀ {xs} → Disjoint xs [] disjoint-[]ˡ _ () disjoint-[]ʳ : ∀ {xs} → Disjoint [] xs disjoint-[]ʳ () disjointness : ∀ {xs ys} → Disjoint xs ys → ∀ {x} → x ∈ xs → ∀ {y} → y ∈ ys → x ≈ y → ⊥ disjointness xs⋈ys x∈xs y∈ys x≈y = xs⋈ys x∈xs (≈-trans-∈ x≈y y∈ys)
{ "alphanum_fraction": 0.6413612565, "avg_line_length": 26.3448275862, "ext": "agda", "hexsha": "0ab83deeeb5ed638f202aa5b66b205b50250fdf4", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "d4cd2a3442a9b58e6139499d16a2b31268f27f80", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "tizmd/agda-distinct-disjoint", "max_forks_repo_path": "src/Data/List/Membership/Setoid/Disjoint.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "d4cd2a3442a9b58e6139499d16a2b31268f27f80", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "tizmd/agda-distinct-disjoint", "max_issues_repo_path": "src/Data/List/Membership/Setoid/Disjoint.agda", "max_line_length": 87, "max_stars_count": null, "max_stars_repo_head_hexsha": "d4cd2a3442a9b58e6139499d16a2b31268f27f80", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "tizmd/agda-distinct-disjoint", "max_stars_repo_path": "src/Data/List/Membership/Setoid/Disjoint.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 273, "size": 764 }
module Monads.Except where open import Class.Monad open import Class.Monad.Except open import Monads.ExceptT open import Monads.Identity open import Level private variable a : Level A : Set a Except : Set a -> Set a -> Set a Except = ExceptT Id instance Except-Monad : Monad (Except A) Except-Monad = ExceptT-Monad Except-MonadExcept : MonadExcept (Except A) A Except-MonadExcept = ExceptT-MonadExcept
{ "alphanum_fraction": 0.7411764706, "avg_line_length": 18.4782608696, "ext": "agda", "hexsha": "3b764bfd5b3d0fffbb8d24c59cac6d4a924964b6", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_path": "stdlib-exts/Monads/Except.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_path": "stdlib-exts/Monads/Except.agda", "max_line_length": 47, "max_stars_count": 35, "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_path": "stdlib-exts/Monads/Except.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "num_tokens": 124, "size": 425 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT open import groups.SumOfSubIndicator open import cohomology.Theory {- It should be possible to prove lemmas for arbitrary universe levels, but this file is only used for [FinSkeleton], which is in the zeroth universe. -} module cohomology.SubFinWedge (CT : CohomologyTheory lzero) (n : ℤ) where open CohomologyTheory CT {- [B-ac] and [B-dec] can actually be proved from [subfin], but maybe the user wants to supply a different [B-ac]. Another good question is why the focus is on [B], not [A]. Well, check the definition of [MinusPoint] and you will see why. -} module _ {I} {A B : Type₀} (p : Fin I → Coprod A B) (X : Ptd₀) where C-subfinite-additive : C n (⊙BigWedge (λ (_ : B) → X)) →ᴳ Πᴳ B (λ _ → C n X) C-subfinite-additive = C-additive n (λ (_ : B) → X) CEl-subfinite-additive : CEl n (⊙BigWedge (λ (_ : B) → X)) → Π B (λ _ → CEl n X) CEl-subfinite-additive = GroupHom.f C-subfinite-additive C-subfinite-additive-is-equiv : has-choice 0 B lzero → is-equiv CEl-subfinite-additive C-subfinite-additive-is-equiv = C-additive-is-equiv n (λ _ → X) C-subfinite-additive-iso : has-choice 0 B lzero → C n (⊙BigWedge (λ (_ : B) → X)) ≃ᴳ Πᴳ B (λ _ → C n X) C-subfinite-additive-iso = C-additive-iso n (λ (_ : B) → X) {- an explicit inverse function -} explicit-inverse-C-subfinite-additive : has-dec-eq B → Π B (λ _ → CEl n X) → CEl n (⊙BigWedge (λ (_ : B) → X)) explicit-inverse-C-subfinite-additive B-dec f = Group.subsum-r (C n (⊙BigWedge (λ _ → X))) p (λ b → CEl-fmap n (⊙bwproj B-dec b) (f b)) module _ where {- this part is to prove the explicit inverse function is correct -} abstract private C-bwproj-bwin-≠ : {B : Type₀} (B-dec : has-dec-eq B) {X : Ptd₀} {b b' : B} (neq : b ≠ b') (g : CEl n X) → CEl-fmap n (⊙bwproj B-dec b ⊙∘ ⊙bwin {X = λ _ → X} b') g == Cident n X C-bwproj-bwin-≠ B-dec neq g = CEl-fmap-base-indep n (bwproj-bwin-≠ B-dec neq) g ∙ C-fmap-cst n g C-bwproj-bwin-diag : {B : Type₀} (B-dec : has-dec-eq B) {X : Ptd₀} (b : B) (g : CEl n X) → CEl-fmap n (⊙bwproj B-dec b ⊙∘ ⊙bwin {X = λ _ → X} b) g == g C-bwproj-bwin-diag B-dec b g = CEl-fmap-base-indep n (bwproj-bwin-diag B-dec b) g ∙ C-fmap-idf n g inverse-C-subfinite-additive-β' : ∀ {A B : Type₀} (B-dec : has-dec-eq B) {I} (p : Fin I ≃ Coprod A B) {X : Ptd₀} → ∀ f → GroupHom.f (C-subfinite-additive (–> p) X) (explicit-inverse-C-subfinite-additive (–> p) X B-dec f) ∼ f inverse-C-subfinite-additive-β' B-dec p {X} f b* = CEl-fmap n (⊙bwin b*) (Group.subsum-r (C n (⊙BigWedge (λ _ → X))) (–> p) (λ b → CEl-fmap n (⊙bwproj B-dec b) (f b))) =⟨ GroupHom.pres-subsum-r (C-fmap n (⊙bwin b*)) (–> p) (λ b → CEl-fmap n (⊙bwproj B-dec b) (f b)) ⟩ Group.subsum-r (C n X) (–> p) (λ b → CEl-fmap n (⊙bwin b*) (CEl-fmap n (⊙bwproj B-dec b) (f b))) =⟨ ap (Group.subsum-r (C n X) (–> p)) (λ= λ b → ∘-CEl-fmap n (⊙bwin b*) (⊙bwproj B-dec b) (f b)) ⟩ Group.subsum-r (C n X) (–> p) (λ b → CEl-fmap n (⊙bwproj B-dec b ⊙∘ ⊙bwin b*) (f b)) =⟨ subsum-r-subindicator (C n X) p (λ b → CEl-fmap n (⊙bwproj B-dec b ⊙∘ ⊙bwin b*) (f b)) b* (λ b≠b* → C-bwproj-bwin-≠ B-dec b≠b* _) ⟩ CEl-fmap n (⊙bwproj B-dec b* ⊙∘ ⊙bwin b*) (f b*) =⟨ C-bwproj-bwin-diag B-dec b* (f b*) ⟩ f b* =∎ inverse-C-subfinite-additive-β : ∀ {A B : Type₀} (B-ac : has-choice 0 B lzero) (B-dec : has-dec-eq B) {I} (p : Fin I ≃ Coprod A B) {X : Ptd₀} → is-equiv.g (C-subfinite-additive-is-equiv (–> p) X B-ac) ∼ explicit-inverse-C-subfinite-additive (–> p) X B-dec inverse-C-subfinite-additive-β B-ac B-dec p {X} f = ! $ equiv-adj (GroupIso.f-equiv (C-subfinite-additive-iso (–> p) X B-ac)) $ λ= $ inverse-C-subfinite-additive-β' B-dec p f module _ (I : ℕ) (X : Ptd₀) where C-finite-additive : C n (⊙BigWedge (λ (_ : Fin I) → X)) →ᴳ Πᴳ (Fin I) (λ _ → C n X) C-finite-additive = C-subfinite-additive {A = Empty} inr X CEl-finite-additive : CEl n (⊙BigWedge (λ (_ : Fin I) → X)) → Π (Fin I) (λ _ → CEl n X) CEl-finite-additive = GroupHom.f C-finite-additive C-finite-additive-is-equiv : is-equiv CEl-finite-additive C-finite-additive-is-equiv = C-subfinite-additive-is-equiv {A = Empty} inr X (Fin-has-choice 0 lzero) C-finite-additive-iso : C n (⊙BigWedge (λ (_ : Fin I) → X)) ≃ᴳ Πᴳ (Fin I) (λ _ → C n X) C-finite-additive-iso = C-subfinite-additive-iso {A = Empty} inr X (Fin-has-choice 0 lzero) {- an explicit inverse function -} explicit-inverse-C-finite-additive : Π (Fin I) (λ _ → CEl n X) → CEl n (⊙BigWedge (λ (_ : Fin I) → X)) explicit-inverse-C-finite-additive = explicit-inverse-C-subfinite-additive {A = Empty} inr X Fin-has-dec-eq module _ where abstract inverse-C-finite-additive-β : ∀ {I : ℕ} {X : Ptd₀} → is-equiv.g (C-finite-additive-is-equiv I X) ∼ explicit-inverse-C-finite-additive I X inverse-C-finite-additive-β {I} {X} = inverse-C-subfinite-additive-β {A = Empty} {B = Fin I} (Fin-has-choice 0 lzero) Fin-has-dec-eq (⊔₁-Empty (Fin I) ⁻¹) {X}
{ "alphanum_fraction": 0.5892822967, "avg_line_length": 47.0720720721, "ext": "agda", "hexsha": "b638cc904e66e7013e44d4f19f257bb3b6c01aff", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "timjb/HoTT-Agda", "max_forks_repo_path": "theorems/cohomology/SubFinWedge.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "timjb/HoTT-Agda", "max_issues_repo_path": "theorems/cohomology/SubFinWedge.agda", "max_line_length": 124, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "theorems/cohomology/SubFinWedge.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 2092, "size": 5225 }
module hierarchy where data Bool : Set where true : Bool false : Bool _and_ : Bool → Bool → Bool true and true = true true and false = false false and true = false false and false = false _or_ : Bool → Bool → Bool true or true = true true or false = true false or true = true false or false = false data ℕ : Set where zero : ℕ suc : ℕ → ℕ _==_ : ℕ → ℕ → Bool zero == zero = true suc n == suc m = n == m _ == _ = false data List (A : Set) : Set where [] : List A _::_ : A → List A → List A _∈_ : ℕ → List ℕ → Bool x ∈ [] = false x ∈ (y :: ys) with x == y ... | true = true ... | false = x ∈ ys _⊂_ : List ℕ → List ℕ → Bool [] ⊂ ys = true (x :: xs) ⊂ ys with x ∈ ys ... | true = xs ⊂ ys ... | false = false _++_ : {A : Set} → List A → List A → List A [] ++ ys = ys (x :: xs) ++ ys = x :: (xs ++ ys) map : {A : Set} → (A → A) → List A → List A map f [] = [] map f (x :: xs) = (f x) :: (map f xs) any : {A : Set} → (A → Bool) → List A → Bool any _ [] = false any f (x :: xs) = (f x) or (any f xs) all : {A : Set} → (A → Bool) → List A → Bool all _ [] = true all f (x :: xs) = (f x) and (all f xs) data Arrow : Set where _⇒_ : List ℕ → ℕ → Arrow _⇔_ : Arrow → Arrow → Bool (at ⇒ ah) ⇔ (bt ⇒ bh) = ((at ⊂ bt) and (bt ⊂ at)) and (ah == bh) _∈∈_ : Arrow → List Arrow → Bool x ∈∈ [] = false x ∈∈ (y :: ys) with x ⇔ y ... | true = true ... | false = x ∈∈ ys _⊂⊂_ : List Arrow → List Arrow → Bool [] ⊂⊂ ys = true (x :: xs) ⊂⊂ ys with x ∈∈ ys ... | true = xs ⊂⊂ ys ... | false = false ArrowSearch : List Arrow → List Arrow → ℕ → Bool ArrowSearch [] ds g = false ArrowSearch (([] ⇒ h) :: cs) ds g with (h == g) ... | true = true ... | false = ArrowSearch cs (([] ⇒ h) :: ds) g ArrowSearch ((ts ⇒ h) :: cs) ds g with (h == g) ... | true = (all (ArrowSearch (cs ++ ds) []) ts) or (ArrowSearch cs ((ts ⇒ h) :: ds) g) ... | false = ArrowSearch cs ((ts ⇒ h) :: ds) g _⊢_ : List Arrow → Arrow → Bool cs ⊢ ((t :: ts) ⇒ h) = (([] ⇒ t) :: cs) ⊢ (ts ⇒ h) cs ⊢ ([] ⇒ h) = ArrowSearch cs [] h
{ "alphanum_fraction": 0.4487978629, "avg_line_length": 22.46, "ext": "agda", "hexsha": "60a8164e60bd32197d3362ace7096fec5901a82d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "e73df65d9a118e35a42d2d00d838aa901f9c3a6f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "louisswarren/hieretikz", "max_forks_repo_path": "hierarchy.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e73df65d9a118e35a42d2d00d838aa901f9c3a6f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "louisswarren/hieretikz", "max_issues_repo_path": "hierarchy.agda", "max_line_length": 64, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e73df65d9a118e35a42d2d00d838aa901f9c3a6f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "louisswarren/hieretikz", "max_stars_repo_path": "hierarchy.agda", "max_stars_repo_stars_event_max_datetime": "2018-03-26T03:34:11.000Z", "max_stars_repo_stars_event_min_datetime": "2018-03-18T12:17:36.000Z", "num_tokens": 820, "size": 2246 }
module Lang.Inspect where open import Type open import Structure.Setoid open import Structure.Relator.Properties {- module _ {ℓ₁ ℓ₂} {A : Type{ℓ₁}} {B : A → Type{ℓ₂}} ⦃ eqB : ∀{x} → Equiv(B(x)) ⦄ (f : ∀(x) → B(x)) (x : A) where data Inspect (y : B(x)) : Type{ℓ₂} where intro : (f(x) ≡ y) → Inspect(y) inspect : Inspect(f(x)) inspect = intro(reflexivity(_≡_ ⦃ eqB ⦄)) {-# INLINE inspect #-} -} module _ {ℓ₁ ℓ₂ ℓₑ₂} {A : Type{ℓ₁}} {B : Type{ℓ₂}} ⦃ equiv-B : Equiv{ℓₑ₂}(B) ⦄ (f : A → B) (x : A) where data Inspect (y : B) : Type{ℓₑ₂} where intro : (f(x) ≡ y) → Inspect(y) inspect : Inspect(f(x)) inspect = intro(reflexivity(_≡_)) {-# INLINE inspect #-}
{ "alphanum_fraction": 0.5758468336, "avg_line_length": 28.2916666667, "ext": "agda", "hexsha": "0ff04dcdf4ab37aeb69f977b678df8f1ee18e0f9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Lang/Inspect.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Lang/Inspect.agda", "max_line_length": 111, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Lang/Inspect.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 292, "size": 679 }
{-# OPTIONS --without-K --rewriting #-} open import HoTT hiding (left; right) module homotopy.BlakersMassey {i j k} {A : Type i} {B : Type j} (Q : A → B → Type k) m (f-conn : ∀ a → is-connected (S m) (Σ B (λ b → Q a b))) n (g-conn : ∀ b → is-connected (S n) (Σ A (λ a → Q a b))) where open import homotopy.blakersmassey.Pushout Q import homotopy.blakersmassey.CoherenceData Q m f-conn n g-conn as Coh -- These extra parameters will be discharged in the end module _ {a₀} {b₀} (q₀₀ : Q a₀ b₀) where -- Step 1: -- Generalizing the theorem to [bmleft x == p] for arbitrary p. -- This requires a pushout-rec -- "extended" version code-bmleft-template : ∀ a₁ {p} (r' : bmleft a₁ == p) → bmleft a₀ == p → Type (lmax i (lmax j k)) code-bmleft-template a₁ r' r = Trunc (m +2+ n) (hfiber (λ q₁₀ → bmglue q₀₀ ∙' ! (bmglue q₁₀) ∙' r') r) code-bmleft : ∀ a₁ → bmleft a₀ == bmleft a₁ → Type (lmax i (lmax j k)) code-bmleft a₁ = code-bmleft-template a₁ idp code-bmright : ∀ b₁ → bmleft a₀ == bmright b₁ → Type (lmax i (lmax j k)) code-bmright b₁ r = Trunc (m +2+ n) (hfiber bmglue r) -- The template from [Coh.eqv] to the input for [apd code glue] -- for using the identification elimination. code-bmglue-template : ∀ {a₁ p} → (code : (r : bmleft a₀ == p) → Type (lmax i (lmax j k))) → (r : bmleft a₁ == p) → (∀ r' → code-bmleft-template a₁ r r' ≃ code r') → code-bmleft-template a₁ idp == code [ (λ p → bmleft a₀ == p → Type (lmax i (lmax j k))) ↓ r ] code-bmglue-template _ idp lemma = λ= (ua ∘ lemma) -- The real glue, that is, the template with actual equivalence. code-bmglue : ∀ {a₁ b₁} (q₁₁ : Q a₁ b₁) → code-bmleft a₁ == code-bmright b₁ [ (λ p → bmleft a₀ == p → Type (lmax i (lmax j k))) ↓ bmglue q₁₁ ] code-bmglue {a₁} {b₁} q₁₁ = code-bmglue-template (code-bmright b₁) (bmglue q₁₁) (Coh.eqv q₀₀ q₁₁) -- Here's the data structure for the generalized theorem. module Code = BMPushoutElim code-bmleft code-bmright code-bmglue code : ∀ p → bmleft a₀ == p → Type (lmax i (lmax j k)) code = Code.f -- Step 2: -- [code] is contractible! -- The center for [idp]. We will use transport to find the center -- in other fibers. code-center-idp : code (bmleft a₀) idp code-center-idp = [ q₀₀ , !-inv'-r (bmglue q₀₀) ] -- The following is the breakdown of the path for coercing: -- [ap2 code r (↓-cst=idf-in' r)] -- We will need the broken-down version anyway, -- so why not breaking them down from the very beginning? -- The template here, again, is to keep the possibility -- of plugging in [idp] for [r]. coerce-path-template : ∀ {p} r → code-bmleft a₀ == code p [ (λ p → bmleft a₀ == p → Type (lmax i (lmax j k))) ↓ r ] → code-bmleft a₀ idp == code p r coerce-path-template idp lemma = app= lemma idp -- The real path. coerce-path : ∀ {p} r → code (bmleft a₀) idp == code p r coerce-path r = coerce-path-template r (apd code r) -- Find the center in other fibers. code-center : ∀ {p} r → code p r code-center r = coe (coerce-path r) code-center-idp -- Part of the decomposed [coe (coerce-path r)] code-bmleft-template-diag : ∀ {p} (r : bmleft a₀ == p) → code-bmleft a₀ idp → code-bmleft-template a₀ r r code-bmleft-template-diag r = Trunc-rec Trunc-level λ {(q₀₀' , shift) → [ q₀₀' , ! (∙'-assoc (bmglue q₀₀) (! (bmglue q₀₀')) r) ∙ ap (_∙' r) shift ∙' ∙'-unit-l r ]} abstract code-bmleft-template-diag-idp : ∀ x → code-bmleft-template-diag idp x == x code-bmleft-template-diag-idp = Trunc-elim (λ _ → =-preserves-level Trunc-level) λ{(q₁₀ , shift) → ap (λ p → [ q₁₀ , p ]) (ap-idf shift)} -- Here shows the use of two templates. It will be super painful -- if we cannot throw in [idp]. Now we only have to deal with -- simple computations. abstract coe-coerce-path-code-bmglue-template : ∀ {p} (r : bmleft a₀ == p) (lemma : ∀ r' → code-bmleft-template a₀ r r' ≃ code p r') (x : code-bmleft a₀ idp) → coe (coerce-path-template r (code-bmglue-template (code p) r lemma)) x == –> (lemma r) (code-bmleft-template-diag r x) coe-coerce-path-code-bmglue-template idp lemma x = coe (app= (λ= (ua ∘ lemma)) idp) x =⟨ ap (λ p → coe p x) (app=-β (ua ∘ lemma) idp) ⟩ coe (ua (lemma idp)) x =⟨ coe-β (lemma idp) x ⟩ –> (lemma idp) x =⟨ ! (ap (–> (lemma idp)) (code-bmleft-template-diag-idp x)) ⟩ –> (lemma idp) (code-bmleft-template-diag idp x) =∎ -- Here is the actually lemma we want! -- A succinct breakdown of [coerce-path code (glue q)]. abstract coe-coerce-path-code-bmglue : ∀ {b₁} (q₀₁ : Q a₀ b₁) x → coe (coerce-path (bmglue q₀₁)) x == Coh.to q₀₀ q₀₁ (bmglue q₀₁) (code-bmleft-template-diag (bmglue q₀₁) x) coe-coerce-path-code-bmglue q₀₁ x = coe (coerce-path-template (bmglue q₀₁) (apd code (bmglue q₀₁))) x =⟨ ap (λ p → coe (coerce-path-template (bmglue q₀₁) p) x) (Code.glue-β q₀₁) ⟩ coe (coerce-path-template (bmglue q₀₁) (code-bmglue q₀₁)) x =⟨ coe-coerce-path-code-bmglue-template (bmglue q₀₁) (Coh.eqv q₀₀ q₀₁) x ⟩ Coh.to q₀₀ q₀₁ (bmglue q₀₁) (code-bmleft-template-diag (bmglue q₀₁) x) =∎ -- This is the only case you care for contractibiltiy. abstract code-coh-lemma : ∀ {b₁} (q₀₁ : Q a₀ b₁) → code-center (bmglue q₀₁) == [ q₀₁ , idp ] code-coh-lemma q₀₁ = coe (coerce-path (bmglue q₀₁)) code-center-idp =⟨ coe-coerce-path-code-bmglue q₀₁ code-center-idp ⟩ Coh.to' q₀₀ q₀₁ (bmglue q₀₁) (q₀₀ , α₁α₁⁻¹α₂=α₂ (bmglue q₀₀) (bmglue q₀₁)) =⟨ ap (Coh.To.ext q₀₀ (_ , q₀₀) (_ , q₀₁) (bmglue q₀₁)) (path-lemma (bmglue q₀₀) (bmglue q₀₁)) ⟩ Coh.To.ext q₀₀ (_ , q₀₀) (_ , q₀₁) (bmglue q₀₁) (! path) =⟨ Coh.To.β-r q₀₀ (_ , q₀₁) (bmglue q₀₁) (! path) ⟩ [ q₀₁ , path ∙' ! path ] =⟨ ap (λ p → [ q₀₁ , p ]) (!-inv'-r path) ⟩ [ q₀₁ , idp ] =∎ where path = Coh.βPair.path (Coh.βpair-bmright q₀₀ q₀₁ (bmglue q₀₁)) -- this is defined to be the path generated by [code-bmleft-template-diag] α₁α₁⁻¹α₂=α₂ : ∀ {p₁ p₂ p₃ : BMPushout} (α₁ : p₁ == p₂) (α₂ : p₁ == p₃) → α₁ ∙' ! α₁ ∙' α₂ == α₂ α₁α₁⁻¹α₂=α₂ α₁ α₂ = ! (∙'-assoc α₁ (! α₁) α₂) ∙ ap (_∙' α₂) (!-inv'-r α₁) ∙' ∙'-unit-l α₂ -- the relation of this path and the one from CoherenceData path-lemma : ∀ {p₁ p₂ p₃ : BMPushout} (α₁ : p₁ == p₂) (α₂ : p₁ == p₃) → α₁α₁⁻¹α₂=α₂ α₁ α₂ == ! (Coh.α₁=α₂α₂⁻¹α₁ α₂ α₁) path-lemma idp idp = idp -- Make [r] free to apply identification elimination. code-coh : ∀ {b₁} (r : bmleft a₀ == bmright b₁) (s : hfiber bmglue r) → code-center r == [ s ] code-coh ._ (q₀₁ , idp) = code-coh-lemma q₀₁ -- Finish the lemma. code-contr : ∀ {b₁} (r : bmleft a₀ == bmright b₁) → is-contr (Trunc (m +2+ n) (hfiber bmglue r)) code-contr r = code-center r , Trunc-elim (λ _ → =-preserves-level Trunc-level) (code-coh r) -- The final theorem. -- It is sufficient to find some [q₀₀]. blakers-massey : ∀ {a₀ b₀} → has-conn-fibers (m +2+ n) (bmglue {a₀} {b₀}) blakers-massey {a₀} r = Trunc-rec (prop-has-level-S is-connected-is-prop) (λ{(_ , q₀₀) → code-contr q₀₀ r}) (fst (f-conn a₀))
{ "alphanum_fraction": 0.5949105915, "avg_line_length": 42.7647058824, "ext": "agda", "hexsha": "9e0d3cd63252ae3c01ac6245c13d3cab9e012b5d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z", "max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "mikeshulman/HoTT-Agda", "max_forks_repo_path": "theorems/homotopy/BlakersMassey.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "mikeshulman/HoTT-Agda", "max_issues_repo_path": "theorems/homotopy/BlakersMassey.agda", "max_line_length": 104, "max_stars_count": null, "max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "mikeshulman/HoTT-Agda", "max_stars_repo_path": "theorems/homotopy/BlakersMassey.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2876, "size": 7270 }
-- An ATP conjecture must be used with postulates. -- This error is detected by Syntax.Translation.ConcreteToAbstract. module ATPBadConjecture1 where data Bool : Set where false true : Bool {-# ATP prove false #-}
{ "alphanum_fraction": 0.75, "avg_line_length": 20, "ext": "agda", "hexsha": "0fb6574dffa13b96e1127d3345778233b4408337", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "asr/eagda", "max_forks_repo_path": "test/fail/ATPBadConjecture1.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "asr/eagda", "max_issues_repo_path": "test/fail/ATPBadConjecture1.agda", "max_line_length": 67, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7220bebfe9f64297880ecec40314c0090018fdd0", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "asr/eagda", "max_stars_repo_path": "test/fail/ATPBadConjecture1.agda", "max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z", "max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z", "num_tokens": 52, "size": 220 }
{-# OPTIONS --without-K #-} module function.surjective where open import sum open import equality open import function.isomorphism.core open import hott.level.core open import hott.equivalence.core open import hott.truncation surjective : ∀ {i j}{A : Set i}{B : Set j} → (A → B) → Set _ surjective f = ∀ b → ∥ f ⁻¹ b ∥ retr⇒surj : ∀ {i j}{A : Set i}{B : Set j} → (f : A → B) → retraction f → surjective f retr⇒surj f retr b = η (retr b) inj+surj⇒eq : ∀ {i j}{A : Set i}{B : Set j} → h 2 A → h 2 B → (f : A → B) → injective f → surjective f → weak-equiv f inj+surj⇒eq {A = A}{B = B} hA hB f inj surj b = retr-f b , propFib b (retr-f b) where propFib : (b : B) → prop (f ⁻¹ b) propFib b (a , p) (a' , p') = unapΣ (inj (p · sym p') , h1⇒prop (hB (f a') b) _ _) retr-f : retraction f retr-f b = Trunc-elim (prop⇒h1 (propFib b)) (λ x → x) (surj b)
{ "alphanum_fraction": 0.5339602926, "avg_line_length": 28.1470588235, "ext": "agda", "hexsha": "68d2c30572f674b00cd450c33e1641ef3548efb6", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-02-26T06:17:38.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-11T17:19:12.000Z", "max_forks_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "HoTT/M-types", "max_forks_repo_path": "function/surjective.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_issues_repo_issues_event_max_datetime": "2015-02-11T15:20:34.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-11T11:14:59.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "HoTT/M-types", "max_issues_repo_path": "function/surjective.agda", "max_line_length": 86, "max_stars_count": 27, "max_stars_repo_head_hexsha": "beebe176981953ab48f37de5eb74557cfc5402f4", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "HoTT/M-types", "max_stars_repo_path": "function/surjective.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-09T07:26:57.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-14T15:47:03.000Z", "num_tokens": 373, "size": 957 }
------------------------------------------------------------------------------ -- The Booleans properties ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module LTC-PCF.Data.Bool.Properties where open import LTC-PCF.Base open import LTC-PCF.Data.Bool open import LTC-PCF.Data.Nat.Inequalities open import LTC-PCF.Data.Nat.Inequalities.Properties open import LTC-PCF.Data.Nat.Type ------------------------------------------------------------------------------ -- Congruence properties notCong : ∀ {a b} → a ≡ b → not a ≡ not b notCong refl = refl ------------------------------------------------------------------------------ -- Basic properties t&&x≡x : ∀ b → true && b ≡ b t&&x≡x b = if-true b f&&x≡f : ∀ b → false && b ≡ false f&&x≡f b = if-false false not-t : not true ≡ false not-t = if-true false not-f : not false ≡ true not-f = if-false true &&-Bool : ∀ {a b} → Bool a → Bool b → Bool (a && b) &&-Bool {b = b} btrue Bb = subst Bool (sym (t&&x≡x b)) Bb &&-Bool {b = b} bfalse Bb = subst Bool (sym (f&&x≡f b)) bfalse not-Bool : ∀ {b} → Bool b → Bool (not b) not-Bool btrue = subst Bool (sym not-t) bfalse not-Bool bfalse = subst Bool (sym not-f) btrue &&-comm : ∀ {a b} → Bool a → Bool b → a && b ≡ b && a &&-comm btrue btrue = refl &&-comm btrue bfalse = trans (t&&x≡x false) (sym (f&&x≡f true)) &&-comm bfalse btrue = trans (f&&x≡f true) (sym (t&&x≡x false)) &&-comm bfalse bfalse = refl x≢not-x : ∀ {b} → Bool b → b ≢ not b x≢not-x btrue h = t≢f (trans h not-t) x≢not-x bfalse h = t≢f (sym (trans h not-f)) not-x≢x : ∀ {b} → Bool b → not b ≢ b not-x≢x Bb h = x≢not-x Bb (sym h) not-involutive : ∀ {b} → Bool b → not (not b) ≡ b not-involutive btrue = trans (notCong not-t) not-f not-involutive bfalse = trans (notCong not-f) not-t ------------------------------------------------------------------------------ -- Properties with inequalities lt-Bool : ∀ {m n} → N m → N n → Bool (lt m n) lt-Bool nzero nzero = subst Bool (sym lt-00) bfalse lt-Bool nzero (nsucc {n} Nn) = subst Bool (sym (lt-0S n)) btrue lt-Bool (nsucc {m} Nm) nzero = subst Bool (sym (lt-S0 m)) bfalse lt-Bool (nsucc {m} Nm) (nsucc {n} Nn) = subst Bool (sym (lt-SS m n)) (lt-Bool Nm Nn) le-Bool : ∀ {m n} → N m → N n → Bool (le m n) le-Bool {n = n} nzero Nn = subst Bool (sym (lt-0S n)) btrue le-Bool (nsucc Nm) nzero = subst Bool (sym (Sx≰0 Nm)) bfalse le-Bool (nsucc {m} Nm) (nsucc {n} Nn) = subst Bool (sym (lt-SS m (succ₁ n))) (le-Bool Nm Nn)
{ "alphanum_fraction": 0.4957983193, "avg_line_length": 35.0897435897, "ext": "agda", "hexsha": "60b31f9dd2d4333fd6ad21192b9925e2db998c50", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "src/fot/LTC-PCF/Data/Bool/Properties.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "src/fot/LTC-PCF/Data/Bool/Properties.agda", "max_line_length": 84, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "src/fot/LTC-PCF/Data/Bool/Properties.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 918, "size": 2737 }
{- This second-order term syntax was created from the following second-order syntax description: syntax Sum | S type _⊕_ : 2-ary | l30 term inl : α -> α ⊕ β inr : β -> α ⊕ β case : α ⊕ β α.γ β.γ -> γ theory (lβ) a : α f : α.γ g : β.γ |> case (inl(a), x.f[x], y.g[y]) = f[a] (rβ) b : β f : α.γ g : β.γ |> case (inr(b), x.f[x], y.g[y]) = g[b] (cη) s : α ⊕ β c : (α ⊕ β).γ |> case (s, x.c[inl(x)], y.c[inr(y)]) = c[s] -} module Sum.Syntax where open import SOAS.Common open import SOAS.Context open import SOAS.Variable open import SOAS.Families.Core open import SOAS.Construction.Structure open import SOAS.ContextMaps.Inductive open import SOAS.Metatheory.Syntax open import Sum.Signature private variable Γ Δ Π : Ctx α β γ : ST 𝔛 : Familyₛ -- Inductive term declaration module S:Terms (𝔛 : Familyₛ) where data S : Familyₛ where var : ℐ ⇾̣ S mvar : 𝔛 α Π → Sub S Π Γ → S α Γ inl : S α Γ → S (α ⊕ β) Γ inr : S β Γ → S (α ⊕ β) Γ case : S (α ⊕ β) Γ → S γ (α ∙ Γ) → S γ (β ∙ Γ) → S γ Γ open import SOAS.Metatheory.MetaAlgebra ⅀F 𝔛 Sᵃ : MetaAlg S Sᵃ = record { 𝑎𝑙𝑔 = λ where (inlₒ ⋮ a) → inl a (inrₒ ⋮ a) → inr a (caseₒ ⋮ a , b , c) → case a b c ; 𝑣𝑎𝑟 = var ; 𝑚𝑣𝑎𝑟 = λ 𝔪 mε → mvar 𝔪 (tabulate mε) } module Sᵃ = MetaAlg Sᵃ module _ {𝒜 : Familyₛ}(𝒜ᵃ : MetaAlg 𝒜) where open MetaAlg 𝒜ᵃ 𝕤𝕖𝕞 : S ⇾̣ 𝒜 𝕊 : Sub S Π Γ → Π ~[ 𝒜 ]↝ Γ 𝕊 (t ◂ σ) new = 𝕤𝕖𝕞 t 𝕊 (t ◂ σ) (old v) = 𝕊 σ v 𝕤𝕖𝕞 (mvar 𝔪 mε) = 𝑚𝑣𝑎𝑟 𝔪 (𝕊 mε) 𝕤𝕖𝕞 (var v) = 𝑣𝑎𝑟 v 𝕤𝕖𝕞 (inl a) = 𝑎𝑙𝑔 (inlₒ ⋮ 𝕤𝕖𝕞 a) 𝕤𝕖𝕞 (inr a) = 𝑎𝑙𝑔 (inrₒ ⋮ 𝕤𝕖𝕞 a) 𝕤𝕖𝕞 (case a b c) = 𝑎𝑙𝑔 (caseₒ ⋮ 𝕤𝕖𝕞 a , 𝕤𝕖𝕞 b , 𝕤𝕖𝕞 c) 𝕤𝕖𝕞ᵃ⇒ : MetaAlg⇒ Sᵃ 𝒜ᵃ 𝕤𝕖𝕞 𝕤𝕖𝕞ᵃ⇒ = record { ⟨𝑎𝑙𝑔⟩ = λ{ {t = t} → ⟨𝑎𝑙𝑔⟩ t } ; ⟨𝑣𝑎𝑟⟩ = refl ; ⟨𝑚𝑣𝑎𝑟⟩ = λ{ {𝔪 = 𝔪}{mε} → cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-tab mε)) } } where open ≡-Reasoning ⟨𝑎𝑙𝑔⟩ : (t : ⅀ S α Γ) → 𝕤𝕖𝕞 (Sᵃ.𝑎𝑙𝑔 t) ≡ 𝑎𝑙𝑔 (⅀₁ 𝕤𝕖𝕞 t) ⟨𝑎𝑙𝑔⟩ (inlₒ ⋮ _) = refl ⟨𝑎𝑙𝑔⟩ (inrₒ ⋮ _) = refl ⟨𝑎𝑙𝑔⟩ (caseₒ ⋮ _) = refl 𝕊-tab : (mε : Π ~[ S ]↝ Γ)(v : ℐ α Π) → 𝕊 (tabulate mε) v ≡ 𝕤𝕖𝕞 (mε v) 𝕊-tab mε new = refl 𝕊-tab mε (old v) = 𝕊-tab (mε ∘ old) v module _ (g : S ⇾̣ 𝒜)(gᵃ⇒ : MetaAlg⇒ Sᵃ 𝒜ᵃ g) where open MetaAlg⇒ gᵃ⇒ 𝕤𝕖𝕞! : (t : S α Γ) → 𝕤𝕖𝕞 t ≡ g t 𝕊-ix : (mε : Sub S Π Γ)(v : ℐ α Π) → 𝕊 mε v ≡ g (index mε v) 𝕊-ix (x ◂ mε) new = 𝕤𝕖𝕞! x 𝕊-ix (x ◂ mε) (old v) = 𝕊-ix mε v 𝕤𝕖𝕞! (mvar 𝔪 mε) rewrite cong (𝑚𝑣𝑎𝑟 𝔪) (dext (𝕊-ix mε)) = trans (sym ⟨𝑚𝑣𝑎𝑟⟩) (cong (g ∘ mvar 𝔪) (tab∘ix≈id mε)) 𝕤𝕖𝕞! (var v) = sym ⟨𝑣𝑎𝑟⟩ 𝕤𝕖𝕞! (inl a) rewrite 𝕤𝕖𝕞! a = sym ⟨𝑎𝑙𝑔⟩ 𝕤𝕖𝕞! (inr a) rewrite 𝕤𝕖𝕞! a = sym ⟨𝑎𝑙𝑔⟩ 𝕤𝕖𝕞! (case a b c) rewrite 𝕤𝕖𝕞! a | 𝕤𝕖𝕞! b | 𝕤𝕖𝕞! c = sym ⟨𝑎𝑙𝑔⟩ -- Syntax instance for the signature S:Syn : Syntax S:Syn = record { ⅀F = ⅀F ; ⅀:CS = ⅀:CompatStr ; mvarᵢ = S:Terms.mvar ; 𝕋:Init = λ 𝔛 → let open S:Terms 𝔛 in record { ⊥ = S ⋉ Sᵃ ; ⊥-is-initial = record { ! = λ{ {𝒜 ⋉ 𝒜ᵃ} → 𝕤𝕖𝕞 𝒜ᵃ ⋉ 𝕤𝕖𝕞ᵃ⇒ 𝒜ᵃ } ; !-unique = λ{ {𝒜 ⋉ 𝒜ᵃ} (f ⋉ fᵃ⇒) {x = t} → 𝕤𝕖𝕞! 𝒜ᵃ f fᵃ⇒ t } } } } -- Instantiation of the syntax and metatheory open Syntax S:Syn public open S:Terms public open import SOAS.Families.Build public open import SOAS.Syntax.Shorthands Sᵃ public open import SOAS.Metatheory S:Syn public
{ "alphanum_fraction": 0.5149911817, "avg_line_length": 26.1692307692, "ext": "agda", "hexsha": "3c736841ffdb4a80e8957160dcc35009897e336a", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2022-01-24T12:49:17.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-09T20:39:59.000Z", "max_forks_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "JoeyEremondi/agda-soas", "max_forks_repo_path": "out/Sum/Syntax.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_issues_repo_issues_event_max_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_issues_event_min_datetime": "2021-11-21T12:19:32.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "JoeyEremondi/agda-soas", "max_issues_repo_path": "out/Sum/Syntax.agda", "max_line_length": 93, "max_stars_count": 39, "max_stars_repo_head_hexsha": "ff1a985a6be9b780d3ba2beff68e902394f0a9d8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "JoeyEremondi/agda-soas", "max_stars_repo_path": "out/Sum/Syntax.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-19T17:33:12.000Z", "max_stars_repo_stars_event_min_datetime": "2021-11-09T20:39:55.000Z", "num_tokens": 2154, "size": 3402 }
module LibB where import LibC
{ "alphanum_fraction": 0.8333333333, "avg_line_length": 10, "ext": "agda", "hexsha": "f22d0e1904910109794d203cd220731ff7e08da5", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/interaction/Issue5245/b/LibB.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/interaction/Issue5245/b/LibB.agda", "max_line_length": 17, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/interaction/Issue5245/b/LibB.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 9, "size": 30 }
{-# OPTIONS --safe #-} module Cubical.Experiments.IsoInt where open import Cubical.Experiments.IsoInt.Base public
{ "alphanum_fraction": 0.775862069, "avg_line_length": 19.3333333333, "ext": "agda", "hexsha": "b3dbb7872416fc550171b76fea2b7be250f56924", "lang": "Agda", "max_forks_count": 134, "max_forks_repo_forks_event_max_datetime": "2022-03-23T16:22:13.000Z", "max_forks_repo_forks_event_min_datetime": "2018-11-16T06:11:03.000Z", "max_forks_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "marcinjangrzybowski/cubical", "max_forks_repo_path": "Cubical/Experiments/IsoInt.agda", "max_issues_count": 584, "max_issues_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_issues_repo_issues_event_max_datetime": "2022-03-30T12:09:17.000Z", "max_issues_repo_issues_event_min_datetime": "2018-10-15T09:49:02.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "marcinjangrzybowski/cubical", "max_issues_repo_path": "Cubical/Experiments/IsoInt.agda", "max_line_length": 50, "max_stars_count": 301, "max_stars_repo_head_hexsha": "53e159ec2e43d981b8fcb199e9db788e006af237", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "marcinjangrzybowski/cubical", "max_stars_repo_path": "Cubical/Experiments/IsoInt.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-24T02:10:47.000Z", "max_stars_repo_stars_event_min_datetime": "2018-10-17T18:00:24.000Z", "num_tokens": 27, "size": 116 }
{-# OPTIONS --without-K #-} module lib.cubical.Cubical where open import lib.cubical.Square public open import lib.cubical.Cube public
{ "alphanum_fraction": 0.7664233577, "avg_line_length": 19.5714285714, "ext": "agda", "hexsha": "16fd283b9ab0ecc98863cf3663dec6ef78a4f29b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "danbornside/HoTT-Agda", "max_forks_repo_path": "lib/cubical/Cubical.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "danbornside/HoTT-Agda", "max_issues_repo_path": "lib/cubical/Cubical.agda", "max_line_length": 37, "max_stars_count": null, "max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "danbornside/HoTT-Agda", "max_stars_repo_path": "lib/cubical/Cubical.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 36, "size": 137 }
-------------------------------------------------------------------------------- -- This is part of Agda Inference Systems open import Data.Nat open import Relation.Binary.PropositionalEquality open import Data.Sum module Examples.Colists.Auxiliary.MaxOf where max : ℕ → ℕ → ℕ max zero zero = zero max zero (suc y) = suc y max (suc x) zero = suc x max (suc x) (suc y) = suc (max x y) max-refl : (x y : ℕ) → (x ≡ max x y) ⊎ (y ≡ max x y) max-refl zero zero = inj₂ refl max-refl zero (suc y) = inj₂ refl max-refl (suc x) zero = inj₁ refl max-refl (suc x) (suc y) with max-refl x y max-refl (suc x) (suc y) | inj₁ eq = inj₁ (cong (λ x₁ → suc x₁) eq) max-refl (suc x) (suc y) | inj₂ eq = inj₂ (cong (λ x₁ → suc x₁) eq) max-refl-eq : ∀{x y z} → z ≡ max x y → z ≡ x ⊎ z ≡ y max-refl-eq {x} {y} {z} refl with max-refl x y max-refl-eq {x} {y} {.(max x y)} refl | inj₁ x₁ = inj₁ (sym x₁) max-refl-eq {x} {y} {.(max x y)} refl | inj₂ y₁ = inj₂ (sym y₁) max-self : ∀ {n} → n ≡ max n n max-self {zero} = refl max-self {suc n} = cong (λ x → suc x) max-self max-trans : ∀{x y z} → y ≡ max y z → x ≡ max x y → x ≡ max x z max-trans {zero} {zero} {zero} _ _ = refl max-trans {suc x} {zero} {zero} refl refl = refl max-trans {suc x} {suc y} {zero} refl _ = refl max-trans {suc x} {suc y} {suc z} eq eq1 = let eq-pred = cong pred eq in let eq1-pred = cong pred eq1 in cong suc (max-trans eq-pred eq1-pred) max-comm : ∀{x y z} → x ≡ max y z → x ≡ max z y max-comm {x} {zero} {zero} eq = eq max-comm {x} {suc y} {zero} eq = eq max-comm {x} {zero} {suc z} eq = eq max-comm {suc x} {suc y} {suc z} eq = cong suc (max-comm (cong pred eq))
{ "alphanum_fraction": 0.5528647372, "avg_line_length": 36.8043478261, "ext": "agda", "hexsha": "fe01bdc8693c343ab9fdccfbf4b2fe33c4f69b75", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "LcicC/inference-systems-agda", "max_forks_repo_path": "Examples/Colists/Auxiliary/MaxOf.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "LcicC/inference-systems-agda", "max_issues_repo_path": "Examples/Colists/Auxiliary/MaxOf.agda", "max_line_length": 80, "max_stars_count": 3, "max_stars_repo_head_hexsha": "b9043f99e4bf7211db4066a7a943401d127f0c8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "LcicC/inference-systems-agda", "max_stars_repo_path": "Examples/Colists/Auxiliary/MaxOf.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-25T15:48:52.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-10T15:53:47.000Z", "num_tokens": 686, "size": 1693 }
data Unit : Set where unit : Unit mutual data D : Unit → Set where c : (x : Unit) → F x x → D x F : Unit → Unit → Set F unit x = D x Works : (x : Unit) → D x → Set₁ Works .x (c x p) with x Works .x (c x p) | _ = Set Fails : (x : Unit) → D x → Set₁ Fails y = Fails′ y where Fails′ : (x : Unit) → D x → Set₁ Fails′ .x (c x p) with x Fails′ .x (c x p) | _ = Set
{ "alphanum_fraction": 0.5090439276, "avg_line_length": 16.8260869565, "ext": "agda", "hexsha": "2641e02412a95420d06b559de0e4c54d83e99bb4", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue2327.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue2327.agda", "max_line_length": 34, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue2327.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 171, "size": 387 }
{-# OPTIONS --without-K --safe #-} open import Definition.Typed.EqualityRelation module Definition.LogicalRelation.ShapeView {{eqrel : EqRelSet}} where open EqRelSet {{...}} open import Definition.Untyped open import Definition.Typed open import Definition.Typed.Properties open import Definition.LogicalRelation open import Definition.LogicalRelation.Properties.Escape open import Definition.LogicalRelation.Properties.Reflexivity open import Tools.Product open import Tools.Empty using (⊥; ⊥-elim) import Tools.PropositionalEquality as PE -- Type for maybe embeddings of reducible types data MaybeEmb (l : TypeLevel) (⊩⟨_⟩ : TypeLevel → Set) : Set where noemb : ⊩⟨ l ⟩ → MaybeEmb l ⊩⟨_⟩ emb : ∀ {l′} → l′ < l → MaybeEmb l′ ⊩⟨_⟩ → MaybeEmb l ⊩⟨_⟩ -- Specific reducible types with possible embedding _⊩⟨_⟩U : (Γ : Con Term) (l : TypeLevel) → Set Γ ⊩⟨ l ⟩U = MaybeEmb l (λ l′ → Γ ⊩′⟨ l′ ⟩U) _⊩⟨_⟩ℕ_ : (Γ : Con Term) (l : TypeLevel) (A : Term) → Set Γ ⊩⟨ l ⟩ℕ A = MaybeEmb l (λ l′ → Γ ⊩ℕ A) _⊩⟨_⟩Empty_ : (Γ : Con Term) (l : TypeLevel) (A : Term) → Set Γ ⊩⟨ l ⟩Empty A = MaybeEmb l (λ l′ → Γ ⊩Empty A) _⊩⟨_⟩Unit_ : (Γ : Con Term) (l : TypeLevel) (A : Term) → Set Γ ⊩⟨ l ⟩Unit A = MaybeEmb l (λ l′ → Γ ⊩Unit A) _⊩⟨_⟩ne_ : (Γ : Con Term) (l : TypeLevel) (A : Term) → Set Γ ⊩⟨ l ⟩ne A = MaybeEmb l (λ l′ → Γ ⊩ne A) _⊩⟨_⟩B⟨_⟩_ : (Γ : Con Term) (l : TypeLevel) (W : BindingType) (A : Term) → Set Γ ⊩⟨ l ⟩B⟨ W ⟩ A = MaybeEmb l (λ l′ → Γ ⊩′⟨ l′ ⟩B⟨ W ⟩ A) -- Construct a general reducible type from a specific U-intr : ∀ {Γ l} → Γ ⊩⟨ l ⟩U → Γ ⊩⟨ l ⟩ U U-intr (noemb x) = Uᵣ x U-intr (emb 0<1 x) = emb 0<1 (U-intr x) ℕ-intr : ∀ {A Γ l} → Γ ⊩⟨ l ⟩ℕ A → Γ ⊩⟨ l ⟩ A ℕ-intr (noemb x) = ℕᵣ x ℕ-intr (emb 0<1 x) = emb 0<1 (ℕ-intr x) Empty-intr : ∀ {A Γ l} → Γ ⊩⟨ l ⟩Empty A → Γ ⊩⟨ l ⟩ A Empty-intr (noemb x) = Emptyᵣ x Empty-intr (emb 0<1 x) = emb 0<1 (Empty-intr x) Unit-intr : ∀ {A Γ l} → Γ ⊩⟨ l ⟩Unit A → Γ ⊩⟨ l ⟩ A Unit-intr (noemb x) = Unitᵣ x Unit-intr (emb 0<1 x) = emb 0<1 (Unit-intr x) ne-intr : ∀ {A Γ l} → Γ ⊩⟨ l ⟩ne A → Γ ⊩⟨ l ⟩ A ne-intr (noemb x) = ne x ne-intr (emb 0<1 x) = emb 0<1 (ne-intr x) B-intr : ∀ {A Γ l} W → Γ ⊩⟨ l ⟩B⟨ W ⟩ A → Γ ⊩⟨ l ⟩ A B-intr W (noemb x) = Bᵣ W x B-intr W (emb 0<1 x) = emb 0<1 (B-intr W x) -- Construct a specific reducible type from a general with some criterion U-elim : ∀ {Γ l} → Γ ⊩⟨ l ⟩ U → Γ ⊩⟨ l ⟩U U-elim (Uᵣ′ l′ l< ⊢Γ) = noemb (Uᵣ l′ l< ⊢Γ) U-elim (ℕᵣ D) with whnfRed* (red D) Uₙ ... | () U-elim (Emptyᵣ D) with whnfRed* (red D) Uₙ ... | () U-elim (Unitᵣ D) with whnfRed* (red D) Uₙ ... | () U-elim (ne′ K D neK K≡K) = ⊥-elim (U≢ne neK (whnfRed* (red D) Uₙ)) U-elim (Bᵣ′ W F G D ⊢F ⊢G A≡A [F] [G] G-ext) = ⊥-elim (U≢B W (whnfRed* (red D) Uₙ)) U-elim (emb 0<1 x) with U-elim x U-elim (emb 0<1 x) | noemb x₁ = emb 0<1 (noemb x₁) U-elim (emb 0<1 x) | emb () x₁ ℕ-elim′ : ∀ {A Γ l} → Γ ⊢ A ⇒* ℕ → Γ ⊩⟨ l ⟩ A → Γ ⊩⟨ l ⟩ℕ A ℕ-elim′ D (Uᵣ′ l′ l< ⊢Γ) with whrDet* (id (Uⱼ ⊢Γ) , Uₙ) (D , ℕₙ) ... | () ℕ-elim′ D (ℕᵣ D′) = noemb D′ ℕ-elim′ D (ne′ K D′ neK K≡K) = ⊥-elim (ℕ≢ne neK (whrDet* (D , ℕₙ) (red D′ , ne neK))) ℕ-elim′ D (Bᵣ′ W F G D′ ⊢F ⊢G A≡A [F] [G] G-ext) = ⊥-elim (ℕ≢B W (whrDet* (D , ℕₙ) (red D′ , ⟦ W ⟧ₙ))) ℕ-elim′ D (Emptyᵣ D′) with whrDet* (D , ℕₙ) (red D′ , Emptyₙ) ... | () ℕ-elim′ D (Unitᵣ D′) with whrDet* (D , ℕₙ) (red D′ , Unitₙ) ... | () ℕ-elim′ D (emb 0<1 x) with ℕ-elim′ D x ℕ-elim′ D (emb 0<1 x) | noemb x₁ = emb 0<1 (noemb x₁) ℕ-elim′ D (emb 0<1 x) | emb () x₂ ℕ-elim : ∀ {Γ l} → Γ ⊩⟨ l ⟩ ℕ → Γ ⊩⟨ l ⟩ℕ ℕ ℕ-elim [ℕ] = ℕ-elim′ (id (escape [ℕ])) [ℕ] Empty-elim′ : ∀ {A Γ l} → Γ ⊢ A ⇒* Empty → Γ ⊩⟨ l ⟩ A → Γ ⊩⟨ l ⟩Empty A Empty-elim′ D (Uᵣ′ l′ l< ⊢Γ) with whrDet* (id (Uⱼ ⊢Γ) , Uₙ) (D , Emptyₙ) ... | () Empty-elim′ D (Emptyᵣ D′) = noemb D′ Empty-elim′ D (Unitᵣ D′) with whrDet* (D , Emptyₙ) (red D′ , Unitₙ) ... | () Empty-elim′ D (ne′ K D′ neK K≡K) = ⊥-elim (Empty≢ne neK (whrDet* (D , Emptyₙ) (red D′ , ne neK))) Empty-elim′ D (Bᵣ′ W F G D′ ⊢F ⊢G A≡A [F] [G] G-ext) = ⊥-elim (Empty≢B W (whrDet* (D , Emptyₙ) (red D′ , ⟦ W ⟧ₙ))) Empty-elim′ D (ℕᵣ D′) with whrDet* (D , Emptyₙ) (red D′ , ℕₙ) ... | () Empty-elim′ D (emb 0<1 x) with Empty-elim′ D x Empty-elim′ D (emb 0<1 x) | noemb x₁ = emb 0<1 (noemb x₁) Empty-elim′ D (emb 0<1 x) | emb () x₂ Empty-elim : ∀ {Γ l} → Γ ⊩⟨ l ⟩ Empty → Γ ⊩⟨ l ⟩Empty Empty Empty-elim [Empty] = Empty-elim′ (id (escape [Empty])) [Empty] Unit-elim′ : ∀ {A Γ l} → Γ ⊢ A ⇒* Unit → Γ ⊩⟨ l ⟩ A → Γ ⊩⟨ l ⟩Unit A Unit-elim′ D (Uᵣ′ l′ l< ⊢Γ) with whrDet* (id (Uⱼ ⊢Γ) , Uₙ) (D , Unitₙ) ... | () Unit-elim′ D (Unitᵣ D′) = noemb D′ Unit-elim′ D (Emptyᵣ D′) with whrDet* (D , Unitₙ) (red D′ , Emptyₙ) ... | () Unit-elim′ D (ne′ K D′ neK K≡K) = ⊥-elim (Unit≢ne neK (whrDet* (D , Unitₙ) (red D′ , ne neK))) Unit-elim′ D (Bᵣ′ W F G D′ ⊢F ⊢G A≡A [F] [G] G-ext) = ⊥-elim (Unit≢B W (whrDet* (D , Unitₙ) (red D′ , ⟦ W ⟧ₙ))) Unit-elim′ D (ℕᵣ D′) with whrDet* (D , Unitₙ) (red D′ , ℕₙ) ... | () Unit-elim′ D (emb 0<1 x) with Unit-elim′ D x Unit-elim′ D (emb 0<1 x) | noemb x₁ = emb 0<1 (noemb x₁) Unit-elim′ D (emb 0<1 x) | emb () x₂ Unit-elim : ∀ {Γ l} → Γ ⊩⟨ l ⟩ Unit → Γ ⊩⟨ l ⟩Unit Unit Unit-elim [Unit] = Unit-elim′ (id (escape [Unit])) [Unit] ne-elim′ : ∀ {A Γ l K} → Γ ⊢ A ⇒* K → Neutral K → Γ ⊩⟨ l ⟩ A → Γ ⊩⟨ l ⟩ne A ne-elim′ D neK (Uᵣ′ l′ l< ⊢Γ) = ⊥-elim (U≢ne neK (whrDet* (id (Uⱼ ⊢Γ) , Uₙ) (D , ne neK))) ne-elim′ D neK (ℕᵣ D′) = ⊥-elim (ℕ≢ne neK (whrDet* (red D′ , ℕₙ) (D , ne neK))) ne-elim′ D neK (Emptyᵣ D′) = ⊥-elim (Empty≢ne neK (whrDet* (red D′ , Emptyₙ) (D , ne neK))) ne-elim′ D neK (Unitᵣ D′) = ⊥-elim (Unit≢ne neK (whrDet* (red D′ , Unitₙ) (D , ne neK))) ne-elim′ D neK (ne′ K D′ neK′ K≡K) = noemb (ne K D′ neK′ K≡K) ne-elim′ D neK (Bᵣ′ W F G D′ ⊢F ⊢G A≡A [F] [G] G-ext) = ⊥-elim (B≢ne W neK (whrDet* (red D′ , ⟦ W ⟧ₙ) (D , ne neK))) ne-elim′ D neK (emb 0<1 x) with ne-elim′ D neK x ne-elim′ D neK (emb 0<1 x) | noemb x₁ = emb 0<1 (noemb x₁) ne-elim′ D neK (emb 0<1 x) | emb () x₂ ne-elim : ∀ {Γ l K} → Neutral K → Γ ⊩⟨ l ⟩ K → Γ ⊩⟨ l ⟩ne K ne-elim neK [K] = ne-elim′ (id (escape [K])) neK [K] B-elim′ : ∀ {A Γ F G l} W → Γ ⊢ A ⇒* ⟦ W ⟧ F ▹ G → Γ ⊩⟨ l ⟩ A → Γ ⊩⟨ l ⟩B⟨ W ⟩ A B-elim′ W D (Uᵣ′ l′ l< ⊢Γ) = ⊥-elim (U≢B W (whrDet* (id (Uⱼ ⊢Γ) , Uₙ) (D , ⟦ W ⟧ₙ))) B-elim′ W D (ℕᵣ D′) = ⊥-elim (ℕ≢B W (whrDet* (red D′ , ℕₙ) (D , ⟦ W ⟧ₙ))) B-elim′ W D (Emptyᵣ D′) = ⊥-elim (Empty≢B W (whrDet* (red D′ , Emptyₙ) (D , ⟦ W ⟧ₙ))) B-elim′ W D (Unitᵣ D′) = ⊥-elim (Unit≢B W (whrDet* (red D′ , Unitₙ) (D , ⟦ W ⟧ₙ))) B-elim′ W D (ne′ K D′ neK K≡K) = ⊥-elim (B≢ne W neK (whrDet* (D , ⟦ W ⟧ₙ) (red D′ , ne neK))) B-elim′ BΠ D (Bᵣ′ BΣ F G D′ ⊢F ⊢G A≡A [F] [G] G-ext) with whrDet* (D , Πₙ) (red D′ , Σₙ) ... | () B-elim′ BΣ D (Bᵣ′ BΠ F G D′ ⊢F ⊢G A≡A [F] [G] G-ext) with whrDet* (D , Σₙ) (red D′ , Πₙ) ... | () B-elim′ BΠ D (Bᵣ′ BΠ F G D′ ⊢F ⊢G A≡A [F] [G] G-ext) = noemb (Bᵣ F G D′ ⊢F ⊢G A≡A [F] [G] G-ext) B-elim′ BΣ D (Bᵣ′ BΣ F G D′ ⊢F ⊢G A≡A [F] [G] G-ext) = noemb (Bᵣ F G D′ ⊢F ⊢G A≡A [F] [G] G-ext) B-elim′ W D (emb 0<1 x) with B-elim′ W D x B-elim′ W D (emb 0<1 x) | noemb x₁ = emb 0<1 (noemb x₁) B-elim′ W D (emb 0<1 x) | emb () x₂ B-elim : ∀ {Γ F G l} W → Γ ⊩⟨ l ⟩ ⟦ W ⟧ F ▹ G → Γ ⊩⟨ l ⟩B⟨ W ⟩ ⟦ W ⟧ F ▹ G B-elim W [Π] = B-elim′ W (id (escape [Π])) [Π] Π-elim : ∀ {Γ F G l} → Γ ⊩⟨ l ⟩ Π F ▹ G → Γ ⊩⟨ l ⟩B⟨ BΠ ⟩ Π F ▹ G Π-elim [Π] = B-elim′ BΠ (id (escape [Π])) [Π] Σ-elim : ∀ {Γ F G l} → Γ ⊩⟨ l ⟩ Σ F ▹ G → Γ ⊩⟨ l ⟩B⟨ BΣ ⟩ Σ F ▹ G Σ-elim [Σ] = B-elim′ BΣ (id (escape [Σ])) [Σ] -- Extract a type and a level from a maybe embedding extractMaybeEmb : ∀ {l ⊩⟨_⟩} → MaybeEmb l ⊩⟨_⟩ → ∃ λ l′ → ⊩⟨ l′ ⟩ extractMaybeEmb (noemb x) = _ , x extractMaybeEmb (emb 0<1 x) = extractMaybeEmb x -- A view for constructor equality of types where embeddings are ignored data ShapeView Γ : ∀ l l′ A B (p : Γ ⊩⟨ l ⟩ A) (q : Γ ⊩⟨ l′ ⟩ B) → Set where Uᵥ : ∀ {l l′} UA UB → ShapeView Γ l l′ U U (Uᵣ UA) (Uᵣ UB) ℕᵥ : ∀ {A B l l′} ℕA ℕB → ShapeView Γ l l′ A B (ℕᵣ ℕA) (ℕᵣ ℕB) Emptyᵥ : ∀ {A B l l′} EmptyA EmptyB → ShapeView Γ l l′ A B (Emptyᵣ EmptyA) (Emptyᵣ EmptyB) Unitᵥ : ∀ {A B l l′} UnitA UnitB → ShapeView Γ l l′ A B (Unitᵣ UnitA) (Unitᵣ UnitB) ne : ∀ {A B l l′} neA neB → ShapeView Γ l l′ A B (ne neA) (ne neB) Bᵥ : ∀ {A B l l′} W BA BB → ShapeView Γ l l′ A B (Bᵣ W BA) (Bᵣ W BB) emb⁰¹ : ∀ {A B l p q} → ShapeView Γ ⁰ l A B p q → ShapeView Γ ¹ l A B (emb 0<1 p) q emb¹⁰ : ∀ {A B l p q} → ShapeView Γ l ⁰ A B p q → ShapeView Γ l ¹ A B p (emb 0<1 q) -- Construct an shape view from an equality (aptly named) goodCases : ∀ {l l′ Γ A B} ([A] : Γ ⊩⟨ l ⟩ A) ([B] : Γ ⊩⟨ l′ ⟩ B) → Γ ⊩⟨ l ⟩ A ≡ B / [A] → ShapeView Γ l l′ A B [A] [B] -- Diagonal cases goodCases (Uᵣ UA) (Uᵣ UB) A≡B = Uᵥ UA UB goodCases (ℕᵣ ℕA) (ℕᵣ ℕB) A≡B = ℕᵥ ℕA ℕB goodCases (Emptyᵣ EmptyA) (Emptyᵣ EmptyB) A≡B = Emptyᵥ EmptyA EmptyB goodCases (Unitᵣ UnitA) (Unitᵣ UnitB) A≡B = Unitᵥ UnitA UnitB goodCases (ne neA) (ne neB) A≡B = ne neA neB goodCases (Bᵣ BΠ ΠA) (Bᵣ BΠ ΠB) A≡B = Bᵥ BΠ ΠA ΠB goodCases (Bᵣ BΣ ΣA) (Bᵣ BΣ ΣB) A≡B = Bᵥ BΣ ΣA ΣB --goodCases (Σᵣ ΣA) (Σᵣ ΣB) A≡B = Σᵥ ΣA ΣB goodCases {l} [A] (emb 0<1 x) A≡B = emb¹⁰ (goodCases {l} {⁰} [A] x A≡B) goodCases {l′ = l} (emb 0<1 x) [B] A≡B = emb⁰¹ (goodCases {⁰} {l} x [B] A≡B) -- Refutable cases -- U ≡ _ goodCases (Uᵣ′ _ _ ⊢Γ) (ℕᵣ D) PE.refl with whnfRed* (red D) Uₙ ... | () goodCases (Uᵣ′ _ _ ⊢Γ) (Emptyᵣ D) PE.refl with whnfRed* (red D) Uₙ ... | () goodCases (Uᵣ′ _ _ ⊢Γ) (Unitᵣ D) PE.refl with whnfRed* (red D) Uₙ ... | () goodCases (Uᵣ′ _ _ ⊢Γ) (ne′ K D neK K≡K) PE.refl = ⊥-elim (U≢ne neK (whnfRed* (red D) Uₙ)) goodCases (Uᵣ′ _ _ ⊢Γ) (Bᵣ′ W F G D ⊢F ⊢G A≡A [F] [G] G-ext) PE.refl = ⊥-elim (U≢B W (whnfRed* (red D) Uₙ)) -- ℕ ≡ _ goodCases (ℕᵣ D) (Uᵣ ⊢Γ) A≡B with whnfRed* A≡B Uₙ ... | () goodCases (ℕᵣ _) (Emptyᵣ D') D with whrDet* (D , ℕₙ) (red D' , Emptyₙ) ... | () goodCases (ℕᵣ x) (Unitᵣ D') D with whrDet* (D , ℕₙ) (red D' , Unitₙ) ... | () goodCases (ℕᵣ D) (ne′ K D₁ neK K≡K) A≡B = ⊥-elim (ℕ≢ne neK (whrDet* (A≡B , ℕₙ) (red D₁ , ne neK))) goodCases (ℕᵣ D) (Bᵣ′ W F G D₁ ⊢F ⊢G A≡A [F] [G] G-ext) A≡B = ⊥-elim (ℕ≢B W (whrDet* (A≡B , ℕₙ) (red D₁ , ⟦ W ⟧ₙ))) -- Empty ≢ _ goodCases (Emptyᵣ D) (Uᵣ ⊢Γ) A≡B with whnfRed* A≡B Uₙ ... | () goodCases (Emptyᵣ _) (Unitᵣ D') D with whrDet* (red D' , Unitₙ) (D , Emptyₙ) ... | () goodCases (Emptyᵣ _) (ℕᵣ D') D with whrDet* (red D' , ℕₙ) (D , Emptyₙ) ... | () goodCases (Emptyᵣ D) (ne′ K D₁ neK K≡K) A≡B = ⊥-elim (Empty≢ne neK (whrDet* (A≡B , Emptyₙ) (red D₁ , ne neK))) goodCases (Emptyᵣ D) (Bᵣ′ W F G D₁ ⊢F ⊢G A≡A [F] [G] G-ext) A≡B = ⊥-elim (Empty≢B W (whrDet* (A≡B , Emptyₙ) (red D₁ , ⟦ W ⟧ₙ))) -- Unit ≡ _ goodCases (Unitᵣ _) (Uᵣ x₁) A≡B with whnfRed* A≡B Uₙ ... | () goodCases (Unitᵣ _) (Emptyᵣ D') D with whrDet* (red D' , Emptyₙ) (D , Unitₙ) ... | () goodCases (Unitᵣ _) (ℕᵣ D') D with whrDet* (red D' , ℕₙ) (D , Unitₙ) ... | () goodCases (Unitᵣ D) (ne′ K D₁ neK K≡K) A≡B = ⊥-elim (Unit≢ne neK (whrDet* (A≡B , Unitₙ) (red D₁ , ne neK))) goodCases (Unitᵣ D) (Bᵣ′ W F G D₁ ⊢F ⊢G A≡A [F] [G] G-ext) A≡B = ⊥-elim (Unit≢B W (whrDet* (A≡B , Unitₙ) (red D₁ , ⟦ W ⟧ₙ))) -- ne ≡ _ goodCases (ne′ K D neK K≡K) (Uᵣ ⊢Γ) (ne₌ M D′ neM K≡M) = ⊥-elim (U≢ne neM (whnfRed* (red D′) Uₙ)) goodCases (ne′ K D neK K≡K) (ℕᵣ D₁) (ne₌ M D′ neM K≡M) = ⊥-elim (ℕ≢ne neM (whrDet* (red D₁ , ℕₙ) (red D′ , ne neM))) goodCases (ne′ K D neK K≡K) (Emptyᵣ D₁) (ne₌ M D′ neM K≡M) = ⊥-elim (Empty≢ne neM (whrDet* (red D₁ , Emptyₙ) (red D′ , ne neM))) goodCases (ne′ K D neK K≡K) (Unitᵣ D₁) (ne₌ M D′ neM K≡M) = ⊥-elim (Unit≢ne neM (whrDet* (red D₁ , Unitₙ) (red D′ , ne neM))) goodCases (ne′ K D neK K≡K) (Bᵣ′ W F G D₁ ⊢F ⊢G A≡A [F] [G] G-ext) (ne₌ M D′ neM K≡M) = ⊥-elim (B≢ne W neM (whrDet* (red D₁ , ⟦ W ⟧ₙ) (red D′ , ne neM))) -- Π ≡ _ goodCases (Bᵣ′ BΠ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Uᵣ ⊢Γ) (B₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) with whnfRed* D′ Uₙ ... | () goodCases (Bᵣ′ BΠ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (ℕᵣ D₁) (B₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) with whrDet* (red D₁ , ℕₙ) (D′ , Πₙ) ... | () goodCases (Bᵣ′ BΠ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Emptyᵣ D₁) (B₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) with whrDet* (red D₁ , Emptyₙ) (D′ , Πₙ) ... | () goodCases (Bᵣ′ BΠ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Unitᵣ D₁) (B₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) with whrDet* (red D₁ , Unitₙ) (D′ , Πₙ) ... | () goodCases (Bᵣ′ BΠ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Bᵣ′ BΣ F′ G′ D′ ⊢F′ ⊢G′ A≡A′ [F]′ [G]′ G-ext′) (B₌ F′₁ G′₁ D′₁ A≡B [F≡F′] [G≡G′]) with whrDet* (red D′ , Σₙ) (D′₁ , Πₙ) ... | () goodCases (Bᵣ′ BΠ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (ne′ K D₁ neK K≡K) (B₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = ⊥-elim (B≢ne BΠ neK (whrDet* (D′ , Πₙ) (red D₁ , ne neK))) -- Σ ≡ _ goodCases (Bᵣ′ BΣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Uᵣ ⊢Γ) (B₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) with whnfRed* D′ Uₙ ... | () goodCases (Bᵣ′ BΣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (ℕᵣ D₁) (B₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) with whrDet* (red D₁ , ℕₙ) (D′ , Σₙ) ... | () goodCases (Bᵣ′ BΣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Emptyᵣ D₁) (B₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) with whrDet* (red D₁ , Emptyₙ) (D′ , Σₙ) ... | () goodCases (Bᵣ′ BΣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Unitᵣ D₁) (B₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) with whrDet* (red D₁ , Unitₙ) (D′ , Σₙ) ... | () goodCases (Bᵣ′ BΣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (Bᵣ′ BΠ F′ G′ D′ ⊢F′ ⊢G′ A≡A′ [F]′ [G]′ G-ext′) (B₌ F′₁ G′₁ D′₁ A≡B [F≡F′] [G≡G′]) with whrDet* (red D′ , Πₙ) (D′₁ , Σₙ) ... | () goodCases (Bᵣ′ BΣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) (ne′ K D₁ neK K≡K) (B₌ F′ G′ D′ A≡B [F≡F′] [G≡G′]) = ⊥-elim (B≢ne BΣ neK (whrDet* (D′ , Σₙ) (red D₁ , ne neK))) -- Construct an shape view between two derivations of the same type goodCasesRefl : ∀ {l l′ Γ A} ([A] : Γ ⊩⟨ l ⟩ A) ([A′] : Γ ⊩⟨ l′ ⟩ A) → ShapeView Γ l l′ A A [A] [A′] goodCasesRefl [A] [A′] = goodCases [A] [A′] (reflEq [A]) -- A view for constructor equality between three types data ShapeView₃ Γ : ∀ l l′ l″ A B C (p : Γ ⊩⟨ l ⟩ A) (q : Γ ⊩⟨ l′ ⟩ B) (r : Γ ⊩⟨ l″ ⟩ C) → Set where Uᵥ : ∀ {l l′ l″} UA UB UC → ShapeView₃ Γ l l′ l″ U U U (Uᵣ UA) (Uᵣ UB) (Uᵣ UC) ℕᵥ : ∀ {A B C l l′ l″} ℕA ℕB ℕC → ShapeView₃ Γ l l′ l″ A B C (ℕᵣ ℕA) (ℕᵣ ℕB) (ℕᵣ ℕC) Emptyᵥ : ∀ {A B C l l′ l″} EmptyA EmptyB EmptyC → ShapeView₃ Γ l l′ l″ A B C (Emptyᵣ EmptyA) (Emptyᵣ EmptyB) (Emptyᵣ EmptyC) Unitᵥ : ∀ {A B C l l′ l″} UnitA UnitB UnitC → ShapeView₃ Γ l l′ l″ A B C (Unitᵣ UnitA) (Unitᵣ UnitB) (Unitᵣ UnitC) ne : ∀ {A B C l l′ l″} neA neB neC → ShapeView₃ Γ l l′ l″ A B C (ne neA) (ne neB) (ne neC) Bᵥ : ∀ {A B C l l′ l″} W BA BB BC → ShapeView₃ Γ l l′ l″ A B C (Bᵣ W BA) (Bᵣ W BB) (Bᵣ W BC) emb⁰¹¹ : ∀ {A B C l l′ p q r} → ShapeView₃ Γ ⁰ l l′ A B C p q r → ShapeView₃ Γ ¹ l l′ A B C (emb 0<1 p) q r emb¹⁰¹ : ∀ {A B C l l′ p q r} → ShapeView₃ Γ l ⁰ l′ A B C p q r → ShapeView₃ Γ l ¹ l′ A B C p (emb 0<1 q) r emb¹¹⁰ : ∀ {A B C l l′ p q r} → ShapeView₃ Γ l l′ ⁰ A B C p q r → ShapeView₃ Γ l l′ ¹ A B C p q (emb 0<1 r) -- Combines two two-way views into a three-way view combine : ∀ {Γ l l′ l″ l‴ A B C [A] [B] [B]′ [C]} → ShapeView Γ l l′ A B [A] [B] → ShapeView Γ l″ l‴ B C [B]′ [C] → ShapeView₃ Γ l l′ l‴ A B C [A] [B] [C] -- Diagonal cases combine (Uᵥ UA₁ UB₁) (Uᵥ UA UB) = Uᵥ UA₁ UB₁ UB combine (ℕᵥ ℕA₁ ℕB₁) (ℕᵥ ℕA ℕB) = ℕᵥ ℕA₁ ℕB₁ ℕB combine (Emptyᵥ EmptyA₁ EmptyB₁) (Emptyᵥ EmptyA EmptyB) = Emptyᵥ EmptyA₁ EmptyB₁ EmptyB combine (Unitᵥ UnitA₁ UnitB₁) (Unitᵥ UnitA UnitB) = Unitᵥ UnitA₁ UnitB₁ UnitB combine (ne neA₁ neB₁) (ne neA neB) = ne neA₁ neB₁ neB combine (Bᵥ BΠ ΠA₁ ΠB₁) (Bᵥ BΠ ΠA ΠB) = Bᵥ BΠ ΠA₁ ΠB₁ ΠB combine (Bᵥ BΣ ΣA₁ ΣB₁) (Bᵥ BΣ ΣA ΣB) = Bᵥ BΣ ΣA₁ ΣB₁ ΣB combine (emb⁰¹ [AB]) [BC] = emb⁰¹¹ (combine [AB] [BC]) combine (emb¹⁰ [AB]) [BC] = emb¹⁰¹ (combine [AB] [BC]) combine [AB] (emb⁰¹ [BC]) = combine [AB] [BC] combine [AB] (emb¹⁰ [BC]) = emb¹¹⁰ (combine [AB] [BC]) -- Refutable cases -- U ≡ _ combine (Uᵥ UA UB) (ℕᵥ ℕA ℕB) with whnfRed* (red ℕA) Uₙ ... | () combine (Uᵥ UA UB) (Emptyᵥ EmptyA EmptyB) with whnfRed* (red EmptyA) Uₙ ... | () combine (Uᵥ UA UB) (Unitᵥ UnA UnB) with whnfRed* (red UnA) Uₙ ... | () combine (Uᵥ UA UB) (ne (ne K D neK K≡K) neB) = ⊥-elim (U≢ne neK (whnfRed* (red D) Uₙ)) combine (Uᵥ UA UB) (Bᵥ W (Bᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) BB) = ⊥-elim (U≢B W (whnfRed* (red D) Uₙ)) -- ℕ ≡ _ combine (ℕᵥ ℕA ℕB) (Uᵥ UA UB) with whnfRed* (red ℕB) Uₙ ... | () combine (ℕᵥ ℕA ℕB) (Emptyᵥ EmptyA EmptyB) with whrDet* (red ℕB , ℕₙ) (red EmptyA , Emptyₙ) ... | () combine (ℕᵥ ℕA ℕB) (Unitᵥ UnA UnB) with whrDet* (red ℕB , ℕₙ) (red UnA , Unitₙ) ... | () combine (ℕᵥ ℕA ℕB) (ne (ne K D neK K≡K) neB) = ⊥-elim (ℕ≢ne neK (whrDet* (red ℕB , ℕₙ) (red D , ne neK))) combine (ℕᵥ ℕA ℕB) (Bᵥ W (Bᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) BB) = ⊥-elim (ℕ≢B W (whrDet* (red ℕB , ℕₙ) (red D , ⟦ W ⟧ₙ))) -- Empty ≡ _ combine (Emptyᵥ EmptyA EmptyB) (Uᵥ UA UB) with whnfRed* (red EmptyB) Uₙ ... | () combine (Emptyᵥ EmptyA EmptyB) (ℕᵥ ℕA ℕB) with whrDet* (red EmptyB , Emptyₙ) (red ℕA , ℕₙ) ... | () combine (Emptyᵥ EmptyA EmptyB) (Unitᵥ UnA UnB) with whrDet* (red EmptyB , Emptyₙ) (red UnA , Unitₙ) ... | () combine (Emptyᵥ EmptyA EmptyB) (ne (ne K D neK K≡K) neB) = ⊥-elim (Empty≢ne neK (whrDet* (red EmptyB , Emptyₙ) (red D , ne neK))) combine (Emptyᵥ EmptyA EmptyB) (Bᵥ W (Bᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) BB) = ⊥-elim (Empty≢B W (whrDet* (red EmptyB , Emptyₙ) (red D , ⟦ W ⟧ₙ))) -- Unit ≡ _ combine (Unitᵥ UnitA UnitB) (Uᵥ UA UB) with whnfRed* (red UnitB) Uₙ ... | () combine (Unitᵥ UnitA UnitB) (ℕᵥ ℕA ℕB) with whrDet* (red UnitB , Unitₙ) (red ℕA , ℕₙ) ... | () combine (Unitᵥ UnitA UnitB) (Emptyᵥ EmptyA EmptyB) with whrDet* (red UnitB , Unitₙ) (red EmptyA , Emptyₙ) ... | () combine (Unitᵥ UnitA UnitB) (ne (ne K D neK K≡K) neB) = ⊥-elim (Unit≢ne neK (whrDet* (red UnitB , Unitₙ) (red D , ne neK))) combine (Unitᵥ UnitA UnitB) (Bᵥ W (Bᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext) BB) = ⊥-elim (Unit≢B W (whrDet* (red UnitB , Unitₙ) (red D , ⟦ W ⟧ₙ))) -- ne ≡ _ combine (ne neA (ne K D neK K≡K)) (Uᵥ UA UB) = ⊥-elim (U≢ne neK (whnfRed* (red D) Uₙ)) combine (ne neA (ne K D neK K≡K)) (ℕᵥ ℕA ℕB) = ⊥-elim (ℕ≢ne neK (whrDet* (red ℕA , ℕₙ) (red D , ne neK))) combine (ne neA (ne K D neK K≡K)) (Emptyᵥ EmptyA EmptyB) = ⊥-elim (Empty≢ne neK (whrDet* (red EmptyA , Emptyₙ) (red D , ne neK))) combine (ne neA (ne K D neK K≡K)) (Unitᵥ UnA UnB) = ⊥-elim (Unit≢ne neK (whrDet* (red UnA , Unitₙ) (red D , ne neK))) combine (ne neA (ne K D neK K≡K)) (Bᵥ W (Bᵣ F G D₁ ⊢F ⊢G A≡A [F] [G] G-ext) BB) = ⊥-elim (B≢ne W neK (whrDet* (red D₁ , ⟦ W ⟧ₙ) (red D , ne neK))) -- Π/Σ ≡ _ combine (Bᵥ W BA (Bᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext)) (Uᵥ UA UB) = ⊥-elim (U≢B W (whnfRed* (red D) Uₙ)) combine (Bᵥ W BA (Bᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext)) (ℕᵥ ℕA ℕB) = ⊥-elim (ℕ≢B W (whrDet* (red ℕA , ℕₙ) (red D , ⟦ W ⟧ₙ))) combine (Bᵥ W BA (Bᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext)) (Emptyᵥ EmptyA EmptyB) = ⊥-elim (Empty≢B W (whrDet* (red EmptyA , Emptyₙ) (red D , ⟦ W ⟧ₙ))) combine (Bᵥ W BA (Bᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext)) (Unitᵥ UnitA UnitB) = ⊥-elim (Unit≢B W (whrDet* (red UnitA , Unitₙ) (red D , ⟦ W ⟧ₙ))) combine (Bᵥ W BA (Bᵣ F G D₁ ⊢F ⊢G A≡A [F] [G] G-ext)) (ne (ne K D neK K≡K) neB) = ⊥-elim (B≢ne W neK (whrDet* (red D₁ , ⟦ W ⟧ₙ) (red D , ne neK))) combine (Bᵥ BΠ ΠA (Bᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext)) (Bᵥ BΣ (Bᵣ F′ G′ D′ ⊢F′ ⊢G′ A≡A′ [F]′ [G]′ G-ext′) ΣA) with whrDet* (red D , Πₙ) (red D′ , Σₙ) ... | () combine (Bᵥ BΣ ΣA (Bᵣ F G D ⊢F ⊢G A≡A [F] [G] G-ext)) (Bᵥ BΠ (Bᵣ F′ G′ D′ ⊢F′ ⊢G′ A≡A′ [F]′ [G]′ G-ext′) ΠA) with whrDet* (red D , Σₙ) (red D′ , Πₙ) ... | ()
{ "alphanum_fraction": 0.528692907, "avg_line_length": 42.5086580087, "ext": "agda", "hexsha": "a360e70f81bac7783c817df940b6a1dc9e17865d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Vtec234/logrel-mltt", "max_forks_repo_path": "Definition/LogicalRelation/ShapeView.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Vtec234/logrel-mltt", "max_issues_repo_path": "Definition/LogicalRelation/ShapeView.agda", "max_line_length": 108, "max_stars_count": null, "max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Vtec234/logrel-mltt", "max_stars_repo_path": "Definition/LogicalRelation/ShapeView.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 11070, "size": 19639 }
open import Prelude hiding (id; Bool; _∷_; []) module Examples.PartialResolution where data TC : Set where tc-int : TC tc-bool : TC _tc≟_ : (a b : TC) → Dec (a ≡ b) tc-int tc≟ tc-int = yes refl tc-int tc≟ tc-bool = no (λ ()) tc-bool tc≟ tc-int = no (λ ()) tc-bool tc≟ tc-bool = yes refl open import Implicits.Syntax open import Implicits.WellTyped open import Implicits.Substitutions open import Implicits.Syntax.Type.Unification open import Implicits.Resolution.Infinite.Algorithm open import Data.Maybe open import Data.List open import Category.Monad.Partiality Bool : ∀ {n} → Type n Bool = simpl (tc tc-bool) Int : ∀ {n} → Type n Int = simpl (tc tc-int) module Ex₁ where Δ : ICtx zero Δ = Bool ∷ Int ∷ [] -- resolves directly using a value from the implicit context r = run_for_steps (resolve Δ Int) 10 p : isNow r ≡ true p = refl module Ex₂ where Δ : ICtx zero Δ = Bool ∷ (Bool ⇒ Int) ∷ [] -- resolves using implicit application r = run_for_steps (resolve Δ Int) 10 p : r resolved? ≡ true p = refl module Ex₃ where Δ : ICtx zero Δ = Bool ∷ (∀' (Bool ⇒ (simpl (tvar zero)))) ∷ [] -- resolves using polymorphic appliation + implicit application r = run_for_steps (resolve Δ Int) 10 p : r resolved? ≡ true p = refl module Ex₄ where Δ : ICtx zero Δ = Bool ∷ (∀' ((simpl (tvar zero)) ⇒ Int)) ∷ [] r = run_for_steps (resolve Δ Int) 10 -- Maybe surprisingly this fails. -- But we should note that unification on the codomain of the rule does not fix the domain to a -- concrete type, such that it's instantiation is left ambiguous. -- Like Oliveira we reject those rules, because they lead to ambiguous terms. p : r failed? ≡ true p = refl module Ex₅ where -- The following context would not resolved Int in Oliveira's deterministic calculus. -- Demonstratint that partial resolution is more powerful for terminating contexts. Δ : ICtx zero Δ = (Bool ⇒ Int) ∷ Int ∷ [] r = run_for_steps (resolve Δ Int) 10 p : r resolved? ≡ true p = refl module Ex₆ where Δ : ICtx zero Δ = Bool ∷ (∀' (Bool ⇒ (simpl (tvar zero)))) ∷ [] -- resolves rule types r = run_for_steps (resolve Δ (Bool ⇒ Int)) 10 p : r resolved? ≡ true p = refl module Ex₇ where Δ : ICtx zero Δ = Bool ∷ (∀' (Bool ⇒ (simpl (tvar zero)))) ∷ [] q : Type zero q = (∀' (Bool ⇒ (simpl (tvar zero)))) -- Resolves polymorphic types. -- Note that it doesn't resolve to the rule in the context directly. -- Instead, it will apply r-tabs and r-iabs, to obtain resolve Δ' ⊢ᵣ (∀' (tvar zero)) r = run_for_steps (resolve Δ q) 10 p : r resolved? ≡ true p = refl module Ex₈ where Δ : ICtx zero Δ = Bool ∷ (∀' ((simpl (tvar zero)) ⇒ (simpl (tvar zero)))) ∷ [] -- infinite derivation exists: not decidable r = run_for_steps (resolve Δ Int) 10 p : r resolved? ≡ false p = refl ¬p : r failed? ≡ false ¬p = refl module Ex₉ where Δ : ICtx zero Δ = (∀' ((Int ⇒ simpl (tvar zero)) ⇒ ((simpl (tvar zero)) ⇒ Int))) ∷ (Int ⇒ Bool) ∷ [] r = run_for_steps (resolve Δ (Bool ⇒ Int)) 10 p : r resolved? ≡ false p = refl ¬p : r failed? ≡ true ¬p = refl -- Below p' demonstrates however that a derivation exists! -- The algorithm doesn't find it because we left the ⊢unamb predicate from oliveira implicit. -- at some point the algorithm has to match ((simpl (mvar zero) ⇒ Int)) with Int. -- However, when we match the codomain Int with the goal Int (note the open mvar): test : mgu {m = suc zero} {ν = zero} (to-meta Int) (tc tc-int) ≡ nothing test = refl -- Because mgu requires that all meta variables are instantiated by unification -- and in this example (mvar zero) does not occur and thus can't be unified. open import Implicits.Resolution.Infinite.Resolution open import Coinduction p' : Δ ⊢ᵣ (Bool ⇒ Int) p' = r-iabs (r-simp (there (here refl)) (i-tabs (simpl (tc tc-bool)) (i-iabs (♯ (r-iabs (r-simp (there (here refl)) (i-simp (tc tc-bool))))) (i-iabs (♯ (r-simp (here refl) (i-simp (tc tc-bool)))) (i-simp (tc tc-int))) ) ) )
{ "alphanum_fraction": 0.6364515349, "avg_line_length": 24.7724550898, "ext": "agda", "hexsha": "ba2623722cdb288ec77237c0845d6635e95df344", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "metaborg/ts.agda", "max_forks_repo_path": "src/Examples/PartialResolution.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "metaborg/ts.agda", "max_issues_repo_path": "src/Examples/PartialResolution.agda", "max_line_length": 97, "max_stars_count": 4, "max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "metaborg/ts.agda", "max_stars_repo_path": "src/Examples/PartialResolution.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 1337, "size": 4137 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties of operations on characters ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Data.Char.Properties where open import Data.Bool using (Bool) open import Data.Char.Base import Data.Nat.Properties as ℕₚ open import Function open import Relation.Nullary using (yes; no) open import Relation.Nullary.Decidable using (map′; ⌊_⌋) open import Relation.Binary using (Decidable; Setoid; DecSetoid; StrictTotalOrder) open import Relation.Binary.PropositionalEquality.Core import Relation.Binary.Construct.On as On import Relation.Binary.PropositionalEquality as PropEq ------------------------------------------------------------------------ -- Primitive properties open import Agda.Builtin.Char.Properties renaming ( primCharToNatInjective to toNat-injective) public ------------------------------------------------------------------------ -- Decidable equality infix 4 _≟_ _≟_ : Decidable {A = Char} _≡_ x ≟ y = map′ (toNat-injective x y) (cong toNat) $ toNat x ℕₚ.≟ toNat y ------------------------------------------------------------------------ -- Boolean equality test. -- -- Why is the definition _==_ = primCharEquality not used? One reason -- is that the present definition can sometimes improve type -- inference, at least with the version of Agda that is current at the -- time of writing: see unit-test below. infix 4 _==_ _==_ : Char → Char → Bool c₁ == c₂ = ⌊ c₁ ≟ c₂ ⌋ private -- The following unit test does not type-check (at the time of -- writing) if _==_ is replaced by primCharEquality. data P : (Char → Bool) → Set where p : (c : Char) → P (c ==_) unit-test : P ('x' ==_) unit-test = p _ ------------------------------------------------------------------------ -- Structures setoid : Setoid _ _ setoid = PropEq.setoid Char decSetoid : DecSetoid _ _ decSetoid = PropEq.decSetoid _≟_ strictTotalOrder : StrictTotalOrder _ _ _ strictTotalOrder = On.strictTotalOrder ℕₚ.<-strictTotalOrder toNat
{ "alphanum_fraction": 0.5784037559, "avg_line_length": 29.1780821918, "ext": "agda", "hexsha": "916bb092872b632d370e1b6293785caf582a1e8b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Char/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Data/Char/Properties.agda", "max_line_length": 82, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Char/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 494, "size": 2130 }
-- This module is copied from Agda's standard library. It has been -- renamed (original name is Size) to avoid name clash in case you -- have the standard library installed. ------------------------------------------------------------------------ -- The Agda standard library -- -- Sizes for Agda's sized types ------------------------------------------------------------------------ module Sized where postulate Size : Set ↑_ : Size → Size ∞ : Size {-# BUILTIN SIZE Size #-} {-# BUILTIN SIZESUC ↑_ #-} {-# BUILTIN SIZEINF ∞ #-}
{ "alphanum_fraction": 0.481884058, "avg_line_length": 26.2857142857, "ext": "agda", "hexsha": "93d4942e5bc3c881b0d55e4ae96acc7a10d5eb09", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "jstolarek/dep-typed-wbl-heaps", "max_forks_repo_path": "src/Sized.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "jstolarek/dep-typed-wbl-heaps", "max_issues_repo_path": "src/Sized.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "57db566cb840dc70331c29eb7bf3a0c849f8b27e", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "jstolarek/dep-typed-wbl-heaps", "max_stars_repo_path": "src/Sized.agda", "max_stars_repo_stars_event_max_datetime": "2018-05-02T21:48:43.000Z", "max_stars_repo_stars_event_min_datetime": "2018-05-02T21:48:43.000Z", "num_tokens": 114, "size": 552 }
{-# OPTIONS --safe #-} module Cubical.HITs.Sn.Properties where open import Cubical.Foundations.Pointed open import Cubical.Foundations.Path open import Cubical.Foundations.Function open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Transport open import Cubical.Foundations.Prelude open import Cubical.Foundations.GroupoidLaws open import Cubical.Foundations.Univalence open import Cubical.HITs.S1 renaming (_·_ to _*_) open import Cubical.HITs.S2 open import Cubical.HITs.S3 open import Cubical.Data.Nat hiding (elim) open import Cubical.Data.Sigma open import Cubical.HITs.Sn.Base open import Cubical.HITs.Susp renaming (toSusp to σ) open import Cubical.HITs.Truncation open import Cubical.Homotopy.Connected open import Cubical.HITs.Join renaming (joinS¹S¹→S³ to joinS¹S¹→S3) open import Cubical.Data.Bool private variable ℓ : Level open Iso IsoSucSphereSusp : (n : ℕ) → Iso (S₊ (suc n)) (Susp (S₊ n)) IsoSucSphereSusp zero = S¹IsoSuspBool IsoSucSphereSusp (suc n) = idIso IsoSucSphereSusp∙ : (n : ℕ) → Iso.inv (IsoSucSphereSusp n) north ≡ ptSn (suc n) IsoSucSphereSusp∙ zero = refl IsoSucSphereSusp∙ (suc n) = refl -- Elimination principles for spheres sphereElim : (n : ℕ) {A : (S₊ (suc n)) → Type ℓ} → ((x : S₊ (suc n)) → isOfHLevel (suc n) (A x)) → A (ptSn (suc n)) → (x : S₊ (suc n)) → A x sphereElim zero hlev pt = toPropElim hlev pt sphereElim (suc n) hlev pt north = pt sphereElim (suc n) {A = A} hlev pt south = subst A (merid (ptSn (suc n))) pt sphereElim (suc n) {A = A} hlev pt (merid a i) = sphereElim n {A = λ a → PathP (λ i → A (merid a i)) pt (subst A (merid (ptSn (suc n))) pt)} (λ a → isOfHLevelPathP' (suc n) (hlev south) _ _) (λ i → transp (λ j → A (merid (ptSn (suc n)) (i ∧ j))) (~ i) pt) a i sphereElim2 : ∀ {ℓ} (n : ℕ) {A : (S₊ (suc n)) → (S₊ (suc n)) → Type ℓ} → ((x y : S₊ (suc n)) → isOfHLevel (suc n) (A x y)) → A (ptSn (suc n)) (ptSn (suc n)) → (x y : S₊ (suc n)) → A x y sphereElim2 n hlev pt = sphereElim n (λ _ → isOfHLevelΠ (suc n) λ _ → hlev _ _) (sphereElim n (hlev _ ) pt) private compPath-lem : ∀ {ℓ} {A : Type ℓ} {x y z : A} (p : x ≡ y) (q : z ≡ y) → PathP (λ i → (p ∙ sym q) i ≡ y) p q compPath-lem {y = y} p q i j = hcomp (λ k → λ { (i = i0) → p j ; (i = i1) → q (~ k ∨ j) ; (j = i1) → y }) (p (j ∨ i)) sphereToPropElim : (n : ℕ) {A : (S₊ (suc n)) → Type ℓ} → ((x : S₊ (suc n)) → isProp (A x)) → A (ptSn (suc n)) → (x : S₊ (suc n)) → A x sphereToPropElim zero = toPropElim sphereToPropElim (suc n) hlev pt north = pt sphereToPropElim (suc n) {A = A} hlev pt south = subst A (merid (ptSn (suc n))) pt sphereToPropElim (suc n) {A = A} hlev pt (merid a i) = isProp→PathP {B = λ i → A (merid a i)} (λ _ → hlev _) pt (subst A (merid (ptSn (suc n))) pt) i -- Elimination rule for fibrations (x : Sⁿ) → (y : Sᵐ) → A x y of h-Level (n + m). -- The following principle is just the special case of the "Wedge Connectivity Lemma" -- for spheres (See Cubical.Homotopy.WedgeConnectivity or chapter 8.6 in the HoTT book). -- We prove it directly here for three reasons: -- (i) it should perform better -- (ii) we get a slightly stronger statement for spheres: one of the homotopies will, by design, be refl -- (iii) the fact that the two homotopies only differ by (composition with) the homotopy leftFunction(base) ≡ rightFunction(base) -- is close to trivial wedgeconFun : (n m : ℕ) {A : (S₊ (suc n)) → (S₊ (suc m)) → Type ℓ} → ((x : S₊ (suc n)) (y : S₊ (suc m)) → isOfHLevel ((suc n) + (suc m)) (A x y)) → (f : (x : _) → A (ptSn (suc n)) x) → (g : (x : _) → A x (ptSn (suc m))) → (g (ptSn (suc n)) ≡ f (ptSn (suc m))) → (x : S₊ (suc n)) (y : S₊ (suc m)) → A x y wedgeconLeft : (n m : ℕ) {A : (S₊ (suc n)) → (S₊ (suc m)) → Type ℓ} → (hLev : ((x : S₊ (suc n)) (y : S₊ (suc m)) → isOfHLevel ((suc n) + (suc m)) (A x y))) → (f : (x : _) → A (ptSn (suc n)) x) → (g : (x : _) → A x (ptSn (suc m))) → (hom : g (ptSn (suc n)) ≡ f (ptSn (suc m))) → (x : _) → wedgeconFun n m hLev f g hom (ptSn (suc n)) x ≡ f x wedgeconRight : (n m : ℕ) {A : (S₊ (suc n)) → (S₊ (suc m)) → Type ℓ} → (hLev : ((x : S₊ (suc n)) (y : S₊ (suc m)) → isOfHLevel ((suc n) + (suc m)) (A x y))) → (f : (x : _) → A (ptSn (suc n)) x) → (g : (x : _) → A x (ptSn (suc m))) → (hom : g (ptSn (suc n)) ≡ f (ptSn (suc m))) → (x : _) → wedgeconFun n m hLev f g hom x (ptSn (suc m)) ≡ g x wedgeconFun zero zero {A = A} hlev f g hom = F where helper : SquareP (λ i j → A (loop i) (loop j)) (cong f loop) (cong f loop) (λ i → hcomp (λ k → λ { (i = i0) → hom k ; (i = i1) → hom k }) (g (loop i))) λ i → hcomp (λ k → λ { (i = i0) → hom k ; (i = i1) → hom k }) (g (loop i)) helper = toPathP (isOfHLevelPathP' 1 (hlev _ _) _ _ _ _) F : (x y : S¹) → A x y F base y = f y F (loop i) base = hcomp (λ k → λ { (i = i0) → hom k ; (i = i1) → hom k }) (g (loop i)) F (loop i) (loop j) = helper i j wedgeconFun zero (suc m) {A = A} hlev f g hom = F₀ module _ where transpLemma₀ : (x : S₊ (suc m)) → transport (λ i₁ → A base (merid x i₁)) (g base) ≡ f south transpLemma₀ x = cong (transport (λ i₁ → A base (merid x i₁))) hom ∙ (λ i → transp (λ j → A base (merid x (i ∨ j))) i (f (merid x i))) pathOverMerid₀ : (x : S₊ (suc m)) → PathP (λ i₁ → A base (merid x i₁)) (g base) (transport (λ i₁ → A base (merid (ptSn (suc m)) i₁)) (g base)) pathOverMerid₀ x i = hcomp (λ k → λ { (i = i0) → g base ; (i = i1) → (transpLemma₀ x ∙ sym (transpLemma₀ (ptSn (suc m)))) k}) (transp (λ i₁ → A base (merid x (i₁ ∧ i))) (~ i) (g base)) pathOverMeridId₀ : pathOverMerid₀ (ptSn (suc m)) ≡ λ i → transp (λ i₁ → A base (merid (ptSn (suc m)) (i₁ ∧ i))) (~ i) (g base) pathOverMeridId₀ = (λ j i → hcomp (λ k → λ {(i = i0) → g base ; (i = i1) → rCancel (transpLemma₀ (ptSn (suc m))) j k}) (transp (λ i₁ → A base (merid (ptSn (suc m)) (i₁ ∧ i))) (~ i) (g base))) ∙ λ j i → hfill (λ k → λ { (i = i0) → g base ; (i = i1) → transport (λ i₁ → A base (merid (ptSn (suc m)) i₁)) (g base)}) (inS (transp (λ i₁ → A base (merid (ptSn (suc m)) (i₁ ∧ i))) (~ i) (g base))) (~ j) indStep₀ : (x : _) (a : _) → PathP (λ i → A x (merid a i)) (g x) (subst (λ y → A x y) (merid (ptSn (suc m))) (g x)) indStep₀ = wedgeconFun zero m (λ _ _ → isOfHLevelPathP' (2 + m) (hlev _ _) _ _) pathOverMerid₀ (λ a i → transp (λ i₁ → A a (merid (ptSn (suc m)) (i₁ ∧ i))) (~ i) (g a)) (sym pathOverMeridId₀) F₀ : (x : S¹) (y : Susp (S₊ (suc m))) → A x y F₀ x north = g x F₀ x south = subst (λ y → A x y) (merid (ptSn (suc m))) (g x) F₀ x (merid a i) = indStep₀ x a i wedgeconFun (suc n) m {A = A} hlev f g hom = F₁ module _ where transpLemma₁ : (x : S₊ (suc n)) → transport (λ i₁ → A (merid x i₁) (ptSn (suc m))) (f (ptSn (suc m))) ≡ g south transpLemma₁ x = cong (transport (λ i₁ → A (merid x i₁) (ptSn (suc m)))) (sym hom) ∙ (λ i → transp (λ j → A (merid x (i ∨ j)) (ptSn (suc m))) i (g (merid x i))) pathOverMerid₁ : (x : S₊ (suc n)) → PathP (λ i₁ → A (merid x i₁) (ptSn (suc m))) (f (ptSn (suc m))) (transport (λ i₁ → A (merid (ptSn (suc n)) i₁) (ptSn (suc m))) (f (ptSn (suc m)))) pathOverMerid₁ x i = hcomp (λ k → λ { (i = i0) → f (ptSn (suc m)) ; (i = i1) → (transpLemma₁ x ∙ sym (transpLemma₁ (ptSn (suc n)))) k }) (transp (λ i₁ → A (merid x (i₁ ∧ i)) (ptSn (suc m))) (~ i) (f (ptSn (suc m)))) pathOverMeridId₁ : pathOverMerid₁ (ptSn (suc n)) ≡ λ i → transp (λ i₁ → A (merid (ptSn (suc n)) (i₁ ∧ i)) (ptSn (suc m))) (~ i) (f (ptSn (suc m))) pathOverMeridId₁ = (λ j i → hcomp (λ k → λ { (i = i0) → f (ptSn (suc m)) ; (i = i1) → rCancel (transpLemma₁ (ptSn (suc n))) j k }) (transp (λ i₁ → A (merid (ptSn (suc n)) (i₁ ∧ i)) (ptSn (suc m))) (~ i) (f (ptSn (suc m))))) ∙ λ j i → hfill (λ k → λ { (i = i0) → f (ptSn (suc m)) ; (i = i1) → transport (λ i₁ → A (merid (ptSn (suc n)) i₁) (ptSn (suc m))) (f (ptSn (suc m))) }) (inS (transp (λ i₁ → A (merid (ptSn (suc n)) (i₁ ∧ i)) (ptSn (suc m))) (~ i) (f (ptSn (suc m))))) (~ j) indStep₁ : (a : _) (y : _) → PathP (λ i → A (merid a i) y) (f y) (subst (λ x → A x y) (merid (ptSn (suc n))) (f y)) indStep₁ = wedgeconFun n m (λ _ _ → isOfHLevelPathP' (suc (n + suc m)) (hlev _ _) _ _) (λ a i → transp (λ i₁ → A (merid (ptSn (suc n)) (i₁ ∧ i)) a) (~ i) (f a)) pathOverMerid₁ pathOverMeridId₁ F₁ : (x : Susp (S₊ (suc n))) (y : S₊ (suc m)) → A x y F₁ north y = f y F₁ south y = subst (λ x → A x y) (merid (ptSn (suc n))) (f y) F₁ (merid a i) y = indStep₁ a y i wedgeconRight zero zero {A = A} hlev f g hom = right where right : (x : S¹) → _ right base = sym hom right (loop i) j = hcomp (λ k → λ { (i = i0) → hom (~ j ∧ k) ; (i = i1) → hom (~ j ∧ k) ; (j = i1) → g (loop i) }) (g (loop i)) wedgeconRight zero (suc m) {A = A} hlev f g hom x = refl wedgeconRight (suc n) m {A = A} hlev f g hom = right where lem : (x : _) → indStep₁ n m hlev f g hom x (ptSn (suc m)) ≡ _ lem = wedgeconRight n m (λ _ _ → isOfHLevelPathP' (suc (n + suc m)) (hlev _ _) _ _) (λ a i → transp (λ i₁ → A (merid (ptSn (suc n)) (i₁ ∧ i)) a) (~ i) (f a)) (pathOverMerid₁ n m hlev f g hom) (pathOverMeridId₁ n m hlev f g hom) right : (x : Susp (S₊ (suc n))) → _ ≡ g x right north = sym hom right south = cong (subst (λ x → A x (ptSn (suc m))) (merid (ptSn (suc n)))) (sym hom) ∙ λ i → transp (λ j → A (merid (ptSn (suc n)) (i ∨ j)) (ptSn (suc m))) i (g (merid (ptSn (suc n)) i)) right (merid a i) j = hcomp (λ k → λ { (i = i0) → hom (~ j) ; (i = i1) → transpLemma₁ n m hlev f g hom (ptSn (suc n)) j ; (j = i0) → lem a (~ k) i ; (j = i1) → g (merid a i)}) (hcomp (λ k → λ { (i = i0) → hom (~ j) ; (i = i1) → compPath-lem (transpLemma₁ n m hlev f g hom a) (transpLemma₁ n m hlev f g hom (ptSn (suc n))) k j ; (j = i1) → g (merid a i)}) (hcomp (λ k → λ { (i = i0) → hom (~ j) ; (j = i0) → transp (λ i₂ → A (merid a (i₂ ∧ i)) (ptSn (suc m))) (~ i) (f (ptSn (suc m))) ; (j = i1) → transp (λ j → A (merid a (i ∧ (j ∨ k))) (ptSn (suc m))) (k ∨ ~ i) (g (merid a (i ∧ k))) }) (transp (λ i₂ → A (merid a (i₂ ∧ i)) (ptSn (suc m))) (~ i) (hom (~ j))))) wedgeconLeft zero zero {A = A} hlev f g hom x = refl wedgeconLeft zero (suc m) {A = A} hlev f g hom = help where left₁ : (x : _) → indStep₀ m hlev f g hom base x ≡ _ left₁ = wedgeconLeft zero m (λ _ _ → isOfHLevelPathP' (2 + m) (hlev _ _) _ _) (pathOverMerid₀ m hlev f g hom) (λ a i → transp (λ i₁ → A a (merid (ptSn (suc m)) (i₁ ∧ i))) (~ i) (g a)) (sym (pathOverMeridId₀ m hlev f g hom)) help : (x : S₊ (suc (suc m))) → _ help north = hom help south = cong (subst (A base) (merid (ptSn (suc m)))) hom ∙ λ i → transp (λ j → A base (merid (ptSn (suc m)) (i ∨ j))) i (f (merid (ptSn (suc m)) i)) help (merid a i) j = hcomp (λ k → λ { (i = i0) → hom j ; (i = i1) → transpLemma₀ m hlev f g hom (ptSn (suc m)) j ; (j = i0) → left₁ a (~ k) i ; (j = i1) → f (merid a i)}) (hcomp (λ k → λ { (i = i0) → hom j ; (i = i1) → compPath-lem (transpLemma₀ m hlev f g hom a) (transpLemma₀ m hlev f g hom (ptSn (suc m))) k j ; (j = i1) → f (merid a i)}) (hcomp (λ k → λ { (i = i0) → hom j ; (j = i0) → transp (λ i₂ → A base (merid a (i₂ ∧ i))) (~ i) (g base) ; (j = i1) → transp (λ j → A base (merid a (i ∧ (j ∨ k)))) (k ∨ ~ i) (f (merid a (i ∧ k)))}) (transp (λ i₂ → A base (merid a (i₂ ∧ i))) (~ i) (hom j)))) wedgeconLeft (suc n) m {A = A} hlev f g hom _ = refl ---------- Connectedness ----------- sphereConnected : (n : HLevel) → isConnected (suc n) (S₊ n) sphereConnected n = ∣ ptSn n ∣ , elim (λ _ → isOfHLevelPath (suc n) (isOfHLevelTrunc (suc n)) _ _) (λ a → sym (spoke ∣_∣ (ptSn n)) ∙ spoke ∣_∣ a) -- The fact that path spaces of Sn are connected can be proved directly for Sⁿ. -- (Unfortunately, this does not work for higher paths) pathIdTruncSⁿ : (n : ℕ) (x y : S₊ (suc n)) → Path (hLevelTrunc (2 + n) (S₊ (suc n))) ∣ x ∣ ∣ y ∣ → hLevelTrunc (suc n) (x ≡ y) pathIdTruncSⁿ n = sphereElim n (λ _ → isOfHLevelΠ (suc n) λ _ → isOfHLevelΠ (suc n) λ _ → isOfHLevelTrunc (suc n)) (sphereElim n (λ _ → isOfHLevelΠ (suc n) λ _ → isOfHLevelTrunc (suc n)) λ _ → ∣ refl ∣) pathIdTruncSⁿ⁻ : (n : ℕ) (x y : S₊ (suc n)) → hLevelTrunc (suc n) (x ≡ y) → Path (hLevelTrunc (2 + n) (S₊ (suc n))) ∣ x ∣ ∣ y ∣ pathIdTruncSⁿ⁻ n x y = rec (isOfHLevelTrunc (2 + n) _ _) (J (λ y _ → Path (hLevelTrunc (2 + n) (S₊ (suc n))) ∣ x ∣ ∣ y ∣) refl) pathIdTruncSⁿretract : (n : ℕ) (x y : S₊ (suc n)) → (p : hLevelTrunc (suc n) (x ≡ y)) → pathIdTruncSⁿ n x y (pathIdTruncSⁿ⁻ n x y p) ≡ p pathIdTruncSⁿretract n = sphereElim n (λ _ → isOfHLevelΠ (suc n) λ _ → isOfHLevelΠ (suc n) λ _ → isOfHLevelPath (suc n) (isOfHLevelTrunc (suc n)) _ _) λ y → elim (λ _ → isOfHLevelPath (suc n) (isOfHLevelTrunc (suc n)) _ _) (J (λ y p → pathIdTruncSⁿ n (ptSn (suc n)) y (pathIdTruncSⁿ⁻ n (ptSn (suc n)) y ∣ p ∣) ≡ ∣ p ∣) (cong (pathIdTruncSⁿ n (ptSn (suc n)) (ptSn (suc n))) (transportRefl refl) ∙ pm-help n)) where pm-help : (n : ℕ) → pathIdTruncSⁿ n (ptSn (suc n)) (ptSn (suc n)) refl ≡ ∣ refl ∣ pm-help zero = refl pm-help (suc n) = refl isConnectedPathSⁿ : (n : ℕ) (x y : S₊ (suc n)) → isConnected (suc n) (x ≡ y) isConnectedPathSⁿ n x y = isContrRetract (pathIdTruncSⁿ⁻ n x y) (pathIdTruncSⁿ n x y) (pathIdTruncSⁿretract n x y) ((isContr→isProp (sphereConnected (suc n)) ∣ x ∣ ∣ y ∣) , isProp→isSet (isContr→isProp (sphereConnected (suc n))) _ _ _) -- Some lemmas on the H space structure on S¹ rUnitS¹ : (x : S¹) → x * base ≡ x rUnitS¹ base = refl rUnitS¹ (loop i₁) = refl commS¹ : (a x : S¹) → a * x ≡ x * a commS¹ = wedgeconFun _ _ (λ _ _ → isGroupoidS¹ _ _) (sym ∘ rUnitS¹) rUnitS¹ refl assocS¹ : (x y z : S¹) → x * (y * z) ≡ (x * y) * z assocS¹ = wedgeconFun _ _ (λ _ _ → isSetΠ λ _ → isGroupoidS¹ _ _) (λ _ _ → refl) (λ x z i → (rUnitS¹ x (~ i)) * z) refl invLooperDistr : (x y : S¹) → invLooper (x * y) ≡ invLooper x * invLooper y invLooperDistr = wedgeconFun 0 0 (λ _ _ → isGroupoidS¹ _ _) (λ _ → refl) (λ x → cong invLooper (rUnitS¹ x) ∙ sym (rUnitS¹ (invLooper x))) (sym (rUnit refl)) SuspS¹-hom : (a x : S¹) → Path (Path (hLevelTrunc 4 (S₊ 2)) _ _) (cong ∣_∣ₕ (σ (S₊∙ 1) (a * x))) (cong ∣_∣ₕ (σ (S₊∙ 1) a) ∙ (cong ∣_∣ₕ (σ (S₊∙ 1) x))) SuspS¹-hom = wedgeconFun _ _ (λ _ _ → isOfHLevelTrunc 4 _ _ _ _) (λ x → lUnit _ ∙ cong (_∙ cong ∣_∣ₕ (σ (S₊∙ 1) x)) (cong (cong ∣_∣ₕ) (sym (rCancel (merid base))))) (λ x → (λ i → cong ∣_∣ₕ (σ (S₊∙ 1) (rUnitS¹ x i))) ∙∙ rUnit _ ∙∙ cong (cong ∣_∣ₕ (σ (S₊∙ 1) x) ∙_) (cong (cong ∣_∣ₕ) (sym (rCancel (merid base))))) (sym (l (cong ∣_∣ₕ (σ (S₊∙ 1) base)) (cong (cong ∣_∣ₕ) (sym (rCancel (merid base)))))) where l : ∀ {ℓ} {A : Type ℓ} {x : A} (p : x ≡ x) (P : refl ≡ p) → lUnit p ∙ cong (_∙ p) P ≡ rUnit p ∙ cong (p ∙_) P l p = J (λ p P → lUnit p ∙ cong (_∙ p) P ≡ rUnit p ∙ cong (p ∙_) P) refl rCancelS¹ : (x : S¹) → ptSn 1 ≡ x * (invLooper x) rCancelS¹ base = refl rCancelS¹ (loop i) j = hcomp (λ r → λ {(i = i0) → base ; (i = i1) → base ; (j = i0) → base}) base SuspS¹-inv : (x : S¹) → Path (Path (hLevelTrunc 4 (S₊ 2)) _ _) (cong ∣_∣ₕ (σ (S₊∙ 1) (invLooper x))) (cong ∣_∣ₕ (sym (σ (S₊∙ 1) x))) SuspS¹-inv x = (lUnit _ ∙∙ cong (_∙ cong ∣_∣ₕ (σ (S₊∙ 1) (invLooper x))) (sym (lCancel (cong ∣_∣ₕ (σ (S₊∙ 1) x)))) ∙∙ sym (assoc _ _ _)) ∙∙ cong (sym (cong ∣_∣ₕ (σ (S₊∙ 1) x)) ∙_) lem ∙∙ (assoc _ _ _ ∙∙ cong (_∙ (cong ∣_∣ₕ (sym (σ (S₊∙ 1) x)))) (lCancel (cong ∣_∣ₕ (σ (S₊∙ 1) x))) ∙∙ sym (lUnit _)) where lem : cong ∣_∣ₕ (σ (S₊∙ 1) x) ∙ cong ∣_∣ₕ (σ (S₊∙ 1) (invLooper x)) ≡ cong ∣_∣ₕ (σ (S₊∙ 1) x) ∙ cong ∣_∣ₕ (sym (σ (S₊∙ 1) x)) lem = sym (SuspS¹-hom x (invLooper x)) ∙ ((λ i → cong ∣_∣ₕ (σ (S₊∙ 1) (rCancelS¹ x (~ i)))) ∙ cong (cong ∣_∣ₕ) (rCancel (merid base))) ∙ sym (rCancel _) -------------------- join Sⁿ Sᵐ ≃ Sⁿ⁺¹⁺ᵐ ------------------------- {- This section contains a proof that join Sⁿ Sᵐ ≃ Sⁿ⁺ᵐ⁺¹. This is easy using various properties proved in HITs.Join. However, we would like the map join Sⁿ Sᵐ → Sⁿ⁺ᵐ⁺¹ to be nice, in particular when n = m = 1. Therefore, we put in some extra work into the equivalence. -} {- We begin with join S¹ S¹ ≃ S³. The iso is induced by: -} S¹×S¹→S² : S¹ → S¹ → S₊ 2 S¹×S¹→S² base y = north S¹×S¹→S² (loop i) base = north S¹×S¹→S² (loop i) (loop j) = (sym (rCancel (merid base)) ∙∙ (λ i → merid (loop i) ∙ sym (merid base)) ∙∙ rCancel (merid base)) i j joinS¹S¹→S³ : join S¹ S¹ → S₊ 3 joinS¹S¹→S³ (inl x) = north joinS¹S¹→S³ (inr x) = south joinS¹S¹→S³ (push a b i) = merid (S¹×S¹→S² a b) i {- Proving that this is an equivalence directly is painful, so we simply prove that it is equal to the old definition of the equivalence join S¹ S¹ ≃ S³ ≃ S₊ 3 To this end, we start by rephrasing the map -} private 3cell : (r i j k : I) → S₊ 3 3cell r i j k = hfill (λ r → λ {(i = i0) → merid (merid base j) (k ∧ ~ r) ; (i = i1) → merid (merid base j) (k ∧ ~ r) ; (j = i0) → merid north (k ∧ ~ r) ; (j = i1) → merid south (k ∧ ~ r) ; (k = i0) → north ; (k = i1) → merid (merid base j) (~ r)}) (inS (merid (merid (loop i) j) k)) r joinS¹S¹→S³' : join S¹ S¹ → S₊ 3 joinS¹S¹→S³' (inl x) = north joinS¹S¹→S³' (inr x) = north joinS¹S¹→S³' (push base b i) = north joinS¹S¹→S³' (push (loop i₁) base i) = north joinS¹S¹→S³' (push (loop i₁) (loop i₂) i) = 3cell i1 i₁ i₂ i {- These two maps are equal -} joinS¹S¹→S³'≡joinS¹S¹→S³' : (x : _) → joinS¹S¹→S³ x ≡ joinS¹S¹→S³' x joinS¹S¹→S³'≡joinS¹S¹→S³' (inl base) = refl joinS¹S¹→S³'≡joinS¹S¹→S³' (inl (loop i)) = refl joinS¹S¹→S³'≡joinS¹S¹→S³' (inr base) = sym (merid north) joinS¹S¹→S³'≡joinS¹S¹→S³' (inr (loop i)) = sym (merid north) joinS¹S¹→S³'≡joinS¹S¹→S³' (push base base i) k = merid north (~ k ∧ i) joinS¹S¹→S³'≡joinS¹S¹→S³' (push base (loop i₁) i) k = merid north (~ k ∧ i) joinS¹S¹→S³'≡joinS¹S¹→S³' (push (loop i₁) base i) k = (merid north) (~ k ∧ i) joinS¹S¹→S³'≡joinS¹S¹→S³' (push (loop i) (loop j) k) l = hcomp (λ r → λ { (i = i0) → merid (sym (rCancel (merid base)) (~ r) j) (~ l ∧ k) ; (i = i1) → merid (sym (rCancel (merid base)) (~ r) j) (~ l ∧ k) ; (j = i0) → merid north (~ l ∧ k) ; (j = i1) → merid north (~ l ∧ k) ; (k = i0) → north ; (k = i1) → merid (sym (rCancel (merid base)) (~ r) j) (~ l) ; (l = i0) → merid (doubleCompPath-filler (sym (rCancel (merid base))) (cong (σ (S₊∙ 1)) loop) (rCancel (merid base)) r i j) k ; (l = i1) → 3cell i1 i j k}) (hcomp (λ r → λ {(i = i0) → merid (cp-fill base r j) (k ∧ ~ l) ; (i = i1) → merid (cp-fill base r j) (k ∧ ~ l) ; (j = i0) → merid north (~ l ∧ k) ; (j = i1) → merid (merid base (~ r)) (~ l ∧ k) ; (k = i0) → north ; (k = i1) → merid (cp-fill base r j) (~ l) ; (l = i0) → merid (cp-fill (loop i) r j) k ; (l = i1) → 3cell i1 i j k}) (hcomp (λ r → λ {(i = i0) → merid (merid base j) (k ∧ (~ r ∨ ~ l)) ; (i = i1) → merid (merid base j) (k ∧ (~ r ∨ ~ l)) ; (j = i0) → merid north (k ∧ (~ l ∨ ~ r)) ; (j = i1) → merid south (k ∧ (~ l ∨ ~ r)) ; (k = i0) → north ; (k = i1) → merid (merid base j) (~ r ∨ ~ l) ; (l = i0) → merid (merid (loop i) j) k ; (l = i1) → 3cell r i j k}) (merid (merid (loop i) j) k))) where cp-fill : (a : S¹) → _ cp-fill a = compPath-filler (merid a) (sym (merid base)) {- joinS¹S¹→S³' is equal to the original equivalence (modulo a flipping of interval variables) -} joinS¹S¹→S³'Id : (x : join S¹ S¹) → joinS¹S¹→S³' x ≡ (Iso.fun IsoS³S3 ∘ flip₀₂S³ ∘ joinS¹S¹→S3) x joinS¹S¹→S³'Id (inl x) = refl joinS¹S¹→S³'Id (inr x) = refl joinS¹S¹→S³'Id (push base base i) = refl joinS¹S¹→S³'Id (push base (loop i₁) i) = refl joinS¹S¹→S³'Id (push (loop i₁) base i) = refl joinS¹S¹→S³'Id (push (loop i) (loop j) k) l = hcomp (λ r → λ {(i = i0) → merid (merid base (j ∧ ~ l)) (~ r ∧ k) ; (i = i1) → merid (merid base (j ∧ ~ l)) (~ r ∧ k) ; (j = i0) → merid north (k ∧ ~ r) ; (j = i1) → merid (merid base (~ l)) (~ r ∧ k) ; (k = i0) → north ; (k = i1) → merid (merid base (j ∧ ~ l)) (~ r) ; (l = i0) → 3cell r i j k ; (l = i1) → Iso.fun (IsoType→IsoSusp S²IsoSuspS¹) (meridian-contraction-2 k j i r)}) (merid (S²Cube i j l) k) where S²Cube : Cube {A = S₊ 2} (λ j l → merid base (j ∧ ~ l)) (λ j l → merid base (j ∧ ~ l)) (λ i l → north) (λ i l → merid base (~ l)) (λ i j → merid (loop i) j) λ i j → fun S²IsoSuspS¹ (surf j i) S²Cube i j l = hcomp (λ r → λ {(i = i0) → merid base (j ∧ (~ l ∨ ~ r)) ; (i = i1) → merid base (j ∧ (~ l ∨ ~ r)) ; (j = i0) → north ; (j = i1) → merid base (~ l ∨ ~ r) ; (l = i0) → merid (loop i) j ; (l = i1) → meridian-contraction j i r}) (merid (loop i) j) {-So, finally our map joinS¹S¹→S³ is an iso. We state its inverse explicitly. -} Iso-joinS¹S¹-S³ : Iso (join S¹ S¹) (S₊ 3) fun Iso-joinS¹S¹-S³ = joinS¹S¹→S³ inv Iso-joinS¹S¹-S³ = S³→joinS¹S¹ ∘ flip₀₂S³ ∘ Iso.inv IsoS³S3 rightInv Iso-joinS¹S¹-S³ x = joinS¹S¹→S³'≡joinS¹S¹→S³' ((S³→joinS¹S¹ ∘ flip₀₂S³ ∘ Iso.inv IsoS³S3) x) ∙∙ joinS¹S¹→S³'Id ((S³→joinS¹S¹ ∘ flip₀₂S³ ∘ Iso.inv IsoS³S3) x) ∙∙ Iso.leftInv (compIso (invIso IsoS³S3) (compIso flip₀₂S³Iso (S³IsojoinS¹S¹))) x leftInv Iso-joinS¹S¹-S³ x = cong (S³→joinS¹S¹ ∘ flip₀₂S³ ∘ inv IsoS³S3) (joinS¹S¹→S³'≡joinS¹S¹→S³' x ∙ joinS¹S¹→S³'Id x) ∙ Iso.rightInv (compIso (invIso IsoS³S3) (compIso flip₀₂S³Iso (S³IsojoinS¹S¹))) x {- We now get the full iso Sⁿ * Sᵐ ≃ Sⁿ⁺ᵐ⁺¹ -} IsoSphereJoin : (n m : ℕ) → Iso (join (S₊ n) (S₊ m)) (S₊ (suc (n + m))) IsoSphereJoin zero zero = compIso (invIso Susp-iso-joinBool) (invIso S¹IsoSuspBool) IsoSphereJoin zero (suc m) = compIso join-comm (invIso Susp-iso-joinBool) IsoSphereJoin (suc zero) zero = (invIso Susp-iso-joinBool) IsoSphereJoin (suc zero) (suc zero) = Iso-joinS¹S¹-S³ IsoSphereJoin (suc zero) (suc (suc m)) = compIso join-comm (compIso (compIso (Iso-joinSusp-suspJoin {A = S₊∙ (suc m)} {B = S₊∙ (suc zero)}) (congSuspIso join-comm)) (congSuspIso (IsoSphereJoin (suc zero) (suc m)))) IsoSphereJoin (suc (suc n)) m = compIso (Iso-joinSusp-suspJoin {A = S₊∙ (suc n)} {B = S₊∙ m}) (congSuspIso (IsoSphereJoin (suc n) m)) {- Pointedness holds by refl. This is due to the explicit definition of Iso-joinSusp-suspJoin -} IsoSphereJoinPres∙ : (n m : ℕ) → Iso.fun (IsoSphereJoin n m) (inl (ptSn n)) ≡ ptSn (suc (n + m)) IsoSphereJoinPres∙ zero zero = refl IsoSphereJoinPres∙ zero (suc m) = refl IsoSphereJoinPres∙ (suc zero) zero = refl IsoSphereJoinPres∙ (suc zero) (suc zero) = refl IsoSphereJoinPres∙ (suc zero) (suc (suc m)) = refl IsoSphereJoinPres∙ (suc (suc n)) m = refl IsoSphereJoin⁻Pres∙ : (n m : ℕ) → Iso.inv (IsoSphereJoin n m) (ptSn (suc (n + m))) ≡ inl (ptSn n) IsoSphereJoin⁻Pres∙ n m = cong (Iso.inv (IsoSphereJoin n m)) (sym (IsoSphereJoinPres∙ n m)) ∙ Iso.leftInv (IsoSphereJoin n m) (inl (ptSn n)) -- Inversion on spheres invSphere : {n : ℕ} → S₊ n → S₊ n invSphere {n = zero} = not invSphere {n = (suc zero)} = invLooper invSphere {n = (suc (suc n))} = invSusp invSphere² : (n : ℕ) (x : S₊ n) → invSphere (invSphere x) ≡ x invSphere² zero = notnot invSphere² (suc zero) base = refl invSphere² (suc zero) (loop i) = refl invSphere² (suc (suc n)) = invSusp² -- Interaction between σ and invSphere σ-invSphere : (n : ℕ) (x : S₊ (suc n)) → σ (S₊∙ (suc n)) (invSphere x) ≡ sym (σ (S₊∙ (suc n)) x) σ-invSphere zero base = rCancel (merid base) ∙∙ refl ∙∙ cong sym (sym (rCancel (merid base))) σ-invSphere zero (loop i) j = hcomp (λ k → λ { (j = i0) → doubleCompPath-filler (sym (rCancel (merid base))) (λ i → (σ (S₊∙ 1) (loop (~ i)))) (rCancel (merid base)) (~ k) i ; (j = i1) → doubleCompPath-filler (sym (cong sym (rCancel (merid base)))) (λ i → sym (σ (S₊∙ 1) (loop i))) (cong sym (rCancel (merid base))) (~ k) i}) (sym≡cong-sym (sym (rCancel (merid base)) ∙∙ (λ i → (σ (S₊∙ 1) (loop i))) ∙∙ (rCancel (merid base))) j i) σ-invSphere (suc n) x = toSusp-invSusp (S₊∙ (suc n)) x -- Some facts about the map S¹×S¹→S² -- Todo: generalise to Sⁿ×Sᵐ→Sⁿ⁺ᵐ S¹×S¹→S²rUnit : (a : S¹) → S¹×S¹→S² a base ≡ north S¹×S¹→S²rUnit base = refl S¹×S¹→S²rUnit (loop i) = refl S¹×S¹→S²x+x : (x : S¹) → S¹×S¹→S² x x ≡ north S¹×S¹→S²x+x base = refl S¹×S¹→S²x+x (loop i) k = lem k i where lem : cong₂ S¹×S¹→S² loop loop ≡ refl lem = cong₂Funct S¹×S¹→S² loop loop ∙ (λ i → rUnit (cong (λ x → S¹×S¹→S²rUnit x i) loop) (~ i)) S¹×S¹→S²-antiComm : (a b : S¹) → S¹×S¹→S² a b ≡ S¹×S¹→S² b (invLooper a) S¹×S¹→S²-antiComm base base = refl S¹×S¹→S²-antiComm base (loop i) = refl S¹×S¹→S²-antiComm (loop i) base = refl S¹×S¹→S²-antiComm (loop i) (loop j) k = sym≡flipSquare (λ j i → S¹×S¹→S² (loop i) (loop j)) (~ k) i j private S¹×S¹→S²-Distr-filler : (i : I) → cong₂ (λ b c → S¹×S¹→S² ((loop i) * b) c) loop loop ≡ cong (S¹×S¹→S² (loop i)) loop S¹×S¹→S²-Distr-filler i = cong₂Funct (λ b c → S¹×S¹→S² ((loop i) * b) c) loop loop ∙∙ (λ j → cong (λ x → S¹×S¹→S²rUnit (rotLoop x i) j) loop ∙ cong (λ c → S¹×S¹→S² (loop i) c) loop) ∙∙ sym (lUnit _) S¹×S¹→S²-Distr : (a b : S¹) → S¹×S¹→S² (a * b) b ≡ S¹×S¹→S² a b S¹×S¹→S²-Distr a base j = S¹×S¹→S² (rUnitS¹ a j) base S¹×S¹→S²-Distr base (loop i) k = S¹×S¹→S²-Distr-filler i0 k i S¹×S¹→S²-Distr (loop i₁) (loop i) k = S¹×S¹→S²-Distr-filler i₁ k i invSusp∘S¹×S¹→S² : (a b : S¹) → S¹×S¹→S² a (invLooper b) ≡ invSusp (S¹×S¹→S² a b) invSusp∘S¹×S¹→S² base b = merid base invSusp∘S¹×S¹→S² (loop i) base = merid base invSusp∘S¹×S¹→S² (loop i) (loop j) k = hcomp (λ r → λ {(i = i0) → i-Boundary₂ r j k ; (i = i1) → i-Boundary₂ r j k ; (j = i0) → m-b k ; (j = i1) → m-b k ; (k = i0) → doubleCompPath-filler rCancel-mb⁻¹ (cong σ₁ loop) rCancel-mb r i (~ j) ; (k = i1) → invSusp (doubleCompPath-filler rCancel-mb⁻¹ (cong σ₁ loop) rCancel-mb r i j)}) (hcomp (λ r → λ {(i = i0) → i-Boundary r (~ j) k ; (i = i1) → i-Boundary r (~ j) k ; (j = i0) → merid base (~ r ∨ k) ; (j = i1) → merid base (r ∧ k) ; (k = i0) → cp-filler (loop i) r (~ j) ; (k = i1) → invSusp (cp-filler (loop i) r j)}) (merid (loop i) (~ j))) where σ₁ = σ (S₊∙ 1) m-b = merid base rCancel-mb = rCancel m-b rCancel-mb⁻¹ = sym (rCancel m-b) cp-filler : (a : S¹) (i j : I) → S₊ 2 cp-filler a i j = compPath-filler (merid a) (sym (merid base)) i j i-Boundary : I → I → I → S₊ 2 i-Boundary r j k = hfill (λ r → λ{(j = i0) → m-b (k ∧ r) ; (j = i1) → m-b (~ r ∨ k) ; (k = i0) → cp-filler base r j ; (k = i1) → invSusp (cp-filler base r (~ j))}) (inS (m-b j)) r i-Boundary₂ : I → I → I → S₊ 2 i-Boundary₂ r j k = hcomp (λ i → λ {(r = i0) → i-Boundary i (~ j) k ; (r = i1) → m-b k ; (j = i0) → m-b (k ∨ (~ i ∧ ~ r)) ; (j = i1) → m-b (k ∧ (i ∨ r)) ; (k = i0) → rCancel-filler m-b i r (~ j) ; (k = i1) → invSusp (rCancel-filler m-b i r j) }) (hcomp (λ i → λ {(r = i0) → m-b (~ j ∨ (~ i ∧ k)) ; (r = i1) → m-b (k ∨ (~ i ∧ ~ j)) ; (j = i0) → m-b (k ∨ (~ r ∨ ~ i)) ; (j = i1) → m-b (k ∧ (~ i ∨ r)) ; (k = i0) → m-b (~ j ∧ (~ r ∨ ~ i)) ; (k = i1) → m-b ((~ j ∨ ~ i) ∨ r) }) (m-b (~ j ∨ k)))
{ "alphanum_fraction": 0.4571861734, "avg_line_length": 47.5216138329, "ext": "agda", "hexsha": "dfbf46b6edda47a351d1eef6e6cd628569b89e2b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "howsiyu/cubical", "max_forks_repo_path": "Cubical/HITs/Sn/Properties.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "howsiyu/cubical", "max_issues_repo_path": "Cubical/HITs/Sn/Properties.agda", "max_line_length": 138, "max_stars_count": null, "max_stars_repo_head_hexsha": "1b9c97a2140fe96fe636f4c66beedfd7b8096e8f", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "howsiyu/cubical", "max_stars_repo_path": "Cubical/HITs/Sn/Properties.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 12853, "size": 32980 }
module Numeral.Finite.Oper where open import Data open import Data.Boolean.Stmt open import Data.Option open import Logic.Propositional open import Logic.Predicate import Lvl open import Numeral.Finite as 𝕟 using (𝕟 ; 𝕟₌ ; 𝕟-to-ℕ) open import Numeral.Finite.Bound open import Numeral.Natural hiding (𝟎 ; 𝐒 ; 𝐏) open import Numeral.Natural.Function open import Numeral.Natural.Function.Proofs import Numeral.Natural.Oper as ℕ import Numeral.Natural.Oper.Comparisons as ℕ open import Numeral.Natural.Relation.Order open import Numeral.Natural.Relation.Order.Proofs open import Relator.Equals open import Relator.Equals.Proofs open import Syntax.Number module Exact where -- Predecessor bounded at the minimum (0) for both the value and the maximum. -- Example: (𝐏₀(5): 𝕟(8)) = (4: 𝕟(7)) 𝐏₀ : ∀{n} → 𝕟(ℕ.𝐒(ℕ.𝐒(n))) → 𝕟(ℕ.𝐒(n)) 𝐏₀(𝕟.𝟎) = 𝕟.𝟎 𝐏₀(𝕟.𝐒(n)) = n -- Addition for both the value and the maximum. -- Example: (5: 𝕟(8)) + (4: 𝕟(6)) = ((5+4): 𝕟(8+6)) = (9: 𝕟(14)) _+_ : ∀{b₁ b₂} → 𝕟(b₁) → 𝕟(b₂) → 𝕟(b₁ ℕ.+ b₂) _+_ {ℕ.𝐒(b₁)}{ℕ.𝐒(b₂)} 𝕟.𝟎 𝕟.𝟎 = 𝕟.𝟎 _+_ {ℕ.𝐒(b₁)}{ℕ.𝐒(b₂)} 𝕟.𝟎 (𝕟.𝐒(b)) = 𝕟.𝐒(𝕟.𝟎{b₁} + b) _+_ {ℕ.𝐒(b₁)}{ℕ.𝐒(b₂)} (𝕟.𝐒(a)) b = 𝕟.𝐒(a + b) -- Distance between two numbers. -- Examples: -- (3: 𝕟(8)) 𝄩 (5: 𝕟(6)) = ((3𝄩5): 𝕟(max 8 6)) = (2: 𝕟(8)) -- (5: 𝕟(8)) 𝄩 (3: 𝕟(6)) = ((5𝄩3): 𝕟(max 8 6)) = (2: 𝕟(8)) -- (7: 𝕟(8)) 𝄩 (0: 𝕟(6)) = ((7𝄩0): 𝕟(max 8 6)) = (7: 𝕟(8)) _𝄩_ : ∀{b₁ b₂} → 𝕟(b₁) → 𝕟(b₂) → 𝕟(max b₁ b₂) _𝄩_ {ℕ.𝐒 b₁} {ℕ.𝐒 b₂} 𝕟.𝟎 𝕟.𝟎 = 𝕟.𝟎 _𝄩_ {ℕ.𝐒 ℕ.𝟎} {ℕ.𝐒 b₂} 𝕟.𝟎 (𝕟.𝐒 b) = 𝕟.𝐒 b _𝄩_ {ℕ.𝐒 (ℕ.𝐒 b₁)} {ℕ.𝐒 b₂} 𝕟.𝟎 (𝕟.𝐒 b) = 𝕟.𝐒(𝕟.𝟎 𝄩 b) _𝄩_ {ℕ.𝐒 b₁} {ℕ.𝐒 b₂} (𝕟.𝐒 a) (𝕟.𝐒 b) = bound-𝐒(a 𝄩 b) _𝄩_ {ℕ.𝐒 b₁} {ℕ.𝐒 ℕ.𝟎} (𝕟.𝐒 a) 𝕟.𝟎 = 𝕟.𝐒 a _𝄩_ {ℕ.𝐒 b₁} {ℕ.𝐒 (ℕ.𝐒 b₂)} (𝕟.𝐒 a) 𝕟.𝟎 = 𝕟.𝐒(a 𝄩 𝕟.𝟎) _⋅_ : ∀{b₁ b₂} → 𝕟(b₁) → 𝕟(b₂) → 𝕟(b₁ ℕ.⋅ b₂) _⋅_ {ℕ.𝐒 b₁} {ℕ.𝐒 b₂} a 𝕟.𝟎 = 𝕟.𝟎 _⋅_ {ℕ.𝐒 b₁} {ℕ.𝐒 b₂} a (𝕟.𝐒 b) = a + (a ⋅ b) module Bounded where -- Predecessor bounded at the minimum (0) for the value only. -- Example: (𝐏₀(5): 𝕟(8)) = (4: 𝕟(8)) 𝐏₀ : ∀{n} → 𝕟(n) → 𝕟(n) 𝐏₀ {ℕ.𝐒(b)} (𝕟.𝟎) = 𝕟.𝟎 𝐏₀ {ℕ.𝐒(b)} (𝕟.𝐒(𝕟.𝟎)) = 𝕟.𝟎 𝐏₀ {ℕ.𝐒(b)} (𝕟.𝐒(𝕟.𝐒(n))) = 𝕟.𝐒(𝐏₀ {b} (𝕟.𝐒(n))) module Total where 𝐒 : ∀{b} → (n : 𝕟(b)) → ⦃ _ : IsTrue(ℕ.𝐒(𝕟-to-ℕ (n)) ℕ.<? b) ⦄ → 𝕟(b) 𝐒 {ℕ.𝐒(ℕ.𝐒(b))} (𝕟.𝟎) = 𝕟.𝐒(𝕟.𝟎) 𝐒 {ℕ.𝐒(ℕ.𝐒(b))} (𝕟.𝐒(n)) = 𝕟.𝐒(𝐒(n)) module Optional where minimum : ∀{n} → Option(𝕟(n)) minimum{ℕ.𝟎} = None minimum{ℕ.𝐒(_)} = Some 𝕟.minimum maximum : ∀{n} → Option(𝕟(n)) maximum{ℕ.𝟎} = None maximum{ℕ.𝐒(n)} = Some 𝕟.maximum _+₀ₗ_ : ∀{b₁ b₂} → Option(𝕟(b₁)) → 𝕟(b₂) → 𝕟(b₁ ℕ.+ b₂) _+₀ₗ_ None 𝕟.𝟎 = 𝕟.𝟎 _+₀ₗ_ {b₁} None (𝕟.𝐒(b)) = 𝕟.𝐒(_+₀ₗ_ {b₁} None b) _+₀ₗ_ (Some a) b = a Exact.+ b _+₀ᵣ_ : ∀{b₁ b₂} → 𝕟(b₁) → Option(𝕟(b₂)) → 𝕟(b₁ ℕ.+ b₂) _+₀ᵣ_ 𝕟.𝟎 None = 𝕟.𝟎 _+₀ᵣ_ (𝕟.𝐒(a)) None = 𝕟.𝐒(_+₀ᵣ_ a None) {-# CATCHALL #-} _+₀ᵣ_ a (Some b) = a Exact.+ b module Unclosed where _+ₙₗ_ : ∀{b₂} → (b₁ : ℕ) → 𝕟(b₂) → 𝕟(b₁ ℕ.+ b₂) ℕ.𝟎 +ₙₗ b = b ℕ.𝐒(a) +ₙₗ b = 𝕟.𝐒(a +ₙₗ b) _+ₙᵣ_ : ∀{b₁} → 𝕟(b₁) → (b₂ : ℕ) → 𝕟(b₁ ℕ.+ b₂) a +ₙᵣ ℕ.𝟎 = a a +ₙᵣ ℕ.𝐒(b) = 𝕟.𝐒(a +ₙᵣ b) -- Example: shrink-subtract(5) (7 : 𝕟(6 + 5)) = (2 : 𝕟(6)) shrink-subtractₗ : ∀{b₁} → (b₂ : ℕ) → 𝕟(ℕ.𝐒(b₁) ℕ.+ b₂) → 𝕟(ℕ.𝐒(b₁)) shrink-subtractₗ _ 𝕟.𝟎 = 𝕟.𝟎 shrink-subtractₗ ℕ.𝟎 (𝕟.𝐒 a) = 𝕟.𝐒 a shrink-subtractₗ {ℕ.𝟎} (ℕ.𝐒 b₂) (𝕟.𝐒 a) = 𝕟.𝟎 shrink-subtractₗ {ℕ.𝐒 b₁} (ℕ.𝐒 b₂) (𝕟.𝐒 a) = shrink-subtractₗ {ℕ.𝐒 b₁} (b₂) (a) shrink-subtractᵣ : (b₁ : ℕ) → ∀{b₂} → 𝕟(b₁ ℕ.+ ℕ.𝐒(b₂)) → 𝕟(ℕ.𝐒(b₂)) shrink-subtractᵣ _ 𝕟.𝟎 = 𝕟.𝟎 shrink-subtractᵣ ℕ.𝟎 (𝕟.𝐒 a) = 𝕟.𝐒 a shrink-subtractᵣ (ℕ.𝐒 b₁) {ℕ.𝟎} (𝕟.𝐒 a) = 𝕟.𝟎 shrink-subtractᵣ (ℕ.𝐒 b₁) {ℕ.𝐒 b₂} (𝕟.𝐒 a) = shrink-subtractᵣ (b₁) {ℕ.𝐒 b₂} (a) {-_⋅ₙₗ_ : ∀{b₂} → (b₁ : ℕ) → 𝕟(b₂) → 𝕟(ℕ.𝐒(b₁ ℕ.⋅ b₂)) _⋅ₙₗ_ {ℕ.𝐒 _} ℕ.𝟎 _ = 𝕟.𝟎 _⋅ₙₗ_ {ℕ.𝐒 _} (ℕ.𝐒 a) b = {!b Exact.+ (a ⋅ₙₗ b)!} -} _⋅ₙᵣ_ : ∀{b₁} → 𝕟(b₁) → (b₂ : ℕ) → 𝕟(ℕ.𝐒(b₁ ℕ.⋅ b₂)) -- TODO: Bounds is too great _⋅ₙᵣ_ {ℕ.𝐒 _} a ℕ.𝟎 = 𝕟.𝟎 _⋅ₙᵣ_ {ℕ.𝐒 _} a (ℕ.𝐒 b) = a Exact.+ (a ⋅ₙᵣ b) module Wrapping where -- Wrapping subtraction. -- Essentially: _[−]_ {b₁}{b₂} a b = (a −ℤ b) mod b₁ _[−]_ : ∀{b₁ b₂} → 𝕟(b₁) → 𝕟(b₂) → 𝕟(b₁) _[−]_ {_} {ℕ.𝐒 _} a 𝕟.𝟎 = a _[−]_ {ℕ.𝐒 b₁} {ℕ.𝐒 _} 𝕟.𝟎 (𝕟.𝐒 b) = 𝕟.maximum {b₁} [−] b _[−]_ {ℕ.𝐒 b₁} {ℕ.𝐒 b₂} (𝕟.𝐒 a) (𝕟.𝐒 b) = _[−]_ {ℕ.𝐒 b₁}{b₂} (bound-𝐒 a) b -- Wrapping negation (Flipping around the symmetric point). -- Essentially: [−]_ {b} n = (−ℤ n) mod b [−]_ : ∀{b} → 𝕟(b) → 𝕟(b) [−]_ {ℕ.𝐒 b} n = 𝕟.maximum {b} [−] n {- TODO: Cannot solve first. Unsure why [𝐒]-not-0 : ∀{b : ℕ}{n : 𝕟(ℕ.𝐒(b))} → (𝐒{b}(n) ≢ 𝟎{ℕ.𝐒(b)}) [𝐒]-not-0 () 𝐏keep : ∀{b} → (n : 𝕟(𝐒(b))) → ⦃ _ : n ≢ 𝟎 ⦄ → 𝕟(𝐒(b)) 𝐏keep {ℕ.𝟎} (𝟎) ⦃ proof ⦄ with proof([≡]-intro) ... | () 𝐏keep {ℕ.𝐒(b)} (𝟎) ⦃ _ ⦄ = 𝟎 𝐏keep {ℕ.𝐒(b)} (𝐒(𝟎)) ⦃ _ ⦄ = 𝟎 𝐏keep {ℕ.𝐒(b)} (𝐒(𝐒(n))) ⦃ proof ⦄ = 𝐒(𝐏keep {b} (𝐒(n)) ⦃ [𝐒]-not-0 ⦄) -} -- _ : ∀{b} → (n : 𝕟(b)) → (𝕟-to-ℕ (n) < b) -- _+small_ : ∀{b₁ b₂} → (x : 𝕟(𝐒(b₁))) → (y : 𝕟(𝐒(b₂))) → 𝕟(ℕ.𝐒(𝕟-to-ℕ (x) ℕ.+ 𝕟-to-ℕ (y))) -- _+small_ 𝟎 𝟎 = 𝟎 -- _+small_ {b₁} (𝐒(a)) 𝟎 = 𝐒(a +small 𝟎) -- _+small_ a (𝐒(b)) = 𝐒(a +small b) -- _−small_ : ∀{b} → (x : 𝕟(𝐒(b))) → (y : 𝕟(ℕ.𝐒(𝕟-to-ℕ (x)))) → 𝕟(ℕ.𝐒(𝕟-to-ℕ (x) ℕ.−₀ 𝕟-to-ℕ (y))) -- 𝟎 −small 𝟎 = 𝟎 -- 𝐒(a) −small 𝟎 = 𝐒(a −small 𝟎) -- 𝐒(a) −small 𝐒(b) = a −small b {- TODO: Will not work like this -- Modulo subtraction. -- Essentially: a [−] b mod n = (a −ℤ b) mod n _[−]_mod_ : ℕ → ℕ → (n : ℕ) → 𝕟₌(n) _ [−] _ mod 𝟎 = 𝟎 𝟎 [−] 𝟎 mod 𝐒(n) = 𝟎 𝐒(a) [−] 𝟎 mod 𝐒(n) = a [−] n mod 𝐒(n) 𝟎 [−] 𝐒(b) mod 𝐒(n) = n [−] b mod 𝐒(n) 𝐒(a) [−] 𝐒(b) mod 𝐒(n) = a [−] b mod 𝐒(n) open import Data test1 : [−]_ {4} 1 ≡ 3 test1 = [≡]-intro -} -- _−_ : ∀{b} → (x : 𝕟(𝐒(b))) → (y : 𝕟(ℕ.𝐒(𝕟-to-ℕ (x)))) → 𝕟(𝐒(b)) -- 𝟎 − 𝟎 = 𝟎 -- 𝐒(a) − 𝟎 = 𝐒(a) -- 𝐒(a) − 𝐒(b) = bound-𝐒(a − b) -- TODO: Wrapping and bounded operations
{ "alphanum_fraction": 0.4630017733, "avg_line_length": 35.4457142857, "ext": "agda", "hexsha": "263971be52ed09a02951d7fe9ccdcdcabaf11ad8", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Numeral/Finite/Oper.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Numeral/Finite/Oper.agda", "max_line_length": 98, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Numeral/Finite/Oper.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 4232, "size": 6203 }
------------------------------------------------------------------------ -- The circle with an erased higher constructor ------------------------------------------------------------------------ {-# OPTIONS --erased-cubical --safe #-} -- Partly following the HoTT book. -- The module is parametrised by a notion of equality. The higher -- constructor of the HIT defining the circle uses path equality, but -- the supplied notion of equality is used for many other things. import Equality.Path as P module Circle.Erased {e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where open P.Derived-definitions-and-properties eq hiding (elim) open import Prelude open import Bijection equality-with-J using (_↔_) open import Circle eq as C using (𝕊¹) open import Equality.Groupoid equality-with-J open import Equality.Path.Isomorphisms eq open import Equality.Path.Isomorphisms.Univalence eq open import Equivalence equality-with-J as Eq using (_≃_) import Equivalence P.equality-with-J as PE open import Erased.Cubical eq open import Function-universe equality-with-J hiding (id; _∘_) open import Group equality-with-J as G using (_≃ᴳ_) open import H-level equality-with-J open import H-level.Truncation.Propositional.Erased eq as T using (∥_∥ᴱ) open import H-level.Truncation.Propositional.One-step eq as O using (∥_∥¹) open import H-level.Truncation.Propositional.One-step.Erased eq as OE using (∥_∥¹ᴱ) open import Integer equality-with-J using (ℤ; +_; ℤ-group) open import Nat equality-with-J open import Pointed-type equality-with-J as PT using (_≃ᴮ_) open import Pointed-type.Homotopy-group eq private variable a p : Level A : Type p P : A → Type p b ℓ : A ------------------------------------------------------------------------ -- The type and some eliminators -- The circle. data 𝕊¹ᴱ : Type where base : 𝕊¹ᴱ @0 loopᴾ : base P.≡ base @0 loop : base ≡ base loop = _↔_.from ≡↔≡ loopᴾ -- A dependent eliminator, expressed using paths. elimᴾ : (P : 𝕊¹ᴱ → Type p) (b : P base) → @0 P.[ (λ i → P (loopᴾ i)) ] b ≡ b → (x : 𝕊¹ᴱ) → P x elimᴾ P b ℓ base = b elimᴾ P b ℓ (loopᴾ i) = ℓ i -- A non-dependent eliminator, expressed using paths. recᴾ : (b : A) → @0 b P.≡ b → 𝕊¹ᴱ → A recᴾ = elimᴾ _ -- A dependent eliminator. elim : (P : 𝕊¹ᴱ → Type p) (b : P base) → @0 subst P loop b ≡ b → (x : 𝕊¹ᴱ) → P x elim P b ℓ = elimᴾ P b (subst≡→[]≡ ℓ) -- A "computation" rule. @0 elim-loop : dcong (elim P b ℓ) loop ≡ ℓ elim-loop = dcong-subst≡→[]≡ (refl _) -- Every dependent function of type (x : 𝕊¹ᴱ) → P x can be expressed -- using elim. η-elim : {f : (x : 𝕊¹ᴱ) → P x} → f ≡ elim P (f base) (dcong f loop) η-elim {P = P} {f = f} = ⟨ext⟩ $ elim _ (refl _) (subst (λ x → f x ≡ elim P (f base) (dcong f loop) x) loop (refl _) ≡⟨ subst-in-terms-of-trans-and-dcong ⟩ trans (sym (dcong f loop)) (trans (cong (subst P loop) (refl _)) (dcong (elim P (f base) (dcong f loop)) loop)) ≡⟨ cong (trans (sym (dcong f loop))) $ trans (cong (flip trans _) $ cong-refl _) $ trans-reflˡ _ ⟩ trans (sym (dcong f loop)) (dcong (elim P (f base) (dcong f loop)) loop) ≡⟨ cong (trans (sym (dcong f loop))) elim-loop ⟩ trans (sym (dcong f loop)) (dcong f loop) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎) -- A non-dependent eliminator. rec : (b : A) → @0 b ≡ b → 𝕊¹ᴱ → A rec b ℓ = recᴾ b (_↔_.to ≡↔≡ ℓ) -- A "computation" rule. @0 rec-loop : cong (rec b ℓ) loop ≡ ℓ rec-loop = cong-≡↔≡ (refl _) -- Every function from 𝕊¹ᴱ to A can be expressed using rec. η-rec : {f : 𝕊¹ᴱ → A} → f ≡ rec (f base) (cong f loop) η-rec {f = f} = ⟨ext⟩ $ elim _ (refl _) (subst (λ x → f x ≡ rec (f base) (cong f loop) x) loop (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong f loop)) (trans (refl _) (cong (rec (f base) (cong f loop)) loop)) ≡⟨ cong (trans (sym (cong f loop))) $ trans-reflˡ _ ⟩ trans (sym (cong f loop)) (cong (rec (f base) (cong f loop)) loop) ≡⟨ cong (trans (sym (cong f loop))) rec-loop ⟩ trans (sym (cong f loop)) (cong f loop) ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎) ------------------------------------------------------------------------ -- Conversion functions -- In erased contexts 𝕊¹ is equivalent to 𝕊¹ᴱ. @0 𝕊¹≃𝕊¹ᴱ : 𝕊¹ ≃ 𝕊¹ᴱ 𝕊¹≃𝕊¹ᴱ = Eq.↔→≃ 𝕊¹→𝕊¹ᴱ 𝕊¹ᴱ→𝕊¹ (elim _ (refl _) (subst (λ x → 𝕊¹→𝕊¹ᴱ (𝕊¹ᴱ→𝕊¹ x) ≡ x) loop (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (𝕊¹→𝕊¹ᴱ ∘ 𝕊¹ᴱ→𝕊¹) loop)) (trans (refl _) (cong id loop)) ≡⟨ cong (trans _) $ trans (trans-reflˡ _) $ sym $ cong-id _ ⟩ trans (sym (cong (𝕊¹→𝕊¹ᴱ ∘ 𝕊¹ᴱ→𝕊¹) loop)) loop ≡⟨ cong (flip trans _) $ cong sym $ trans (sym $ cong-∘ _ _ _) $ trans (cong (cong 𝕊¹→𝕊¹ᴱ) rec-loop) $ C.rec-loop ⟩ trans (sym loop) loop ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎)) (C.elim _ (refl _) (subst (λ x → 𝕊¹ᴱ→𝕊¹ (𝕊¹→𝕊¹ᴱ x) ≡ x) C.loop (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (𝕊¹ᴱ→𝕊¹ ∘ 𝕊¹→𝕊¹ᴱ) C.loop)) (trans (refl _) (cong id C.loop)) ≡⟨ cong (trans _) $ trans (trans-reflˡ _) $ sym $ cong-id _ ⟩ trans (sym (cong (𝕊¹ᴱ→𝕊¹ ∘ 𝕊¹→𝕊¹ᴱ) C.loop)) C.loop ≡⟨ cong (flip trans _) $ cong sym $ trans (sym $ cong-∘ _ _ _) $ trans (cong (cong 𝕊¹ᴱ→𝕊¹) C.rec-loop) $ rec-loop ⟩ trans (sym C.loop) C.loop ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎)) where 𝕊¹→𝕊¹ᴱ = C.rec base loop 𝕊¹ᴱ→𝕊¹ = rec C.base C.loop -- In erased contexts there is a based equivalence between 𝕊¹ , C.base -- and 𝕊¹ᴱ , base. @0 𝕊¹≃ᴮ𝕊¹ᴱ : (𝕊¹ , C.base) ≃ᴮ (𝕊¹ᴱ , base) 𝕊¹≃ᴮ𝕊¹ᴱ = 𝕊¹≃𝕊¹ᴱ , refl _ -- The one-step truncation of the unit type is equivalent to 𝕊¹ᴱ. -- -- Paolo Capriotti informed me about the corresponding result without -- erasure. ∥⊤∥¹ᴱ≃𝕊¹ᴱ : ∥ ⊤ ∥¹ᴱ ≃ 𝕊¹ᴱ ∥⊤∥¹ᴱ≃𝕊¹ᴱ = _↔_.from ≃↔≃ $ PE.↔→≃ (OE.recᴾ λ where .OE.∣∣ʳ _ → base .OE.∣∣-constantʳ _ _ → loopᴾ) (recᴾ OE.∣ _ ∣ (OE.∣∣-constantᴾ _ _)) (elimᴾ _ P.refl (λ _ → P.refl)) (OE.elimᴾ λ where .OE.∣∣ʳ _ → P.refl .OE.∣∣-constantʳ _ _ _ → P.refl) ------------------------------------------------------------------------ -- The loop space of 𝕊¹ᴱ -- The function trans is commutative for the loop space of 𝕊¹ᴱ. trans-commutative : (p q : base ≡ base) → trans p q ≡ trans q p trans-commutative = flip $ Transitivity-commutative.commutative base _∙_ ∙-base base-∙ where _∙_ : 𝕊¹ᴱ → 𝕊¹ᴱ → 𝕊¹ᴱ x ∙ y = rec x (elim (λ x → x ≡ x) loop lemma x) y where @0 lemma : subst (λ x → x ≡ x) loop loop ≡ loop lemma = ≡⇒↝ _ (sym [subst≡]≡[trans≡trans]) (refl _) base-∙ : ∀ x → x ∙ base ≡ x base-∙ _ = refl _ ∙-base : ∀ y → base ∙ y ≡ y ∙-base = elim _ (refl _) (subst (λ x → rec base loop x ≡ x) loop (refl _) ≡⟨ subst-in-terms-of-trans-and-cong ⟩ trans (sym (cong (rec base loop) loop)) (trans (refl _) (cong id loop)) ≡⟨ cong (trans _) $ trans-reflˡ _ ⟩ trans (sym (cong (rec base loop) loop)) (cong id loop) ≡⟨ cong₂ (trans ∘ sym) rec-loop (sym $ cong-id _) ⟩ trans (sym loop) loop ≡⟨ trans-symˡ _ ⟩∎ refl _ ∎) -- The loop space is equivalent to x ≡ x, for any x : 𝕊¹ᴱ. base≡base≃≡ : {x : 𝕊¹ᴱ} → (base ≡ base) ≃ (x ≡ x) base≡base≃≡ = elim (λ x → (base ≡ base) ≃ (x ≡ x)) Eq.id (Eq.lift-equality ext $ ⟨ext⟩ λ eq → _≃_.to (subst (λ x → (base ≡ base) ≃ (x ≡ x)) loop Eq.id) eq ≡⟨ cong (_$ eq) Eq.to-subst ⟩ subst (λ x → base ≡ base → x ≡ x) loop id eq ≡⟨ subst-→ ⟩ subst (λ x → x ≡ x) loop (subst (λ _ → base ≡ base) (sym loop) eq) ≡⟨ cong (subst (λ x → x ≡ x) loop) $ subst-const _ ⟩ subst (λ x → x ≡ x) loop eq ≡⟨ ≡⇒↝ _ (sym [subst≡]≡[trans≡trans]) ( trans eq loop ≡⟨ trans-commutative _ _ ⟩∎ trans loop eq ∎) ⟩∎ eq ∎) _ -- In erased contexts the loop space of 𝕊¹ᴱ is equivalent to the type -- of integers. @0 base≡base≃ℤ : (base ≡ base) ≃ ℤ base≡base≃ℤ = base ≡ base ↝⟨ Eq.≃-≡ 𝕊¹≃𝕊¹ᴱ ⟩ C.base ≡ C.base ↝⟨ C.base≡base≃ℤ univ ⟩□ ℤ □ -- In erased contexts the fundamental group of 𝕊¹ᴱ is equivalent to -- the group of integers. @0 Fundamental-group≃ℤ : Fundamental-group (𝕊¹ᴱ , base) ≃ᴳ ℤ-group Fundamental-group≃ℤ = G.↝ᴳ-trans (G.≃ᴳ-sym $ ≃ᴮ→≃ᴳ _ _ 0 𝕊¹≃ᴮ𝕊¹ᴱ) (C.Fundamental-group≃ℤ univ) -- 𝕊¹ᴱ is a groupoid (in erased contexts). @0 𝕊¹ᴱ-groupoid : H-level 3 𝕊¹ᴱ 𝕊¹ᴱ-groupoid = $⟨ (λ {_ _ _ _} → C.𝕊¹-groupoid univ) ⟩ H-level 3 𝕊¹ ↝⟨ H-level-cong _ 3 𝕊¹≃𝕊¹ᴱ ⦂ (_ → _) ⟩□ H-level 3 𝕊¹ᴱ □ -- The type of endofunctions on 𝕊¹ᴱ is equivalent to -- ∃ λ (x : 𝕊¹ᴱ) → Erased (x ≡ x). 𝕊¹ᴱ→𝕊¹ᴱ≃Σ𝕊¹ᴱ-Erased≡ : (𝕊¹ᴱ → 𝕊¹ᴱ) ≃ ∃ λ (x : 𝕊¹ᴱ) → Erased (x ≡ x) 𝕊¹ᴱ→𝕊¹ᴱ≃Σ𝕊¹ᴱ-Erased≡ = Eq.↔→≃ to from to-from from-to where to : (𝕊¹ᴱ → 𝕊¹ᴱ) → ∃ λ (x : 𝕊¹ᴱ) → Erased (x ≡ x) to f = f base , [ cong f loop ] from : (∃ λ (x : 𝕊¹ᴱ) → Erased (x ≡ x)) → (𝕊¹ᴱ → 𝕊¹ᴱ) from (x , [ eq ]) = rec x eq to-from : ∀ p → to (from p) ≡ p to-from (x , [ eq ]) = cong (x ,_) ([ cong (rec x eq) loop ] ≡⟨ []-cong [ rec-loop ] ⟩∎ [ eq ] ∎) from-to : ∀ f → from (to f) ≡ f from-to f = rec (f base) (cong f loop) ≡⟨ sym η-rec ⟩∎ f ∎ -- The type of endofunctions on 𝕊¹ᴱ is equivalent to 𝕊¹ᴱ × Erased ℤ. 𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ : (𝕊¹ᴱ → 𝕊¹ᴱ) ≃ (𝕊¹ᴱ × Erased ℤ) 𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ = (𝕊¹ᴱ → 𝕊¹ᴱ) ↝⟨ 𝕊¹ᴱ→𝕊¹ᴱ≃Σ𝕊¹ᴱ-Erased≡ ⟩ (∃ λ (x : 𝕊¹ᴱ) → Erased (x ≡ x)) ↝⟨ (∃-cong λ _ → Erased-cong (inverse base≡base≃≡)) ⟩ 𝕊¹ᴱ × Erased (base ≡ base) ↝⟨ (∃-cong λ _ → Erased-cong base≡base≃ℤ) ⟩□ 𝕊¹ᴱ × Erased ℤ □ -- The forward direction of 𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ maps the identity -- function to base , [ + 1 ]. 𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ-id : _≃_.to 𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ id ≡ (base , [ + 1 ]) 𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ-id = _≃_.from-to 𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ (rec base (cong (_≃_.to 𝕊¹≃𝕊¹ᴱ) (trans (refl C.base) C.loop)) ≡⟨ cong (λ ([ ℓ ]) → rec base ℓ) $ []-cong [ lemma ] ⟩ rec base (cong id loop) ≡⟨ sym η-rec ⟩∎ id ∎) where @0 lemma : _ lemma = cong (_≃_.to 𝕊¹≃𝕊¹ᴱ) (trans (refl C.base) C.loop) ≡⟨ cong (cong (_≃_.to 𝕊¹≃𝕊¹ᴱ)) $ trans-reflˡ _ ⟩ cong (_≃_.to 𝕊¹≃𝕊¹ᴱ) C.loop ≡⟨ C.rec-loop ⟩ loop ≡⟨ cong-id _ ⟩∎ cong id loop ∎ -- The forward direction of 𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ maps the constant -- function returning base to base , [ + 0 ]. 𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ-const : _≃_.to 𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ (const base) ≡ (base , [ + 0 ]) 𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ-const = _≃_.from-to 𝕊¹ᴱ→𝕊¹ᴱ≃𝕊¹ᴱ×Erased-ℤ (rec base (cong (_≃_.to 𝕊¹≃𝕊¹ᴱ) (refl C.base)) ≡⟨ cong (λ ([ ℓ ]) → rec base ℓ) $ []-cong [ lemma ] ⟩ rec base (cong (const base) loop) ≡⟨ sym η-rec ⟩∎ const base ∎) where @0 lemma : _ lemma = cong (_≃_.to 𝕊¹≃𝕊¹ᴱ) (refl C.base) ≡⟨ cong-refl _ ⟩ refl _ ≡⟨ sym $ cong-const _ ⟩∎ cong (const base) loop ∎ ------------------------------------------------------------------------ -- Some negative results -- The equality loop is not equal to refl base. loop≢refl : loop ≢ refl base loop≢refl = Stable-¬ [ loop ≡ refl base ↔⟨ inverse $ Eq.≃-≡ $ inverse $ Eq.≃-≡ $ inverse 𝕊¹≃𝕊¹ᴱ ⟩ cong (_≃_.from 𝕊¹≃𝕊¹ᴱ) loop ≡ cong (_≃_.from 𝕊¹≃𝕊¹ᴱ) (refl base) ↝⟨ trans (sym rec-loop) ∘ flip trans (cong-refl _) ⟩ C.loop ≡ refl C.base ↝⟨ C.loop≢refl ⟩□ ⊥ □ ] -- 𝕊¹ᴱ is not a set. ¬-𝕊¹ᴱ-set : ¬ Is-set 𝕊¹ᴱ ¬-𝕊¹ᴱ-set = Stable-¬ [ Is-set 𝕊¹ᴱ ↝⟨ H-level-cong _ 2 $ inverse 𝕊¹≃𝕊¹ᴱ ⟩ Is-set 𝕊¹ ↝⟨ C.¬-𝕊¹-set ⟩□ ⊥ □ ] -- It is not necessarily the case that the one-step truncation of a -- proposition is a proposition. ¬-Is-proposition-∥∥¹ᴱ : ¬ ({A : Type a} → Is-proposition A → Is-proposition ∥ A ∥¹ᴱ) ¬-Is-proposition-∥∥¹ᴱ {a = a} = Stable-¬ [ ({A : Type a} → Is-proposition A → Is-proposition ∥ A ∥¹ᴱ) ↝⟨ (implicit-∀-cong _ $ ∀-cong _ λ _ → H-level-cong _ 1 O.∥∥¹ᴱ≃∥∥¹) ⟩ ({A : Type a} → Is-proposition A → Is-proposition ∥ A ∥¹) ↝⟨ C.¬-Is-proposition-∥∥¹ ⟩□ ⊥ □ ] -- A function with the type of refl (for 𝕊¹ᴱ) that is not equal to -- refl. The function is available in erased contexts. @0 not-refl : (x : 𝕊¹ᴱ) → x ≡ x not-refl x = $⟨ C.not-refl (_≃_.from 𝕊¹≃𝕊¹ᴱ x) ⟩ _≃_.from 𝕊¹≃𝕊¹ᴱ x ≡ _≃_.from 𝕊¹≃𝕊¹ᴱ x ↝⟨ Eq.≃-≡ $ inverse 𝕊¹≃𝕊¹ᴱ ⟩□ x ≡ x □ -- The function not-refl is not equal to refl. not-refl≢refl : not-refl ≢ refl not-refl≢refl = Stable-¬ [ not-refl ≡ refl ↔⟨⟩ _≃_.to (Eq.≃-≡ $ inverse 𝕊¹≃𝕊¹ᴱ) ∘ C.not-refl ∘ _≃_.from 𝕊¹≃𝕊¹ᴱ ≡ refl ↝⟨ flip trans (⟨ext⟩ lemma) ⟩ _≃_.to (Eq.≃-≡ $ inverse 𝕊¹≃𝕊¹ᴱ) ∘ C.not-refl ∘ _≃_.from 𝕊¹≃𝕊¹ᴱ ≡ _≃_.to (Eq.≃-≡ $ inverse 𝕊¹≃𝕊¹ᴱ) ∘ refl ∘ _≃_.from 𝕊¹≃𝕊¹ᴱ ↔⟨ (Eq.≃-≡ $ inverse $ Π-cong ext (inverse 𝕊¹≃𝕊¹ᴱ) λ _ → inverse $ Eq.≃-≡ $ inverse 𝕊¹≃𝕊¹ᴱ) ⟩ C.not-refl ≡ refl ↝⟨ C.not-refl≢refl ⟩□ ⊥ □ ] where @0 lemma : _ lemma x = sym $ _≃_.from-to (Eq.≃-≡ $ Eq.inverse 𝕊¹≃𝕊¹ᴱ) (_≃_.from (Eq.≃-≡ $ Eq.inverse 𝕊¹≃𝕊¹ᴱ) (refl x) ≡⟨⟩ cong (_≃_.from 𝕊¹≃𝕊¹ᴱ) (refl x) ≡⟨ cong-refl _ ⟩∎ refl (_≃_.from 𝕊¹≃𝕊¹ᴱ x) ∎) -- For every universe level there is a type A such that -- (x : A) → x ≡ x is not a proposition. ¬-type-of-refl-propositional : ∃ λ (A : Type a) → ¬ Is-proposition ((x : A) → x ≡ x) ¬-type-of-refl-propositional {a = a} = ↑ _ 𝕊¹ᴱ , Stable-¬ [ Is-proposition ((x : ↑ _ 𝕊¹ᴱ) → x ≡ x) ↝⟨ (H-level-cong _ 1 $ Π-cong ext (↑-cong $ inverse 𝕊¹≃𝕊¹ᴱ) λ _ → inverse $ Eq.≃-≡ $ ↑-cong $ inverse 𝕊¹≃𝕊¹ᴱ) ⟩ Is-proposition ((x : ↑ _ 𝕊¹) → x ≡ x) ↝⟨ proj₂ C.¬-type-of-refl-propositional ⟩□ ⊥ □ ] -- Every value of type 𝕊¹ᴱ is merely equal to the base point (using -- ∥_∥ᴱ to express "merely"). -- -- A variant of this lemma was mentioned by Mike Shulman in a blog -- post (http://homotopytypetheory.org/2013/07/24/cohomology/). all-points-on-the-circle-are-merely-equal : (x : 𝕊¹ᴱ) → ∥ x ≡ base ∥ᴱ all-points-on-the-circle-are-merely-equal = elim _ T.∣ refl base ∣ (T.truncation-is-proposition _ _) -- Every value of type 𝕊¹ᴱ is not not equal to the base point. all-points-on-the-circle-are-¬¬-equal : (x : 𝕊¹ᴱ) → ¬ ¬ x ≡ base all-points-on-the-circle-are-¬¬-equal x = Stable-¬ [ x ≢ base ↔⟨ →-cong ext (inverse $ Eq.≃-≡ $ inverse 𝕊¹≃𝕊¹ᴱ) Eq.id ⟩ _≃_.from 𝕊¹≃𝕊¹ᴱ x ≢ C.base ↝⟨ C.all-points-on-the-circle-are-¬¬-equal _ ⟩□ ⊥ □ ] -- It is not the case that every value of type 𝕊¹ᴱ is equal to the -- base point. ¬-all-points-on-the-circle-are-equal : ¬ ((x : 𝕊¹ᴱ) → x ≡ base) ¬-all-points-on-the-circle-are-equal = Stable-¬ [ ((x : 𝕊¹ᴱ) → x ≡ base) ↔⟨ (Π-cong ext (inverse 𝕊¹≃𝕊¹ᴱ) λ _ → inverse $ Eq.≃-≡ $ Eq.inverse 𝕊¹≃𝕊¹ᴱ) ⟩ ((x : 𝕊¹) → x ≡ C.base) ↝⟨ C.¬-all-points-on-the-circle-are-equal ⟩□ ⊥ □ ] -- Double-negation shift for Type-valued predicates over 𝕊¹ᴱ does not -- hold in general. ¬-double-negation-shift : ¬ ({P : 𝕊¹ᴱ → Type} → ((x : 𝕊¹ᴱ) → ¬ ¬ P x) → ¬ ¬ ((x : 𝕊¹ᴱ) → P x)) ¬-double-negation-shift = Stable-¬ [ ({P : 𝕊¹ᴱ → Type} → ((x : 𝕊¹ᴱ) → ¬ ¬ P x) → ¬ ¬ ((x : 𝕊¹ᴱ) → P x)) ↔⟨ (implicit-Π-cong ext (→-cong₁ {k₂ = equivalence} ext $ inverse 𝕊¹≃𝕊¹ᴱ) λ _ → →-cong ext (inverse $ Π-cong ext 𝕊¹≃𝕊¹ᴱ λ _ → Eq.id) $ ¬-cong ext $ ¬-cong ext $ inverse $ Π-cong ext 𝕊¹≃𝕊¹ᴱ λ _ → Eq.id) ⟩ ({P : 𝕊¹ → Type} → ((x : 𝕊¹) → ¬ ¬ P x) → ¬ ¬ ((x : 𝕊¹) → P x)) ↝⟨ C.¬-double-negation-shift ⟩□ ⊥ □ ] -- H-level.Closure.proj₁-closure cannot be generalised by replacing -- the assumption ∀ a → B a with ∀ a → ∥ B a ∥ᴱ. -- -- A variant of this observation is due to Andrea Vezzosi. ¬-generalised-proj₁-closure : ¬ ({A : Type} {B : A → Type} → (∀ a → ∥ B a ∥ᴱ) → ∀ n → H-level n (Σ A B) → H-level n A) ¬-generalised-proj₁-closure generalised-proj₁-closure = $⟨ singleton-contractible _ ⟩ Contractible (Σ 𝕊¹ᴱ (_≡ base)) ↝⟨ generalised-proj₁-closure all-points-on-the-circle-are-merely-equal 0 ⟩ Contractible 𝕊¹ᴱ ↝⟨ ¬-𝕊¹ᴱ-set ∘ mono (zero≤ 2) ⟩□ ⊥ □ -- There is no based equivalence between 𝕊¹ᴱ and the product of 𝕊¹ᴱ -- with itself. 𝕊¹ᴱ≄ᴮ𝕊¹ᴱ×𝕊¹ᴱ : ¬ (𝕊¹ᴱ , base) ≃ᴮ ((𝕊¹ᴱ , base) PT.× (𝕊¹ᴱ , base)) 𝕊¹ᴱ≄ᴮ𝕊¹ᴱ×𝕊¹ᴱ = Stable-¬ [ (𝕊¹ᴱ , base) ≃ᴮ ((𝕊¹ᴱ , base) PT.× (𝕊¹ᴱ , base)) ↝⟨ PT.↝ᴮ-trans 𝕊¹≃ᴮ𝕊¹ᴱ ∘ flip PT.↝ᴮ-trans (PT.≃ᴮ-sym (𝕊¹≃ᴮ𝕊¹ᴱ PT.×-cong-≃ᴮ 𝕊¹≃ᴮ𝕊¹ᴱ)) ⟩ (𝕊¹ , C.base) ≃ᴮ ((𝕊¹ , C.base) PT.× (𝕊¹ , C.base)) ↝⟨ C.𝕊¹≄ᴮ𝕊¹×𝕊¹ ⟩□ ⊥ □ ] -- 𝕊¹ᴱ is not equivalent to 𝕊¹ᴱ × 𝕊¹ᴱ. 𝕊¹ᴱ≄𝕊¹ᴱ×𝕊¹ᴱ : ¬ 𝕊¹ᴱ ≃ (𝕊¹ᴱ × 𝕊¹ᴱ) 𝕊¹ᴱ≄𝕊¹ᴱ×𝕊¹ᴱ = Stable-¬ [ 𝕊¹ᴱ ≃ (𝕊¹ᴱ × 𝕊¹ᴱ) ↔⟨ Eq.≃-preserves ext (inverse 𝕊¹≃𝕊¹ᴱ) (inverse $ 𝕊¹≃𝕊¹ᴱ ×-cong 𝕊¹≃𝕊¹ᴱ) ⟩ 𝕊¹ ≃ (𝕊¹ × 𝕊¹) ↝⟨ C.𝕊¹≄𝕊¹×𝕊¹ ⟩□ ⊥ □ ]
{ "alphanum_fraction": 0.457252022, "avg_line_length": 38.4599236641, "ext": "agda", "hexsha": "048d52b32f4a2d39f25724b4e61baa45794587a7", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/equality", "max_forks_repo_path": "src/Circle/Erased.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/equality", "max_issues_repo_path": "src/Circle/Erased.agda", "max_line_length": 146, "max_stars_count": 3, "max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/equality", "max_stars_repo_path": "src/Circle/Erased.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z", "num_tokens": 8480, "size": 20153 }
module _ (_ : Set) where open import Imports.Issue5198 Set data D : Set where r : D F : D → Set₂ F r = R f : {d : D} → F d → F d f x = x _ : R _ = f record {A = Set}
{ "alphanum_fraction": 0.5344827586, "avg_line_length": 10.2352941176, "ext": "agda", "hexsha": "7ecdcc96e69a380d9737c4aceea0d39e14c4b91c", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue5198.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue5198.agda", "max_line_length": 33, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue5198.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 73, "size": 174 }
-- Andreas, 2017-01-12, issue #2386 postulate A : Set data _≡_ (x : A) : A → Set where refl : x ≡ x {-# BUILTIN EQUALITY _≡_ #-} -- Monomorphic equality is not accepted. -- If needed, this could change in the future.
{ "alphanum_fraction": 0.6327433628, "avg_line_length": 16.1428571429, "ext": "agda", "hexsha": "abb4d1f5fc156b0f74c0d706566f9d61e684a243", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/Issue2386MonomorphicEquality.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/Issue2386MonomorphicEquality.agda", "max_line_length": 46, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue2386MonomorphicEquality.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 77, "size": 226 }
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-} module Light.Library.Data.These where open import Light.Level using (Setω ; Level) open import Light.Variable.Levels open import Light.Variable.Sets record Dependencies : Setω where record Library (dependencies : Dependencies) : Setω where field ℓf : Level → Level → Level These : Set aℓ → Set bℓ → Set (ℓf aℓ bℓ) this : 𝕒 → These 𝕒 𝕓 that : 𝕓 → These 𝕒 𝕓 these : 𝕒 → 𝕓 → These 𝕒 𝕓 open Library ⦃ ... ⦄ public
{ "alphanum_fraction": 0.6303571429, "avg_line_length": 29.4736842105, "ext": "agda", "hexsha": "2470c76bf0bd6e6804aded3032aebb30b67eff9c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "Zambonifofex/lightlib", "max_forks_repo_path": "Light/Library/Data/These.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "Zambonifofex/lightlib", "max_issues_repo_path": "Light/Library/Data/These.agda", "max_line_length": 79, "max_stars_count": 1, "max_stars_repo_head_hexsha": "44b1c724f2de95d3a9effe87ca36ef9eca8b4756", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "zamfofex/lightlib", "max_stars_repo_path": "Light/Library/Data/These.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-20T21:33:05.000Z", "max_stars_repo_stars_event_min_datetime": "2019-12-20T21:33:05.000Z", "num_tokens": 169, "size": 560 }
-- {-# OPTIONS --show-implicit #-} -- {-# OPTIONS -v tc.meta:25 #-} module NoBlockOnLevel where open import Common.Level open import Common.Product BSetoid : ∀ c → Set (lsuc c) BSetoid c = Set c infixr 0 _⟶_ postulate _⟶_ : ∀ {f t} → BSetoid f → BSetoid t → Set (f ⊔ t) →-to-⟶ : ∀ {a b} {A : Set a} {B : BSetoid b} → (A → B) → A ⟶ B postulate a b p : Level A : Set a B : Set b P : A → B → Set p -- This will leave unsolved metas if we give up on an unsolved level constraint -- when checking argument spines. Since we can't match on levels it's safe to keep -- checking later constraints even if they depend on the unsolved levels. f : (∃ λ x → ∃ λ y → P x y) ⟶ (∃ λ y → ∃ λ x → P x y) f = →-to-⟶ λ p → proj₁ (proj₂ p) , proj₁ p , proj₂ (proj₂ p)
{ "alphanum_fraction": 0.5971685972, "avg_line_length": 25.9, "ext": "agda", "hexsha": "74f5bb65437897cafbbd0c31f01c6b801537af8c", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/NoBlockOnLevel.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/NoBlockOnLevel.agda", "max_line_length": 82, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/NoBlockOnLevel.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 287, "size": 777 }
-- {-# OPTIONS -v term:20 -v tc.term:20 #-} -- {-# OPTIONS -v tc.def.alias:100 -v tc.term.expr.coind:100 #-} module Issue807 where open import Common.Coinduction data Stream : Set where cons : ∞ Stream → Stream mutual -- s : Stream s = cons s′ -- s′ : ∞ _ s′ = ♯ s -- Under 2.3.0.1: The code is accepted. -- Under 2.3.2: The termination checker complains. -- Bug was that aliases did not lead to construction of ♯-auxiliary function.
{ "alphanum_fraction": 0.6387665198, "avg_line_length": 20.6363636364, "ext": "agda", "hexsha": "5864ad555148d25cd5e3d67557ce409bfb432958", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "alhassy/agda", "max_forks_repo_path": "test/Succeed/Issue807.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "alhassy/agda", "max_issues_repo_path": "test/Succeed/Issue807.agda", "max_line_length": 77, "max_stars_count": 3, "max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "alhassy/agda", "max_stars_repo_path": "test/Succeed/Issue807.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 146, "size": 454 }
{-# OPTIONS --erased-cubical --save-metas #-} module Erased-cubical-Pattern-matching-Erased where open import Agda.Builtin.String open import Erased-cubical-Pattern-matching-Cubical -- If c₁ and c₂ are treated as erased, then f might be compiled to -- something akin to ⊥-elim. However, the main module uses -- --cubical, not --erased-cubical, so f should not be compiled in -- that way. f : D → String f c₁ = "Success\n" f c₂ = "Failure\n"
{ "alphanum_fraction": 0.7235955056, "avg_line_length": 27.8125, "ext": "agda", "hexsha": "4eacb1c6ba004b7cee9b55618e0992716af9c642", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "Seanpm2001-Agda-lang/agda", "max_forks_repo_path": "test/Compiler/simple/Erased-cubical-Pattern-matching-Erased.agda", "max_issues_count": 6, "max_issues_repo_head_hexsha": "b5b3b1657556f720a7310cb7744edb1fac71eaf4", "max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z", "max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "Seanpm2001-Agda-lang/agda", "max_issues_repo_path": "test/Compiler/simple/Erased-cubical-Pattern-matching-Erased.agda", "max_line_length": 66, "max_stars_count": 1, "max_stars_repo_head_hexsha": "6b13364d36eeb60d8ec15eaf8effe23c73401900", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "sseefried/agda", "max_stars_repo_path": "test/Compiler/simple/Erased-cubical-Pattern-matching-Erased.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-05T00:25:14.000Z", "max_stars_repo_stars_event_min_datetime": "2022-03-05T00:25:14.000Z", "num_tokens": 134, "size": 445 }
{-# OPTIONS --cubical #-} module Type.Cubical.InductiveInterval where open import Functional import Lvl open import Type import Type.Cubical as Cubical import Type.Cubical.Path as Cubical import Type.Cubical.Path.Proofs as Cubical private variable ℓ ℓ₁ ℓ₂ : Lvl.Level private variable A B P : Type{ℓ} data Interval : Type{Lvl.𝟎} where 𝟎 : Interval 𝟏 : Interval segment : Cubical.Path 𝟎 𝟏 elim : (P : Interval → Type{ℓ}) → (p0 : P(𝟎)) → (p1 : P(𝟏)) → (Cubical.PathP(\i → P(segment i)) p0 p1) → ((i : Interval) → P(i)) elim(P) p0 _ _ 𝟎 = p0 elim(P) _ p1 _ 𝟏 = p1 elim(P) _ _ ps (segment i) = ps(i) flip : Interval → Interval flip 𝟎 = 𝟏 flip 𝟏 = 𝟎 flip (segment i) = segment(Cubical.Interval.flip i) min : Interval → Interval → Interval min 𝟎 𝟎 = 𝟎 min 𝟎 𝟏 = 𝟎 min 𝟏 𝟎 = 𝟎 min 𝟏 𝟏 = 𝟏 min 𝟎 (segment i) = 𝟎 min 𝟏 (segment i) = segment i min (segment i) 𝟎 = 𝟎 min (segment i) 𝟏 = segment i min (segment i) (segment j) = segment(Cubical.Interval.min i j) max : Interval → Interval → Interval max = flip ∘₂ (min on₂ flip) open import Structure.Relator.Properties open import Type.Cubical.Path.Equality open import Type.Properties.Singleton instance Interval-unit : IsUnit(Interval) IsUnit.unit Interval-unit = 𝟏 IsUnit.uniqueness Interval-unit {𝟎} = segment IsUnit.uniqueness Interval-unit {𝟏} = reflexivity(Cubical.Path) IsUnit.uniqueness Interval-unit {segment i} j = segment(Cubical.Interval.max i j) transp : (P : Interval → Type{ℓ}) → P(𝟎) → P(𝟏) transp(P) = sub₂(Cubical.Path)(_→ᶠ_) (Cubical.map P(segment))
{ "alphanum_fraction": 0.6493902439, "avg_line_length": 28.7719298246, "ext": "agda", "hexsha": "b11defe370581e21fd703922185b4853dc12bd4d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Type/Cubical/InductiveInterval.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Type/Cubical/InductiveInterval.agda", "max_line_length": 128, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Type/Cubical/InductiveInterval.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 619, "size": 1640 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Properties related to negation ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Relation.Nullary.Negation where open import Category.Monad open import Data.Bool.Base using (Bool; false; true; if_then_else_) open import Data.Empty open import Data.Product as Prod open import Data.Sum as Sum using (_⊎_; inj₁; inj₂; [_,_]) open import Function open import Level open import Relation.Nullary open import Relation.Unary contradiction : ∀ {p w} {P : Set p} {Whatever : Set w} → P → ¬ P → Whatever contradiction p ¬p = ⊥-elim (¬p p) contraposition : ∀ {p q} {P : Set p} {Q : Set q} → (P → Q) → ¬ Q → ¬ P contraposition f ¬q p = contradiction (f p) ¬q -- Note also the following use of flip: private note : ∀ {p q} {P : Set p} {Q : Set q} → (P → ¬ Q) → Q → ¬ P note = flip -- If we can decide P, then we can decide its negation. ¬? : ∀ {p} {P : Set p} → Dec P → Dec (¬ P) ¬? (yes p) = no (λ ¬p → ¬p p) ¬? (no ¬p) = yes ¬p ------------------------------------------------------------------------ -- Quantifier juggling ∃⟶¬∀¬ : ∀ {a p} {A : Set a} {P : A → Set p} → ∃ P → ¬ (∀ x → ¬ P x) ∃⟶¬∀¬ = flip uncurry ∀⟶¬∃¬ : ∀ {a p} {A : Set a} {P : A → Set p} → (∀ x → P x) → ¬ ∃ λ x → ¬ P x ∀⟶¬∃¬ ∀xPx (x , ¬Px) = ¬Px (∀xPx x) ¬∃⟶∀¬ : ∀ {a p} {A : Set a} {P : A → Set p} → ¬ ∃ (λ x → P x) → ∀ x → ¬ P x ¬∃⟶∀¬ = curry ∀¬⟶¬∃ : ∀ {a p} {A : Set a} {P : A → Set p} → (∀ x → ¬ P x) → ¬ ∃ (λ x → P x) ∀¬⟶¬∃ = uncurry ∃¬⟶¬∀ : ∀ {a p} {A : Set a} {P : A → Set p} → ∃ (λ x → ¬ P x) → ¬ (∀ x → P x) ∃¬⟶¬∀ = flip ∀⟶¬∃¬ ------------------------------------------------------------------------ -- Double-negation ¬¬-map : ∀ {p q} {P : Set p} {Q : Set q} → (P → Q) → ¬ ¬ P → ¬ ¬ Q ¬¬-map f = contraposition (contraposition f) -- Stability under double-negation. Stable : ∀ {ℓ} → Set ℓ → Set ℓ Stable P = ¬ ¬ P → P -- Everything is stable in the double-negation monad. stable : ∀ {p} {P : Set p} → ¬ ¬ Stable P stable ¬[¬¬p→p] = ¬[¬¬p→p] (λ ¬¬p → ⊥-elim (¬¬p (¬[¬¬p→p] ∘ const))) -- Negated predicates are stable. negated-stable : ∀ {p} {P : Set p} → Stable (¬ P) negated-stable ¬¬¬P P = ¬¬¬P (λ ¬P → ¬P P) -- Decidable predicates are stable. decidable-stable : ∀ {p} {P : Set p} → Dec P → Stable P decidable-stable (yes p) ¬¬p = p decidable-stable (no ¬p) ¬¬p = ⊥-elim (¬¬p ¬p) ¬-drop-Dec : ∀ {p} {P : Set p} → Dec (¬ ¬ P) → Dec (¬ P) ¬-drop-Dec (yes ¬¬p) = no ¬¬p ¬-drop-Dec (no ¬¬¬p) = yes (negated-stable ¬¬¬p) -- Double-negation is a monad (if we assume that all elements of ¬ ¬ P -- are equal). ¬¬-Monad : ∀ {p} → RawMonad (λ (P : Set p) → ¬ ¬ P) ¬¬-Monad = record { return = contradiction ; _>>=_ = λ x f → negated-stable (¬¬-map f x) } ¬¬-push : ∀ {p q} {P : Set p} {Q : P → Set q} → ¬ ¬ ((x : P) → Q x) → (x : P) → ¬ ¬ Q x ¬¬-push ¬¬P⟶Q P ¬Q = ¬¬P⟶Q (λ P⟶Q → ¬Q (P⟶Q P)) -- A double-negation-translated variant of excluded middle (or: every -- nullary relation is decidable in the double-negation monad). excluded-middle : ∀ {p} {P : Set p} → ¬ ¬ Dec P excluded-middle ¬h = ¬h (no (λ p → ¬h (yes p))) -- If Whatever is instantiated with ¬ ¬ something, then this function -- is call with current continuation in the double-negation monad, or, -- if you will, a double-negation translation of Peirce's law. -- -- In order to prove ¬ ¬ P one can assume ¬ P and prove ⊥. However, -- sometimes it is nice to avoid leaving the double-negation monad; in -- that case this function can be used (with Whatever instantiated to -- ⊥). call/cc : ∀ {w p} {Whatever : Set w} {P : Set p} → ((P → Whatever) → ¬ ¬ P) → ¬ ¬ P call/cc hyp ¬p = hyp (λ p → ⊥-elim (¬p p)) ¬p -- The "independence of premise" rule, in the double-negation monad. -- It is assumed that the index set (Q) is inhabited. independence-of-premise : ∀ {p q r} {P : Set p} {Q : Set q} {R : Q → Set r} → Q → (P → Σ Q R) → ¬ ¬ (Σ[ x ∈ Q ] (P → R x)) independence-of-premise {P = P} q f = ¬¬-map helper excluded-middle where helper : Dec P → _ helper (yes p) = Prod.map id const (f p) helper (no ¬p) = (q , ⊥-elim ∘′ ¬p) -- The independence of premise rule for binary sums. independence-of-premise-⊎ : ∀ {p q r} {P : Set p} {Q : Set q} {R : Set r} → (P → Q ⊎ R) → ¬ ¬ ((P → Q) ⊎ (P → R)) independence-of-premise-⊎ {P = P} f = ¬¬-map helper excluded-middle where helper : Dec P → _ helper (yes p) = Sum.map const const (f p) helper (no ¬p) = inj₁ (⊥-elim ∘′ ¬p) private -- Note that independence-of-premise-⊎ is a consequence of -- independence-of-premise (for simplicity it is assumed that Q and -- R have the same type here): corollary : ∀ {p ℓ} {P : Set p} {Q R : Set ℓ} → (P → Q ⊎ R) → ¬ ¬ ((P → Q) ⊎ (P → R)) corollary {P = P} {Q} {R} f = ¬¬-map helper (independence-of-premise true ([ _,_ true , _,_ false ] ∘′ f)) where helper : ∃ (λ b → P → if b then Q else R) → (P → Q) ⊎ (P → R) helper (true , f) = inj₁ f helper (false , f) = inj₂ f ------------------------------------------------------------------------ -- DEPRECATED NAMES ------------------------------------------------------------------------ -- Please use the new names as continuing support for the old names is -- not guaranteed. -- Version 1.0 Excluded-Middle : (ℓ : Level) → Set (suc ℓ) Excluded-Middle p = {P : Set p} → Dec P {-# WARNING_ON_USAGE Excluded-Middle "Warning: Excluded-Middle was deprecated in v1.0. Please use ExcludedMiddle from `Axiom.ExcludedMiddle` instead." #-} Double-Negation-Elimination : (ℓ : Level) → Set (suc ℓ) Double-Negation-Elimination p = {P : Set p} → Stable P {-# WARNING_ON_USAGE Double-Negation-Elimination "Warning: Double-Negation-Elimination was deprecated in v1.0. Please use DoubleNegationElimination from `Axiom.DoubleNegationElimination` instead." #-}
{ "alphanum_fraction": 0.5183280809, "avg_line_length": 31.7315789474, "ext": "agda", "hexsha": "158ce718d928634240a04970f2369299cfea35d6", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "omega12345/agda-mode", "max_forks_repo_path": "test/asset/agda-stdlib-1.0/Relation/Nullary/Negation.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "omega12345/agda-mode", "max_issues_repo_path": "test/asset/agda-stdlib-1.0/Relation/Nullary/Negation.agda", "max_line_length": 85, "max_stars_count": null, "max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "omega12345/agda-mode", "max_stars_repo_path": "test/asset/agda-stdlib-1.0/Relation/Nullary/Negation.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 2151, "size": 6029 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Strings ------------------------------------------------------------------------ module Data.String where open import Data.List as List using (_∷_; []; List) open import Data.Vec as Vec using (Vec) open import Data.Colist as Colist using (Colist) open import Data.Char as Char using (Char) open import Data.Bool using (Bool; true; false) open import Function open import Relation.Nullary open import Relation.Nullary.Decidable open import Relation.Binary open import Relation.Binary.List.StrictLex as StrictLex import Relation.Binary.On as On open import Relation.Binary.PropositionalEquality as PropEq using (_≡_) open import Relation.Binary.PropositionalEquality.TrustMe import Data.String.Core as Core open Core public using (String) open Core -- Possibly infinite strings. Costring : Set Costring = Colist Char ------------------------------------------------------------------------ -- Operations infixr 5 _++_ _++_ : String → String → String _++_ = primStringAppend toList : String → List Char toList = primStringToList fromList : List Char → String fromList = primStringFromList toList∘fromList : ∀ s → toList (fromList s) ≡ s toList∘fromList s = trustMe fromList∘toList : ∀ s → fromList (toList s) ≡ s fromList∘toList s = trustMe toVec : (s : String) → Vec Char (List.length (toList s)) toVec s = Vec.fromList (toList s) toCostring : String → Costring toCostring = Colist.fromList ∘ toList unlines : List String → String unlines [] = "" unlines (x ∷ xs) = x ++ "\n" ++ unlines xs show : String → String show = primShowString -- Informative equality test. _≟_ : Decidable {A = String} _≡_ s₁ ≟ s₂ with primStringEquality s₁ s₂ ... | true = yes trustMe ... | false = no whatever where postulate whatever : _ -- Boolean equality test. -- -- Why is the definition _==_ = primStringEquality not used? One -- reason is that the present definition can sometimes improve type -- inference, at least with the version of Agda that is current at the -- time of writing: see unit-test below. infix 4 _==_ _==_ : String → String → Bool s₁ == s₂ = ⌊ s₁ ≟ s₂ ⌋ private -- The following unit test does not type-check (at the time of -- writing) if _==_ is replaced by primStringEquality. data P : (String → Bool) → Set where p : (c : String) → P (_==_ c) unit-test : P (_==_ "") unit-test = p _ setoid : Setoid _ _ setoid = PropEq.setoid String decSetoid : DecSetoid _ _ decSetoid = PropEq.decSetoid _≟_ -- Lexicographic ordering of strings. strictTotalOrder : StrictTotalOrder _ _ _ strictTotalOrder = On.strictTotalOrder (StrictLex.<-strictTotalOrder Char.strictTotalOrder) toList
{ "alphanum_fraction": 0.6637522769, "avg_line_length": 25.1834862385, "ext": "agda", "hexsha": "7a4ff66cb02a24f73db9fe8ebaf54165f094dc06", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Data/String.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/String.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/String.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 718, "size": 2745 }
{-# OPTIONS --no-auto-inline #-} -- Agda doesn't have an Int type (only Word64). With some work we -- can represent signed ints using Word64. module Haskell.Prim.Int where open import Agda.Builtin.Nat open import Agda.Builtin.Word renaming (primWord64ToNat to w2n; primWord64FromNat to n2w) open import Agda.Builtin.List open import Agda.Builtin.Char open import Agda.Builtin.String open import Agda.Builtin.Unit open import Agda.Builtin.Int using (pos; negsuc) open import Agda.Builtin.Equality open import Haskell.Prim open import Haskell.Prim.Word open import Haskell.Prim.Integer open import Haskell.Prim.Bool -------------------------------------------------- -- Definition data Int : Set where int64 : Word64 → Int intToWord : Int → Word64 intToWord (int64 a) = a unsafeIntToNat : Int → Nat unsafeIntToNat a = w2n (intToWord a) -------------------------------------------------- -- Literals private 2⁶⁴ : Nat 2⁶⁴ = 18446744073709551616 2⁶³ : Nat 2⁶³ = 9223372036854775808 maxInt : Nat maxInt = 2⁶³ - 1 instance iNumberInt : Number Int iNumberInt .Number.Constraint n = IsTrue (n < 2⁶³) iNumberInt .fromNat n = int64 (n2w n) iNegativeInt : Negative Int iNegativeInt .Negative.Constraint n = IsTrue (n < 1 + 2⁶³) iNegativeInt .fromNeg n = int64 (n2w (2⁶⁴ - n)) -------------------------------------------------- -- Arithmetic isNegativeInt : Int → Bool isNegativeInt (int64 w) = maxInt < w2n w eqInt : Int → Int → Bool eqInt (int64 a) (int64 b) = w2n a == w2n b negateInt : Int → Int negateInt (int64 a) = int64 (n2w (2⁶⁴ - w2n a)) intToInteger : Int → Integer intToInteger a = if isNegativeInt a then negsuc (unsafeIntToNat (negateInt a) - 1) else pos (unsafeIntToNat a) integerToInt : Integer → Int integerToInt (pos n) = int64 (n2w n) integerToInt (negsuc n) = negateInt (int64 (n2w (suc n))) private ltPosInt : Int → Int → Bool ltPosInt (int64 a) (int64 b) = ltWord a b ltInt : Int → Int → Bool ltInt a b with isNegativeInt a | isNegativeInt b ... | true | false = true ... | false | true = false ... | true | true = ltPosInt (negateInt b) (negateInt a) ... | false | false = ltPosInt a b addInt : Int → Int → Int addInt (int64 a) (int64 b) = int64 (addWord a b) subInt : Int → Int → Int subInt a b = addInt a (negateInt b) mulInt : Int → Int → Int mulInt (int64 a) (int64 b) = int64 (mulWord a b) absInt : Int → Int absInt a = if isNegativeInt a then negateInt a else a signInt : Int → Int signInt a = if isNegativeInt a then -1 else if eqInt a 0 then 0 else 1 showInt : Int → List Char showInt a = showInteger (intToInteger a) -------------------------------------------------- -- Constraints IsNonNegativeInt : Int → Set IsNonNegativeInt a@(int64 _) = if isNegativeInt a then TypeError (primStringAppend (primStringFromList (showInt a)) " is negative") else ⊤ intToNat : (a : Int) → ⦃ IsNonNegativeInt a ⦄ → Nat intToNat a = unsafeIntToNat a
{ "alphanum_fraction": 0.638510143, "avg_line_length": 25.0583333333, "ext": "agda", "hexsha": "b2241ed59ed60d6c16798bd3d1619423832d0895", "lang": "Agda", "max_forks_count": 18, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:42:52.000Z", "max_forks_repo_forks_event_min_datetime": "2020-10-21T22:19:09.000Z", "max_forks_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "seanpm2001/agda2hs", "max_forks_repo_path": "lib/Haskell/Prim/Int.agda", "max_issues_count": 63, "max_issues_repo_head_hexsha": "160478a51bc78b0fdab07b968464420439f9fed6", "max_issues_repo_issues_event_max_datetime": "2022-02-25T15:47:30.000Z", "max_issues_repo_issues_event_min_datetime": "2020-10-22T05:19:27.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "seanpm2001/agda2hs", "max_issues_repo_path": "lib/Haskell/Prim/Int.agda", "max_line_length": 102, "max_stars_count": 55, "max_stars_repo_head_hexsha": "8c8f24a079ed9677dbe6893cf786e7ed52dfe8b6", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dxts/agda2hs", "max_stars_repo_path": "lib/Haskell/Prim/Int.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-26T21:57:56.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-20T13:36:25.000Z", "num_tokens": 961, "size": 3007 }
module Vecs.Reverse where open import Vecs open import Nats open import Equality open import Function ------------------------------------------------------------------------ -- internal stuffs private -- rev$v:a=a:rev$v : ∀ {n m} {A : Set n} (a : A) (v : Vec A m) → -- rev (v ∷ʳ a) ≡ a ∷ rev v -- rev$v:a=a:rev$v _ [] = refl -- rev$v:a=a:rev$v a (_ ∷ xs) with rev (xs ∷ʳ a) | rev$v:a=a:rev$v a xs -- ... | .(a ∷ rev xs) | refl = refl rev$v:a=a:rev$v : ∀ {n m} {A : Set n} (a : A) (v : Vec A m) → reverse (v ∷ʳ a) ≡ a ∷ reverse v rev$v:a=a:rev$v _ [] = refl rev$v:a=a:rev$v a (_ ∷ xs) rewrite rev$v:a=a:rev$v a xs = refl rev∘rev=id : ∀ {n m} {A : Set n} (v : Vec A m) → reverse (reverse v) ≡ v rev∘rev=id [] = refl rev∘rev=id (x ∷ xs) rewrite rev$v:a=a:rev$v x $ reverse xs | rev∘rev=id xs = refl ------------------------------------------------------------------------ -- public aliases vec-rev-rev-id : ∀ {n m} {A : Set n} (v : Vec A m) → reverse (reverse v) ≡ v vec-rev-rev-id = rev∘rev=id
{ "alphanum_fraction": 0.4262877442, "avg_line_length": 29.6315789474, "ext": "agda", "hexsha": "7e55305376d4ca16fc685913382ef14dddea4fd3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ice1k/Theorems", "max_forks_repo_path": "src/Vecs/Reverse.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "ice1k/Theorems", "max_issues_repo_path": "src/Vecs/Reverse.agda", "max_line_length": 76, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ice1k/Theorems", "max_stars_repo_path": "src/Vecs/Reverse.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z", "num_tokens": 389, "size": 1126 }
-- This file needs to be rewritten so that Rng's are defined as a -- record (as is the case for other algebraic structures like -- rings). As this file isn't used for anything at the moment this -- rewrite has been postponed. {-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Experiments.Rng where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Equiv open import Cubical.Foundations.HLevels open import Cubical.Foundations.SIP open import Cubical.Data.Sigma open import Cubical.Structures.Axioms open import Cubical.Structures.Auto open import Cubical.Structures.Macro open import Cubical.Algebra.Semigroup hiding (⟨_⟩) open import Cubical.Algebra.AbGroup private variable ℓ ℓ' : Level module _ {ℓ} where rawRngDesc : Desc ℓ rawRngDesc = autoDesc (λ (X : Type ℓ) → (X → X → X) × (X → X → X)) open Macro ℓ rawRngDesc public renaming ( structure to RawRngStructure ; equiv to RawRngEquivStr ; univalent to rawRngUnivalentStr ) RngAxioms : (X : Type ℓ) (s : RawRngStructure X) → Type ℓ RngAxioms X (_·_ , _+_) = AbGroupΣTheory.AbGroupAxioms X _·_ × SemigroupΣTheory.SemigroupAxioms X _+_ × ((x y z : X) → x · (y + z) ≡ (x · y) + (x · z)) × ((x y z : X) → (x + y) · z ≡ (x · z) + (y · z)) RngStructure : Type ℓ → Type ℓ RngStructure = AxiomsStructure RawRngStructure RngAxioms Rng : Type (ℓ-suc ℓ) Rng {ℓ} = TypeWithStr ℓ RngStructure RngEquivStr : StrEquiv RngStructure ℓ RngEquivStr = AxiomsEquivStr RawRngEquivStr RngAxioms isPropRngAxioms : (X : Type ℓ) (s : RawRngStructure X) → isProp (RngAxioms X s) isPropRngAxioms X (_·_ , _+_) = isPropΣ (AbGroupΣTheory.isPropAbGroupAxioms X _·_) λ _ → isPropΣ (SemigroupΣTheory.isPropSemigroupAxioms X _+_) λ { (isSetX , _) → isPropΣ (isPropΠ3 (λ _ _ _ → isSetX _ _)) λ _ → isPropΠ3 (λ _ _ _ → isSetX _ _)} rngUnivalentStr : UnivalentStr {ℓ} RngStructure RngEquivStr rngUnivalentStr = axiomsUnivalentStr _ isPropRngAxioms rawRngUnivalentStr RngPath : (M N : Rng {ℓ}) → (M ≃[ RngEquivStr ] N) ≃ (M ≡ N) RngPath = SIP rngUnivalentStr
{ "alphanum_fraction": 0.6822386679, "avg_line_length": 35.4426229508, "ext": "agda", "hexsha": "62d261172facde73bc8391faf7be9fb053d49a5e", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "knrafto/cubical", "max_forks_repo_path": "Cubical/Experiments/Rng.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "knrafto/cubical", "max_issues_repo_path": "Cubical/Experiments/Rng.agda", "max_line_length": 99, "max_stars_count": null, "max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "knrafto/cubical", "max_stars_repo_path": "Cubical/Experiments/Rng.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 760, "size": 2162 }
module Issue27 where infix 4 _≡_ infixl 4 _>_ _<_ infixr 1 _∨_ postulate ℝ : Set ------------------------------------------------------------------------------ -- Logic stuff -- The identity type on the universe of discourse. data _≡_ (x : ℝ) : ℝ → Set where refl : x ≡ x data _∨_ (A B : Set) : Set where inj₁ : A → A ∨ B inj₂ : B → A ∨ B case : ∀ {A B} → {C : Set} → (A → C) → (B → C) → A ∨ B → C case f g (inj₁ a) = f a case f g (inj₂ b) = g b ------------------------------------------------------------------------------ -- Real numbers stuff postulate _>_ : ℝ → ℝ → Set _<_ : ℝ → ℝ → Set y < x = x > y {-# ATP definition _<_ #-} postulate trichotomy : (x y : ℝ) → (x > y) ∨ (x ≡ y) ∨ (x < y) {-# ATP axiom trichotomy #-} ------------------------------------------------------------------------------ rmin : ℝ → ℝ → ℝ rmin x y = case (λ _ → y) (λ h → case (λ _ → x) (λ _ → x) h) (trichotomy x y) {-# ATP definition rmin #-} postulate foo : ∀ x y → rmin x y ≡ rmin x y {-# ATP prove foo #-} {- Error: $ apia --check Issue27.agda apia: tptp4X found an error/warning in the file /tmp/Issue27/44-foo.fof Please report this as a bug WARNING: Line 34 Char 159 Token "," : Multiple arity symbol n_62__46_8405600604384089447, arity 0 and now 2 WARNING: Line 34 Char 259 Token ")" : Multiple arity symbol n_60__48_8405600604384089447, arity 0 and now 2 WARNING: Line 34 Char 387 Token "," : Multiple arity symbol n_60__48_8405600604384089447, arity 0 and now 2 WARNING: Line 34 Char 460 Token ")" : Multiple arity symbol case_32_8405600604384089447, arity 5 and now 6 -}
{ "alphanum_fraction": 0.5355122564, "avg_line_length": 27.4310344828, "ext": "agda", "hexsha": "a851ba8327702e8aecd2fc34a78dd7d6476ea910", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z", "max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/apia", "max_forks_repo_path": "issues/Issue27.agda", "max_issues_count": 121, "max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/apia", "max_issues_repo_path": "issues/Issue27.agda", "max_line_length": 107, "max_stars_count": 10, "max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/apia", "max_stars_repo_path": "issues/Issue27.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z", "num_tokens": 531, "size": 1591 }
------------------------------------------------------------------------ -- The Agda standard library -- -- The identity function ------------------------------------------------------------------------ {-# OPTIONS --without-K --safe #-} module Function.Construct.Identity where open import Data.Product using (_,_) open import Function using (id) open import Function.Bundles import Function.Definitions as Definitions import Function.Structures as Structures open import Level open import Relation.Binary open import Relation.Binary.PropositionalEquality using (_≡_; setoid) private variable a ℓ : Level A : Set a ------------------------------------------------------------------------ -- Properties module _ (_≈_ : Rel A ℓ) where open Definitions _≈_ _≈_ injective : Injective id injective = id surjective : Reflexive _≈_ → Surjective id surjective refl x = x , refl bijective : Reflexive _≈_ → Bijective id bijective refl = injective , surjective refl inverseˡ : Reflexive _≈_ → Inverseˡ id id inverseˡ refl x = refl inverseʳ : Reflexive _≈_ → Inverseʳ id id inverseʳ refl x = refl inverseᵇ : Reflexive _≈_ → Inverseᵇ id id inverseᵇ refl = inverseˡ refl , inverseʳ refl ------------------------------------------------------------------------ -- Structures module _ {_≈_ : Rel A ℓ} (isEq : IsEquivalence _≈_) where open Structures _≈_ _≈_ open IsEquivalence isEq isCongruent : IsCongruent id isCongruent = record { cong = id ; isEquivalence₁ = isEq ; isEquivalence₂ = isEq } isInjection : IsInjection id isInjection = record { isCongruent = isCongruent ; injective = injective _≈_ } isSurjection : IsSurjection id isSurjection = record { isCongruent = isCongruent ; surjective = surjective _≈_ refl } isBijection : IsBijection id isBijection = record { isInjection = isInjection ; surjective = surjective _≈_ refl } isLeftInverse : IsLeftInverse id id isLeftInverse = record { isCongruent = isCongruent ; cong₂ = id ; inverseˡ = inverseˡ _≈_ refl } isRightInverse : IsRightInverse id id isRightInverse = record { isCongruent = isCongruent ; cong₂ = id ; inverseʳ = inverseʳ _≈_ refl } isInverse : IsInverse id id isInverse = record { isLeftInverse = isLeftInverse ; inverseʳ = inverseʳ _≈_ refl } ------------------------------------------------------------------------ -- Setoid bundles module _ (S : Setoid a ℓ) where open Setoid S injection : Injection S S injection = record { f = id ; cong = id ; injective = injective _≈_ } surjection : Surjection S S surjection = record { f = id ; cong = id ; surjective = surjective _≈_ refl } bijection : Bijection S S bijection = record { f = id ; cong = id ; bijective = bijective _≈_ refl } equivalence : Equivalence S S equivalence = record { f = id ; g = id ; cong₁ = id ; cong₂ = id } leftInverse : LeftInverse S S leftInverse = record { f = id ; g = id ; cong₁ = id ; cong₂ = id ; inverseˡ = inverseˡ _≈_ refl } rightInverse : RightInverse S S rightInverse = record { f = id ; g = id ; cong₁ = id ; cong₂ = id ; inverseʳ = inverseʳ _≈_ refl } inverse : Inverse S S inverse = record { f = id ; f⁻¹ = id ; cong₁ = id ; cong₂ = id ; inverse = inverseᵇ _≈_ refl } ------------------------------------------------------------------------ -- Propositional bundles module _ (A : Set a) where id-↣ : A ↣ A id-↣ = injection (setoid A) id-↠ : A ↠ A id-↠ = surjection (setoid A) id-⤖ : A ⤖ A id-⤖ = bijection (setoid A) id-⇔ : A ⇔ A id-⇔ = equivalence (setoid A) id-↩ : A ↩ A id-↩ = leftInverse (setoid A) id-↪ : A ↪ A id-↪ = rightInverse (setoid A) id-↔ : A ↔ A id-↔ = inverse (setoid A)
{ "alphanum_fraction": 0.5405935737, "avg_line_length": 21.3455497382, "ext": "agda", "hexsha": "2207a5789894e6497f96028bb47d708c27d0845e", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z", "max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "DreamLinuxer/popl21-artifact", "max_forks_repo_path": "agda-stdlib/src/Function/Construct/Identity.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "DreamLinuxer/popl21-artifact", "max_issues_repo_path": "agda-stdlib/src/Function/Construct/Identity.agda", "max_line_length": 72, "max_stars_count": 5, "max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "DreamLinuxer/popl21-artifact", "max_stars_repo_path": "agda-stdlib/src/Function/Construct/Identity.agda", "max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z", "num_tokens": 1251, "size": 4077 }
------------------------------------------------------------------------ -- Coinductive axiomatisation of subtyping ------------------------------------------------------------------------ module RecursiveTypes.Subtyping.Axiomatic.Coinductive where import Data.Empty as E open import Data.Fin using (Fin; zero; suc) open import Data.Nat using (ℕ; zero; suc) open import Codata.Musical.Notation open import Relation.Nullary open import RecursiveTypes.Syntax open import RecursiveTypes.Substitution open import RecursiveTypes.Semantics open import RecursiveTypes.Subtyping.Semantic.Coinductive as Sem using (_≤∞P_; _≤Coind_; ⟦_⟧P; ⌜_⌝; ⊥; ⊤; var; _⟶_; _≤⟨_⟩_) ------------------------------------------------------------------------ -- Definition -- This definition uses mixed induction and coinduction. Induction is -- used for rules like transitivity, whereas coinduction is used for -- structural rules. Benjamin Pierce observed in Types and Programming -- Languages that coinductive inference systems cannot be -- "declarative" (including rules like transitivity); they can be -- "algorithmic" (syntax-directed), though. However, by mixing -- induction and coinduction one can combine the benefits of -- coinduction and declarative inference systems. infixr 10 _⟶_ infix 4 _≤_ infix 3 _∎ infixr 2 _≤⟨_⟩_ data _≤_ {n} : Ty n → Ty n → Set where -- Structural rules. Note that the rule for _⟶_ is coinductive. ⊥ : ∀ {τ} → ⊥ ≤ τ ⊤ : ∀ {σ} → σ ≤ ⊤ _⟶_ : ∀ {σ₁ σ₂ τ₁ τ₂} (τ₁≤σ₁ : ∞ (τ₁ ≤ σ₁)) (σ₂≤τ₂ : ∞ (σ₂ ≤ τ₂)) → σ₁ ⟶ σ₂ ≤ τ₁ ⟶ τ₂ -- Rules for folding and unfolding μ. unfold : ∀ {τ₁ τ₂} → μ τ₁ ⟶ τ₂ ≤ unfold[μ τ₁ ⟶ τ₂ ] fold : ∀ {τ₁ τ₂} → unfold[μ τ₁ ⟶ τ₂ ] ≤ μ τ₁ ⟶ τ₂ -- Reflexivity. _∎ : ∀ τ → τ ≤ τ -- Transitivity. _≤⟨_⟩_ : ∀ τ₁ {τ₂ τ₃} (τ₁≤τ₂ : τ₁ ≤ τ₂) (τ₂≤τ₃ : τ₂ ≤ τ₃) → τ₁ ≤ τ₃ ------------------------------------------------------------------------ -- Equivalence -- The axiomatisation is equivalent to the semantic definitions of -- subtyping. soundP : ∀ {n} {σ τ : Ty n} → σ ≤ τ → ⟦ σ ⟧ ≤∞P ⟦ τ ⟧ soundP ⊥ = ⊥ soundP ⊤ = ⊤ soundP (τ₁≤σ₁ ⟶ σ₂≤τ₂) = ♯ soundP (♭ τ₁≤σ₁) ⟶ ♯ soundP (♭ σ₂≤τ₂) soundP unfold = ⌜ Sem.unfold ⌝ soundP fold = ⌜ Sem.fold ⌝ soundP (τ ∎) = ⌜ Sem.refl∞ _ ⌝ soundP (τ₁ ≤⟨ τ₁≤τ₂ ⟩ τ₂≤τ₃) = _ ≤⟨ soundP τ₁≤τ₂ ⟩ soundP τ₂≤τ₃ sound : ∀ {n} {σ τ : Ty n} → σ ≤ τ → σ ≤Coind τ sound σ≤τ = ⟦ soundP σ≤τ ⟧P complete : ∀ {n} (σ τ : Ty n) → σ ≤Coind τ → σ ≤ τ complete ⊥ _ _ = ⊥ complete _ ⊤ _ = ⊤ complete ⊤ ⊥ () complete ⊤ (var x) () complete ⊤ (σ ⟶ τ) () complete ⊤ (μ σ ⟶ τ) () complete (var x) ⊥ () complete (var x) (var .x) var = var x ∎ complete (var x) (σ ⟶ τ) () complete (var x) (μ σ ⟶ τ) () complete (σ₁ ⟶ σ₂) ⊥ () complete (σ₁ ⟶ σ₂) (var x) () complete (σ₁ ⟶ σ₂) (τ₁ ⟶ τ₂) (τ₁≤σ₁ ⟶ σ₂≤τ₂) = ♯ complete τ₁ σ₁ (♭ τ₁≤σ₁) ⟶ ♯ complete σ₂ τ₂ (♭ σ₂≤τ₂) complete (σ₁ ⟶ σ₂) (μ τ₁ ⟶ τ₂) (τ₁≤σ₁ ⟶ σ₂≤τ₂) = σ₁ ⟶ σ₂ ≤⟨ ♯ complete _ _ (♭ τ₁≤σ₁) ⟶ ♯ complete _ _ (♭ σ₂≤τ₂) ⟩ unfold[μ τ₁ ⟶ τ₂ ] ≤⟨ fold ⟩ μ τ₁ ⟶ τ₂ ∎ complete (μ σ₁ ⟶ σ₂) ⊥ () complete (μ σ₁ ⟶ σ₂) (var x) () complete (μ σ₁ ⟶ σ₂) (τ₁ ⟶ τ₂) (τ₁≤σ₁ ⟶ σ₂≤τ₂) = μ σ₁ ⟶ σ₂ ≤⟨ unfold ⟩ unfold[μ σ₁ ⟶ σ₂ ] ≤⟨ ♯ complete _ _ (♭ τ₁≤σ₁) ⟶ ♯ complete _ _ (♭ σ₂≤τ₂) ⟩ (τ₁ ⟶ τ₂) ∎ complete (μ σ₁ ⟶ σ₂) (μ τ₁ ⟶ τ₂) (τ₁≤σ₁ ⟶ σ₂≤τ₂) = μ σ₁ ⟶ σ₂ ≤⟨ unfold ⟩ unfold[μ σ₁ ⟶ σ₂ ] ≤⟨ ♯ complete _ _ (♭ τ₁≤σ₁) ⟶ ♯ complete _ _ (♭ σ₂≤τ₂) ⟩ unfold[μ τ₁ ⟶ τ₂ ] ≤⟨ fold ⟩ μ τ₁ ⟶ τ₂ ∎ ------------------------------------------------------------------------ -- The reflexivity constructor is essential -- Minor point: the constructor _∎ cannot be omitted. In -- RecursiveTypes.Subtyping.Axiomatic.Incorrect it is shown that -- _≤⟨_⟩_ is also essential. module ∎-Is-Essential where infixr 10 _⟶_ infix 4 _≤′_ infixr 2 _≤⟨_⟩_ data _≤′_ {n} : Ty n → Ty n → Set where ⊥ : ∀ {τ} → ⊥ ≤′ τ ⊤ : ∀ {σ} → σ ≤′ ⊤ _⟶_ : ∀ {σ₁ σ₂ τ₁ τ₂} (τ₁≤σ₁ : ∞ (τ₁ ≤′ σ₁)) (σ₂≤τ₂ : ∞ (σ₂ ≤′ τ₂)) → σ₁ ⟶ σ₂ ≤′ τ₁ ⟶ τ₂ unfold : ∀ {τ₁ τ₂} → μ τ₁ ⟶ τ₂ ≤′ unfold[μ τ₁ ⟶ τ₂ ] fold : ∀ {τ₁ τ₂} → unfold[μ τ₁ ⟶ τ₂ ] ≤′ μ τ₁ ⟶ τ₂ _≤⟨_⟩_ : ∀ τ₁ {τ₂ τ₃} (τ₁≤τ₂ : τ₁ ≤′ τ₂) (τ₂≤τ₃ : τ₂ ≤′ τ₃) → τ₁ ≤′ τ₃ sound′ : ∀ {n} {σ τ : Ty n} → σ ≤′ τ → σ ≤ τ sound′ ⊥ = ⊥ sound′ ⊤ = ⊤ sound′ (τ₁≤σ₁ ⟶ σ₂≤τ₂) = ♯ sound′ (♭ τ₁≤σ₁) ⟶ ♯ sound′ (♭ σ₂≤τ₂) sound′ unfold = unfold sound′ fold = fold sound′ (_ ≤⟨ τ₁≤τ₂ ⟩ τ₂≤τ₃) = _ ≤⟨ sound′ τ₁≤τ₂ ⟩ sound′ τ₂≤τ₃ x : Ty 1 x = var zero x≰′x : ¬ x ≤′ x x≰′x (.x ≤⟨ x≤′σ ⟩ σ≤x) = helper x≤′σ σ≤x where helper : ∀ {σ} → x ≤′ σ → σ ≤′ x → E.⊥ helper (.x ≤⟨ x≤σ₁ ⟩ σ₁≤σ₂) σ₂≤′x = helper x≤σ₁ (_ ≤⟨ σ₁≤σ₂ ⟩ σ₂≤′x) helper ⊤ ⊤≤′x with sound (sound′ ⊤≤′x) ... | () incomplete : ¬ (∀ {n} {σ τ : Ty n} → σ ≤ τ → σ ≤′ τ) incomplete hyp with x≰′x (hyp (x ∎)) ... | ()
{ "alphanum_fraction": 0.4712359977, "avg_line_length": 34.4248366013, "ext": "agda", "hexsha": "c05e5e7fae571794d0c53cb5c8f75677f6ff1408", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/codata", "max_forks_repo_path": "RecursiveTypes/Subtyping/Axiomatic/Coinductive.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/codata", "max_issues_repo_path": "RecursiveTypes/Subtyping/Axiomatic/Coinductive.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/codata", "max_stars_repo_path": "RecursiveTypes/Subtyping/Axiomatic/Coinductive.agda", "max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z", "max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z", "num_tokens": 2230, "size": 5267 }
-- Basic intuitionistic modal logic S4, without ∨, ⊥, or ◇. -- Hilbert-style formalisation of syntax with context pairs. -- Sequences of terms. module BasicIS4.Syntax.DyadicHilbertSequential where open import BasicIS4.Syntax.Common public -- Derivations. infix 3 _⊦⊢_ data _⊦⊢_ : Cx² Ty Ty → Cx Ty → Set where nil : ∀ {Γ Δ} → Γ ⁏ Δ ⊦⊢ ∅ var : ∀ {Ξ A Γ Δ} → A ∈ Γ → Γ ⁏ Δ ⊦⊢ Ξ → Γ ⁏ Δ ⊦⊢ Ξ , A mp : ∀ {Ξ A B Γ Δ} → A ▻ B ∈ Ξ → A ∈ Ξ → Γ ⁏ Δ ⊦⊢ Ξ → Γ ⁏ Δ ⊦⊢ Ξ , B ci : ∀ {Ξ A Γ Δ} → Γ ⁏ Δ ⊦⊢ Ξ → Γ ⁏ Δ ⊦⊢ Ξ , A ▻ A ck : ∀ {Ξ A B Γ Δ} → Γ ⁏ Δ ⊦⊢ Ξ → Γ ⁏ Δ ⊦⊢ Ξ , A ▻ B ▻ A cs : ∀ {Ξ A B C Γ Δ} → Γ ⁏ Δ ⊦⊢ Ξ → Γ ⁏ Δ ⊦⊢ Ξ , (A ▻ B ▻ C) ▻ (A ▻ B) ▻ A ▻ C mvar : ∀ {Ξ A Γ Δ} → A ∈ Δ → Γ ⁏ Δ ⊦⊢ Ξ → Γ ⁏ Δ ⊦⊢ Ξ , A nec : ∀ {Ξ Ξ′ A Γ Δ} → ∅ ⁏ Δ ⊦⊢ Ξ′ , A → Γ ⁏ Δ ⊦⊢ Ξ → Γ ⁏ Δ ⊦⊢ Ξ , □ A cdist : ∀ {Ξ A B Γ Δ} → Γ ⁏ Δ ⊦⊢ Ξ → Γ ⁏ Δ ⊦⊢ Ξ , □ (A ▻ B) ▻ □ A ▻ □ B cup : ∀ {Ξ A Γ Δ} → Γ ⁏ Δ ⊦⊢ Ξ → Γ ⁏ Δ ⊦⊢ Ξ , □ A ▻ □ □ A cdown : ∀ {Ξ A Γ Δ} → Γ ⁏ Δ ⊦⊢ Ξ → Γ ⁏ Δ ⊦⊢ Ξ , □ A ▻ A cpair : ∀ {Ξ A B Γ Δ} → Γ ⁏ Δ ⊦⊢ Ξ → Γ ⁏ Δ ⊦⊢ Ξ , A ▻ B ▻ A ∧ B cfst : ∀ {Ξ A B Γ Δ} → Γ ⁏ Δ ⊦⊢ Ξ → Γ ⁏ Δ ⊦⊢ Ξ , A ∧ B ▻ A csnd : ∀ {Ξ A B Γ Δ} → Γ ⁏ Δ ⊦⊢ Ξ → Γ ⁏ Δ ⊦⊢ Ξ , A ∧ B ▻ B unit : ∀ {Ξ Γ Δ} → Γ ⁏ Δ ⊦⊢ Ξ → Γ ⁏ Δ ⊦⊢ Ξ , ⊤ infix 3 _⊢_ _⊢_ : Cx² Ty Ty → Ty → Set Γ ⁏ Δ ⊢ A = ∃ (λ Ξ → Γ ⁏ Δ ⊦⊢ Ξ , A) -- Monotonicity with respect to context inclusion. mono⊦⊢ : ∀ {Ξ Γ Γ′ Δ} → Γ ⊆ Γ′ → Γ ⁏ Δ ⊦⊢ Ξ → Γ′ ⁏ Δ ⊦⊢ Ξ mono⊦⊢ η nil = nil mono⊦⊢ η (var i ts) = var (mono∈ η i) (mono⊦⊢ η ts) mono⊦⊢ η (mp i j ts) = mp i j (mono⊦⊢ η ts) mono⊦⊢ η (ci ts) = ci (mono⊦⊢ η ts) mono⊦⊢ η (ck ts) = ck (mono⊦⊢ η ts) mono⊦⊢ η (cs ts) = cs (mono⊦⊢ η ts) mono⊦⊢ η (mvar i ts) = mvar i (mono⊦⊢ η ts) mono⊦⊢ η (nec ss ts) = nec ss (mono⊦⊢ η ts) mono⊦⊢ η (cdist ts) = cdist (mono⊦⊢ η ts) mono⊦⊢ η (cup ts) = cup (mono⊦⊢ η ts) mono⊦⊢ η (cdown ts) = cdown (mono⊦⊢ η ts) mono⊦⊢ η (cpair ts) = cpair (mono⊦⊢ η ts) mono⊦⊢ η (cfst ts) = cfst (mono⊦⊢ η ts) mono⊦⊢ η (csnd ts) = csnd (mono⊦⊢ η ts) mono⊦⊢ η (unit ts) = unit (mono⊦⊢ η ts) mono⊢ : ∀ {A Γ Γ′ Δ} → Γ ⊆ Γ′ → Γ ⁏ Δ ⊢ A → Γ′ ⁏ Δ ⊢ A mono⊢ η (Ξ , ts) = Ξ , mono⊦⊢ η ts -- Monotonicity with respect to modal context inclusion. mmono⊦⊢ : ∀ {Ξ Γ Δ Δ′} → Δ ⊆ Δ′ → Γ ⁏ Δ ⊦⊢ Ξ → Γ ⁏ Δ′ ⊦⊢ Ξ mmono⊦⊢ θ nil = nil mmono⊦⊢ θ (var i ts) = var i (mmono⊦⊢ θ ts) mmono⊦⊢ θ (mp i j ts) = mp i j (mmono⊦⊢ θ ts) mmono⊦⊢ θ (ci ts) = ci (mmono⊦⊢ θ ts) mmono⊦⊢ θ (ck ts) = ck (mmono⊦⊢ θ ts) mmono⊦⊢ θ (cs ts) = cs (mmono⊦⊢ θ ts) mmono⊦⊢ θ (mvar i ts) = mvar (mono∈ θ i) (mmono⊦⊢ θ ts) mmono⊦⊢ θ (nec ss ts) = nec (mmono⊦⊢ θ ss) (mmono⊦⊢ θ ts) mmono⊦⊢ θ (cdist ts) = cdist (mmono⊦⊢ θ ts) mmono⊦⊢ θ (cup ts) = cup (mmono⊦⊢ θ ts) mmono⊦⊢ θ (cdown ts) = cdown (mmono⊦⊢ θ ts) mmono⊦⊢ θ (cpair ts) = cpair (mmono⊦⊢ θ ts) mmono⊦⊢ θ (cfst ts) = cfst (mmono⊦⊢ θ ts) mmono⊦⊢ θ (csnd ts) = csnd (mmono⊦⊢ θ ts) mmono⊦⊢ θ (unit ts) = unit (mmono⊦⊢ θ ts) mmono⊢ : ∀ {A Γ Δ Δ′} → Δ ⊆ Δ′ → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ′ ⊢ A mmono⊢ θ (Ξ , ts) = Ξ , mmono⊦⊢ θ ts -- Concatenation of derivations. _⧺⊦_ : ∀ {Γ Δ Ξ Ξ′} → Γ ⁏ Δ ⊦⊢ Ξ → Γ ⁏ Δ ⊦⊢ Ξ′ → Γ ⁏ Δ ⊦⊢ Ξ ⧺ Ξ′ us ⧺⊦ nil = us us ⧺⊦ var i ts = var i (us ⧺⊦ ts) us ⧺⊦ mp i j ts = mp (mono∈ weak⊆⧺₂ i) (mono∈ weak⊆⧺₂ j) (us ⧺⊦ ts) us ⧺⊦ ci ts = ci (us ⧺⊦ ts) us ⧺⊦ ck ts = ck (us ⧺⊦ ts) us ⧺⊦ cs ts = cs (us ⧺⊦ ts) us ⧺⊦ mvar i ts = mvar i (us ⧺⊦ ts) us ⧺⊦ nec ss ts = nec ss (us ⧺⊦ ts) us ⧺⊦ cdist ts = cdist (us ⧺⊦ ts) us ⧺⊦ cup ts = cup (us ⧺⊦ ts) us ⧺⊦ cdown ts = cdown (us ⧺⊦ ts) us ⧺⊦ cpair ts = cpair (us ⧺⊦ ts) us ⧺⊦ cfst ts = cfst (us ⧺⊦ ts) us ⧺⊦ csnd ts = csnd (us ⧺⊦ ts) us ⧺⊦ unit ts = unit (us ⧺⊦ ts) -- Modus ponens and necessitation in expanded form. app : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ A ▻ B → Γ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ B app {A} {B} (Ξ , ts) (Ξ′ , us) = Ξ″ , vs where Ξ″ = (Ξ′ , A) ⧺ (Ξ , A ▻ B) vs = mp top (mono∈ (weak⊆⧺₁ (Ξ , A ▻ B)) top) (us ⧺⊦ ts) box : ∀ {A Γ Δ} → ∅ ⁏ Δ ⊢ A → Γ ⁏ Δ ⊢ □ A box (Ξ , ts) = ∅ , nec ts nil
{ "alphanum_fraction": 0.4435663127, "avg_line_length": 36.8090909091, "ext": "agda", "hexsha": "96b8218061045498aea45855217cdb124a049a69", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_forks_repo_licenses": [ "X11" ], "max_forks_repo_name": "mietek/hilbert-gentzen", "max_forks_repo_path": "BasicIS4/Syntax/DyadicHilbertSequential.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z", "max_issues_repo_licenses": [ "X11" ], "max_issues_repo_name": "mietek/hilbert-gentzen", "max_issues_repo_path": "BasicIS4/Syntax/DyadicHilbertSequential.agda", "max_line_length": 83, "max_stars_count": 29, "max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c", "max_stars_repo_licenses": [ "X11" ], "max_stars_repo_name": "mietek/hilbert-gentzen", "max_stars_repo_path": "BasicIS4/Syntax/DyadicHilbertSequential.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z", "max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z", "num_tokens": 2652, "size": 4049 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} open import Cubical.Core.Everything open import Cubical.Foundations.HLevels module Cubical.Algebra.Monoid.Construct.Free {ℓ} (Aˢ : hSet ℓ) where open import Cubical.Foundations.Prelude open import Cubical.Foundations.Isomorphism open import Cubical.Foundations.Univalence open import Cubical.Foundations.Path open import Cubical.Algebra.Monoid open import Cubical.Data.Empty.Polymorphic open import Cubical.Data.Prod open import Cubical.Relation.Binary.Reasoning.Equality private A = ⟨ Aˢ ⟩ isSetA = Aˢ .snd ------------------------------------------------------------------------ -- The direct free monoid type data FreeM : Type ℓ where inj : A → FreeM _•_ : Op₂ FreeM ε : FreeM •-assoc : Associative _•_ ε-identityˡ : LeftIdentity ε _•_ ε-identityʳ : RightIdentity ε _•_ squash : isSet FreeM ε-identity : Identity ε _•_ ε-identity = ε-identityˡ , ε-identityʳ elim : ∀ {ℓ′} {B : FreeM → Type ℓ′} → (∀ x → isSet (B x)) → (∀ x → B (inj x)) → (op : ∀ {x y} → B x → B y → B (x • y)) → (e : B ε) → (∀ {x y z} (a : B x) (b : B y) (c : B z) → PathP (λ i → B (•-assoc x y z i)) (op (op a b) c) (op a (op b c))) → (∀ {x} (a : B x) → PathP (λ i → B (ε-identityˡ x i)) (op e a) a) → (∀ {x} (a : B x) → PathP (λ i → B (ε-identityʳ x i)) (op a e) a) → (x : FreeM) → B x elim isSetB f op e assc idˡ idʳ (inj x) = f x elim isSetB f op e assc idˡ idʳ (x • y) = op (elim isSetB f op e assc idˡ idʳ x) (elim isSetB f op e assc idˡ idʳ y) elim isSetB f op e assc idˡ idʳ ε = e elim isSetB f op e assc idˡ idʳ (•-assoc x y z i) = assc (elim isSetB f op e assc idˡ idʳ x) (elim isSetB f op e assc idˡ idʳ y) (elim isSetB f op e assc idˡ idʳ z) i elim isSetB f op e assc idˡ idʳ (ε-identityˡ x i) = idˡ (elim isSetB f op e assc idˡ idʳ x) i elim isSetB f op e assc idˡ idʳ (ε-identityʳ x i) = idʳ (elim isSetB f op e assc idˡ idʳ x) i elim isSetB f op e assc idˡ idʳ (squash x y p q i j) = isOfHLevel→isOfHLevelDep 2 isSetB (elim isSetB f op e assc idˡ idʳ x) (elim isSetB f op e assc idˡ idʳ y) (cong (elim isSetB f op e assc idˡ idʳ) p) (cong (elim isSetB f op e assc idˡ idʳ) q) (squash x y p q) i j ------------------------------------------------------------------------ -- The simplified free monoid type -- Defined in Cubical.Data.List open import Cubical.Data.List open Structures isSetA public ------------------------------------------------------------------------ -- Proving the two types are equivalent List→FreeM : List A → FreeM List→FreeM [] = ε List→FreeM (x ∷ xs) = inj x • List→FreeM xs FreeM→List : FreeM → List A FreeM→List = elim (λ _ → isOfHLevelList 0 isSetA) [_] _++_ [] ++-assoc ++-identityˡ ++-identityʳ ++-hom : Homomorphic₂ List→FreeM _++_ _•_ ++-hom [] ys = sym (ε-identityˡ _) ++-hom (x ∷ xs) ys = cong (inj x •_) (++-hom xs ys) ∙ sym (•-assoc (inj x) (List→FreeM xs) (List→FreeM ys)) List→FreeM→List : retract List→FreeM FreeM→List List→FreeM→List [] = refl List→FreeM→List (x ∷ xs) = cong (x ∷_) (List→FreeM→List xs) FreeM→List→FreeM : section List→FreeM FreeM→List FreeM→List→FreeM = elim (λ _ → isSet→isGroupoid squash _ _) (λ _ → ε-identityʳ _) sectionOp refl (λ _ _ _ → isOfHLevelPathP' 0 (squash _ _) _ _ .fst) (λ _ → isOfHLevelPathP' 0 (squash _ _) _ _ .fst) (λ _ → isOfHLevelPathP' 0 (squash _ _) _ _ .fst) where sectionOp : ∀ {x y} → List→FreeM (FreeM→List x) ≡ x → List→FreeM (FreeM→List y) ≡ y → List→FreeM (FreeM→List (x • y)) ≡ (x • y) sectionOp {x} {y} p q = List→FreeM (FreeM→List (x • y)) ≡⟨⟩ List→FreeM (FreeM→List x ++ FreeM→List y) ≡⟨ ++-hom (FreeM→List x) (FreeM→List y) ⟩ List→FreeM (FreeM→List x) • List→FreeM (FreeM→List y) ≡⟨ cong₂ _•_ p q ⟩ x • y ∎ List≃FreeM : List A ≃ FreeM List≃FreeM = isoToEquiv (iso List→FreeM FreeM→List FreeM→List→FreeM List→FreeM→List) List≡FreeM : List A ≡ FreeM List≡FreeM = ua List≃FreeM ------------------------------------------------------------------------ -- Monoid structure FreeM-isMonoid : IsMonoid FreeM _•_ ε FreeM-isMonoid = record { isSemigroup = record { isMagma = record { is-set = squash } ; assoc = •-assoc } ; identity = ε-identity } FreeMonoid : Monoid ℓ FreeMonoid = record { isMonoid = FreeM-isMonoid } EquivFreeM : MonoidEquiv ListMonoid FreeMonoid EquivFreeM = record { eq = List≃FreeM ; isHom = record { preservesOp = ++-hom ; preservesId = refl } } FreeMonoid≡ : ListMonoid ≡ FreeMonoid FreeMonoid≡ = uaMonoid EquivFreeM
{ "alphanum_fraction": 0.5577355406, "avg_line_length": 35.4565217391, "ext": "agda", "hexsha": "c5a84f1f78221fe46c40a31cc975e0cb82a51a33", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Algebra/Monoid/Construct/Free.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Algebra/Monoid/Construct/Free.agda", "max_line_length": 119, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Algebra/Monoid/Construct/Free.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1776, "size": 4893 }
module SolveAll-Norm where open import Common.Equality open import Common.List open import Common.Nat example = 0 ∷ 1 ∷ 2 ∷ [] test1 : length example ≡ {!!} test1 = refl reverse : {A : Set} → List A → List A reverse = go [] where go : {A : Set} → List A → List A → List A go acc [] = acc go acc (x ∷ xs) = go (x ∷ acc) xs test2 : reverse example ≡ {!!} test2 = refl
{ "alphanum_fraction": 0.6015625, "avg_line_length": 18.2857142857, "ext": "agda", "hexsha": "b261ef75c1c1afbdd89e695cd04757d607e23540", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/SolveAll-Norm.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/SolveAll-Norm.agda", "max_line_length": 43, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/SolveAll-Norm.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 132, "size": 384 }
open import Agda.Primitive open import Agda.Builtin.Equality open import Agda.Builtin.List open import Agda.Builtin.Reflection testQuote : quoteTerm Setω ≡ agda-sort (inf 0) testQuote = refl macro doUnquote : Term → Term → TC _ doUnquote t hole = bindTC (unquoteTC t) (unify hole) testUnquote : doUnquote (agda-sort (inf 0)) testUnquote = ∀ ℓ → Set ℓ
{ "alphanum_fraction": 0.7458100559, "avg_line_length": 23.8666666667, "ext": "agda", "hexsha": "c2721b12eca202d9cda4ae444a4c5735ebfc3c67", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Succeed/QuoteSetOmega.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Succeed/QuoteSetOmega.agda", "max_line_length": 54, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Succeed/QuoteSetOmega.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 115, "size": 358 }
module Issue62 where module A where data A : Set where a : A module B where open A data B : Set where a : B open B -- Note that a : A.A is not in scope here, so the following should not -- type check. foo : A.A -> A.A foo a = a
{ "alphanum_fraction": 0.609561753, "avg_line_length": 10.9130434783, "ext": "agda", "hexsha": "c6bede648163b67800408769fc7346ca18c616c0", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Fail/Issue62.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/Issue62.agda", "max_line_length": 70, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue62.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 81, "size": 251 }
{- 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 import LibraBFT.Impl.Consensus.ConsensusTypes.ProposalMsg as ProposalMsg import LibraBFT.Impl.Consensus.ConsensusTypes.VoteMsg as VoteMsg open import LibraBFT.ImplShared.Base.Types open import LibraBFT.ImplShared.Consensus.Types open import LibraBFT.ImplShared.NetworkMsg open import Optics.All open import Util.Prelude module LibraBFT.Impl.Consensus.Network where processProposal : {- NodeId → -} ProposalMsg → Epoch → ValidatorVerifier → Either (Either ErrLog InfoLog) Unit processProposal {- peerId -} proposal myEpoch vv = case pProposal of λ where (Left e) → Left (Left e) (Right unit) → grd‖ proposal ^∙ pmProposal ∙ bEpoch == myEpoch ≔ pure unit -- TODO : push this onto a queue if epoch is in future (is this still relevant?) ‖ proposal ^∙ pmProposal ∙ bEpoch == myEpoch + 1 ≔ Left (Right fakeInfo) -- proposal in new epoch arrived before my epoch change ‖ otherwise≔ Left (Left fakeErr) -- proposal for wrong epoch where pProposal = do ProposalMsg.verify proposal vv -- Note that our model does not assume knowledge of who sends a message, and therefore we do not -- check that the proposal is *sent* by the given peer (of course it must be *signed* by the -- peer, which is verified elsewhere). Our proof should not require this. {- lcheck (proposal ^∙ pmProposal ∙ bAuthor == just peerId) -} processVote : {- NodeId → -} VoteMsg → Epoch → ValidatorVerifier → Either (Either ErrLog InfoLog) Unit processVote {- peerId -} voteMsg myEpoch vv = case pVote of λ where (Left e) → Left (Left e) (Right unit) → grd‖ voteMsg ^∙ vmEpoch == myEpoch ≔ pure unit -- IMPL-TODO : push this onto a queue if epoch is in future (is this still relevant?) -- NOTE : epoch might be mismatched because -- - vote for EpochChange proposal round + 2 arrives -- after leader already already formed a quorum -- - timeout votes for previous or subsequent epochs arrive after the epoch change ‖ voteMsg ^∙ vmVote ∙ vVoteData ∙ vdProposed ∙ biEpoch + 1 == myEpoch ≔ Left (Right (fakeInfo {- (here $ "vote for previous epoch arrived after my epoch change" ∷ lsE myEpoch ∷ []) -})) ‖ voteMsg ^∙ vmVote ∙ vVoteData ∙ vdProposed ∙ biEpoch == myEpoch + 1 ≔ Left (Right (fakeInfo {- (here $ "vote for previous epoch arrived before my epoch change" ∷ lsE myEpoch ∷ []) -})) ‖ otherwise≔ Left (Left (fakeErr {- (here $ "vote for wrong epoch" ∷ lsE myEpoch ∷ [])-})) where -- here t = "Network" ∷ "processVote" ∷ lsVM voteMsg ∷ t pVote : Either ErrLog Unit pVote = do -- See comment above about checking which peer *sent* the message. -- lcheck (voteMsg ^∙ vmVote ∙ vAuthor == peerId) -- (here $ "vote received must be from the sending peer" ∷ lsA peerId ∷ []) VoteMsg.verify voteMsg vv
{ "alphanum_fraction": 0.6725912067, "avg_line_length": 49.3384615385, "ext": "agda", "hexsha": "11b62fe12e23f85565a1b0576216be2b94de1a92", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_forks_repo_licenses": [ "UPL-1.0" ], "max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_forks_repo_path": "src/LibraBFT/Impl/Consensus/Network.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "UPL-1.0" ], "max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_issues_repo_path": "src/LibraBFT/Impl/Consensus/Network.agda", "max_line_length": 125, "max_stars_count": null, "max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef", "max_stars_repo_licenses": [ "UPL-1.0" ], "max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda", "max_stars_repo_path": "src/LibraBFT/Impl/Consensus/Network.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 882, "size": 3207 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Semirings.Definition module Semirings.Lemmas {a : _} {A : Set a} {Zero One : A} {_+_ _*_ : A → A → A} (S : Semiring Zero One _+_ _*_) where open Semiring S doubleIsAddTwo : (a : A) → (a + a) ≡ (One + One) * a doubleIsAddTwo a = transitivity (equalityCommutative (+WellDefined (productOneLeft a) (productOneLeft a))) (equalityCommutative (+DistributesOver*' One One a))
{ "alphanum_fraction": 0.6875, "avg_line_length": 38.6666666667, "ext": "agda", "hexsha": "8deefe45b11c6f9d853e30aaeb0363cbbc484672", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Semirings/Lemmas.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Semirings/Lemmas.agda", "max_line_length": 159, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Semirings/Lemmas.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 149, "size": 464 }
------------------------------------------------------------------------ -- The Agda standard library -- -- Integers ------------------------------------------------------------------------ module Data.Integer where open import Data.Nat as ℕ using (ℕ) renaming (_+_ to _ℕ+_; _*_ to _ℕ*_) import Data.Nat.Show as ℕ open import Data.Sign as Sign using (Sign) renaming (_*_ to _S*_) open import Data.Product as Prod open import Data.String using (String; _++_) open import Function open import Data.Sum as Sum open import Relation.Nullary import Relation.Nullary.Decidable as Dec open import Relation.Binary open import Relation.Binary.PropositionalEquality as PropEq using (_≡_; refl; sym; cong; cong₂) open PropEq.≡-Reasoning infix 8 +_ -_ infixl 7 _*_ _⊓_ infixl 6 _+_ _-_ _⊖_ _⊔_ infix 4 _≤_ _≤?_ ------------------------------------------------------------------------ -- The types -- Integers. data ℤ : Set where -[1+_] : (n : ℕ) → ℤ -- -[1+ n ] stands for - (1 + n). +_ : (n : ℕ) → ℤ -- + n stands for n. ------------------------------------------------------------------------ -- Conversions -- Absolute value. ∣_∣ : ℤ → ℕ ∣ + n ∣ = n ∣ -[1+ n ] ∣ = ℕ.suc n -- Gives the sign. For zero the sign is arbitrarily chosen to be +. sign : ℤ → Sign sign (+ _) = Sign.+ sign -[1+ _ ] = Sign.- -- Decimal string representation. show : ℤ → String show i = showSign (sign i) ++ ℕ.show ∣ i ∣ where showSign : Sign → String showSign Sign.- = "-" showSign Sign.+ = "" ------------------------------------------------------------------------ -- A view of integers as sign + absolute value infix 5 _◂_ _◃_ _◃_ : Sign → ℕ → ℤ _ ◃ ℕ.zero = + ℕ.zero Sign.+ ◃ n = + n Sign.- ◃ ℕ.suc n = -[1+ n ] ◃-left-inverse : ∀ i → sign i ◃ ∣ i ∣ ≡ i ◃-left-inverse -[1+ n ] = refl ◃-left-inverse (+ ℕ.zero) = refl ◃-left-inverse (+ ℕ.suc n) = refl ◃-cong : ∀ {i j} → sign i ≡ sign j → ∣ i ∣ ≡ ∣ j ∣ → i ≡ j ◃-cong {i} {j} sign-≡ abs-≡ = begin i ≡⟨ sym $ ◃-left-inverse i ⟩ sign i ◃ ∣ i ∣ ≡⟨ cong₂ _◃_ sign-≡ abs-≡ ⟩ sign j ◃ ∣ j ∣ ≡⟨ ◃-left-inverse j ⟩ j ∎ data SignAbs : ℤ → Set where _◂_ : (s : Sign) (n : ℕ) → SignAbs (s ◃ n) signAbs : ∀ i → SignAbs i signAbs i = PropEq.subst SignAbs (◃-left-inverse i) $ sign i ◂ ∣ i ∣ ------------------------------------------------------------------------ -- Equality is decidable infix 4 _≟_ _≟_ : Decidable {A = ℤ} _≡_ i ≟ j with Sign._≟_ (sign i) (sign j) | ℕ._≟_ ∣ i ∣ ∣ j ∣ i ≟ j | yes sign-≡ | yes abs-≡ = yes (◃-cong sign-≡ abs-≡) i ≟ j | no sign-≢ | _ = no (sign-≢ ∘ cong sign) i ≟ j | _ | no abs-≢ = no (abs-≢ ∘ cong ∣_∣) decSetoid : DecSetoid _ _ decSetoid = PropEq.decSetoid _≟_ ------------------------------------------------------------------------ -- Arithmetic -- Negation. -_ : ℤ → ℤ - (+ ℕ.suc n) = -[1+ n ] - (+ ℕ.zero) = + ℕ.zero - -[1+ n ] = + ℕ.suc n -- Subtraction of natural numbers. _⊖_ : ℕ → ℕ → ℤ m ⊖ ℕ.zero = + m ℕ.zero ⊖ ℕ.suc n = -[1+ n ] ℕ.suc m ⊖ ℕ.suc n = m ⊖ n -- Addition. _+_ : ℤ → ℤ → ℤ -[1+ m ] + -[1+ n ] = -[1+ ℕ.suc (m ℕ+ n) ] -[1+ m ] + + n = n ⊖ ℕ.suc m + m + -[1+ n ] = m ⊖ ℕ.suc n + m + + n = + (m ℕ+ n) -- Subtraction. _-_ : ℤ → ℤ → ℤ i - j = i + - j -- Successor. suc : ℤ → ℤ suc i = + 1 + i private suc-is-lazy⁺ : ∀ n → suc (+ n) ≡ + ℕ.suc n suc-is-lazy⁺ n = refl suc-is-lazy⁻ : ∀ n → suc -[1+ ℕ.suc n ] ≡ -[1+ n ] suc-is-lazy⁻ n = refl -- Predecessor. pred : ℤ → ℤ pred i = - + 1 + i private pred-is-lazy⁺ : ∀ n → pred (+ ℕ.suc n) ≡ + n pred-is-lazy⁺ n = refl pred-is-lazy⁻ : ∀ n → pred -[1+ n ] ≡ -[1+ ℕ.suc n ] pred-is-lazy⁻ n = refl -- Multiplication. _*_ : ℤ → ℤ → ℤ i * j = sign i S* sign j ◃ ∣ i ∣ ℕ* ∣ j ∣ -- Maximum. _⊔_ : ℤ → ℤ → ℤ -[1+ m ] ⊔ -[1+ n ] = -[1+ ℕ._⊓_ m n ] -[1+ m ] ⊔ + n = + n + m ⊔ -[1+ n ] = + m + m ⊔ + n = + (ℕ._⊔_ m n) -- Minimum. _⊓_ : ℤ → ℤ → ℤ -[1+ m ] ⊓ -[1+ n ] = -[1+ ℕ._⊔_ m n ] -[1+ m ] ⊓ + n = -[1+ m ] + m ⊓ -[1+ n ] = -[1+ n ] + m ⊓ + n = + (ℕ._⊓_ m n) ------------------------------------------------------------------------ -- Ordering data _≤_ : ℤ → ℤ → Set where -≤+ : ∀ {m n} → -[1+ m ] ≤ + n -≤- : ∀ {m n} → (n≤m : ℕ._≤_ n m) → -[1+ m ] ≤ -[1+ n ] +≤+ : ∀ {m n} → (m≤n : ℕ._≤_ m n) → + m ≤ + n drop‿+≤+ : ∀ {m n} → + m ≤ + n → ℕ._≤_ m n drop‿+≤+ (+≤+ m≤n) = m≤n drop‿-≤- : ∀ {m n} → -[1+ m ] ≤ -[1+ n ] → ℕ._≤_ n m drop‿-≤- (-≤- n≤m) = n≤m _≤?_ : Decidable _≤_ -[1+ m ] ≤? -[1+ n ] = Dec.map′ -≤- drop‿-≤- (ℕ._≤?_ n m) -[1+ m ] ≤? + n = yes -≤+ + m ≤? -[1+ n ] = no λ () + m ≤? + n = Dec.map′ +≤+ drop‿+≤+ (ℕ._≤?_ m n) decTotalOrder : DecTotalOrder _ _ _ decTotalOrder = record { Carrier = ℤ ; _≈_ = _≡_ ; _≤_ = _≤_ ; isDecTotalOrder = record { isTotalOrder = record { isPartialOrder = record { isPreorder = record { isEquivalence = PropEq.isEquivalence ; reflexive = refl′ ; trans = trans } ; antisym = antisym } ; total = total } ; _≟_ = _≟_ ; _≤?_ = _≤?_ } } where module ℕO = DecTotalOrder ℕ.decTotalOrder refl′ : _≡_ ⇒ _≤_ refl′ { -[1+ n ]} refl = -≤- ℕO.refl refl′ {+ n} refl = +≤+ ℕO.refl trans : Transitive _≤_ trans -≤+ (+≤+ n≤m) = -≤+ trans (-≤- n≤m) -≤+ = -≤+ trans (-≤- n≤m) (-≤- k≤n) = -≤- (ℕO.trans k≤n n≤m) trans (+≤+ m≤n) (+≤+ n≤k) = +≤+ (ℕO.trans m≤n n≤k) antisym : Antisymmetric _≡_ _≤_ antisym -≤+ () antisym (-≤- n≤m) (-≤- m≤n) = cong -[1+_] $ ℕO.antisym m≤n n≤m antisym (+≤+ m≤n) (+≤+ n≤m) = cong +_ $ ℕO.antisym m≤n n≤m total : Total _≤_ total (-[1+ m ]) (-[1+ n ]) = [ inj₂ ∘′ -≤- , inj₁ ∘′ -≤- ]′ $ ℕO.total m n total (-[1+ m ]) (+ n ) = inj₁ -≤+ total (+ m ) (-[1+ n ]) = inj₂ -≤+ total (+ m ) (+ n ) = [ inj₁ ∘′ +≤+ , inj₂ ∘′ +≤+ ]′ $ ℕO.total m n poset : Poset _ _ _ poset = DecTotalOrder.poset decTotalOrder import Relation.Binary.PartialOrderReasoning as POR module ≤-Reasoning = POR poset renaming (_≈⟨_⟩_ to _≡⟨_⟩_)
{ "alphanum_fraction": 0.4195292621, "avg_line_length": 24.8537549407, "ext": "agda", "hexsha": "f106a9f994bfe354725e712ffcc9f14f1ab72be2", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "qwe2/try-agda", "max_forks_repo_path": "agda-stdlib-0.9/src/Data/Integer.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "qwe2/try-agda", "max_issues_repo_path": "agda-stdlib-0.9/src/Data/Integer.agda", "max_line_length": 77, "max_stars_count": 1, "max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "qwe2/try-agda", "max_stars_repo_path": "agda-stdlib-0.9/src/Data/Integer.agda", "max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z", "max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z", "num_tokens": 2655, "size": 6288 }
{-# OPTIONS --without-K #-} {- Imports everything that is not imported by something else. This is not supposed to be used anywhere, this is just a simple way to do `make all' This file is intentionally named index.agda so that Agda will generate index.html. -} module index where import Base import Spaces.IntervalProps import Algebra.F2NotCommutative import Spaces.LoopSpaceCircle import Spaces.LoopSpaceDecidableWedgeCircles import Homotopy.PullbackIsPullback import Homotopy.PushoutIsPushout import Homotopy.Truncation import Sets.QuotientUP import Spaces.PikSn import Homotopy.VanKampen import Homotopy.Cover import Homotopy.Cover.ExamplePi1Circle
{ "alphanum_fraction": 0.8307926829, "avg_line_length": 24.2962962963, "ext": "agda", "hexsha": "1e22ec3ba13d9ab61128ef9704f6bf6e0171d5f3", "lang": "Agda", "max_forks_count": 50, "max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z", "max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nicolaikraus/HoTT-Agda", "max_forks_repo_path": "old/index.agda", "max_issues_count": 31, "max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633", "max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z", "max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nicolaikraus/HoTT-Agda", "max_issues_repo_path": "old/index.agda", "max_line_length": 70, "max_stars_count": 294, "max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "timjb/HoTT-Agda", "max_stars_repo_path": "old/index.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-20T13:54:45.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T16:23:23.000Z", "num_tokens": 170, "size": 656 }
data M : Set where m : (I : _) → (I → M) → M -- inferred -- m : (I : Set) → (I → M) → M
{ "alphanum_fraction": 0.3804347826, "avg_line_length": 13.1428571429, "ext": "agda", "hexsha": "f3a03e534cd95ece881f8267027d849c18d1b333", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "shlevy/agda", "max_forks_repo_path": "test/Fail/Issue4461.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Fail/Issue4461.agda", "max_line_length": 30, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Fail/Issue4461.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 43, "size": 92 }
{-# OPTIONS --cubical --no-import-sorts --guardedness --safe #-} module Cubical.Codata.M.AsLimit.itree where open import Cubical.Data.Unit open import Cubical.Data.Prod open import Cubical.Data.Nat as ℕ using (ℕ ; suc ; _+_ ) open import Cubical.Data.Sum open import Cubical.Data.Empty open import Cubical.Data.Bool open import Cubical.Foundations.Function open import Cubical.Foundations.Prelude open import Cubical.Codata.M.AsLimit.Container open import Cubical.Codata.M.AsLimit.M open import Cubical.Codata.M.AsLimit.Coalg -- Delay monad defined as an M-type delay-S : (R : Type₀) -> Container ℓ-zero delay-S R = (Unit ⊎ R) , λ { (inr _) -> ⊥ ; (inl tt) -> Unit } delay : (R : Type₀) -> Type₀ delay R = M (delay-S R) delay-ret : {R : Type₀} -> R -> delay R delay-ret r = in-fun (inr r , λ ()) delay-tau : {R : Type₀} -> delay R -> delay R delay-tau S = in-fun (inl tt , λ x → S) -- Bottom element raised data ⊥₁ : Type₁ where -- TREES tree-S : (E : Type₀ -> Type₁) (R : Type₀) -> Container (ℓ-suc ℓ-zero) tree-S E R = (R ⊎ (Σ[ A ∈ Type₀ ] (E A))) , (λ { (inl _) -> ⊥₁ ; (inr (A , e)) -> Lift A } ) tree : (E : Type₀ -> Type₁) (R : Type₀) -> Type₁ tree E R = M (tree-S E R) tree-ret : ∀ {E} {R} -> R -> tree E R tree-ret {E} {R} r = in-fun (inl r , λ ()) tree-vis : ∀ {E} {R} -> ∀ {A} -> E A -> (A -> tree E R) -> tree E R tree-vis {A = A} e k = in-fun (inr (A , e) , λ { (lift x) -> k x } ) -- ITrees (and buildup examples) -- https://arxiv.org/pdf/1906.00046.pdf -- Interaction Trees: Representing Recursive and Impure Programs in Coq -- Li-yao Xia, Yannick Zakowski, Paul He, Chung-Kil Hur, Gregory Malecha, Benjamin C. Pierce, Steve Zdancewic itree-S : ∀ (E : Type₀ -> Type₁) (R : Type₀) -> Container (ℓ-suc ℓ-zero) itree-S E R = ((Unit ⊎ R) ⊎ (Σ[ A ∈ Type₀ ] (E A))) , (λ { (inl (inl _)) -> Lift Unit ; (inl (inr _)) -> ⊥₁ ; (inr (A , e)) -> Lift A } ) itree : ∀ (E : Type₀ -> Type₁) (R : Type₀) -> Type₁ itree E R = M (itree-S E R) ret' : ∀ {E} {R} -> R -> P₀ (itree-S E R) (itree E R) ret' {E} {R} r = inl (inr r) , λ () tau' : {E : Type₀ -> Type₁} -> {R : Type₀} -> itree E R -> P₀ (itree-S E R) (itree E R) tau' t = inl (inl tt) , λ x → t vis' : ∀ {E} {R} -> ∀ {A : Type₀} -> E A -> (A -> itree E R) -> P₀ (itree-S E R) (itree E R) vis' {A = A} e k = inr (A , e) , λ { (lift x) -> k x } ret : ∀ {E} {R} -> R -> itree E R ret = in-fun ∘ ret' tau : {E : Type₀ -> Type₁} -> {R : Type₀} -> itree E R -> itree E R tau = in-fun ∘ tau' vis : ∀ {E} {R} -> ∀ {A : Type₀} -> E A -> (A -> itree E R) -> itree E R vis {A = A} e = in-fun ∘ (vis' {A = A} e)
{ "alphanum_fraction": 0.5654024768, "avg_line_length": 34, "ext": "agda", "hexsha": "ad5894d5b424a0146ec9fff97e221f96125c9e72", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Codata/M/AsLimit/itree.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Codata/M/AsLimit/itree.agda", "max_line_length": 137, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Codata/M/AsLimit/itree.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1023, "size": 2584 }
-- Andreas, 2017-01-12 data D {A : Set} : A → Set where c : (a : A) → D {!!} -- fill with a d : (a : A) → {!!} -- fill with D a
{ "alphanum_fraction": 0.437037037, "avg_line_length": 22.5, "ext": "agda", "hexsha": "006235b6025ce91e7905ec5cea67e955e0ef0fe1", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/interaction/InductiveFamilyNoTarget.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/interaction/InductiveFamilyNoTarget.agda", "max_line_length": 38, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/interaction/InductiveFamilyNoTarget.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 60, "size": 135 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Finite.Fin.Instance.Triangle where open import Data.Nat using (ℕ) open import Data.Fin open import Data.Fin.Patterns open import Relation.Binary.PropositionalEquality as ≡ open import Categories.Category.Finite.Fin open import Categories.Category private variable a b c d : Fin 3 -- the diagram is the following: -- -- 0 -- | \ -- | \ -- | \ -- | \ -- v v -- 1 ---> 2 -- -- all morphisms are 0 (because there is at most one morphism between each pair of objects). TriangleShape : FinCatShape TriangleShape = record { size = 3 ; ∣_⇒_∣ = morph ; hasShape = record { id = id ; _∘_ = _∘_ ; assoc = assoc ; identityˡ = identityˡ ; identityʳ = identityʳ } } where morph : Fin 3 → Fin 3 → ℕ morph 0F 0F = 1 morph 0F 1F = 1 morph 0F 2F = 1 morph 1F 1F = 1 morph 1F 2F = 1 morph 2F 2F = 1 morph _ _ = 0 id : Fin (morph a a) id {0F} = 0F id {1F} = 0F id {2F} = 0F _∘_ : ∀ {a b c} → Fin (morph b c) → Fin (morph a b) → Fin (morph a c) _∘_ {0F} {0F} {0F} 0F 0F = 0F _∘_ {0F} {0F} {1F} 0F 0F = 0F _∘_ {0F} {0F} {2F} 0F 0F = 0F _∘_ {0F} {1F} {1F} 0F 0F = 0F _∘_ {0F} {1F} {2F} 0F 0F = 0F _∘_ {0F} {2F} {2F} 0F 0F = 0F _∘_ {1F} {1F} {1F} 0F 0F = 0F _∘_ {1F} {1F} {2F} 0F 0F = 0F _∘_ {1F} {2F} {2F} 0F 0F = 0F _∘_ {2F} {2F} {2F} 0F 0F = 0F assoc : ∀ {f : Fin (morph a b)} {g : Fin (morph b c)} {h : Fin (morph c d)} → ((h ∘ g) ∘ f) ≡ (h ∘ (g ∘ f)) assoc {0F} {0F} {0F} {0F} {0F} {0F} {0F} = refl assoc {0F} {0F} {0F} {1F} {0F} {0F} {0F} = refl assoc {0F} {0F} {0F} {2F} {0F} {0F} {0F} = refl assoc {0F} {0F} {1F} {1F} {0F} {0F} {0F} = refl assoc {0F} {0F} {1F} {2F} {0F} {0F} {0F} = refl assoc {0F} {0F} {2F} {2F} {0F} {0F} {0F} = refl assoc {0F} {1F} {1F} {1F} {0F} {0F} {0F} = refl assoc {0F} {1F} {1F} {2F} {0F} {0F} {0F} = refl assoc {0F} {1F} {2F} {2F} {0F} {0F} {0F} = refl assoc {0F} {2F} {2F} {2F} {0F} {0F} {0F} = refl assoc {1F} {1F} {1F} {1F} {0F} {0F} {0F} = refl assoc {1F} {1F} {1F} {2F} {0F} {0F} {0F} = refl assoc {1F} {1F} {2F} {2F} {0F} {0F} {0F} = refl assoc {1F} {2F} {2F} {2F} {0F} {0F} {0F} = refl assoc {2F} {2F} {2F} {2F} {0F} {0F} {0F} = refl identityˡ : ∀ {f : Fin (morph a b)} → (id ∘ f) ≡ f identityˡ {0F} {0F} {0F} = refl identityˡ {0F} {1F} {0F} = refl identityˡ {0F} {2F} {0F} = refl identityˡ {1F} {1F} {0F} = refl identityˡ {1F} {2F} {0F} = refl identityˡ {2F} {2F} {0F} = refl identityʳ : ∀ {f : Fin (morph a b)} → (f ∘ id) ≡ f identityʳ {0F} {0F} {0F} = refl identityʳ {0F} {1F} {0F} = refl identityʳ {0F} {2F} {0F} = refl identityʳ {1F} {1F} {0F} = refl identityʳ {1F} {2F} {0F} = refl identityʳ {2F} {2F} {0F} = refl Triangle : Category _ _ _ Triangle = FinCategory TriangleShape module Triangle = Category Triangle
{ "alphanum_fraction": 0.475069681, "avg_line_length": 31.0480769231, "ext": "agda", "hexsha": "ce15528945b86749baa56f081e8a2ba91cf96a4d", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "MirceaS/agda-categories", "max_forks_repo_path": "src/Categories/Category/Finite/Fin/Instance/Triangle.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "MirceaS/agda-categories", "max_issues_repo_path": "src/Categories/Category/Finite/Fin/Instance/Triangle.agda", "max_line_length": 93, "max_stars_count": null, "max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "MirceaS/agda-categories", "max_stars_repo_path": "src/Categories/Category/Finite/Fin/Instance/Triangle.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1547, "size": 3229 }
module Nats.Multiply.Assoc where open import Nats open import Equality open import Function open import Nats.Multiply.Comm open import Nats.Multiply.Distrib ------------------------------------------------------------------------ -- internal stuffs private a*1+b=a+a*b : ∀ a b → a * suc b ≡ a + a * b a*1+b=a+a*b a b rewrite nat-multiply-comm a $ suc b | nat-multiply-comm a b = refl a*/b*c/=/a*b/*c : ∀ a b c → a * b * c ≡ a * (b * c) a*/b*c/=/a*b/*c zero b c = refl a*/b*c/=/a*b/*c (suc a) b c rewrite a*/b*c/=/a*b/*c a b c | nat-multiply-comm a b | sym $ nat-multiply-distrib b (b * a) c | sym $ a*/b*c/=/a*b/*c a b c | nat-multiply-comm a b = refl ------------------------------------------------------------------------ -- public aliases nat-multiply-assoc : ∀ a b c → a * b * c ≡ a * (b * c) nat-multiply-assoc = a*/b*c/=/a*b/*c
{ "alphanum_fraction": 0.447761194, "avg_line_length": 26.0555555556, "ext": "agda", "hexsha": "b216a5018178a83af0170b8d04bcd59e381159c9", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "ice1k/Theorems", "max_forks_repo_path": "src/Nats/Multiply/Assoc.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "ice1k/Theorems", "max_issues_repo_path": "src/Nats/Multiply/Assoc.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "ice1k/Theorems", "max_stars_repo_path": "src/Nats/Multiply/Assoc.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z", "num_tokens": 298, "size": 938 }
open import Reflection hiding (return; _>>=_) open import Data.List renaming (_++_ to _++l_) open import Data.Vec as V using (Vec; updateAt) open import Data.Unit open import Data.Nat as N open import Data.Nat.Properties open import Data.Fin using (Fin; #_; suc; zero) open import Data.Maybe hiding (_>>=_; map) open import Function open import Data.Bool open import Data.Product hiding (map) open import Data.String renaming (_++_ to _++s_; concat to sconc; length to slen) open import Data.Char renaming (_≈?_ to _c≈?_) open import Relation.Binary.PropositionalEquality hiding ([_]) open import Relation.Nullary open import Relation.Nullary.Decidable hiding (map) open import Data.Nat.Show renaming (show to showNat) open import Level renaming (zero to lzero; suc to lsuc) open import Category.Monad using (RawMonad) open RawMonad {{...}} public instance monadMB : ∀ {f} → RawMonad {f} Maybe monadMB = record { return = just ; _>>=_ = Data.Maybe._>>=_ } monadTC : ∀ {f} → RawMonad {f} TC monadTC = record { return = Reflection.return ; _>>=_ = Reflection._>>=_ } data Err {a} (A : Set a) : Set a where error : String → Err A ok : A → Err A instance monadErr : ∀ {f} → RawMonad {f} Err monadErr = record { return = ok ; _>>=_ = λ { (error s) f → error s ; (ok a) f → f a } } record RawMonoid {a}(A : Set a) : Set a where field _++_ : A → A → A ε : A ++/_ : List A → A ++/ [] = ε ++/ (x ∷ a) = x ++ ++/ a infixr 5 _++_ open RawMonoid {{...}} public instance monoidLst : ∀ {a}{A : Set a} → RawMonoid (List A) monoidLst {A = A} = record { _++_ = _++l_; ε = [] } monoidStr : RawMonoid String monoidStr = record { _++_ = _++s_; ε = "" } monoidErrStr : RawMonoid (Err String) monoidErrStr = record { _++_ = λ where (error s) _ → error s _ (error s) → error s (ok s₁) (ok s₂) → ok (s₁ ++ s₂) ; ε = ok "" } monoidErrLst : ∀{a}{A : Set a} → RawMonoid (Err $ List A) monoidErrLst = record { _++_ = λ where (error s) _ → error s _ (error s) → error s (ok s₁) (ok s₂) → ok (s₁ ++ s₂) ; ε = ok [] } defToTerm : Name → Definition → List (Arg Term) → Term defToTerm _ (function cs) as = pat-lam cs as defToTerm _ (constructor′ d) as = con d as defToTerm _ _ _ = unknown derefImmediate : Term → TC Term derefImmediate (def f args) = getDefinition f >>= λ f' → return (defToTerm f f' args) derefImmediate x = return x derefT : Term → TC Term derefT (def f args) = getType f derefT (con f args) = getType f derefT x = return x defName : Term → Maybe Name defName (def f args) = just f defName _ = nothing Ctx = List $ Arg Type pi-to-ctx : Term → Ctx -- we have a Ctx for the entire function, now we want to build -- a context for the given variables in the clause. To do so -- we merge function's ctx with patterns of the given clause -- and we grab the types that correspond to the variables within -- the patterns. --pats-ctx : Ctx → (List $ Arg Pattern) → TC $ Maybe Ctx macro reflect : Term → Term → TC ⊤ reflect f a = (derefImmediate f) >>= quoteTC >>= unify a reflect-ty : Name → Type → TC ⊤ reflect-ty f a = getType f >>= quoteTC >>= normalise >>= unify a rtest : Term → Term → TC ⊤ rtest f a = do t ← derefT f v ← derefImmediate f --v ← pat-lam-no--rm v (pi-to-ctx t) --q ← quoteTC v q ← quoteTC (pi-to-ctx t) unify a q rmkstring : Term → Term → TC ⊤ rmkstring f a = unify (lit (string "Test")) a infert : Type → Term → TC ⊤ infert t a = inferType t >>= quoteTC >>= unify a -- FIXME we probably want to error out on these two functions. pi-to-ctx (Π[ s ∶ a ] x) = (a ∷ pi-to-ctx x) pi-to-ctx _ = [] Prog = Err $ List String infixl 5 _#p_ _#p_ = _++_ okl : String → Prog okl s = ok ([ s ]) -- reduce a list of Progs with a delimiter _/#p_ : List Prog → (delim : String) → Prog [] /#p d = ok [] (x ∷ []) /#p d = x (x ∷ xs@(_ ∷ _)) /#p d = x #p okl d #p xs /#p d -- Normalise the name of functions that we obtain from showName, -- i.e. remove dots, replace weird symbols by ascii. nnorm : String → Prog nnorm s = okl $ replace '.' '_' $ replace '-' '_' $ s where repchar : (t f x : Char) → Char repchar f t x with x c≈? f ... | yes _ = t ... | no _ = x replace : (from to : Char) → String → String replace f t s = fromList $ map (repchar f t) $ toList s data NumClauses : Set where Many One : NumClauses record State : Set where constructor st field --arg-ctx : Ctx --ret-typ : String var-names : List String retvar : String cls : NumClauses open State --compile-clause : Clause → State → Prog -- Pack the information about new variables generated -- by patterns in the clause, assignments to these, -- and the list of conditions. E.g. -- foo : List ℕ → ℕ -- foo (x ∷ xs) 2 = ... -- -- Assume that we named top-level arguments [a, b] -- Then, new variables for this clause are going to be -- [x, xs] -- Assignments are: -- [x = hd a, xs = tl a] -- Conditions are: -- [is-cons a, b = 2] record ClCond : Set where constructor clcond field vars : List String assigns : List String conds : List String data MbClCond : Set where ok : ClCond → MbClCond error : String → MbClCond _#c_ : MbClCond → MbClCond → MbClCond error s #c _ = error s _ #c error s = error s ok (clcond a b c) #c ok (clcond a' b' c') = ok (clcond (a ++ a') (b ++ b') (c ++ c')) {-# TERMINATING #-} clause-ctx-vars : (pats : List $ Arg Pattern) → (vars : List String) → (counter : ℕ) → MbClCond showLitProg : Literal → Prog comp-term : Term → (varctx : List String) → Prog sjoin : List String → String → String sjoin [] delim = "" sjoin (x ∷ []) delim = x sjoin (x ∷ xs@(_ ∷ _)) delim = x ++s delim ++s sjoin xs delim join' : List String → (delim : String) → (empty : String) → String join' [] _ e = e join' x@(_ ∷ _) d _ = sjoin x d compile-cls : List Clause → State → Prog compile-cls [] s = error "comile-cls: expected at least one clause" compile-cls (clause ps t ∷ []) s with clause-ctx-vars ps (var-names s) 0 ... | error msg = error msg ... | ok (clcond vars assgns conds) = let as = sconc (map (_++s "\n") assgns) rv = retvar s ++s " = " in okl (as ++s rv) #p comp-term t vars #p okl ";" compile-cls (absurd-clause ps ∷ []) s with clause-ctx-vars ps (var-names s) 0 ... | error msg = error msg ... | ok (clcond vars assgns conds) = okl "unreachable ();" compile-cls (clause ps t ∷ xs@(_ ∷ _)) s with clause-ctx-vars ps (var-names s) 0 ... | error msg = error msg ... | ok (clcond vars assgns conds) = let cs = join' conds " && " "true" as = sconc (map (_++s "\n") assgns) rv = retvar s ++s " = " in okl ("if (" ++s cs ++s ") {" ++s as ++s rv) #p comp-term t vars #p okl "; }" #p okl "else {" #p compile-cls xs s #p okl "}" compile-cls (absurd-clause ps ∷ xs@(_ ∷ _)) s with clause-ctx-vars ps (var-names s) 0 ... | error msg = error msg ... | ok (clcond vars assgns conds) = let -- XXX it would be weird if conds were empty... catch it? cs = join' conds " && " "true" in okl ("if (" ++s cs ++s ") { unreachable (); } else {" ) #p compile-cls xs s #p okl "}" clause-ctx-vars (arg i (con c ps) ∷ l) (v ∷ vars) vcnt with showName c ... | "Agda.Builtin.List.List.[]" = ok (clcond [] [] [ "emptyvec_p (" ++s v ++s ")" ]) #c clause-ctx-vars l vars vcnt ... | "Agda.Builtin.List.List._∷_" = ok (clcond [] [] [ "nonemptyvec_p (" ++s v ++s ")" ]) #c clause-ctx-vars (ps ++ l) (("hd (" ++s v ++s ")") ∷ ("tl (" ++s v ++s ")") ∷ vars) vcnt ... | "Agda.Builtin.Bool.Bool.true" = ok (clcond [] [] [ v {- == true -} ]) #c clause-ctx-vars l vars vcnt ... | "Agda.Builtin.Bool.Bool.false" = ok (clcond [] [] [ "! " ++s v ]) #c clause-ctx-vars l vars vcnt ... | "Agda.Builtin.Nat.Nat.suc" = ok (clcond [] [] [ v ++s " > 0" ]) #c clause-ctx-vars (ps ++ l) ((v ++s " - 1") ∷ vars) vcnt ... | "Agda.Builtin.Nat.Nat.zero" = ok (clcond [] [] [ v ++s " == 0" ]) #c clause-ctx-vars l vars vcnt ... | "Data.Fin.Base.Fin.zero" = ok (clcond [] [] [ v ++s " == 0" ]) -- XXX can also add v < u #c clause-ctx-vars l vars vcnt ... | "Data.Fin.Base.Fin.suc" = ok (clcond [] [] [ v ++s " > 0" ]) -- XXX can also add v < u #c clause-ctx-vars l vars vcnt ... | "Data.Vec.Base.Vec.[]" = ok (clcond [] [] [ "emptyvec_p (" ++s v ++s ")" ]) #c clause-ctx-vars l vars vcnt ... | "Data.Vec.Base.Vec._∷_" = ok (clcond [] [] [ "nonemptyvec_p (" ++s v ++s ")" ]) #c clause-ctx-vars (ps ++ l) (("len (" ++s v ++s ") - 1") ∷ ("hd (" ++s v ++s ")") ∷ ("tl (" ++s v ++s ")") ∷ vars) vcnt -- Well, let's see how far we can go with this hack ... | "Array.Base.Ar.imap" = --... | "test-extract.Ar'.imap" = ok (clcond [ "IMAP_" ++s v ] [ "\n#define IMAP_" ++s v ++s "(__x) " ++s v ++s "[__x]\n" ] [ "true" ]) #c clause-ctx-vars l vars vcnt ... | x = error ("clause-ctx-vars: don't know what to do with `" ++s x ++s "` constructor in patterns") clause-ctx-vars (arg i dot ∷ l) (v ∷ vars) vcnt = -- Dot patterns are skipped. clause-ctx-vars l vars vcnt clause-ctx-vars (arg (arg-info visible r) (var s) ∷ l) (v ∷ vars) vcnt = -- If we have "_" as a variable, we need to insert it -- into the list, but we don't generate an assignment for it. let asgn = case s ≈? "_" of λ where -- XXX hopefully this is fine, otherwise -- we can do the same thing as for hidden -- vars. (yes p) → [] (no ¬p) → [ s ++s " = " ++s v ++s ";" ] in ok (clcond [ s ] asgn []) #c clause-ctx-vars l vars vcnt clause-ctx-vars (arg (arg-info hidden r) (var s) ∷ l) (v ∷ vars) vcnt = -- Hidden variables are simply added to the context -- as regular variables let s , vcnt = case s ≈? "_" of λ where (yes p) → s ++ "_" ++ showNat vcnt , 1 + vcnt (no ¬p) → s , vcnt in ok (clcond [ s ] [ s ++ " = " ++ v ++ ";" ] []) #c clause-ctx-vars l vars vcnt clause-ctx-vars (arg (arg-info instance′ r) (var s) ∷ l) (v ∷ vars) vcnt = error "FIXME handle instance variables" clause-ctx-vars (arg i (lit x) ∷ l) (v ∷ vars) vcnt = case showLitProg x of λ where (error s) → error s (ok s) → ok (clcond [] [] [ v ++s " == " ++s (sconc s) ]) #c clause-ctx-vars l vars vcnt clause-ctx-vars (arg i (proj f) ∷ l) (v ∷ vars) vcnt = error "FIXME proj pattern" clause-ctx-vars (arg i absurd ∷ l) (v ∷ vars) vcnt = -- I assume that absurd can only appear in the -- absurd clause, therefore, we don't need a condition -- for this pattern, so we just skip it. clause-ctx-vars l vars vcnt clause-ctx-vars [] [] _ = ok (clcond [] [] []) clause-ctx-vars _ _ _ = error "mismatching number of patterns and types" showLitProg (name x) = error ("Found name `" ++s (showName x) ++s "` as literal") showLitProg (meta x) = error ("Found meta `" ++s (showMeta x) ++s "` as literal") showLitProg x = okl (showLiteral x) var-lkup : List String → ℕ → Prog var-lkup [] n = error ("Variable not found") var-lkup (x ∷ l) zero = okl x var-lkup (x ∷ l) (suc n) = var-lkup l n -- Compile each arg and join them with ", " comp-arglist : List $ Arg Term → (varctx : List String) → Prog comp-arglist args varctx = map (λ {(arg i x) → comp-term x varctx}) args /#p ", " -- Helper for comp-arglist-mask mk-mask : (n : ℕ) → List (Fin n) → List Bool mk-mask n xs = V.toList $ go (V.replicate {n = n} false) xs where go : _ → _ → _ go e [] = e go e (x ∷ xs) = go (updateAt x (λ _ → true) e) xs comp-arglist-mask : List $ Arg Term → (mask : List Bool) → (varctx : List String) → Prog comp-arglist-mask args mask varctx = go args mask varctx /#p ", " where go : List $ Arg Term → (mask : List Bool) → (varctx : List String) → List Prog go [] [] _ = [] go [] (x ∷ mask) _ = [ error "Incorrect argument mask" ] go (x ∷ args) [] _ = [ error "Incorrect argument mask" ] go (x ∷ args) (false ∷ mask) vars = go args mask vars go (arg i x ∷ args) (true ∷ mask) vars = comp-term x vars ∷ go args mask vars comp-term (var x []) vars = var-lkup (reverse vars) x comp-term (var x args@(_ ∷ _)) vars = var-lkup (reverse vars) x #p okl "(" #p comp-arglist args vars #p okl ")" --comp-term (var x (x₁ ∷ args)) vars with var-lkup (reverse vars) x --comp-term (var x (x₁ ∷ args)) vars | ok l = error ("Variable " ++s (sconc l) ++s " used as a function call") --comp-term (var x (x₁ ∷ args)) vars | error s = error s comp-term (lit l) vars = showLitProg l comp-term exp@(con c args) vars with showName c ... | "Data.Vec.Base.Vec.[]" = okl "[]" ... | "Data.Vec.Base.Vec._∷_" = okl "cons (" #p comp-arglist-mask args (mk-mask 5 $ # 3 ∷ # 4 ∷ []) vars #p okl ")" ... | "Agda.Builtin.Nat.Nat.suc" = okl "(1 + " #p comp-arglist-mask args (mk-mask 1 $ # 0 ∷ []) vars #p okl ")" ... | "Data.Fin.Base.Fin.zero" = okl "0" ... | "Data.Fin.Base.Fin.suc" = okl "(1 + " #p comp-arglist-mask args (mk-mask 2 $ # 1 ∷ []) vars #p okl ")" ... | "Array.Base.Ar.imap" = --... | "test-extract.Ar'.imap" = case args of λ where (_ ∷ _ ∷ _ ∷ arg _ s ∷ arg _ (vLam x e) ∷ []) → let p = comp-term e (vars ++ [ x ]) sh = comp-term s vars --infert exp in okl ("with { (. <= " ++s x ++s " <= .): ") #p p #p okl "; }: genarray (" #p sh #p okl ")" _ → error "comp-term: don't recognize arguments to imap" ... | "Array.Base.Ix.[]" = okl "[]" ... | "Array.Base.Ix._∷_" = okl "cons (" #p comp-arglist-mask args (mk-mask 5 $ # 3 ∷ # 4 ∷ []) vars #p okl ")" ... | n = error ("comp-term: don't know constructor `" ++s n ++s "`") comp-term (def f args) vars with showName f ... | "Agda.Builtin.Nat._+_" = okl "_add_SxS_ (" #p comp-arglist args vars #p okl ")" ... | "Agda.Builtin.Nat._*_" = okl "_mul_SxS_ (" #p comp-arglist args vars #p okl ")" ... | "Data.Nat.DivMod._/_" = okl "_div_SxS_ (" #p comp-arglist-mask args (mk-mask 3 $ # 0 ∷ # 1 ∷ []) vars #p okl ")" ... | "Data.Fin.#_" = comp-arglist-mask args (mk-mask 3 $ # 0 ∷ []) vars ... | "Array.Base.ix-lookup" = case args of λ where (_ ∷ _ ∷ arg _ iv ∷ arg _ el ∷ []) → let iv′ = comp-term iv vars el′ = comp-term el vars in iv′ #p okl "[" #p el′ #p okl "]" _ → error "comp-term: don't recognize arguments to ix-lookup" ... | "Data.Vec.Base.[_]" = case args of λ where (_ ∷ _ ∷ arg _ x ∷ []) → okl "[" #p comp-term x vars #p okl "]" _ → error "comp-term: don't recognize arguments to Vec.[_]" ... | "Data.Fin.Base.raise" = -- Note that "raise" is a total junk, as it only makes sure that the -- Fin value is valid in some context; all we are interested in is the -- value of that Fin. case args of λ where (_ ∷ _ ∷ arg _ x ∷ []) → comp-term x vars _ → error "comp-term: don't recognize arguments to Data.Fin.raise" -- XXX we need to figure out what are we going to do with recursive functions, -- as clearly its name can't be known in advance. Probably add it to the -- state? Or maintain a list of functions? ... | n = nnorm n #p okl " (" #p comp-arglist args vars #p okl ")" --... | n = error ("comp-term: don't know definition `" ++s n ++s "`") comp-term (lam v t) vars = error "comp-term: lambdas are not supported" comp-term (pat-lam cs args) vars = error "comp-term: pattern-matching lambdas are not supported" comp-term (pi a b) vars = error "comp-term: pi types are not supported" comp-term (sort s) vars = error "comp-term: sorts are not supported" comp-term (meta x x₁) vars = error "comp-term: metas are not supported" comp-term unknown vars = error "comp-term: unknowns are not supported" record Pistate : Set where constructor pist-vc=_cv=_vctx=_tctx=_rv=_ret=_cons=_ field var-counter : ℕ cur-var : String var-ctx : List String type-ctx : List String ret-var : String ret : Prog -- XXX come up with a better type for -- constraints on variables. cons : List (String × Prog) open Pistate trav-pi : Type → Pistate → Pistate trav-pi (Π[ s ∶ arg i x ] y) pst = let varname = case s of λ where "_" → "x_" ++s (showNat $ var-counter pst) n → n tp = trav-pi x (record pst {cur-var = varname}) -- ; cons = []}) in case ret tp of λ where (error s) → tp (ok l) → trav-pi y (record pst {var-counter = 1 + var-counter pst ; cur-var = ret-var pst ; var-ctx = var-ctx pst ++ [ varname ] ; type-ctx = type-ctx pst ++ [ (sjoin l "") ] ; cons = cons tp}) --cons pst ++ cons tp }) trav-pi (con c args) pst with showName c ... | x = record pst {ret = error ("trav-pi: don't know how to handle `" ++s x ++s "` constructor")} trav-pi (def f args) pst with showName f ... | "Agda.Builtin.Nat.ℕ" = record pst {ret = okl "int"} ... | "Agda.Builtin.Nat.Nat" = record pst {ret = okl "int"} ... | "Agda.Builtin.Bool.Bool" = record pst {ret = okl "bool"} ... | "Agda.Builtin.List.List" = -- We encode lists as 1-d arrays of their argument type. case args of λ where (_ ∷ arg i x ∷ _) → let tp = trav-pi x (record pst {cons = []}) in case ret tp of λ where (error s) → tp (ok l) → record tp {ret = okl $ (sjoin l "") ++s "[.]"} _ → record pst {ret = error "trav-pi: incorrect arguments to List"} ... | "Data.Vec.Base.Vec" = -- Vectors are also 1-d arrays (such as lists) but we extract -- a bit of extra infromation from these. case args of λ where (_ ∷ arg _ t ∷ arg _ x ∷ []) → let tp = trav-pi t (record pst {cur-var = "" {- XXX well, typeof (cur-var pst) is the thing -} }) --cons = []}) p = comp-term x (var-ctx pst) in record tp {ret = ret tp #p okl "[.]" ; cons = (cons tp) ++ [ cur-var pst , okl ("/* assert (shape (" ++s (cur-var pst) ++s ")[[0]] == ") #p p #p okl ") */" ] } _ → record pst {ret = error "trav-pi: incorrect arguments to Vec"} ... | "Data.Fin.Base.Fin" = case args of λ where (arg _ x ∷ []) → let p = comp-term x (var-ctx pst) in record pst { ret = okl "int"; cons = (cons pst) ++ [ cur-var pst , okl ("/* assert (" ++s (cur-var pst) ++s " < ") #p p #p okl ") */"] } _ → record pst {ret = error "trav-pi: incorrect arguments to Fin"} ... | "Array.Base.Ar" = --... | "test-extract.Ar'" = case args of λ where (_ ∷ arg _ ty ∷ arg _ dim ∷ arg _ sh ∷ []) → let ty′ = trav-pi ty pst dim′ = comp-term dim (var-ctx pst) sh′ = comp-term sh (var-ctx pst) in record ty′ { ret = ret ty′ #p okl "[*]" ; cons = cons ty′ ++ [ cur-var pst , okl ("/* assert (dim (" ++s (cur-var pst) ++s ") == ") #p dim′ #p okl " )*/" ] ++ [ cur-var pst , okl ("/* assert (shape (" ++s (cur-var pst) ++s ") == ") #p sh′ #p okl " )*/" ] } _ → record pst {ret = error "trav-pi: incorrect arguments to Ar"} ... | x = record pst {ret = error ("trav-pi: don't know the `" ++s x ++s "` type")} trav-pi _ pst = record pst {ret = error "trav-pi ERRR"} find : List String → String → Bool find [] x = false find (y ∷ l) x with x ≈? y ... | yes _ = true ... | no _ = find l x collect-var-cons : List (String × Prog) → (accum : List String) → List (String × Prog) collect-var-cons [] acc = [] collect-var-cons ((x , v) ∷ l) acc with find acc x ... | true = collect-var-cons l acc ... | false = (x , v #p collect l x) ∷ collect-var-cons l (x ∷ acc) where collect : _ → _ → _ collect [] x = ok [] collect ((y , v) ∷ l) x with y ≈? x ... | yes _ = v #p collect l x ... | no _ = collect l x -- Get the value bound to the given variable or return (ok []) lkup-var-cons : List (String × Prog) → String → Prog lkup-var-cons [] s = ok [] lkup-var-cons ((x , v) ∷ xs) s with x ≈? s ... | yes _ = v ... | no _ = lkup-var-cons xs s fltr : List (String × Prog) → (var : String) → List (String × Prog) fltr [] x = [] fltr ((y , v) ∷ l) x with x ≈? y ... | yes _ = fltr l x ... | no _ = (y , v) ∷ fltr l x mkfun : Name → _ → Pistate → NumClauses → Prog mkfun n cls ps nc = let rv = (ret-var ps) cs = collect-var-cons (cons ps) [] arg-cons = map proj₂ $ fltr cs rv ret-cons = lkup-var-cons cs rv in (okl $ "// Function " ++s (showName n) ++s "\n") #p ret ps #p okl "\n" #p (nnorm $ showName n ++s "(") #p tvl (var-ctx ps) (type-ctx ps) #p okl ") {\n" --#p (cons ps) /#p "\n" #p arg-cons /#p "\n" #p ret ps #p okl (" " ++s rv ++s ";\n") #p compile-cls cls (st (var-ctx ps) rv nc) #p ret-cons #p okl ("return " ++s rv ++s ";\n}\n\n") where tvl : List String → List String → Prog tvl [] [] = ok [] tvl [] (t ∷ typs) = error "more types than variables" tvl (x ∷ vars) [] = error "more variables than types" tvl (x ∷ []) (t ∷ []) = okl (t ++s " " ++s x) tvl (x ∷ []) (_ ∷ _ ∷ _) = error "more types than variables" tvl (_ ∷ _ ∷ _) (_ ∷ []) = error "more variables than types" tvl (x ∷ xs@(_ ∷ _)) (t ∷ ts@(_ ∷ _)) = okl (t ++s " " ++s x ++s ", ") #p tvl xs ts compile' : (lam : Term) → (sig : Type) → (name : Maybe Name) → TC Prog compile' (pat-lam cs args) t nm with nm compile' (pat-lam cs args) t nm | nothing = return $ error "compile' got invalid function name" compile' (pat-lam [] args) t nm | just x = return $ error "compile' got zero clauses in the lambda term" compile' (pat-lam cs@(_ ∷ []) args) t nm | just x = -- XXX currently the name `__ret` is hardcoded. let ps = trav-pi t (pist-vc= 1 cv= "" vctx= [] tctx= [] rv= "__ret" ret= error "" cons= []) in return (mkfun x cs ps One) compile' (pat-lam cs@(_ ∷ _ ∷ _) args) t nm | just x = -- XXX currently the name `__ret` is hardcoded. let ps = trav-pi t (pist-vc= 1 cv= "" vctx= [] tctx= [] rv= "__ret" ret= error "" cons= []) in return (mkfun x cs ps Many) compile' x _ _ = return (error "compile' expected pattern-matching lambda") macro compile : Term → Term → TC ⊤ compile f a = do t ← derefT f v ← derefImmediate f let ctx = pi-to-ctx t let n = defName f --v ← pat-lam-norm v ctx let v = return v case v of λ where (ok v) → do v ← compile' v t n q ← quoteTC v unify a q e@(error s) → return e >>= quoteTC >>= unify a ---===== These are just all examples to play around ====--- tst-triv : ℕ → ℕ tst-triv x = x + 1 -- Test pattern contraction tst-ss : ℕ → ℕ tst-ss (suc (suc x)) = x tst-ss _ = 0 -- Here we have the (+ 0) in the last clause that -- stays in the generated code. tst-rew0 : ℕ → Bool → ℕ → ℕ tst-rew0 x true y = let a = x * x in a + y tst-rew0 x false y = x + 2 + 0 -- XXX can't do with clauses yet, but that shouldn tst-with : ℕ → ℕ tst-with x with x >? 0 tst-with x | yes p = 0 tst-with x | no ¬p = 1 -- Trivial test with Lists lst-test : List ℕ → ℕ lst-test [] = 0 lst-test (_∷_ x y) = x + 1 data Test : Set where cstctr : {x : ℕ} → x > 0 → Test test-test : Test → ℕ test-test (cstctr p) = 1 test-dot : (a : ℕ) → a > 0 → ℕ test-dot a@(.(suc _)) (s≤s pf) = a data Square : ℕ → Set where sq : (m : ℕ) → Square (m * m) root : (m : ℕ) (n : ℕ) → Square n → ℕ root a .(m * m) (sq m) = -- This is to show that square pattern is skipped -- from the context. In the above case, the clause is -- represetned as: a , . , (sq m) ==ctx==> a , m -- and the expression is (var 0) + (var 1) m + a open import Data.Vec hiding (concat) tst-vec : ∀ {n} → Vec ℕ n → Vec ℕ (n + n * n) → ℕ tst-vec [] _ = 0 tst-vec (x ∷ a) b = x a = (reflect-ty tst-vec) tst-undsc : _ → ℕ tst-undsc n = 1 + n vec-sum : ∀ {n} → Vec ℕ n → Vec ℕ (n) → Vec ℕ n vec-sum [] _ = [] vec-sum (x ∷ a) (y ∷ b) = x + y ∷ vec-sum a b vec-and-1 : ∀ {n} → Vec Bool n → Bool vec-and-1 (x ∷ xs) = x ∧ vec-and-1 xs vec-and-1 _ = true vec-and : ∀ {n} → Vec Bool n → Vec Bool n → Vec Bool n vec-and [] _ = [] vec-and (x ∷ a) (y ∷ b) = x ∧ y ∷ vec-and a b vec-+ : ∀ {n} → Vec ℕ n → ℕ vec-+ (x ∷ xs) = x + vec-+ xs vec-+ _ = 0 f : ℕ → ℕ f x = x * x vec-tst : ∀ n → Vec ℕ (n) → ℕ vec-tst 0 [] = 0 vec-tst (suc n) x = n * 2 -- (x ∷ xs) = n * 2 def-pst = (pist-vc= 1 cv= "" vctx= [] tctx= [] rv= "__ret" ret= error "" cons= []) --pist 1 [] [] (error "") q : List String × List String × Prog q = let (pist-vc= _ cv= _ vctx= v tctx= t rv= _ ret= r cons= _) = (trav-pi (reflect-ty vec-sum) def-pst) in (v , t , r) --open import Data.Fin xxx : Fin 5 → Fin 6 xxx zero = suc zero xxx (suc _) = zero fun-in-ty : (f : ℕ → ℕ) → Vec ℕ (f 3) → ℕ fun-in-ty f x = 1 -- V.replicate 1 open import Array data Ar' {a} (X : Set a) (d : ℕ) : (Vec ℕ d) → Set a where imap : ∀ s → (Ix d s → X) → Ar' X d s add-2v : ∀ {n} → let X = Ar ℕ 1 (n ∷ []) in X → X → X add-2v (imap a) (imap b) = imap λ iv → a iv + b iv postulate asum : ∀ {n} → Ar ℕ 1 (n ∷ []) → ℕ asum' : ∀ {n} → Ar' ℕ 1 (n ∷ []) → ℕ --sum (imap a) mm : ∀ {m n k} → let Mat a b = Ar ℕ 2 (a ∷ b ∷ []) in Mat m n → Mat n k → Mat m k mm (imap a) (imap b) = imap λ iv → let i = ix-lookup iv (# 0) j = ix-lookup iv (# 1) in asum (imap λ kv → let k = ix-lookup kv (# 0) in a (i ∷ k ∷ []) * b (k ∷ j ∷ [])) conv : ∀ {n} → let Ar1d n = Ar ℕ 1 V.[ n ] in Ar1d (3 + n) → Ar1d 3 → Ar1d (1 + n) conv (imap inp) (imap ker) = imap λ iv → let i = ix-lookup iv (# 0) in ( inp (raise 2 i ∷ []) * ker (# 0 ∷ []) + inp (raise 1 (suc i) ∷ []) * ker (# 1 ∷ []) + inp (raise 0 (suc (suc i)) ∷ []) * ker (# 2 ∷ []) ) / 3 where open import Data.Fin using (raise) open import Data.Nat.DivMod test-fin : Fin 3 → Fin 4 test-fin x = suc x w : String w = case compile mm of λ where (error s) → s (ok l) → sjoin l ""
{ "alphanum_fraction": 0.5094151568, "avg_line_length": 35.5158027813, "ext": "agda", "hexsha": "7474e678f32f63b4647b287062646e4d3d0e4b76", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2020-10-12T07:19:48.000Z", "max_forks_repo_forks_event_min_datetime": "2020-10-12T07:19:48.000Z", "max_forks_repo_head_hexsha": "584fedb30552f820c0668cedae53ec3d926860b5", "max_forks_repo_licenses": [ "0BSD" ], "max_forks_repo_name": "ashinkarov/agda-array", "max_forks_repo_path": "ExExtract.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "584fedb30552f820c0668cedae53ec3d926860b5", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "0BSD" ], "max_issues_repo_name": "ashinkarov/agda-array", "max_issues_repo_path": "ExExtract.agda", "max_line_length": 147, "max_stars_count": 6, "max_stars_repo_head_hexsha": "584fedb30552f820c0668cedae53ec3d926860b5", "max_stars_repo_licenses": [ "0BSD" ], "max_stars_repo_name": "ashinkarov/agda-array", "max_stars_repo_path": "ExExtract.agda", "max_stars_repo_stars_event_max_datetime": "2021-06-15T14:21:32.000Z", "max_stars_repo_stars_event_min_datetime": "2020-05-09T13:53:46.000Z", "num_tokens": 9202, "size": 28093 }
{-# OPTIONS --without-K #-} module hott.equivalence.logical where open import sum open import function.isomorphism.core open import hott.level.core _↔_ : ∀ {i j} → Set i → Set j → Set _ X ↔ Y = (X → Y) × (Y → X) module _ {i j}{X : Set i}{Y : Set j} where ≅⇒↔ : X ≅ Y → X ↔ Y ≅⇒↔ φ = to , from where open _≅_ φ ↔⇒≅ : h 1 X → h 1 Y → X ↔ Y → X ≅ Y ↔⇒≅ hX hY (f , g) = iso f g (λ x → h1⇒prop hX _ x) (λ y → h1⇒prop hY _ y)
{ "alphanum_fraction": 0.5298165138, "avg_line_length": 24.2222222222, "ext": "agda", "hexsha": "c355fae91005f8a86098bc0952919c6dae46adb1", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z", "max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z", "max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "pcapriotti/agda-base", "max_forks_repo_path": "src/hott/equivalence/logical.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "pcapriotti/agda-base", "max_issues_repo_path": "src/hott/equivalence/logical.agda", "max_line_length": 75, "max_stars_count": 20, "max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "pcapriotti/agda-base", "max_stars_repo_path": "src/hott/equivalence/logical.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z", "num_tokens": 201, "size": 436 }
open import FRP.JS.Level using ( Level ; _⊔_ ) renaming ( zero to o ; suc to ↑ ) open import FRP.JS.Time using ( Time ; _≤_ ; _<_ ) open import FRP.JS.Bool using ( Bool ; true ; false ; not ; _≟_ ) open import FRP.JS.True using ( True ; tt ) module FRP.JS.Model where -- This model is essentially System F-omega with a kind time -- together with a type for the partial order on time, -- and expressions for reflexivity and transitivity. -- We prove parametricity, and then show that parametricity implies causality. -- Note that this is a "deep" notion of causality, not the "shallow" -- causality usually used in FRP. The pragmatic upshot of this is that -- there is only one time model: nested signals are in the same time -- model, not a simulated time model. This fits with the JS implementation, -- which uses wall clock time for all signals. -- Propositional equality data _≡_ {α} {A : Set α} (a : A) : A → Set α where refl : a ≡ a sym : ∀ {α} {A : Set α} {a b : A} → (a ≡ b) → (b ≡ a) sym refl = refl trans : ∀ {α} {A : Set α} {a b c : A} → (a ≡ b) → (b ≡ c) → (a ≡ c) trans refl refl = refl cong : ∀ {α β} {A : Set α} {B : Set β} (f : A → B) {a₁ a₂ : A} → (a₁ ≡ a₂) → (f a₁ ≡ f a₂) cong f refl = refl apply : ∀ {α β} {A : Set α} {B : Set β} {F G : A → B} → (F ≡ G) → ∀ {a b} → (a ≡ b) → (F a ≡ G b) apply refl refl = refl cast : ∀ {α} {A B : Set α} → (A ≡ B) → A → B cast refl a = a cast² : ∀ {α} {A B : Set α} {ℜ ℑ : A → B → Set α} → (ℜ ≡ ℑ) → ∀ {a b} → ℜ a b → ℑ a b cast² refl aℜb = aℜb irrel : ∀ b → (b₁ b₂ : True b) → (b₁ ≡ b₂) irrel true tt tt = refl irrel false () () -- Postulates (including dependent extensionality) data _≤?_ (t u : Time) : Set where leq : True (t ≤ u) → (t ≤? u) geq : True (u ≤ t) → (t ≤? u) postulate ≤-refl : ∀ t → True (t ≤ t) ≤-trans : ∀ t u v → True (t ≤ u) → True (u ≤ v) → True (t ≤ v) ≤-asym : ∀ t u → True (t ≤ u) → True (u ≤ t) → (t ≡ u) ≤-total : ∀ t u → (t ≤? u) dext : ∀ {α β} {A : Set α} {B : A → Set β} {F G : ∀ a → B a} → (∀ a → F a ≡ G a) → (F ≡ G) ext : ∀ {α β} {A : Set α} {B : Set β} {F G : A → B} → (∀ a → F a ≡ G a) → (F ≡ G) ext = dext iext : ∀ {α β} {A : Set α} {B : A → Set β} {F G : ∀ {a} → B a} → (∀ a → F {a} ≡ G {a}) → ((λ {a} → F {a}) ≡ (λ {a} → G {a})) iext F≈G = cong (λ X {a} → X a) (dext F≈G) -- Finite products record ⊤ {α} : Set α where constructor tt open ⊤ public record Σ {α β} (A : Set α) (B : A → Set β) : Set (α ⊔ β) where constructor _,_ field proj₁ : A proj₂ : B proj₁ open Σ public _×_ : ∀ {α β} → Set α → Set β → Set (α ⊔ β) A × B = Σ A (λ a → B) _ײ_ : ∀ {α β} {A C : Set α} {B D : Set β} → (A → C → Set α) → (B → D → Set β) → ((A × B) → (C × D) → Set (α ⊔ β)) (ℜ ײ ℑ) (a , b) (c , d) = (ℜ a c × ℑ b d) _→²_ : ∀ {α β} {A C : Set α} {B D : Set β} → (A → C → Set α) → (B → D → Set β) → ((A → B) → (C → D) → Set (α ⊔ β)) (ℜ →² ℑ) f g = ∀ {a b} → ℜ a b → ℑ (f a) (g b) -- Case on booleans data Case (c : Bool) : Set where _,_ : ∀ b → True (b ≟ c) → Case c switch : ∀ b → Case b switch true = (true , tt) switch false = (false , tt) -- Reactive sets RSet : ∀ α → Set (↑ α) RSet α = Time → Set α -- Equalitional reasoning infix 4 _IsRelatedTo_ infix 2 _∎ infixr 2 _≡⟨_⟩_ infix 1 begin_ data _IsRelatedTo_ {α} {A : Set α} (a b : A) : Set α where relTo : (a≡b : a ≡ b) → a IsRelatedTo b begin_ : ∀ {α} {A : Set α} {a b : A} → a IsRelatedTo b → a ≡ b begin relTo a≡b = a≡b _≡⟨_⟩_ : ∀ {α} {A : Set α} a {b c : A} → a ≡ b → b IsRelatedTo c → a IsRelatedTo c _ ≡⟨ a≡b ⟩ relTo b≡c = relTo (trans a≡b b≡c) _∎ : ∀ {α} {A : Set α} (a : A) → a IsRelatedTo a _∎ _ = relTo refl -- Kinds data Kind : Set where time : Kind set : Level → Kind _⇒_ : Kind → Kind → Kind level : Kind → Level level time = o level (set α) = ↑ α level (K ⇒ L) = level K ⊔ level L K⟦_⟧ : ∀ K → Set (level K) K⟦ time ⟧ = Time K⟦ set α ⟧ = Set α K⟦ K ⇒ L ⟧ = K⟦ K ⟧ → K⟦ L ⟧ _∋_↔_ : ∀ K → K⟦ K ⟧ → K⟦ K ⟧ → Set (level K) time ∋ t ↔ u = (t ≡ u) set α ∋ A ↔ B = A → B → Set α (K ⇒ L) ∋ F ↔ G = ∀ {A B} → (K ∋ A ↔ B) → (L ∋ F A ↔ G B) -- ≡ can be used as a structural equivalence on relations. struct : ∀ K {A B C D} → (A ≡ B) → (K ∋ B ↔ D) → (C ≡ D) → (K ∋ A ↔ C) struct K refl ℜ refl = ℜ struct-ext : ∀ K L {A B} {F G H I : K⟦ K ⇒ L ⟧} (F≈G : ∀ A → F A ≡ G A) (ℜ : (K ⇒ L) ∋ G ↔ I) (H≈I : ∀ B → H B ≡ I B) (ℑ : K ∋ A ↔ B) → struct L (F≈G A) (ℜ ℑ) (H≈I B) ≡ struct (K ⇒ L) (ext F≈G) ℜ (ext H≈I) ℑ struct-ext K L {A} {B} F≈G ℜ H≈I ℑ with ext F≈G | ext H≈I | F≈G A | H≈I B ... | refl | refl | refl | refl = refl struct-apply : ∀ K L {F G H I A B C D} → (F≡G : F ≡ G) (ℜ : (K ⇒ L) ∋ G ↔ I) (H≡I : H ≡ I) → (A≡B : A ≡ B) (ℑ : K ∋ B ↔ D) (C≡D : C ≡ D) → struct (K ⇒ L) F≡G ℜ H≡I (struct K A≡B ℑ C≡D) ≡ struct L (apply F≡G A≡B) (ℜ ℑ) (apply H≡I C≡D) struct-apply K L refl ℜ refl refl ℑ refl = refl struct-cast : ∀ {α A B C D} (ℜ : set α ∋ B ↔ D) (A≡B : A ≡ B) (C≡D : C ≡ D) {a c} → struct (set α) A≡B ℜ C≡D a c → ℜ (cast A≡B a) (cast C≡D c) struct-cast ℜ refl refl aℜc = aℜc struct-sym : ∀ K {A B C D ℑ ℜ} → (A≡B : A ≡ B) → (C≡D : C ≡ D) → (ℑ ≡ struct K A≡B ℜ C≡D) → (ℜ ≡ struct K (sym A≡B) ℑ (sym C≡D)) struct-sym K refl refl refl = refl struct-trans : ∀ K {A B C D E F} (A≡B : A ≡ B) (B≡C : B ≡ C) (ℜ : K ∋ C ↔ F) (E≡F : E ≡ F) (D≡E : D ≡ E) → struct K A≡B (struct K B≡C ℜ E≡F) D≡E ≡ struct K (trans A≡B B≡C) ℜ (trans D≡E E≡F) struct-trans K refl refl ℜ refl refl = refl -- Type contexts infixr 4 _∷_ data Kinds : Set where [] : Kinds _∷_ : Kind → Kinds → Kinds levels : Kinds → Level levels [] = o levels (K ∷ Σ) = level K ⊔ levels Σ Σ⟦_⟧ : ∀ Σ → Set (levels Σ) Σ⟦ [] ⟧ = ⊤ Σ⟦ K ∷ Σ ⟧ = K⟦ K ⟧ × Σ⟦ Σ ⟧ _∋_↔*_ : ∀ Σ → Σ⟦ Σ ⟧ → Σ⟦ Σ ⟧ → Set (levels Σ) [] ∋ tt ↔* tt = ⊤ (K ∷ Σ) ∋ (A , As) ↔* (B , Bs) = (K ∋ A ↔ B) × (Σ ∋ As ↔* Bs) -- Inclusion order on type contexts. -- Credited by Randy Pollack to Geuvers and Nederhof, JAR 1991. -- http://thread.gmane.org/gmane.comp.lang.agda/3259/focus=3267 data _⊑_ : Kinds → Kinds → Set where id : ∀ {Σ} → Σ ⊑ Σ keep : ∀ K {Σ Υ} → (Σ ⊑ Υ) → ((K ∷ Σ) ⊑ (K ∷ Υ)) skip : ∀ K {Σ Υ} → (Σ ⊑ Υ) → (Σ ⊑ (K ∷ Υ)) ⊑⟦_⟧ : ∀ {Σ Υ} → (Σ ⊑ Υ) → Σ⟦ Υ ⟧ → Σ⟦ Σ ⟧ ⊑⟦ id ⟧ As = As ⊑⟦ keep K Σ⊑Υ ⟧ (A , As) = (A , ⊑⟦ Σ⊑Υ ⟧ As) ⊑⟦ skip K Σ⊑Υ ⟧ (A , As) = ⊑⟦ Σ⊑Υ ⟧ As ⊑⟦_⟧² : ∀ {Σ Υ} → (Σ⊑Υ : Σ ⊑ Υ) → ∀ {As Bs} → (Υ ∋ As ↔* Bs) → (Σ ∋ ⊑⟦ Σ⊑Υ ⟧ As ↔* ⊑⟦ Σ⊑Υ ⟧ Bs) ⊑⟦ id ⟧² ℜs = ℜs ⊑⟦ keep K Σ⊑Υ ⟧² (ℜ , ℜs) = (ℜ , ⊑⟦ Σ⊑Υ ⟧² ℜs) ⊑⟦ skip K Σ⊑Υ ⟧² (ℜ , ℜs) = ⊑⟦ Σ⊑Υ ⟧² ℜs -- Concatenation of type contexts _++_ : Kinds → Kinds → Kinds [] ++ Υ = Υ (K ∷ Σ) ++ Υ = K ∷ (Σ ++ Υ) _∋_++_∋_ : ∀ Σ → Σ⟦ Σ ⟧ → ∀ Υ → Σ⟦ Υ ⟧ → Σ⟦ Σ ++ Υ ⟧ [] ∋ tt ++ Υ ∋ Bs = Bs (K ∷ Σ) ∋ (A , As) ++ Υ ∋ Bs = (A , (Σ ∋ As ++ Υ ∋ Bs)) _∋_++²_∋_ : ∀ Σ {As Bs} → (Σ ∋ As ↔* Bs) → ∀ Υ {Cs Ds} → (Υ ∋ Cs ↔* Ds) → ((Σ ++ Υ) ∋ (Σ ∋ As ++ Υ ∋ Cs) ↔* (Σ ∋ Bs ++ Υ ∋ Ds)) [] ∋ tt ++² Υ ∋ ℑs = ℑs (K ∷ Σ) ∋ (ℜ , ℜs) ++² Υ ∋ ℑs = (ℜ , (Σ ∋ ℜs ++² Υ ∋ ℑs)) -- Type variables data TVar (K : Kind) : Kinds → Set where zero : ∀ {Σ} → TVar K (K ∷ Σ) suc : ∀ {L Σ} → TVar K Σ → TVar K (L ∷ Σ) τ⟦_⟧ : ∀ {Σ K} (τ : TVar K Σ) → Σ⟦ Σ ⟧ → K⟦ K ⟧ τ⟦ zero ⟧ (A , As) = A τ⟦ suc τ ⟧ (A , As) = τ⟦ τ ⟧ As τ⟦_⟧² : ∀ {Σ K} (τ : TVar K Σ) {As Bs} → (Σ ∋ As ↔* Bs) → (K ∋ τ⟦ τ ⟧ As ↔ τ⟦ τ ⟧ Bs) τ⟦ zero ⟧² (ℜ , ℜs) = ℜ τ⟦ suc τ ⟧² (ℜ , ℜs) = τ⟦ τ ⟧² ℜs -- Type constants data TConst : Kind → Set where prod fun : ∀ {α β} → TConst (set α ⇒ (set β ⇒ set (α ⊔ β))) leq : TConst (time ⇒ (time ⇒ set o)) univ : ∀ K {α} → TConst ((K ⇒ set α) ⇒ set (level K ⊔ α)) C⟦_⟧ : ∀ {K} → (TConst K) → K⟦ K ⟧ C⟦ prod ⟧ = λ A B → (A × B) C⟦ fun ⟧ = λ A B → (A → B) C⟦ leq ⟧ = λ t u → True (t ≤ u) C⟦ univ K ⟧ = λ F → ∀ A → F A C⟦_⟧² : ∀ {K} (C : TConst K) → (K ∋ C⟦ C ⟧ ↔ C⟦ C ⟧) C⟦ prod ⟧² = λ ℜ ℑ → (ℜ ײ ℑ) C⟦ fun ⟧² = λ ℜ ℑ → (ℜ →² ℑ) C⟦ leq ⟧² = λ _ _ _ _ → ⊤ C⟦ univ K ⟧² = λ ℜ f g → ∀ {a b} ℑ → ℜ ℑ (f a) (g b) -- Types data Typ (Σ : Kinds) : Kind → Set where const : ∀ {K} → TConst K → Typ Σ K abs : ∀ K {L} → Typ (K ∷ Σ) L → Typ Σ (K ⇒ L) app : ∀ {K L} → Typ Σ (K ⇒ L) → Typ Σ K → Typ Σ L var : ∀ {K} → TVar K Σ → Typ Σ K tlevel : ∀ {Σ α} → Typ Σ (set α) → Level tlevel {Σ} {α} T = α T⟦_⟧ : ∀ {Σ K} (T : Typ Σ K) → Σ⟦ Σ ⟧ → K⟦ K ⟧ T⟦ const C ⟧ As = C⟦ C ⟧ T⟦ abs K T ⟧ As = λ A → T⟦ T ⟧ (A , As) T⟦ app T U ⟧ As = T⟦ T ⟧ As (T⟦ U ⟧ As) T⟦ var τ ⟧ As = τ⟦ τ ⟧ As T⟦_⟧² : ∀ {Σ K} (T : Typ Σ K) {As Bs} → (Σ ∋ As ↔* Bs) → (K ∋ T⟦ T ⟧ As ↔ T⟦ T ⟧ Bs) T⟦ const C ⟧² ℜs = C⟦ C ⟧² T⟦ abs K T ⟧² ℜs = λ ℜ → T⟦ T ⟧² (ℜ , ℜs) T⟦ app T U ⟧² ℜs = T⟦ T ⟧² ℜs (T⟦ U ⟧² ℜs) T⟦ var τ ⟧² ℜs = τ⟦ τ ⟧² ℜs -- Type shorthands app₂ : ∀ {Σ K L M} → Typ Σ (K ⇒ (L ⇒ M)) → Typ Σ K → Typ Σ L → Typ Σ M app₂ T U V = app (app T U) V capp : ∀ {Σ K L} → TConst (K ⇒ L) → Typ Σ K → Typ Σ L capp C = app (const C) capp₂ : ∀ {Σ K L M} → TConst (K ⇒ (L ⇒ M)) → Typ Σ K → Typ Σ L → Typ Σ M capp₂ C = app₂ (const C) _⊗_ : ∀ {Σ α β} → Typ Σ (set α) → Typ Σ (set β) → Typ Σ (set (α ⊔ β)) _⊗_ = capp₂ prod _⊸_ : ∀ {Σ α β} → Typ Σ (set α) → Typ Σ (set β) → Typ Σ (set (α ⊔ β)) _⊸_ = capp₂ fun _≼_ : ∀ {Σ} → Typ Σ time → Typ Σ time → Typ Σ (set o) _≼_ = capp₂ leq Π : ∀ {Σ α} K → Typ (K ∷ Σ) (set α) → Typ Σ (set (level K ⊔ α)) Π K T = capp (univ K) (abs K T) tvar₀ : ∀ {Σ K} → Typ (K ∷ Σ) K tvar₀ = var zero tvar₁ : ∀ {Σ K L} → Typ (L ∷ K ∷ Σ) K tvar₁ = var (suc zero) tvar₂ : ∀ {Σ K L M} → Typ (M ∷ L ∷ K ∷ Σ) K tvar₂ = var (suc (suc zero)) tvar₃ : ∀ {Σ K L M N} → Typ (N ∷ M ∷ L ∷ K ∷ Σ) K tvar₃ = var (suc (suc (suc zero))) rset : Level → Kind rset α = time ⇒ set α rset₀ : Kind rset₀ = rset o prodʳ : ∀ {Σ α β} → Typ Σ (rset α ⇒ (rset β ⇒ rset (α ⊔ β))) prodʳ {Σ} {α} {β} = abs (rset α) (abs (rset β) (abs time (app tvar₂ tvar₀ ⊗ app tvar₁ tvar₀))) _⊗ʳ_ : ∀ {Σ α β} → Typ Σ (rset α) → Typ Σ (rset β) → Typ Σ (rset (α ⊔ β)) _⊗ʳ_ = app₂ prodʳ funʳ : ∀ {Σ α β} → Typ Σ (rset α ⇒ (rset β ⇒ rset (α ⊔ β))) funʳ {Σ} {α} {β} = abs (rset α) (abs (rset β) (abs time (app tvar₂ tvar₀ ⊸ app tvar₁ tvar₀))) _⊸ʳ_ : ∀ {Σ α β} → Typ Σ (rset α) → Typ Σ (rset β) → Typ Σ (rset (α ⊔ β)) _⊸ʳ_ = app₂ funʳ always : ∀ {Σ α} → Typ Σ (set α ⇒ rset α) always {Σ} {α} = abs (set α) (abs time tvar₁) interval : ∀ {Σ α} → Typ Σ (rset α ⇒ (time ⇒ (time ⇒ set α))) interval {Σ} {α} = abs (rset α) (abs time (abs time (Π time ((tvar₂ ≼ tvar₀) ⊸ ((tvar₀ ≼ tvar₁) ⊸ app tvar₃ tvar₀))))) _[_,_] : ∀ {Σ α} → Typ Σ (rset α) → Typ Σ time → Typ Σ time → Typ Σ (set α) T [ t , u ] = app (app (app interval T) t) u constreq : ∀ {Σ α β} → Typ Σ (rset α ⇒ (rset β ⇒ rset (α ⊔ β))) constreq {Σ} {α} {β} = abs (rset α) (abs (rset β) (abs time (Π time ((tvar₁ ≼ tvar₀) ⊸ ((tvar₃ [ tvar₁ , tvar₀ ]) ⊸ app tvar₂ tvar₀))))) _⊵_ : ∀ {Σ α β} → Typ Σ (rset α) → Typ Σ (rset β) → Typ Σ (rset (α ⊔ β)) T ⊵ U = app₂ constreq T U -- Contexts data Typs (Σ : Kinds) : Set where [] : Typs Σ _∷_ : ∀ {α} → (Typ Σ (set α)) → Typs Σ → Typs Σ tlevels : ∀ {Σ} → Typs Σ → Level tlevels [] = o tlevels (T ∷ Γ) = tlevel T ⊔ tlevels Γ Γ⟦_⟧ : ∀ {Σ} (Γ : Typs Σ) → Σ⟦ Σ ⟧ → Set (tlevels Γ) Γ⟦ [] ⟧ As = ⊤ Γ⟦ T ∷ Γ ⟧ As = T⟦ T ⟧ As × Γ⟦ Γ ⟧ As Γ⟦_⟧² : ∀ {Σ} (Γ : Typs Σ) {As Bs} (ℜs : Σ ∋ As ↔* Bs) → (Γ⟦ Γ ⟧ As → Γ⟦ Γ ⟧ Bs → Set (tlevels Γ)) Γ⟦ [] ⟧² ℜs tt tt = ⊤ Γ⟦ T ∷ Γ ⟧² ℜs (a , as) (b , bs) = T⟦ T ⟧² ℜs a b × Γ⟦ Γ ⟧² ℜs as bs -- Weakening of type variables τweaken : ∀ {Σ Υ K} → (Σ ⊑ Υ) → TVar K Σ → TVar K Υ τweaken id x = x τweaken (keep K Σ⊑Υ) zero = zero τweaken (keep K Σ⊑Υ) (suc x) = suc (τweaken Σ⊑Υ x) τweaken (skip K Σ⊑Υ) x = suc (τweaken Σ⊑Υ x) τweaken⟦_⟧ : ∀ {Σ Υ K} (τ : TVar K Σ) (Σ⊑Υ : Σ ⊑ Υ) (As : Σ⟦ Υ ⟧) → τ⟦ τ ⟧ (⊑⟦ Σ⊑Υ ⟧ As) ≡ τ⟦ τweaken Σ⊑Υ τ ⟧ As τweaken⟦ τ ⟧ id As = refl τweaken⟦ zero ⟧ (keep K Σ⊑Υ) (A , As) = refl τweaken⟦ suc τ ⟧ (keep K Σ⊑Υ) (A , As) = τweaken⟦ τ ⟧ Σ⊑Υ As τweaken⟦ τ ⟧ (skip K Σ⊑Υ) (A , As) = τweaken⟦ τ ⟧ Σ⊑Υ As τweaken⟦_⟧² : ∀ {Σ Υ K} (τ : TVar K Σ) (Σ⊑Υ : Σ ⊑ Υ) {As Bs} (ℜs : Υ ∋ As ↔* Bs) → τ⟦ τ ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs) ≡ struct K (τweaken⟦ τ ⟧ Σ⊑Υ As) (τ⟦ τweaken Σ⊑Υ τ ⟧² ℜs) (τweaken⟦ τ ⟧ Σ⊑Υ Bs) τweaken⟦ τ ⟧² id ℜs = refl τweaken⟦ zero ⟧² (keep K Σ⊑Υ) (ℜ , ℜs) = refl τweaken⟦ suc τ ⟧² (keep K Σ⊑Υ) (ℜ , ℜs) = τweaken⟦ τ ⟧² Σ⊑Υ ℜs τweaken⟦ τ ⟧² (skip K Σ⊑Υ) (ℜ , ℜs) = τweaken⟦ τ ⟧² Σ⊑Υ ℜs -- Weakening of types weaken : ∀ {Σ Υ K} → (Σ ⊑ Υ) → Typ Σ K → Typ Υ K weaken Σ⊑Υ (const C) = const C weaken Σ⊑Υ (abs K T) = abs K (weaken (keep K Σ⊑Υ) T) weaken Σ⊑Υ (app T U) = app (weaken Σ⊑Υ T) (weaken Σ⊑Υ U) weaken Σ⊑Υ (var τ) = var (τweaken Σ⊑Υ τ) weaken⟦_⟧ : ∀ {Σ Υ K} (T : Typ Σ K) (Σ⊑Υ : Σ ⊑ Υ) (As : Σ⟦ Υ ⟧) → T⟦ T ⟧ (⊑⟦ Σ⊑Υ ⟧ As) ≡ T⟦ weaken Σ⊑Υ T ⟧ As weaken⟦ const C ⟧ Σ⊑Υ As = refl weaken⟦ abs K T ⟧ Σ⊑Υ As = ext (λ A → weaken⟦ T ⟧ (keep K Σ⊑Υ) (A , As)) weaken⟦ app T U ⟧ Σ⊑Υ As = apply (weaken⟦ T ⟧ Σ⊑Υ As) (weaken⟦ U ⟧ Σ⊑Υ As) weaken⟦ var τ ⟧ Σ⊑Υ As = τweaken⟦ τ ⟧ Σ⊑Υ As weaken⟦_⟧² : ∀ {Σ Υ K} (T : Typ Σ K) (Σ⊑Υ : Σ ⊑ Υ) {As Bs} (ℜs : Υ ∋ As ↔* Bs) → T⟦ T ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs) ≡ struct K (weaken⟦ T ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ T ⟧² ℜs) (weaken⟦ T ⟧ Σ⊑Υ Bs) weaken⟦ const C ⟧² Σ⊑Υ ℜs = refl weaken⟦ abs K {L} T ⟧² Σ⊑Υ {As} {Bs} ℜs = iext (λ A → iext (λ B → ext (λ ℜ → begin T⟦ abs K T ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs) ℜ ≡⟨ weaken⟦ T ⟧² (keep K Σ⊑Υ) (ℜ , ℜs) ⟩ struct L (weaken⟦ T ⟧ (keep K Σ⊑Υ) (A , As)) (T⟦ weaken (keep K Σ⊑Υ) T ⟧² (ℜ , ℜs)) (weaken⟦ T ⟧ (keep K Σ⊑Υ) (B , Bs)) ≡⟨ struct-ext K L (λ A → weaken⟦ T ⟧ (keep K Σ⊑Υ) (A , As)) (λ ℜ → T⟦ weaken (keep K Σ⊑Υ) T ⟧² (ℜ , ℜs)) (λ B → weaken⟦ T ⟧ (keep K Σ⊑Υ) (B , Bs)) ℜ ⟩ struct (K ⇒ L) (weaken⟦ abs K T ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ (abs K T) ⟧² ℜs) (weaken⟦ abs K T ⟧ Σ⊑Υ Bs) ℜ ∎))) weaken⟦ app {K} {L} T U ⟧² Σ⊑Υ {As} {Bs} ℜs = begin T⟦ app T U ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs) ≡⟨ cong (T⟦ T ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs)) (weaken⟦ U ⟧² Σ⊑Υ ℜs) ⟩ T⟦ T ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs) (struct K (weaken⟦ U ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ U ⟧² ℜs) (weaken⟦ U ⟧ Σ⊑Υ Bs)) ≡⟨ cong (λ X → X (struct K (weaken⟦ U ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ U ⟧² ℜs) (weaken⟦ U ⟧ Σ⊑Υ Bs))) (weaken⟦ T ⟧² Σ⊑Υ ℜs) ⟩ (struct (K ⇒ L) (weaken⟦ T ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ T ⟧² ℜs) (weaken⟦ T ⟧ Σ⊑Υ Bs)) (struct K (weaken⟦ U ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ U ⟧² ℜs) (weaken⟦ U ⟧ Σ⊑Υ Bs)) ≡⟨ struct-apply K L (weaken⟦ T ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ T ⟧² ℜs) (weaken⟦ T ⟧ Σ⊑Υ Bs) (weaken⟦ U ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ U ⟧² ℜs) (weaken⟦ U ⟧ Σ⊑Υ Bs) ⟩ struct L (weaken⟦ app T U ⟧ Σ⊑Υ As) (T⟦ weaken Σ⊑Υ (app T U) ⟧² ℜs) (weaken⟦ app T U ⟧ Σ⊑Υ Bs) ∎ weaken⟦ var τ ⟧² Σ⊑Υ ℜs = τweaken⟦ τ ⟧² Σ⊑Υ ℜs -- Weakening on type contexts weakens : ∀ {Σ Υ} → (Σ ⊑ Υ) → Typs Σ → Typs Υ weakens Σ⊑Υ [] = [] weakens Σ⊑Υ (T ∷ Γ) = weaken Σ⊑Υ T ∷ weakens Σ⊑Υ Γ weakens⟦_⟧ : ∀ {Σ Υ} (Γ : Typs Σ) (Σ⊑Υ : Σ ⊑ Υ) (As : Σ⟦ Υ ⟧) → Γ⟦ Γ ⟧ (⊑⟦ Σ⊑Υ ⟧ As) → Γ⟦ weakens Σ⊑Υ Γ ⟧ As weakens⟦ [] ⟧ Σ⊑Υ As tt = tt weakens⟦ T ∷ Γ ⟧ Σ⊑Υ As (B , Bs) = (cast (weaken⟦ T ⟧ Σ⊑Υ As) B , weakens⟦ Γ ⟧ Σ⊑Υ As Bs) weakens⟦_⟧² : ∀ {Σ Υ} (Γ : Typs Σ) (Σ⊑Υ : Σ ⊑ Υ) {As Bs} (ℜs : Υ ∋ As ↔* Bs) {as bs} → Γ⟦ Γ ⟧² (⊑⟦ Σ⊑Υ ⟧² ℜs) as bs → Γ⟦ weakens Σ⊑Υ Γ ⟧² ℜs (weakens⟦ Γ ⟧ Σ⊑Υ As as) (weakens⟦ Γ ⟧ Σ⊑Υ Bs bs) weakens⟦ [] ⟧² Σ⊑Υ ℜs tt = tt weakens⟦ T ∷ Γ ⟧² Σ⊑Υ ℜs (aℜb , asℜbs) = ( struct-cast (T⟦ weaken Σ⊑Υ T ⟧² ℜs) (weaken⟦ T ⟧ Σ⊑Υ _) (weaken⟦ T ⟧ Σ⊑Υ _) (cast² (weaken⟦ T ⟧² Σ⊑Υ ℜs) aℜb) , weakens⟦ Γ ⟧² Σ⊑Υ ℜs asℜbs) -- Susbtitution on type variables under a context τsubstn+ : ∀ Σ {Υ K L} → TVar K (Σ ++ (L ∷ Υ)) → Typ Υ L → Typ (Σ ++ Υ) K τsubstn+ [] zero U = U τsubstn+ [] (suc τ) U = var τ τsubstn+ (K ∷ Σ) zero U = var zero τsubstn+ (K ∷ Σ) (suc τ) U = weaken (skip K id) (τsubstn+ Σ τ U) τsubstn+_⟦_⟧⟦_⟧ : ∀ Σ {Υ K L} (τ : TVar K (Σ ++ (L ∷ Υ))) (U : Typ Υ L) (As : Σ⟦ Σ ⟧) (Bs : Σ⟦ Υ ⟧) → τ⟦ τ ⟧ (Σ ∋ As ++ (L ∷ Υ) ∋ (T⟦ U ⟧ Bs , Bs)) ≡ T⟦ τsubstn+ Σ τ U ⟧ (Σ ∋ As ++ Υ ∋ Bs) τsubstn+ [] ⟦ zero ⟧⟦ U ⟧ tt Bs = refl τsubstn+ [] ⟦ suc τ ⟧⟦ U ⟧ tt Bs = refl τsubstn+ (K ∷ Σ) ⟦ zero ⟧⟦ U ⟧ (A , As) Bs = refl τsubstn+ (K ∷ Σ) ⟦ suc τ ⟧⟦ U ⟧ (A , As) Bs = trans (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Bs) (weaken⟦ τsubstn+ Σ τ U ⟧ (skip K id) (A , (Σ ∋ As ++ _ ∋ Bs))) τsubstn+_⟦_⟧⟦_⟧² : ∀ Σ {Υ L K} (τ : TVar K (Σ ++ (L ∷ Υ))) (U : Typ Υ L) {As Bs Cs Ds} (ℜs : Σ ∋ As ↔* Bs) → (ℑs : Υ ∋ Cs ↔* Ds) → τ⟦ τ ⟧² (Σ ∋ ℜs ++² (L ∷ Υ) ∋ (T⟦ U ⟧² ℑs , ℑs)) ≡ struct K (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Cs) (T⟦ τsubstn+ Σ τ U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs) ) (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ Bs Ds) τsubstn+ [] ⟦ zero ⟧⟦ U ⟧² tt ℑs = refl τsubstn+ [] ⟦ suc τ ⟧⟦ U ⟧² tt ℑs = refl τsubstn+ (J ∷ Σ) ⟦ zero ⟧⟦ U ⟧² (ℜ , ℜs) ℑs = refl τsubstn+_⟦_⟧⟦_⟧² (J ∷ Σ) {Υ} {L} {K} (suc τ) U {A , As} {B , Bs} {Cs} {Ds} (ℜ , ℜs) ℑs = begin τ⟦ τ ⟧² (Σ ∋ ℜs ++² (L ∷ Υ) ∋ (T⟦ U ⟧² ℑs , ℑs)) ≡⟨ τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧² ℜs ℑs ⟩ struct K (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Cs) (T⟦ τsubstn+ Σ τ U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs)) (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ Bs Ds) ≡⟨ cong (λ X → struct K (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Cs) X (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ Bs Ds)) (weaken⟦ τsubstn+ Σ τ U ⟧² (skip J id) (ℜ , (Σ ∋ ℜs ++² Υ ∋ ℑs))) ⟩ struct K (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Cs) (struct K (weaken⟦ τsubstn+ Σ τ U ⟧ (skip J id) (A , (Σ ∋ As ++ Υ ∋ Cs))) (T⟦ weaken (skip J id) (τsubstn+ Σ τ U) ⟧² (ℜ , (Σ ∋ ℜs ++² Υ ∋ ℑs))) (weaken⟦ τsubstn+ Σ τ U ⟧ (skip J id) (B , (Σ ∋ Bs ++ Υ ∋ Ds)))) (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ Bs Ds) ≡⟨ struct-trans K (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Cs) (weaken⟦ τsubstn+ Σ τ U ⟧ (skip J id) (A , (Σ ∋ As ++ Υ ∋ Cs))) (T⟦ weaken (skip J id) (τsubstn+ Σ τ U) ⟧² (ℜ , (Σ ∋ ℜs ++² Υ ∋ ℑs))) (weaken⟦ τsubstn+ Σ τ U ⟧ (skip J id) (B , (Σ ∋ Bs ++ Υ ∋ Ds))) (τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ Bs Ds) ⟩ struct K (τsubstn+ (J ∷ Σ) ⟦ suc τ ⟧⟦ U ⟧ (A , As) Cs) (T⟦ τsubstn+ (J ∷ Σ) (suc τ) U ⟧² (ℜ , (Σ ∋ ℜs ++² Υ ∋ ℑs)) ) (τsubstn+ (J ∷ Σ) ⟦ suc τ ⟧⟦ U ⟧ (B , Bs) Ds) ∎ -- Substitution on types under a context substn+ : ∀ Σ {Υ K L} → Typ (Σ ++ (L ∷ Υ)) K → Typ Υ L → Typ (Σ ++ Υ) K substn+ Σ (const C) U = const C substn+ Σ (abs K T) U = abs K (substn+ (K ∷ Σ) T U) substn+ Σ (app S T) U = app (substn+ Σ S U) (substn+ Σ T U) substn+ Σ (var τ) U = τsubstn+ Σ τ U substn+_⟦_⟧⟦_⟧ : ∀ Σ {Υ K L} (T : Typ (Σ ++ (L ∷ Υ)) K) (U : Typ Υ L) (As : Σ⟦ Σ ⟧) (Bs : Σ⟦ Υ ⟧) → T⟦ T ⟧ (Σ ∋ As ++ (L ∷ Υ) ∋ (T⟦ U ⟧ Bs , Bs)) ≡ T⟦ substn+ Σ T U ⟧ (Σ ∋ As ++ Υ ∋ Bs) substn+ Σ ⟦ const C ⟧⟦ U ⟧ As Bs = refl substn+ Σ ⟦ abs K T ⟧⟦ U ⟧ As Bs = ext (λ A → substn+ K ∷ Σ ⟦ T ⟧⟦ U ⟧ (A , As) Bs) substn+ Σ ⟦ app S T ⟧⟦ U ⟧ As Bs = apply (substn+ Σ ⟦ S ⟧⟦ U ⟧ As Bs) (substn+ Σ ⟦ T ⟧⟦ U ⟧ As Bs) substn+ Σ ⟦ var τ ⟧⟦ U ⟧ As Bs = τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧ As Bs substn+_⟦_⟧⟦_⟧² : ∀ Σ {Υ L K} (T : Typ (Σ ++ (L ∷ Υ)) K) (U : Typ Υ L) {As Bs Cs Ds} (ℜs : Σ ∋ As ↔* Bs) → (ℑs : Υ ∋ Cs ↔* Ds) → T⟦ T ⟧² (Σ ∋ ℜs ++² (L ∷ Υ) ∋ (T⟦ U ⟧² ℑs , ℑs)) ≡ struct K (substn+ Σ ⟦ T ⟧⟦ U ⟧ As Cs) (T⟦ substn+ Σ T U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs) ) (substn+ Σ ⟦ T ⟧⟦ U ⟧ Bs Ds) substn+ Σ ⟦ const C ⟧⟦ U ⟧² ℜs ℑs = refl substn+_⟦_⟧⟦_⟧² Σ {Υ} {L} (abs J {K} T) U {As} {Bs} {Cs} {Ds} ℜs ℑs = iext (λ A → iext (λ B → ext (λ ℜ → begin T⟦ abs J T ⟧² (Σ ∋ ℜs ++² (L ∷ Υ) ∋ (T⟦ U ⟧² ℑs , ℑs)) ℜ ≡⟨ substn+ (J ∷ Σ) ⟦ T ⟧⟦ U ⟧² (ℜ , ℜs) ℑs ⟩ struct K (substn+ J ∷ Σ ⟦ T ⟧⟦ U ⟧ (A , As) Cs) (T⟦ substn+ (J ∷ Σ) T U ⟧² ((J ∷ Σ) ∋ (ℜ , ℜs) ++² Υ ∋ ℑs)) (substn+ J ∷ Σ ⟦ T ⟧⟦ U ⟧ (B , Bs) Ds) ≡⟨ struct-ext J K (λ A → substn+ J ∷ Σ ⟦ T ⟧⟦ U ⟧ (A , As) Cs) (λ ℜ → T⟦ substn+ (J ∷ Σ) T U ⟧² ((J ∷ Σ) ∋ ℜ , ℜs ++² Υ ∋ ℑs)) (λ B → substn+ J ∷ Σ ⟦ T ⟧⟦ U ⟧ (B , Bs) Ds) ℜ ⟩ struct (J ⇒ K) (substn+ Σ ⟦ abs J T ⟧⟦ U ⟧ As Cs) (T⟦ substn+ Σ (abs J T) U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs)) (substn+ Σ ⟦ abs J T ⟧⟦ U ⟧ Bs Ds) ℜ ∎))) substn+_⟦_⟧⟦_⟧² Σ {Υ} {L} (app {J} {K} S T) U {As} {Bs} {Cs} {Ds} ℜs ℑs = begin T⟦ app S T ⟧² (Σ ∋ ℜs ++² L ∷ Υ ∋ (T⟦ U ⟧² ℑs , ℑs)) ≡⟨ cong (T⟦ S ⟧² (Σ ∋ ℜs ++² L ∷ Υ ∋ (T⟦ U ⟧² ℑs , ℑs))) (substn+ Σ ⟦ T ⟧⟦ U ⟧² ℜs ℑs) ⟩ T⟦ S ⟧² (Σ ∋ ℜs ++² L ∷ Υ ∋ (T⟦ U ⟧² ℑs , ℑs)) (struct J (substn+ Σ ⟦ T ⟧⟦ U ⟧ As Cs) (T⟦ substn+ Σ T U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs)) (substn+ Σ ⟦ T ⟧⟦ U ⟧ Bs Ds)) ≡⟨ cong (λ X → X (struct J (substn+ Σ ⟦ T ⟧⟦ U ⟧ As Cs) (T⟦ substn+ Σ T U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs)) (substn+ Σ ⟦ T ⟧⟦ U ⟧ Bs Ds))) (substn+ Σ ⟦ S ⟧⟦ U ⟧² ℜs ℑs) ⟩ struct (J ⇒ K) (substn+ Σ ⟦ S ⟧⟦ U ⟧ As Cs) (T⟦ substn+ Σ S U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs)) (substn+ Σ ⟦ S ⟧⟦ U ⟧ Bs Ds) (struct J (substn+ Σ ⟦ T ⟧⟦ U ⟧ As Cs) (T⟦ substn+ Σ T U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs)) (substn+ Σ ⟦ T ⟧⟦ U ⟧ Bs Ds)) ≡⟨ struct-apply J K (substn+ Σ ⟦ S ⟧⟦ U ⟧ As Cs) (T⟦ substn+ Σ S U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs)) (substn+ Σ ⟦ S ⟧⟦ U ⟧ Bs Ds) (substn+ Σ ⟦ T ⟧⟦ U ⟧ As Cs) (T⟦ substn+ Σ T U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs)) (substn+ Σ ⟦ T ⟧⟦ U ⟧ Bs Ds) ⟩ struct K (substn+ Σ ⟦ app S T ⟧⟦ U ⟧ As Cs) (T⟦ substn+ Σ (app S T) U ⟧² (Σ ∋ ℜs ++² Υ ∋ ℑs)) (substn+ Σ ⟦ app S T ⟧⟦ U ⟧ Bs Ds) ∎ substn+ Σ ⟦ var τ ⟧⟦ U ⟧² ℜs ℑs = τsubstn+ Σ ⟦ τ ⟧⟦ U ⟧² ℜs ℑs -- Substitution on types substn : ∀ {Σ K L} → Typ (L ∷ Σ) K → Typ Σ L → Typ Σ K substn = substn+ [] substn⟦_⟧⟦_⟧ : ∀ {Σ K L} (T : Typ (L ∷ Σ) K) (U : Typ Σ L) (As : Σ⟦ Σ ⟧)→ T⟦ T ⟧ (T⟦ U ⟧ As , As) ≡ T⟦ substn T U ⟧ As substn⟦ T ⟧⟦ U ⟧ = substn+ [] ⟦ T ⟧⟦ U ⟧ tt substn⟦_⟧⟦_⟧² : ∀ {Σ K L} (T : Typ (L ∷ Σ) K) (U : Typ Σ L) {As Bs} (ℜs : Σ ∋ As ↔* Bs) → T⟦ T ⟧² (T⟦ U ⟧² ℜs , ℜs) ≡ struct K (substn⟦ T ⟧⟦ U ⟧ As) (T⟦ substn T U ⟧² ℜs) (substn⟦ T ⟧⟦ U ⟧ Bs) substn⟦ T ⟧⟦ U ⟧² = substn+ [] ⟦ T ⟧⟦ U ⟧² tt -- Eta-beta equivalence on types data _∋_≣_ {Σ} : ∀ K → Typ Σ K → Typ Σ K → Set where abs : ∀ K {L T U} → (L ∋ T ≣ U) → ((K ⇒ L) ∋ abs K T ≣ abs K U) app : ∀ {K L F G T U} → ((K ⇒ L) ∋ F ≣ G) → (K ∋ T ≣ U) → (L ∋ app F T ≣ app G U) beta : ∀ {K L} T U → (L ∋ app (abs K T) U ≣ substn T U) eta : ∀ {K L} T → ((K ⇒ L) ∋ T ≣ abs K (app (weaken (skip K id) T) tvar₀)) ≣-refl : ∀ {K T} → (K ∋ T ≣ T) ≣-sym : ∀ {K T U} → (K ∋ T ≣ U) → (K ∋ U ≣ T) ≣-trans : ∀ {K T U V} → (K ∋ T ≣ U) → (K ∋ U ≣ V) → (K ∋ T ≣ V) ≣⟦_⟧ : ∀ {Σ K} {T U : Typ Σ K} → (K ∋ T ≣ U) → ∀ As → T⟦ T ⟧ As ≡ T⟦ U ⟧ As ≣⟦ abs K T≣U ⟧ As = ext (λ A → ≣⟦ T≣U ⟧ (A , As)) ≣⟦ app F≣G T≣U ⟧ As = apply (≣⟦ F≣G ⟧ As) (≣⟦ T≣U ⟧ As) ≣⟦ beta T U ⟧ As = substn⟦ T ⟧⟦ U ⟧ As ≣⟦ eta {K} T ⟧ As = ext (λ A → apply (weaken⟦ T ⟧ (skip K id) (A , As)) refl) ≣⟦ ≣-refl ⟧ As = refl ≣⟦ ≣-sym T≣U ⟧ As = sym (≣⟦ T≣U ⟧ As) ≣⟦ ≣-trans T≣U U≣V ⟧ As = trans (≣⟦ T≣U ⟧ As) (≣⟦ U≣V ⟧ As) ≣⟦_⟧² : ∀ {Σ K} {T U : Typ Σ K} (T≣U : K ∋ T ≣ U) {As Bs} (ℜs : Σ ∋ As ↔* Bs) → T⟦ T ⟧² ℜs ≡ struct K (≣⟦ T≣U ⟧ As) (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ Bs) ≣⟦ abs K {L} {T} {U} T≣U ⟧² {As} {Bs} ℜs = iext (λ A → iext (λ B → ext (λ ℜ → begin T⟦ T ⟧² (ℜ , ℜs) ≡⟨ ≣⟦ T≣U ⟧² (ℜ , ℜs) ⟩ struct L (≣⟦ T≣U ⟧ (A , As)) (T⟦ U ⟧² (ℜ , ℜs)) (≣⟦ T≣U ⟧ (B , Bs)) ≡⟨ struct-ext K L (λ A → ≣⟦ T≣U ⟧ (A , As)) (λ ℜ' → T⟦ U ⟧² (ℜ' , ℜs)) (λ B → ≣⟦ T≣U ⟧ (B , Bs)) ℜ ⟩ struct (K ⇒ L) (≣⟦ abs K T≣U ⟧ As) (T⟦ abs K U ⟧² ℜs) (≣⟦ abs K T≣U ⟧ Bs) ℜ ∎))) ≣⟦ app {K} {L} {F} {G} {T} {U} F≣G T≣U ⟧² {As} {Bs} ℜs = begin T⟦ app F T ⟧² ℜs ≡⟨ cong (T⟦ F ⟧² ℜs) (≣⟦ T≣U ⟧² ℜs) ⟩ T⟦ F ⟧² ℜs (struct K (≣⟦ T≣U ⟧ As) (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ Bs)) ≡⟨ cong (λ X → X (struct K (≣⟦ T≣U ⟧ As) (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ Bs))) (≣⟦ F≣G ⟧² ℜs) ⟩ struct (K ⇒ L) (≣⟦ F≣G ⟧ As) (T⟦ G ⟧² ℜs) (≣⟦ F≣G ⟧ Bs) (struct K (≣⟦ T≣U ⟧ As) (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ Bs)) ≡⟨ struct-apply K L (≣⟦ F≣G ⟧ As) (T⟦ G ⟧² ℜs) (≣⟦ F≣G ⟧ Bs) (≣⟦ T≣U ⟧ As) (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ Bs) ⟩ struct L (≣⟦ app F≣G T≣U ⟧ As) (T⟦ app G U ⟧² ℜs) (≣⟦ app F≣G T≣U ⟧ Bs) ∎ ≣⟦ beta T U ⟧² ℜs = substn⟦ T ⟧⟦ U ⟧² ℜs ≣⟦ eta {K} {L} T ⟧² {As} {Bs} ℜs = iext (λ A → iext (λ B → ext (λ ℜ → begin T⟦ T ⟧² ℜs ℜ ≡⟨ cong (λ X → X ℜ) (weaken⟦ T ⟧² (skip K id) (ℜ , ℜs)) ⟩ struct (K ⇒ L) (weaken⟦ T ⟧ (skip K id) (A , As)) (T⟦ weaken (skip K id) T ⟧² (ℜ , ℜs)) (weaken⟦ T ⟧ (skip K id) (B , Bs)) ℜ ≡⟨ struct-apply K L (weaken⟦ T ⟧ (skip K id) (A , As)) (T⟦ weaken (skip K id) T ⟧² (ℜ , ℜs)) (weaken⟦ T ⟧ (skip K id) (B , Bs)) refl ℜ refl ⟩ struct L (apply (weaken⟦ T ⟧ (skip K id) (A , As)) refl) (T⟦ weaken (skip K id) T ⟧² (ℜ , ℜs) ℜ) (apply (weaken⟦ T ⟧ (skip K id) (B , Bs)) refl) ≡⟨ struct-ext K L (λ A → apply (weaken⟦ T ⟧ (skip K id) (A , As)) refl) (λ ℜ → T⟦ weaken (skip K id) T ⟧² (ℜ , ℜs) ℜ) (λ B → apply (weaken⟦ T ⟧ (skip K id) (B , Bs)) refl) ℜ ⟩ struct (K ⇒ L) (≣⟦ eta T ⟧ As) (T⟦ abs K (app (weaken (skip K id) T) (var zero)) ⟧² ℜs) (≣⟦ eta T ⟧ Bs) ℜ ∎))) ≣⟦ ≣-refl ⟧² ℜs = refl ≣⟦ ≣-sym {K} {T} {U} T≣U ⟧² {As} {Bs} ℜs = struct-sym K (≣⟦ T≣U ⟧ As) (≣⟦ T≣U ⟧ Bs) (≣⟦ T≣U ⟧² ℜs) ≣⟦ ≣-trans {K} {T} {U} {V} T≣U U≣V ⟧² {As} {Bs} ℜs = begin T⟦ T ⟧² ℜs ≡⟨ ≣⟦ T≣U ⟧² ℜs ⟩ struct K (≣⟦ T≣U ⟧ As) (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ Bs) ≡⟨ cong (λ X → struct K (≣⟦ T≣U ⟧ As) X (≣⟦ T≣U ⟧ Bs)) (≣⟦ U≣V ⟧² ℜs) ⟩ struct K (≣⟦ T≣U ⟧ As) (struct K (≣⟦ U≣V ⟧ As) (T⟦ V ⟧² ℜs) (≣⟦ U≣V ⟧ Bs)) (≣⟦ T≣U ⟧ Bs) ≡⟨ struct-trans K (≣⟦ T≣U ⟧ As) (≣⟦ U≣V ⟧ As) (T⟦ V ⟧² ℜs) (≣⟦ U≣V ⟧ Bs) (≣⟦ T≣U ⟧ Bs) ⟩ struct K (≣⟦ ≣-trans T≣U U≣V ⟧ As) (T⟦ V ⟧² ℜs) (≣⟦ ≣-trans T≣U U≣V ⟧ Bs) ∎ -- Variables data Var {Σ : Kinds} {α} (T : Typ Σ (set α)) : Typs Σ → Set where zero : ∀ {Γ} → Var T (T ∷ Γ) suc : ∀ {β Γ} {U : Typ Σ (set β)} → Var T Γ → Var T (U ∷ Γ) x⟦_⟧ : ∀ {Σ} {Γ : Typs Σ} {α} {T : Typ Σ (set α)} → Var T Γ → (As : Σ⟦ Σ ⟧) → (as : Γ⟦ Γ ⟧ As) → (T⟦ T ⟧ As) x⟦ zero ⟧ As (a , as) = a x⟦ suc x ⟧ As (a , as) = x⟦ x ⟧ As as x⟦_⟧² : ∀ {Σ} {Γ : Typs Σ} {α} {T : Typ Σ (set α)} (x : Var T Γ) → ∀ {As Bs} (ℜs : Σ ∋ As ↔* Bs) {as bs} → (Γ⟦ Γ ⟧² ℜs as bs) → (T⟦ T ⟧² ℜs (x⟦ x ⟧ As as) (x⟦ x ⟧ Bs bs)) x⟦ zero ⟧² ℜs (aℜb , asℜbs) = aℜb x⟦ suc x ⟧² ℜs (aℜb , asℜbs) = x⟦ x ⟧² ℜs asℜbs -- Constants data Const {Σ : Kinds} : ∀ {α} → Typ Σ (set α) → Set where pair : ∀ {α β} → Const (Π (set α) (Π (set β) (tvar₁ ⊸ (tvar₀ ⊸ (tvar₁ ⊗ tvar₀))))) fst : ∀ {α β} → Const (Π (set α) (Π (set β) ((tvar₁ ⊗ tvar₀) ⊸ tvar₁))) snd : ∀ {α β} → Const (Π (set α) (Π (set β) ((tvar₁ ⊗ tvar₀) ⊸ tvar₀))) ≼-refl : Const (Π time (tvar₀ ≼ tvar₀)) ≼-trans : Const (Π time (Π time (Π time ((tvar₂ ≼ tvar₁) ⊸ ((tvar₁ ≼ tvar₀) ⊸ (tvar₂ ≼ tvar₀)))))) ≼-antisym : ∀ {α} → Const (Π (rset α) (Π time (Π time ((tvar₁ ≼ tvar₀) ⊸ ((tvar₀ ≼ tvar₁) ⊸ (app tvar₂ tvar₁ ⊸ app tvar₂ tvar₀)))))) ≼-case : ∀ {α} → Const (Π (set α) (Π time (Π time (((tvar₁ ≼ tvar₀) ⊸ tvar₂) ⊸ (((tvar₀ ≼ tvar₁) ⊸ tvar₂) ⊸ tvar₂))))) ≤-antisym : ∀ {α} (A : RSet α) t u → True (t ≤ u) → True (u ≤ t) → A t → A u ≤-antisym A t u t≤u u≤t a with ≤-asym t u t≤u u≤t ≤-antisym A t .t _ _ a | refl = a ≤-case′ : ∀ {α} {A : Set α} {t u} → (t ≤? u) → (True (t ≤ u) → A) → (True (u ≤ t) → A) → A ≤-case′ (leq t≤u) f g = f t≤u ≤-case′ (geq u≤t) f g = g u≤t ≤-case : ∀ {α} (A : Set α) t u → (True (t ≤ u) → A) → (True (u ≤ t) → A) → A ≤-case A t u = ≤-case′ (≤-total t u) c⟦_⟧ : ∀ {Σ} {α} {T : Typ Σ (set α)} → Const T → (As : Σ⟦ Σ ⟧) → (T⟦ T ⟧ As) c⟦ pair ⟧ As = λ A B a b → (a , b) c⟦ fst ⟧ As = λ A B → proj₁ c⟦ snd ⟧ As = λ A B → proj₂ c⟦ ≼-refl ⟧ As = ≤-refl c⟦ ≼-trans ⟧ As = ≤-trans c⟦ ≼-antisym ⟧ As = ≤-antisym c⟦ ≼-case ⟧ As = ≤-case c⟦_⟧² : ∀ {Σ} {α} {T : Typ Σ (set α)} (c : Const T) → ∀ {As Bs} (ℜs : Σ ∋ As ↔* Bs) → (T⟦ T ⟧² ℜs (c⟦ c ⟧ As) (c⟦ c ⟧ Bs)) c⟦ pair ⟧² ℜs = λ ℜ ℑ aℜb cℑd → (aℜb , cℑd) c⟦ fst ⟧² ℜs = λ ℜ ℑ → proj₁ c⟦ snd ⟧² ℜs = λ ℜ ℑ → proj₂ c⟦ ≼-refl ⟧² ℜs = _ c⟦ ≼-trans ⟧² ℜs = _ c⟦ ≼-antisym {α} ⟧² ℜs = lemma where lemma : ∀ {α} {A B : RSet α} (ℜ : rset α ∋ A ↔ B) → {t u : Time} → (t≡u : t ≡ u) → {v w : Time} → (v≡w : v ≡ w) → {t≤v : True (t ≤ v)} {u≤w : True (u ≤ w)} → ⊤ → {v≤t : True (v ≤ t)} {w≤u : True (w ≤ u)} → ⊤ → {a : A t} {b : B u} → ℜ t≡u a b → ℜ v≡w (≤-antisym A t v t≤v v≤t a) (≤-antisym B u w u≤w w≤u b) lemma ℜ {t} refl {v} refl {t≤v} {u≤w} tt {v≤t} {w≤u} tt aℜb with irrel (t ≤ v) t≤v u≤w | irrel (v ≤ t) v≤t w≤u lemma ℜ {t} refl {v} refl {t≤v} tt {v≤t} tt aℜb | refl | refl with ≤-asym t v t≤v v≤t lemma ℜ refl refl tt tt aℜb | refl | refl | refl = aℜb c⟦ ≼-case {α} ⟧² ℜs = lemma where lemma : ∀ {α} {A B : Set α} (ℜ : set α ∋ A ↔ B) → ∀ {t u : Time} → (t≡u : t ≡ u) → ∀ {v w : Time} → (v≡w : v ≡ w) → ∀ {f g} → (∀ {t≤v} {u≤w} → ⊤ → ℜ (f t≤v) (g u≤w)) → ∀ {h i} → (∀ {v≤t} {w≤u} → ⊤ → ℜ (h v≤t) (i w≤u)) → ℜ (≤-case A t v f h) (≤-case B u w g i) lemma ℜ {t} refl {v} refl {f} {g} fℜg {h} {i} hℜi = lemma′ (≤-total t v) where lemma′ : ∀ t≤?v → ℜ (≤-case′ t≤?v f h) (≤-case′ t≤?v g i) lemma′ (leq t≤v) = fℜg {t≤v} {t≤v} tt lemma′ (geq v≤t) = hℜi {v≤t} {v≤t} tt -- Expressions data Exp {Σ : Kinds} (Γ : Typs Σ) : ∀ {α} → Typ Σ (set α) → Set where const : ∀ {α} {T : Typ Σ (set α)} → Const T → Exp Γ T abs : ∀ {α β} (T : Typ Σ (set α)) {U : Typ Σ (set β)} (M : Exp (T ∷ Γ) U) → Exp Γ (T ⊸ U) app : ∀ {α β} {T : Typ Σ (set α)} {U : Typ Σ (set β)} (M : Exp Γ (T ⊸ U)) (N : Exp Γ T) → Exp Γ U var : ∀ {α} {T : Typ Σ (set α)} → Var T Γ → Exp Γ T tabs : ∀ K {α} {T : Typ (K ∷ Σ) (set α)} (M : Exp (weakens (skip K id) Γ) T) → Exp Γ (Π K T) tapp : ∀ {K α} {T : Typ (K ∷ Σ) (set α)} → Exp Γ (Π K T) → ∀ U → Exp Γ (substn T U) eq : ∀ {α T U} → (set α ∋ T ≣ U) → (Exp Γ T) → (Exp Γ U) ctxt : ∀ {Σ Γ α T} → Exp {Σ} Γ {α} T → Typs Σ ctxt {Σ} {Γ} M = Γ M⟦_⟧ : ∀ {Σ} {Γ : Typs Σ} {α} {T : Typ Σ (set α)} → Exp Γ T → (As : Σ⟦ Σ ⟧) → (as : Γ⟦ Γ ⟧ As) → (T⟦ T ⟧ As) M⟦ const c ⟧ As as = c⟦ c ⟧ As M⟦ abs T M ⟧ As as = λ a → M⟦ M ⟧ As (a , as) M⟦ app M N ⟧ As as = M⟦ M ⟧ As as (M⟦ N ⟧ As as) M⟦ var x ⟧ As as = x⟦ x ⟧ As as M⟦ tabs K M ⟧ As as = λ A → M⟦ M ⟧ (A , As) (weakens⟦ ctxt (tabs K M) ⟧ (skip K id) (A , As) as) M⟦ tapp {T = T} M U ⟧ As as = cast (substn⟦ T ⟧⟦ U ⟧ As) (M⟦ M ⟧ As as (T⟦ U ⟧ As)) M⟦ eq T≣U M ⟧ As as = cast (≣⟦ T≣U ⟧ As) (M⟦ M ⟧ As as) M⟦_⟧² : ∀ {Σ} {Γ : Typs Σ} {α} {T : Typ Σ (set α)} (M : Exp Γ T) → ∀ {As Bs} (ℜs : Σ ∋ As ↔* Bs) {as bs} → (Γ⟦ Γ ⟧² ℜs as bs) → (T⟦ T ⟧² ℜs (M⟦ M ⟧ As as) (M⟦ M ⟧ Bs bs)) M⟦ const c ⟧² ℜs asℜbs = c⟦ c ⟧² ℜs M⟦ abs T M ⟧² ℜs asℜbs = λ aℜb → M⟦ M ⟧² ℜs (aℜb , asℜbs) M⟦ app M N ⟧² ℜs asℜbs = M⟦ M ⟧² ℜs asℜbs (M⟦ N ⟧² ℜs asℜbs) M⟦ var x ⟧² ℜs asℜbs = x⟦ x ⟧² ℜs asℜbs M⟦ tabs K M ⟧² ℜs asℜbs = λ ℜ → M⟦ M ⟧² (ℜ , ℜs) (weakens⟦ ctxt (tabs K M) ⟧² (skip K id) (ℜ , ℜs) asℜbs) M⟦ tapp {T = T} M U ⟧² ℜs asℜbs = struct-cast (T⟦ substn T U ⟧² ℜs) (substn⟦ T ⟧⟦ U ⟧ _) (substn⟦ T ⟧⟦ U ⟧ _) (cast² (substn⟦ T ⟧⟦ U ⟧² ℜs) (M⟦ M ⟧² ℜs asℜbs (T⟦ U ⟧² ℜs))) M⟦ eq {α} {T} {U} T≣U M ⟧² {As} {Bs} ℜs asℜbs = struct-cast (T⟦ U ⟧² ℜs) (≣⟦ T≣U ⟧ As) (≣⟦ T≣U ⟧ Bs) (cast² (≣⟦ T≣U ⟧² ℜs) (M⟦ M ⟧² ℜs asℜbs)) -- Types with a chosen free world variable _∷ʳ_ : Kinds → Kind → Kinds [] ∷ʳ K = K ∷ [] (T ∷ Σ) ∷ʳ K = T ∷ (Σ ∷ʳ K) TVar+ : Kind → Kinds → Set TVar+ K Σ = TVar K (Σ ∷ʳ rset₀) Typ+ : Kinds → Kind → Set Typ+ Σ = Typ (Σ ∷ʳ rset₀) wvar : ∀ Σ → TVar+ rset₀ Σ wvar [] = zero wvar (K ∷ Σ) = suc (wvar Σ) world : ∀ {Σ} → Typ+ Σ rset₀ world {Σ} = var (wvar Σ) World : Time → Set World t = ⊤ taut : ∀ {Σ α} → Typ+ Σ (rset α ⇒ set α) taut {Σ} {α} = abs (rset α) (Π time (app (world {time ∷ rset α ∷ Σ}) tvar₀ ⊸ app tvar₁ tvar₀)) -- Surface types data STyp : Kind → Set where ⟨_⟩ : ∀ {α} → STyp (set α) → STyp (rset α) [_] : ∀ {α} → STyp (rset α) → STyp (set α) _⊠_ _↦_ : ∀ {α β} → STyp (set α) → STyp (set β) → STyp (set (α ⊔ β)) _∧_ _⇒_ : ∀ {α β} → STyp (rset α) → STyp (rset β) → STyp (rset (α ⊔ β)) □ : ∀ {α} → STyp (rset α) → STyp (rset α) ⟪_⟫ : ∀ {K} → STyp K → Typ+ [] K ⟪ ⟨ T ⟩ ⟫ = app always ⟪ T ⟫ ⟪ [ T ] ⟫ = app (taut {[]}) ⟪ T ⟫ ⟪ T ⊠ U ⟫ = ⟪ T ⟫ ⊗ ⟪ U ⟫ ⟪ T ↦ U ⟫ = ⟪ T ⟫ ⊸ ⟪ U ⟫ ⟪ T ∧ U ⟫ = ⟪ T ⟫ ⊗ʳ ⟪ U ⟫ ⟪ T ⇒ U ⟫ = ⟪ T ⟫ ⊸ʳ ⟪ U ⟫ ⟪ □ T ⟫ = tvar₀ ⊵ ⟪ T ⟫ T⟪_⟫ : ∀ {K} → STyp K → K⟦ K ⟧ T⟪ T ⟫ = T⟦ ⟪ T ⟫ ⟧ (World , tt) -- Signals of T are iso to □ T Signal : ∀ {α} → RSet α → RSet α Signal A s = ∀ t → True (s ≤ t) → A t sig : ∀ {α} (T : STyp (rset α)) s → T⟪ □ T ⟫ s → Signal T⟪ T ⟫ s sig T s σ t s≤t = σ t s≤t _ sig⁻¹ : ∀ {α} (T : STyp (rset α)) s → Signal T⟪ T ⟫ s → T⟪ □ T ⟫ s sig⁻¹ T s σ t s≤t _ = σ t s≤t sig-iso : ∀ {α} (T : STyp (rset α)) s σ → (sig T s (sig⁻¹ T s σ) ≡ σ) sig-iso T s σ = refl sig-iso⁻¹ : ∀ {α} (T : STyp (rset α)) s σ → (sig⁻¹ T s (sig T s σ) ≡ σ) sig-iso⁻¹ T s σ = refl -- Signal functions from T to U are iso to □ T ⇒ □ U SF : ∀ {α β} → RSet α → RSet β → RSet (α ⊔ β) SF A B s = Signal A s → Signal B s sf : ∀ {α β} (T : STyp (rset α)) (U : STyp (rset β)) s → T⟪ □ T ⇒ □ U ⟫ s → SF T⟪ T ⟫ T⟪ U ⟫ s sf T U s f σ = sig U s (f (sig⁻¹ T s σ)) sf⁻¹ : ∀ {α β} (T : STyp (rset α)) (U : STyp (rset β)) s → SF T⟪ T ⟫ T⟪ U ⟫ s → T⟪ □ T ⇒ □ U ⟫ s sf⁻¹ T U s f σ = sig⁻¹ U s (f (sig T s σ)) sf-iso : ∀ {α β} (T : STyp (rset α)) (U : STyp (rset β)) s f → (sf T U s (sf⁻¹ T U s f) ≡ f) sf-iso T U s f = refl sf-iso⁻¹ : ∀ {α β} (T : STyp (rset α)) (U : STyp (rset β)) s f → (sf⁻¹ T U s (sf T U s f) ≡ f) sf-iso⁻¹ T U s f = refl -- Causality mutual _at_⊨_≈[_]_ : ∀ {α} (T : STyp (rset α)) s → T⟪ T ⟫ s → Time → T⟪ T ⟫ s → Set α ⟨ T ⟩ at s ⊨ a ≈[ u ] b = T ⊨ a ≈[ u ] b (T ∧ U) at s ⊨ (a , b) ≈[ u ] (c , d) = (T at s ⊨ a ≈[ u ] c) × (U at s ⊨ b ≈[ u ] d) (T ⇒ U) at s ⊨ f ≈[ u ] g = ∀ a b → (T at s ⊨ a ≈[ u ] b) → (U at s ⊨ f a ≈[ u ] g b) □ T at s ⊨ σ ≈[ u ] τ = (∀ t s≤t → True (t ≤ u) → (T at t ⊨ σ t s≤t _ ≈[ u ] τ t s≤t _)) _⊨_≈[_]_ : ∀ {α} → (T : STyp (set α)) → T⟪ T ⟫ → Time → T⟪ T ⟫ → Set α [ T ] ⊨ σ ≈[ u ] τ = ∀ s → True (s ≤ u) → (T at s ⊨ σ s _ ≈[ u ] τ s _) (T ⊠ U) ⊨ (a , b) ≈[ u ] (c , d) = (T ⊨ a ≈[ u ] c) × (U ⊨ b ≈[ u ] d) (T ↦ U) ⊨ f ≈[ u ] g = ∀ a b → (T ⊨ a ≈[ u ] b) → (U ⊨ f a ≈[ u ] g b) Causal : ∀ {α β} (T : STyp (set α)) (U : STyp (set β)) → T⟪ T ↦ U ⟫ → Set (α ⊔ β) Causal T U f = ∀ u σ τ → (T ⊨ σ ≈[ u ] τ) → (U ⊨ f σ ≈[ u ] f τ) -- Parametricity implies causality ℜ[_] : Time → (rset o ∋ World ↔ World) ℜ[ u ] {t} s≡t tt tt = True (t ≤ u) mutual ℜ-impl-≈_at : ∀ {α} (T : STyp (rset α)) s u → True (s ≤ u) → ∀ a b → (T⟦ ⟪ T ⟫ ⟧² (ℜ[ u ] , tt) refl a b) → (T at s ⊨ a ≈[ u ] b) ℜ-impl-≈ ⟨ T ⟩ at s u s≤u a b aℜb = ℜ-impl-≈ T u a b aℜb ℜ-impl-≈ (T ∧ U) at s u s≤u (a , b) (c , d) (aℜc , bℜd) = (ℜ-impl-≈ T at s u s≤u a c aℜc , ℜ-impl-≈ U at s u s≤u b d bℜd) ℜ-impl-≈ (T ⇒ U) at s u s≤u f g fℜg = λ a b a≈b → ℜ-impl-≈ U at s u s≤u (f a) (g b) (fℜg (≈-impl-ℜ T at s u s≤u a b a≈b)) ℜ-impl-≈_at (□ T) s u s≤u σ τ σℜτ = λ t s≤t t≤u → ℜ-impl-≈ T at t u t≤u (σ t s≤t _) (τ t s≤t _) (σℜτ refl tt (λ {r} _ _ {r≤t} _ → ≤-trans r t u r≤t t≤u)) ≈-impl-ℜ_at : ∀ {α} (T : STyp (rset α)) s u → True (s ≤ u) → ∀ a b → (T at s ⊨ a ≈[ u ] b) → (T⟦ ⟪ T ⟫ ⟧² (ℜ[ u ] , tt) refl a b) ≈-impl-ℜ ⟨ T ⟩ at s u s≤u a b a≈b = ≈-impl-ℜ T u a b a≈b ≈-impl-ℜ (T ∧ U) at s u s≤u (a , b) (c , d) (a≈c , b≈d) = (≈-impl-ℜ T at s u s≤u a c a≈c , ≈-impl-ℜ U at s u s≤u b d b≈d) ≈-impl-ℜ (T ⇒ U) at s u s≤u f g f≈g = λ {a} {b} aℜb → ≈-impl-ℜ U at s u s≤u (f a) (g b) (f≈g a b (ℜ-impl-≈ T at s u s≤u a b aℜb)) ≈-impl-ℜ (□ T) at s u s≤u σ τ σ≈τ = lemma where lemma : T⟦ ⟪ □ T ⟫ ⟧² (ℜ[ u ] , tt) {s} refl σ τ lemma {t} refl {s≤t} {s≤t′} tt kℜk′ with irrel (s ≤ t) s≤t s≤t′ lemma {t} refl {s≤t} tt kℜk′ | refl = ≈-impl-ℜ T at t u t≤u (σ t s≤t _) (τ t s≤t _) (σ≈τ t s≤t t≤u) where t≤u = kℜk′ {t} refl {s≤t} {s≤t} tt {≤-refl t} {≤-refl t} tt ℜ-impl-≈ : ∀ {α} (T : STyp (set α)) (u : Time) (a b : T⟪ T ⟫) → (T⟦ ⟪ T ⟫ ⟧² (ℜ[ u ] , tt) a b) → (T ⊨ a ≈[ u ] b) ℜ-impl-≈ (T ⊠ U) u (a , b) (c , d) (aℜc , bℜd) = (ℜ-impl-≈ T u a c aℜc , ℜ-impl-≈ U u b d bℜd) ℜ-impl-≈ (T ↦ U) u f g fℜg = λ a b a≈b → ℜ-impl-≈ U u (f a) (g b) (fℜg (≈-impl-ℜ T u a b a≈b)) ℜ-impl-≈ [ T ] u σ τ σℜτ = λ s s≤u → ℜ-impl-≈ T at s u s≤u (σ s _) (τ s _) (σℜτ refl s≤u) ≈-impl-ℜ : ∀ {α} (T : STyp (set α)) (u : Time) (a b : T⟪ T ⟫) → (T ⊨ a ≈[ u ] b) → (T⟦ ⟪ T ⟫ ⟧² (ℜ[ u ] , tt) a b) ≈-impl-ℜ (T ⊠ U) u (a , b) (c , d) (a≈c , b≈d) = (≈-impl-ℜ T u a c a≈c , ≈-impl-ℜ U u b d b≈d) ≈-impl-ℜ (T ↦ U) u f g f≈g = λ {a} {b} aℜb → ≈-impl-ℜ U u (f a) (g b) (f≈g a b (ℜ-impl-≈ T u a b aℜb)) ≈-impl-ℜ [ T ] u σ τ σ≈τ = lemma where lemma : T⟦ ⟪ [ T ] ⟫ ⟧² (ℜ[ u ] , tt) σ τ lemma {s} refl s≤u = ≈-impl-ℜ T at s u s≤u (σ s _) (τ s _) (σ≈τ s s≤u) -- Every F-omega function is causal causality : ∀ {α β} (T : STyp (set α)) (U : STyp (set β)) (M : Exp [] ⟪ T ↦ U ⟫) → Causal T U (M⟦ M ⟧ (World , tt) tt) causality T U M u = ℜ-impl-≈ (T ↦ U) u (M⟦ M ⟧ (World , tt) tt) (M⟦ M ⟧ (World , tt) tt) (M⟦ M ⟧² (ℜ[ u ] , _) tt)
{ "alphanum_fraction": 0.4363592635, "avg_line_length": 37.1608738828, "ext": "agda", "hexsha": "3fb837cf23c0bc7bf7e37cf48d1152a487aa51bc", "lang": "Agda", "max_forks_count": 7, "max_forks_repo_forks_event_max_datetime": "2022-03-12T11:39:38.000Z", "max_forks_repo_forks_event_min_datetime": "2016-11-07T21:50:58.000Z", "max_forks_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_forks_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_forks_repo_name": "agda/agda-frp-js", "max_forks_repo_path": "src/agda/FRP/JS/Model.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_issues_repo_name": "agda/agda-frp-js", "max_issues_repo_path": "src/agda/FRP/JS/Model.agda", "max_line_length": 134, "max_stars_count": 63, "max_stars_repo_head_hexsha": "c7ccaca624cb1fa1c982d8a8310c313fb9a7fa72", "max_stars_repo_licenses": [ "MIT", "BSD-3-Clause" ], "max_stars_repo_name": "agda/agda-frp-js", "max_stars_repo_path": "src/agda/FRP/JS/Model.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-28T09:46:14.000Z", "max_stars_repo_stars_event_min_datetime": "2015-04-20T21:47:00.000Z", "num_tokens": 22276, "size": 37421 }
module x00-playpen where -- prove properties of inductive naturals and operations on them via induction import Relation.Binary.PropositionalEquality as Eq open Eq using (_≡_; refl; cong; sym) open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; step-≡; _∎) open import Data.Nat using (ℕ; zero; suc; _+_; _*_; _∸_; _^_) *-assoc : ∀ (m n p : ℕ) → (m * n) * p ≡ m * (n * p) *-assoc m n p = {!!} +-xx : ∀ (n : ℕ) → (n ^ 3) ∸ ((n * n) * n) ≡ zero +-xx zero = refl +-xx (suc n) = {!!} {- begin (n * (n ^ 2)) ∸ ((n * n) * n) ≡⟨⟩ (n * (n * (n ^ 1))) ∸ ((n * n) * n) ≡⟨⟩ (n * (n * (n * (n ^ 0)))) ∸ ((n * n) * n) ≡⟨⟩ (n * (n * (n * 1 ))) ∸ ((n * n) * n) ≡⟨⟩ (n * (n * n )) ∸ ((n * n) * n) ≡⟨ cong ( ((n * (n * n))) ∸_) (*-assoc n n n) ⟩ (n * (n * n )) ∸ ( n * (n * n)) ∎ -}
{ "alphanum_fraction": 0.3713033954, "avg_line_length": 26.0857142857, "ext": "agda", "hexsha": "995d37bbba0f82cc8955d762cd9938e0d21bd349", "lang": "Agda", "max_forks_count": 8, "max_forks_repo_forks_event_max_datetime": "2021-09-21T15:58:10.000Z", "max_forks_repo_forks_event_min_datetime": "2015-04-13T21:40:15.000Z", "max_forks_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_forks_repo_licenses": [ "Unlicense" ], "max_forks_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_forks_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x00-playpen.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "Unlicense" ], "max_issues_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_issues_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x00-playpen.agda", "max_line_length": 78, "max_stars_count": 36, "max_stars_repo_head_hexsha": "3dc7abca7ad868316bb08f31c77fbba0d3910225", "max_stars_repo_licenses": [ "Unlicense" ], "max_stars_repo_name": "haroldcarr/learn-haskell-coq-ml-etc", "max_stars_repo_path": "agda/book/Programming_Language_Foundations_in_Agda/x00-playpen.agda", "max_stars_repo_stars_event_max_datetime": "2021-07-30T06:55:03.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-29T14:37:15.000Z", "num_tokens": 405, "size": 913 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Data.Queue where open import Cubical.Data.Queue.Base public open import Cubical.Data.Queue.Finite public
{ "alphanum_fraction": 0.7586206897, "avg_line_length": 21.75, "ext": "agda", "hexsha": "b47e6aca5f1887c56eaa546157144c936f2e7867", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/Data/Queue.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/Data/Queue.agda", "max_line_length": 50, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/Data/Queue.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 41, "size": 174 }
module Numeral.CoordinateVector where import Lvl open import Data.Boolean open import Functional open import Lang.Instance open import Numeral.Finite open import Numeral.Finite.Bound open import Numeral.Finite.Oper open import Numeral.Finite.Oper.Comparisons open import Numeral.Natural import Numeral.Natural.Oper as ℕ open import Numeral.Natural.Function open import Numeral.Natural.Function.Proofs open import Type private variable ℓ : Lvl.Level private variable T A B C : Type{ℓ} private variable d d₁ d₂ : ℕ -- Accessor of data in 1-dimensional finite space (Implies bounded). -- Like a homogenous tuple or a fixed-size list. -- The type is defined as the type of the vector projection function (A cell in the vector). Vector : ℕ → Type{ℓ} → Type Vector(d)(T) = 𝕟(d) → T -- Type of elements in the vector Element : Vector(d)(T) → Type Element{T = T} = const T -- The maximum number of dimensions of a space that the vector can describe points in dim : Vector(d)(T) → ℕ dim{d = d} = const d -- The projection function (which also is the function itself). proj : Vector(d)(T) → 𝕟(d) → T proj = id -- TODO: Move this to a separate "Relations" file open import Logic open import Relator.Equals.Proofs.Equivalence open import Structure.Function.Domain open import Structure.Setoid private variable ℓₑ : Lvl.Level -- The vector's elements are all distinct (the vector contains no duplicate elements). Distinct : ⦃ equiv : Equiv{ℓₑ}(T) ⦄ → Vector(d)(T) → Stmt Distinct = Injective ⦃ [≡]-equiv ⦄ -- The first element of a non-empty vector head : Vector(𝐒(d))(T) → T head(v) = v(𝟎) -- The list without the first element of a non-empty vector tail : Vector(𝐒(d))(T) → Vector(d)(T) (tail{𝐒(_)}(v)) (i) = v(𝐒(i)) -- The list without the first element if there were any tail₀ : Vector(d)(T) → Vector(Numeral.Natural.𝐏(d))(T) tail₀{𝟎} = id tail₀{𝐒(_)} = tail -- The last element of a non-empty vector last : Vector(𝐒(d))(T) → T last(v) = v(maximum) -- The list without the last element if there were any withoutLast : Vector(𝐒(d))(T) → Vector(d)(T) (withoutLast v)(i) = v(bound-𝐒(i)) -- Applies a function on every value of the vector map : (A → B) → Vector(d)(A) → Vector(d)(B) (map f(v))(i) = f(v(i)) -- Applies a binary operation on every pair of values, each from 2 vectors elementwise -- Example: -- map₂(_+_) [1,2,3] [10,20,30] = [1+10 , 2+20 , 3+30] = [11,22,33] map₂ : (A → B → C) → Vector(d)(A) → Vector(d)(B) → Vector(d)(C) (map₂(_▫_) (v₁)(v₂))(i) = v₁(i) ▫ v₂(i) map₂-min : (A → B → C) → ∀{d₁ d₂} → Vector(d₁)(A) → Vector(d₂)(B) → Vector(min d₁ d₂)(C) (map₂-min(_▫_) (v₁)(v₂))(i) = v₁(bound-[≤] infer i) ▫ v₂(bound-[≤] infer i) -- Example: -- foldₗ (_▫_) (0) [1,2,3,4] -- = (((0 ▫ 1) ▫ 2) ▫ 3) ▫ 4 foldₗ : (B → A → B) → B → Vector(d)(A) → B foldₗ {d = 𝟎} (_▫_) (init) (v) = init foldₗ {d = 𝐒(d)} (_▫_) (init) (v) = foldₗ {d = d} (_▫_) (init ▫ (head v)) (tail v) -- Example: -- reduceₗ (_▫_) [1,2,3,4] -- = ((1 ▫ 2) ▫ 3) ▫ 4 reduceₗ : (A → A → A) → Vector(𝐒(d))(A) → A reduceₗ(_▫_) v = foldₗ(_▫_) (head v) (tail v) -- Example: -- reduceOrₗ (_▫_) 0 [1,2,3,4] -- = ((1 ▫ 2) ▫ 3) ▫ 4 reduceOrₗ : (A → A → A) → A → Vector(d)(A) → A reduceOrₗ {d = 𝟎} _ empty _ = empty reduceOrₗ {d = 𝐒(d)} (_▫_) empty v = foldₗ(_▫_) (head v) (tail v) -- Example: -- foldᵣ (_▫_) (0) [1,2,3,4] -- = 1 ▫ (2 ▫ (3 ▫ (4 ▫ 0))) foldᵣ : (A → B → B) → B → Vector(d)(A) → B foldᵣ {d = 𝟎} (_▫_) (init) (v) = init foldᵣ {d = 𝐒(d)} (_▫_) (init) (v) = (head v) ▫ (foldᵣ {d = d} (_▫_) (init) (tail v)) -- Example: -- foldᵣ-init (_▫_) (0) [1,2,3,4] -- = 0 ▫ (1 ▫ (2 ▫ (3 ▫ 4))) foldᵣ-init : (A → A → A) → A → Vector(d)(A) → A foldᵣ-init {d = 𝟎} (_▫_) (init) (v) = init foldᵣ-init {d = 𝐒(d)} (_▫_) (init) (v) = init ▫ (foldᵣ-init {d = d} (_▫_) (head v) (tail v)) -- Example: -- reduceᵣ (_▫_) [1,2,3,4] -- = 1 ▫ (2 ▫ (3 ▫ 4)) reduceᵣ : (T → T → T) → Vector(𝐒(d))(T) → T reduceᵣ {d = 𝟎} (_▫_) (v) = head v reduceᵣ {d = 𝐒(d)} (_▫_) (v) = (head v) ▫ (reduceᵣ (_▫_) (tail v)) -- Example: -- reduceOrᵣ (_▫_) (0) [1,2,3,4] -- = 1 ▫ (2 ▫ (3 ▫ 4)) reduceOrᵣ : (T → T → T) → T → Vector(d)(T) → T reduceOrᵣ {d = 𝟎} _ empty v = empty reduceOrᵣ {d = 𝐒(d)} (_▫_) empty v = reduceᵣ(_▫_) v -- A vector filled with multiple copies of a single element. fill : T → Vector(d)(T) fill(elem) = const(elem) -- An empty vector. empty : Vector(0)(T) empty() -- A vector with a single element. singleton : T → Vector(1)(T) singleton x 𝟎 = x -- A vector with two elements. pair : T → T → Vector(2)(T) pair x _ (𝟎) = x pair _ y (𝐒 𝟎) = y -- A vector with an additional element at the start. prepend : T → Vector(d)(T) → Vector(𝐒(d))(T) (prepend(x)(_)) (𝟎) = x (prepend(_)(v)) (𝐒(n)) = v(n) -- A vector with an additional element inserted at an already existing position. -- Examples: -- insert 0 x [a,b,c] = [x,a,b,c] -- insert 1 x [a,b,c] = [a,x,b,c] -- insert 2 x [a,b,c] = [a,b,x,c] -- insert 3 x [a,b,c] is a type error because 3 is not an existing position. insert : 𝕟(d) → T → Vector(d)(T) → Vector(𝐒(d))(T) insert 𝟎 = prepend insert (𝐒 _) _ v 𝟎 = v(𝟎) insert (𝐒 i) x v (𝐒 n) = insert i x (tail v) n -- A vector with an additional element inserted at a position. -- Note: The difference compared to insert is that this includes the postpending operation. -- Examples: -- insert₊ 0 x [a,b] = [x,a,b] -- insert₊ 0 x [a,b] 0 ≟ [x,a,b] 0 = x -- insert₊ 0 x [a,b] 1 ≟ [x,a,b] 1 = a -- insert₊ 0 x [a,b] 2 ≟ [x,a,b] 2 = b -- insert₊ 1 x [a,b] = [a,x,b] -- insert₊ 1 x [a,b] 0 = a -- insert₊ 1 x [a,b] 1 = insert₊ 0 x [b] 0 = x -- insert₊ 1 x [a,b] 2 = insert₊ 0 x [b] 1 = [x,b] 1 = b -- insertv 2 x [a,b] = [a,b,x] -- insert₊ 2 x [a,b] 0 = a -- insert₊ 2 x [a,b] 1 = insert₊ 1 x [b] 0 = b -- insert₊ 2 x [a,b] 2 = insert₊ 1 x [b] 1 = insert₊ 0 x [] 0 = [x] 0 = x insert₊ : 𝕟₌(d) → T → Vector(d)(T) → Vector(𝐒(d))(T) insert₊{_} 𝟎 = prepend insert₊{𝐒 _} (𝐒 _) _ v 𝟎 = v(𝟎) insert₊{𝐒 _} (𝐒 i) x v (𝐒 n) = insert₊ i x (tail v) n -- A vector concatenated with another vector _++_ : Vector(d₁)(T) → Vector(d₂)(T) → Vector(d₁ ℕ.+ d₂)(T) _++_ {d₁ = 𝟎} {d₂ = d₂} v₁ v₂ = v₂ _++_ {d₁ = 𝐒(d₁)} {d₂ = d₂} v₁ v₂ (𝟎) = v₁(𝟎) _++_ {d₁ = 𝐒(d₁)} {d₂ = d₂} v₁ v₂ (𝐒(i)) = _++_ {d₁ = d₁} {d₂ = d₂} (v₁ ∘ 𝐒) v₂ i count : (T → Bool) → Vector(d)(T) → ℕ count {d = 𝟎} (f)(v) = 𝟎 count {d = 𝐒(n)} (f)(v) = (if f(head v) then 𝐒 else id) (count{d = n} (f)(tail v)) reverse : Vector(d)(T) → Vector(d)(T) (reverse(v)) (n) = v(Wrapping.[−] n) indexProject : 𝕟(d) → T → T → Vector(d)(T) indexProject n true false i = if(n ≡? i) then true else false -- A vector without the element at the specified index -- TODO: Implement Numeral.Finite.Bound.bound-𝐏 -- without : ∀{T}{d} → 𝕟(𝐒(d)) → Vector(𝐒(d))(T) → Vector(d)(T) -- Vector.proj (without {_}{𝐒(_)} (𝟎) (v)) (i) = Vector.proj(v)(𝐒(i)) -- Vector.proj (without {_}{𝐒(_)} (𝐒(n))(v)) (i) = if(i ≤? n) then Vector.proj(v)(𝐒(i)) else Vector.proj(v)(bound-𝐏(i)) -- postpend : ∀{T}{d} → T → Vector(d)(T) → Vector(𝐒(d))(T) -- Vector.proj(postpend{_}{d} (x)(_)) (n) = if (n ≡? d) then x else Vector.proj(v)(n) -- concat : ∀{T}{d₁ d₂} → Vector(d₁)(T) → Vector(d₂)(T) → Vector(d₁ + d₂)(T) -- Vector.proj(concat(v₁)(v₂)) (n) with (n < d₁ ≡ 𝑇) -- ... () = Vector.proj(v₁) (n) -- ... () = Vector.proj(v₂) (n) -- TODO: take / truncate -- TODO: Equality by function equality
{ "alphanum_fraction": 0.5698331539, "avg_line_length": 34.4074074074, "ext": "agda", "hexsha": "1cd1777e559a12577c81dd70feb29103e399b0b3", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Numeral/CoordinateVector.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Numeral/CoordinateVector.agda", "max_line_length": 119, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Numeral/CoordinateVector.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 3191, "size": 7432 }
{-# OPTIONS --cubical #-} module Issue4365 where open import Agda.Primitive.Cubical open import Agda.Builtin.Cubical.Path postulate A : Set a : A _ : primTransp (\ i → A) i0 a ≡ a _ = \ _ → a
{ "alphanum_fraction": 0.655, "avg_line_length": 14.2857142857, "ext": "agda", "hexsha": "9fc203d764643dd06d60cfcfd3e324a98d55c3a4", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_forks_repo_licenses": [ "BSD-2-Clause" ], "max_forks_repo_name": "cagix/agda", "max_forks_repo_path": "test/Fail/Issue4365.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-2-Clause" ], "max_issues_repo_name": "cagix/agda", "max_issues_repo_path": "test/Fail/Issue4365.agda", "max_line_length": 37, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "cc026a6a97a3e517bb94bafa9d49233b067c7559", "max_stars_repo_licenses": [ "BSD-2-Clause" ], "max_stars_repo_name": "cagix/agda", "max_stars_repo_path": "test/Fail/Issue4365.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 71, "size": 200 }
{-# OPTIONS --without-K --safe #-} module Categories.Category.Instance.Cats where -- The (large) category of (small) categories. -- Even though Agda can figure out the levels, it is worth making them explicit, -- to see the large level jumps involved. open import Level open import Categories.Category using (Category) open import Categories.Functor using (Functor; id; _∘F_) open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism; associator; unitorˡ; unitorʳ; unitor²; isEquivalence; _ⓘₕ_; sym) private variable o ℓ e : Level C D E : Category o ℓ e F G H I : Functor C D Cats : ∀ o ℓ e → Category (suc (o ⊔ ℓ ⊔ e)) (o ⊔ ℓ ⊔ e) (o ⊔ ℓ ⊔ e) Cats o ℓ e = record { Obj = Category o ℓ e ; _⇒_ = Functor ; _≈_ = NaturalIsomorphism ; id = id ; _∘_ = _∘F_ ; assoc = λ {_ _ _ _ F G H} → associator F G H ; sym-assoc = λ {_ _ _ _ F G H} → sym (associator F G H) ; identityˡ = unitorˡ ; identityʳ = unitorʳ ; identity² = unitor² ; equiv = isEquivalence ; ∘-resp-≈ = _ⓘₕ_ }
{ "alphanum_fraction": 0.6368663594, "avg_line_length": 31.9117647059, "ext": "agda", "hexsha": "77b2ab8bf5fab1ad919cc61380cef34ccd077dfb", "lang": "Agda", "max_forks_count": 64, "max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z", "max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Code-distancing/agda-categories", "max_forks_repo_path": "src/Categories/Category/Instance/Cats.agda", "max_issues_count": 236, "max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Code-distancing/agda-categories", "max_issues_repo_path": "src/Categories/Category/Instance/Cats.agda", "max_line_length": 93, "max_stars_count": 279, "max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Trebor-Huang/agda-categories", "max_stars_repo_path": "src/Categories/Category/Instance/Cats.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-22T00:40:14.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-01T14:36:40.000Z", "num_tokens": 380, "size": 1085 }
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-} module Cubical.HITs.InfNat where open import Cubical.HITs.InfNat.Base public open import Cubical.HITs.InfNat.Properties public
{ "alphanum_fraction": 0.7664974619, "avg_line_length": 28.1428571429, "ext": "agda", "hexsha": "3351f76da6569b74f5da2fc950889aa2d7ffb0c6", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z", "max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "dan-iel-lee/cubical", "max_forks_repo_path": "Cubical/HITs/InfNat.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "dan-iel-lee/cubical", "max_issues_repo_path": "Cubical/HITs/InfNat.agda", "max_line_length": 67, "max_stars_count": null, "max_stars_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "dan-iel-lee/cubical", "max_stars_repo_path": "Cubical/HITs/InfNat.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 53, "size": 197 }
module LFRef.Readme where open import LFRef.Syntax open import LFRef.Welltyped open import LFRef.Eval open import LFRef.Properties.Soundness open import LFRef.Properties.Confluence
{ "alphanum_fraction": 0.8516483516, "avg_line_length": 22.75, "ext": "agda", "hexsha": "126095c5c9d0030aad6d912966b67433e7dc48fa", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "ef2e347a4470e55083c83b743efbc2902ef1ad22", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "ElessarWebb/implicits.agda", "max_forks_repo_path": "src/LFRef/Readme.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "ef2e347a4470e55083c83b743efbc2902ef1ad22", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "ElessarWebb/implicits.agda", "max_issues_repo_path": "src/LFRef/Readme.agda", "max_line_length": 39, "max_stars_count": 4, "max_stars_repo_head_hexsha": "ef2e347a4470e55083c83b743efbc2902ef1ad22", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "ajrouvoet/implicits.agda", "max_stars_repo_path": "src/LFRef/Readme.agda", "max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z", "max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z", "num_tokens": 44, "size": 182 }
open import Prelude open import dynamics-core module lemmas-consistency where -- type consistency is symmetric ~sym : {t1 t2 : htyp} → t1 ~ t2 → t2 ~ t1 ~sym TCRefl = TCRefl ~sym TCHole1 = TCHole2 ~sym TCHole2 = TCHole1 ~sym (TCArr p1 p2) = TCArr (~sym p1) (~sym p2) ~sym (TCSum p1 p2) = TCSum (~sym p1) (~sym p2) ~sym (TCProd p1 p2) = TCProd (~sym p1) (~sym p2) -- type consistency isn't transitive not-trans : ((t1 t2 t3 : htyp) → t1 ~ t2 → t2 ~ t3 → t1 ~ t3) → ⊥ not-trans t with t (num ==> num) ⦇-⦈ num TCHole1 TCHole2 ... | () -- every pair of types is either consistent or not consistent ~dec : (t1 t2 : htyp) → ((t1 ~ t2) + (t1 ~̸ t2)) -- this takes care of all hole cases, so we don't consider them below ~dec _ ⦇-⦈ = Inl TCHole1 ~dec ⦇-⦈ _ = Inl TCHole2 ~dec num num = Inl TCRefl ~dec num (t2 ==> t3) = Inr (λ ()) ~dec num (t2 ⊕ t3) = Inr (λ ()) ~dec (t1 ==> t3) num = Inr (λ ()) ~dec (t1 ==> t3) (t2 ==> t4) with ~dec t1 t2 | ~dec t3 t4 ... | Inl x | Inl x₁ = Inl (TCArr x x₁) ... | Inl x | Inr x₁ = Inr λ{ TCRefl → x₁ TCRefl ; (TCArr x₂ x₃) → x₁ x₃} ... | Inr x | w = Inr λ{ TCRefl → x TCRefl ; (TCArr x₁ x₂) → x x₁} ~dec (t1 ==> t3) (t2 ⊕ t4) = Inr (λ ()) ~dec (t1 ⊕ t3) num = Inr (λ ()) ~dec (t1 ⊕ t3) (t2 ==> t4) = Inr (λ ()) ~dec (t1 ⊕ t3) (t2 ⊕ t4) with ~dec t1 t2 | ~dec t3 t4 ... | Inl x | Inl x₁ = Inl (TCSum x x₁) ... | Inl x | Inr x₁ = Inr λ{ TCRefl → x₁ TCRefl ; (TCSum x₂ x₃) → x₁ x₃} ... | Inr x | w = Inr λ{ TCRefl → x TCRefl ; (TCSum x₁ x₂) → x x₁} ~dec num (t2 ⊠ t4) = Inr (λ ()) ~dec (t1 ==> t3) (t2 ⊠ t4) = Inr (λ ()) ~dec (t1 ⊕ t3) (t2 ⊠ t4) = Inr (λ ()) ~dec (t1 ⊠ t3) num = Inr (λ ()) ~dec (t1 ⊠ t3) (t2 ==> t4) = Inr (λ ()) ~dec (t1 ⊠ t3) (t2 ⊕ t4) = Inr (λ ()) ~dec (t1 ⊠ t3) (t2 ⊠ t4) with ~dec t1 t2 | ~dec t3 t4 ... | Inl x | Inl x₁ = Inl (TCProd x x₁) ... | Inl x | Inr x₁ = Inr λ{ TCRefl → x₁ TCRefl ; (TCProd x₂ x₃) → x₁ x₃} ... | Inr x | w = Inr λ{ TCRefl → x TCRefl ; (TCProd x₁ x₂) → x x₁} -- if arrows are consistent, their components are consistent ~arr : ∀{τ1 τ2 τ3 τ4} → (τ1 ==> τ2) ~ (τ3 ==> τ4) → (τ1 ~ τ3) × (τ2 ~ τ4) ~arr TCRefl = TCRefl , TCRefl ~arr (TCArr con con₁) = con , con₁ -- if sums are consistent, their components are consistent ~sum : ∀{τ1 τ2 τ3 τ4} → (τ1 ⊕ τ2) ~ (τ3 ⊕ τ4) → (τ1 ~ τ3) × (τ2 ~ τ4) ~sum TCRefl = TCRefl , TCRefl ~sum (TCSum con con₁) = con , con₁ -- if products are consistent, their components are consistent ~prod : ∀{τ1 τ2 τ3 τ4} → (τ1 ⊠ τ2) ~ (τ3 ⊠ τ4) → (τ1 ~ τ3) × (τ2 ~ τ4) ~prod TCRefl = TCRefl , TCRefl ~prod (TCProd con con₁) = con , con₁
{ "alphanum_fraction": 0.5192943771, "avg_line_length": 37.2739726027, "ext": "agda", "hexsha": "1c6b9cd31933ad90cfa35ba7259e104213e20d1c", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "hazelgrove/hazelnut-agda", "max_forks_repo_path": "lemmas-consistency.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "hazelgrove/hazelnut-agda", "max_issues_repo_path": "lemmas-consistency.agda", "max_line_length": 76, "max_stars_count": null, "max_stars_repo_head_hexsha": "a3640d7b0f76cdac193afd382694197729ed6d57", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "hazelgrove/hazelnut-agda", "max_stars_repo_path": "lemmas-consistency.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 1299, "size": 2721 }
module Operator.Equals {ℓ ℓₑ} where open import Data.Boolean open import Logic open import Structure.Setoid open import Type.Properties.Decidable open import Type DecidableEquiv : (T : Type{ℓ}) ⦃ equiv : Equiv{ℓₑ}(T) ⦄ → Stmt DecidableEquiv(T) = Decidable(2)(_≡_) _==_ : ∀{T : Type{ℓ}} ⦃ equiv : Equiv{ℓₑ}(T) ⦄ ⦃ _ : DecidableEquiv(T) ⦄ → (T → T → Bool) _==_ = decide(2)(_≡_)
{ "alphanum_fraction": 0.6701846966, "avg_line_length": 27.0714285714, "ext": "agda", "hexsha": "8baa6a469ff8676ceeeadf0525ebca60e405d793", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Lolirofle/stuff-in-agda", "max_forks_repo_path": "Operator/Equals.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Lolirofle/stuff-in-agda", "max_issues_repo_path": "Operator/Equals.agda", "max_line_length": 89, "max_stars_count": 6, "max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Lolirofle/stuff-in-agda", "max_stars_repo_path": "Operator/Equals.agda", "max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z", "num_tokens": 153, "size": 379 }
module Issue175 where data List (A : Set) : Set where [] : List A _∷_ : A → List A → List A {-# BUILTIN LIST List #-} {-# BUILTIN NIL [] #-} {-# BUILTIN CONS _∷_ #-} data _≡_ {A : Set} (x : A) : A → Set where refl : x ≡ x postulate Char : Set String : Set {-# BUILTIN CHAR Char #-} {-# BUILTIN STRING String #-} primitive primStringToList : String → List Char lemma : primStringToList "0" ≡ ('0' ∷ []) lemma = refl
{ "alphanum_fraction": 0.5688487585, "avg_line_length": 17.72, "ext": "agda", "hexsha": "118bae1011168434f4ec61f010953cd45bd7f90d", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z", "max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "masondesu/agda", "max_forks_repo_path": "test/succeed/Issue175.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "masondesu/agda", "max_issues_repo_path": "test/succeed/Issue175.agda", "max_line_length": 47, "max_stars_count": 3, "max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "redfish64/autonomic-agda", "max_stars_repo_path": "test/Succeed/Issue175.agda", "max_stars_repo_stars_event_max_datetime": "2015-12-07T20:14:00.000Z", "max_stars_repo_stars_event_min_datetime": "2015-03-28T14:51:03.000Z", "num_tokens": 148, "size": 443 }
import Issue2447.Operator-error
{ "alphanum_fraction": 0.875, "avg_line_length": 16, "ext": "agda", "hexsha": "b2f4865b29c3318c241b4af1c3da1d8c063a4467", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/interaction/Issue2447d.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/interaction/Issue2447d.agda", "max_line_length": 31, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/interaction/Issue2447d.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 7, "size": 32 }
{-# OPTIONS --rewriting --prop --confluence-check #-} open import Agda.Primitive open import Agda.Builtin.Bool open import Agda.Builtin.Nat open import Agda.Builtin.List open import Agda.Builtin.Equality open import Agda.Builtin.Equality.Rewrite open import Agda.Builtin.Sigma open import Agda.Builtin.Unit open import Data.Vec.Base open import Data.Bool open import Data.Sum -- sigma type in Prop used to handle telescopes. record Tel {a b} (A : Prop a) (B : A → Prop b) : Prop (a ⊔ b) where constructor _,_ field fstC : A sndC : B fstC open Tel public infixr 4 _,_ record ΣCov {a b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where constructor _,_ field fstCov : A sndCov : B fstCov open ΣCov public record prod {a b} (A : Set a) (B : Set b) : Set (a ⊔ b) where constructor _,_ field fstprod : A sndprod : B open prod public variable ℓ ℓ₁ ℓ₂ ℓ₃ ℓ₄ : Level -- a bit of boilerplate to deal with Prop data ⊥ : Prop where record ⊤P : Prop ℓ where constructor ttP record Box (A : Prop ℓ) : Set ℓ where constructor box field unbox : A open Box public _×_ : ∀ (A : Prop ℓ) (B : Prop ℓ₁) → Prop (ℓ ⊔ ℓ₁) A × B = Tel A (λ _ → B) -- we need this for cumulativity record i (A : Prop ℓ) : Prop (ℓ ⊔ ℓ₁) where constructor inj field uninj : A open i public record iS (A : Set ℓ) : Set (ℓ ⊔ ℓ₁) where constructor inj field uninj : A open iS public {- Axiomatisation of Id, Id-refl, transport (for proposition), cast Note that Id-refl, transport are axioms in Prop, so we don't need to give them a computation content. Also transport-refl is useless for transport on Prop -} postulate Id : (A : Set ℓ) → A → A → Prop ℓ postulate cast : (A B : Set ℓ) (e : Id (Set ℓ) A B) → A → B postulate Id-refl : {A : Set ℓ} (x : A) → Id A x x postulate cast-refl : {A : Set ℓ} (e : Id _ A A) (a : A) → Id A (cast A A e a) a postulate transport : {A : Set ℓ} (P : A → Prop ℓ₁) (x : A) (t : P x) (y : A) (e : Id A x y) → P y -- cast-refl' : {A : Set ℓ} (e : Id (Set ℓ) A A) (a : A) → Id A (cast A A e a) a -- cast-refl' {A = A} e a = transport (λ z → Id A z a) {!!} (Id-refl a) {!!} {!!} -- direct derived functions ap : {A : Set ℓ} {B : Set ℓ₁} {x y : A} (f : A → B) (e : Id A x y) → Id B (f x) (f y) ap {ℓ} {ℓ₁} {A} {B} {x} {y} f e = transport (λ z → Id B (f x) (f z)) x (Id-refl _) y e transport-Id : {A : Set ℓ} (P : A → Set ℓ₁) (x : A) (t : P x) (y : A) (e : Id A x y) → P y transport-Id P x t y e = cast (P x) (P y) (ap P e) t transport-refl : {A : Set ℓ} (P : A → Set ℓ₁) (x : A) (t : P x) (e : Id A x x) → Id _ (transport-Id P x t x e) t transport-refl P x t e = cast-refl (ap P e) t inverse : (A : Set ℓ) {x y : A} (p : Id {ℓ} A x y) → Id A y x inverse A {x} {y} p = transport (λ z → Id A z x) x (Id-refl x) y p concatId : (A : Set ℓ) {x y z : A} (p : Id {ℓ} A x y) (q : Id {ℓ} A y z) → Id A x z concatId A {x} {y} {z} p q = transport (λ t → Id A x t) y p z q -- we now state rewrite rules for the identity type postulate Id-Pi : (A : Set ℓ) (B : A → Set ℓ₁) (f g : (a : A) → B a) → Id ((a : A) → B a) f g ≡ ((a : A) → Id (B a) (f a) (g a)) {-# REWRITE Id-Pi #-} -- rewrite rules on Id-refl are not needed because it is in Prop refl-Pi : (A : Set ℓ) (B : A → Set ℓ₁) (f : (a : A) → B a) → box (Id-refl f) ≡ box (λ a → Id-refl (f a)) refl-Pi A B f = refl -- sanity check for funext funext : (A : Set ℓ) (B : A → Set ℓ₁) (f g : (a : A) → B a) → ((a : A) → Id (B a) (f a) (g a)) → Id ((a : A) → B a) f g funext A B f g e = e postulate Id-Sigma : (A : Set ℓ) (B : A → Set ℓ₁) (a a' : A) (b : B a) (b' : B a') → Id (Σ A B) (a , b) (a' , b') ≡ Tel (Id A a a') (λ e → Id (B a') (transport-Id B a b a' e) b') {-# REWRITE Id-Sigma #-} postulate Id-SigmaCov : (A : Set ℓ) (B : A → Set ℓ₁) (a a' : A) (b : B a) (b' : B a') → Id (ΣCov A B) (a , b) (a' , b') ≡ Tel (Id A a a') (λ e → Id (B a) b (transport-Id B a' b' a (inverse A e))) {-# REWRITE Id-SigmaCov #-} postulate Id-prod : (A : Set ℓ) (B : Set ℓ₁) (a a' : A) (b b' : B) → Id (prod A B) (a , b) (a' , b') ≡ (Id A a a') × (Id B b b') {-# REWRITE Id-prod #-} postulate Id-Box : (A : Prop ℓ) (p q : A) → Id (Box A) (box p) (box q) ≡ ⊤P {-# REWRITE Id-Box #-} postulate Id-Unit : (p q : ⊤) → Id ⊤ p q ≡ ⊤P {-# REWRITE Id-Unit #-} postulate Id-list-nil-nil : (A : Set ℓ) → Id (List A) [] [] ≡ ⊤P -- postulate Id-list-nil-cons : (A : Set ℓ) (a' : A) (l' : List A) → -- Id (List A) [] (a' ∷ l') ≡ i ⊥ -- postulate Id-list-cons-nil : (A : Set ℓ) (a : A) (l : List A) → -- Id (List A) (a ∷ l) [] ≡ i ⊥ postulate Id-list-cons-cons : (A : Set ℓ) (a a' : A) (l l' : List A) → Id (List A) (a ∷ l) (a' ∷ l') ≡ Id A a a' × Id (List A) l l' {-# REWRITE Id-list-nil-nil #-} {-# REWRITE Id-list-cons-cons #-} postulate Id-nat-zero-zero : Id Nat 0 0 ≡ ⊤P -- postulate Id-nat-zero-suc : (n : Nat) → -- Id Nat 0 (suc n) ≡ i ⊥ -- postulate Id-nat-suc-zero : (n : Nat) → -- Id Nat (suc n) zero ≡ i ⊥ postulate Id-nat-suc-suc : (n n' : Nat) → Id Nat (suc n) (suc n') ≡ Id Nat n n' {-# REWRITE Id-nat-zero-zero #-} {-# REWRITE Id-nat-suc-suc #-} postulate Id-bool-true-true : Id Bool true true ≡ ⊤P postulate Id-bool-false-false : Id Bool false false ≡ ⊤P {-# REWRITE Id-bool-true-true #-} {-# REWRITE Id-bool-false-false #-} postulate Id-sum-inj₁-inj₁ : (A : Set ℓ) (B : Set ℓ₁) (a a' : A) → Id (A ⊎ B) (inj₁ a) (inj₁ a') ≡ i {ℓ = ℓ} {ℓ₁ = ℓ₁} (Id A a a') postulate Id-sum-inj₂-inj₂ : (A : Set ℓ) (B : Set ℓ₁) (b b' : B) → Id (A ⊎ B) (inj₂ b) (inj₂ b') ≡ i {ℓ = ℓ₁} {ℓ₁ = ℓ} (Id B b b') {-# REWRITE Id-sum-inj₁-inj₁ #-} {-# REWRITE Id-sum-inj₂-inj₂ #-} -- rewrite rules for the identity type on the universe telescope-Sigma : Set (lsuc (ℓ ⊔ ℓ₁)) telescope-Sigma {ℓ} {ℓ₁} = ΣCov (Set ℓ) (λ A → A → Set ℓ₁) postulate Id-Type-Sigma : (A A' : Set ℓ) (B : A → Set ℓ₁) (B' : A' → Set ℓ₁) → Id (Set (ℓ ⊔ ℓ₁)) (Σ A B) (Σ A' B') ≡ Id telescope-Sigma (A , B) (A' , B') {-# REWRITE Id-Type-Sigma #-} telescope-Forall : Set (lsuc (ℓ ⊔ ℓ₁)) telescope-Forall {ℓ} {ℓ₁} = Σ (Set ℓ) (λ A → A → Set ℓ₁) postulate Id-Type-Pi : (A A' : Set ℓ) (B : A → Set ℓ₁) (B' : A' → Set ℓ₁) → Id (Set (ℓ ⊔ ℓ₁)) ((a : A) → B a) ((a' : A') → B' a') ≡ Id telescope-Forall (A , B) (A' , B') {-# REWRITE Id-Type-Pi #-} telescope-Sum : Set (lsuc (ℓ ⊔ ℓ₁)) telescope-Sum {ℓ} {ℓ₁} = Σ (Set ℓ) (λ _ → Set ℓ₁) postulate Id-Type-Sum : (A A' : Set ℓ) (B B' : Set ℓ₁) → Id (Set (ℓ ⊔ ℓ₁)) (A ⊎ B) (A' ⊎ B') ≡ Id telescope-Sum (A , B) (A' , B') {-# REWRITE Id-Type-Sum #-} postulate Id-Type-prod : (A A' : Set ℓ) (B B' : Set ℓ₁) → Id (Set (ℓ ⊔ ℓ₁)) (prod A B) (prod A' B') ≡ Id telescope-Sum (A , B) (A' , B') {-# REWRITE Id-Type-prod #-} telescope-List : Set (lsuc ℓ) telescope-List {ℓ} = Set ℓ postulate Id-Type-List : (A A' : Set ℓ) → Id (Set ℓ) (List A) (List A') ≡ Id telescope-List A A' {-# REWRITE Id-Type-List #-} postulate Id-Type-Unit : Id Set ⊤ ⊤ ≡ ⊤P {-# REWRITE Id-Type-Unit #-} postulate Id-Type-Nat : Id Set Nat Nat ≡ Id Set ⊤ ⊤ {-# REWRITE Id-Type-Nat #-} postulate Id-Type-Bool : Id Set Bool Bool ≡ Id Set ⊤ ⊤ {-# REWRITE Id-Type-Bool #-} telescope-Box : Set (lsuc ℓ) telescope-Box {ℓ} = Prop ℓ postulate Id-Type-Box : (P P' : Prop ℓ) → Id (Set ℓ) (Box P) (Box P') ≡ Id telescope-Box P P' {-# REWRITE Id-Type-Box #-} -- rewrite rules for the identity type on Prop : Prop ext modulo cumul postulate Id-prop : (P Q : Prop ℓ) → Id (Prop ℓ) P Q ≡ i (P → Q) × (Q → P) {-# REWRITE Id-prop #-} postulate Id-set : Id (Set (lsuc ℓ₁)) (Set ℓ₁) (Set ℓ₁) ≡ ⊤P {-# REWRITE Id-set #-} -- non-diagonal cases {- There are n^2 cases, that's a pain, this is not exhaustive for the moment -} postulate Id-set-nat : Id _ (Set ℓ) (iS Nat) ≡ i ⊥ postulate Id-nat-set : Id (Set (lsuc ℓ)) (iS Nat) (Set ℓ) ≡ i ⊥ postulate Id-set-bool : Id _ (Set ℓ) (iS Bool) ≡ i ⊥ postulate Id-bool-set : Id (Set (lsuc ℓ)) (iS Bool) (Set ℓ) ≡ i ⊥ postulate Id-bool-nat : Id _ Bool Nat ≡ i ⊥ postulate Id-nat-bool : Id _ Nat Bool ≡ i ⊥ postulate Id-set-pi : (A : Set ℓ₁) (B : A → Set ℓ₂) → Id (Set (lsuc ℓ ⊔ ℓ₁ ⊔ ℓ₂)) (iS {lsuc ℓ} {lsuc ℓ ⊔ ℓ₁ ⊔ ℓ₂} (Set ℓ)) (iS {ℓ₁ ⊔ ℓ₂} {lsuc ℓ ⊔ ℓ₁ ⊔ ℓ₂} ((a : A) → B a)) ≡ i ⊥ postulate Id-pi-set : (A : Set ℓ₁) (B : A → Set ℓ₂) → Id (Set (lsuc ℓ ⊔ ℓ₁ ⊔ ℓ₂)) (iS {ℓ₁ ⊔ ℓ₂} {lsuc ℓ ⊔ ℓ₁ ⊔ ℓ₂} ((a : A) → B a)) (iS {lsuc ℓ} {lsuc ℓ ⊔ ℓ₁ ⊔ ℓ₂} (Set ℓ)) ≡ i ⊥ postulate Id-set-sigma : (A : Set ℓ₁) (B : A → Set ℓ₂) → Id (Set (lsuc ℓ ⊔ ℓ₁ ⊔ ℓ₂)) (iS {lsuc ℓ} {lsuc ℓ ⊔ ℓ₁ ⊔ ℓ₂} (Set ℓ)) (iS {ℓ₁ ⊔ ℓ₂} {lsuc ℓ ⊔ ℓ₁ ⊔ ℓ₂} (Σ A B)) ≡ i ⊥ postulate Id-sigma-set : (A : Set ℓ₁) (B : A → Set ℓ₂) → Id (Set (lsuc ℓ ⊔ ℓ₁ ⊔ ℓ₂)) (iS {ℓ₁ ⊔ ℓ₂} {lsuc ℓ ⊔ ℓ₁ ⊔ ℓ₂} (Σ A B)) (iS {lsuc ℓ} {lsuc ℓ ⊔ ℓ₁ ⊔ ℓ₂} (Set ℓ)) ≡ i ⊥ {-# REWRITE Id-set-nat Id-nat-set Id-set-bool Id-bool-set Id-bool-nat Id-nat-bool Id-set-pi Id-pi-set Id-set-sigma Id-sigma-set #-} --- Contractibility of singletons and J can be defined contr-sing : (A : Set ℓ) {x y : A} (p : Id {ℓ} A x y) → Id (Σ A (λ y → Box (Id A x y))) (x , box (Id-refl x)) (y , box p) contr-sing A {x} {y} p = p , ttP J : (A : Set ℓ) (x : A) (P : (y : A) → Id A x y → Prop ℓ₁) (t : P x (Id-refl x)) (y : A) (e : Id A x y) → P y e J A x P t y e = transport (λ z → P (fst z) (unbox (snd z))) (x , box (Id-refl x)) t (y , box e) (contr-sing A e) -- tranporting back and forth is the identity -- cast-inv : (A B : Set ℓ) (e : Id _ A B) (a : A) → -- Id A (cast B A (inverse (Set ℓ) {x = A} {y = B} e) (cast A B e a)) a -- cast-inv {ℓ} A B e a = let e-refl = cast-refl (Id-refl A) a in -- let e-refl-cast = cast-refl (Id-refl A) (cast A A (Id-refl A) a) in -- J (Set ℓ) A (λ B e → Id A (cast B A (inverse (Set ℓ) {x = A} {y = B} e) (cast A B e a)) a) -- (concatId A e-refl-cast e-refl) B e postulate cast-set : (A : Set ℓ) (e : _) → cast (Set ℓ) (Set ℓ) e A ≡ A {-# REWRITE cast-set #-} postulate cast-prop : (A : Prop ℓ) (e : _) → cast (Prop ℓ) (Prop ℓ) e A ≡ A {-# REWRITE cast-prop #-} postulate cast-type-family : (A A' : Set ℓ) (f : (a : A) → Set ℓ₁) (e : _) → cast ((a : A) → Set ℓ₁) ((a' : A') → Set ℓ₁) e f ≡ λ (a' : A') → let a = cast A' A (inverse (Set ℓ) {x = A} {y = A'} (fstC e)) a' in f a {-# REWRITE cast-type-family #-} postulate cast-Pi : (A A' : Set ℓ) (B : A → Set ℓ₁) (B' : A' → Set ℓ₁) (f : (a : A) → B a) (e : Id _ ((a : A) → B a) ((a' : A') → B' a')) → cast ((a : A) → B a) ((a' : A') → B' a') e f ≡ λ (a' : A') → let a = cast A' A (inverse (Set ℓ) {x = A} {y = A'} (fstC e)) a' in cast _ _ (sndC e a') (f a) {-# REWRITE cast-Pi #-} postulate cast-Sigma : (A A' : Set ℓ) (B : A → Set ℓ₁) (B' : A' → Set ℓ₁) (x : A) (y : B x) (e : _) → let eA = fstC e in let x' = cast A A' eA x in let eB = sndC e x in cast (Σ A B) (Σ A' B') e (x , y) ≡ (cast A A' eA x , cast (B x) (B' x') eB y) {-# REWRITE cast-Sigma #-} postulate cast-prod : (A A' : Set ℓ) (B B' : Set ℓ₁) (x : A) (y : B) (e : _) → let eA = fstC e in let eB = sndC e in cast (prod A B) (prod A' B') e (x , y) ≡ (cast A A' eA x , cast B B' eB y) {-# REWRITE cast-prod #-} postulate cast-Sum-inj₁ : (A A' : Set ℓ) (B B' : Set ℓ₁) (a : A) (e : _) → let eA = fstC e in let eB = sndC e in cast (A ⊎ B) (A' ⊎ B') e (inj₁ a) ≡ inj₁ (cast A A' eA a) postulate cast-Sum-inj₂ : (A A' : Set ℓ) (B B' : Set ℓ₁) (b : B) (e : _) → let eA = fstC e in let eB = sndC e in cast (A ⊎ B) (A' ⊎ B') e (inj₂ b) ≡ inj₂ (cast B B' eB b) {-# REWRITE cast-Sum-inj₁ #-} {-# REWRITE cast-Sum-inj₂ #-} postulate cast-List-nil : (A A' : Set ℓ) (e : _) → cast (List A) (List A') e [] ≡ [] postulate cast-List-cons : (A A' : Set ℓ) (e : _) (a : A) (l : List A) → cast (List A) (List A') e (a ∷ l) ≡ cast A A' e a ∷ cast _ _ e l {-# REWRITE cast-List-nil #-} {-# REWRITE cast-List-cons #-} postulate cast-Nat : (e : _) (n : Nat) → cast Nat Nat e n ≡ n {-# REWRITE cast-Nat #-} postulate cast-Bool : (e : _) (b : Bool) → cast Bool Bool e b ≡ b {-# REWRITE cast-Bool #-} postulate cast-Unit : (e : _) (t : ⊤) → cast ⊤ ⊤ e t ≡ t {-# REWRITE cast-Unit #-} postulate cast-Box : (A A' : Prop ℓ) (a : A) (f : _) (g : _) → cast (Box A) (Box A') (f , g) (box a) ≡ box (uninj f a) {-# REWRITE cast-Box #-} -- sanity check on closed terms foo : transport-Id (λ (T : Σ Set (λ A → Σ A (λ _ → A → Set))) → ((snd (snd T)) (fst (snd T)))) (Nat , (0 , λ _ → Nat)) 3 (Nat , (0 , λ _ → Nat)) (Id-refl {A = Σ Set (λ A → Σ A (λ _ → A → Set))} (Nat , (0 , λ _ → Nat))) ≡ 3 foo = refl test-J-refl-on-closed-term : (X : Set ℓ) (x : X) → transport-Id (λ z → Σ ⊤ (λ z → ⊤)) x (tt , tt) x (Id-refl x) ≡ (tt , tt) test-J-refl-on-closed-term X x = refl -- Quotient types {- Note that r s and t are not used in the definitions, they are just here to make sure the theory stays consistent, because postulating the quotient, we can derive them. In particular, with R = λ - - → ⊥, we would get a direct inconsistency using Id-refl -} record quotient-data ℓ : Set (lsuc ℓ) where constructor q-data field carrier : Set ℓ rel : carrier → carrier → Prop ℓ rel-refl : (x : carrier) → rel x x rel-sym : (x y : carrier) → rel x y → rel y x rel-trans : (x y z : carrier) → rel x y → rel y z → rel x z open quotient-data public postulate Quotient : (Q : quotient-data ℓ) → Set ℓ postulate pi : {Q : quotient-data ℓ} → carrier Q → Quotient Q telescope-Quotient : Set (lsuc ℓ) telescope-Quotient {ℓ} = Σ (Set ℓ) (λ A → A → A → Prop ℓ) postulate Id-Quotient : (Q : quotient-data ℓ) (a a' : carrier Q) → Id (Quotient Q) (pi a) (pi a') ≡ rel Q a a' {-# REWRITE Id-Quotient #-} postulate Quotient-elim : (Q : quotient-data ℓ) (P : Quotient Q → Set ℓ₁) (p : (x : carrier Q) → P (pi x)) (e : (x y : carrier Q) → (r : rel Q x y) → Id _ (transport-Id P (pi x) (p x) (pi y) r) (p y)) (w : Quotient Q) → P w postulate Quotient-elim-red : (Q : quotient-data ℓ) (P : Quotient Q → Set ℓ₁) (p : (x : carrier Q) → P (pi x)) (e : (x y : carrier Q) → (r : rel Q x y) → Id _ (transport-Id P (pi x) (p x) (pi y) r) (p y)) (a : carrier Q) → Quotient-elim Q P p e (pi a) ≡ p a {-# REWRITE Quotient-elim-red #-} postulate Quotient-elim-prop : (Q : quotient-data ℓ) (P : Quotient Q → Prop ℓ₁) (p : (x : carrier Q) → P (pi x)) (w : Quotient Q) → P w postulate Id-Type-Quotient : (Q Q' : quotient-data ℓ) → Id (Set ℓ) (Quotient Q) (Quotient Q') ≡ Id telescope-Quotient (carrier Q , rel Q) (carrier Q' , rel Q') {-# REWRITE Id-Type-Quotient #-} postulate cast-Quotient : (Q Q' : quotient-data ℓ) (a : carrier Q) (e : _) → cast (Quotient Q) (Quotient Q') e (pi a) ≡ pi (cast (carrier Q) (carrier Q') (fstC e) a) {-# REWRITE cast-Quotient #-} -- double induction principle Quotient-elim2-aux : (Q : quotient-data ℓ) (P : Quotient Q → Quotient Q → Set ℓ₁) (p : (x y : carrier Q) → P (pi x) (pi y)) (e : (x x' y y' : carrier Q) → (Q-rel1 : rel Q x x') → (Q-rel2 : rel Q y y') → Id _ (transport-Id (P (pi x')) (pi y) (transport-Id (λ x → P x (pi y)) (pi x) (p x y) (pi x') Q-rel1) (pi y') Q-rel2) (p x' y')) (x : carrier Q) (w : Quotient Q) → P w (pi x) Quotient-elim2-aux Q P p e x = Quotient-elim Q (λ w → P w (pi x)) (λ y → p y x) (λ y y' r → let e-cst = e y y' x x r (rel-refl Q x) in transport (λ e → Id (P (pi y') (pi x)) (e (cast (P (pi y) (pi x)) (P (pi y') (pi x)) (ap (λ y → P y (pi x)) r) (p y x))) (p y' x)) (cast (P (pi y') (pi x)) (P (pi y') (pi x)) (ap (P (pi y')) (rel-refl Q x))) e-cst (λ w → w) λ a → cast-refl {A = P (pi y') (pi x)} (Id-refl (P (pi y') (pi x))) a ) Quotient-elim2 : (Q : quotient-data ℓ) (P : Quotient Q → Quotient Q → Set ℓ₁) (p : (x y : carrier Q) → P (pi x) (pi y)) (e : (x x' y y' : carrier Q) → (Q-rel1 : rel Q x x') → (Q-rel2 : rel Q y y') → Id _ (transport-Id (P (pi x')) (pi y) (transport-Id (λ x → P x (pi y)) (pi x) (p x y) (pi x') Q-rel1) (pi y') Q-rel2) (p x' y')) (w w' : Quotient Q) → P w w' Quotient-elim2 Q P p e w = Quotient-elim Q (P w) (λ x → Quotient-elim2-aux Q P p e x w) (λ x x' r → Quotient-elim-prop Q (λ w → Id (P w (pi x')) (transport-Id (P w) (pi x) (Quotient-elim2-aux Q P p e x w) (pi x') r) (Quotient-elim2-aux Q P p e x' w)) (λ y → let e-cst = e y y x x' (rel-refl Q y) r in transport (λ e → Id (P (pi y) (pi x')) (cast (P (pi y) (pi x)) (P (pi y) (pi x')) (ap (P (pi y)) r) (e (p y x))) (p y x')) (cast (P (pi y) (pi x)) (P (pi y) (pi x)) (ap (P (pi y)) (rel-refl Q x))) e-cst (λ w → w) λ a → cast-refl {A = P (pi y) (pi x)} (Id-refl (P (pi y) (pi x))) a ) w) {- -- Sanity Check: transport-refl on quotient type transport-refl-Quotient : (X : Set ℓ) (carrier Q : X -> Set ℓ₁) (R : (x : X) → carrier Q x → carrier Q x → Prop ℓ₁) (r : (z : X) (x : carrier Q z) → R z x x) (s : (z : X) (x y : carrier Q z) → R z x y → R z y x) (t : (zz : X) (x y z : carrier Q zz) → R zz x y → R zz y z → R zz x z) (x : X) (q : Quotient (carrier Q x) (R x) (r x) (s x) (t x)) (e : Id X x x) → Id _ (transport-Id (λ x → Quotient (carrier Q x) (R x) (r x) (s x) (t x)) x q x e) q transport-refl-Quotient X carrier Q R r s t x q e = Quotient-elim-prop (carrier Q x) (R x) (r x) (s x) (t x) ((λ a → Id _ (transport-Id (λ (x : X) → Quotient (carrier Q x) (R x) (r x) (s x) (t x)) x a x e) a)) (λ a → transport (λ a' → R x a' a) a (r x a) (cast (carrier Q x) (carrier Q x) _ a) (inverse (carrier Q x) (transport-refl carrier Q x a e))) q -} -- Now for Path telescope-Path : Set (lsuc ℓ) telescope-Path {ℓ} = Σ (Set ℓ) (λ A → prod A A) postulate Id-Path : (A : Set ℓ) (x : A) (y : A) (e e' : _)→ Id (x ≡ y) e e' ≡ ⊤P {-# REWRITE Id-Path #-} postulate Id-Type-Path : (A A' : Set ℓ) (x y : A) (x' y' : A') → Id (Set ℓ) (x ≡ y) (x' ≡ y') ≡ Id telescope-Path (A , (x , y)) (A' , (x' , y' )) {-# REWRITE Id-Type-Path #-} -- not enough to get canonicity -- postulate cast-Path : (A A' : Set ℓ) (x : A) (x' : A') (e : _) → -- cast (x ≡ x) (x' ≡ x') e refl ≡ refl -- {-# REWRITE cast-Path #-} transport-Path : {A : Set ℓ} (x : A) (P : (y : A) → Set ℓ₁) (t : P x) (y : A) (e : x ≡ y) → P y transport-Path P x t y refl = t transport-Path-refl : {A : Set ℓ} (P : A → Prop ℓ₁) (x : A) (t : P x) (y : A) (e : x ≡ y) → P y transport-Path-refl P x t .x refl = t path-to-Id : {A : Set ℓ} {x y : A} → x ≡ y → Id A x y path-to-Id {ℓ} {A} {x} {y} = transport-Path-refl (Id A x) x (Id-refl x) y -- we treat cast X (a ≡ b) e x as a new constructor of equality postulate IdPath : {A : Set ℓ} {x y : A} → Id A x y → x ≡ y postulate transport-Path-cast-refl : {A B : Set ℓ} (a : A) (b b' : B) (e : Id (Set ℓ) (a ≡ a) (b ≡ b')) → cast (a ≡ a) (b ≡ b') e refl ≡ IdPath ( let X = fstC (sndC e) in let Y = sndC (sndC e) in concatId B (inverse B X) Y) {-# REWRITE transport-Path-cast-refl #-} postulate transport-Path-IdPath : {A : Set ℓ} (x : A) (P : (y : A) → Set ℓ₁) (t : P x) (y : A) (e : Id A x y) → transport-Path x P t y (IdPath e) ≡ transport-Id P x t y e {-# REWRITE transport-Path-IdPath #-} postulate transport-Path-cast-IdPath : {A B : Set ℓ} (a a' : A) (b b' : B) (ea : Id A a a') (e : Id (Set ℓ) (a ≡ a') (b ≡ b')) → cast (a ≡ a') (b ≡ b') e (IdPath ea) ≡ IdPath (concatId B (inverse B (fstC (sndC e))) (concatId B (ap (cast A B (fstC e)) ea) (sndC (sndC e)))) {-# REWRITE transport-Path-cast-IdPath #-} transport-refl-Path : {A : Set ℓ} (P : A → Set ℓ₁) (x : A) (t : P x) → transport-Path x P t x refl ≡ t transport-refl-Path P x t = refl funext-Path : (A : Set ℓ) (B : A → Set ℓ₁) (f g : (a : A) → B a) → ((a : A) → f a ≡ g a) → f ≡ g funext-Path A B f g e = IdPath (λ a → path-to-Id (e a)) etaBool : (a : Bool) → a ≡ (if a then true else false) etaBool true = refl etaBool false = refl eq_fun : (λ (b : Bool) → b) ≡ (λ (b : Bool) → if b then true else false) eq_fun = funext-Path Bool (λ - → Bool) _ _ λ a → etaBool a -- standard boolean using equality std-bool : Bool std-bool = transport-Path (λ (b : Bool) → b) (λ f → Bool) true (λ (b : Bool) → if b then true else false) eq_fun sanity-check : std-bool ≡ true sanity-check = refl
{ "alphanum_fraction": 0.4591687462, "avg_line_length": 35.9783281734, "ext": "agda", "hexsha": "c54027ed98195706bee262dcca64d930393d7ba5", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z", "max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z", "max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "CoqHott/logrel-mltt", "max_forks_repo_path": "setoid_rr.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "CoqHott/logrel-mltt", "max_issues_repo_path": "setoid_rr.agda", "max_line_length": 202, "max_stars_count": 2, "max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "CoqHott/logrel-mltt", "max_stars_repo_path": "setoid_rr.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z", "max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z", "num_tokens": 8927, "size": 23242 }
------------------------------------------------------------------------ -- A parser for PBM images; illustrates "essential" use of bind ------------------------------------------------------------------------ -- Note that I am using the simple "Plain PBM" format, and I try to -- adhere to the following statement from the pbm man page: -- -- "Programs that read this format should be as lenient as possible, -- accepting anything that looks remotely like a bitmap." -- I got the idea to write this particular parser from "The Power of -- Pi" by Oury and Swierstra. module StructurallyRecursiveDescentParsing.PBM where import Data.Vec as Vec import Data.List as List open import Codata.Musical.Notation open import Data.Bool open import Data.Char using (_==_) import Data.Char.Properties as Char import Data.String as String open import Data.Unit open import Function open import Relation.Binary.PropositionalEquality open import StructurallyRecursiveDescentParsing.Grammar open import StructurallyRecursiveDescentParsing.Lib open import StructurallyRecursiveDescentParsing.DepthFirst open Token Char.decSetoid open import TotalParserCombinators.Examples.PBM using (module PBM) open PBM mutual comment : Parser EmptyNT _ _ _ comment = tt <$ tok '#' <⊛ sat' (not ∘ _==_ '\n') ⋆ <⊛ tok '\n' colour = white <$ tok '0' ∣ black <$ tok '1' pbm = w∣c ⋆ ⊛> theString (String.toVec "P1") ⊛> w∣c ⋆ ⊛> number !>>= λ cols → ♯ -- _>>=_ works just as well. (w∣c + ⊛> number >>= λ rows → -- _!>>=_ works just as well. w∣c ⊛> (toPBM <$> exactly rows (exactly cols (w∣c ⋆ ⊛> colour))) <⊛ any ⋆) where w∣c = whitespace ∣ comment module Example where open Vec image = toPBM ((white ∷ black ∷ white ∷ []) ∷ (black ∷ white ∷ black ∷ []) ∷ (white ∷ black ∷ white ∷ []) ∷ []) ex : parseComplete (⟦ pbm ⟧ emptyGrammar) (String.toList (show image)) ≡ List.[_] image ex = refl
{ "alphanum_fraction": 0.6010794897, "avg_line_length": 29.5362318841, "ext": "agda", "hexsha": "1a47a279c5eb69faf254d93ce90e97df735b2f9b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "nad/parser-combinators", "max_forks_repo_path": "StructurallyRecursiveDescentParsing/PBM.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "nad/parser-combinators", "max_issues_repo_path": "StructurallyRecursiveDescentParsing/PBM.agda", "max_line_length": 72, "max_stars_count": 1, "max_stars_repo_head_hexsha": "76774f54f466cfe943debf2da731074fe0c33644", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "nad/parser-combinators", "max_stars_repo_path": "StructurallyRecursiveDescentParsing/PBM.agda", "max_stars_repo_stars_event_max_datetime": "2020-07-03T08:56:13.000Z", "max_stars_repo_stars_event_min_datetime": "2020-07-03T08:56:13.000Z", "num_tokens": 554, "size": 2038 }
{-# OPTIONS --safe --warning=error --without-K #-} open import Setoids.Setoids open import Rings.Definition open import Rings.IntegralDomains.Definition open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) module Rings.PrincipalIdealDomains.Definition {a b : _} {A : Set a} {S : Setoid {a} {b} A} {_+_ _*_ : A → A → A} {R : Ring S _+_ _*_} (intDom : IntegralDomain R) where open import Rings.Ideals.Principal.Definition R open import Rings.Ideals.Definition R PrincipalIdealDomain : {c : _} → Set (a ⊔ b ⊔ lsuc c) PrincipalIdealDomain {c} = {pred : A → Set c} → (ideal : Ideal pred) → PrincipalIdeal ideal
{ "alphanum_fraction": 0.7050243112, "avg_line_length": 38.5625, "ext": "agda", "hexsha": "7f78703985c4577e54511912f1ca24ad2dc8d96f", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Rings/PrincipalIdealDomains/Definition.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Rings/PrincipalIdealDomains/Definition.agda", "max_line_length": 167, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Rings/PrincipalIdealDomains/Definition.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 191, "size": 617 }
{-# OPTIONS --safe --warning=error --without-K #-} open import LogicalFormulae open import Lists.Definition open import Lists.Concat module Lists.Reversal.Reversal where rev : {a : _} → {A : Set a} → List A → List A rev [] = [] rev (x :: l) = (rev l) ++ [ x ] revIsHom : {a : _} → {A : Set a} → (l1 : List A) → (l2 : List A) → (rev (l1 ++ l2) ≡ (rev l2) ++ (rev l1)) revIsHom l1 [] = applyEquality rev (appendEmptyList l1) revIsHom [] (x :: l2) with (rev l2 ++ [ x ]) ... | r = equalityCommutative (appendEmptyList r) revIsHom (w :: l1) (x :: l2) = transitivity t (equalityCommutative s) where s : ((rev l2 ++ [ x ]) ++ (rev l1 ++ [ w ])) ≡ (((rev l2 ++ [ x ]) ++ rev l1) ++ [ w ]) s = equalityCommutative (concatAssoc (rev l2 ++ (x :: [])) (rev l1) ([ w ])) t' : rev (l1 ++ (x :: l2)) ≡ rev (x :: l2) ++ rev l1 t' = revIsHom l1 (x :: l2) t : (rev (l1 ++ (x :: l2)) ++ [ w ]) ≡ ((rev l2 ++ [ x ]) ++ rev l1) ++ [ w ] t = applyEquality (λ r → r ++ [ w ]) {rev (l1 ++ (x :: l2))} {((rev l2) ++ [ x ]) ++ rev l1} (transitivity t' (applyEquality (λ r → r ++ rev l1) {rev l2 ++ (x :: [])} {rev l2 ++ (x :: [])} refl)) revRevIsId : {a : _} → {A : Set a} → (l : List A) → (rev (rev l) ≡ l) revRevIsId [] = refl revRevIsId (x :: l) = t where s : rev (rev l ++ [ x ] ) ≡ [ x ] ++ rev (rev l) s = revIsHom (rev l) [ x ] t : rev (rev l ++ [ x ] ) ≡ [ x ] ++ l t = identityOfIndiscernablesRight _≡_ s (applyEquality (λ n → [ x ] ++ n) (revRevIsId l))
{ "alphanum_fraction": 0.498655914, "avg_line_length": 43.7647058824, "ext": "agda", "hexsha": "e2fa9d3c2f10c1b1e7023ef280678487c5eb9854", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Lists/Reversal/Reversal.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Lists/Reversal/Reversal.agda", "max_line_length": 199, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Lists/Reversal/Reversal.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 595, "size": 1488 }
{-# OPTIONS --without-K --safe --exact-split #-} module Experiment.Omniscience where open import Level using () renaming (zero to lzero) open import Data.Nat using (ℕ; zero; suc; _≤_; _+_) open import Data.Nat.Properties using (≤-refl; +-identityʳ) open import Data.Product using (Σ; _,_; proj₁; proj₂; ∃; _×_) open import Data.Bool using (Bool; true; false; _∧_; not) open import Data.Bool.Properties using (∧-assoc; ∧-idem) open import Function.Base using (_$_) open import Relation.Binary using (Rel) open import Relation.Binary.PropositionalEquality using (_≡_; refl; subst; sym; _≢_; cong; module ≡-Reasoning) infix 5 _≤ᵇ_ _≤ᵇ_ : Bool → Bool → Bool false ≤ᵇ false = true true ≤ᵇ false = false false ≤ᵇ true = true true ≤ᵇ true = true x≤ᵇtrue≡true : ∀ x → x ≤ᵇ true ≡ true x≤ᵇtrue≡true false = refl x≤ᵇtrue≡true true = refl Decrease : (ℕ → Bool) → Set Decrease α = ∀ i → α (suc i) ≤ᵇ α i ≡ true ℕ∞ : Set ℕ∞ = Σ (ℕ → Bool) Decrease -- less n i ≡ true <=> n > i less : ℕ → ℕ → Bool less zero zero = false less zero (suc n) = false less (suc m) zero = true less (suc m) (suc n) = less m n less-decrease : ∀ n → Decrease (less n) less-decrease zero zero = refl less-decrease zero (suc i) = refl less-decrease (suc n) zero = x≤ᵇtrue≡true (less n 0) less-decrease (suc n) (suc i) = less-decrease n i toℕ∞ : ℕ → ℕ∞ toℕ∞ n = less n , less-decrease n _≈C_ : Rel (ℕ → Bool) lzero α ≈C β = ∀ i → α i ≡ β i _≈_ : Rel ℕ∞ lzero x ≈ y = proj₁ x ≈C proj₁ y _#C_ : Rel (ℕ → Bool) lzero α #C β = ∃ λ i → α i ≢ β i _#_ : Rel ℕ∞ lzero x # y = proj₁ x #C proj₁ y -- retract 𝓇 : (ℕ → Bool) → (ℕ → Bool) 𝓇 α zero = α 0 𝓇 α (suc n) = α (suc n) ∧ 𝓇 α n 𝓇-decrease : ∀ α → Decrease (𝓇 α) 𝓇-decrease α i = lemma (α (suc i)) (𝓇 α i) where lemma : ∀ x y → x ∧ y ≤ᵇ y ≡ true lemma false false = refl lemma false true = refl lemma true false = refl lemma true true = refl 𝓇-idem : ∀ α → 𝓇 (𝓇 α) ≈C 𝓇 α 𝓇-idem α zero = refl 𝓇-idem α (suc i) = begin (α (suc i) ∧ 𝓇 α i) ∧ 𝓇 (𝓇 α) i ≡⟨ cong (λ v → (α (suc i) ∧ 𝓇 α i) ∧ v) $ 𝓇-idem α i ⟩ (α (suc i) ∧ 𝓇 α i) ∧ 𝓇 α i ≡⟨ ∧-assoc (α (suc i)) (𝓇 α i) (𝓇 α i) ⟩ α (suc i) ∧ (𝓇 α i ∧ 𝓇 α i) ≡⟨ cong (λ v → α (suc i) ∧ v) $ ∧-idem (𝓇 α i) ⟩ α (suc i) ∧ 𝓇 α i ∎ where open ≡-Reasoning ⟦_⟧ : ℕ∞ → (ℕ → Bool) ⟦_⟧ = proj₁ private contraposition-Bool : ∀ {x y z} → (x ≡ z → y ≡ z) → y ≡ not z → x ≡ not z contraposition-Bool {false} {false} {true} f e = refl contraposition-Bool {false} {true} {false} f e = (λ ()) $ f refl contraposition-Bool {true} {false} {true} f e = (λ ()) $ f refl contraposition-Bool {true} {true} {false} f e = refl ≤ᵇ-to-fun : ∀ {x y} → x ≤ᵇ y ≡ true → x ≡ true → y ≡ true ≤ᵇ-to-fun {true} {true} _ _ = refl lemma-3-2-lemma : ∀ (x : ℕ∞) m n → ⟦ x ⟧ n ≡ false → ⟦ x ⟧ (m + n) ≡ false lemma-3-2-lemma x@(α , d) zero n αn≡false = αn≡false lemma-3-2-lemma x@(α , d) (suc m) n αn≡false = contraposition-Bool (≤ᵇ-to-fun (d (m + n))) (lemma-3-2-lemma x m n αn≡false) lemma-3-2 : ∀ (x : ℕ∞) n → ⟦ x ⟧ n ≡ false → ∃ λ k → k ≤ n × x ≈ toℕ∞ k lemma-3-2 x@(α , d) zero αn≡false = 0 , (≤-refl , f) where f : ∀ i → α i ≡ less 0 i f zero = αn≡false f (suc i) = subst (λ v → α (suc v) ≡ false) (+-identityʳ i) $ lemma-3-2-lemma x (suc i) 0 αn≡false lemma-3-2 (α , d) (suc n) αn≡false = {! !} -- α i ≡ less 0 i
{ "alphanum_fraction": 0.562592483, "avg_line_length": 29.1293103448, "ext": "agda", "hexsha": "7c815e955cbd70c0a5dd33efa94fe3416c980621", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "rei1024/agda-misc", "max_forks_repo_path": "Experiment/Omniscience.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "rei1024/agda-misc", "max_issues_repo_path": "Experiment/Omniscience.agda", "max_line_length": 78, "max_stars_count": 3, "max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "rei1024/agda-misc", "max_stars_repo_path": "Experiment/Omniscience.agda", "max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z", "max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z", "num_tokens": 1582, "size": 3379 }
{-# OPTIONS --cubical --no-import-sorts --safe #-} module Cubical.Algebra.Monoid.Construct.Unit where open import Cubical.Core.Everything open import Cubical.Foundations.Prelude open import Cubical.Algebra.Monoid open import Cubical.Data.Prod using (_,_) open import Cubical.Data.Unit import Cubical.Algebra.Semigroup.Construct.Unit as ⊤Semigroup open ⊤Semigroup public hiding (⊤-isSemigroup; ⊤-Semigroup) ◯-identityˡ : LeftIdentity tt _◯_ ◯-identityˡ _ = refl ◯-identityʳ : RightIdentity tt _◯_ ◯-identityʳ _ = refl ◯-identity : Identity tt _◯_ ◯-identity = ◯-identityˡ , ◯-identityʳ ⊤-isMonoid : IsMonoid ⊤ _◯_ tt ⊤-isMonoid = record { isSemigroup = ⊤Semigroup.⊤-isSemigroup ; identity = ◯-identity } ⊤-Monoid : Monoid ℓ-zero ⊤-Monoid = record { isMonoid = ⊤-isMonoid }
{ "alphanum_fraction": 0.7303797468, "avg_line_length": 24.6875, "ext": "agda", "hexsha": "364f861418b542be487ab5df0cd7ce93587b3b48", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "bijan2005/univalent-foundations", "max_forks_repo_path": "Cubical/Algebra/Monoid/Construct/Unit.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "bijan2005/univalent-foundations", "max_issues_repo_path": "Cubical/Algebra/Monoid/Construct/Unit.agda", "max_line_length": 61, "max_stars_count": null, "max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "bijan2005/univalent-foundations", "max_stars_repo_path": "Cubical/Algebra/Monoid/Construct/Unit.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 282, "size": 790 }
module Data.List.All.Properties.Extra {a}{A : Set a} where open import Relation.Binary.PropositionalEquality open import Data.Nat open import Data.Fin open import Data.List as List hiding (reverse) open import Data.List.Relation.Unary.Any hiding (tail) open import Data.List.Membership.Propositional open import Data.List.Properties.Extra open import Data.List.At open import Data.List.Relation.Unary.All as All hiding (_[_]=_) open import Data.List.Relation.Unary.All.Properties open import Data.Product open import Function map-map : ∀ {p q r}{P : A → Set p}{Q : A → Set q}{R : A → Set r}{l : List A}(ps : All P l) {f : ∀ {x : A} → P x → Q x}{g : ∀ {x : A} → Q x → R x} → All.map g (All.map f ps) ≡ All.map (g ∘ f) ps map-map [] = refl map-map (px ∷ ps) = cong₂ _∷_ refl (map-map ps) drop-all : ∀ {p}{P : A → Set p}{l : List A} n → All P l → All P (drop n l) drop-all zero px = px drop-all (suc n) [] = [] drop-all (suc n) (px ∷ pxs) = drop-all n pxs split-++ : ∀ {p}{P : A → Set p}(l m : List A) → All P (l ++ m) → All P l × All P m split-++ [] m pxs = [] , pxs split-++ (x ∷ l) m (px ∷ pxs) with split-++ l m pxs ... | lp , rp = px ∷ lp , rp _++-all_ : ∀ {l m p}{P : A → Set p} → All P l → All P m → All P (l ++ m) [] ++-all pm = pm (px ∷ pl) ++-all pm = px ∷ (pl ++-all pm) ∈-all : ∀ {p}{P : A → Set p}{l : List A}{x} → x ∈ l → All P l → P x ∈-all (here refl) (px ∷ q) = px ∈-all (there p) (px ∷ q) = ∈-all p q -- proof matters; update a particular witness of a property _All[_]≔_ : ∀ {p}{P : A → Set p} {xs : List A} {i x} → All P xs → xs [ i ]= x → P x → All P xs _All[_]≔_ [] () _All[_]≔_ {xs = .(_ ∷ _)} {zero} (px ∷ xs) refl px' = px' ∷ xs _All[_]≔_ {xs = .(_ ∷ _)} {suc i} (px ∷ xs) q px' = px ∷ (xs All[ q ]≔ px') -- strong update -- _All[_]≔!_ : ∀ {p}{P : A → Set p} {xs : List A} {x} → -- All P xs → (i : Fin (length xs)) → P x → All P (xs [ i ]≔ x) -- [] All[ () ]≔! y -- (px ∷ xs) All[ zero ]≔! y = y ∷ xs -- (px ∷ xs) All[ suc i ]≔! y = px ∷ xs All[ i ]≔! y _all-∷ʳ_ : ∀ {p}{l : List A} {x} {P : A → Set p} → All P l → P x → All P (l ∷ʳ x) _all-∷ʳ_ [] q = q ∷ [] _all-∷ʳ_ (px ∷ p) q = px ∷ (p all-∷ʳ q) -- All≔'∘map : ∀ {p q}{P : A → Set p}{Q : A → Set q}{xs : List A} {x}(pxs : All P xs)(e : x ∈ xs)(px : P x)(f : ∀ {x} → P x → Q x) → -- (All.map f pxs) All[ e ]≔' (f px) ≡ All.map f (pxs All[ e ]≔' px) -- All≔'∘map [] () -- All≔'∘map (px ∷ pxs) (here refl) qx f = refl -- All≔'∘map (px ∷ pxs) (there e) qx f = cong₂ _∷_ refl (All≔'∘map pxs e qx f) all-∷ʳ∘map : ∀ {p q}{P : A → Set p}{Q : A → Set q}{xs : List A} {x}(pxs : All P xs)(px : P x)(f : ∀ {x} → P x → Q x) → (All.map f pxs) all-∷ʳ (f px) ≡ All.map f (pxs all-∷ʳ px) all-∷ʳ∘map [] px f = refl all-∷ʳ∘map (px₁ ∷ pxs) px f = cong₂ _∷_ refl (all-∷ʳ∘map pxs px f) lookup∘map : ∀ {p q}{P : A → Set p}{Q : A → Set q}{xs : List A} {x}(pxs : All P xs)(e : x ∈ xs)(f : ∀ {x} → P x → Q x) → All.lookup (All.map f pxs) e ≡ f (All.lookup pxs e) lookup∘map [] () lookup∘map (px ∷ pxs) (here refl) f = refl lookup∘map (px ∷ pxs) (there e) f = lookup∘map pxs e f erase : ∀ {p b}{P : A → Set p}{l : List A}{B : Set b} → (∀ {x} → P x → B) → All P l → List B erase f [] = [] erase f (px ∷ xs₁) = f px ∷ erase f xs₁ -- pop₁ : ∀ {x : A}{p xs}{P : A → Set p} → All P (x ∷ xs) → P x × All P xs -- pop₁ st = head st , tail st -- open import Data.List.Properties -- popₙ : ∀ (as : List A){p xs}{P : A → Set p} → All P (as ++ xs) → All P (List.reverse as) × All P xs -- popₙ [] st = [] , st -- popₙ (x ∷ xs) (px ∷ pxs) rewrite unfold-reverse x xs = -- let pys , pzs = popₙ xs pxs in (pys all-∷ʳ px) , pzs -- open import Relation.Binary.Core -- open import Data.List.Relation.Pointwise hiding (Rel) -- module _ {a ℓ}{A : Set a}(_∼_ : Rel A ℓ) where -- pw-map : ∀ {l m p}{P : A → Set p} → (∀ {a b} → a ∼ b → P a → P b) → Pointwise _∼_ l m → All P l → All P m -- pw-map f [] [] = [] -- pw-map f (x∼y ∷ r) (px ∷ xs) = f x∼y px ∷ pw-map f r xs
{ "alphanum_fraction": 0.5106276569, "avg_line_length": 42.0947368421, "ext": "agda", "hexsha": "e99789fe359e11fcdf076fb10b91700d07dff703", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z", "max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_forks_repo_licenses": [ "Apache-2.0" ], "max_forks_repo_name": "metaborg/mj.agda", "max_forks_repo_path": "src/Data/List/All/Properties/Extra.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z", "max_issues_repo_licenses": [ "Apache-2.0" ], "max_issues_repo_name": "metaborg/mj.agda", "max_issues_repo_path": "src/Data/List/All/Properties/Extra.agda", "max_line_length": 132, "max_stars_count": 10, "max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df", "max_stars_repo_licenses": [ "Apache-2.0" ], "max_stars_repo_name": "metaborg/mj.agda", "max_stars_repo_path": "src/Data/List/All/Properties/Extra.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z", "max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z", "num_tokens": 1747, "size": 3999 }
module Examples.OpSem where open import Luau.OpSem using (_⊢_⟶ᴱ_⊣_; _⊢_⟶ᴮ_⊣_; subst) open import Luau.Syntax using (Block; var; nil; local_←_; _∙_; done; return; block_is_end) open import Luau.Heap using (∅) ex1 : ∅ ⊢ (local (var "x") ← nil ∙ return (var "x") ∙ done) ⟶ᴮ (return nil ∙ done) ⊣ ∅ ex1 = subst
{ "alphanum_fraction": 0.6601941748, "avg_line_length": 34.3333333333, "ext": "agda", "hexsha": "c4cfc5e5c79a09558b820e0aaed4af98841b7255", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Tr4shh/Roblox-Luau", "max_forks_repo_path": "prototyping/Examples/OpSem.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Tr4shh/Roblox-Luau", "max_issues_repo_path": "prototyping/Examples/OpSem.agda", "max_line_length": 90, "max_stars_count": null, "max_stars_repo_head_hexsha": "cd18adc20ecb805b8eeb770a9e5ef8e0cd123734", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Tr4shh/Roblox-Luau", "max_stars_repo_path": "prototyping/Examples/OpSem.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 134, "size": 309 }
------------------------------------------------------------------------------ -- Testing Agda internal term: @Con@ ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} -- The following hint uses the internal Agda term @Con@. module AgdaInternalTerms.ConTerm where -- We add 3 to the fixities of the standard library. infixl 9 _+_ infix 7 _≡_ ------------------------------------------------------------------------------ data ℕ : Set where zero : ℕ succ : ℕ → ℕ data _≡_ (n : ℕ) : ℕ → Set where refl : n ≡ n _+_ : ℕ → ℕ → ℕ zero + n = n succ m + n = succ (m + n) +-0x : ∀ n → zero + n ≡ n +-0x n = refl {-# ATP hint +-0x #-} postulate foo : ∀ n → zero + n ≡ n {-# ATP prove foo #-}
{ "alphanum_fraction": 0.4026548673, "avg_line_length": 24.4324324324, "ext": "agda", "hexsha": "efa349e2bb7a8af450d202cb999eea4846740ecc", "lang": "Agda", "max_forks_count": 4, "max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z", "max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z", "max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/apia", "max_forks_repo_path": "issues/Issue16/sharing/AgdaInternalTerms/ConTerm.agda", "max_issues_count": 121, "max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/apia", "max_issues_repo_path": "issues/Issue16/sharing/AgdaInternalTerms/ConTerm.agda", "max_line_length": 78, "max_stars_count": 10, "max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/apia", "max_stars_repo_path": "issues/Issue16/sharing/AgdaInternalTerms/ConTerm.agda", "max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z", "num_tokens": 219, "size": 904 }
open import Prelude open import Data.Maybe using (Maybe; just; nothing) open import RW.Language.RTerm open import RW.Language.RTermUtils using (hole2Abs) open import RW.Language.Instantiation using (RSubst) open import RW.Utils.Error open import RW.Strategy module RW.Strategy.PropEq where pattern pat-≡ = (rdef (quote _≡_)) private open UData ≡-when : RTermName → RTermName → Bool ≡-when pat-≡ pat-≡ = true ≡-when _ _ = false fixTrs : Trs → RTerm ⊥ → RTerm ⊥ fixTrs Symmetry term = rapp (rdef (quote sym)) (term ∷ []) ≡-how : Name → UData → Err StratErr (RTerm ⊥) ≡-how act (u-data g□ σ trs) = i2 (rapp (rdef (quote cong)) ( hole2Abs g□ ∷ foldr fixTrs (makeApp act σ) trs ∷ []) ) ≡-strat : TStrat ≡-strat = record { when = ≡-when ; how = ≡-how } open import RW.RW (≡-strat ∷ []) by*-≡ : by*-tactic by*-≡ = by* (quote trans)
{ "alphanum_fraction": 0.5756951596, "avg_line_length": 23.119047619, "ext": "agda", "hexsha": "c1577dfbd23bdec0351d1d0aa8e08b9ddbd85ce2", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "VictorCMiraldo/agda-rw", "max_forks_repo_path": "RW/Strategy/PropEq.agda", "max_issues_count": 4, "max_issues_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_issues_repo_issues_event_max_datetime": "2015-05-28T14:48:03.000Z", "max_issues_repo_issues_event_min_datetime": "2015-02-06T15:03:33.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "VictorCMiraldo/agda-rw", "max_issues_repo_path": "RW/Strategy/PropEq.agda", "max_line_length": 62, "max_stars_count": 16, "max_stars_repo_head_hexsha": "2856afd12b7dbbcc908482975638d99220f38bf2", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "VictorCMiraldo/agda-rw", "max_stars_repo_path": "RW/Strategy/PropEq.agda", "max_stars_repo_stars_event_max_datetime": "2019-10-24T17:38:20.000Z", "max_stars_repo_stars_event_min_datetime": "2015-02-09T15:43:38.000Z", "num_tokens": 339, "size": 971 }
module Id where id : {A : Set} -> A -> A id x = {!!}
{ "alphanum_fraction": 0.4444444444, "avg_line_length": 10.8, "ext": "agda", "hexsha": "1473515d354edcc0b92a8bd69e585d4de459244b", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "baf979ef78b5ec0f4783240b03f9547490bc5d42", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "carlostome/martin", "max_forks_repo_path": "data/test-files/Id.agda", "max_issues_count": null, "max_issues_repo_head_hexsha": "baf979ef78b5ec0f4783240b03f9547490bc5d42", "max_issues_repo_issues_event_max_datetime": null, "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "carlostome/martin", "max_issues_repo_path": "data/test-files/Id.agda", "max_line_length": 24, "max_stars_count": null, "max_stars_repo_head_hexsha": "baf979ef78b5ec0f4783240b03f9547490bc5d42", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "carlostome/martin", "max_stars_repo_path": "data/test-files/Id.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 21, "size": 54 }
------------------------------------------------------------------------------ -- Proving mirror (mirror t) = t using mutual data types ------------------------------------------------------------------------------ {-# OPTIONS --exact-split #-} {-# OPTIONS --no-sized-types #-} {-# OPTIONS --no-universe-polymorphism #-} {-# OPTIONS --without-K #-} module FOT.FOTC.Program.Mirror.MirrorMutualSL where infixr 5 _∷_ _++_ open import Function open import Relation.Binary.PropositionalEquality open ≡-Reasoning ------------------------------------------------------------------------------ -- The mutual data types data Tree (A : Set) : Set data Forest (A : Set) : Set data Tree A where tree : A → Forest A → Tree A data Forest A where [] : Forest A _∷_ : Tree A → Forest A → Forest A ------------------------------------------------------------------------------ -- Auxiliary functions _++_ : {A : Set} → Forest A → Forest A → Forest A [] ++ ys = ys (a ∷ xs) ++ ys = a ∷ xs ++ ys map : {A B : Set} → (Tree A → Tree B) → Forest A → Forest B map f [] = [] map f (a ∷ ts) = f a ∷ map f ts reverse : {A : Set} → Forest A → Forest A reverse [] = [] reverse (a ∷ ts) = reverse ts ++ a ∷ [] postulate map-++ : {A B : Set}(f : Tree A → Tree B)(xs ys : Forest A) → map f (xs ++ ys) ≡ map f xs ++ map f ys reverse-++ : {A : Set}(xs ys : Forest A) → reverse (xs ++ ys) ≡ reverse ys ++ reverse xs ------------------------------------------------------------------------------ -- The mirror function. {-# TERMINATING #-} mirror : {A : Set} → Tree A → Tree A mirror (tree a ts) = tree a (reverse (map mirror ts)) ------------------------------------------------------------------------------ -- The proof of the property. mirror-involutive : {A : Set} → (t : Tree A) → mirror (mirror t) ≡ t helper : {A : Set} → (ts : Forest A) → reverse (map mirror (reverse (map mirror ts))) ≡ ts mirror-involutive (tree a []) = refl mirror-involutive (tree a (t ∷ ts)) = begin tree a (reverse (map mirror (reverse (map mirror ts) ++ mirror t ∷ []))) ≡⟨ cong (tree a) (helper (t ∷ ts)) ⟩ tree a (t ∷ ts) ∎ helper [] = refl helper (t ∷ ts) = begin reverse (map mirror (reverse (map mirror ts) ++ mirror t ∷ [])) ≡⟨ cong reverse (map-++ mirror (reverse (map mirror ts)) (mirror t ∷ [])) ⟩ reverse (map mirror (reverse (map mirror ts)) ++ (map mirror (mirror t ∷ []))) ≡⟨ subst (λ x → (reverse (map mirror (reverse (map mirror ts)) ++ (map mirror (mirror t ∷ [])))) ≡ x) (reverse-++ (map mirror (reverse (map mirror ts))) (map mirror (mirror t ∷ []))) refl ⟩ reverse (map mirror (mirror t ∷ [])) ++ reverse (map mirror (reverse (map mirror ts))) ≡⟨ refl ⟩ mirror (mirror t) ∷ reverse (map mirror (reverse (map mirror ts))) ≡⟨ cong (flip _∷_ (reverse (map mirror (reverse (map mirror ts))))) (mirror-involutive t) ⟩ t ∷ reverse (map mirror (reverse (map mirror ts))) ≡⟨ cong (_∷_ t) (helper ts) ⟩ t ∷ ts ∎
{ "alphanum_fraction": 0.4525862069, "avg_line_length": 32.8080808081, "ext": "agda", "hexsha": "184359c9471fcd0acb0a4d81629e219a8ac7276b", "lang": "Agda", "max_forks_count": 3, "max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z", "max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z", "max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "asr/fotc", "max_forks_repo_path": "notes/FOT/FOTC/Program/Mirror/MirrorMutualSL.agda", "max_issues_count": 2, "max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z", "max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "asr/fotc", "max_issues_repo_path": "notes/FOT/FOTC/Program/Mirror/MirrorMutualSL.agda", "max_line_length": 78, "max_stars_count": 11, "max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "asr/fotc", "max_stars_repo_path": "notes/FOT/FOTC/Program/Mirror/MirrorMutualSL.agda", "max_stars_repo_stars_event_max_datetime": "2021-09-12T16:09:54.000Z", "max_stars_repo_stars_event_min_datetime": "2015-09-03T20:53:42.000Z", "num_tokens": 869, "size": 3248 }
module Data.Tree.Instance where open import Class.Functor open import Class.Monad open import Class.Monoid open import Class.Show open import Class.Traversable open import Data.List open import Data.List.Instance open import Data.String using (String) open import Data.String.Instance open import Data.Tree.Base instance {-# TERMINATING #-} Tree-Functor : Functor Tree Tree-Functor = record { _<$>_ = helper } where helper : ∀ {A B} -> (A -> B) -> Tree A -> Tree B helper f (Node x x₁) = Node (f x) (map (helper f) x₁) {-# TERMINATING #-} Tree-Show : ∀ {A} {{_ : Show A}} -> Show (Tree A) Tree-Show = record { show = helper show } where helper : ∀ {A} -> (A -> String) -> Tree A -> String helper f (Node x x₁) = "Node (" + f x + ") " + show (map (helper f) x₁) {-# TERMINATING #-} Tree-Traversable : Traversable Tree Tree-Traversable = record { sequence = helper } where helper : {M : Set → Set} {{_ : Monad M}} {A : Set} → Tree (M A) → M (Tree A) helper (Node x y) = do x' <- x y' <- sequence (map helper y) return (Node x' y')
{ "alphanum_fraction": 0.6019590383, "avg_line_length": 29.5526315789, "ext": "agda", "hexsha": "2273adbaccf1c2125defcad5d4cdb0712810e92f", "lang": "Agda", "max_forks_count": 2, "max_forks_repo_forks_event_max_datetime": "2021-10-20T10:46:20.000Z", "max_forks_repo_forks_event_min_datetime": "2019-06-27T23:12:48.000Z", "max_forks_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "WhatisRT/meta-cedille", "max_forks_repo_path": "stdlib-exts/Data/Tree/Instance.agda", "max_issues_count": 10, "max_issues_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_issues_repo_issues_event_max_datetime": "2020-04-25T15:29:17.000Z", "max_issues_repo_issues_event_min_datetime": "2019-06-13T17:44:43.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "WhatisRT/meta-cedille", "max_issues_repo_path": "stdlib-exts/Data/Tree/Instance.agda", "max_line_length": 82, "max_stars_count": 35, "max_stars_repo_head_hexsha": "62fa6f36e4555360d94041113749bbb6d291691c", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "WhatisRT/meta-cedille", "max_stars_repo_path": "stdlib-exts/Data/Tree/Instance.agda", "max_stars_repo_stars_event_max_datetime": "2021-10-12T22:59:10.000Z", "max_stars_repo_stars_event_min_datetime": "2019-06-13T07:44:50.000Z", "num_tokens": 332, "size": 1123 }
-- Getting projection like functions right was a little tricky. -- Here are the cases that didn't work and weren't caught by -- existing test cases. module ProjectionLikeFunctions where record Wrap (A : Set) : Set where constructor [_] field unwrap : A postulate Nat : Set n : Nat Thm : Nat → Set prf : ∀ n → Thm n module M x (p : Thm x) (w : Wrap Nat) where module W = Wrap w module M′ = M n (prf n) ([ n ]) test₁ : Thm M′.W.unwrap test₁ = prf n eq! : ∀ x (S : Thm x) → Wrap Nat → Nat eq! s S [n] = W.unwrap module Local where module W = Wrap [n] test₂ : Thm (eq! n (prf n) [ n ]) test₂ = prf n
{ "alphanum_fraction": 0.6145339652, "avg_line_length": 20.4193548387, "ext": "agda", "hexsha": "d0a41a9ca2e8056c03805efcffb27bbd01939c20", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9", "max_forks_repo_licenses": [ "BSD-3-Clause" ], "max_forks_repo_name": "Agda-zh/agda", "max_forks_repo_path": "test/Succeed/ProjectionLikeFunctions.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "BSD-3-Clause" ], "max_issues_repo_name": "shlevy/agda", "max_issues_repo_path": "test/Succeed/ProjectionLikeFunctions.agda", "max_line_length": 63, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338", "max_stars_repo_licenses": [ "BSD-3-Clause" ], "max_stars_repo_name": "shlevy/agda", "max_stars_repo_path": "test/Succeed/ProjectionLikeFunctions.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 217, "size": 633 }
module IsPropositionalFormula where open import OscarPrelude open import Formula open import Term open import PredicateName open import HasNeitherNor data IsPropositionalFormula : Formula → Set where atomic : (𝑃 : PredicateName) → (τs : Terms) → IsPropositionalFormula $ 𝑃[ 𝑃 ♭ τs ] logical : {φ₁ : Formula} → IsPropositionalFormula φ₁ → {φ₂ : Formula} → IsPropositionalFormula φ₂ → IsPropositionalFormula (φ₁ ⊗ φ₂) instance EqIsPropositionalFormula : ∀ {φ} → Eq (IsPropositionalFormula φ) Eq._==_ EqIsPropositionalFormula (atomic _ _) (atomic _ _ ) = yes refl Eq._==_ EqIsPropositionalFormula (logical φ₁₁ φ₁₂) (logical φ₂₁ φ₂₂) with φ₁₁ ≟ φ₂₁ | φ₁₂ ≟ φ₂₂ Eq._==_ EqIsPropositionalFormula (logical φ₁₁ φ₁₂) (logical φ₂₁ φ₂₂) | yes refl | yes refl = yes refl Eq._==_ EqIsPropositionalFormula (logical φ₁₁ φ₁₂) (logical φ₂₁ φ₂₂) | yes refl | no φ₁₂≢φ₂₂ = no λ {refl → φ₁₂≢φ₂₂ refl} Eq._==_ EqIsPropositionalFormula (logical φ₁₁ φ₁₂) (logical φ₂₁ φ₂₂) | no φ₁₁≢φ₂₁ | _ = no λ {refl → φ₁₁≢φ₂₁ refl} {- -- need to use coinduction to prove this foo : ¬ ∃ λ φ → ∃ λ (p₁ : IsPropositionalFormula φ) → ∃ λ (p₂ : IsPropositionalFormula φ) → p₁ ≢ p₂ foo (atomic x x₁ , atomic .x .x₁ , atomic .x .x₁ , snd₁) = snd₁ refl foo (logical fst₁ fst₂ , logical fst₃ fst₄ , logical fst₅ fst₆ , snd₁) with fst₃ ≟ fst₅ | fst₄ ≟ fst₆ foo (logical fst₁ fst₂ , logical fst₃ fst₄ , logical .fst₃ .fst₄ , snd₁) | yes refl | (yes refl) = snd₁ refl foo (logical fst₁ fst₂ , logical fst₃ fst₄ , logical .fst₃ fst₆ , snd₁) | yes refl | (no x₁) = foo (fst₂ , fst₄ , fst₆ , λ xs → x₁ xs) foo (logical fst₁ fst₂ , logical fst₃ fst₄ , logical fst₅ fst₆ , snd₁) | no x | (yes x₁) = {!!} foo (logical fst₁ fst₂ , logical fst₃ fst₄ , logical fst₅ fst₆ , snd₁) | no x | (no x₁) = {!!} foo (quantified x fst₁ , () , fst₃ , snd₁) -}
{ "alphanum_fraction": 0.6960621187, "avg_line_length": 53.0294117647, "ext": "agda", "hexsha": "71abb2a1cb68493b5eb98e5bfa23f962083238ce", "lang": "Agda", "max_forks_count": null, "max_forks_repo_forks_event_max_datetime": null, "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_forks_repo_licenses": [ "RSA-MD" ], "max_forks_repo_name": "m0davis/oscar", "max_forks_repo_path": "archive/agda-1/IsPropositionalFormula.agda", "max_issues_count": 1, "max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z", "max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z", "max_issues_repo_licenses": [ "RSA-MD" ], "max_issues_repo_name": "m0davis/oscar", "max_issues_repo_path": "archive/agda-1/IsPropositionalFormula.agda", "max_line_length": 134, "max_stars_count": null, "max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb", "max_stars_repo_licenses": [ "RSA-MD" ], "max_stars_repo_name": "m0davis/oscar", "max_stars_repo_path": "archive/agda-1/IsPropositionalFormula.agda", "max_stars_repo_stars_event_max_datetime": null, "max_stars_repo_stars_event_min_datetime": null, "num_tokens": 705, "size": 1803 }
open import Agda.Builtin.Reflection open import Agda.Builtin.List open import Agda.Builtin.Unit macro m-0 : Term → TC ⊤ m-0 goal = bindTC (inferType goal) λ where (pi (arg (arg-info _ (modality _ quantity-0)) _) _) → bindTC (quoteTC (λ (_ : Set) → Set)) (unify goal) type → typeError (termErr type ∷ []) m-ω : Term → TC ⊤ m-ω goal = bindTC (inferType goal) λ where (pi (arg (arg-info _ (modality _ quantity-ω)) _) _) → bindTC (quoteTC (λ (_ : Set) → Set)) (unify goal) type → typeError (termErr type ∷ []) _ : @0 Set → Set₁ _ = m-0 _ : @ω Set → Set₁ _ = m-ω postulate f : @0 Set₁ → Set₁ macro m₁ : Set₁ → Term → TC ⊤ m₁ A goal = bindTC (quoteTC A) λ A → unify goal (def (quote f) (arg (arg-info visible (modality relevant quantity-0)) A ∷ [])) _ : Set₁ → Set₁ _ = λ A → m₁ A macro m₂ : Set₁ → Term → TC ⊤ m₂ A goal = bindTC (quoteTC A) λ A → unify goal (def (quote f) -- The modality is ignored. (arg (arg-info visible (modality irrelevant quantity-ω)) A ∷ [])) _ : Set₁ → Set₁ _ = λ A → m₂ A
{ "alphanum_fraction": 0.5296080067, "avg_line_length": 20.6724137931, "ext": "agda", "hexsha": "5e186fa3e3269e09fdeb9d4992a78e96bba4a2e0", "lang": "Agda", "max_forks_count": 371, "max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z", "max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z", "max_forks_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "cruhland/agda", "max_forks_repo_path": "test/Succeed/Issue5317.agda", "max_issues_count": 4066, "max_issues_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z", "max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "cruhland/agda", "max_issues_repo_path": "test/Succeed/Issue5317.agda", "max_line_length": 69, "max_stars_count": 1989, "max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "cruhland/agda", "max_stars_repo_path": "test/Succeed/Issue5317.agda", "max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z", "max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z", "num_tokens": 408, "size": 1199 }
{-# OPTIONS --warning=error --safe --without-K #-} open import LogicalFormulae open import Agda.Primitive using (Level; lzero; lsuc; _⊔_) open import Functions.Definition open import Setoids.Setoids open import Setoids.Subset open import Graphs.Definition open import Sets.FinSet.Definition open import Numbers.Naturals.Semiring module Graphs.Colouring where Colouring : (n : ℕ) {a b c : _} {V' : Set a} {V : Setoid {a} {b} V'} (G : Graph c V) → Set (a ⊔ c) Colouring n {V' = V'} G = {x y : V'} → (Graph._<->_ G x y) → FinSet n inheritColouring : {n : ℕ} {a b c : _} {V' : Set a} {V : Setoid {a} {b} V'} {G : Graph c V} → (k : Colouring n G) → {e : _} {pred : V' → Set e} {sub : subset V pred} {d : _} {_<->'_ : Rel {_} {d} (Sg V' pred)} (H : Subgraph G sub _<->'_) → Colouring n (subgraphIsGraph H) inheritColouring k H {v1 , _} {v2 , _} x-y = k (Subgraph.inherits H x-y) Monochromatic : {a b c : Level} {V' : Set a} {V : Setoid {a} {b} V'} {G : Graph c V} {n : ℕ} → (k : Colouring n G) → {d e : _} {pred : V' → Set d} {sub : subset V pred} {_<->'_ : Rel {_} {e} (Sg V' pred)} (H : Subgraph G sub _<->'_) → Set (a ⊔ d ⊔ e) Monochromatic {V' = V'} {n = n} k {pred = pred} {sub = sub} {_<->'_} H = Sg (FinSet n) (λ c → {x : Sg V' pred} {y : Sg V' pred} (edge : x <->' y) → (inheritColouring k H) edge ≡ c)
{ "alphanum_fraction": 0.5816793893, "avg_line_length": 59.5454545455, "ext": "agda", "hexsha": "ad3ef1ffeff506a426a15a212a89238145d3e7de", "lang": "Agda", "max_forks_count": 1, "max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z", "max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_forks_repo_licenses": [ "MIT" ], "max_forks_repo_name": "Smaug123/agdaproofs", "max_forks_repo_path": "Graphs/Colouring.agda", "max_issues_count": 14, "max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z", "max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z", "max_issues_repo_licenses": [ "MIT" ], "max_issues_repo_name": "Smaug123/agdaproofs", "max_issues_repo_path": "Graphs/Colouring.agda", "max_line_length": 271, "max_stars_count": 4, "max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562", "max_stars_repo_licenses": [ "MIT" ], "max_stars_repo_name": "Smaug123/agdaproofs", "max_stars_repo_path": "Graphs/Colouring.agda", "max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z", "max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z", "num_tokens": 523, "size": 1310 }