Search is not available for this dataset
text
string | meta
dict |
---|---|
{-# OPTIONS --without-K #-}
module FinEquivTypeEquiv where
-- The goal is to establish that finite sets and equivalences form a
-- commutative semiring.
import Level using (zero)
open import Data.Nat using (ℕ; _+_; _*_)
open import Data.Fin using (Fin)
open import Relation.Binary using (IsEquivalence)
open import Algebra using (CommutativeSemiring)
open import Algebra.Structures
using (IsSemigroup; IsCommutativeMonoid; IsCommutativeSemiring)
open import Equiv using (_≃_; id≃; sym≃; trans≃; _●_; _⊎≃_; _×≃_)
open import TypeEquiv
using (assocl₊equiv; unite₊equiv; unite₊′equiv; swap₊equiv;
unite⋆equiv; unite⋆′equiv; swap⋆equiv; assocl⋆equiv;
distzequiv; distzrequiv; distequiv; distlequiv)
open import FinEquivPlusTimes using (F0≃⊥; module Plus; Fin1≃⊤; module Times)
open Plus using (+≃⊎; ⊎≃+)
open Times using (*≃×; ×≃*)
------------------------------------------------------------------------------
-- This is the relation we are interested in showing is a commutative
-- semiring.
_fin≃_ : (m n : ℕ) → Set
m fin≃ n = Fin m ≃ Fin n
------------------------------------------------------------------------------
-- Additive monoid
module PlusE where
infix 9 _+F_
-- additive monoid equivalences
-- unite+
unite+ : {m : ℕ} → Fin (0 + m) ≃ Fin m
unite+ = unite₊equiv ● F0≃⊥ ⊎≃ id≃ ● +≃⊎
-- and on the other side as well
unite+r : {m : ℕ} → Fin (m + 0) ≃ Fin m
unite+r = unite₊′equiv ● id≃ ⊎≃ F0≃⊥ ● +≃⊎
-- swap₊
swap+ : {m n : ℕ} → Fin (m + n) ≃ Fin (n + m)
swap+ {m} = ⊎≃+ ● swap₊equiv ● +≃⊎ {m}
-- associativity
assocl+ : {m n o : ℕ} → Fin (m + (n + o)) ≃ Fin ((m + n) + o)
assocl+ {m} = ⊎≃+ ● ⊎≃+ ⊎≃ id≃ ● assocl₊equiv ● id≃ ⊎≃ +≃⊎ ● +≃⊎ {m}
-- congruence
_+F_ : {m n o p : ℕ} → (Fin m ≃ Fin n) → (Fin o ≃ Fin p) →
Fin (m + o) ≃ Fin (n + p)
Fm≃Fn +F Fo≃Fp = ⊎≃+ ● Fm≃Fn ⊎≃ Fo≃Fp ● +≃⊎
uniti+ : {m : ℕ} → Fin m ≃ Fin (0 + m)
uniti+ = sym≃ unite+
uniti+r : {m : ℕ} → Fin m ≃ Fin (m + 0)
uniti+r = sym≃ unite+r
assocr+ : {m n o : ℕ} → Fin ((m + n) + o) ≃ Fin (m + (n + o))
assocr+ {m} = sym≃ (assocl+ {m})
sswap+ : {m n : ℕ} → Fin (n + m) ≃ Fin (m + n)
sswap+ {m} {n} = sym≃ (swap+ {m} {n})
-----------------------------------------------------------------------------
-- Multiplicative monoid
module TimesE where
infixl 7 _*F_
-- multiplicative monoid equivalences
-- unite*
unite* : {m : ℕ} → Fin (1 * m) ≃ Fin m
unite* {m} = unite⋆equiv ● Fin1≃⊤ ×≃ id≃ ● *≃×
-- unite*r
unite*r : {m : ℕ} → Fin (m * 1) ≃ Fin m
unite*r {m} = unite⋆′equiv ● id≃ ×≃ Fin1≃⊤ ● *≃×
-- swap*
swap* : {m n : ℕ} → Fin (m * n) ≃ Fin (n * m)
swap* {m} {n} = ×≃* ● swap⋆equiv ● *≃× {m}
-- associativity
assocl* : {m n o : ℕ} → Fin (m * (n * o)) ≃ Fin ((m * n) * o)
assocl* {m} {n} {o} = ×≃* ● ×≃* ×≃ id≃ ● assocl⋆equiv ● id≃ ×≃ *≃× ● *≃× {m}
-- congruence
_*F_ : {m n o p : ℕ} → Fin m ≃ Fin n → Fin o ≃ Fin p →
Fin (m * o) ≃ Fin (n * p)
Fm≃Fn *F Fo≃Fp = ×≃* ● Fm≃Fn ×≃ Fo≃Fp ● *≃×
uniti* : {m : ℕ} → Fin m ≃ Fin (1 * m)
uniti* = sym≃ unite*
uniti*r : {m : ℕ} → Fin m ≃ Fin (m * 1)
uniti*r = sym≃ unite*r
assocr* : {m n o : ℕ} → Fin ((m * n) * o) ≃ Fin (m * (n * o))
assocr* {m} {n} {o} = sym≃ (assocl* {m})
sswap* : {m n : ℕ} → Fin (n * m) ≃ Fin (m * n)
sswap* {m} {n} = sym≃ (swap* {m} {n})
------------------------------------------------------------------------------
-- Distributivity of multiplication over addition
module PlusTimesE where
-- now that we have two monoids, we need to check distributivity
-- note that the sequence below is "logically right", *but* could be
-- replaced by id≃ !
distz : {m : ℕ} → Fin (0 * m) ≃ Fin 0
distz {m} = sym≃ F0≃⊥ ● distzequiv ● F0≃⊥ ×≃ id≃ ● *≃× {0} {m}
where open Times
distzr : {m : ℕ} → Fin (m * 0) ≃ Fin 0
distzr {m} = sym≃ F0≃⊥ ● distzrequiv ● id≃ ×≃ F0≃⊥ ● *≃× {m} {0}
where open Times
dist : {m n o : ℕ} → Fin ((m + n) * o) ≃ Fin ((m * o) + (n * o))
dist {m} {n} {o} = ⊎≃+ {m * o} {n * o} ● ×≃* {m} ⊎≃ ×≃* ● distequiv ● +≃⊎ ×≃ id≃ ● *≃×
where open Times
open Plus
distl : {m n o : ℕ} → Fin (m * (n + o)) ≃ Fin ((m * n) + (m * o))
distl {m} {n} {o} = ⊎≃+ {m * n} {m * o} ● ×≃* {m} ⊎≃ ×≃* ● distlequiv ● id≃ ×≃ +≃⊎ ● *≃×
where open Plus
open Times
factorzr : {n : ℕ} → Fin 0 ≃ Fin (n * 0)
factorzr {n} = sym≃ (distzr {n})
factorz : {m : ℕ} → Fin 0 ≃ Fin (0 * m)
factorz {m} = sym≃ (distz {m})
factor : {m n o : ℕ} → Fin ((m * o) + (n * o)) ≃ Fin ((m + n) * o)
factor {m} = sym≃ (dist {m})
factorl : {m n o : ℕ} → Fin ((m * n) + (m * o)) ≃ Fin (m * (n + o))
factorl {m} = sym≃ (distl {m})
------------------------------------------------------------------------------
-- Summarizing... we have a commutative semiring structure
fin≃IsEquiv : IsEquivalence _fin≃_
fin≃IsEquiv = record {
refl = id≃ ;
sym = sym≃ ;
trans = trans≃
}
finPlusIsSG : IsSemigroup _fin≃_ _+_
finPlusIsSG = record {
isEquivalence = fin≃IsEquiv ;
assoc = λ m n o → PlusE.assocr+ {m} {n} {o} ;
∙-cong = PlusE._+F_
}
finTimesIsSG : IsSemigroup _fin≃_ _*_
finTimesIsSG = record {
isEquivalence = fin≃IsEquiv ;
assoc = λ m n o → TimesE.assocr* {m} {n} {o} ;
∙-cong = TimesE._*F_
}
finPlusIsCM : IsCommutativeMonoid _fin≃_ _+_ 0
finPlusIsCM = record {
isSemigroup = finPlusIsSG ;
identityˡ = λ m → id≃ ;
comm = λ m n → PlusE.swap+ {m} {n}
}
finTimesIsCM : IsCommutativeMonoid _fin≃_ _*_ 1
finTimesIsCM = record {
isSemigroup = finTimesIsSG ;
identityˡ = λ m → TimesE.unite* {m} ;
comm = λ m n → TimesE.swap* {m} {n}
}
finIsCSR : IsCommutativeSemiring _fin≃_ _+_ _*_ 0 1
finIsCSR = record {
+-isCommutativeMonoid = finPlusIsCM ;
*-isCommutativeMonoid = finTimesIsCM ;
distribʳ = λ o m n → PlusTimesE.dist {m} {n} {o} ;
zeroˡ = λ m → PlusTimesE.distz {m}
}
finCSR : CommutativeSemiring Level.zero Level.zero
finCSR = record {
Carrier = ℕ ;
_≈_ = _fin≃_ ;
_+_ = _+_ ;
_*_ = _*_ ;
0# = 0 ;
1# = 1 ;
isCommutativeSemiring = finIsCSR
}
------------------------------------------------------------------------------
|
{
"alphanum_fraction": 0.4915803109,
"avg_line_length": 27.3274336283,
"ext": "agda",
"hexsha": "9013106eca5090535b8718d924a17cc5ab0e60c9",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2019-09-10T09:47:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-29T01:56:33.000Z",
"max_forks_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "JacquesCarette/pi-dual",
"max_forks_repo_path": "Univalence/FinEquivTypeEquiv.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_issues_repo_issues_event_max_datetime": "2021-10-29T20:41:23.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-07T16:27:41.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "JacquesCarette/pi-dual",
"max_issues_repo_path": "Univalence/FinEquivTypeEquiv.agda",
"max_line_length": 90,
"max_stars_count": 14,
"max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "JacquesCarette/pi-dual",
"max_stars_repo_path": "Univalence/FinEquivTypeEquiv.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-05T01:07:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-08-18T21:40:15.000Z",
"num_tokens": 2608,
"size": 6176
}
|
{-# OPTIONS --cubical #-}
module Erased-cubical-Module-application.Cubical (_ : Set₁) where
open import Agda.Builtin.Cubical.Path
data ∥_∥ (A : Set) : Set where
∣_∣ : A → ∥ A ∥
trivial : (x y : ∥ A ∥) → x ≡ y
|
{
"alphanum_fraction": 0.5954545455,
"avg_line_length": 22,
"ext": "agda",
"hexsha": "d113f887a0f40c68d12a2c57276beda461fb24fc",
"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/Erased-cubical-Module-application/Cubical.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/Erased-cubical-Module-application/Cubical.agda",
"max_line_length": 65,
"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/Erased-cubical-Module-application/Cubical.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": 87,
"size": 220
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.RingSolver.AlmostRing where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Sigma
open import Cubical.Algebra.Semigroup
open import Cubical.Algebra.Monoid
open import Cubical.Algebra.AbGroup
private
variable
ℓ : Level
record IsAlmostRing {R : Type ℓ}
(0r 1r : R) (_+_ _·_ : R → R → R) (-_ : R → R) : Type ℓ where
constructor isalmostring
field
+IsMonoid : IsMonoid 0r _+_
·IsMonoid : IsMonoid 1r _·_
+Comm : (x y : R) → x + y ≡ y + x
·Comm : (x y : R) → x · y ≡ y · x
·DistR+ : (x y z : R) → x · (y + z) ≡ (x · y) + (x · z)
·DistL+ : (x y z : R) → (x + y) · z ≡ (x · z) + (y · z)
-Comm· : (x y : R) → - (x · y) ≡ (- x) · y
-Dist+ : (x y : R) → - (x + y) ≡ (- x) + (- y)
open IsMonoid +IsMonoid public
renaming
( assoc to +Assoc
; identity to +Identity
; lid to +Lid
; rid to +Rid
; isSemigroup to +IsSemigroup)
open IsMonoid ·IsMonoid public
renaming
( assoc to ·Assoc
; identity to ·Identity
; lid to ·Lid
; rid to ·Rid
; isSemigroup to ·IsSemigroup )
hiding
( is-set ) -- We only want to export one proof of this
record AlmostRing : Type (ℓ-suc ℓ) where
constructor almostring
field
Carrier : Type ℓ
0r : Carrier
1r : Carrier
_+_ : Carrier → Carrier → Carrier
_·_ : Carrier → Carrier → Carrier
-_ : Carrier → Carrier
isAlmostRing : IsAlmostRing 0r 1r _+_ _·_ -_
infixl 8 _·_
infixl 7 -_
infixl 6 _+_
open IsAlmostRing isAlmostRing public
-- Extractor for the carrier type
⟨_⟩ : AlmostRing → Type ℓ
⟨_⟩ = AlmostRing.Carrier
isSetAlmostRing : (R : AlmostRing {ℓ}) → isSet ⟨ R ⟩
isSetAlmostRing R = R .AlmostRing.isAlmostRing .IsAlmostRing.·IsMonoid .IsMonoid.isSemigroup .IsSemigroup.is-set
|
{
"alphanum_fraction": 0.5744245524,
"avg_line_length": 26.4189189189,
"ext": "agda",
"hexsha": "008d0db5febd7a55c5cf1418c969ea79ddea8154",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Schippmunk/cubical",
"max_forks_repo_path": "Cubical/Algebra/RingSolver/AlmostRing.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"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": "Schippmunk/cubical",
"max_issues_repo_path": "Cubical/Algebra/RingSolver/AlmostRing.agda",
"max_line_length": 112,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c345dc0c49d3950dc57f53ca5f7099bb53a4dc3a",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Schippmunk/cubical",
"max_stars_repo_path": "Cubical/Algebra/RingSolver/AlmostRing.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 691,
"size": 1955
}
|
module Issue326 where
open import Common.Prelude
postulate
QName : Set
Unit : Set
IO : Set → Set
printBool : Bool → IO Unit
{-# BUILTIN QNAME QName #-}
{-# BUILTIN IO IO #-}
{-# COMPILED_TYPE IO IO #-}
{-# COMPILED_TYPE Unit () #-}
{-# COMPILED printBool print #-}
primitive primQNameEquality : QName → QName → Bool
main : IO Unit
main = printBool (primQNameEquality (quote Unit) (quote IO))
|
{
"alphanum_fraction": 0.6691176471,
"avg_line_length": 18.5454545455,
"ext": "agda",
"hexsha": "eac3a71c8072cf53c914f9b9e8da213876a457e5",
"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": "4383a3d20328a6c43689161496cee8eb479aca08",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dagit/agda",
"max_forks_repo_path": "test/succeed/Issue326.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08",
"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": "dagit/agda",
"max_issues_repo_path": "test/succeed/Issue326.agda",
"max_line_length": 60,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/succeed/Issue326.agda",
"max_stars_repo_stars_event_max_datetime": "2019-11-27T07:26:06.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-11-27T07:26:06.000Z",
"num_tokens": 113,
"size": 408
}
|
module REMatch where
open import Data.Char
import Data.Nat
--open import Data.List
open import Data.Bool
open import Data.Product
import Algebra
import Algebra.FunctionProperties
open import Relation.Nullary
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
open import Data.List
open import Data.List.Properties
open import Data.Sum
open import Data.List.NonEmpty
--open List-solver renaming (nil to :[]; _⊕_ to _:++_; _⊜_ to _:≡_; solve to listSolve; prove to listProve)
open import Algebra
import Algebra.FunctionProperties as FunProp
open import Data.Maybe
open import Data.Nat
open import RETypes
import Relation.Binary.Reflection as Ref
import Data.Bool.Properties
listDivisions : List Char -> List (List Char × List Char)
listDivisions [] = ( [] , []) ∷ []
listDivisions (h ∷ t) = ([] , h ∷ t ) ∷ (Data.List.map (λ p -> ( (h ∷ proj₁ p) , proj₂ p )) (listDivisions t) )
elementMatches : {A : Set} (f : A -> Bool) -> List A -> Bool
elementMatches f [] = false
elementMatches f (h ∷ t) = (f h) ∨ elementMatches f t
{-
mutual
starMatch : {n : Null?} -> (RE n) -> List Char -> List Char -> (List Char -> Bool) -> Bool
starMatch (r *) s1 (sh ∷ st) k = (acc r (s1 ++ Data.List.[ sh ]) null ∧ acc ( r *) st k ) ∨ starMatch (r *) (s1 ++ Data.List.[ sh ]) st k
starMatch (r *) s1 [] k = false
starMatch _ _ _ _ = false
-}
{-# TERMINATING #-}
acc : {n : Null?} -> RE n -> List Char -> (List Char -> Bool) -> Bool
acc ε s k = k s
acc ∅ _ _ = false
acc (Lit _) [] _ = false
acc (Lit c) (sFirst ∷ sRest) k with (c Data.Char.≟ sFirst)
... | yes pf = (k sRest)
... | no _ = false
acc (r₁ + r₂) s k = (acc r₁ s k) ∨ (acc r₂ s k)
acc (r₁ · r₂) s k = acc r₁ s (λ s' -> acc r₂ s' k)
acc (r *) [] k = (k [])
acc (r *) (ch ∷ ct) k =
let
cs = ch ∷ ct
in k cs ∨ acc r cs (\cs' -> acc (r *) cs' k)
--acc r cs (\cs' -> acc (r) cs' k)
--acc (r *) (sFirst ∷ sRest) k = starMatch r (sFirst ∷ [] ) sRest k
accept : {n : Null?} -> RE n -> List Char -> Bool
accept r s = acc r s null
concatPreservesNonNull : {s1 : List Char}
-> {s2 : List Char}
-> (∃ λ (h : Char) -> ∃ λ (t : List Char) -> (s1 ≡ h ∷ t) )
-> (∃ λ (h : Char) -> ∃ λ (t : List Char) -> (s1 ++ s2 ≡ h ∷ t) )
concatPreservesNonNull {s1} {s2 = []} (sh , st , pf) =
let
concatPf : s1 ++ [] ≡ s1
concatPf = (solve (suc zero) (λ x → x ⊕ nil , x) (λ {x} → refl)) s1 --Should be easy, I might have already proved something similar,
--This is probably a good place to try the List prover stuff
in sh , st , trans concatPf pf
where open List-solver
concatPreservesNonNull {s1} {s2 = x ∷ s2} (sh , st , pf) =
let
--subProof : (∃ λ (h : Char) -> ∃ λ (t : List Char) -> (s1 ++ s2 ≡ h ∷ t) )
(h , t , subProof) = concatPreservesNonNull {s1} {s2} (sh , st , pf)
p2 : ((sh ∷ st) ++ s2 ≡ h ∷ t)
p2 = subst (λ x₁ → x₁ ++ s2 ≡ h ∷ t) pf subProof
in sh , (st ++ (x ∷ s2)) , cong (λ x₁ → x₁ ++ x ∷ s2) pf
concatPreservesNonNull2 : {s1 : List Char}
-> {s2 : List Char}
-> (∃ λ (h : Char) -> ∃ λ (t : List Char) -> (s2 ≡ h ∷ t) )
-> (∃ λ (h : Char) -> ∃ λ (t : List Char) -> (s1 ++ s2 ≡ h ∷ t) )
concatPreservesNonNull2 {[]} (sh , st , pf) = sh , st , pf
concatPreservesNonNull2 {x ∷ s1} {s2} (sh , st , pf) = x , s1 ++ s2 , refl
open ≡-Reasoning
nullCorrect : (r : RE NonNull) -> (s : List Char ) -> (REMatch s r)
-> (∃ λ (h : Char) -> ∃ λ (t : List Char) -> (s ≡ h ∷ t) )
nullCorrect .(Lit c) .(c ∷ []) (LitMatch c) = c , [] , refl
nullCorrect ._ s (LeftPlusMatch {nb = BothNullB} {r1 = r1} r2 match) = nullCorrect r1 s match
nullCorrect ._ s (RightPlusMatch {nb = BothNullB} r1 {r2 = r2} match) = nullCorrect r2 s match
nullCorrect .(r1 · r2) s (ConcatMatch {nt = LeftNullT} {s1 = s1} {s2 = s2} {spf = spf} {r1 = r1} {r2 = r2} match1 match2) =
let
sh , st , subPf = concatPreservesNonNull2 {s1 = s1} {s2 = s2} (nullCorrect r2 s2 match2)
in sh , st , trans (sym spf) subPf --subH , subT , ?
nullCorrect ._ s (ConcatMatch {nt = BothNonNullT} {s1 = s1} {s2 = s2} {spf = spf} {r1 = r1} {r2 = r2} match1 match2) =
let
sh , st , subPf = concatPreservesNonNull2 {s1 = s1} {s2 = s2} (nullCorrect r2 s2 match2)
in sh , st , trans (sym spf) subPf
nullCorrect ._ s (ConcatMatch {nt = RightNullT} {s1 = s1} {s2 = s2} {spf = spf} {r1 = r1} {r2 = r2} match1 match2) =
let
sh , st , subPf = concatPreservesNonNull {s1 = s1} {s2 = s2} (nullCorrect r1 s1 match1)
in sh , st , trans (sym spf) subPf -- concatPreservesNonNull (nullCorrect r1 s1 match1)
--Taken from http://gelisam.blogspot.ca/2010/10/equality-is-useless-transmutation.html
--Can probably be done with more complicated existing stuff, but this is easier
mySubst : {X : Set}
→ (P : X → Set)
→ (x y : X)
→ x ≡ y
→ P x
→ P y
mySubst P v .v refl p = p
orLemma1 : {x : Bool} {y : Bool} -> (y ≡ true) -> (y ∨ x) ≡ true
orLemma1 {x} {true} pf = refl
orLemma1 {x} {false} ()
andElim1 : {x : Bool} {y : Bool} -> (x ∧ y) ≡ true -> (x ≡ true)
andElim1 {true} pf = refl
andElim1 {false} ()
--TODO Pattern match on and first
andElim2 : {x : Bool} {y : Bool} -> (x ∧ y) ≡ true -> (y ≡ true)
andElim2 {y = true} pf = refl
andElim2 {true} {false} ()
andElim2 {false} {false} ()
andCombine : {x : Bool} {y : Bool} -> x ≡ true -> y ≡ true -> (x ∧ y) ≡ true
andCombine {true} pfx pfy = pfy
andCombine {false} ()
{-
orCommut : {x : Bool} {y : Bool} -> (y ∨ x) ≡ (x ∨ y)
orCommut {true} {true} = refl
orCommut {false} {true} = refl
orCommut {true} {false} = refl
orCommut {false} {false} = refl
-}
orLemma2 : {x : Bool} {y : Bool} -> (y ≡ true) -> (x ∨ y) ≡ true
orLemma2 {true} {true} pf = refl
orLemma2 {false} {true} pf = refl
orLemma2 {true} {false} pf = refl
orLemma2 {false} {false} ()
orCases : {x : Bool} {y : Bool} -> (x ∨ y ≡ true) -> (x ≡ true) ⊎ (y ≡ true)
orCases {true} y = inj₁ refl
orCases {false} y = inj₂ y
listRightIdent : { x : List Char} -> (x ++ []) ≡ x
listRightIdent {[]} = refl
listRightIdent {x ∷ x₁} = cong (_∷_ x) (listRightIdent {x₁})
listAssoc : {x y z : List Char} -> (x ++ y) ++ z ≡ x ++ (y ++ z)
listAssoc {[]} = λ {y} {z} → refl
listAssoc {xh ∷ xt} {y} {z} = cong (_∷_ xh) (listAssoc {xt} {y} {z})
maybeHead : List Char -> Maybe Char
maybeHead [] = nothing
maybeHead (x ∷ _) = just x
fakeTail : List Char -> List Char
fakeTail [] = []
fakeTail (_ ∷ t) = t
myFromJust : Maybe Char -> Char
myFromJust (just x) = x
myFromJust (nothing) = 'a'
sameHead : {a : Char}{b : Char}{l1 : List Char}{l2 : List Char} -> ((a ∷ l1) ≡ (b ∷ l2)) -> (a ≡ b)
sameHead {a} {b} {l1} {l2} pf =
let
maybeSameHead : (just a) ≡ (just b)
maybeSameHead = cong (maybeHead) pf
in cong myFromJust maybeSameHead
sameTail : {a : Char}{b : Char}{l1 : List Char}{l2 : List Char} -> ((a ∷ l1) ≡ (b ∷ l2)) -> (l1 ≡ l2)
sameTail {a} {b} {l1} {l2} pf = cong fakeTail pf
emptyMiddleList : {c : Char}{s1 s2 : List Char} -> (c ∷ s1 ≡ (c ∷ []) ++ s2 ) -> s1 ≡ s2
emptyMiddleList {c} {s1} {s2} spf =
let
p0 : (s1 ≡ [] ++ s2 )
p0 = cong fakeTail spf
p1 : [] ++ s2 ≡ s2
p1 = refl
in trans p0 p1
accCorrect :
{n : Null? }
(r : RE n)
(s : List Char) (s1 : List Char) (s2 : List Char)
(k : (List Char -> Bool))
-> ( (s1 ++ s2) ≡ s)
-> (REMatch s1 r)
-> (k s2 ≡ true)
-> (acc r s k ≡ true )
--accCorrect ∅ [] [] [] k _ () kproof
accCorrect ε [] ._ [] k _ EmptyMatch kproof = kproof
accCorrect (Lit .c) (c1 ∷ srest ) (.c ∷ []) s2 k stringProof (LitMatch c) kproof with (c Data.Char.≟ c1)
... | yes eqPf = let
sameHeads : c ≡ c1
sameHeads = sameHead stringProof
p0 : c Data.List.∷ srest ≡ c1 Data.List.∷ srest
p0 = cong (λ x → x ∷ srest) sameHeads
flipProof : (c1 ∷ srest ) ≡ (c ∷ []) ++ s2
flipProof = sym stringProof
cFlip : (c ∷ srest ) ≡ (c ∷ []) ++ s2
cFlip = trans p0 flipProof
restProof : srest ≡ s2
restProof = emptyMiddleList cFlip
primEq : (Dec (c ≡ c1))
primEq = yes sameHeads
pf3 = cong (λ theChar -> acc (Lit c) (c ∷ srest) k ) sameHeads
in trans (cong k restProof) kproof
accCorrect (Lit .c) (c1 ∷ srest ) (.c ∷ []) s2 k stringProof (LitMatch c) () | no pf
{-
let
sameHeads = sameHead stringProof
primEq : (Dec (c ≡ c1))
primEq = yes sameHeads
pf3 = cong (λ theChar -> acc (Lit c) (c ∷ srest) k ) sameHeads
restProof : srest ≡ s2
restProof = {!!}
in cong k restProof
-}
accCorrect (.r1 · .r2 ) s .s1 s2 k split1 (ConcatMatch {_} {_} {n3} {nt} {s1'} {s2'} {s1} {spf'} {r1} {r2} subMatch1 subMatch2) kproof =
let
--s1 = s1' ++ s2'
split2 : (s1' ++ s2') ≡ s1
split2 = spf' --refl
split3 : (s1' ++ s2') ++ s2 ≡ s1 ++ s2
split3 = cong (λ x -> x ++ s2) split2
split4 : s1' ++ s2' ++ s2 ≡ (s1' ++ s2') ++ s2
split4 = sym (listAssoc {s1'} {s2'} {s2})
transChain : s1' ++ s2' ++ s2 ≡ s
transChain = trans split4 (trans split3 split1)
in accCorrect r1 s s1' (s2' ++ s2) (\cs -> acc r2 cs k) transChain
subMatch1 (accCorrect r2 (s2' ++ s2) s2' s2 k refl subMatch2 kproof)
accCorrect (.r1 + .r2 ) s .s1 s2 k
splitProof (LeftPlusMatch {_} {_} {n3} {nb} {s1} {r1} (r2) subMatch) kproof =
orLemma1 (accCorrect r1 s s1 s2 k splitProof subMatch kproof )
accCorrect (.r1 + .r2) s .s1 s2 k
splitProof (RightPlusMatch {_} {_} {n3} {nb} {s1} (r1) {r2} subMatch) kproof =
let subCorrect = accCorrect r2 s s1 s2 k splitProof subMatch kproof
in orLemma2 {acc r1 s k} {acc r2 s k} subCorrect
accCorrect (.r *) [] ._ [] k _ (EmptyStarMatch {r}) kproof = kproof
accCorrect {MaybeNull} (.r *) (sh ∷ st ) .s1 s2 k split1 (StarMatch {c1} {s1t'} {s2'} {s1} {spf} {r} subMatch1 subMatch2) kproof =
let
s = (sh ∷ st )
s1' = (c1 ∷ s1t')
split2 : (s1' ++ s2') ≡ s1
split2 = spf
split3 : (s1' ++ s2') ++ s2 ≡ s1 ++ s2
split3 = cong (λ x -> x ++ s2) split2
split4 : s1' ++ s2' ++ s2 ≡ (s1' ++ s2') ++ s2
split4 = sym (listAssoc {s1'} {s2'} {s2})
transChain : s1' ++ s2' ++ s2 ≡ s
transChain = trans split4 (trans split3 split1)
sub2' : REMatch {MaybeNull} s2' (r *)
sub2' = subMatch2
subCorrect : acc (r *) (s2' ++ s2) k ≡ true
subCorrect = accCorrect (r *) (s2' ++ s2) s2' s2 k refl subMatch2 kproof
rightCorrect : acc r s (\cs' -> acc (r *) cs' k) ≡ true
rightCorrect = accCorrect r s s1' (s2' ++ s2) (λ cs → acc (r *) cs k) transChain subMatch1 subCorrect
orCorrect : (k s ∨ acc r s (\cs' -> acc (r *) cs' k) ) ≡ true
orCorrect = orLemma2 {x = k s} rightCorrect
--TODO pass in x and y explicitly
in orCorrect --accCorrect r s s1' (s2' ++ s2) (\cs -> acc (r *) cs k) transChain
--subMatch1 (accCorrect (r *) (s2' ++ s2) s2' s2 k refl subMatch2 kproof)
accCorrect (r *) (sh ∷ st) [] s2 k sp1 _ kproof =
let
s = sh ∷ st
sp2 : s2 ≡ s
sp2 = sp1
kproof2 : k s ≡ k s2
kproof2 = cong k (sym sp1)
kproof3 : k s ≡ true
kproof3 = trans kproof2 kproof
--orProof : (k s ∨ starMatch r [] s k) ≡ true
orProof = orLemma1 kproof3
in orProof
--accCorrect r s s1' (s2' ++ s2) (\cs -> acc (r *) cs k) transChain
--subMatch1 (accCorrect (r *) (s2' ++ s2) s2' s2 k refl subMatch2 kproof)
--accCorrect (.r *) s ._ s2 k sp1 (StarMatch {s1'} {s1''} {r} sub1 sub2) kproof = ?
accCorrect ∅ _ _ _ _ _ ()
accCorrect ε (_ ∷ _ ) _ _ _ () _
accCorrect _ [] (_ ∷ _ ) _ _ () _ _
accCorrect _ [] _ (_ ∷ _ ) _ () _ _
accCorrect (Lit _) [] _ _ _ () _ _
accCorrect {._} (_* _) [] [] [] _ _
(StarMatch {_} {_} {_} {._} {()} {._} _ _) _
--accCorrect _ _ _ _ _ _ _ _ = {!!} --This case should disappear when I finish star
boolExclMiddle : {x : Bool} { y : Bool } -> (x ∨ y ≡ true ) -> (x ≡ false) -> (y ≡ true)
boolExclMiddle {true} p1 ()
boolExclMiddle {false} p1 p2 = p1
{-# TERMINATING #-}
accComplete :
{n : Null?}
(r : RE n)
(s : List Char)
(k : (List Char -> Bool))
-> (acc r s k ≡ true)
-> ∃ (λ s1 -> ∃ (λ s2 -> (s1 ++ s2 ≡ s) × ( k s2 ≡ true) × (REMatch s1 r ) ) )
accComplete ε [] k pf = [] , [] , refl , pf , EmptyMatch
accComplete ε s k pf = [] , s , refl , pf , EmptyMatch
accComplete (Lit c) (c1 ∷ srest) k accProof with (c Data.Char.≟ c1)
...| yes eqProof =
let
charsEqual : c ≡ c1
charsEqual = eqProof
in Data.List.[ c ] , srest , cong (λ x → x ∷ srest) charsEqual , accProof , LitMatch c
accComplete (Lit c) (c1 ∷ srest) k () | no _
accComplete (_·_ {n1} {n2} r1 r2) s k pf =
let
sub1 : acc r1 s (λ s' -> acc r2 s' k) ≡ true
sub1 = pf
s11 , s2' , psub1 , psub2 , match1 = accComplete r1 s (λ s' -> acc r2 s' k) pf
s12 , s2 , p1 , p2 , match2 = accComplete r2 s2' k psub2
localAssoc : s11 ++ (s12 ++ s2) ≡ (s11 ++ s12) ++ s2
localAssoc = sym (listAssoc {s11} {s12} {s2})
subProof1 : s11 ++ s2' ≡ s11 ++ (s12 ++ s2)
subProof1 = sym ( cong (λ x -> s11 ++ x) p1 )
subProof2 : s11 ++ s2' ≡ (s11 ++ s12) ++ s2
subProof2 = trans subProof1 localAssoc
stringProof = trans (sym subProof2) psub1
in (s11 ++ s12 ) , s2 , stringProof , p2 , (ConcatMatch {spf = refl} match1 match2)
accComplete (r1 + r2) s k accProof with (orCases accProof)
... | inj₁ leftTrue =
let
s1 , s2 , p1 , p2 , match = accComplete r1 s k leftTrue
in s1 , s2 , p1 , p2 , LeftPlusMatch r2 match
... | inj₂ rightTrue = let
s1 , s2 , p1 , p2 , match = accComplete r2 s k rightTrue
in s1 , s2 , p1 , p2 , RightPlusMatch r1 match
accComplete (r *) [] k pf = [] , [] , refl , pf , EmptyStarMatch
accComplete {MaybeNull} (r *) (sh ∷ st) k accProof with (orCases accProof)
... | inj₁ leftTrue = [] , (sh ∷ st) , refl , leftTrue , EmptyStarMatch
... | inj₂ rightTrue =
let
rTest : RE NonNull
rTest = r
s = sh ∷ st
sub1 : acc r s (λ s' -> acc (r *) s' k) ≡ true
sub1 = rightTrue
s11 , s2' , psub1 , psub2 , match1 = accComplete r s (λ s' -> acc (r *) s' k) rightTrue
s12 , s2 , p1 , p2 , match2 = accComplete (r *) s2' k psub2
localAssoc : s11 ++ (s12 ++ s2) ≡ (s11 ++ s12) ++ s2
localAssoc = sym (listAssoc {s11} {s12} {s2})
subProof1 : s11 ++ s2' ≡ s11 ++ (s12 ++ s2)
subProof1 = sym ( cong (λ x -> s11 ++ x) p1 )
subProof2 : s11 ++ s2' ≡ (s11 ++ s12) ++ s2
subProof2 = trans subProof1 localAssoc
stringProof = trans (sym subProof2) psub1
s11h , s11t , nnpf = nullCorrect r s11 match1
nonNullPf : s11 ≡ s11h ∷ s11t
nonNullPf = nnpf
m1 : REMatch (s11h ∷ s11t) r
m1 = mySubst (λ str → REMatch str r) s11 (s11h ∷ s11t) (nonNullPf) match1
m2 : REMatch s12 (r *)
m2 = match2
newSpf : (s11h ∷ s11t) ++ s2' ≡ s11 ++ s2'
newSpf = {!!}
--ourMatch : REMatch (s11 ++ s12) (r *)
ourMatch = StarMatch {spf = newSpf} {r = rTest} m1 ? --m2
in (s11 ++ s12 ) , s2 , stringProof , p2 , {!!} --ourMatch
accComplete ∅ _ _ ()
accComplete (Lit _) [] _ ()
acceptCorrect :
{n : Null? }
(r : RE n)
(s : List Char)
-> (REMatch s r)
-> (accept r s ≡ true )
acceptCorrect r s match = accCorrect r s s [] null listRightIdent match refl
nullEq : {x : List Char} -> (null x ≡ true ) -> (x ≡ [])
nullEq {[]} pf = refl
nullEq {x ∷ x₁} ()
substMatch : {n : Null?}{r : RE n}{s s1 : List Char} -> s1 ≡ s -> REMatch s1 r -> REMatch s r
substMatch refl m = m
acceptComplete :
{n : Null? }
(r : RE n)
(s : List Char)
-> (accept r s ≡ true )
-> REMatch s r
acceptComplete r s pf =
let
s1 , s2 , sproof , ks2Proof , match = accComplete r s null pf
s2Null : s2 ≡ []
s2Null = nullEq ks2Proof
sp3 : s1 ++ s2 ≡ s1 ++ []
sp3 = cong (λ x -> s1 ++ x) s2Null
sp4 : s1 ++ s2 ≡ s1
sp4 = trans sp3 listRightIdent
sp5 : s1 ≡ s
sp5 = sym (trans (sym sproof) sp4)
in substMatch sp5 match --match
|
{
"alphanum_fraction": 0.5549974887,
"avg_line_length": 35.0837004405,
"ext": "agda",
"hexsha": "9e99b4555b98ab39a773d7919dbfe6ce1af64a1e",
"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": "1e28103ff7dd1d4f3351ef21397833aa4490b7ea",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "JoeyEremondi/agda-parikh",
"max_forks_repo_path": "REMatch.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1e28103ff7dd1d4f3351ef21397833aa4490b7ea",
"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": "JoeyEremondi/agda-parikh",
"max_issues_repo_path": "REMatch.agda",
"max_line_length": 141,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "1e28103ff7dd1d4f3351ef21397833aa4490b7ea",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "JoeyEremondi/agda-parikh",
"max_stars_repo_path": "REMatch.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 6334,
"size": 15928
}
|
-- Define the integers as a HIT by identifying +0 and -0
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.Ints.QuoInt.Base where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Relation.Nullary
open import Cubical.Data.Int as Int using (Int; sucInt; predInt; discreteInt; isSetInt)
open import Cubical.Data.Nat as ℕ using (ℕ; zero; suc)
open import Cubical.Data.Bool as Bool using (Bool; not; notnot)
variable
l : Level
Sign : Type₀
Sign = Bool
pattern spos = Bool.false
pattern sneg = Bool.true
_·S_ : Sign → Sign → Sign
_·S_ = Bool._⊕_
data ℤ : Type₀ where
signed : (s : Sign) (n : ℕ) → ℤ
posneg : signed spos 0 ≡ signed sneg 0
pattern pos n = signed spos n
pattern neg n = signed sneg n
sign : ℤ → Sign
sign (signed _ zero) = spos
sign (signed s (suc _)) = s
sign (posneg i) = spos
sign-pos : ∀ n → sign (pos n) ≡ spos
sign-pos zero = refl
sign-pos (suc n) = refl
abs : ℤ → ℕ
abs (signed _ n) = n
abs (posneg i) = zero
signed-inv : ∀ n → signed (sign n) (abs n) ≡ n
signed-inv (pos zero) = refl
signed-inv (neg zero) = posneg
signed-inv (signed s (suc n)) = refl
signed-inv (posneg i) j = posneg (i ∧ j)
signed-zero : ∀ s₁ s₂ → signed s₁ zero ≡ signed s₂ zero
signed-zero spos spos = refl
signed-zero sneg sneg = refl
signed-zero spos sneg = posneg
signed-zero sneg spos = sym posneg
rec : ∀ {A : Type l} → (pos' neg' : ℕ → A) → pos' 0 ≡ neg' 0 → ℤ → A
rec pos' neg' eq (pos m) = pos' m
rec pos' neg' eq (neg m) = neg' m
rec pos' neg' eq (posneg i) = eq i
elim : ∀ (P : ℤ → Type l)
→ (pos' : ∀ n → P (pos n))
→ (neg' : ∀ n → P (neg n))
→ (λ i → P (posneg i)) [ pos' 0 ≡ neg' 0 ]
→ ∀ z → P z
elim P pos' neg' eq (pos n) = pos' n
elim P pos' neg' eq (neg n) = neg' n
elim P pos' neg' eq (posneg i) = eq i
Int→ℤ : Int → ℤ
Int→ℤ (Int.pos n) = pos n
Int→ℤ (Int.negsuc n) = neg (suc n)
ℤ→Int : ℤ → Int
ℤ→Int (pos n) = Int.pos n
ℤ→Int (neg zero) = Int.pos 0
ℤ→Int (neg (suc n)) = Int.negsuc n
ℤ→Int (posneg _) = Int.pos 0
ℤ→Int→ℤ : ∀ (n : ℤ) → Int→ℤ (ℤ→Int n) ≡ n
ℤ→Int→ℤ (pos n) _ = pos n
ℤ→Int→ℤ (neg zero) i = posneg i
ℤ→Int→ℤ (neg (suc n)) _ = neg (suc n)
ℤ→Int→ℤ (posneg j) i = posneg (j ∧ i)
Int→ℤ→Int : ∀ (n : Int) → ℤ→Int (Int→ℤ n) ≡ n
Int→ℤ→Int (Int.pos n) _ = Int.pos n
Int→ℤ→Int (Int.negsuc n) _ = Int.negsuc n
Int≡ℤ : Int ≡ ℤ
Int≡ℤ = isoToPath (iso Int→ℤ ℤ→Int ℤ→Int→ℤ Int→ℤ→Int)
discreteℤ : Discrete ℤ
discreteℤ = subst Discrete Int≡ℤ discreteInt
isSetℤ : isSet ℤ
isSetℤ = subst isSet Int≡ℤ isSetInt
-_ : ℤ → ℤ
- signed s n = signed (not s) n
- posneg i = posneg (~ i)
negate-invol : ∀ n → - - n ≡ n
negate-invol (signed s n) i = signed (notnot s i) n
negate-invol (posneg i) _ = posneg i
negateEquiv : ℤ ≃ ℤ
negateEquiv = isoToEquiv (iso -_ -_ negate-invol negate-invol)
negateEq : ℤ ≡ ℤ
negateEq = ua negateEquiv
infixl 6 _+_
infixl 7 _·_
sucℤ : ℤ → ℤ
sucℤ (pos n) = pos (suc n)
sucℤ (neg zero) = pos 1
sucℤ (neg (suc n)) = neg n
sucℤ (posneg _) = pos 1
predℤ : ℤ → ℤ
predℤ = subst (λ Z → (Z → Z)) negateEq sucℤ
-- definitionally equal to λ n → - (sucℤ (- n))
-- strictly more useful than the direct pattern matching version,
-- see negateSuc and negatePred
sucPredℤ : ∀ n → sucℤ (predℤ n) ≡ n
sucPredℤ (pos zero) = sym posneg
sucPredℤ (pos (suc _)) = refl
sucPredℤ (neg _) = refl
sucPredℤ (posneg i) j = posneg (i ∨ ~ j)
predSucℤ : ∀ n → predℤ (sucℤ n) ≡ n
predSucℤ (pos _) = refl
predSucℤ (neg zero) = posneg
predSucℤ (neg (suc _)) = refl
predSucℤ (posneg i) j = posneg (i ∧ j)
_+_ : ℤ → ℤ → ℤ
(signed _ zero) + n = n
(posneg _) + n = n
(pos (suc m)) + n = sucℤ (pos m + n)
(neg (suc m)) + n = predℤ (neg m + n)
sucPathℤ : ℤ ≡ ℤ
sucPathℤ = isoToPath (iso sucℤ predℤ sucPredℤ predSucℤ)
-- We do the same trick as in Cubical.Data.Int to prove that addition
-- is an equivalence
addEqℤ : ℕ → ℤ ≡ ℤ
addEqℤ zero = refl
addEqℤ (suc n) = addEqℤ n ∙ sucPathℤ
predPathℤ : ℤ ≡ ℤ
predPathℤ = isoToPath (iso predℤ sucℤ predSucℤ sucPredℤ)
subEqℤ : ℕ → ℤ ≡ ℤ
subEqℤ zero = refl
subEqℤ (suc n) = subEqℤ n ∙ predPathℤ
addℤ : ℤ → ℤ → ℤ
addℤ (pos m) n = transport (addEqℤ m) n
addℤ (neg m) n = transport (subEqℤ m) n
addℤ (posneg _) n = n
isEquivAddℤ : (m : ℤ) → isEquiv (addℤ m)
isEquivAddℤ (pos n) = isEquivTransport (addEqℤ n)
isEquivAddℤ (neg n) = isEquivTransport (subEqℤ n)
isEquivAddℤ (posneg _) = isEquivTransport refl
addℤ≡+ℤ : addℤ ≡ _+_
addℤ≡+ℤ i (pos (suc m)) n = sucℤ (addℤ≡+ℤ i (pos m) n)
addℤ≡+ℤ i (neg (suc m)) n = predℤ (addℤ≡+ℤ i (neg m) n)
addℤ≡+ℤ i (pos zero) n = n
addℤ≡+ℤ i (neg zero) n = n
addℤ≡+ℤ _ (posneg _) n = n
isEquiv+ℤ : (m : ℤ) → isEquiv (m +_)
isEquiv+ℤ = subst (λ _+_ → (m : ℤ) → isEquiv (m +_)) addℤ≡+ℤ isEquivAddℤ
_·_ : ℤ → ℤ → ℤ
m · n = signed (sign m ·S sign n) (abs m ℕ.· abs n)
private
·-abs : ∀ m n → abs (m · n) ≡ abs m ℕ.· abs n
·-abs m n = refl
-- Natural number and negative integer literals for ℤ
open import Cubical.Data.Nat.Literals public
instance
fromNatℤ : HasFromNat ℤ
fromNatℤ = record { Constraint = λ _ → Unit ; fromNat = λ n → pos n }
instance
fromNegℤ : HasFromNeg ℤ
fromNegℤ = record { Constraint = λ _ → Unit ; fromNeg = λ n → neg n }
|
{
"alphanum_fraction": 0.6195732156,
"avg_line_length": 25.1666666667,
"ext": "agda",
"hexsha": "7b9257e98ffb996f614d07be6e689866f01fe514",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/HITs/Ints/QuoInt/Base.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/Ints/QuoInt/Base.agda",
"max_line_length": 87,
"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/Ints/QuoInt/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2337,
"size": 5436
}
|
module Oscar.Data.Term.internal.SubstituteAndSubstitution {𝔣} (FunctionName : Set 𝔣) where
open import Oscar.Category.Action
open import Oscar.Category.Category
open import Oscar.Category.CategoryAction
open import Oscar.Category.Functor
open import Oscar.Category.Morphism
open import Oscar.Category.Semifunctor
open import Oscar.Category.Semigroupoid
open import Oscar.Category.Setoid
open import Oscar.Category.SemigroupoidAction
open import Oscar.Data.Equality
open import Oscar.Data.Equality.properties
open import Oscar.Data.Fin
open import Oscar.Data.Nat
open import Oscar.Data.Term FunctionName
open import Oscar.Data.Vec
open import Oscar.Function
open import Oscar.Level
open import Oscar.Relation
𝕞₁ : Morphism _ _ _
𝕞₁ = Fin ⇨ Term
𝕞₂ : Morphism _ _ _
𝕞₂ = Term ⇨ Term
𝕞₂ₛ : Nat → Morphism _ _ _
𝕞₂ₛ N = Terms N ⇨ Terms N
module 𝔐₁ = Morphism 𝕞₁
module 𝔐₂ = Morphism 𝕞₂
module 𝔐₂ₛ (N : Nat) where open Morphism (𝕞₂ₛ N) public using () renaming (_↦_ to _[_↦_])
private
infix 19 _◂_ _◂s_
mutual
_◂_ : ∀ {m n} → m 𝔐₁.↦ n → m 𝔐₂.↦ n
σ̇ ◂ i 𝑥 = σ̇ 𝑥
_ ◂ leaf = leaf
σ̇ ◂ (τl fork τr) = (σ̇ ◂ τl) fork (σ̇ ◂ τr)
σ̇ ◂ (function fn τs) = function fn (σ̇ ◂s τs) where
_◂s_ : ∀ {m n} → m ⊸ n → ∀ {N} → N 𝔐₂ₛ.[ m ↦ n ] -- Vec (Term m) N → Vec (Term n) N
f ◂s [] = []
f ◂s (t ∷ ts) = f ◂ t ∷ f ◂s ts
_∙_ : ∀ {m n} → m ⊸ n → ∀ {l} → l ⊸ m → l ⊸ n
_∙_ f g = (f ◂_) ∘ g
mutual
◂-extensionality : ∀ {m n} {f g : m ⊸ n} → f ≡̇ g → f ◂_ ≡̇ g ◂_
◂-extensionality p (i x) = p x
◂-extensionality p leaf = refl
◂-extensionality p (s fork t) = cong₂ _fork_ (◂-extensionality p s) (◂-extensionality p t)
◂-extensionality p (function fn ts) = cong (function fn) (◂s-extensionality p ts)
◂s-extensionality : ∀ {m n} {f g : m ⊸ n} → f ≡̇ g → ∀ {N} → _◂s_ f {N} ≡̇ _◂s_ g
◂s-extensionality p [] = refl
◂s-extensionality p (t ∷ ts) = cong₂ _∷_ (◂-extensionality p t) (◂s-extensionality p ts)
mutual
◂-associativity : ∀ {l m} (f : l ⊸ m) {n} (g : m ⊸ n) → (g ∙ f) ◂_ ≡̇ (g ◂_) ∘ (f ◂_)
◂-associativity _ _ (i _) = refl
◂-associativity _ _ leaf = refl
◂-associativity _ _ (τ₁ fork τ₂) = cong₂ _fork_ (◂-associativity _ _ τ₁) (◂-associativity _ _ τ₂)
◂-associativity f g (function fn ts) = cong (function fn) (◂s-associativity f g ts)
◂s-associativity : ∀ {l m n} (f : l ⊸ m) (g : m ⊸ n) → ∀ {N} → (_◂s_ (g ∙ f) {N}) ≡̇ (g ◂s_) ∘ (f ◂s_)
◂s-associativity _ _ [] = refl
◂s-associativity _ _ (τ ∷ τs) = cong₂ _∷_ (◂-associativity _ _ τ) (◂s-associativity _ _ τs)
∙-associativity : ∀ {k l} (f : k ⊸ l) {m} (g : l ⊸ m) {n} (h : m ⊸ n) → (h ∙ g) ∙ f ≡̇ h ∙ (g ∙ f)
∙-associativity f g h x rewrite ◂-associativity g h (f x) = refl
∙-extensionality : ∀ {l m} {f₁ f₂ : l ⊸ m} → f₁ ≡̇ f₂ → ∀ {n} {g₁ g₂ : m ⊸ n} → g₁ ≡̇ g₂ → g₁ ∙ f₁ ≡̇ g₂ ∙ f₂
∙-extensionality {f₂ = f₂} f₁≡̇f₂ g₁≡̇g₂ x rewrite f₁≡̇f₂ x = ◂-extensionality g₁≡̇g₂ (f₂ x)
instance
IsSemigroupoid𝕞₁∙ : IsSemigroupoid 𝕞₁ _∙_
IsSemigroupoid.extensionality IsSemigroupoid𝕞₁∙ = ∙-extensionality
IsSemigroupoid.associativity IsSemigroupoid𝕞₁∙ = ∙-associativity
𝕘₁ : Semigroupoid _ _ _
𝕘₁ = 𝕞₁ , _∙_
𝕘₂ : Semigroupoid _ _ _
𝕘₂ = 𝕞₂ , (λ ‵ → _∘_ ‵)
𝕘₂ₛ : Nat → Semigroupoid _ _ _
𝕘₂ₛ N = 𝕞₂ₛ N , (λ ‵ → _∘_ ‵)
𝕘₁,₂ : Semigroupoids _ _ _ _ _ _
𝕘₁,₂ = 𝕘₁ , 𝕘₂
instance
IsSemifunctor𝕘₁₂◂ : IsSemifunctor 𝕘₁,₂ _◂_
IsSemifunctor.extensionality IsSemifunctor𝕘₁₂◂ = ◂-extensionality
IsSemifunctor.distributivity IsSemifunctor𝕘₁₂◂ = ◂-associativity
𝕗◂ : Semifunctor _ _ _ _ _ _
𝕗◂ = 𝕘₁,₂ , _◂_
𝕘₁,₂ₛ : Nat → Semigroupoids _ _ _ _ _ _
𝕘₁,₂ₛ N = 𝕘₁ , 𝕘₂ₛ N
instance
IsSemifunctor𝕘₁,₂ₛ◂s : ∀ {N} → IsSemifunctor (𝕘₁,₂ₛ N) (λ ‵ → _◂s_ ‵)
IsSemifunctor.extensionality IsSemifunctor𝕘₁,₂ₛ◂s f≡̇g τs = ◂s-extensionality f≡̇g τs
IsSemifunctor.distributivity IsSemifunctor𝕘₁,₂ₛ◂s f g x = ◂s-associativity f g x
𝕗◂s : Nat → Semifunctor _ _ _ _ _ _
𝕗◂s N = 𝕘₁,₂ₛ N , (λ ‵ → _◂s_ ‵)
𝕒₂ : Action _ _ _
𝕒₂ = actionΣ Term
𝕒₂ₛ : Nat → Action _ _ _
𝕒₂ₛ N = actionΣ (Terms N)
instance
IsSemigroupoidAction𝕘₁𝕒₂◂ : IsSemigroupoidAction 𝕘₁ 𝕒₂ _◂_
IsSemigroupoidAction.extensionality IsSemigroupoidAction𝕘₁𝕒₂◂ {s₁ = s₁} refl f₁≡̇f₂ = ◂-extensionality f₁≡̇f₂ s₁
IsSemigroupoidAction.associativity IsSemigroupoidAction𝕘₁𝕒₂◂ s f g = ◂-associativity f g s
IsSemigroupoidAction𝕘₁𝕒₂ₛ◂s : ∀ {N} → IsSemigroupoidAction 𝕘₁ (𝕒₂ₛ N) (λ ‵ → _◂s_ ‵)
IsSemigroupoidAction.extensionality IsSemigroupoidAction𝕘₁𝕒₂ₛ◂s {s₁ = s₁} refl f₁≡̇f₂ = ◂s-extensionality f₁≡̇f₂ s₁
IsSemigroupoidAction.associativity IsSemigroupoidAction𝕘₁𝕒₂ₛ◂s s f g = ◂s-associativity f g s
𝕟◂ : SemigroupoidAction _ _ _ _ _
𝕟◂ = [ 𝕘₁ / 𝕒₂ ] _◂_
𝕟◂s : Nat → SemigroupoidAction _ _ _ _ _
𝕟◂s N = [ 𝕘₁ / 𝕒₂ₛ N ] (λ ‵ → _◂s_ ‵)
private
ε : ∀ {m} → m ⊸ m
ε = i
mutual
◂-identity : ∀ {m} (t : Term m) → ε ◂ t ≡ t
◂-identity (i x) = refl
◂-identity leaf = refl
◂-identity (s fork t) = cong₂ _fork_ (◂-identity s) (◂-identity t)
◂-identity (function fn ts) = cong (function fn) (◂s-identity ts)
◂s-identity : ∀ {N m} (t : Vec (Term m) N) → ε ◂s t ≡ t
◂s-identity [] = refl
◂s-identity (t ∷ ts) = cong₂ _∷_ (◂-identity t) (◂s-identity ts)
∙-left-identity : ∀ {m n} (f : m ⊸ n) → ε ∙ f ≡̇ f
∙-left-identity f = ◂-identity ∘ f
∙-right-identity : ∀ {m n} (f : m ⊸ n) → f ∙ ε ≡̇ f
∙-right-identity _ _ = refl
instance
IsCategory𝕘₁ε : IsCategory 𝕘₁ ε
IsCategory.left-identity IsCategory𝕘₁ε = ∙-left-identity
IsCategory.right-identity IsCategory𝕘₁ε = ∙-right-identity
𝔾₁ : Category _ _ _
𝔾₁ = 𝕘₁ , ε
𝔾₂ : Category _ _ _
𝔾₂ = 𝕘₂ , id
𝔾₂ₛ : Nat → Category _ _ _
𝔾₂ₛ N = 𝕘₂ₛ N , id
𝔾₁,₂ : Categories _ _ _ _ _ _
𝔾₁,₂ = 𝔾₁ , 𝔾₂
𝔾₁,₂ₛ : Nat → Categories _ _ _ _ _ _
𝔾₁,₂ₛ N = 𝔾₁ , 𝔾₂ₛ N
instance
IsFunctor𝔾₁,₂◂ : IsFunctor 𝔾₁,₂ _◂_
IsFunctor.identity IsFunctor𝔾₁,₂◂ _ = ◂-identity
𝔽◂ : Functor _ _ _ _ _ _
𝔽◂ = 𝔾₁,₂ , _◂_
instance
IsFunctor𝔾₁,₂ₛ◂ : ∀ {N} → IsFunctor (𝔾₁,₂ₛ N) (λ ‵ → _◂s_ ‵)
IsFunctor.identity IsFunctor𝔾₁,₂ₛ◂ _ = ◂s-identity -- ◂-identity
𝔽s : Nat → Functor _ _ _ _ _ _
𝔽s N = 𝔾₁,₂ₛ N , (λ ‵ → _◂s_ ‵)
instance
IsCategoryAction𝔾₁𝕒₂◂ : IsCategoryAction 𝔾₁ 𝕒₂ _◂_
IsCategoryAction.identity IsCategoryAction𝔾₁𝕒₂◂ = ◂-identity
IsCategoryAction𝔾₁𝕒₂ₛ◂s : ∀ {N} → IsCategoryAction 𝔾₁ (𝕒₂ₛ N) (λ ‵ → _◂s_ ‵)
IsCategoryAction.identity IsCategoryAction𝔾₁𝕒₂ₛ◂s = ◂s-identity
ℕ◂ : CategoryAction _ _ _ _ _
ℕ◂ = [ 𝔾₁ / 𝕒₂ ] _◂_
ℕ◂s : Nat → CategoryAction _ _ _ _ _
ℕ◂s N = [ 𝔾₁ / 𝕒₂ₛ N ] (λ ‵ → _◂s_ ‵)
|
{
"alphanum_fraction": 0.6256709094,
"avg_line_length": 29.7762557078,
"ext": "agda",
"hexsha": "a108f0c85174309b4c6156f0d09844008a1448b6",
"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-2/Oscar/Data/Term/internal/SubstituteAndSubstitution.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-2/Oscar/Data/Term/internal/SubstituteAndSubstitution.agda",
"max_line_length": 117,
"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-2/Oscar/Data/Term/internal/SubstituteAndSubstitution.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3208,
"size": 6521
}
|
module Lemmachine.Default where
open import Lemmachine
resource : Hooks
resource = []
main = runResolve (toApp resource)
|
{
"alphanum_fraction": 0.7804878049,
"avg_line_length": 15.375,
"ext": "agda",
"hexsha": "3d219df6fed750f6e14b5e7bd801921bc713d36e",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z",
"max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "isabella232/Lemmachine",
"max_forks_repo_path": "src/Lemmachine/Default.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/Lemmachine",
"max_issues_repo_path": "src/Lemmachine/Default.agda",
"max_line_length": 34,
"max_stars_count": 56,
"max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "isabella232/Lemmachine",
"max_stars_repo_path": "src/Lemmachine/Default.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z",
"num_tokens": 27,
"size": 123
}
|
import Lvl
-- TODO: Just testing how it goes with creating an axiomatic system
module Geometry.Test2 (Point : Set(Lvl.𝟎)) where
open import Functional
open import Logic.Propositional{Lvl.𝟎}
open import Logic.Predicate{Lvl.𝟎}{Lvl.𝟎}
open import Relator.Equals{Lvl.𝟎}{Lvl.𝟎}
-- open import Structure.Setoid.Uniqueness{Lvl.𝟎}{Lvl.𝟎}{Lvl.𝟎} hiding (Theorems)
open import Structure.Relator.Equivalence{Lvl.𝟎}{Lvl.𝟎}
open import Structure.Relator.Ordering{Lvl.𝟎}{Lvl.𝟎}
-- open import Structure.Relator.Properties{Lvl.𝟎}{Lvl.𝟎} hiding (Theorems)
-- A line of finite length
record Line : Set(Lvl.𝟎) where
constructor line
field
a : Point
b : Point
-- A circle
record Circle : Set(Lvl.𝟎) where
constructor circle
field
middle : Point
outer : Point
record Theory : Set(Lvl.𝐒(Lvl.𝟎)) where
-- Symbols
field
PointOnLine : Point → Line → Set(Lvl.𝟎) -- The point lies on the line
PointOnCircle : Point → Circle → Set(Lvl.𝟎) -- The point lies on the circle
_≾_ : Line → Line → Set(Lvl.𝟎) -- Comparison of line length
_≿_ : Line → Line → Set(Lvl.𝟎) -- Comparison of line length
_≿_ l₁ l₂ = l₂ ≾ l₁
_≋_ : Line → Line → Set(Lvl.𝟎) -- Equality of line length
_≋_ l₁ l₂ = (l₁ ≾ l₂) ∧ (l₁ ≿ l₂)
-- Axioms
field
[≾]-weak-total-order : Weak.TotalOrder(_≾_)(_≋_) -- (_≾_) is a weak total order
point-on-line-existence : ∀{l : Line} → ∃(p ↦ PointOnLine(p)(l)) -- There is a point on a line
endpoint1-on-line : ∀{l : Line} → PointOnLine(Line.a(l))(l)
endpoint2-on-line : ∀{l : Line} → PointOnLine(Line.b(l))(l)
single-point-line : ∀{p : Point}{x : Point} → PointOnLine(x) (line(p)(p)) → (x ≡ p) -- There is only a simgle point on a line of zero length
point-on-circle-existence : ∀{c : Circle} → ∃(p ↦ PointOnCircle(p)(c)) -- There is a point on a circle
outer-on-circle : ∀{c : Circle} → PointOnCircle(Circle.outer(c))(c)
single-point-circle : ∀{p : Point}{x : Point} → PointOnCircle(x) (circle(p)(p)) → (x ≡ p) -- There is only a simgle point on a circle of zero radius
line-symmetry : ∀{a : Point}{b : Point} → (line(a)(b) ≡ line(b)(a)) -- A line is non-directional
circle-intersection : ∀{a : Point}{b : Point} → ∃(i ↦ PointOnCircle(i)(circle(a)(b)) ∧ PointOnCircle(i)(circle(b)(a))) ∧ ∃(i ↦ PointOnCircle(i)(circle(a)(b)) ∧ PointOnCircle(i)(circle(b)(a)))
module Theorems ⦃ _ : Theory ⦄ where
open Theory ⦃ ... ⦄
-- middlepoint : Line → Point
-- middlepoint(line(a)(b)) =
|
{
"alphanum_fraction": 0.6462474645,
"avg_line_length": 38.515625,
"ext": "agda",
"hexsha": "44b77f2953650c8e6806fa912af8f7bb4044e7d8",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "old/Geometry/Test2.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "old/Geometry/Test2.agda",
"max_line_length": 195,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "old/Geometry/Test2.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": 898,
"size": 2465
}
|
{-# OPTIONS --rewriting #-}
-- Interface to the standard library.
-- Place to add own auxiliary definitions.
module Library where
open import Size public
open import Level public using () renaming (zero to lzero)
open import Data.Unit public using (⊤)
open import Data.Empty public using (⊥; ⊥-elim)
open import Data.Product public using (Σ; ∃; _×_; _,_; proj₁; proj₂; <_,_>; curry; uncurry) renaming (map to map-×)
open import Data.Sum public using (_⊎_; inj₁; inj₂; [_,_]; [_,_]′) renaming (map to map-⊎)
open import Data.List public using (List; []; _∷_) hiding (module List)
open import Data.List.Relation.Unary.All public using (All; []; _∷_) hiding (module All)
open import Data.List.Relation.Unary.Any public using (here; there)
open import Data.List.Membership.Propositional public using (_∈_)
open import Data.List.Relation.Binary.Sublist.Propositional public using (_⊆_; []; _∷_; _∷ʳ_; ⊆-refl; ⊆-trans) renaming (lookup to ⊆-lookup)
open import Function public using (_∘_; _∘′_; id; _$_; _ˢ_; case_of_; const; flip)
open import Relation.Binary.PropositionalEquality public using (_≡_; refl; sym; trans; cong; cong₂; subst; _≗_)
{-# BUILTIN REWRITE _≡_ #-}
module All where
open import Data.List.Relation.Unary.All public
module Any where
open import Data.List.Relation.Unary.Any public
-- open import Axiom.Extensionality.Propositional public using (Extensionality)
-- postulate
-- funExt : ∀{a b} → Extensionality a b -- inline to avoid library incomp.
postulate
funExt : ∀{a b} {A : Set a} {B : A → Set b} {f g : (x : A) → B x}
→ (∀ x → f x ≡ g x)
→ f ≡ g
funExtH : ∀{a b} {A : Set a} {B : A → Set b} {f g : {x : A} → B x}
→ (∀ {x} → f {x} ≡ g {x})
→ (λ {x} → f {x}) ≡ g
⊥-elim-ext : ∀{a b} {A : Set a} {B : Set b} {f : A → ⊥} {g : A → B} → ⊥-elim {b} {B} ∘ f ≡ g
⊥-elim-ext {f = f} = funExt λ a → ⊥-elim (f a)
cong₃ : ∀ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d}
(f : A → B → C → D) {a a' b b' c c'} → a ≡ a' → b ≡ b' → c ≡ c' → f a b c ≡ f a' b' c'
cong₃ f refl refl refl = refl
_×̇_ : ∀{A B C D : Set} → (A → C) → (B → D) → A × B → C × D
(f ×̇ g) (x , y) = f x , g y
-- Application (S-combinator)
apply : ∀{A B C : Set} (f : C → A → B) (d : C → A) → C → B
apply f a = λ c → f c (a c)
-- Kripke application
kapply : ∀{A B C D : Set} (f : C → A → B) (τ : D → C) (d : D → A) → D → B
kapply f τ a = apply (f ∘ τ) a
-- kapply f τ a = λ d → f (τ d) (a d)
caseof : ∀{A B C D : Set} (f : C → A ⊎ B) (g : C × A → D) (h : C × B → D) → C → D
caseof f g h = λ c → [ curry g c , curry h c ]′ (f c)
sum-eta : ∀{A B : Set} (x : A ⊎ B) → [ inj₁ , inj₂ ] x ≡ x
sum-eta (inj₁ x) = refl
sum-eta (inj₂ y) = refl
caseof-eta : ∀{A B C : Set} (f : C → A ⊎ B) → caseof f (inj₁ ∘ proj₂) (inj₂ ∘ proj₂) ≡ f
caseof-eta f = funExt λ c → sum-eta (f c)
sum-perm : ∀{A B C D : Set} (k : C → D) {g : A → C} {h : B → C} (x : A ⊎ B) →
[ k ∘ g , k ∘ h ]′ x ≡ k ([ g , h ]′ x)
sum-perm k (inj₁ x) = refl
sum-perm k (inj₂ y) = refl
caseof-perm' : ∀{A B C D E : Set}
(k : C → D → E) {f : C → A ⊎ B} {g : C × A → D} {h : C × B → D} →
caseof f (apply (k ∘ proj₁) g) (apply (k ∘ proj₁) h)
≡ apply k (caseof f g h)
caseof-perm' k {f} = funExt λ c → sum-perm (k c) (f c)
caseof-perm : ∀{A B C D E : Set} (k : D → E) {f : C → A ⊎ B} {g : C × A → D} {h : C × B → D}
→ caseof f (k ∘ g) (k ∘ h) ≡ k ∘ caseof f g h
caseof-perm = caseof-perm' ∘ const
caseof-wk : ∀{A B C D E : Set} (k : D → C) {f : C → A ⊎ B} {g : C × A → E} {h : C × B → E}
→ caseof (f ∘ k) (g ∘ (k ×̇ id)) (h ∘ (k ×̇ id)) ≡ caseof f g h ∘ k
caseof-wk {A} {B} {C} {D} {E} k {f} {g} {h} = refl
caseof-apply : ∀{A B C D E : Set}
(f : C → A ⊎ B) {g : C × A → D → E} {h : C × B → D → E} (d : C → D)
→ caseof f (apply g (d ∘ proj₁)) (apply h (d ∘ proj₁))
≡ apply (caseof f g h) d
caseof-apply f {g} {h} d = funExt λ c → sum-perm (λ z → z (d c)) {curry g c} {curry h c} (f c)
-- caseof-apply {A} {B} {C} {D} {E} d {f} {g} {h} = funExt λ c → aux (f c)
-- where
-- aux : ∀ {c : C} (w : A ⊎ B) →
-- [ (λ y → curry g c y (d c)) , (λ y → curry h c y (d c)) ]′ w ≡
-- [ curry g c , curry h c ]′ w (d c)
-- aux (inj₁ a) = refl
-- aux (inj₂ b) = refl
-- caseof (f ∘ τ)
-- (apply (g ∘ (τ ×̇ id)) (a ∘ proj₁))
-- (apply (h ∘ (τ ×̇ id)) (a ∘ proj₁))
-- ≡
-- apply (caseof f g h ∘ τ) a
caseof-kapply : ∀{A B C D E F : Set}
(f : C → A ⊎ B) (g : C × A → E → F) (h : C × B → E → F) (τ : D → C) (a : D → E)
→ caseof (f ∘ τ)
(kapply g (τ ×̇ id) (a ∘ proj₁))
(kapply h (τ ×̇ id) (a ∘ proj₁))
≡
kapply (caseof f g h) τ a
caseof-kapply f g h τ a = caseof-apply (f ∘ τ) a
caseof-swap : ∀{A B C D X Y : Set}
(f : C → X ⊎ Y)
(i : C × X → A ⊎ B)
(j : C × Y → A ⊎ B)
(g : C → A → D)
(h : C → B → D) →
caseof f (caseof i (uncurry (g ∘ proj₁)) (uncurry (h ∘ proj₁)))
(caseof j (uncurry (g ∘ proj₁)) (uncurry (h ∘ proj₁)))
≡ caseof (caseof f i j) (uncurry g) (uncurry h)
caseof-swap {A} {B} {C} {D} {X} {Y} f i j g h = funExt λ c →
sum-perm [ (g c) , (h c) ] (f c)
|
{
"alphanum_fraction": 0.500974279,
"avg_line_length": 37.1884057971,
"ext": "agda",
"hexsha": "ccd61d8fc02f1e52bdfc4254521725eacc0c6540",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-02-25T20:39:03.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-11-13T16:01:46.000Z",
"max_forks_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "andreasabel/ipl",
"max_forks_repo_path": "src/Library.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "andreasabel/ipl",
"max_issues_repo_path": "src/Library.agda",
"max_line_length": 142,
"max_stars_count": 19,
"max_stars_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "andreasabel/ipl",
"max_stars_repo_path": "src/Library.agda",
"max_stars_repo_stars_event_max_datetime": "2021-04-27T19:10:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-16T08:08:51.000Z",
"num_tokens": 2259,
"size": 5132
}
|
------------------------------------------------------------------------
-- INCREMENTAL λ-CALCULUS
--
-- The syntax of types with the Nehemiah plugin.
------------------------------------------------------------------------
module Nehemiah.Syntax.Type where
import Parametric.Syntax.Type as Type
data Base : Type.Structure where
base-int : Base
base-bag : Base
open Type.Structure Base public
pattern int = base base-int
pattern bag = base base-bag
|
{
"alphanum_fraction": 0.5131004367,
"avg_line_length": 24.1052631579,
"ext": "agda",
"hexsha": "cc494f6b2d55388c483137bac23a74ecc94ed4bc",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-02-18T12:26:44.000Z",
"max_forks_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "inc-lc/ilc-agda",
"max_forks_repo_path": "Nehemiah/Syntax/Type.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_issues_repo_issues_event_max_datetime": "2017-05-04T13:53:59.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-07-01T18:09:31.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "inc-lc/ilc-agda",
"max_issues_repo_path": "Nehemiah/Syntax/Type.agda",
"max_line_length": 72,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "39bb081c6f192bdb87bd58b4a89291686d2d7d03",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "inc-lc/ilc-agda",
"max_stars_repo_path": "Nehemiah/Syntax/Type.agda",
"max_stars_repo_stars_event_max_datetime": "2019-07-19T07:06:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-03-04T06:09:20.000Z",
"num_tokens": 85,
"size": 458
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Relations between properties of scaling and other operations
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Algebra.Module.Consequences where
open import Algebra.Core using (Op₂; Opₗ; Opᵣ)
import Algebra.Definitions as Defs
open import Algebra.Module.Definitions
open import Function.Base using (flip)
open import Level using (Level)
open import Relation.Binary using (Rel; Setoid)
import Relation.Binary.Reasoning.Setoid as Rea
private
variable
a b c ℓ ℓa : Level
A : Set a
B : Set b
module _ (_≈ᴬ_ : Rel {a} A ℓa) (S : Setoid c ℓ) where
open Setoid S
open Rea S
open Defs _≈ᴬ_
private
module L = LeftDefs A _≈_
module R = RightDefs A _≈_
module B = BiDefs A A _≈_
module _ {_*_ : Op₂ A} {_*ₗ_ : Opₗ A Carrier} where
private
_*ᵣ_ = flip _*ₗ_
*ₗ-assoc+comm⇒*ᵣ-assoc :
L.RightCongruent _≈ᴬ_ _*ₗ_ →
L.Associative _*_ _*ₗ_ → Commutative _*_ → R.Associative _*_ _*ᵣ_
*ₗ-assoc+comm⇒*ᵣ-assoc *ₗ-congʳ *ₗ-assoc *-comm m x y = begin
(m *ᵣ x) *ᵣ y ≈⟨ refl ⟩
y *ₗ (x *ₗ m) ≈˘⟨ *ₗ-assoc _ _ _ ⟩
(y * x) *ₗ m ≈⟨ *ₗ-congʳ (*-comm y x) ⟩
(x * y) *ₗ m ≈⟨ refl ⟩
m *ᵣ (x * y) ∎
*ₗ-assoc+comm⇒*ₗ-*ᵣ-assoc :
L.RightCongruent _≈ᴬ_ _*ₗ_ →
L.Associative _*_ _*ₗ_ → Commutative _*_ → B.Associative _*ₗ_ _*ᵣ_
*ₗ-assoc+comm⇒*ₗ-*ᵣ-assoc *ₗ-congʳ *ₗ-assoc *-comm x m y = begin
((x *ₗ m) *ᵣ y) ≈⟨ refl ⟩
(y *ₗ (x *ₗ m)) ≈˘⟨ *ₗ-assoc _ _ _ ⟩
((y * x) *ₗ m) ≈⟨ *ₗ-congʳ (*-comm y x) ⟩
((x * y) *ₗ m) ≈⟨ *ₗ-assoc _ _ _ ⟩
(x *ₗ (y *ₗ m)) ≈⟨ refl ⟩
(x *ₗ (m *ᵣ y)) ∎
module _ {_*_ : Op₂ A} {_*ᵣ_ : Opᵣ A Carrier} where
private
_*ₗ_ = flip _*ᵣ_
*ᵣ-assoc+comm⇒*ₗ-assoc :
R.LeftCongruent _≈ᴬ_ _*ᵣ_ →
R.Associative _*_ _*ᵣ_ → Commutative _*_ → L.Associative _*_ _*ₗ_
*ᵣ-assoc+comm⇒*ₗ-assoc *ᵣ-congˡ *ᵣ-assoc *-comm x y m = begin
((x * y) *ₗ m) ≈⟨ refl ⟩
(m *ᵣ (x * y)) ≈⟨ *ᵣ-congˡ (*-comm x y) ⟩
(m *ᵣ (y * x)) ≈˘⟨ *ᵣ-assoc _ _ _ ⟩
((m *ᵣ y) *ᵣ x) ≈⟨ refl ⟩
(x *ₗ (y *ₗ m)) ∎
*ᵣ-assoc+comm⇒*ₗ-*ᵣ-assoc :
R.LeftCongruent _≈ᴬ_ _*ᵣ_ →
R.Associative _*_ _*ᵣ_ → Commutative _*_ → B.Associative _*ₗ_ _*ᵣ_
*ᵣ-assoc+comm⇒*ₗ-*ᵣ-assoc *ᵣ-congˡ *ᵣ-assoc *-comm x m y = begin
((x *ₗ m) *ᵣ y) ≈⟨ refl ⟩
((m *ᵣ x) *ᵣ y) ≈⟨ *ᵣ-assoc _ _ _ ⟩
(m *ᵣ (x * y)) ≈⟨ *ᵣ-congˡ (*-comm x y) ⟩
(m *ᵣ (y * x)) ≈˘⟨ *ᵣ-assoc _ _ _ ⟩
((m *ᵣ y) *ᵣ x) ≈⟨ refl ⟩
(x *ₗ (m *ᵣ y)) ∎
|
{
"alphanum_fraction": 0.5001848429,
"avg_line_length": 31.091954023,
"ext": "agda",
"hexsha": "f4b581c5297b91edfa64ed8551b11b76c6e754b9",
"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/Algebra/Module/Consequences.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/Algebra/Module/Consequences.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/Algebra/Module/Consequences.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": 1329,
"size": 2705
}
|
module Module where
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
_+_ : ℕ → ℕ → ℕ
zero + n = zero
suc m + n = suc (m + n)
import Data.Nat using (ℕ; zero; suc; _+_)
|
{
"alphanum_fraction": 0.5542168675,
"avg_line_length": 12.7692307692,
"ext": "agda",
"hexsha": "e8c6d7bf46ef803307ab8ab4307760bf5588811f",
"lang": "Agda",
"max_forks_count": 304,
"max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z",
"max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "manikdv/plfa.github.io",
"max_forks_repo_path": "extra/extra/Module.agda",
"max_issues_count": 323,
"max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4",
"max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z",
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "manikdv/plfa.github.io",
"max_issues_repo_path": "extra/extra/Module.agda",
"max_line_length": 41,
"max_stars_count": 1003,
"max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "manikdv/plfa.github.io",
"max_stars_repo_path": "extra/extra/Module.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z",
"num_tokens": 65,
"size": 166
}
|
-- Andreas, 2015-05-10 Report wrong hiding for copattern
{-# OPTIONS --copatterns #-}
record ⊤ : Set where
record Foo (A : Set) : Set where
field
foo : A
bar : Foo ⊤
Foo.foo {bar} = _
-- Error WAS: Unexpected implicit argument
-- Better error:
-- Wrong hiding used for projection Foo.foo
-- when checking that the clause Foo.foo {bar} = _ has type Foo ⊤
|
{
"alphanum_fraction": 0.6657608696,
"avg_line_length": 19.3684210526,
"ext": "agda",
"hexsha": "6a077139e6fa8cd02f9a9712779988487dd5d08f",
"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/Issue1413WrongHiding.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/Issue1413WrongHiding.agda",
"max_line_length": 65,
"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/Issue1413WrongHiding.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": 105,
"size": 368
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Basic definitions for Characters
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Char.Base where
open import Level using (zero)
import Data.Nat.Base as ℕ
open import Function
open import Relation.Binary using (Rel)
open import Relation.Binary.PropositionalEquality
------------------------------------------------------------------------
-- Re-export the type, and renamed primitives
open import Agda.Builtin.Char public using ( Char )
renaming
-- testing
( primIsLower to isLower
; primIsDigit to isDigit
; primIsAlpha to isAlpha
; primIsSpace to isSpace
; primIsAscii to isAscii
; primIsLatin1 to isLatin1
; primIsPrint to isPrint
; primIsHexDigit to isHexDigit
-- transforming
; primToUpper to toUpper
; primToLower to toLower
-- converting
; primCharToNat to toℕ
; primNatToChar to fromℕ
)
open import Agda.Builtin.String public using ()
renaming ( primShowChar to show )
infix 4 _≈_
_≈_ : Rel Char zero
_≈_ = _≡_ on toℕ
infix 4 _<_
_<_ : Rel Char zero
_<_ = ℕ._<_ on toℕ
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 1.1
toNat = toℕ
{-# WARNING_ON_USAGE toNat
"Warning: toNat was deprecated in v1.1.
Please use toℕ instead."
#-}
fromNat = fromℕ
{-# WARNING_ON_USAGE fromNat
"Warning: fromNat was deprecated in v1.1.
Please use fromℕ instead."
#-}
|
{
"alphanum_fraction": 0.5653689715,
"avg_line_length": 24.9420289855,
"ext": "agda",
"hexsha": "3e58c1bcc113c8195dcb325aaacbd839e829a7e6",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/Char/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/Char/Base.agda",
"max_line_length": 72,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/Char/Base.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 414,
"size": 1721
}
|
{-# OPTIONS --without-K --safe #-}
private
variable
A : Set
a : A
variable
A : Set
private
A = B
where
B = Set
|
{
"alphanum_fraction": 0.5303030303,
"avg_line_length": 10.1538461538,
"ext": "agda",
"hexsha": "834247dc3945937ff365a98bef84d9c3e19cfb3f",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2021-03-12T21:33:35.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-10-07T01:38:12.000Z",
"max_forks_repo_head_hexsha": "ee25a3a81dacebfe4449de7a9aaff029171456be",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "dubinsky/intellij-dtlc",
"max_forks_repo_path": "testData/parse/agda/complex-nested-layouts.agda",
"max_issues_count": 16,
"max_issues_repo_head_hexsha": "ee25a3a81dacebfe4449de7a9aaff029171456be",
"max_issues_repo_issues_event_max_datetime": "2021-03-15T17:04:36.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-03-30T04:29:32.000Z",
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "dubinsky/intellij-dtlc",
"max_issues_repo_path": "testData/parse/agda/complex-nested-layouts.agda",
"max_line_length": 34,
"max_stars_count": 30,
"max_stars_repo_head_hexsha": "ee25a3a81dacebfe4449de7a9aaff029171456be",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "dubinsky/intellij-dtlc",
"max_stars_repo_path": "testData/parse/agda/complex-nested-layouts.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-29T13:18:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-05-11T16:26:38.000Z",
"num_tokens": 45,
"size": 132
}
|
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Instance.Properties.Setoids.Choice where
open import Categories.Category using (Category)
open import Categories.Category.Exact using (Exact)
open import Categories.Category.Instance.Setoids using (Setoids)
open import Data.Product using (∃; proj₁; proj₂; _,_; Σ-syntax; _×_; -,_; map; zip; swap; map₂)
open import Data.Sum using (_⊎_; inj₁; inj₂)
open import Function.Equality as SΠ using (Π; _⇨_) renaming (id to ⟶-id; _∘_ to _∘⟶_)
open import Level
open import Relation.Binary using (Setoid; Rel; REL; IsEquivalence)
import Relation.Binary.Reasoning.Setoid as SR
open import Data.Nat.Base
import Relation.Binary.PropositionalEquality.Core as P
open Setoid renaming (_≈_ to [_][_≈_]; Carrier to ∣_∣) using (isEquivalence; refl; sym; trans)
open Π using (_⟨$⟩_; cong)
module _ ℓ where
private
S = Setoids ℓ ℓ
open Category S hiding (_≈_)
module S = Category S
open import Categories.Category.Instance.Properties.Setoids.Exact
open import Categories.Object.InternalRelation using (Relation)
-- Presentation axiom, aka CoSHEP (http://nlab-pages.s3.us-east-2.amazonaws.com/nlab/show/presentation+axiom)
record CoSHEP (A : Setoid ℓ ℓ) : Set (Level.suc ℓ) where
field
{P} : Setoid ℓ ℓ
pre : P ⇒ A
surj : SSurj ℓ pre
split : {X : Setoid ℓ ℓ} (f : X ⇒ P) → SSurj ℓ f → Σ[ g ∈ ∣ P ⇨ X ∣ ] [ P ⇨ P ][ f ∘ g ≈ id ]
Setoid-CoSHEP : (A : Setoid ℓ ℓ) → CoSHEP A
Setoid-CoSHEP A = record
{ P = record
{ Carrier = ∣ A ∣
; _≈_ = P._≡_
; isEquivalence = record { refl = P.refl ; sym = P.sym ; trans = P.trans }
}
; pre = record
{ _⟨$⟩_ = λ x → x
; cong = λ {x} eq → P.subst (λ z → [ A ][ x ≈ z ]) eq (refl A)
}
; surj = λ x → x , refl A
; split = λ {X} f surj → record
{ _⟨$⟩_ = λ y → let x , _ = surj y in x
; cong = λ {x}{y} x≡y → P.subst (λ z → [ X ][ proj₁ (surj x) ≈ proj₁ (surj z) ]) x≡y (refl X)
}
, λ {x}{y} x≡y → let z , eq = surj x in P.trans eq x≡y
}
entire : {A B : Setoid ℓ ℓ} → (R : Relation S A B) → Set ℓ
entire {A} R = ∀ (x : ∣ A ∣) → Σ[ e ∈ ∣ dom ∣ ] [ A ][ p₁ ⟨$⟩ e ≈ x ]
where open Relation R
ℕ-Setoid : Setoid ℓ ℓ
ℕ-Setoid = record { Carrier = Lift _ ℕ ; _≈_ = P._≡_ ; isEquivalence = record { refl = P.refl ; sym = P.sym ; trans = P.trans } }
record DepChoice {A : Setoid ℓ ℓ} (R : Relation S A A) (inhb : ∣ A ∣) (ent : entire R) : Set (Level.suc ℓ) where
open Relation R
field
pair : ℕ → ∣ dom ∣
chain : ∀ (n : ℕ) → [ A ][ p₁ ⟨$⟩ pair (ℕ.suc n) ≈ p₂ ⟨$⟩ pair n ]
-- Dependent choice for setoids
Setoid-DepChoice : {A : Setoid ℓ ℓ} (R : Relation S A A) (inhb : ∣ A ∣) (ent : entire R) → DepChoice R inhb ent
Setoid-DepChoice {A} R inhb ent = record
{ pair = pair
; chain = chain
}
where
open Relation R
pair : ℕ → ∣ dom ∣
pair ℕ.zero = proj₁ (ent inhb)
pair (ℕ.suc n) = let x , _ = ent (p₂ ⟨$⟩ pair n) in x
chain : (n : ℕ) → [ A ][ p₁ ⟨$⟩ proj₁ (ent (p₂ ⟨$⟩ pair n)) ≈ p₂ ⟨$⟩ pair n ]
chain ℕ.zero = let _ , eq = ent (p₂ ⟨$⟩ proj₁ (ent inhb)) in eq
chain (ℕ.suc n) = let x , eq = ent (p₂ ⟨$⟩ proj₁ (ent (p₂ ⟨$⟩ pair n))) in eq
-- Countable choice for setoids
ℕ-Choice : ∀ {A : Setoid ℓ ℓ} (f : A ⇒ ℕ-Setoid) → SSurj ℓ f → Σ[ g ∈ ∣ ℕ-Setoid ⇨ A ∣ ] [ ℕ-Setoid ⇨ ℕ-Setoid ][ f ∘ g ≈ id ]
ℕ-Choice {A} f surj = record
{ _⟨$⟩_ = λ n → let x , eq = surj n in x
; cong = λ {n}{m} eq → let x , _ = surj n; y , _ = surj m in P.subst (λ m → [ A ][ proj₁ (surj n) ≈ proj₁ (surj m) ]) eq (refl A)
}
, λ {n}{m} n≡m → let _ , eq = surj n in P.trans eq n≡m
|
{
"alphanum_fraction": 0.5507246377,
"avg_line_length": 39.1237113402,
"ext": "agda",
"hexsha": "8cb94825b2d9ffc25a451429c7a3a953247a2404",
"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": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Instance/Properties/Setoids/Choice.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"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": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Instance/Properties/Setoids/Choice.agda",
"max_line_length": 134,
"max_stars_count": 5,
"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/Properties/Setoids/Choice.agda",
"max_stars_repo_stars_event_max_datetime": "2019-05-22T03:54:24.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-05-21T17:07:19.000Z",
"num_tokens": 1440,
"size": 3795
}
|
------------------------------------------------------------------------
-- Properties of functions
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe --exact-split #-}
module Math.Combinatorics.ListFunction.Properties where
-- agda-stdlib
open import Data.List hiding (_∷ʳ_)
import Data.List.Properties as Lₚ
open import Data.List.Membership.Propositional using (_∈_; _∉_)
import Data.List.Membership.Propositional.Properties as ∈ₚ
open import Data.List.Relation.Binary.BagAndSetEquality
open import Data.List.Relation.Binary.Sublist.Propositional using (_⊆_; []; _∷_; _∷ʳ_)
import Data.List.Relation.Binary.Sublist.Propositional.Properties as Sublistₚ
open import Data.List.Relation.Unary.All as All using (All; []; _∷_)
import Data.List.Relation.Unary.All.Properties as Allₚ
open import Data.List.Relation.Unary.AllPairs using (AllPairs; []; _∷_)
open import Data.List.Relation.Unary.Any as Any using (Any; here; there)
import Data.List.Relation.Unary.Unique.Propositional as UniqueP
import Data.List.Relation.Unary.Unique.Propositional.Properties as UniquePₚ
import Data.List.Relation.Unary.Unique.Setoid as UniqueS
import Data.List.Relation.Unary.Unique.Setoid.Properties as UniqueSₚ
open import Data.Nat
open import Data.Product as Prod using (_×_; _,_; ∃; proj₁; proj₂)
open import Data.Sum using (inj₁; inj₂)
open import Function.Base
open import Function.Equivalence using (_⇔_; equivalence) -- TODO: use new packages
open import Relation.Binary.PropositionalEquality as P
-- agda-combinatorics
open import Math.Combinatorics.Function
open import Math.Combinatorics.Function.Properties
open import Math.Combinatorics.ListFunction
import Math.Combinatorics.ListFunction.Properties.Lemma as Lemma
------------------------------------------------------------------------
-- Properties of `applyEach`
module _ {a} {A : Set a} where
open ≡-Reasoning
length-applyEach : ∀ (f : A → A) (xs : List A) →
length (applyEach f xs) ≡ length xs
length-applyEach f [] = refl
length-applyEach f (x ∷ xs) = begin
1 + length (map (x ∷_) (applyEach f xs))
≡⟨ cong suc $ Lₚ.length-map (x ∷_) (applyEach f xs ) ⟩
1 + length (applyEach f xs)
≡⟨ cong suc $ length-applyEach f xs ⟩
1 + length xs
∎
All-length-applyEach : ∀ (f : A → A) (xs : List A) →
All (λ ys → length ys ≡ length xs) (applyEach f xs)
All-length-applyEach f [] = []
All-length-applyEach f (x ∷ xs) =
refl ∷ (Allₚ.map⁺ $ All.map (cong suc) $ All-length-applyEach f xs)
applyEach-cong : ∀ (f g : A → A) (xs : List A) →
(∀ x → f x ≡ g x) → applyEach f xs ≡ applyEach g xs
applyEach-cong f g [] f≡g = refl
applyEach-cong f g (x ∷ xs) f≡g = begin
(f x ∷ xs) ∷ map (_∷_ x) (applyEach f xs)
≡⟨ cong₂ (λ u v → (u ∷ xs) ∷ map (_∷_ x) v) (f≡g x) (applyEach-cong f g xs f≡g) ⟩
(g x ∷ xs) ∷ map (_∷_ x) (applyEach g xs)
∎
------------------------------------------------------------------------
-- Properties of `combinations`
module _ {a} {A : Set a} where
open ≡-Reasoning
length-combinations : ∀ (k : ℕ) (xs : List A) →
length (combinations k xs) ≡ C (length xs) k
length-combinations 0 xs = refl
length-combinations (suc k) [] = refl
length-combinations (suc k) (x ∷ xs) = begin
length (map (x ∷_) (combinations k xs) ++ combinations (suc k) xs)
≡⟨ Lₚ.length-++ (map (x ∷_) (combinations k xs)) ⟩
length (map (x ∷_) (combinations k xs)) + length (combinations (suc k) xs)
≡⟨ cong₂ _+_ (Lₚ.length-map (x ∷_) (combinations k xs)) refl ⟩
length (combinations k xs) + length (combinations (suc k) xs)
≡⟨ cong₂ _+_ (length-combinations k xs) (length-combinations (suc k) xs) ⟩
C (length xs) k + C (length xs) (suc k)
≡⟨ sym $ C[1+n,1+k]≡C[n,k]+C[n,1+k] (length xs) k ⟩
C (length (x ∷ xs)) (suc k)
∎
All-length-combinations : ∀ (k : ℕ) (xs : List A) →
All (λ ys → length ys ≡ k) (combinations k xs)
All-length-combinations 0 xs = refl ∷ []
All-length-combinations (suc k) [] = []
All-length-combinations (suc k) (x ∷ xs) =
Allₚ.++⁺ (Allₚ.map⁺ $ All.map (cong suc) $ All-length-combinations k xs)
(All-length-combinations (suc k) xs)
∈-length-combinations : ∀ (xs : List A) k ys → xs ∈ combinations k ys → length xs ≡ k
∈-length-combinations xs k ys xs∈combinations[k,ys] =
All.lookup (All-length-combinations k ys) xs∈combinations[k,ys]
combinations-⊆⇒∈ : ∀ {xs ys : List A} → xs ⊆ ys → xs ∈ combinations (length xs) ys
combinations-⊆⇒∈ {[]} {ys} xs⊆ys = here refl
combinations-⊆⇒∈ {x ∷ xs} {y ∷ ys} (.y ∷ʳ x∷xs⊆ys) =
∈ₚ.∈-++⁺ʳ (map (y ∷_) (combinations (length xs) ys)) (combinations-⊆⇒∈ x∷xs⊆ys)
combinations-⊆⇒∈ {x ∷ xs} {.x ∷ ys} (refl ∷ xs⊆ys) =
∈ₚ.∈-++⁺ˡ $ ∈ₚ.∈-map⁺ (x ∷_) $ combinations-⊆⇒∈ xs⊆ys
combinations-∈⇒⊆ : ∀ {xs ys : List A} → xs ∈ combinations (length xs) ys → xs ⊆ ys
combinations-∈⇒⊆ {[]} {ys} _ = Lemma.[]⊆xs ys
combinations-∈⇒⊆ {x ∷ xs} {y ∷ ys} x∷xs∈c[len[x∷xs],y∷ys]
with ∈ₚ.∈-++⁻ (map (y ∷_) (combinations (length xs) ys)) x∷xs∈c[len[x∷xs],y∷ys]
... | inj₁ x∷xs∈map[y∷-][c[len[xs],ys]]
with ∈ₚ.∈-map⁻ (y ∷_) x∷xs∈map[y∷-][c[len[xs],ys]] -- ∷ ∃ λ zs → zs ∈ combinations (length xs) ys × x ∷ xs ≡ y ∷ zs
combinations-∈⇒⊆ {x ∷ xs} {y ∷ ys} _ | inj₁ _
| zs , (zs∈c[len[xs],ys] , x∷xs≡y∷zs) = x≡y ∷ xs⊆ys
where
xs≡zs : xs ≡ zs
xs≡zs = Lₚ.∷-injectiveʳ x∷xs≡y∷zs
x≡y : x ≡ y
x≡y = Lₚ.∷-injectiveˡ x∷xs≡y∷zs
xs⊆ys : xs ⊆ ys
xs⊆ys = combinations-∈⇒⊆ $ subst (λ v → v ∈ combinations (length xs) ys)
(sym xs≡zs) zs∈c[len[xs],ys]
combinations-∈⇒⊆ {x ∷ xs} {y ∷ ys} _ | inj₂ x∷xs∈c[len[x∷xs],ys] = y ∷ʳ x∷xs⊆ys
where
x∷xs⊆ys : x ∷ xs ⊆ ys
x∷xs⊆ys = combinations-∈⇒⊆ x∷xs∈c[len[x∷xs],ys]
combinations-∈⇔⊆ : ∀ {xs ys : List A} → (xs ∈ combinations (length xs) ys) ⇔ (xs ⊆ ys)
combinations-∈⇔⊆ = equivalence combinations-∈⇒⊆ combinations-⊆⇒∈
All-⊆-combinations : ∀ k (xs : List A) → All (_⊆ xs) (combinations k xs)
All-⊆-combinations k xs = All.tabulate λ {ys} ys∈combinations[k,xs] →
combinations-∈⇒⊆ $ subst (λ v → ys ∈ combinations v xs)
(sym $ ∈-length-combinations ys k xs ys∈combinations[k,xs])
ys∈combinations[k,xs]
combinations-∈⇒⊆∧length : ∀ {xs : List A} {k ys} →
xs ∈ combinations k ys → (xs ⊆ ys × length xs ≡ k)
combinations-∈⇒⊆∧length {xs} {k} {ys} xs∈c[k,ys] =
combinations-∈⇒⊆ xs∈c[len[xs],ys] , length[xs]≡k
where
length[xs]≡k : length xs ≡ k
length[xs]≡k = ∈-length-combinations xs k ys xs∈c[k,ys]
xs∈c[len[xs],ys] : xs ∈ combinations (length xs) ys
xs∈c[len[xs],ys] =
subst (λ v → xs ∈ combinations v ys) (sym length[xs]≡k) xs∈c[k,ys]
combinations-⊆∧length⇒∈ : ∀ {xs ys : List A} {k} →
(xs ⊆ ys × length xs ≡ k) → xs ∈ combinations k ys
combinations-⊆∧length⇒∈ {xs} {ys} {k} (xs⊆ys , len[xs]≡k) =
subst (λ v → xs ∈ combinations v ys) len[xs]≡k (combinations-⊆⇒∈ xs⊆ys)
combinations-∈⇔⊆∧length : ∀ {xs : List A} {k} {ys} →
xs ∈ combinations k ys ⇔ (xs ⊆ ys × length xs ≡ k)
combinations-∈⇔⊆∧length =
equivalence combinations-∈⇒⊆∧length combinations-⊆∧length⇒∈
unique-combinations : ∀ k {xs : List A} →
UniqueP.Unique xs → UniqueP.Unique (combinations k xs)
unique-combinations 0 {xs} xs-unique = [] ∷ []
unique-combinations (suc k) {[]} xs-unique = []
unique-combinations (suc k) {x ∷ xs} (All[x≢-]xs ∷ xs-unique) =
UniquePₚ.++⁺ {_} {_} {map (x ∷_) (combinations k xs)} {combinations (suc k) xs}
(UniquePₚ.map⁺ Lₚ.∷-injectiveʳ (unique-combinations k {xs} xs-unique))
(unique-combinations (suc k) {xs} xs-unique)
λ {vs} vs∈map[x∷-]c[k,xs]×vs∈c[1+k,xs] →
let
vs∈map[x∷-]c[k,xs] = proj₁ vs∈map[x∷-]c[k,xs]×vs∈c[1+k,xs]
vs∈c[1+k,xs] = proj₂ vs∈map[x∷-]c[k,xs]×vs∈c[1+k,xs]
proof = ∈ₚ.∈-map⁻ (x ∷_) vs∈map[x∷-]c[k,xs]
us = proj₁ proof
vs≡x∷us : vs ≡ x ∷ us
vs≡x∷us = proj₂ (proj₂ proof)
x∈vs : x ∈ vs
x∈vs = subst (x ∈_) (sym vs≡x∷us) (here refl)
vs⊆xs : vs ⊆ xs
vs⊆xs = proj₁ $ combinations-∈⇒⊆∧length {vs} {suc k} {xs} vs∈c[1+k,xs]
All[x≢-]vs : All (x ≢_) vs
All[x≢-]vs = Sublistₚ.All-resp-⊆ vs⊆xs All[x≢-]xs
x∉vs : x ∉ vs
x∉vs = Allₚ.All¬⇒¬Any All[x≢-]vs
in x∉vs x∈vs
{-
-- unique⇒drop-cons-set : ∀ {a} {A : Set a} {x : A} {xs ys} →
unique-combinations-set : ∀ k {xs : List A} →
UniqueP.Unique xs → UniqueS.Unique ([ set ]-Equality A) (combinations k xs)
unique-combinations-set 0 xs-unique = [] ∷ []
unique-combinations-set (suc k) {[]} xs-unique = []
unique-combinations-set (suc k) {x ∷ xs} (this ∷ xs-unique) =
UniqueSₚ.++⁺ ([ set ]-Equality A)
(UniqueSₚ.map⁺ ([ set ]-Equality A) ([ set ]-Equality A) (λ → {! !}) (unique-combinations-set k {xs} xs-unique))
(unique-combinations-set (suc k) {xs} xs-unique)
{! !}
-- {- x∉xs -} Unique -[ set ] xs → Unique -[ set ] (x ∷ xs)
-}
module _ {a b} {A : Set a} {B : Set b} where
combinations-map : ∀ k (f : A → B) (xs : List A) →
combinations k (map f xs) ≡ map (map f) (combinations k xs)
combinations-map 0 f xs = refl
combinations-map (suc k) f [] = refl
combinations-map (suc k) f (x ∷ xs) = begin
map (f x ∷_) (combinations k (map f xs)) ++ combinations (suc k) (map f xs)
≡⟨ cong₂ _++_ (cong (map (f x ∷_)) (combinations-map k f xs)) (combinations-map (suc k) f xs) ⟩
map (f x ∷_) (map (map f) (combinations k xs)) ++ map (map f) (combinations (suc k) xs)
≡⟨ cong (_++ map (map f) (combinations (suc k) xs)) $ Lemma.lemma₁ f x (combinations k xs) ⟩
map (map f) (map (x ∷_) (combinations k xs)) ++ map (map f) (combinations (suc k) xs)
≡⟨ sym $ Lₚ.map-++-commute (map f) (map (x ∷_) (combinations k xs)) (combinations (suc k) xs) ⟩
map (map f) (map (x ∷_) (combinations k xs) ++ combinations (suc k) xs)
∎
where open ≡-Reasoning
------------------------------------------------------------------------
-- Properties of `combinationsWithComplement`
module _ {a} {A : Set a} where
open ≡-Reasoning
map-proj₁-combinationsWithComplement : ∀ k (xs : List A) →
map proj₁ (combinationsWithComplement k xs) ≡ combinations k xs
map-proj₁-combinationsWithComplement 0 xs = refl
map-proj₁-combinationsWithComplement (suc k) [] = refl
map-proj₁-combinationsWithComplement (suc k) (x ∷ xs) = begin
map proj₁ (map f ys ++ map g zs)
≡⟨ Lₚ.map-++-commute proj₁ (map f ys) (map g zs) ⟩
map proj₁ (map f ys) ++ map proj₁ (map g zs)
≡⟨ sym $ Lₚ.map-compose ys ⟨ cong₂ _++_ ⟩ Lₚ.map-compose zs ⟩
map (proj₁ ∘′ f) ys ++ map (λ v → proj₁ (g v)) zs
≡⟨ Lₚ.map-cong lemma₁ ys ⟨ cong₂ _++_ ⟩ Lₚ.map-cong lemma₂ zs ⟩
map ((x ∷_) ∘′ proj₁) ys ++ map proj₁ zs
≡⟨ cong (_++ map proj₁ zs) $ Lₚ.map-compose ys ⟩
map (x ∷_) (map proj₁ ys) ++ map proj₁ zs
≡⟨ cong (map (x ∷_)) (map-proj₁-combinationsWithComplement k xs) ⟨ cong₂ _++_ ⟩ map-proj₁-combinationsWithComplement (suc k) xs ⟩
map (x ∷_) (combinations k xs) ++ combinations (suc k) xs
∎
where
ys = combinationsWithComplement k xs
zs = combinationsWithComplement (suc k) xs
f g : List A × List A → List A × List A
f = Prod.map₁ (x ∷_)
g = Prod.map₂ (x ∷_)
lemma₁ : ∀ (t : List A × List A) → proj₁ (Prod.map₁ (x ∷_) t) ≡ x ∷ proj₁ t
lemma₁ t = Lemma.proj₁-map₁ (x ∷_) t
lemma₂ : ∀ (t : List A × List A) → Lemma.proj₁′ {_} {_} {_} {List A} (Prod.map₂ (x ∷_) t) ≡ proj₁ t
lemma₂ t = Lemma.proj₁-map₂ (x ∷_) t
length-combinationsWithComplement : ∀ k (xs : List A) →
length (combinationsWithComplement k xs) ≡ C (length xs) k
length-combinationsWithComplement k xs = begin
length (combinationsWithComplement k xs)
≡⟨ sym $ Lₚ.length-map proj₁ (combinationsWithComplement k xs) ⟩
length (map proj₁ (combinationsWithComplement k xs))
≡⟨ cong length $ map-proj₁-combinationsWithComplement k xs ⟩
length (combinations k xs)
≡⟨ length-combinations k xs ⟩
C (length xs) k
∎
------------------------------------------------------------------------
-- Properties of `splits₂`
module _ {a} {A : Set a} where
open ≡-Reasoning
open Prod using (map₁; map₂)
length-splits₂ : ∀ (xs : List A) → length (splits₂ xs) ≡ 1 + length xs
length-splits₂ [] = refl
length-splits₂ (x ∷ xs) = begin
1 + length (map (map₁ (x ∷_)) (splits₂ xs))
≡⟨ cong (1 +_) $ Lₚ.length-map (map₁ (x ∷_)) (splits₂ xs) ⟩
1 + length (splits₂ xs)
≡⟨ cong (1 +_) $ length-splits₂ xs ⟩
1 + length (x ∷ xs)
∎
splits₂-defn : ∀ (xs : List A) → splits₂ xs ≡ zip (inits xs) (tails xs)
splits₂-defn [] = refl
splits₂-defn (x ∷ xs) = begin
splits₂ (x ∷ xs) ≡⟨⟩
([] , x ∷ xs) ∷ map (map₁ (x ∷_)) (splits₂ xs)
≡⟨ cong (([] , x ∷ xs) ∷_) (begin
map (map₁ (x ∷_)) (splits₂ xs)
≡⟨ cong (map (map₁ (x ∷_))) $ splits₂-defn xs ⟩
map (map₁ (x ∷_)) (zip is ts)
≡⟨ Lₚ.map-zipWith _,_ (map₁ (x ∷_)) is ts ⟩
zipWith (λ ys zs → map₁ (x ∷_) (ys , zs)) is ts
≡⟨ sym $ Lₚ.zipWith-map _,_ (x ∷_) id is ts ⟩
zip (map (x ∷_) is) (map id ts)
≡⟨ cong (zip (map (x ∷_) is)) $ Lₚ.map-id ts ⟩
zip (map (x ∷_) is) ts
∎) ⟩
([] , x ∷ xs) ∷ zip (map (x ∷_) is) ts
∎
where
is = inits xs
ts = tails xs
All-++-splits₂ : (xs : List A) →
All (Prod.uncurry (λ ys zs → ys ++ zs ≡ xs)) (splits₂ xs)
All-++-splits₂ [] = refl ∷ []
All-++-splits₂ (x ∷ xs) =
All._∷_ refl $ Allₚ.map⁺ $ All.map (cong (x ∷_)) $ All-++-splits₂ xs
splits₂-∈⇒++ : {xs ys zs : List A} → (ys , zs) ∈ splits₂ xs → ys ++ zs ≡ xs
splits₂-∈⇒++ {xs = xs} = All.lookup (All-++-splits₂ xs)
private
[],xs∈splits₂[xs] : (xs : List A) → ([] , xs) ∈ splits₂ xs
[],xs∈splits₂[xs] [] = here refl
[],xs∈splits₂[xs] (x ∷ xs) = here refl
∈-split₂-++ : (xs ys : List A) → (xs , ys) ∈ splits₂ (xs ++ ys)
∈-split₂-++ [] ys = [],xs∈splits₂[xs] ys
∈-split₂-++ (x ∷ xs) ys =
Any.there $ ∈ₚ.∈-map⁺ (map₁ (x ∷_)) $ ∈-split₂-++ xs ys
splits₂-++⇒∈ : {xs ys zs : List A} → xs ++ ys ≡ zs → (xs , ys) ∈ splits₂ zs
splits₂-++⇒∈ {xs} {ys} {zs} xs++ys≡zs =
subst (λ v → (xs , ys) ∈ splits₂ v) xs++ys≡zs (∈-split₂-++ xs ys)
splits₂-∈⇔++ : {xs ys zs : List A} → (xs , ys) ∈ splits₂ zs ⇔ xs ++ ys ≡ zs
splits₂-∈⇔++ = equivalence splits₂-∈⇒++ splits₂-++⇒∈
module _ {a b} {A : Set a} {B : Set b} where
open ≡-Reasoning
{-
splits₂-map : ∀ (f : A → B) (xs : List A) →
splits₂ (map f xs) ≡ map (Prod.map (map f) (map f)) (splits₂ xs)
splits₂-map f [] = refl
splits₂-map f (x ∷ xs) = {! !}
-}
-- length[xs]<k⇒combinations[k,xs]≡[]
-- All-unique-combinations : UniqueP.Unique xs → All (UniqueP.Unique) (combinations k xs)
-- All-unique-combinations-set : UniqueP.Unique xs → All (UniqueS.Unique [ set ]-Equality A) (combinations k xs)
-- unique-combinations-PW : UniqueS.Unique S xs → UniqueS.Unique (Equality S) (combinations k xs)
-- unique-combinations-set : UniqueP.Unique xs → Unique (_-[ set ]_) (combinations k xs)
-- sorted-combinations : Sorted _<_ xs → Sorted {- Lex._<_ _<_ -} (combinations k xs)
-- All-sorted-combinations : Sorted _<_ xs → All (Sorted _<_) (combinations k xs)
-- filter-combinations = filter P ∘ combinations k xs
-- each-disjoint-combinationsWithComplement : Unique zs → (xs , ys) ∈ combinationsWithComplement k zs → Disjoint xs ys
-- combinationsWithComplement-∈⇒⊆ : (xs , ys) ∈ combinationsWithComplement (length xs) zs → xs ⊆ zs × ys ⊆ zs
-- length-splits : length (splits k xs) ≡ C (length xs + k ∸ 1) (length xs)
-- length-partitionsAll : length (partitionsAll xs) ≡ B (length xs)
-- length-insertEverywhere : length (insertEverywhere x xs) ≡ 1 + length xs
-- All-length-insertEverywhere : All (λ ys → length ys ≡ 1 + length xs) (insertEverywhere x xs)
-- length-permutations : length (permutations xs) ≡ length xs !
|
{
"alphanum_fraction": 0.5605802048,
"avg_line_length": 46.6136363636,
"ext": "agda",
"hexsha": "4a5161698d4659779b09b67653f8b924c6f277e7",
"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": "9fafa35c940ff7b893a80120f6a1f22b0a3917b7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "rei1024/agda-combinatorics",
"max_forks_repo_path": "Math/Combinatorics/ListFunction/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9fafa35c940ff7b893a80120f6a1f22b0a3917b7",
"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-combinatorics",
"max_issues_repo_path": "Math/Combinatorics/ListFunction/Properties.agda",
"max_line_length": 135,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "9fafa35c940ff7b893a80120f6a1f22b0a3917b7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "rei1024/agda-combinatorics",
"max_stars_repo_path": "Math/Combinatorics/ListFunction/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2020-04-25T07:25:27.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-06-25T08:24:15.000Z",
"num_tokens": 6328,
"size": 16408
}
|
-- Andreas, 2017-11-01, issue #2824
-- allow built-in pragmas in parametrized modules
data Nat : Set where
zero : Nat
suc : Nat → Nat
module M (A : Set) where
{-# BUILTIN NATURAL Nat #-}
test = 5
|
{
"alphanum_fraction": 0.6394230769,
"avg_line_length": 16,
"ext": "agda",
"hexsha": "fc91c64c8f2d5b2843d32c01f7c571ac3b07fce5",
"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/Issue2824Nat.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/Issue2824Nat.agda",
"max_line_length": 49,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue2824Nat.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": 70,
"size": 208
}
|
open import Common.Prelude
open import Common.Reflection
id : {A : Set} → A → A
id x = x
idTerm : Term
idTerm = lam visible (abs "x" (def (quote id) (arg₁ ∷ arg₂ ∷ [])))
where
arg₁ = arg (argInfo hidden relevant) (def (quote Nat) [])
arg₂ = arg (argInfo visible relevant) (var 0 [])
-- Should fail since idTerm "λ z → id {Nat} z"
id₂ : {A : Set} → A → A
id₂ = unquote (give idTerm)
|
{
"alphanum_fraction": 0.6161616162,
"avg_line_length": 23.2941176471,
"ext": "agda",
"hexsha": "eed96222ac60f133b6decfe2594f9f01640307fa",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue1012.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue1012.agda",
"max_line_length": 66,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue1012.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": 137,
"size": 396
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Categories.Adjoint where
open import Cubical.Foundations.Prelude
open import Cubical.Data.Sigma
open import Cubical.Categories.Category
open import Cubical.Categories.Functor
open import Cubical.Categories.NaturalTransformation
open import Cubical.Foundations.Isomorphism
open Functor
open Iso
open Precategory
{-
==============================================
Overview
==============================================
This module contains two definitions for adjoint
functors, and functions witnessing their
logical (and maybe eventually actual?)
equivalence.
-}
private
variable
ℓC ℓC' ℓD ℓD' : Level
{-
==============================================
Adjoint definitions
==============================================
We provide two alternative definitions for
adjoint functors: the unit-counit
definition, followed by the natural bijection
definition.
-}
module UnitCounit where
-- Adjoint def 1: unit-counit
record _⊣_ {C : Precategory ℓC ℓC'} {D : Precategory ℓD ℓD'} (F : Functor C D) (G : Functor D C)
: Type (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD')) where
field
-- unit
η : 𝟙⟨ C ⟩ ⇒ (funcComp G F)
-- counit
ε : (funcComp F G) ⇒ 𝟙⟨ D ⟩
-- triangle identities
Δ₁ : PathP (λ i → NatTrans (F-lUnit {F = F} i) (F-rUnit {F = F} i))
(seqTransP F-assoc (F ∘ʳ η) (ε ∘ˡ F))
(1[ F ])
Δ₂ : PathP (λ i → NatTrans (F-rUnit {F = G} i) (F-lUnit {F = G} i))
(seqTransP (sym F-assoc) (η ∘ˡ G) (G ∘ʳ ε))
(1[ G ])
{-
Helper function for building unit-counit adjunctions between categories,
using that equality of natural transformations in a category is equality on objects
-}
module _ {ℓC ℓC' ℓD ℓD'}
{C : Precategory ℓC ℓC'} {D : Precategory ℓD ℓD'} {F : Functor C D} {G : Functor D C}
⦃ isCatC : isCategory C ⦄ ⦃ isCatD : isCategory D ⦄
(η : 𝟙⟨ C ⟩ ⇒ (funcComp G F))
(ε : (funcComp F G) ⇒ 𝟙⟨ D ⟩)
(Δ₁ : ∀ c → F ⟪ η ⟦ c ⟧ ⟫ ⋆⟨ D ⟩ ε ⟦ F ⟅ c ⟆ ⟧ ≡ D .id (F ⟅ c ⟆))
(Δ₂ : ∀ d → η ⟦ G ⟅ d ⟆ ⟧ ⋆⟨ C ⟩ G ⟪ ε ⟦ d ⟧ ⟫ ≡ C .id (G ⟅ d ⟆))
where
make⊣ : F ⊣ G
make⊣ ._⊣_.η = η
make⊣ ._⊣_.ε = ε
make⊣ ._⊣_.Δ₁ =
makeNatTransPathP F-lUnit F-rUnit
(funExt λ c → cong (D ._⋆_ (F ⟪ η ⟦ c ⟧ ⟫)) (transportRefl _) ∙ Δ₁ c)
make⊣ ._⊣_.Δ₂ =
makeNatTransPathP F-rUnit F-lUnit
(funExt λ d → cong (C ._⋆_ (η ⟦ G ⟅ d ⟆ ⟧)) (transportRefl _) ∙ Δ₂ d)
module NaturalBijection where
-- Adjoint def 2: natural bijection
record _⊣_ {C : Precategory ℓC ℓC'} {D : Precategory ℓD ℓD'} (F : Functor C D) (G : Functor D C) : Type (ℓ-max (ℓ-max ℓC ℓC') (ℓ-max ℓD ℓD')) where
field
adjIso : ∀ {c d} → Iso (D [ F ⟅ c ⟆ , d ]) (C [ c , G ⟅ d ⟆ ])
infix 40 _♭
infix 40 _♯
_♭ : ∀ {c d} → (D [ F ⟅ c ⟆ , d ]) → (C [ c , G ⟅ d ⟆ ])
(_♭) {_} {_} = adjIso .fun
_♯ : ∀ {c d} → (C [ c , G ⟅ d ⟆ ]) → (D [ F ⟅ c ⟆ , d ])
(_♯) {_} {_} = adjIso .inv
field
adjNatInD : ∀ {c : C .ob} {d d'} (f : D [ F ⟅ c ⟆ , d ]) (k : D [ d , d' ])
→ (f ⋆⟨ D ⟩ k) ♭ ≡ f ♭ ⋆⟨ C ⟩ G ⟪ k ⟫
adjNatInC : ∀ {c' c d} (g : C [ c , G ⟅ d ⟆ ]) (h : C [ c' , c ])
→ (h ⋆⟨ C ⟩ g) ♯ ≡ F ⟪ h ⟫ ⋆⟨ D ⟩ g ♯
{-
==============================================
Proofs of equivalence
==============================================
This first unnamed module provides a function
adj'→adj which takes you from the second
definition to the first.
The second unnamed module does the reverse.
-}
module _ {C : Precategory ℓC ℓC'} {D : Precategory ℓD ℓD'} (F : Functor C D) (G : Functor D C) where
open UnitCounit
open NaturalBijection renaming (_⊣_ to _⊣²_)
module _ (adj : F ⊣² G) where
open _⊣²_ adj
open _⊣_
-- Naturality condition implies that a commutative square in C
-- appears iff the transpose in D is commutative as well
-- Used in adj'→adj
adjNat' : ∀ {c c' d d'} {f : D [ F ⟅ c ⟆ , d ]} {k : D [ d , d' ]}
→ {h : C [ c , c' ]} {g : C [ c' , G ⟅ d' ⟆ ]}
-- commutativity of squares is iff
→ ((f ⋆⟨ D ⟩ k ≡ F ⟪ h ⟫ ⋆⟨ D ⟩ g ♯) → (f ♭ ⋆⟨ C ⟩ G ⟪ k ⟫ ≡ h ⋆⟨ C ⟩ g))
× ((f ♭ ⋆⟨ C ⟩ G ⟪ k ⟫ ≡ h ⋆⟨ C ⟩ g) → (f ⋆⟨ D ⟩ k ≡ F ⟪ h ⟫ ⋆⟨ D ⟩ g ♯))
adjNat' {c} {c'} {d} {d'} {f} {k} {h} {g} = D→C , C→D
where
D→C : (f ⋆⟨ D ⟩ k ≡ F ⟪ h ⟫ ⋆⟨ D ⟩ g ♯) → (f ♭ ⋆⟨ C ⟩ G ⟪ k ⟫ ≡ h ⋆⟨ C ⟩ g)
D→C eq = f ♭ ⋆⟨ C ⟩ G ⟪ k ⟫
≡⟨ sym (adjNatInD _ _) ⟩
((f ⋆⟨ D ⟩ k) ♭)
≡⟨ cong _♭ eq ⟩
(F ⟪ h ⟫ ⋆⟨ D ⟩ g ♯) ♭
≡⟨ sym (cong _♭ (adjNatInC _ _)) ⟩
(h ⋆⟨ C ⟩ g) ♯ ♭
≡⟨ adjIso .rightInv _ ⟩
h ⋆⟨ C ⟩ g
∎
C→D : (f ♭ ⋆⟨ C ⟩ G ⟪ k ⟫ ≡ h ⋆⟨ C ⟩ g) → (f ⋆⟨ D ⟩ k ≡ F ⟪ h ⟫ ⋆⟨ D ⟩ g ♯)
C→D eq = f ⋆⟨ D ⟩ k
≡⟨ sym (adjIso .leftInv _) ⟩
(f ⋆⟨ D ⟩ k) ♭ ♯
≡⟨ cong _♯ (adjNatInD _ _) ⟩
(f ♭ ⋆⟨ C ⟩ G ⟪ k ⟫) ♯
≡⟨ cong _♯ eq ⟩
(h ⋆⟨ C ⟩ g) ♯
≡⟨ adjNatInC _ _ ⟩
F ⟪ h ⟫ ⋆⟨ D ⟩ g ♯
∎
open NatTrans
-- note : had to make this record syntax because termination checker was complaining
-- due to referencing η and ε from the definitions of Δs
adj'→adj : ⦃ isCatC : isCategory C ⦄ ⦃ isCatD : isCategory D ⦄ → F ⊣ G
adj'→adj = record
{ η = η'
; ε = ε'
; Δ₁ = Δ₁'
; Δ₂ = Δ₂' }
where
-- ETA
-- trivial commutative diagram between identities in D
commInD : ∀ {x y} (f : C [ x , y ]) → (D .id _) ⋆⟨ D ⟩ F ⟪ f ⟫ ≡ F ⟪ f ⟫ ⋆⟨ D ⟩ (D .id _)
commInD f = (D .⋆IdL _) ∙ sym (D .⋆IdR _)
sharpen1 : ∀ {x y} (f : C [ x , y ]) → F ⟪ f ⟫ ⋆⟨ D ⟩ (D .id _) ≡ F ⟪ f ⟫ ⋆⟨ D ⟩ (D .id _) ♭ ♯
sharpen1 f = cong (λ v → F ⟪ f ⟫ ⋆⟨ D ⟩ v) (sym (adjIso .leftInv _))
η' : 𝟙⟨ C ⟩ ⇒ G ∘F F
η' .N-ob x = (D .id _) ♭
η' .N-hom f = sym (fst (adjNat') (commInD f ∙ sharpen1 f))
-- EPSILON
-- trivial commutative diagram between identities in C
commInC : ∀ {x y} (g : D [ x , y ]) → (C .id _) ⋆⟨ C ⟩ G ⟪ g ⟫ ≡ G ⟪ g ⟫ ⋆⟨ C ⟩ (C .id _)
commInC g = (C .⋆IdL _) ∙ sym (C .⋆IdR _)
sharpen2 : ∀ {x y} (g : D [ x , y ]) → (C .id _ ♯ ♭) ⋆⟨ C ⟩ G ⟪ g ⟫ ≡ (C .id _) ⋆⟨ C ⟩ G ⟪ g ⟫
sharpen2 g = cong (λ v → v ⋆⟨ C ⟩ G ⟪ g ⟫) (adjIso .rightInv _)
ε' : F ∘F G ⇒ 𝟙⟨ D ⟩
ε' .N-ob x = (C .id _) ♯
ε' .N-hom g = sym (snd adjNat' (sharpen2 g ∙ commInC g))
-- DELTA 1
expL : ∀ (c)
→ (seqTransP F-assoc (F ∘ʳ η') (ε' ∘ˡ F) .N-ob c)
≡ F ⟪ η' ⟦ c ⟧ ⟫ ⋆⟨ D ⟩ ε' ⟦ F ⟅ c ⟆ ⟧
expL c = seqTransP F-assoc (F ∘ʳ η') (ε' ∘ˡ F) .N-ob c
≡⟨ refl ⟩
seqP {C = D} {p = refl} (F ⟪ η' ⟦ c ⟧ ⟫) (ε' ⟦ F ⟅ c ⟆ ⟧)
≡⟨ seqP≡seq {C = D} _ _ ⟩
F ⟪ η' ⟦ c ⟧ ⟫ ⋆⟨ D ⟩ ε' ⟦ F ⟅ c ⟆ ⟧
∎
body : ∀ (c)
→ (idTrans F) ⟦ c ⟧ ≡ (seqTransP F-assoc (F ∘ʳ η') (ε' ∘ˡ F) .N-ob c)
body c = (idTrans F) ⟦ c ⟧
≡⟨ refl ⟩
D .id _
≡⟨ sym (D .⋆IdL _) ⟩
D .id _ ⋆⟨ D ⟩ D .id _
≡⟨ snd adjNat' (cong (λ v → (η' ⟦ c ⟧) ⋆⟨ C ⟩ v) (G .F-id)) ⟩
F ⟪ η' ⟦ c ⟧ ⟫ ⋆⟨ D ⟩ ε' ⟦ F ⟅ c ⟆ ⟧
≡⟨ sym (expL c) ⟩
seqTransP F-assoc (F ∘ʳ η') (ε' ∘ˡ F) .N-ob c
∎
Δ₁' : PathP (λ i → NatTrans (F-lUnit {F = F} i) (F-rUnit {F = F} i))
(seqTransP F-assoc (F ∘ʳ η') (ε' ∘ˡ F))
(1[ F ])
Δ₁' = makeNatTransPathP F-lUnit F-rUnit (sym (funExt body))
-- DELTA 2
body2 : ∀ (d)
→ seqP {C = C} {p = refl} ((η' ∘ˡ G) ⟦ d ⟧) ((G ∘ʳ ε') ⟦ d ⟧) ≡ C .id (G .F-ob d)
body2 d = seqP {C = C} {p = refl} ((η' ∘ˡ G) ⟦ d ⟧) ((G ∘ʳ ε') ⟦ d ⟧)
≡⟨ seqP≡seq {C = C} _ _ ⟩
((η' ∘ˡ G) ⟦ d ⟧) ⋆⟨ C ⟩ ((G ∘ʳ ε') ⟦ d ⟧)
≡⟨ refl ⟩
(η' ⟦ G ⟅ d ⟆ ⟧) ⋆⟨ C ⟩ (G ⟪ ε' ⟦ d ⟧ ⟫)
≡⟨ fst adjNat' (cong (λ v → v ⋆⟨ D ⟩ (ε' ⟦ d ⟧)) (sym (F .F-id))) ⟩
C .id _ ⋆⟨ C ⟩ C .id _
≡⟨ C .⋆IdL _ ⟩
C .id (G .F-ob d)
∎
Δ₂' : PathP (λ i → NatTrans (F-rUnit {F = G} i) (F-lUnit {F = G} i))
(seqTransP (sym F-assoc) (η' ∘ˡ G) (G ∘ʳ ε'))
(1[ G ])
Δ₂' = makeNatTransPathP F-rUnit F-lUnit (funExt body2)
module _ (adj : F ⊣ G) where
open _⊣_ adj
open _⊣²_
open NatTrans
-- helper functions for working with this Adjoint definition
δ₁ : ∀ {c} → (F ⟪ η ⟦ c ⟧ ⟫ ⋆⟨ D ⟩ ε ⟦ F ⟅ c ⟆ ⟧) ≡ D .id _
δ₁ {c} = (F ⟪ η ⟦ c ⟧ ⟫ ⋆⟨ D ⟩ ε ⟦ F ⟅ c ⟆ ⟧)
≡⟨ sym (seqP≡seq {C = D} _ _) ⟩
seqP {C = D} {p = refl} (F ⟪ η ⟦ c ⟧ ⟫) (ε ⟦ F ⟅ c ⟆ ⟧)
≡⟨ (λ j → (Δ₁ j) .N-ob c) ⟩
D .id _
∎
δ₂ : ∀ {d} → (η ⟦ G ⟅ d ⟆ ⟧ ⋆⟨ C ⟩ G ⟪ ε ⟦ d ⟧ ⟫) ≡ C .id _
δ₂ {d} = (η ⟦ G ⟅ d ⟆ ⟧ ⋆⟨ C ⟩ G ⟪ ε ⟦ d ⟧ ⟫)
≡⟨ sym (seqP≡seq {C = C} _ _) ⟩
seqP {C = C} {p = refl} (η ⟦ G ⟅ d ⟆ ⟧) (G ⟪ ε ⟦ d ⟧ ⟫)
≡⟨ (λ j → (Δ₂ j) .N-ob d) ⟩
C .id _
∎
adj→adj' : F ⊣² G
-- ∀ {c d} → Iso (D [ F ⟅ c ⟆ , d ]) (C [ c , G ⟅ d ⟆ ])
-- takes f to Gf precomposed with the unit
adj→adj' .adjIso {c = c} .fun f = η ⟦ c ⟧ ⋆⟨ C ⟩ G ⟪ f ⟫
-- takes g to Fg postcomposed with the counit
adj→adj' .adjIso {d = d} .inv g = F ⟪ g ⟫ ⋆⟨ D ⟩ ε ⟦ d ⟧
-- invertibility follows from the triangle identities
adj→adj' .adjIso {c = c} {d} .rightInv g
= η ⟦ c ⟧ ⋆⟨ C ⟩ G ⟪ F ⟪ g ⟫ ⋆⟨ D ⟩ ε ⟦ d ⟧ ⟫ -- step0 ∙ step1 ∙ step2 ∙ (C .⋆IdR _)
≡⟨ cong (λ v → η ⟦ c ⟧ ⋆⟨ C ⟩ v) (G .F-seq _ _) ⟩
η ⟦ c ⟧ ⋆⟨ C ⟩ (G ⟪ F ⟪ g ⟫ ⟫ ⋆⟨ C ⟩ G ⟪ ε ⟦ d ⟧ ⟫)
≡⟨ sym (C .⋆Assoc _ _ _) ⟩
η ⟦ c ⟧ ⋆⟨ C ⟩ G ⟪ F ⟪ g ⟫ ⟫ ⋆⟨ C ⟩ G ⟪ ε ⟦ d ⟧ ⟫
-- apply naturality
≡⟨ rPrecatWhisker {C = C} _ _ _ natu ⟩
(g ⋆⟨ C ⟩ η ⟦ G ⟅ d ⟆ ⟧) ⋆⟨ C ⟩ G ⟪ ε ⟦ d ⟧ ⟫
≡⟨ C .⋆Assoc _ _ _ ⟩
g ⋆⟨ C ⟩ (η ⟦ G ⟅ d ⟆ ⟧ ⋆⟨ C ⟩ G ⟪ ε ⟦ d ⟧ ⟫)
≡⟨ lPrecatWhisker {C = C} _ _ _ δ₂ ⟩
g ⋆⟨ C ⟩ C .id _
≡⟨ C .⋆IdR _ ⟩
g
∎
where
natu : η ⟦ c ⟧ ⋆⟨ C ⟩ G ⟪ F ⟪ g ⟫ ⟫ ≡ g ⋆⟨ C ⟩ η ⟦ G ⟅ d ⟆ ⟧
natu = sym (η .N-hom _)
adj→adj' .adjIso {c = c} {d} .leftInv f
= F ⟪ η ⟦ c ⟧ ⋆⟨ C ⟩ G ⟪ f ⟫ ⟫ ⋆⟨ D ⟩ ε ⟦ d ⟧
≡⟨ cong (λ v → v ⋆⟨ D ⟩ ε ⟦ d ⟧) (F .F-seq _ _) ⟩
F ⟪ η ⟦ c ⟧ ⟫ ⋆⟨ D ⟩ F ⟪ G ⟪ f ⟫ ⟫ ⋆⟨ D ⟩ ε ⟦ d ⟧
≡⟨ D .⋆Assoc _ _ _ ⟩
F ⟪ η ⟦ c ⟧ ⟫ ⋆⟨ D ⟩ (F ⟪ G ⟪ f ⟫ ⟫ ⋆⟨ D ⟩ ε ⟦ d ⟧)
-- apply naturality
≡⟨ lPrecatWhisker {C = D} _ _ _ natu ⟩
F ⟪ η ⟦ c ⟧ ⟫ ⋆⟨ D ⟩ (ε ⟦ F ⟅ c ⟆ ⟧ ⋆⟨ D ⟩ f)
≡⟨ sym (D .⋆Assoc _ _ _) ⟩
F ⟪ η ⟦ c ⟧ ⟫ ⋆⟨ D ⟩ ε ⟦ F ⟅ c ⟆ ⟧ ⋆⟨ D ⟩ f
-- apply triangle identity
≡⟨ rPrecatWhisker {C = D} _ _ _ δ₁ ⟩
(D .id _) ⋆⟨ D ⟩ f
≡⟨ D .⋆IdL _ ⟩
f
∎
where
natu : F ⟪ G ⟪ f ⟫ ⟫ ⋆⟨ D ⟩ ε ⟦ d ⟧ ≡ ε ⟦ F ⟅ c ⟆ ⟧ ⋆⟨ D ⟩ f
natu = ε .N-hom _
-- follows directly from functoriality
adj→adj' .adjNatInD {c = c} f k = cong (λ v → η ⟦ c ⟧ ⋆⟨ C ⟩ v) (G .F-seq _ _) ∙ (sym (C .⋆Assoc _ _ _))
adj→adj' .adjNatInC {d = d} g h = cong (λ v → v ⋆⟨ D ⟩ ε ⟦ d ⟧) (F .F-seq _ _) ∙ D .⋆Assoc _ _ _
|
{
"alphanum_fraction": 0.3964081208,
"avg_line_length": 36.01875,
"ext": "agda",
"hexsha": "fef75eeb35ddb4292c74aa68c1d6df51a6ed9a3f",
"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": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Edlyr/cubical",
"max_forks_repo_path": "Cubical/Categories/Adjoint.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
"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": "Edlyr/cubical",
"max_issues_repo_path": "Cubical/Categories/Adjoint.agda",
"max_line_length": 149,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "5de11df25b79ee49d5c084fbbe6dfc66e4147a2e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Edlyr/cubical",
"max_stars_repo_path": "Cubical/Categories/Adjoint.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5516,
"size": 11526
}
|
module my-integer where
open import bool
open import bool-thms2
open import eq
open import nat
open import nat-thms
open import product
--open import product-thms
open import sum
-- open import unit
data ⊤ : Set where
triv : ⊤
ℤ-pos-t : ℕ → Set
ℤ-pos-t 0 = ⊤
ℤ-pos-t (suc _) = 𝔹
data ℤ : Set where
mkℤ : (n : ℕ) → ℤ-pos-t n → ℤ
0ℤ : ℤ
0ℤ = mkℤ 0 triv
1ℤ : ℤ
1ℤ = mkℤ 1 tt
-1ℤ : ℤ
-1ℤ = mkℤ 1 ff
abs-val : ℤ → ℕ
abs-val (mkℤ n _) = n
is-evenℤ : ℤ → 𝔹
is-evenℤ (mkℤ n _) = is-even n
is-oddℤ : ℤ → 𝔹
is-oddℤ (mkℤ n _) = is-odd n
{- subtract the second natural number from the first, returning an integer.
This is mostly a helper for _+ℤ_ -}
diffℤ : ℕ → ℕ → ℤ
diffℤ n m with ℕ-trichotomy n m
diffℤ n m | inj₁ p with <∸suc{m}{n} p -- n < m
diffℤ n m | inj₁ p | x , _ = mkℤ (suc x) ff
diffℤ n m | inj₂ (inj₁ p) = mkℤ 0 triv -- n = m
diffℤ n m | inj₂ (inj₂ p) with <∸suc{n}{m} p
diffℤ n m | inj₂ (inj₂ p) | x , _ = mkℤ (suc x) tt -- m < n
_+ℤ_ : ℤ → ℤ → ℤ
(mkℤ 0 _) +ℤ x = x
x +ℤ (mkℤ 0 _) = x
(mkℤ (suc n) p1) +ℤ (mkℤ (suc m) p2) with p1 xor p2
(mkℤ (suc n) p1) +ℤ (mkℤ (suc m) p2) | ff = mkℤ (suc n + suc m) p1
(mkℤ (suc n) p1) +ℤ (mkℤ (suc m) p2) | tt = if p1 imp p2 then diffℤ m n else diffℤ n m
|
{
"alphanum_fraction": 0.5759036145,
"avg_line_length": 21.8421052632,
"ext": "agda",
"hexsha": "e4ac923c9ed576415051df5c9fe45b4d943be856",
"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": "2ad96390a9be5c238e73709a21533c7354cedd0c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "logicshan/IAL",
"max_forks_repo_path": "my-integer.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c",
"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": "logicshan/IAL",
"max_issues_repo_path": "my-integer.agda",
"max_line_length": 87,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "2ad96390a9be5c238e73709a21533c7354cedd0c",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "logicshan/IAL",
"max_stars_repo_path": "my-integer.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 618,
"size": 1245
}
|
{-
This files contains:
- Lots of useful properties about (this) decidable predicates on finite sets.
(P.S. We use the alternative definition of decidability for computational effectivity.)
-}
{-# OPTIONS --safe #-}
module Cubical.Data.FinSet.DecidablePredicate where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Equiv renaming (_∙ₑ_ to _⋆_)
open import Cubical.Foundations.Equiv.Properties
open import Cubical.HITs.PropositionalTruncation as Prop
open import Cubical.Data.Bool
open import Cubical.Data.Empty as Empty
open import Cubical.Data.Sigma
open import Cubical.Data.Fin
open import Cubical.Data.SumFin renaming (Fin to SumFin)
open import Cubical.Data.FinSet.Base
open import Cubical.Data.FinSet.Properties
open import Cubical.Relation.Nullary
open import Cubical.Relation.Nullary.DecidablePropositions
hiding (DecProp) renaming (DecProp' to DecProp)
private
variable
ℓ ℓ' ℓ'' ℓ''' : Level
module _
(X : Type ℓ)(p : isFinOrd X) where
isDecProp¬' : isDecProp (¬ X)
isDecProp¬' = _ , invEquiv (preCompEquiv (p .snd)) ⋆ SumFin¬ _
isDecProp∥∥' : isDecProp ∥ X ∥
isDecProp∥∥' = _ , propTrunc≃ (p .snd) ⋆ SumFin∥∥DecProp _
module _
(X : Type ℓ )(p : isFinOrd X)
(P : X → Type ℓ')
(dec : (x : X) → isDecProp (P x)) where
private
e = p .snd
isFinOrdSub : isFinOrd (Σ X P)
isFinOrdSub = _ ,
Σ-cong-equiv {B' = λ x → P (invEq e x)} e (transpFamily p)
⋆ Σ-cong-equiv-snd (λ x → dec (invEq e x) .snd)
⋆ SumFinSub≃ _ (fst ∘ dec ∘ invEq e)
isDecProp∃' : isDecProp ∥ Σ X P ∥
isDecProp∃' = _ ,
Prop.propTrunc≃ (
Σ-cong-equiv {B' = λ x → P (invEq e x)} e (transpFamily p)
⋆ Σ-cong-equiv-snd (λ x → dec (invEq e x) .snd))
⋆ SumFin∃≃ _ (fst ∘ dec ∘ invEq e)
isDecProp∀' : isDecProp ((x : X) → P x)
isDecProp∀' = _ ,
equivΠ {B' = λ x → P (invEq e x)} e (transpFamily p)
⋆ equivΠCod (λ x → dec (invEq e x) .snd)
⋆ SumFin∀≃ _ (fst ∘ dec ∘ invEq e)
module _
(X : Type ℓ )(p : isFinOrd X)
(a b : X) where
private
e = p .snd
isDecProp≡' : isDecProp (a ≡ b)
isDecProp≡' .fst = SumFin≡ _ (e .fst a) (e .fst b)
isDecProp≡' .snd = congEquiv e ⋆ SumFin≡≃ _ _ _
module _
(X : FinSet ℓ)
(P : X .fst → DecProp ℓ') where
isFinSetSub : isFinSet (Σ (X .fst) (λ x → P x .fst))
isFinSetSub = Prop.rec isPropIsFinSet
(λ p → isFinOrd→isFinSet (isFinOrdSub (X .fst) (_ , p) (λ x → P x .fst) (λ x → P x .snd)))
(X .snd .snd)
isDecProp∃ : isDecProp ∥ Σ (X .fst) (λ x → P x .fst) ∥
isDecProp∃ = Prop.rec isPropIsDecProp
(λ p → isDecProp∃' (X .fst) (_ , p) (λ x → P x .fst) (λ x → P x .snd)) (X .snd .snd)
isDecProp∀ : isDecProp ((x : X .fst) → P x .fst)
isDecProp∀ = Prop.rec isPropIsDecProp
(λ p → isDecProp∀' (X .fst) (_ , p) (λ x → P x .fst) (λ x → P x .snd)) (X .snd .snd)
module _
(X : FinSet ℓ)
(Y : X .fst → FinSet ℓ')
(Z : (x : X .fst) → Y x .fst → DecProp ℓ'') where
isDecProp∀2 : isDecProp ((x : X .fst) → (y : Y x .fst) → Z x y .fst)
isDecProp∀2 = isDecProp∀ X (λ x → _ , isDecProp∀ (Y x) (Z x))
module _
(X : FinSet ℓ)
(Y : X .fst → FinSet ℓ')
(Z : (x : X .fst) → Y x .fst → FinSet ℓ'')
(W : (x : X .fst) → (y : Y x .fst) → Z x y .fst → DecProp ℓ''') where
isDecProp∀3 : isDecProp ((x : X .fst) → (y : Y x .fst) → (z : Z x y .fst) → W x y z .fst)
isDecProp∀3 = isDecProp∀ X (λ x → _ , isDecProp∀2 (Y x) (Z x) (W x))
module _
(X : FinSet ℓ) where
isDecProp≡ : (a b : X .fst) → isDecProp (a ≡ b)
isDecProp≡ a b = Prop.rec isPropIsDecProp
(λ p → isDecProp≡' (X .fst) (_ , p) a b) (X .snd .snd)
module _
(P : DecProp ℓ )
(Q : DecProp ℓ') where
isDecProp× : isDecProp (P .fst × Q .fst)
isDecProp× .fst = P .snd .fst and Q .snd .fst
isDecProp× .snd = Σ-cong-equiv (P .snd .snd) (λ _ → Q .snd .snd) ⋆ Bool→Type×≃ _ _
module _
(X : FinSet ℓ) where
isDecProp¬ : isDecProp (¬ (X .fst))
isDecProp¬ = Prop.rec isPropIsDecProp
(λ p → isDecProp¬' (X .fst) (_ , p)) (X .snd .snd)
isDecProp∥∥ : isDecProp ∥ X .fst ∥
isDecProp∥∥ = Prop.rec isPropIsDecProp
(λ p → isDecProp∥∥' (X .fst) (_ , p)) (X .snd .snd)
|
{
"alphanum_fraction": 0.6040332147,
"avg_line_length": 29.4755244755,
"ext": "agda",
"hexsha": "65025ff805f6a03cb774bffb15ff827c1f55573e",
"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/Data/FinSet/DecidablePredicate.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/Data/FinSet/DecidablePredicate.agda",
"max_line_length": 94,
"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/Data/FinSet/DecidablePredicate.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1740,
"size": 4215
}
|
open import Relation.Ternary.Separation
module Relation.Ternary.Separation.Construct.ListOf
{a} (A : Set a)
{{ r : RawSep A }}
{{ _ : IsSep r }}
where
open import Level
open import Data.Product
open import Data.List
open import Data.List.Properties using (++-isMonoid)
open import Data.List.Relation.Binary.Equality.Propositional
open import Data.List.Relation.Binary.Permutation.Inductive
open import Relation.Binary.PropositionalEquality as P hiding ([_])
open import Relation.Unary hiding (_∈_; _⊢_)
open import Relation.Ternary.Separation.Morphisms
private
Carrier = List A
variable
xˡ xʳ x y z : A
xsˡ xsʳ xs ys zs : Carrier
data Split : (xs ys zs : Carrier) → Set a where
divide : xˡ ⊎ xʳ ≣ x → Split xs ys zs → Split (xˡ ∷ xs) (xʳ ∷ ys) (x ∷ zs)
to-left : Split xs ys zs → Split (z ∷ xs) ys (z ∷ zs)
to-right : Split xs ys zs → Split xs (z ∷ ys) (z ∷ zs)
[] : Split [] [] []
-- Split yields a separation algebra
instance
splits : RawSep Carrier
RawSep._⊎_≣_ splits = Split
split-is-sep : IsSep splits
-- commutes
IsSep.⊎-comm split-is-sep (divide τ σ) = divide (⊎-comm τ) (⊎-comm σ)
IsSep.⊎-comm split-is-sep (to-left σ) = to-right (⊎-comm σ)
IsSep.⊎-comm split-is-sep (to-right σ) = to-left (⊎-comm σ)
IsSep.⊎-comm split-is-sep [] = []
-- reassociates
IsSep.⊎-assoc split-is-sep σ₁ (to-right σ₂) with ⊎-assoc σ₁ σ₂
... | _ , σ₄ , σ₅ = -, to-right σ₄ , to-right σ₅
IsSep.⊎-assoc split-is-sep (to-left σ₁) (divide τ σ₂) with ⊎-assoc σ₁ σ₂
... | _ , σ₄ , σ₅ = -, divide τ σ₄ , to-right σ₅
IsSep.⊎-assoc split-is-sep (to-right σ₁) (divide τ σ₂) with ⊎-assoc σ₁ σ₂
... | _ , σ₄ , σ₅ = -, to-right σ₄ , divide τ σ₅
IsSep.⊎-assoc split-is-sep (divide τ σ₁) (to-left σ) with ⊎-assoc σ₁ σ
... | _ , σ₄ , σ₅ = -, divide τ σ₄ , to-left σ₅
IsSep.⊎-assoc split-is-sep (to-left σ₁) (to-left σ) with ⊎-assoc σ₁ σ
... | _ , σ₄ , σ₅ = -, to-left σ₄ , σ₅
IsSep.⊎-assoc split-is-sep (to-right σ₁) (to-left σ) with ⊎-assoc σ₁ σ
... | _ , σ₄ , σ₅ = -, to-right σ₄ , to-left σ₅
IsSep.⊎-assoc split-is-sep [] [] = -, [] , []
IsSep.⊎-assoc split-is-sep (divide lr σ₁) (divide rl σ₂) with ⊎-assoc σ₁ σ₂ | ⊎-assoc lr rl
... | _ , σ₃ , σ₄ | _ , τ₃ , τ₄ = -, divide τ₃ σ₃ , divide τ₄ σ₄
split-is-unital : IsUnitalSep splits []
IsUnitalSep.⊎-idˡ split-is-unital {[]} = []
IsUnitalSep.⊎-idˡ split-is-unital {x ∷ Φ} = to-right ⊎-idˡ
IsUnitalSep.⊎-id⁻ˡ split-is-unital (to-right σ) rewrite ⊎-id⁻ˡ σ = refl
IsUnitalSep.⊎-id⁻ˡ split-is-unital [] = refl
split-has-concat : IsConcattative splits
IsConcattative._∙_ split-has-concat = _++_
IsConcattative.⊎-∙ₗ split-has-concat {Φₑ = []} σ = σ
IsConcattative.⊎-∙ₗ split-has-concat {Φₑ = x ∷ Φₑ} σ = to-left (⊎-∙ₗ σ)
split-separation : Separation _
split-separation = record { Carrier = List A }
split-monoidal : MonoidalSep _
split-monoidal = record { monoid = ++-isMonoid }
list-positive : IsPositive splits
list-positive = record
{ ⊎-εˡ = λ where [] → refl }
unspliceᵣ : ∀ {xs ys zs : Carrier} {y} → xs ⊎ (y ∷ ys) ≣ zs → ∃ λ zs₁ → xs ⊎ [ y ] ≣ zs₁ × zs₁ ⊎ ys ≣ zs
unspliceᵣ σ with ⊎-unassoc σ (⊎-∙ {Φₗ = [ _ ]})
... | _ , σ₁ , σ₂ = -, σ₁ , σ₂
|
{
"alphanum_fraction": 0.6032806804,
"avg_line_length": 37.4090909091,
"ext": "agda",
"hexsha": "eb810c4184e7e565e034dea948e61d6b40413bbe",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2020-05-23T00:34:36.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-01-30T14:15:14.000Z",
"max_forks_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "laMudri/linear.agda",
"max_forks_repo_path": "src/Relation/Ternary/Separation/Construct/ListOf.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "laMudri/linear.agda",
"max_issues_repo_path": "src/Relation/Ternary/Separation/Construct/ListOf.agda",
"max_line_length": 104,
"max_stars_count": 34,
"max_stars_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "laMudri/linear.agda",
"max_stars_repo_path": "src/Relation/Ternary/Separation/Construct/ListOf.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-03T15:22:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-12-20T13:57:50.000Z",
"num_tokens": 1342,
"size": 3292
}
|
module drawingProgram where
open import Unit
open import Data.Bool.Base
open import Data.Char.Base renaming (primCharEquality to charEquality)
open import Data.Nat.Base hiding (_≟_;_⊓_; _+_; _*_)
open import Data.List.Base hiding (_++_)
open import Data.Integer.Base hiding (suc)
open import Data.String.Base
open import Data.Maybe.Base
open import NativeIO
open import Function
open import Size renaming (Size to AgdaSize)
open import SizedIO.Base
open import SizedIO.IOGraphicsLib hiding (GraphicsCommands; GraphicsResponses; GraphicsInterface; IOGraphics; getWindowEvent; openWindow; drawInWindow; closeWindow; translateIOGraphicsLocal; translateIOGraphics)
open import NativeInt
-- open import NativeIOSafe
data GraphicsCommands : Set where
closeWindow : Window → GraphicsCommands
maybeGetWindowEvent : Window → GraphicsCommands
getWindowEvent : Window → GraphicsCommands
openWindowNotEx : String → Size → GraphicsCommands
openWindow : String → (Maybe Point) → (Maybe Size)
→ RedrawMode → (Maybe Word32) → GraphicsCommands
timeGetTime : GraphicsCommands
drawInWindow : Window → Graphic → GraphicsCommands
print : String → GraphicsCommands
GraphicsResponses : GraphicsCommands → Set
GraphicsResponses (maybeGetWindowEvent w) = Maybe Event
GraphicsResponses (getWindowEvent w) = Event
GraphicsResponses (closeWindow w) = Unit
GraphicsResponses (openWindowNotEx s s') = Window
GraphicsResponses (openWindow s p s' r w) = Window
GraphicsResponses timeGetTime = Word32
GraphicsResponses _ = Unit
GraphicsInterface : IOInterface
Command GraphicsInterface = GraphicsCommands
Response GraphicsInterface = GraphicsResponses
IOGraphics : AgdaSize → Set → Set
IOGraphics i = IO GraphicsInterface i
translateIOGraphicsLocal : (c : GraphicsCommands) → NativeIO (GraphicsResponses c)
translateIOGraphicsLocal (maybeGetWindowEvent w) = nativeMaybeGetWindowEvent w
translateIOGraphicsLocal (getWindowEvent w) = nativeGetWindowEvent w
translateIOGraphicsLocal (closeWindow w) = nativeCloseWindow w
translateIOGraphicsLocal (openWindowNotEx str size) = nativeOpenWindow str size
translateIOGraphicsLocal (openWindow str point size mode word) = nativeOpenWindowEx str point size mode word
translateIOGraphicsLocal timeGetTime = nativeTimeGetTime
translateIOGraphicsLocal (drawInWindow w g) = nativeDrawInWindow w g
translateIOGraphicsLocal (print s) = nativePutStrLn s
translateIOGraphics : {A : Set} → IOGraphics ∞ A → NativeIO A
translateIOGraphics = translateIO translateIOGraphicsLocal
integerLess : ℤ → ℤ → Bool
integerLess x y with ∣(y - (x ⊓ y))∣
... | zero = true
... | z = false
line : Point → Point → Graphic
line p newpoint = withColor red (polygon
(nativePoint x y
∷ nativePoint a b
∷ nativePoint (a + xAddition) (b + yAddition)
∷ nativePoint (x + xAddition) (y + yAddition)
∷ [] ) )
where
x = nativeProj1Point p
y = nativeProj2Point p
a = nativeProj1Point newpoint
b = nativeProj2Point newpoint
diffx = + ∣ (a - x) ∣
diffy = + ∣ (b - y) ∣
diffx*3 = diffx * (+ 3)
diffy*3 = diffy * (+ 3)
condition = (integerLess diffx diffy*3) ∧ (integerLess diffy diffx*3)
xAddition = if condition then + 2 else + 1
yAddition = if condition then + 2 else + 1
State = Maybe Point
loop : ∀{i} → Window → State → IOGraphics i Unit
force (loop w s) = do' (getWindowEvent w)
λ{ (Key c t) → if charEquality c 'x' then do (closeWindow w) return
else loop w s
; (MouseMove p₂) → case s of
λ{ nothing → loop w (just p₂) ;
(just p₁) → do (drawInWindow w (line p₁ p₂)) λ _ →
loop w (just p₂) }
; _ → loop w s }
program : ∀{i} → IOGraphics i Unit
program =
do (openWindow "Drawing Program" nothing (just (size (+ 1000) (+ 1000)))
nativeDrawGraphic nothing) λ window →
loop window nothing
main : NativeIO Unit
main = nativeRunGraphics (translateIOGraphics program)
|
{
"alphanum_fraction": 0.6552506237,
"avg_line_length": 34.9920634921,
"ext": "agda",
"hexsha": "9d00986b9ae7e10db18ec0e7dc2bfb88246a378c",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z",
"max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/ooAgda",
"max_forks_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/drawingProgram.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"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/ooAgda",
"max_issues_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/drawingProgram.agda",
"max_line_length": 211,
"max_stars_count": 23,
"max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/ooAgda",
"max_stars_repo_path": "presentationsAndExampleCode/agdaImplementorsMeetingGlasgow22April2016AntonSetzer/drawingProgram.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z",
"num_tokens": 1115,
"size": 4409
}
|
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
-- Lifts a 1-Category into a bicategory
module Categories.Bicategory.Construction.1-Category
{o ℓ e} b (C : Category o ℓ e) where
open import Level using (Lift; lift)
open import Data.Unit using (⊤; tt)
open import Data.Product using (uncurry)
open import Relation.Binary using (Setoid)
open import Categories.Bicategory
open import Categories.Category.Construction.0-Groupoid using (0-Groupoid)
open import Categories.Category.Instance.Cats using (Cats)
open import Categories.Category.Monoidal using (Monoidal)
open import Categories.Category.Monoidal.Instance.Cats using (module Product)
open import Categories.Category.Groupoid using (Groupoid; IsGroupoid)
open import Categories.Functor using (Functor; _∘F_) renaming (id to idF)
open import Categories.Functor.Construction.Constant using (const)
open import Categories.Functor.Bifunctor using (Bifunctor)
private module C = Category C
open C hiding (id)
1-Category : Bicategory ℓ e b o
1-Category = record
{ enriched = record
{ Obj = Obj
; hom = hom
; id = id
; ⊚ = ⊚
; ⊚-assoc = ⊚-assoc
; unitˡ = unitˡ
; unitʳ = unitʳ
}
; triangle = lift tt
; pentagon = lift tt
}
where
open Monoidal (Product.Cats-Monoidal {ℓ} {e} {b})
open Category.Commutation (Cats ℓ e b)
-- Since we are doing Setoid-enriched category theory, we don't
-- lift homsets to discrete hom-categories, but hom-setoids to
-- thin hom-groupoids.
hom : C.Obj → C.Obj → Category ℓ e b
hom A B = Groupoid.category (0-Groupoid b (hom-setoid {A} {B}))
id : ∀ {A} → Functor unit (hom A A)
id = const C.id
⊚ : ∀ {A B C} → Bifunctor (hom B C) (hom A B) (hom A C)
⊚ {A} {B} {C} = record
{ F₀ = uncurry _∘_
; F₁ = uncurry ∘-resp-≈
; identity = lift tt
; homomorphism = lift tt
; F-resp-≈ = λ _ → lift tt
}
⊚-assoc : ∀ {A B C D} →
[ (hom C D ⊗₀ hom B C) ⊗₀ hom A B ⇒ hom A D ]⟨
⊚ ⊗₁ idF ⇒⟨ hom B D ⊗₀ hom A B ⟩
⊚
≈ associator.from ⇒⟨ hom C D ⊗₀ (hom B C ⊗₀ hom A B) ⟩
idF ⊗₁ ⊚ ⇒⟨ hom C D ⊗₀ hom A C ⟩
⊚
⟩
⊚-assoc = record
{ F⇒G = record { η = λ _ → assoc ; commute = λ _ → lift tt }
; F⇐G = record { η = λ _ → sym-assoc ; commute = λ _ → lift tt }
; iso = λ _ → record { isoˡ = lift tt ; isoʳ = lift tt }
}
unitˡ : ∀ {A B} →
[ unit ⊗₀ hom A B ⇒ hom A B ]⟨
id ⊗₁ idF ⇒⟨ hom B B ⊗₀ hom A B ⟩
⊚
≈ unitorˡ.from
⟩
unitˡ = record
{ F⇒G = record { η = λ _ → identityˡ ; commute = λ _ → lift tt }
; F⇐G = record { η = λ _ → Equiv.sym identityˡ ; commute = λ _ → lift tt }
; iso = λ _ → record { isoˡ = lift tt ; isoʳ = lift tt }
}
unitʳ : ∀ {A B} →
[ hom A B ⊗₀ unit ⇒ hom A B ]⟨
idF ⊗₁ id ⇒⟨ hom A B ⊗₀ hom A A ⟩
⊚
≈ unitorʳ.from
⟩
unitʳ = record
{ F⇒G = record { η = λ _ → identityʳ ; commute = λ _ → lift tt }
; F⇐G = record { η = λ _ → Equiv.sym identityʳ ; commute = λ _ → lift tt }
; iso = λ _ → record { isoˡ = lift tt ; isoʳ = lift tt }
}
open Bicategory 1-Category
-- The hom-categories are hom-groupoids
hom-isGroupoid : ∀ {A B} → IsGroupoid (hom A B)
hom-isGroupoid = Groupoid.isGroupoid (0-Groupoid b hom-setoid)
|
{
"alphanum_fraction": 0.5720116618,
"avg_line_length": 31.4678899083,
"ext": "agda",
"hexsha": "d22f24d67337d0a8ce23a987fedb6e9f4299eaa2",
"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/Bicategory/Construction/1-Category.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/Bicategory/Construction/1-Category.agda",
"max_line_length": 80,
"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/Bicategory/Construction/1-Category.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1194,
"size": 3430
}
|
------------------------------------------------------------------------
-- Lexicographic products of binary relations
------------------------------------------------------------------------
-- The definition of lexicographic product used here is suitable if
-- the left-hand relation is a strict partial order.
module Relation.Binary.Product.StrictLex where
open import Data.Function
open import Data.Product
open import Data.Sum
open import Data.Empty
open import Relation.Nullary.Product
open import Relation.Nullary.Sum
open import Relation.Binary
open import Relation.Binary.Consequences
open import Relation.Binary.Product.Pointwise as Pointwise
using (_×-Rel_)
private
module Dummy {a₁ a₂ : Set} where
×-Lex : (≈₁ <₁ : Rel a₁) → (≤₂ : Rel a₂) → Rel (a₁ × a₂)
×-Lex ≈₁ <₁ ≤₂ = (<₁ on₁ proj₁) -⊎- (≈₁ on₁ proj₁) -×- (≤₂ on₁ proj₂)
-- Some properties which are preserved by ×-Lex (under certain
-- assumptions).
×-reflexive : ∀ ≈₁ ∼₁ {≈₂} ≤₂ →
≈₂ ⇒ ≤₂ → (≈₁ ×-Rel ≈₂) ⇒ (×-Lex ≈₁ ∼₁ ≤₂)
×-reflexive _ _ _ refl₂ = λ x≈y →
inj₂ (proj₁ x≈y , refl₂ (proj₂ x≈y))
_×-irreflexive_ : ∀ {≈₁ <₁} → Irreflexive ≈₁ <₁ →
∀ {≈₂ <₂} → Irreflexive ≈₂ <₂ →
Irreflexive (≈₁ ×-Rel ≈₂) (×-Lex ≈₁ <₁ <₂)
(ir₁ ×-irreflexive ir₂) x≈y (inj₁ x₁<y₁) = ir₁ (proj₁ x≈y) x₁<y₁
(ir₁ ×-irreflexive ir₂) x≈y (inj₂ x≈<y) =
ir₂ (proj₂ x≈y) (proj₂ x≈<y)
×-transitive :
∀ {≈₁ <₁} → IsEquivalence ≈₁ → <₁ Respects₂ ≈₁ → Transitive <₁ →
∀ {≤₂} → Transitive ≤₂ →
Transitive (×-Lex ≈₁ <₁ ≤₂)
×-transitive {≈₁ = ≈₁} {<₁ = <₁} eq₁ resp₁ trans₁
{≤₂ = ≤₂} trans₂ {x} {y} {z} = trans {x} {y} {z}
where
module Eq₁ = IsEquivalence eq₁
trans : Transitive (×-Lex ≈₁ <₁ ≤₂)
trans (inj₁ x₁<y₁) (inj₁ y₁<z₁) = inj₁ (trans₁ x₁<y₁ y₁<z₁)
trans (inj₁ x₁<y₁) (inj₂ y≈≤z) =
inj₁ (proj₁ resp₁ (proj₁ y≈≤z) x₁<y₁)
trans (inj₂ x≈≤y) (inj₁ y₁<z₁) =
inj₁ (proj₂ resp₁ (Eq₁.sym $ proj₁ x≈≤y) y₁<z₁)
trans (inj₂ x≈≤y) (inj₂ y≈≤z) =
inj₂ ( Eq₁.trans (proj₁ x≈≤y) (proj₁ y≈≤z)
, trans₂ (proj₂ x≈≤y) (proj₂ y≈≤z) )
×-antisymmetric :
∀ {≈₁ <₁} → Symmetric ≈₁ → Irreflexive ≈₁ <₁ → Asymmetric <₁ →
∀ {≈₂ ≤₂} → Antisymmetric ≈₂ ≤₂ →
Antisymmetric (≈₁ ×-Rel ≈₂) (×-Lex ≈₁ <₁ ≤₂)
×-antisymmetric {≈₁ = ≈₁} {<₁ = <₁} sym₁ irrefl₁ asym₁
{≈₂ = ≈₂} {≤₂ = ≤₂} antisym₂ {x} {y} =
antisym {x} {y}
where
antisym : Antisymmetric (≈₁ ×-Rel ≈₂) (×-Lex ≈₁ <₁ ≤₂)
antisym (inj₁ x₁<y₁) (inj₁ y₁<x₁) =
⊥-elim {_ × _} $ asym₁ x₁<y₁ y₁<x₁
antisym (inj₁ x₁<y₁) (inj₂ y≈≤x) =
⊥-elim {_ × _} $ irrefl₁ (sym₁ $ proj₁ y≈≤x) x₁<y₁
antisym (inj₂ x≈≤y) (inj₁ y₁<x₁) =
⊥-elim {_ × _} $ irrefl₁ (sym₁ $ proj₁ x≈≤y) y₁<x₁
antisym (inj₂ x≈≤y) (inj₂ y≈≤x) =
proj₁ x≈≤y , antisym₂ (proj₂ x≈≤y) (proj₂ y≈≤x)
×-asymmetric :
∀ {≈₁ <₁} → Symmetric ≈₁ → <₁ Respects₂ ≈₁ → Asymmetric <₁ →
∀ {<₂} → Asymmetric <₂ →
Asymmetric (×-Lex ≈₁ <₁ <₂)
×-asymmetric {≈₁ = ≈₁} {<₁ = <₁} sym₁ resp₁ asym₁
{<₂ = <₂} asym₂ {x} {y} = asym {x} {y}
where
irrefl₁ : Irreflexive ≈₁ <₁
irrefl₁ = asym⟶irr resp₁ sym₁ asym₁
asym : Asymmetric (×-Lex ≈₁ <₁ <₂)
asym (inj₁ x₁<y₁) (inj₁ y₁<x₁) = asym₁ x₁<y₁ y₁<x₁
asym (inj₁ x₁<y₁) (inj₂ y≈<x) = irrefl₁ (sym₁ $ proj₁ y≈<x) x₁<y₁
asym (inj₂ x≈<y) (inj₁ y₁<x₁) = irrefl₁ (sym₁ $ proj₁ x≈<y) y₁<x₁
asym (inj₂ x≈<y) (inj₂ y≈<x) = asym₂ (proj₂ x≈<y) (proj₂ y≈<x)
×-≈-respects₂ :
∀ {≈₁ <₁} → IsEquivalence ≈₁ → <₁ Respects₂ ≈₁ →
∀ {≈₂ <₂} → <₂ Respects₂ ≈₂ →
(×-Lex ≈₁ <₁ <₂) Respects₂ (≈₁ ×-Rel ≈₂)
×-≈-respects₂ {≈₁ = ≈₁} {<₁ = <₁} eq₁ resp₁
{≈₂ = ≈₂} {<₂ = <₂} resp₂ =
(λ {x y z} → resp¹ {x} {y} {z}) ,
(λ {x y z} → resp² {x} {y} {z})
where
< = ×-Lex ≈₁ <₁ <₂
open IsEquivalence eq₁ renaming (sym to sym₁; trans to trans₁)
resp¹ : ∀ {x} → (< x) Respects (≈₁ ×-Rel ≈₂)
resp¹ y≈y' (inj₁ x₁<y₁) = inj₁ (proj₁ resp₁ (proj₁ y≈y') x₁<y₁)
resp¹ y≈y' (inj₂ x≈<y) =
inj₂ ( trans₁ (proj₁ x≈<y) (proj₁ y≈y')
, proj₁ resp₂ (proj₂ y≈y') (proj₂ x≈<y) )
resp² : ∀ {y} → (flip₁ < y) Respects (≈₁ ×-Rel ≈₂)
resp² x≈x' (inj₁ x₁<y₁) = inj₁ (proj₂ resp₁ (proj₁ x≈x') x₁<y₁)
resp² x≈x' (inj₂ x≈<y) =
inj₂ ( trans₁ (sym₁ $ proj₁ x≈x') (proj₁ x≈<y)
, proj₂ resp₂ (proj₂ x≈x') (proj₂ x≈<y) )
×-decidable : ∀ {≈₁ <₁} → Decidable ≈₁ → Decidable <₁ →
∀ {≤₂} → Decidable ≤₂ →
Decidable (×-Lex ≈₁ <₁ ≤₂)
×-decidable dec-≈₁ dec-<₁ dec-≤₂ = λ x y →
dec-<₁ (proj₁ x) (proj₁ y)
⊎-dec
(dec-≈₁ (proj₁ x) (proj₁ y)
×-dec
dec-≤₂ (proj₂ x) (proj₂ y))
×-total : ∀ {≈₁ <₁} → Total <₁ →
∀ {≤₂} →
Total (×-Lex ≈₁ <₁ ≤₂)
×-total {≈₁ = ≈₁} {<₁ = <₁} total₁ {≤₂ = ≤₂} = total
where
total : Total (×-Lex ≈₁ <₁ ≤₂)
total x y with total₁ (proj₁ x) (proj₁ y)
... | inj₁ x₁<y₁ = inj₁ (inj₁ x₁<y₁)
... | inj₂ x₁>y₁ = inj₂ (inj₁ x₁>y₁)
×-compare : ∀ {≈₁ <₁} → Symmetric ≈₁ → Trichotomous ≈₁ <₁ →
∀ {≈₂ <₂} → Trichotomous ≈₂ <₂ →
Trichotomous (≈₁ ×-Rel ≈₂) (×-Lex ≈₁ <₁ <₂)
×-compare {≈₁} {<₁} sym₁ compare₁ {≈₂} {<₂} compare₂ = cmp
where
cmp : Trichotomous (≈₁ ×-Rel ≈₂) (×-Lex ≈₁ <₁ <₂)
cmp (x₁ , x₂) (y₁ , y₂) with compare₁ x₁ y₁
... | tri< x₁<y₁ x₁≉y₁ x₁≯y₁ = tri< (inj₁ x₁<y₁) (x₁≉y₁ ∘ proj₁)
[ x₁≯y₁ , x₁≉y₁ ∘ sym₁ ∘ proj₁ ]
... | tri> x₁≮y₁ x₁≉y₁ x₁>y₁ = tri> [ x₁≮y₁ , x₁≉y₁ ∘ proj₁ ]
(x₁≉y₁ ∘ proj₁) (inj₁ x₁>y₁)
... | tri≈ x₁≮y₁ x₁≈y₁ x₁≯y₁ with compare₂ x₂ y₂
... | tri< x₂<y₂ x₂≉y₂ x₂≯y₂ = tri< (inj₂ (x₁≈y₁ , x₂<y₂))
(x₂≉y₂ ∘ proj₂)
[ x₁≯y₁ , x₂≯y₂ ∘ proj₂ ]
... | tri> x₂≮y₂ x₂≉y₂ x₂>y₂ = tri> [ x₁≮y₁ , x₂≮y₂ ∘ proj₂ ]
(x₂≉y₂ ∘ proj₂)
(inj₂ (sym₁ x₁≈y₁ , x₂>y₂))
... | tri≈ x₂≮y₂ x₂≈y₂ x₂≯y₂ = tri≈ [ x₁≮y₁ , x₂≮y₂ ∘ proj₂ ]
(x₁≈y₁ , x₂≈y₂)
[ x₁≯y₁ , x₂≯y₂ ∘ proj₂ ]
-- Some collections of properties which are preserved by ×-Lex.
_×-isPreorder_ : ∀ {≈₁ ∼₁} → IsPreorder ≈₁ ∼₁ →
∀ {≈₂ ∼₂} → IsPreorder ≈₂ ∼₂ →
IsPreorder (≈₁ ×-Rel ≈₂) (×-Lex ≈₁ ∼₁ ∼₂)
_×-isPreorder_ {≈₁ = ≈₁} {∼₁ = ∼₁} pre₁ {∼₂ = ∼₂} pre₂ = record
{ isEquivalence = Pointwise._×-isEquivalence_
(isEquivalence pre₁) (isEquivalence pre₂)
; reflexive = λ {x y} →
×-reflexive ≈₁ ∼₁ ∼₂ (reflexive pre₂) {x} {y}
; trans = λ {x y z} →
×-transitive
(isEquivalence pre₁) (∼-resp-≈ pre₁) (trans pre₁)
{≤₂ = ∼₂} (trans pre₂) {x} {y} {z}
; ∼-resp-≈ = ×-≈-respects₂ (isEquivalence pre₁)
(∼-resp-≈ pre₁)
(∼-resp-≈ pre₂)
}
where open IsPreorder
_×-isStrictPartialOrder_ :
∀ {≈₁ <₁} → IsStrictPartialOrder ≈₁ <₁ →
∀ {≈₂ <₂} → IsStrictPartialOrder ≈₂ <₂ →
IsStrictPartialOrder (≈₁ ×-Rel ≈₂) (×-Lex ≈₁ <₁ <₂)
_×-isStrictPartialOrder_ {<₁ = <₁} spo₁ {<₂ = <₂} spo₂ =
record
{ isEquivalence = Pointwise._×-isEquivalence_
(isEquivalence spo₁) (isEquivalence spo₂)
; irrefl = λ {x y} →
_×-irreflexive_ {<₁ = <₁} (irrefl spo₁)
{<₂ = <₂} (irrefl spo₂) {x} {y}
; trans = λ {x y z} →
×-transitive
{<₁ = <₁} (isEquivalence spo₁) (<-resp-≈ spo₁)
(trans spo₁)
{≤₂ = <₂} (trans spo₂) {x} {y} {z}
; <-resp-≈ = ×-≈-respects₂ (isEquivalence spo₁)
(<-resp-≈ spo₁)
(<-resp-≈ spo₂)
}
where open IsStrictPartialOrder
_×-isStrictTotalOrder_ :
∀ {≈₁ <₁} → IsStrictTotalOrder ≈₁ <₁ →
∀ {≈₂ <₂} → IsStrictTotalOrder ≈₂ <₂ →
IsStrictTotalOrder (≈₁ ×-Rel ≈₂) (×-Lex ≈₁ <₁ <₂)
_×-isStrictTotalOrder_ {<₁ = <₁} spo₁ {<₂ = <₂} spo₂ =
record
{ isEquivalence = Pointwise._×-isEquivalence_
(isEquivalence spo₁) (isEquivalence spo₂)
; trans = λ {x y z} →
×-transitive
{<₁ = <₁} (isEquivalence spo₁) (<-resp-≈ spo₁)
(trans spo₁)
{≤₂ = <₂} (trans spo₂) {x} {y} {z}
; compare = ×-compare (Eq.sym spo₁) (compare spo₁)
(compare spo₂)
; <-resp-≈ = ×-≈-respects₂ (isEquivalence spo₁)
(<-resp-≈ spo₁)
(<-resp-≈ spo₂)
}
where open IsStrictTotalOrder
open Dummy public
-- "Packages" (e.g. preorders) can also be combined.
_×-preorder_ : Preorder → Preorder → Preorder
p₁ ×-preorder p₂ = record
{ isPreorder = isPreorder p₁ ×-isPreorder isPreorder p₂
} where open Preorder
_×-strictPartialOrder_ :
StrictPartialOrder → StrictPartialOrder → StrictPartialOrder
s₁ ×-strictPartialOrder s₂ = record
{ isStrictPartialOrder = isStrictPartialOrder s₁
×-isStrictPartialOrder
isStrictPartialOrder s₂
} where open StrictPartialOrder
_×-strictTotalOrder_ :
StrictTotalOrder → StrictTotalOrder → StrictTotalOrder
s₁ ×-strictTotalOrder s₂ = record
{ isStrictTotalOrder = isStrictTotalOrder s₁
×-isStrictTotalOrder
isStrictTotalOrder s₂
} where open StrictTotalOrder
|
{
"alphanum_fraction": 0.4762900976,
"avg_line_length": 40.313253012,
"ext": "agda",
"hexsha": "5d7ead0cb7fe950ead26eeddc759fbf4bc48282c",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z",
"max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "isabella232/Lemmachine",
"max_forks_repo_path": "vendor/stdlib/src/Relation/Binary/Product/StrictLex.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/Lemmachine",
"max_issues_repo_path": "vendor/stdlib/src/Relation/Binary/Product/StrictLex.agda",
"max_line_length": 73,
"max_stars_count": 56,
"max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "isabella232/Lemmachine",
"max_stars_repo_path": "vendor/stdlib/src/Relation/Binary/Product/StrictLex.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-21T17:02:19.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-20T02:11:42.000Z",
"num_tokens": 4114,
"size": 10038
}
|
module Issue556 (A : Set) (x : A) where
y : A
y = x
|
{
"alphanum_fraction": 0.5471698113,
"avg_line_length": 10.6,
"ext": "agda",
"hexsha": "13da9490eb8fc72508f5847c9e946aee00d27773",
"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/Issue556.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/Issue556.agda",
"max_line_length": 39,
"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/Issue556.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": 23,
"size": 53
}
|
{-# OPTIONS --cubical-compatible #-}
module Issue1025 where
data _≡_ {A : Set} (x : A) : A → Set where
refl : x ≡ x
postulate mySpace : Set
postulate myPoint : mySpace
data Foo : myPoint ≡ myPoint → Set where
foo : Foo refl
test : {e : myPoint ≡ myPoint} → (a : Foo e) → (i : a ≡ a) → i ≡ refl
test foo refl = {!!}
|
{
"alphanum_fraction": 0.6018518519,
"avg_line_length": 20.25,
"ext": "agda",
"hexsha": "c92ffb0cd3f3b4b146e8bbcb59b9199369e26b6f",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_forks_repo_licenses": [
"BSD-2-Clause"
],
"max_forks_repo_name": "KDr2/agda",
"max_forks_repo_path": "test/Fail/Issue1025.agda",
"max_issues_count": 6,
"max_issues_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_issues_repo_issues_event_max_datetime": "2021-11-24T08:31:10.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-10-18T08:12:24.000Z",
"max_issues_repo_licenses": [
"BSD-2-Clause"
],
"max_issues_repo_name": "KDr2/agda",
"max_issues_repo_path": "test/Fail/Issue1025.agda",
"max_line_length": 69,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "98c9382a59f707c2c97d75919e389fc2a783ac75",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "KDr2/agda",
"max_stars_repo_path": "test/Fail/Issue1025.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 117,
"size": 324
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Non empty trie, basic type and operations
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe --sized-types #-}
open import Relation.Binary using (StrictTotalOrder)
module Data.Trie.NonEmpty {k e r} (S : StrictTotalOrder k e r) where
open import Level
open import Size
open import Category.Monad
open import Data.Product as Prod using (∃; uncurry; -,_)
open import Data.List.Base as List using (List; []; _∷_; _++_)
open import Data.List.NonEmpty as List⁺ using (List⁺; [_]; concatMap)
open import Data.Maybe.Base as Maybe using (Maybe; nothing; just; maybe′) hiding (module Maybe)
open import Data.These as These using (These; this; that; these)
open import Function as F
import Function.Identity.Categorical as Identity
open import Relation.Unary using (_⇒_; IUniversal)
open StrictTotalOrder S
using (module Eq)
renaming (Carrier to Key)
open import Data.List.Relation.Binary.Equality.Setoid Eq.setoid
open import Data.AVL.Value hiding (Value)
open import Data.AVL.Value ≋-setoid using (Value)
open import Data.AVL.NonEmpty S as Tree⁺ using (Tree⁺)
open Value
------------------------------------------------------------------------
-- Definition
-- A Trie⁺ is a tree branching over an alphabet of Keys. It stores values
-- indexed over the Word (i.e. List Key) that was read to reach them.
-- Each node in the Trie⁺ contains either a value, a non-empty Tree of
-- sub-Trie⁺ reached by reading an extra letter, or both.
Word : Set k
Word = List Key
eat : ∀ {v} → Value v → Word → Value v
family (eat V ks) = family V ∘′ (ks ++_)
respects (eat V ks) = respects V ∘′ ++⁺ ≋-refl
data Trie⁺ {v} (V : Value v) : Size → Set (v ⊔ k ⊔ e ⊔ r)
Tries⁺ : ∀ {v} (V : Value v) (i : Size) → Set (v ⊔ k ⊔ e ⊔ r)
map : ∀ {v w} (V : Value v) (W : Value w) {i} →
∀[ family V ⇒ family W ] →
Trie⁺ V i → Trie⁺ W i
data Trie⁺ V where
node : ∀ {i} → These (family V []) (Tries⁺ V i) → Trie⁺ V (↑ i)
Tries⁺ V j = Tree⁺ $ MkValue (λ k → Trie⁺ (eat V (k ∷ [])) j)
$ λ eq → map _ _ (respects V (eq ∷ ≋-refl))
map V W f (node t) = node $ These.map f (Tree⁺.map (map _ _ f)) t
------------------------------------------------------------------------
-- Query
lookup : ∀ {v} {V : Value v} ks → Trie⁺ V ∞ →
Maybe (These (family V ks) (Tries⁺ (eat V ks) ∞))
lookup [] (node nd) = just (These.map₂ (Tree⁺.map id) nd)
lookup (k ∷ ks) (node nd) = let open Maybe in do
ts ← These.fromThat nd
t ← Tree⁺.lookup k ts
lookup ks t
module _ {v} {V : Value v} where
lookupValue : ∀ (ks : Word) → Trie⁺ V ∞ → Maybe (family V ks)
lookupValue ks t = lookup ks t Maybe.>>= These.fromThis
lookupTries⁺ : ∀ ks → Trie⁺ V ∞ → Maybe (Tries⁺ (eat V ks) ∞)
lookupTries⁺ ks t = lookup ks t Maybe.>>= These.fromThat
lookupTrie⁺ : ∀ k → Trie⁺ V ∞ → Maybe (Trie⁺ (eat V (k ∷ [])) ∞)
lookupTrie⁺ k t = lookupTries⁺ [] t Maybe.>>= Tree⁺.lookup k
------------------------------------------------------------------------
-- Construction
singleton : ∀ {v} {V : Value v} ks → family V ks → Trie⁺ V ∞
singleton [] v = node (this v)
singleton (k ∷ ks) v = node (that (Tree⁺.singleton k (singleton ks v)))
insertWith : ∀ {v} {V : Value v} ks → (Maybe (family V ks) → family V ks) →
Trie⁺ V ∞ → Trie⁺ V ∞
insertWith [] f (node nd) =
node (These.fold (this ∘ f ∘ just) (these (f nothing)) (these ∘ f ∘ just) nd)
insertWith {v} {V} (k ∷ ks) f (node {j} nd) = node $
These.fold (λ v → these v (Tree⁺.singleton k end))
(that ∘′ rec)
(λ v → these v ∘′ rec)
nd
where
end : Trie⁺ (eat V (k ∷ [])) ∞
end = singleton ks (f nothing)
rec : Tries⁺ V ∞ → Tries⁺ V ∞
rec = Tree⁺.insertWith k (maybe′ (insertWith ks f) end)
module _ {v} {V : Value v} where
private Val = family V
insert : ∀ ks → Val ks → Trie⁺ V ∞ → Trie⁺ V ∞
insert ks = insertWith ks ∘′ F.const
fromList⁺ : List⁺ (∃ Val) → Trie⁺ V ∞
fromList⁺ = List⁺.foldr (uncurry insert) (uncurry singleton)
toList⁺ : ∀ {v} {V : Value v} {i} → let Val = Value.family V in
Trie⁺ V i → List⁺ (∃ Val)
toList⁺ (node nd) = These.mergeThese List⁺._⁺++⁺_
$ These.map fromVal fromTries⁺ nd
where
fromVal = [_] ∘′ -,_
fromTries⁺ = concatMap (uncurry λ k → List⁺.map (Prod.map (k ∷_) id) ∘′ toList⁺)
∘′ Tree⁺.toList⁺
------------------------------------------------------------------------
-- Modification
-- Deletion
deleteWith : ∀ {v} {V : Value v} {i} ks →
(∀ {i} → Trie⁺ (eat V ks) i → Maybe (Trie⁺ (eat V ks) i)) →
Trie⁺ V i → Maybe (Trie⁺ V i)
deleteWith [] f t = f t
deleteWith (k ∷ ks) f t@(node nd) = let open RawMonad Identity.monad in do
just ts ← These.fromThat nd where _ → just t
-- This would be a lot cleaner if we had
-- Tree⁺.updateWith : ∀ k → (Maybe (V k) → Maybe (V k)) → AVL → AVL
-- Instead we lookup the subtree, update it and either put it back in
-- or delete the corresponding leaf depending on whether the result is successful.
just t′ ← Tree⁺.lookup k ts where _ → just t
Maybe.map node ∘′ Maybe.align (These.fromThis nd) $′ case deleteWith ks f t′ of λ where
nothing → Tree⁺.delete k ts
(just u) → just (Tree⁺.insert k u ts)
module _ {v} {V : Value v} where
deleteTrie⁺ : ∀ {i} (ks : Word) → Trie⁺ V i → Maybe (Trie⁺ V i)
deleteTrie⁺ ks = deleteWith ks (F.const nothing)
deleteValue : ∀ {i} (ks : Word) → Trie⁺ V i → Maybe (Trie⁺ V i)
deleteValue ks = deleteWith ks $ λ where
(node nd) → Maybe.map node $′ These.deleteThis nd
deleteTries⁺ : ∀ {i} (ks : Word) → Trie⁺ V i → Maybe (Trie⁺ V i)
deleteTries⁺ ks = deleteWith ks $ λ where
(node nd) → Maybe.map node $′ These.deleteThat nd
|
{
"alphanum_fraction": 0.5591288072,
"avg_line_length": 36.0552147239,
"ext": "agda",
"hexsha": "447cd68fa71342efae4840684f67a5662fc846ce",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/Trie/NonEmpty.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/Trie/NonEmpty.agda",
"max_line_length": 95,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/Trie/NonEmpty.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": 1917,
"size": 5877
}
|
module Basic where
open import Prelude
data List (A : Set) : Set
data List A where
nil : List A
cons : A -> List A -> List A
append : {A : Set} -> List A -> List A -> List A
append nil ys = ys
append (cons x xs) ys = cons x (append xs ys)
record Equiv {A : Set} (R : A -> A -> Set) : Set
record Equiv {A} R where
constructor equiv
field
ref : (x : A) -> R x x
sym : (x : A) (y : A) -> R x y -> R y x
trans : {x y z : A} -> R x y -> R y z -> R x z
open Equiv
trans1 : {A : Set}{R : A -> A -> Set}{x y z : A} -> Equiv R -> R x y -> R y z -> R x z
trans1 eq p q = trans eq p q
postulate
symId : {A : Set} (x y : A) -> x == y -> y == x
transId : {A : Set} {x y z : A} -> x == y -> y == z -> x == z
equivId : {A : Set} -> Equiv {A} (\x y -> x == y)
equivId {A} = equiv (\x -> refl) symId (\ x y z -> transId)
record Sigma (A : Set) (B : A -> Set) : Set
record Sigma A B where
constructor pair
field fst : A
snd : B fst
record True : Set
record True where
constructor tt
|
{
"alphanum_fraction": 0.5210991168,
"avg_line_length": 22.152173913,
"ext": "agda",
"hexsha": "74921cdf813d84e83d4a7cbfcc87bddc8ab433d9",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "src/prototyping/term/examples/Basic.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": "src/prototyping/term/examples/Basic.agda",
"max_line_length": 86,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "src/prototyping/term/examples/Basic.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": 381,
"size": 1019
}
|
{-
This file contains:
- An implementation of the free groupoid (a free group that has no limitiations
over the high dimensional path structure). An intermediate construction used
to calculate the fundamental group of a Bouquet.
-}
{-# OPTIONS --safe #-}
module Cubical.HITs.FreeGroupoid.Base where
open import Cubical.Foundations.Prelude
private
variable
ℓ : Level
data FreeGroupoid (A : Type ℓ) : Type ℓ where
η : A → FreeGroupoid A
_·_ : FreeGroupoid A → FreeGroupoid A → FreeGroupoid A
ε : FreeGroupoid A
inv : FreeGroupoid A → FreeGroupoid A
assoc : ∀ x y z → x · (y · z) ≡ (x · y) · z
idr : ∀ x → x ≡ x · ε
idl : ∀ x → x ≡ ε · x
invr : ∀ x → x · (inv x) ≡ ε
invl : ∀ x → (inv x) · x ≡ ε
|
{
"alphanum_fraction": 0.6296791444,
"avg_line_length": 24.9333333333,
"ext": "agda",
"hexsha": "3f766f97208fd972e9740ff4a8f46ae4b0a5df31",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/HITs/FreeGroupoid/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/HITs/FreeGroupoid/Base.agda",
"max_line_length": 79,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/HITs/FreeGroupoid/Base.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z",
"num_tokens": 252,
"size": 748
}
|
{-# OPTIONS --without-K --exact-split #-}
module encode-decode where
import 05-identity-types
open 05-identity-types public
record Lift {i j : Level} (A : UU i) : UU (i ⊔ j) where
field
raise : A
module Coprod where
code-left : {i j : Level} {A : UU i} {B : UU j} → A → (coprod A B) → (UU i)
code-left a₀ (inl a) = Id a₀ a
code-left a₀ (inr b) = Lift 𝟘
code-right : {i j : Level} {A : UU i} {B : UU j} → B → (coprod A B) → (UU j)
code-right b₀ (inr b) = Id b₀ b
code-right b₀ (inl a) = Lift 𝟘
encode-left : {i j : Level} {A : UU i} {B : UU j} → (a₀ : A) → (x : coprod A B) → (p : Id (inl a₀) x) → (code-left a₀ x)
encode-left a₀ x p = tr (code-left a₀) p refl
decode-left : {i j : Level} {A : UU i} {B : UU j} → (a₀ : A) → (x : coprod A B) → (c : (code-left a₀ x)) → Id (inl a₀) x
decode-left a₀ (inl a) refl = refl
decode-left a₀ (inr b) c = ind-empty (Lift.raise c)
module Nats where
code : ℕ → ℕ → (UU lzero)
code zero-ℕ zero-ℕ = 𝟙
code (succ-ℕ m) zero-ℕ = Lift 𝟘
code zero-ℕ (succ-ℕ n) = Lift 𝟘
code (succ-ℕ m) (succ-ℕ n) = code m n
recursion : (n : ℕ) → code n n
recursion zero-ℕ = star
recursion (succ-ℕ n) = recursion n
encode : (m n : ℕ) → (Id m n) → (code m n)
encode m n p = tr (code m) p (recursion m)
decode : (m n : ℕ) → (code m n) → (Id m n)
decode zero-ℕ zero-ℕ s = refl
decode (succ-ℕ m) zero-ℕ e = ind-empty (Lift.raise e)
decode zero-ℕ (succ-ℕ n) e = ind-empty (Lift.raise e)
decode (succ-ℕ m) (succ-ℕ n) c = ap succ-ℕ (decode m n c)
-- This doesn't work.
constant-fn : (n : ℕ) → code n n
constant-fn n = star
|
{
"alphanum_fraction": 0.5538648813,
"avg_line_length": 32.2156862745,
"ext": "agda",
"hexsha": "a30b10e5e17e9351ea51b7c2589984194685fc3e",
"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": "09c710bf9c31ba88be144cc950bd7bc19c22a934",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "hemangandhi/HoTT-Intro",
"max_forks_repo_path": "Agda/univalent-hott/encode-decode.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "hemangandhi/HoTT-Intro",
"max_issues_repo_path": "Agda/univalent-hott/encode-decode.agda",
"max_line_length": 122,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "09c710bf9c31ba88be144cc950bd7bc19c22a934",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "hemangandhi/HoTT-Intro",
"max_stars_repo_path": "Agda/univalent-hott/encode-decode.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 702,
"size": 1643
}
|
------------------------------------------------------------------------------
-- Properties of the mirror function
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module FOTC.Program.Mirror.PropertiesI where
open import Common.FOL.Relation.Binary.EqReasoning
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Base.List.PropertiesI
open import FOTC.Data.List
open import FOTC.Data.List.PropertiesI
open import FOTC.Program.Mirror.Type
open import FOTC.Program.Mirror.Forest.PropertiesI as ForestP
open import FOTC.Program.Mirror.Forest.TotalityI
open import FOTC.Program.Mirror.Mirror
open import FOTC.Program.Mirror.Tree.TotalityI
------------------------------------------------------------------------------
mirror-involutive : ∀ {t} → Tree t → mirror · (mirror · t) ≡ t
helper : ∀ {ts} → Forest ts →
reverse (map mirror (reverse (map mirror ts))) ≡ ts
mirror-involutive (tree d fnil) =
mirror · (mirror · (node d []))
≡⟨ subst (λ x → mirror · (mirror · (node d [])) ≡ mirror · x)
(mirror-eq d [])
refl
⟩
mirror · node d (reverse (map mirror []))
≡⟨ subst (λ x → mirror · node d (reverse (map mirror [])) ≡
mirror · node d (reverse x))
(map-[] mirror)
refl
⟩
mirror · node d (reverse [])
≡⟨ subst (λ x → mirror · node d (reverse []) ≡ mirror · node d x)
(rev-[] [])
refl
⟩
mirror · node d []
≡⟨ mirror-eq d [] ⟩
node d (reverse (map mirror []))
≡⟨ subst (λ x → node d (reverse (map mirror [])) ≡
node d (reverse x))
(map-[] mirror)
refl
⟩
node d (reverse [])
≡⟨ subst (λ x → node d (reverse []) ≡ node d x) (rev-[] []) refl ⟩
node d [] ∎
mirror-involutive (tree d (fcons {t} {ts} Tt Fts)) =
mirror · (mirror · node d (t ∷ ts))
≡⟨ subst (λ x → mirror · (mirror · node d (t ∷ ts)) ≡ mirror · x)
(mirror-eq d (t ∷ ts))
refl
⟩
mirror · node d (reverse (map mirror (t ∷ ts)))
≡⟨ subst (λ x → mirror · node d (reverse (map mirror (t ∷ ts))) ≡ x)
(mirror-eq d (reverse (map mirror (t ∷ ts))))
refl
⟩
node d (reverse (map mirror (reverse (map mirror (t ∷ ts)))))
≡⟨ subst (λ x → node d (reverse (map mirror (reverse (map mirror (t ∷ ts))))) ≡
node d x)
(helper (fcons Tt Fts))
refl
⟩
node d (t ∷ ts) ∎
helper fnil =
reverse (map mirror (reverse (map mirror [])))
≡⟨ reverseCong (mapCong₂ (reverseCong (map-[] mirror))) ⟩
reverse (map mirror (reverse []))
≡⟨ reverseCong (mapCong₂ (rev-[] [])) ⟩
reverse (map mirror [])
≡⟨ reverseCong (map-[] mirror) ⟩
reverse []
≡⟨ rev-[] [] ⟩
[] ∎
helper (fcons {t} {ts} Tt Fts) =
reverse (map mirror (reverse (map mirror (t ∷ ts))))
≡⟨ reverseCong (mapCong₂ (reverseCong (map-∷ mirror t ts))) ⟩
reverse (map mirror (reverse (mirror · t ∷ map mirror ts)))
≡⟨ reverseCong (mapCong₂
(ForestP.reverse-∷ (mirror-Tree Tt)
(map-Forest mirror mirror-Tree Fts)))
⟩
reverse (map mirror (reverse (map mirror ts) ++ (mirror · t ∷ [])))
≡⟨ reverseCong (ForestP.map-++
mirror
mirror-Tree
(reverse-Forest (map-Forest mirror mirror-Tree Fts))
(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)
(ForestP.reverse-++
(map-Forest mirror mirror-Tree
(reverse-Forest
(map-Forest mirror mirror-Tree Fts)))
(map-Forest mirror mirror-Tree
(fcons (mirror-Tree Tt) fnil)))
refl
⟩
reverse (map mirror (mirror · t ∷ [])) ++
reverse (map mirror (reverse (map mirror ts)))
≡⟨ subst (λ x → reverse (map mirror (mirror · t ∷ [])) ++ n₁ ≡
reverse x ++ n₁)
(map-∷ mirror (mirror · t) [])
refl
⟩
reverse (mirror · (mirror · t) ∷ map mirror []) ++ n₁
≡⟨ subst (λ x → reverse (mirror · (mirror · t) ∷ map mirror []) ++ n₁ ≡
reverse (mirror · (mirror · t) ∷ x) ++ n₁)
(map-[] mirror)
refl
⟩
reverse (mirror · (mirror · t) ∷ []) ++ n₁
≡⟨ ++-leftCong (reverse-[x]≡[x] (mirror · (mirror · t))) ⟩
(mirror · (mirror · t) ∷ []) ++ n₁
≡⟨ ++-∷ (mirror · (mirror · t)) [] n₁ ⟩
mirror · (mirror · t) ∷ [] ++ n₁
≡⟨ subst (λ x → mirror · (mirror · t) ∷ [] ++ n₁ ≡
mirror · (mirror · t) ∷ x)
(++-leftIdentity n₁)
refl
⟩
mirror · (mirror · t) ∷ reverse (map mirror (reverse (map mirror ts)))
≡⟨ ∷-leftCong (mirror-involutive Tt) ⟩
t ∷ reverse (map mirror (reverse (map mirror ts)))
≡⟨ ∷-rightCong (helper Fts) ⟩
t ∷ ts ∎
where
n₁ : D
n₁ = reverse (map mirror (reverse (map mirror ts)))
Fn₁ : Forest n₁
Fn₁ = rev-Forest
(map-Forest mirror mirror-Tree
(reverse-Forest (map-Forest mirror mirror-Tree Fts)))
fnil
|
{
"alphanum_fraction": 0.4849354376,
"avg_line_length": 35.9741935484,
"ext": "agda",
"hexsha": "cfe762fc482594fc5adc9df76957465b4440c85c",
"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/FOTC/Program/Mirror/PropertiesI.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/FOTC/Program/Mirror/PropertiesI.agda",
"max_line_length": 83,
"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/FOTC/Program/Mirror/PropertiesI.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": 1646,
"size": 5576
}
|
module UnequalTerms where
data Zero : Set where
data One : Set where one : One
err1 : Zero
err1 = one
err2 : One -> One
err2 = \(x : Zero) -> one
|
{
"alphanum_fraction": 0.6381578947,
"avg_line_length": 11.6923076923,
"ext": "agda",
"hexsha": "816e6a0bb0ac3c822b5dc9947b078e89e5eb6c57",
"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/UnequalTerms.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/UnequalTerms.agda",
"max_line_length": 31,
"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/UnequalTerms.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": 51,
"size": 152
}
|
-- Andreas, 2015-02-26
-- {-# OPTIONS -v interaction:100 #-}
data D : Set where
c : D
goal : D
goal = {! !} -- C-c C-r gave a parse error here, as there was a (single) space.
g1 : D
g1 = {! !}
g2 : D
g2 = {! !}
-- works now
|
{
"alphanum_fraction": 0.5276595745,
"avg_line_length": 13.8235294118,
"ext": "agda",
"hexsha": "4f97fabf038fdf81ef79ae09281db839b545a34c",
"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/Issue1447.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/Issue1447.agda",
"max_line_length": 80,
"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/Issue1447.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": 90,
"size": 235
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Code related to vector equality over propositional equality that
-- makes use of heterogeneous equality
------------------------------------------------------------------------
{-# OPTIONS --with-K --safe #-}
module Data.Vec.Relation.Binary.Equality.Propositional.WithK
{a} {A : Set a} where
open import Data.Vec
open import Data.Vec.Relation.Binary.Equality.Propositional {A = A}
open import Relation.Binary.PropositionalEquality
open import Relation.Binary.HeterogeneousEquality as H using (_≅_)
≋⇒≅ : ∀ {m n} {xs : Vec A m} {ys : Vec A n} →
xs ≋ ys → xs ≅ ys
≋⇒≅ p with length-equal p
... | refl = H.≡-to-≅ (≋⇒≡ p)
|
{
"alphanum_fraction": 0.554200542,
"avg_line_length": 33.5454545455,
"ext": "agda",
"hexsha": "1c0144b77602d34e5ebaae47bd7a1cb2abb2312f",
"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/Vec/Relation/Binary/Equality/Propositional/WithK.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/Vec/Relation/Binary/Equality/Propositional/WithK.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Vec/Relation/Binary/Equality/Propositional/WithK.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 192,
"size": 738
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Relation.Binary.Construct.Constant where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels using (hProp)
open import Cubical.Relation.Binary
open import Cubical.Structures.Carrier
------------------------------------------------------------------------
-- Definition
Const : ∀ {a b ℓ} {A : Type a} {B : Type b} → hProp ℓ → REL A B ℓ
Const I = λ _ _ → I
------------------------------------------------------------------------
-- Properties
module _ {a c} {A : Type a} {C : hProp c} where
reflexive : ⟨ C ⟩ → Reflexive {A = A} (Const C)
reflexive c = c
symmetric : Symmetric {A = A} (Const C)
symmetric c = c
transitive : Transitive {A = A} (Const C)
transitive c d = c
isPartialEquivalence : IsPartialEquivalence {A = A} (Const C)
isPartialEquivalence = record
{ symmetric = λ {x} {y} → symmetric {x} {y}
; transitive = λ {x} {y} {z} → transitive {x} {y} {z}
}
partialEquivalence : PartialEquivalence A c
partialEquivalence = record { isPartialEquivalence = isPartialEquivalence }
isEquivalence : ⟨ C ⟩ → IsEquivalence {A = A} (Const C)
isEquivalence c = record
{ isPartialEquivalence = isPartialEquivalence
; reflexive = λ {x} → reflexive c {x}
}
equivalence : ⟨ C ⟩ → Equivalence A c
equivalence x = record { isEquivalence = isEquivalence x }
|
{
"alphanum_fraction": 0.6011004127,
"avg_line_length": 30.2916666667,
"ext": "agda",
"hexsha": "ccd09d0be12de25ce74c9a53a3ad10f49de0aaf1",
"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/Relation/Binary/Construct/Constant.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/Relation/Binary/Construct/Constant.agda",
"max_line_length": 77,
"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/Relation/Binary/Construct/Constant.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 411,
"size": 1454
}
|
{-# OPTIONS --cubical --save-metas #-}
module Erased-cubical-Pattern-matching-Cubical where
data D : Set where
c₁ c₂ : D
|
{
"alphanum_fraction": 0.696,
"avg_line_length": 17.8571428571,
"ext": "agda",
"hexsha": "2fd7d8ab431811536ba6233fcde6d9451d078704",
"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-Cubical.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-Cubical.agda",
"max_line_length": 52,
"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-Cubical.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": 40,
"size": 125
}
|
{-# OPTIONS --cubical #-}
module Numeral.Natural.Equiv.Path where
open import Data.Boolean.Equiv.Path
open import Functional
open import Logic.Propositional
open import Numeral.Natural.Oper.Comparisons
open import Numeral.Natural
open import Relator.Equals.Proofs.Equivalence using () renaming ([≡]-equiv to Id-equiv ; [≡]-symmetry to Id-symmetry ; [≡]-to-function to Id-to-function ; [≡]-function to Id-function)
open import Structure.Function.Domain
open import Structure.Function
open import Structure.Relator.Properties
open import Type.Cubical.Path.Equality
open import Type.Cubical.Path
open import Type.Identity
instance
𝐒-injective : Injective(𝐒)
Injective.proof 𝐒-injective p = congruence₁(𝐏) p
ℕ-Path-to-Id : ∀{x y : ℕ} → (Path x y) → (Id x y)
ℕ-Path-to-Id {𝟎} {𝟎} p = intro
ℕ-Path-to-Id {𝟎} {𝐒 y} = [⊥]-elim ∘ Bool-different-values ∘ congruence₁(positive?)
ℕ-Path-to-Id {𝐒 x} {𝟎} = [⊥]-elim ∘ Bool-different-values ∘ symmetry(Path) ∘ congruence₁(positive?)
ℕ-Path-to-Id {𝐒 x} {𝐒 y} p = congruence₁ ⦃ Id-equiv ⦄ ⦃ Id-equiv ⦄ (ℕ.𝐒) ⦃ Id-function ⦄ (ℕ-Path-to-Id {x}{y} (injective(ℕ.𝐒) p))
|
{
"alphanum_fraction": 0.7110912343,
"avg_line_length": 41.4074074074,
"ext": "agda",
"hexsha": "a473a3045719932ff810e434f7793386f779b558",
"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/Natural/Equiv/Path.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/Natural/Equiv/Path.agda",
"max_line_length": 183,
"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/Natural/Equiv/Path.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": 410,
"size": 1118
}
|
module List.Order.Bounded {A : Set}(_≤_ : A → A → Set) where
open import Bound.Total A
open import Bound.Total.Order _≤_
open import Data.List
data _≤*_ : List A → Bound → Set where
lenx : {t : Bound} → [] ≤* t
lecx : {t : Bound}{x : A}{xs : List A} → LeB (val x) t → xs ≤* t → (x ∷ xs) ≤* t
data _*≤_ : Bound → List A → Set where
genx : {b : Bound} → b *≤ []
gecx : {b : Bound}{x : A}{xs : List A} → LeB b (val x) → b *≤ xs → b *≤ (x ∷ xs)
|
{
"alphanum_fraction": 0.5342163355,
"avg_line_length": 32.3571428571,
"ext": "agda",
"hexsha": "05b689d82ee781ee9b1f03d25629876fb9d5a3d4",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bgbianchi/sorting",
"max_forks_repo_path": "agda/List/Order/Bounded.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bgbianchi/sorting",
"max_issues_repo_path": "agda/List/Order/Bounded.agda",
"max_line_length": 82,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bgbianchi/sorting",
"max_stars_repo_path": "agda/List/Order/Bounded.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z",
"num_tokens": 188,
"size": 453
}
|
{-# OPTIONS --safe --without-K #-}
module Source.Size.Substitution.Theory where
open import Source.Size
open import Source.Size.Substitution.Canonical as SC using (Sub⊢)
open import Source.Size.Substitution.Universe as SU using (⟨_⟩ ; Sub⊢ᵤ)
open import Util.Prelude
record SubTheory (A : Ctx → Set) : Set where
infixl 5 _[_] _[_]ᵤ
field
_[_] : A Ω → SC.Sub Δ Ω → A Δ
[Id] : ∀ {Δ} (a : A Δ) → a [ SC.Id ] ≡ a
[>>] : ∀ {Δ Δ′ Δ″} (σ : SC.Sub Δ Δ′) (τ : SC.Sub Δ′ Δ″) a
→ a [ σ SC.>> τ ] ≡ a [ τ ] [ σ ]
abstract
[Id]′ : ∀ {Δ} {σ : SC.Sub Δ Δ} a
→ σ ≡ SC.Id
→ a [ σ ] ≡ a
[Id]′ a refl = [Id] a
[>>]′ : ∀ {Δ Δ′ Δ″} (ι : SC.Sub Δ Δ″) (σ : SC.Sub Δ Δ′) (τ : SC.Sub Δ′ Δ″) a
→ ι ≡ σ SC.>> τ
→ a [ ι ] ≡ a [ τ ] [ σ ]
[>>]′ ι σ τ a refl = [>>] σ τ a
[>>]″ : ∀ {Δ Δ′ Δ″} (σ : SC.Sub Δ Δ′) (τ : SC.Sub Δ′ Δ″)
→ ∀ (σ′ : SC.Sub Δ Ω) (τ′ : SC.Sub Ω Δ″) a
→ σ SC.>> τ ≡ σ′ SC.>> τ′
→ a [ τ ] [ σ ] ≡ a [ τ′ ] [ σ′ ]
[>>]″ σ τ σ′ τ′ a eq
= trans (sym ([>>] σ τ a)) (trans (cong (λ σ → a [ σ ]) eq) ([>>] σ′ τ′ a))
_[_]ᵤ : A Ω → SU.Sub Δ Ω → A Δ
a [ σ ]ᵤ = a [ ⟨ σ ⟩ ]
abstract
[]ᵤ-resp-≈ : ∀ {Δ Ω} {σ τ : SU.Sub Δ Ω}
→ σ SU.≈ τ
→ ∀ a
→ a [ σ ]ᵤ ≡ a [ τ ]ᵤ
[]ᵤ-resp-≈ (SU.≈⁺ p) a = cong (λ σ → a [ σ ]) p
[Id]ᵤ : ∀ {Δ} (a : A Δ) → a [ SU.Id ]ᵤ ≡ a
[Id]ᵤ a = [Id] a
[Id]ᵤ′ : ∀ {Δ} {σ : SU.Sub Δ Δ} (a : A Δ)
→ σ SU.≈ SU.Id
→ a [ σ ]ᵤ ≡ a
[Id]ᵤ′ a (SU.≈⁺ p) = [Id]′ a p
[>>]ᵤ : ∀ {Δ Δ′ Δ″} (σ : SU.Sub Δ Δ′) (τ : SU.Sub Δ′ Δ″) (a : A Δ″)
→ a [ σ SU.>> τ ]ᵤ ≡ a [ τ ]ᵤ [ σ ]ᵤ
[>>]ᵤ σ τ a = [>>] _ _ _
[>>]ᵤ′ : ∀ {Δ Δ′ Δ″} (ι : SU.Sub Δ Δ″) (σ : SU.Sub Δ Δ′) (τ : SU.Sub Δ′ Δ″) a
→ ι SU.≈ σ SU.>> τ
→ a [ ι ]ᵤ ≡ a [ τ ]ᵤ [ σ ]ᵤ
[>>]ᵤ′ ι σ τ a (SU.≈⁺ p) = [>>]′ ⟨ ι ⟩ ⟨ σ ⟩ ⟨ τ ⟩ a p
[>>]ᵤ″ : ∀ {Δ Δ′ Δ″} (σ : SU.Sub Δ Δ′) (τ : SU.Sub Δ′ Δ″)
→ ∀ (σ′ : SU.Sub Δ Ω) (τ′ : SU.Sub Ω Δ″) a
→ σ SU.>> τ SU.≈ σ′ SU.>> τ′
→ a [ τ ]ᵤ [ σ ]ᵤ ≡ a [ τ′ ]ᵤ [ σ′ ]ᵤ
[>>]ᵤ″ σ τ σ′ τ′ a (SU.≈⁺ p) = [>>]″ ⟨ σ ⟩ ⟨ τ ⟩ ⟨ σ′ ⟩ ⟨ τ′ ⟩ a p
open SubTheory {{...}} public
instance
SubTheory-Size : SubTheory Size
SubTheory-Size = record
{ _[_] = λ n σ → SC.sub σ n
; [Id] = λ n → SC.sub-Id n refl
; [>>] = λ σ τ n → SC.sub->> n refl
}
|
{
"alphanum_fraction": 0.3790322581,
"avg_line_length": 26.1777777778,
"ext": "agda",
"hexsha": "ecf82ca956f0c8617aaa8ab66403be053363b36e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JLimperg/msc-thesis-code",
"max_forks_repo_path": "src/Source/Size/Substitution/Theory.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JLimperg/msc-thesis-code",
"max_issues_repo_path": "src/Source/Size/Substitution/Theory.agda",
"max_line_length": 81,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JLimperg/msc-thesis-code",
"max_stars_repo_path": "src/Source/Size/Substitution/Theory.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-26T06:37:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-04-13T21:31:17.000Z",
"num_tokens": 1218,
"size": 2356
}
|
{-# OPTIONS --allow-unsolved-metas #-}
module LateExpansionOfRecordMeta where
postulate
I : Set
i : I
A : I → Set
a : A i
data D : Set₁ where
d : (P : A i → Set) → P a → D
record R (P : A i → Set) : Set where
field
p : P a
record ID : Set₁ where
field
P : (i : I) → A i → Set
isR : R (P i)
at : ID → D
at id = d (ID.P id i) (R.p (ID.isR id))
postulate
T : D → Set
F : (id : ID) → T (at id) → Set
id : ID
foo : T (at id) → Set
foo t = F _ t
|
{
"alphanum_fraction": 0.5103305785,
"avg_line_length": 14.6666666667,
"ext": "agda",
"hexsha": "985b54db90ad884a0330d9ad45bd7b02f2a406f2",
"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/LateExpansionOfRecordMeta.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/LateExpansionOfRecordMeta.agda",
"max_line_length": 39,
"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/LateExpansionOfRecordMeta.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": 201,
"size": 484
}
|
module lib.libraryString where
open import Data.String
open import Data.Bool
open import Agda.Builtin.String using ( primStringEquality )
open import Data.String public using ()
renaming (toList to primStringToList;
_++_ to _++Str_)
_==Str_ : String → String → Bool
_==Str_ = primStringEquality
|
{
"alphanum_fraction": 0.6260162602,
"avg_line_length": 30.75,
"ext": "agda",
"hexsha": "7ef7e036c3ba07294c1854d3d670653e61354aec",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:41:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-01T15:02:37.000Z",
"max_forks_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "agda/ooAgda",
"max_forks_repo_path": "src/lib/libraryString.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"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/ooAgda",
"max_issues_repo_path": "src/lib/libraryString.agda",
"max_line_length": 68,
"max_stars_count": 23,
"max_stars_repo_head_hexsha": "7cc45e0148a4a508d20ed67e791544c30fecd795",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "agda/ooAgda",
"max_stars_repo_path": "src/lib/libraryString.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-12T23:15:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-06-19T12:57:55.000Z",
"num_tokens": 76,
"size": 369
}
|
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-}
module Light.Variable.Levels where
open import Light.Level using (Level)
variable ℓ aℓ bℓ cℓ dℓ eℓ fℓ gℓ hℓ : Level
|
{
"alphanum_fraction": 0.7386934673,
"avg_line_length": 24.875,
"ext": "agda",
"hexsha": "efca169a0ea285fe1b552d3e02c75fabb48fc9f0",
"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/Variable/Levels.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/Variable/Levels.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/Variable/Levels.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": 63,
"size": 199
}
|
module ReasoningEx where
open import Prelude
open import T
open import Contexts
open import Eq
open import Eq.Theory
open import Eq.ObsTheory
---- some example programs
-- boy, de bruijn indexes are unreadable
w = weaken-closed
plus-rec : ∀{Γ} → TExp Γ nat → TExp Γ nat → TExp Γ nat
plus-rec n m = rec n m (suc (var Z))
t-plus1 : TCExp (nat ⇒ nat ⇒ nat)
t-plus1 = Λ (Λ (plus-rec (var Z) (var (S Z))))
t-plus2 : TCExp (nat ⇒ nat ⇒ nat)
t-plus2 = Λ (Λ (plus-rec (var (S Z)) (var Z)))
plus-adds : ∀{Γ} → (n : Nat) (m : Nat) →
Γ ⊢ plus-rec (t-numeral n) (t-numeral m) ≅ t-numeral (n +n m) :: nat
plus-adds Z m = obs-contains-def def-rec-z
plus-adds {Γ} (S n) m with
(def-rec-s {Γ} {e = (t-numeral n)} {e0 = t-numeral m} {es = suc (var Z)})
-- If I don't name the def eq thing above and use it directly, agda uses all my core.
... | bullshit-workaround with obs-contains-def bullshit-workaround
... | step-eq with obs-congruence (plus-adds {Γ} n m) (suc ∘)
... | reccase = obs-trans step-eq reccase
help : (n : Nat) → ObservEq (nat :: []) nat
(rec (t-numeral n) (var Z) (suc (var Z)))
(rec (var Z) (t-numeral n) (suc (var Z)))
help n = {!!}
plus-commutes : [] ⊢ t-plus1 ≅ t-plus2 :: nat ⇒ nat ⇒ nat
plus-commutes with
def-cong (def-beta {e = Λ (plus-rec (var Z) (var (S Z)))} {e' = var (S Z)}) (∘ $e var Z) |
def-cong (def-beta {e = Λ (plus-rec (var (S Z)) (var Z))} {e' = var (S Z)}) (∘ $e var Z)
... | beq1 | beq2 with def-beta {e = plus-rec (var Z) (var (S (S Z)))} {e' = var Z} |
def-beta {e = plus-rec (var (S (S Z))) (var Z)} {e' = var Z}
... | beq1' | beq2' with obs-contains-def (def-trans beq1 beq1') | obs-contains-def (def-trans beq2 beq2')
... | oeq1 | oeq2 with function-induction-obs help
... | main-eq with obs-trans oeq1 (obs-trans main-eq (obs-sym oeq2))
... | lol = function-ext-obs (function-ext-obs lol)
|
{
"alphanum_fraction": 0.5844700944,
"avg_line_length": 39.7083333333,
"ext": "agda",
"hexsha": "fceb0f0a964fccbe6fc9af70214038f99fdf8d87",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2021-05-04T22:37:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-04-26T11:39:14.000Z",
"max_forks_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "msullivan/godels-t",
"max_forks_repo_path": "ReasoningEx.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91",
"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": "msullivan/godels-t",
"max_issues_repo_path": "ReasoningEx.agda",
"max_line_length": 106,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "7412725cf27873b2b23f7e411a236a97dd99ef91",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "msullivan/godels-t",
"max_stars_repo_path": "ReasoningEx.agda",
"max_stars_repo_stars_event_max_datetime": "2021-03-22T00:28:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-12-25T01:52:57.000Z",
"num_tokens": 703,
"size": 1906
}
|
{-# OPTIONS --rewriting --confluence-check #-}
module Issue4333.N where
open import Issue4333.M
open import Issue4333.N0
open import Issue4333.N1
postulate
of-type : (X : Set) (x : X) → Set
-- Subject reduction violated for b₁' = b.
_ = of-type (B a₁') b₁'
_ = of-type (B a₀') b
|
{
"alphanum_fraction": 0.6725352113,
"avg_line_length": 20.2857142857,
"ext": "agda",
"hexsha": "531030db68d3c3d2662967f09bbd64cc6193dcb3",
"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/Issue4333/N.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/Issue4333/N.agda",
"max_line_length": 46,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/interaction/Issue4333/N.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": 94,
"size": 284
}
|
{-# OPTIONS --without-K #-}
open import HoTT
module homotopy.ConstantToSetFactorization
{i j} {A : Type i} {B : Type j} (B-is-set : is-set B)
(f : A → B) (f-is-const : ∀ a₁ a₂ → f a₁ == f a₂) where
private
Skel = SetQuotient {A = A} (λ _ _ → Unit)
abstract
Skel-has-all-paths : has-all-paths Skel
Skel-has-all-paths =
SetQuot-elim (λ _ → Π-is-set λ _ → =-preserves-set SetQuotient-is-set)
(λ a₁ →
SetQuot-elim {P = λ s₂ → q[ a₁ ] == s₂}
(λ _ → =-preserves-set SetQuotient-is-set)
(λ _ → quot-rel _)
(λ _ → prop-has-all-paths-↓ (SetQuotient-is-set _ _)))
(λ {a₁ a₂} _ → ↓-cst→app-in λ s₂ →
prop-has-all-paths-↓ (SetQuotient-is-set _ _))
Skel-is-prop : is-prop Skel
Skel-is-prop = all-paths-is-prop Skel-has-all-paths
Skel-lift : Skel → B
Skel-lift = SetQuot-rec B-is-set f (λ {a₁ a₂} _ → f-is-const a₁ a₂)
cst-extend : Trunc -1 A → B
cst-extend = Skel-lift ∘ Trunc-rec Skel-is-prop q[_]
-- The beta rule.
-- This is definitionally true, so you don't need it.
cst-extend-β : cst-extend ∘ [_] == f
cst-extend-β = idp
|
{
"alphanum_fraction": 0.5588737201,
"avg_line_length": 31.6756756757,
"ext": "agda",
"hexsha": "663835c3d65c7058b2fe00ec31debf0017331ca0",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "cmknapp/HoTT-Agda",
"max_forks_repo_path": "theorems/homotopy/ConstantToSetFactorization.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "cmknapp/HoTT-Agda",
"max_issues_repo_path": "theorems/homotopy/ConstantToSetFactorization.agda",
"max_line_length": 78,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "bc849346a17b33e2679a5b3f2b8efbe7835dc4b6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cmknapp/HoTT-Agda",
"max_stars_repo_path": "theorems/homotopy/ConstantToSetFactorization.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 428,
"size": 1172
}
|
module Cats.Functor.Representable where
open import Data.Product using (_×_ ; _,_)
open import Relation.Binary using (Setoid)
open import Cats.Bifunctor using (Bifunctor)
open import Cats.Category
open import Cats.Category.Op using (_ᵒᵖ)
open import Cats.Category.Setoids as Setoids using (Setoids ; ≈-intro)
open import Cats.Util.Simp using (simp!)
open import Cats.Util.SetoidReasoning
import Relation.Binary.PropositionalEquality as ≡
module Build {lo la l≈} (C : Category lo la l≈) where
open Category C renaming (Hom to Homset)
open Setoids._⇒_ using (arr ; resp)
private
module S = Category (Setoids la l≈)
fmap : ∀ {A B A′ B′} → (A′ ⇒ A) × (B ⇒ B′) → Homset A B S.⇒ Homset A′ B′
fmap {A} {B} {A′} {B′} (f , g) = record
{ arr = λ h → g ∘ h ∘ f
; resp = λ h≈i → ∘-resp-r (∘-resp-l h≈i)
}
Hom : Bifunctor (C ᵒᵖ) C (Setoids la l≈)
Hom = record
{ fobj = λ { (A , B) → Homset A B }
; fmap = fmap
; fmap-resp = λ where
(f≈g , h≈i) → ≈-intro λ x≈y → ∘-resp h≈i (∘-resp x≈y f≈g)
; fmap-id = ≈-intro λ x≈y → ≈.trans id-l (≈.trans id-r x≈y)
; fmap-∘ = λ where
{A , B} {A′ , B′} {A″ , B″} {f , f′} {g , g′} → ≈-intro λ {x} {y} x≈y →
begin⟨ Homset A″ B″ ⟩
f′ ∘ (g′ ∘ x ∘ g) ∘ f
≈⟨ simp! C ⟩
(f′ ∘ g′) ∘ x ∘ g ∘ f
≈⟨ ∘-resp-r (∘-resp-l x≈y) ⟩
(f′ ∘ g′) ∘ y ∘ g ∘ f
∎
}
open Build public using () renaming (Hom to Hom[_])
|
{
"alphanum_fraction": 0.5248838752,
"avg_line_length": 30.14,
"ext": "agda",
"hexsha": "44e398f0b18b27ad1e427b6554403141d1298492",
"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": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "alessio-b-zak/cats",
"max_forks_repo_path": "Cats/Functor/Representable.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"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": "alessio-b-zak/cats",
"max_issues_repo_path": "Cats/Functor/Representable.agda",
"max_line_length": 81,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "alessio-b-zak/cats",
"max_stars_repo_path": "Cats/Functor/Representable.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 609,
"size": 1507
}
|
{-# OPTIONS --without-K #-}
module Computability.Prelude where
open import Data.Bool public using (Bool; false; true)
open import Data.Empty public using (⊥; ⊥-elim)
open import Data.Nat public using (ℕ; zero; suc; _+_; _*_)
open import Data.Product public using (Σ; Σ-syntax; _×_; _,_; proj₁; proj₂)
open import Data.Sum public using (_⊎_)
open import Data.Unit public using (⊤)
open import Relation.Binary.PropositionalEquality public using (_≡_; refl)
open import Level public using (Level) renaming (zero to lzero; suc to lsuc)
|
{
"alphanum_fraction": 0.7415730337,
"avg_line_length": 41.0769230769,
"ext": "agda",
"hexsha": "4144d0fb36f20e537c2318e4c3bbd5f3287f4fe8",
"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": "1b5cf338eb0adb90c1897383e05251ddd954efff",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "jesyspa/computability-in-agda",
"max_forks_repo_path": "Computability/Prelude.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b5cf338eb0adb90c1897383e05251ddd954efff",
"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": "jesyspa/computability-in-agda",
"max_issues_repo_path": "Computability/Prelude.agda",
"max_line_length": 76,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "1b5cf338eb0adb90c1897383e05251ddd954efff",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "jesyspa/computability-in-agda",
"max_stars_repo_path": "Computability/Prelude.agda",
"max_stars_repo_stars_event_max_datetime": "2021-04-30T11:15:51.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-19T15:51:22.000Z",
"num_tokens": 146,
"size": 534
}
|
module UniDB.Morph.Bla where
open import UniDB.Spec
open import UniDB.Morph.WeakenOne
open import UniDB.Morph.Sub
open import UniDB.Morph.ShiftsPrime
open import UniDB.Morph.Subs
-- mutual
-- data BlaSubst (T : STX) : MOR where
-- blasubst : {γ₁ γ₂ : Dom} → BlaSubst T γ₁ γ₂
mutual
data BlaWeak* (T : STX) : MOR where
reflW : {γ : Dom} → BlaWeak* T γ γ
inclW : {γ₁ γ₂ : Dom} → BlaWeak+ T γ₁ γ₂ → BlaWeak* T γ₁ γ₂
skipW : {γ₁ γ₂ : Dom} → Bla T γ₁ γ₂ → BlaWeak* T (suc γ₁) (suc γ₂)
data BlaWeak+ (T : STX) : MOR where
stepW : {γ₁ γ₂ γ₃ : Dom} → Weaken₁ γ₁ γ₂ → BlaWeak* T γ₂ γ₃ → BlaWeak T γ₁ γ₃
data BlaSubs* (T : STX) : MOR where
reflS : {γ : Dom} → BlaSubs* T γ γ
inclS : {γ₁ γ₂ : Dom} → BlaSubs+ T γ₁ γ₂ → BlaSubs* T γ₁ γ₂
skipS : {γ₁ γ₂ : Dom} → Bla T γ₁ γ₂ → BlaSubs* T (suc γ₁) (suc γ₂)
data BlaSubs+ (T : STX) : MOR where
stepS : {γ₁ γ₂ γ₃ : Dom} → BlaSubs* T γ₁ γ₂ → Single T γ₂ γ₃ → BlaWeak T γ₁ γ₃
data Bla (T : STX) : MOR where
refl : {γ : Dom} → Shifts* γ γ
incl : {γ₁ γ₂ : Dom} (ξ : Shifts+ γ₁ γ₂) → Shifts* γ₁ γ₂
data Shifts+ : MOR where
step : {γ₁ γ₂ : Dom} (ξ : Shifts* γ₁ γ₂) → Shifts+ γ₁ (suc γ₂)
skip : {γ₁ γ₂ : Dom} (ξ : Shifts+ γ₁ γ₂) → Shifts+ (suc γ₁) (suc γ₂)
|
{
"alphanum_fraction": 0.5908372828,
"avg_line_length": 33.3157894737,
"ext": "agda",
"hexsha": "8002e6a53678e26dcd31786d7ecc2ace4e07f71d",
"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": "7ae52205db44ad4f463882ba7e5082120fb76349",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "skeuchel/unidb-agda",
"max_forks_repo_path": "UniDB/Morph/Bla.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349",
"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": "skeuchel/unidb-agda",
"max_issues_repo_path": "UniDB/Morph/Bla.agda",
"max_line_length": 82,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "7ae52205db44ad4f463882ba7e5082120fb76349",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "skeuchel/unidb-agda",
"max_stars_repo_path": "UniDB/Morph/Bla.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 586,
"size": 1266
}
|
open import Categories.Category using (Category)
import Categories.Category.CartesianClosed
open import Data.Fin using (Fin) renaming (zero to fzero; suc to fsuc)
open import Data.List using (List; []; _∷_)
open import Data.Product using (Σ; Σ-syntax; proj₁; proj₂)
open import Syntax
open import Level using (_⊔_; suc)
module Semantics {o ℓ e}
(𝒞 : Category o ℓ e)
(CC : Categories.Category.CartesianClosed.CartesianClosed 𝒞)
{ℓ₁ ℓ₂}
(Sg : Signature ℓ₁ ℓ₂)
where
open Categories.Category.CartesianClosed 𝒞
open import Categories.Category.Cartesian 𝒞
open import Categories.Category.BinaryProducts 𝒞
open import Categories.Object.Terminal 𝒞
open import Categories.Object.Product 𝒞
open Category 𝒞
open CartesianClosed CC
open Cartesian cartesian
open BinaryProducts products
private module T = Terminal terminal
open Signature Sg
open Term Sg
module I (⟦_⟧G : Gr -> Obj) where
⟦_⟧T : Type -> Obj
⟦ ⌊ g ⌋ ⟧T = ⟦ g ⟧G
⟦ Unit ⟧T = T.⊤
⟦ A * A₁ ⟧T = ⟦ A ⟧T × ⟦ A₁ ⟧T
⟦ A => A₁ ⟧T = ⟦ A ⟧T ⇨ ⟦ A₁ ⟧T
record Structure : Set (o ⊔ ℓ ⊔ ℓ₁ ⊔ ℓ₂) where
field
⟦_⟧G : Gr -> Obj
open I ⟦_⟧G public
field
⟦_⟧F : (f : Func) -> ⟦ dom f ⟧T ⇒ ⟦ cod f ⟧T
⟦_⟧C : Context -> Obj
⟦ [] ⟧C = T.⊤
⟦ A ∷ Γ ⟧C = ⟦ Γ ⟧C × ⟦ A ⟧T
⟦_⟧ : forall {Γ A} -> Γ ⊢ A -> ⟦ Γ ⟧C ⇒ ⟦ A ⟧T
⟦_⟧S : forall {Γ Γ′} -> Γ ⊨ Γ′ -> ⟦ Γ ⟧C ⇒ ⟦ Γ′ ⟧C
⟦ func f e ⟧ = ⟦ f ⟧F ∘ ⟦ e ⟧
⟦ var ⟧ = π₂
⟦ unit ⟧ = T.!
⟦ pair e e₁ ⟧ = ⟨ ⟦ e ⟧ , ⟦ e₁ ⟧ ⟩
⟦ fst e ⟧ = π₁ ∘ ⟦ e ⟧
⟦ snd e ⟧ = π₂ ∘ ⟦ e ⟧
⟦ abs e ⟧ = λg ⟦ e ⟧
⟦ app e e₁ ⟧ = eval′ ∘ ⟨ ⟦ e ⟧ , ⟦ e₁ ⟧ ⟩
⟦ e [ γ ] ⟧ = ⟦ e ⟧ ∘ ⟦ γ ⟧S
⟦ id ⟧S = Category.id 𝒞
⟦ γ ∙ γ₁ ⟧S = ⟦ γ ⟧S ∘ ⟦ γ₁ ⟧S
⟦ weaken ⟧S = π₁
⟦ ext γ e ⟧S = ⟨ ⟦ γ ⟧S , ⟦ e ⟧ ⟩
⟦ ! ⟧S = T.!
⟦_⟧G_ : Gr -> (M : Structure) -> Obj
⟦_⟧G_ g M = Structure.⟦_⟧G M g
⟦_⟧T_ : Type -> (M : Structure) -> Obj
⟦_⟧T_ A M = Structure.⟦_⟧T M A
⟦_⟧F_ : (f : Func) -> (M : Structure) -> Structure.⟦_⟧T M (dom f) ⇒ Structure.⟦_⟧T M (cod f)
⟦_⟧F_ f M = Structure.⟦_⟧F M f
⟦_⟧_ : forall {Γ A} -> Γ ⊢ A -> (M : Structure) -> Structure.⟦_⟧C M Γ ⇒ Structure.⟦_⟧T M A
⟦_⟧_ e M = Structure.⟦_⟧ M e
|
{
"alphanum_fraction": 0.5299145299,
"avg_line_length": 26.4642857143,
"ext": "agda",
"hexsha": "2b23533e75bf63565113acca5ce7992740482bf9",
"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": "7541ab22debdfe9d529ac7a210e5bd102c788ad9",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "elpinal/exsub-ccc",
"max_forks_repo_path": "Semantics.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7541ab22debdfe9d529ac7a210e5bd102c788ad9",
"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": "elpinal/exsub-ccc",
"max_issues_repo_path": "Semantics.agda",
"max_line_length": 94,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "7541ab22debdfe9d529ac7a210e5bd102c788ad9",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "elpinal/exsub-ccc",
"max_stars_repo_path": "Semantics.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T13:30:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-02-05T06:16:32.000Z",
"num_tokens": 1049,
"size": 2223
}
|
{-# OPTIONS --without-K #-}
module Util.Induction.WellFounded where
open import Induction.WellFounded public using
( Acc ; acc ; WellFounded ; module Subrelation ; module InverseImage
; module TransitiveClosure ; module Lexicographic )
open import Relation.Binary using (Rel)
open import Util.HoTT.FunctionalExtensionality using (funext)
open import Util.HoTT.HLevel using (IsProp ; ∀-IsProp)
open import Util.Prelude
module _ {α β} {A : Set α} {_<_ : Rel A β} where
Acc-IsProp : ∀ {x} → IsProp (Acc _<_ x)
Acc-IsProp (acc rs₀) (acc rs₁)
= cong acc (funext λ y → funext λ y<x → Acc-IsProp _ _)
WellFounded-IsProp : IsProp (WellFounded _<_)
WellFounded-IsProp = ∀-IsProp λ _ → Acc-IsProp
wfInd-acc : ∀ {γ} (P : A → Set γ)
→ (∀ x → (∀ y → y < x → P y) → P x)
→ ∀ x → Acc _<_ x → P x
wfInd-acc P f x (acc rs) = f x (λ y y<x → wfInd-acc P f y (rs y y<x))
mutual
wfIndΣ-acc : ∀ {γ} (P : A → Set γ)
→ (Q : ∀ x y → P x → P y → Set)
→ (f : ∀ x
→ (g : ∀ y → y < x → P y)
→ (∀ y y<x z z<x → Q y z (g y y<x) (g z z<x))
→ P x)
→ (∀ x g g-resp y h h-resp
→ (∀ z z<x z′ z′<y → Q z z′ (g z z<x) (h z′ z′<y))
→ Q x y (f x g g-resp) (f y h h-resp))
→ ∀ x → Acc _<_ x → P x
wfIndΣ-acc P Q f f-resp x (acc rs)
= f x
(λ y y<x → wfIndΣ-acc P Q f f-resp y (rs y y<x))
(λ y y<x z z<x
→ wfIndΣ-acc-resp P Q f f-resp y (rs y y<x) z (rs z z<x))
wfIndΣ-acc-resp : ∀ {γ} (P : A → Set γ)
→ (Q : ∀ x y → P x → P y → Set)
→ (f : ∀ x
→ (g : ∀ y → y < x → P y)
→ (∀ y y<x z z<x → Q y z (g y y<x) (g z z<x))
→ P x)
→ (f-resp : ∀ x g g-resp y h h-resp
→ (∀ z z<x z′ z′<y → Q z z′ (g z z<x) (h z′ z′<y))
→ Q x y (f x g g-resp) (f y h h-resp))
→ ∀ x x-acc y y-acc
→ Q x y (wfIndΣ-acc P Q f f-resp x x-acc) (wfIndΣ-acc P Q f f-resp y y-acc)
wfIndΣ-acc-resp P Q f f-resp x (acc rsx) y (acc rsy)
= f-resp _ _ _ _ _ _ λ z z<x z′ z′<y
→ wfIndΣ-acc-resp P Q f f-resp z (rsx z z<x) z′ (rsy z′ z′<y)
module Build (<-wf : WellFounded _<_) where
wfInd : ∀ {γ} (P : A → Set γ)
→ (∀ x → (∀ y → y < x → P y) → P x)
→ ∀ x → P x
wfInd P f x = wfInd-acc P f x (<-wf x)
wfRec : ∀ {γ} {B : Set γ}
→ (∀ x → (∀ y → y < x → B) → B)
→ A → B
wfRec = wfInd _
wfInd-unfold : ∀ {γ} (P : A → Set γ)
→ (f : ∀ x → (∀ y → y < x → P y) → P x)
→ (x : A)
→ wfInd P f x ≡ f x (λ y _ → wfInd P f y)
wfInd-unfold P f x with <-wf x
... | acc rs
= cong (f x)
(funext λ y → funext λ y<x →
cong (wfInd-acc P f y) (Acc-IsProp (rs y y<x) (<-wf y)))
wfRec-unfold : ∀ {γ} {B : Set γ}
→ (f : ∀ x → (∀ y → y < x → B) → B)
→ (x : A)
→ wfRec f x ≡ f x (λ y _ → wfRec f y)
wfRec-unfold = wfInd-unfold _
wfInd-ind : ∀ {γ} {P : A → Set γ}
→ (Q : ∀ x → P x → Set)
→ {f : ∀ x → (∀ y → y < x → P y) → P x}
→ (∀ x g
→ (∀ y y<x → Q y (g y y<x))
→ Q x (f x g))
→ {x : A}
→ Q x (wfInd P f x)
wfInd-ind {P = P} Q {f} f-resp
= wfInd (λ x → Q x (wfInd P f x))
(λ x rec → subst (Q x) (sym (wfInd-unfold P f x))
(f-resp _ _ rec))
_
module _ {γ} (P : A → Set γ)
(Q : ∀ x y → P x → P y → Set)
(f : ∀ x
→ (g : ∀ y → y < x → P y)
→ (∀ y y<x z z<x → Q y z (g y y<x) (g z z<x))
→ P x)
(f-resp : ∀ x g g-resp y h h-resp
→ (∀ z z<x z′ z′<y → Q z z′ (g z z<x) (h z′ z′<y))
→ Q x y (f x g g-resp) (f y h h-resp))
where
wfIndΣ : Σ[ f ∈ (∀ x → P x) ] (∀ x y → Q x y (f x) (f y))
wfIndΣ
= (λ x → wfIndΣ-acc P Q f f-resp x (<-wf x))
, λ x y → wfIndΣ-acc-resp P Q f f-resp x (<-wf x) y (<-wf y)
wfIndΣ-unfold : ∀ {x}
→ wfIndΣ .proj₁ x
≡ f x (λ y y<x → wfIndΣ .proj₁ y)
(λ y y<x z z<x → wfIndΣ .proj₂ y z)
wfIndΣ-unfold {x} with <-wf x
... | acc rs
= go rs (λ y y<x → <-wf y)
where
go : (p q : (y : A) → y < x → Acc _<_ y)
→ f x (λ y y<x → wfIndΣ-acc P Q f f-resp y (p y y<x))
(λ y y<x z z<x
→ wfIndΣ-acc-resp P Q f f-resp y (p y y<x) z (p z z<x))
≡ f x (λ y y<x → wfIndΣ-acc P Q f f-resp y (q y y<x))
(λ y y<x z z<x
→ wfIndΣ-acc-resp P Q f f-resp y (q y y<x) z (q z z<x))
go p q
rewrite (funext λ y → funext λ y<x → Acc-IsProp (p y y<x) (q y y<x))
= refl
wfIndΣ′ : Σ[ g ∈ (∀ x → P x) ]
Σ[ g-param ∈ (∀ x y → Q x y (g x) (g y)) ]
(∀ {x} → g x ≡ f x (λ y y<x → g y) (λ y y<x z z<x → g-param y z))
wfIndΣ′ = wfIndΣ .proj₁ , wfIndΣ .proj₂ , wfIndΣ-unfold
open Build public
module _ {α β γ δ} {A : Set α} {B : Set β} where
×-Rel : Rel A γ → Rel B δ → Rel (A × B) (γ ⊔ℓ δ)
×-Rel R S (a , b) (a′ , b′) = R a a′ × S b b′
×-wellFounded : {R : Rel A γ} {S : Rel B δ}
→ WellFounded R → WellFounded S → WellFounded (×-Rel R S)
×-wellFounded {R} {S} R-wf S-wf (a , b) = ×-acc (R-wf a) (S-wf b)
where
×-acc : ∀ {x y} → Acc R x → Acc S y → Acc (×-Rel R S) (x , y)
×-acc (acc rsa) (acc rsb)
= acc (λ { (a , b) (a<x , b<y) → ×-acc (rsa a a<x) (rsb b b<y) })
-- This is not in Build because the implementation uses wfInd at
-- (×-Rel _<_ _<_), but within Build, we can only use wfInd at
-- _<_.
wfInd-ind₂ : ∀ {α β} {A : Set α} {_<_ : Rel A β}
→ (<-wf : WellFounded _<_)
→ ∀ {γ} {P : A → Set γ}
→ (R : ∀ x y → P x → P y → Set)
→ {f : ∀ x → (∀ y → y < x → P y) → P x}
→ (∀ x x′ g g′
→ (∀ y y′ y<x y′<x → R y y′ (g y y<x) (g′ y′ y′<x))
→ R x x′ (f x g) (f x′ g′))
→ {x x′ : A}
→ R x x′ (wfInd <-wf P f x) (wfInd <-wf P f x′)
wfInd-ind₂ <-wf {P = P} R {f} f-resp
= wfInd (×-wellFounded <-wf <-wf)
(λ { (x , x′) → R x x′ (wfInd <-wf P f x) (wfInd <-wf P f x′)})
(λ where
(x , y) rec
→ subst₂ (R x y)
(sym (wfInd-unfold <-wf P f x))
(sym (wfInd-unfold <-wf P f y))
(f-resp x y _ _ λ x′ y′ x′<x y′<y → rec (x′ , y′) (x′<x , y′<y)))
_
|
{
"alphanum_fraction": 0.4251592357,
"avg_line_length": 31.5577889447,
"ext": "agda",
"hexsha": "aaf5540ecc450bc94ae65e558a21b467ef7f6eec",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JLimperg/msc-thesis-code",
"max_forks_repo_path": "src/Util/Induction/WellFounded.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JLimperg/msc-thesis-code",
"max_issues_repo_path": "src/Util/Induction/WellFounded.agda",
"max_line_length": 81,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JLimperg/msc-thesis-code",
"max_stars_repo_path": "src/Util/Induction/WellFounded.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-26T06:37:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-04-13T21:31:17.000Z",
"num_tokens": 2675,
"size": 6280
}
|
-- WARNING: This file was generated automatically by Vehicle
-- and should not be modified manually!
-- Metadata
-- - Agda version: 2.6.2
-- - AISEC version: 0.1.0.1
-- - Time generated: ???
{-# OPTIONS --allow-exec #-}
open import Vehicle
open import Vehicle.Data.Tensor
open import Data.Rational as ℚ using (ℚ)
open import Data.List
open import Relation.Binary.PropositionalEquality
module autoencoderError-output where
private
VEHICLE_PROJECT_FILE = "TODO_projectFile"
encode : Tensor ℚ (5 ∷ []) → Tensor ℚ (2 ∷ [])
encode = evaluate record
{ projectFile = VEHICLE_PROJECT_FILE
; networkUUID = "TODO_networkUUID"
}
decode : Tensor ℚ (2 ∷ []) → Tensor ℚ (5 ∷ [])
decode = evaluate record
{ projectFile = VEHICLE_PROJECT_FILE
; networkUUID = "TODO_networkUUID"
}
abstract
identity : ∀ (x : Tensor ℚ (5 ∷ [])) → decode (encode x) ≡ x
identity = checkProperty record
{ projectFile = VEHICLE_PROJECT_FILE
; propertyUUID = "TODO_propertyUUID"
}
|
{
"alphanum_fraction": 0.6985743381,
"avg_line_length": 25.8421052632,
"ext": "agda",
"hexsha": "d80741e89f8bf9fb68dade465fe0cd1a06b66f17",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2021-11-16T14:30:47.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-03-15T15:22:31.000Z",
"max_forks_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "wenkokke/vehicle",
"max_forks_repo_path": "examples/network/autoencoderError/autoencoderError-output.agda",
"max_issues_count": 53,
"max_issues_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674",
"max_issues_repo_issues_event_max_datetime": "2021-12-15T22:42:01.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-04-16T07:26:42.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "wenkokke/vehicle",
"max_issues_repo_path": "examples/network/autoencoderError/autoencoderError-output.agda",
"max_line_length": 62,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "41d8653d7e48a716f5085ec53171b29094669674",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "wenkokke/vehicle",
"max_stars_repo_path": "examples/network/autoencoderError/autoencoderError-output.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-01T01:35:39.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-02-24T05:55:15.000Z",
"num_tokens": 274,
"size": 982
}
|
{-# OPTIONS --without-K --rewriting #-}
{-
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.
favonia:
On 2017/05/08, I further partition the results into multiple
independent index[n].agda files because the garbage collection
is not really working.
-}
module index1 where
{- some group theory results -}
import groups.ReducedWord
import groups.ProductRepr
import groups.CoefficientExtensionality
{- homotopy groups of circles -}
import homotopy.LoopSpaceCircle
import homotopy.PinSn
import homotopy.HopfJunior
import homotopy.Hopf
{- cohomology -}
import cohomology.EMModel
import cohomology.Sigma
import cohomology.Coproduct
import cohomology.Torus
import cohomology.InverseInSusp
import cohomology.MayerVietoris
-- import cohomology.MayerVietorisExact -- FIXME
{- prop * prop is still a prop -}
import homotopy.PropJoinProp
{- a space with preassigned homotopy groups -}
import homotopy.SpaceFromGroups
{- pushout 3x3 lemma -}
{- These takes lots of time and memory to check. -}
-- import homotopy.3x3.Commutes -- commented out because this does not run on travis.
-- import homotopy.JoinAssoc3x3 -- commented out because this does not run on travis.
{- covering spaces -}
import homotopy.GroupSetsRepresentCovers
import homotopy.AnyUniversalCoverIsPathSet
import homotopy.PathSetIsInitalCover
import homotopy.CircleCover
{- van kampen -}
-- see index3.agda
{- blakers massey -}
-- see index3.agda
{- cw complexes -}
-- see index2.agda
-- There are some unported theorems
-- import Spaces.IntervalProps
-- import Algebra.F2NotCommutative
-- import Spaces.LoopSpaceDecidableWedgeCircles
-- import Homotopy.PullbackIsPullback
-- import Homotopy.PushoutIsPushout
-- import Homotopy.Truncation
-- import Sets.QuotientUP
|
{
"alphanum_fraction": 0.7869791667,
"avg_line_length": 25.6,
"ext": "agda",
"hexsha": "f9f2c9bdbdd4cbdabe200b97a2bb4cdfb888baba",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "theorems/index1.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "theorems/index1.agda",
"max_line_length": 85,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "theorems/index1.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 513,
"size": 1920
}
|
{-# OPTIONS --without-K --rewriting #-}
open import lib.Basics
open import lib.NConnected
open import lib.NType2
open import lib.types.Paths
open import lib.types.Pi
open import lib.types.Truncation
open import lib.types.Unit
open import lib.types.Bool
open import lib.types.Suspension
open import lib.types.IteratedSuspension
module lib.types.Circle where
{-
Idea :
data S¹ : Type₀ where
base : S¹
loop : base == base
I’m using Dan Licata’s trick to have a higher inductive type with definitional
reduction rule for [base]
-}
{-
favonia (2016/05): Now [Circle] is defined as [Sphere 1].
-}
module _ where
-- (already defined in IteratedSuspension.agda)
-- S¹ : Type₀
-- S¹ = Sphere 1
base : S¹
base = north
loop : base == base
loop = σloop ⊙Bool false
module S¹Elim {i} {P : S¹ → Type i} (base* : P base)
(loop* : base* == base* [ P ↓ loop ]) where
private
north* = base*
south* = transport P (merid false) base*
merid*-general :
∀ {x : S¹} (p q : base == x)
(loop* : base* == base* [ P ↓ p ∙ ! q ]) (b : Bool)
→ base* == transport P p base* [ P ↓ Bool-rec q p b ]
merid*-general idp q loop* false = idp
merid*-general idp q loop* true = !ᵈ' loop*
merid* : ∀ (b : Bool) → north* == south* [ P ↓ merid b ]
merid* false = merid*-general (merid false) (merid true) loop* false
merid* true = merid*-general (merid false) (merid true) loop* true
module SE = SuspElim north* south* merid*
f : Π S¹ P
f = SE.f
private
merid*-general-lemma :
∀ {x : S¹} (p q : base == x) (loop* : base* == base* [ P ↓ p ∙ ! q ])
→ merid*-general p q loop* false ◃ !ᵈ (merid*-general p q loop* true) == loop*
merid*-general-lemma idp q loop* = idp◃ _ ∙ !ᵈ-!ᵈ' loop*
loop-β : apd f loop == loop*
loop-β =
apd f loop
=⟨ apd-∙ f (merid false) (! (merid true)) ⟩
apd f (merid false) ◃ apd f (! (merid true))
=⟨ apd-! f (merid true) |in-ctx apd f (merid false) ◃_ ⟩
apd f (merid false) ◃ !ᵈ (apd f (merid true))
=⟨ SE.merid-β false |in-ctx _◃ !ᵈ (apd f (merid true)) ⟩
merid* false ◃ !ᵈ (apd f (merid true))
=⟨ SE.merid-β true |in-ctx (λ p → merid* false ◃ !ᵈ p) ⟩
merid* false ◃ !ᵈ (merid* true)
=⟨ merid*-general-lemma (merid false) (merid true) loop* ⟩
loop*
=∎
open S¹Elim public using () renaming (f to S¹-elim)
module S¹Rec {i} {A : Type i} (base* : A) (loop* : base* == base*) where
private
module M = S¹Elim base* (↓-cst-in loop*)
f : S¹ → A
f = M.f
loop-β : ap f loop == loop*
loop-β = apd=cst-in {f = f} M.loop-β
open S¹Rec public using () renaming (f to S¹-rec)
S¹-rec-η : ∀ {i} {A : Type i} (f : S¹ → A)
→ ∀ x → S¹-rec (f base) (ap f loop) x == f x
S¹-rec-η f = S¹-elim idp (↓-='-in' $ ! $ S¹Rec.loop-β (f base) (ap f loop))
module S¹RecType {i} (A : Type i) (e : A ≃ A) where
open S¹Rec A (ua e) public
coe-loop-β : (a : A) → coe (ap f loop) a == –> e a
coe-loop-β a =
coe (ap f loop) a =⟨ loop-β |in-ctx (λ u → coe u a) ⟩
coe (ua e) a =⟨ coe-β e a ⟩
–> e a =∎
coe!-loop-β : (a : A) → coe! (ap f loop) a == <– e a
coe!-loop-β a =
coe! (ap f loop) a =⟨ loop-β |in-ctx (λ u → coe! u a) ⟩
coe! (ua e) a =⟨ coe!-β e a ⟩
<– e a =∎
↓-loop-out : {a a' : A} → a == a' [ f ↓ loop ] → –> e a == a'
↓-loop-out {a} {a'} p =
–> e a =⟨ ! (coe-loop-β a) ⟩
coe (ap f loop) a =⟨ to-transp p ⟩
a' =∎
import lib.types.Generic1HIT as Generic1HIT
module S¹G = Generic1HIT Unit Unit (idf _) (idf _)
module P = S¹G.RecType (cst A) (cst e)
private
generic-S¹ : Σ S¹ f == Σ S¹G.T P.f
generic-S¹ = eqv-tot where
module To = S¹Rec (S¹G.cc tt) (S¹G.pp tt)
to = To.f
module From = S¹G.Rec (cst base) (cst loop)
from : S¹G.T → S¹
from = From.f
abstract
to-from : (x : S¹G.T) → to (from x) == x
to-from = S¹G.elim (λ _ → idp) (λ _ → ↓-∘=idf-in' to from
(ap to (ap from (S¹G.pp tt)) =⟨ From.pp-β tt |in-ctx ap to ⟩
ap to loop =⟨ To.loop-β ⟩
S¹G.pp tt =∎))
from-to : (x : S¹) → from (to x) == x
from-to = S¹-elim idp (↓-∘=idf-in' from to
(ap from (ap to loop) =⟨ To.loop-β |in-ctx ap from ⟩
ap from (S¹G.pp tt) =⟨ From.pp-β tt ⟩
loop =∎))
eqv : S¹ ≃ S¹G.T
eqv = equiv to from to-from from-to
eqv-fib : f == P.f [ (λ X → (X → Type _)) ↓ ua eqv ]
eqv-fib =
↓-app→cst-in (λ {t} p → S¹-elim {P = λ t → f t == P.f (–> eqv t)} idp
(↓-='-in'
(ap (P.f ∘ (–> eqv)) loop =⟨ ap-∘ P.f to loop ⟩
ap P.f (ap to loop) =⟨ To.loop-β |in-ctx ap P.f ⟩
ap P.f (S¹G.pp tt) =⟨ P.pp-β tt ⟩
ua e =⟨ ! loop-β ⟩
ap f loop =∎))
t ∙ ap P.f (↓-idf-ua-out eqv p))
eqv-tot : Σ S¹ f == Σ S¹G.T P.f
eqv-tot = ap (uncurry Σ) (pair= (ua eqv) eqv-fib)
import lib.types.Flattening as Flattening
module FlatteningS¹ = Flattening
Unit Unit (idf _) (idf _) (cst A) (cst e)
open FlatteningS¹ public hiding (flattening-equiv; module P)
flattening-S¹ : Σ S¹ f == Wt
flattening-S¹ = generic-S¹ ∙ ua FlatteningS¹.flattening-equiv
instance
S¹-conn : is-connected 0 S¹
S¹-conn = Sphere-conn 1
|
{
"alphanum_fraction": 0.5239322533,
"avg_line_length": 29.8461538462,
"ext": "agda",
"hexsha": "8d4e411c119f019966161abd62bde5d09f106f19",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "core/lib/types/Circle.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "core/lib/types/Circle.agda",
"max_line_length": 86,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "core/lib/types/Circle.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2147,
"size": 5432
}
|
module _ where
open import Common.Prelude
open import Common.Reflection
postulate
stuck : TC ⊤
macro
not-so-good : Tactic
not-so-good hole = stuck
fail : Nat
fail = not-so-good
|
{
"alphanum_fraction": 0.7180851064,
"avg_line_length": 11.75,
"ext": "agda",
"hexsha": "c25a2db3ca1e4bfad8e2f4937b52dd9d10df3ebc",
"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/PostulateMacro.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/PostulateMacro.agda",
"max_line_length": 29,
"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/PostulateMacro.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": 54,
"size": 188
}
|
import Issue2447.Type-error
|
{
"alphanum_fraction": 0.8571428571,
"avg_line_length": 14,
"ext": "agda",
"hexsha": "29c090a6a134659ca3bdf7c886571a4b76fcb8b8",
"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/Issue2447b.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/Issue2447b.agda",
"max_line_length": 27,
"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/Issue2447b.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": 28
}
|
-- Monoidal categories
{-# OPTIONS --safe #-}
module Cubical.Categories.Monoidal.Base where
open import Cubical.Categories.Category.Base
open import Cubical.Categories.Constructions.BinProduct
open import Cubical.Categories.Functor.Base
open import Cubical.Categories.Functor.BinProduct
open import Cubical.Categories.Morphism
open import Cubical.Categories.NaturalTransformation.Base
open import Cubical.Foundations.Prelude
module _ {ℓ ℓ' : Level} (C : Category ℓ ℓ') where
open Category C
private
record TensorStr : Type (ℓ-max ℓ ℓ') where
field
─⊗─ : Functor (C × C) C
unit : ob
open Functor
-- Useful tensor product notation
_⊗_ : ob → ob → ob
x ⊗ y = ─⊗─ .F-ob (x , y)
_⊗ₕ_ : ∀ {x y z w} → Hom[ x , y ] → Hom[ z , w ]
→ Hom[ x ⊗ z , y ⊗ w ]
f ⊗ₕ g = ─⊗─ .F-hom (f , g)
record StrictMonStr : Type (ℓ-max ℓ ℓ') where
field
tenstr : TensorStr
open TensorStr tenstr public
field
-- Axioms - strict
assoc : ∀ x y z → x ⊗ (y ⊗ z) ≡ (x ⊗ y) ⊗ z
idl : ∀ x → unit ⊗ x ≡ x
idr : ∀ x → x ⊗ unit ≡ x
record MonoidalStr : Type (ℓ-max ℓ ℓ') where
field
tenstr : TensorStr
open TensorStr tenstr public
private
-- Private names to make the axioms below look nice
x⊗[y⊗z] : Functor (C × C × C) C
x⊗[y⊗z] = ─⊗─ ∘F (𝟙⟨ C ⟩ ×F ─⊗─)
[x⊗y]⊗z : Functor (C × C × C) C
[x⊗y]⊗z = ─⊗─ ∘F (─⊗─ ×F 𝟙⟨ C ⟩) ∘F (×C-assoc C C C)
x = 𝟙⟨ C ⟩
1⊗x = ─⊗─ ∘F (rinj C C unit)
x⊗1 = ─⊗─ ∘F (linj C C unit)
field
-- "Axioms" - up to natural isomorphism
α : x⊗[y⊗z] ≅ᶜ [x⊗y]⊗z
η : 1⊗x ≅ᶜ x
ρ : x⊗1 ≅ᶜ x
open NatIso
-- More nice notations
α⟨_,_,_⟩ : (x y z : ob) → Hom[ x ⊗ (y ⊗ z) , (x ⊗ y) ⊗ z ]
α⟨ x , y , z ⟩ = α .trans ⟦ ( x , y , z ) ⟧
η⟨_⟩ : (x : ob) → Hom[ unit ⊗ x , x ]
η⟨ x ⟩ = η .trans ⟦ x ⟧
ρ⟨_⟩ : (x : ob) → Hom[ x ⊗ unit , x ]
ρ⟨ x ⟩ = ρ .trans ⟦ x ⟧
field
-- Coherence conditions
pentagon : ∀ w x y z →
id ⊗ₕ α⟨ x , y , z ⟩ ⋆ α⟨ w , x ⊗ y , z ⟩ ⋆ α⟨ w , x , y ⟩ ⊗ₕ id
≡ α⟨ w , x , y ⊗ z ⟩ ⋆ α⟨ w ⊗ x , y , z ⟩
triangle : ∀ x y →
α⟨ x , unit , y ⟩ ⋆ ρ⟨ x ⟩ ⊗ₕ id ≡ id ⊗ₕ η⟨ y ⟩
open isIso
-- Inverses of α, η, ρ for convenience
α⁻¹⟨_,_,_⟩ : (x y z : ob) → Hom[ (x ⊗ y) ⊗ z , x ⊗ (y ⊗ z) ]
α⁻¹⟨ x , y , z ⟩ = α .nIso (x , y , z) .inv
η⁻¹⟨_⟩ : (x : ob) → Hom[ x , unit ⊗ x ]
η⁻¹⟨ x ⟩ = η .nIso (x) .inv
ρ⁻¹⟨_⟩ : (x : ob) → Hom[ x , x ⊗ unit ]
ρ⁻¹⟨ x ⟩ = ρ .nIso (x) .inv
record StrictMonCategory ℓ ℓ' : Type (ℓ-suc (ℓ-max ℓ ℓ')) where
field
C : Category ℓ ℓ'
sms : StrictMonStr C
open Category C public
open StrictMonStr sms public
record MonoidalCategory ℓ ℓ' : Type (ℓ-suc (ℓ-max ℓ ℓ')) where
field
C : Category ℓ ℓ'
monstr : MonoidalStr C
open Category C public
open MonoidalStr monstr public
|
{
"alphanum_fraction": 0.5026845638,
"avg_line_length": 24.4262295082,
"ext": "agda",
"hexsha": "21a2c05fb810308dfb216bd0d18956daa3434ef5",
"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/Categories/Monoidal/Base.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/Categories/Monoidal/Base.agda",
"max_line_length": 76,
"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/Categories/Monoidal/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1349,
"size": 2980
}
|
{-# OPTIONS --copatterns #-}
module SplitResult where
open import Common.Product
test : {A B : Set} (a : A) (b : B) → A × B
test a b = {!!}
testFun : {A B : Set} (a : A) (b : B) → A × B
testFun = {!!}
|
{
"alphanum_fraction": 0.5242718447,
"avg_line_length": 15.8461538462,
"ext": "agda",
"hexsha": "c546e94dfde065392185a63d743ce078b33bbbdf",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "test/interaction/SplitResult.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "redfish64/autonomic-agda",
"max_issues_repo_path": "test/interaction/SplitResult.agda",
"max_line_length": 45,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/interaction/SplitResult.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 75,
"size": 206
}
|
-- | NOTE: This module can only represent file paths which are valid strings.
-- On Linux, a file path may be an arbitrary sequence of bytes, but using anything
-- except utf8 for file paths is a terrible idea.
--
-- What should happen if we come across a non utf8 path from an untrusted source?
-- crash -> denial-of-service
-- ignore -> maybe security holes
--
-- Currently, the behaviour for non-textual file paths is undefined.
module System.FilePath where
open import Prelude.Unit
open import Prelude.String
data Kind : Set where
Rel : Kind
Abs : Kind
abstract
record Path (kind : Kind) : Set where
constructor mkPath
field
path : String
open import Prelude.Monoid
open Path
_//_ : ∀ {k} → Path k → Path Rel → Path k
x // y = mkPath (path x <> "/" <> path y)
_∙_ : ∀ {k} → Path k → String → Path k
p ∙ ext = mkPath (path p <> "." <> ext)
toString : ∀ {k} → Path k → String
toString p = path p
relative : String → Path Rel
relative = mkPath
absolute : String → Path Abs
absolute = mkPath
|
{
"alphanum_fraction": 0.6650717703,
"avg_line_length": 24.880952381,
"ext": "agda",
"hexsha": "fde40973d328974b2f66dd7279a3b749ee782699",
"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": "da4fca7744d317b8843f2bc80a923972f65548d3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "t-more/agda-prelude",
"max_forks_repo_path": "src/System/FilePath.agda",
"max_issues_count": 59,
"max_issues_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3",
"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": "t-more/agda-prelude",
"max_issues_repo_path": "src/System/FilePath.agda",
"max_line_length": 82,
"max_stars_count": 111,
"max_stars_repo_head_hexsha": "da4fca7744d317b8843f2bc80a923972f65548d3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "t-more/agda-prelude",
"max_stars_repo_path": "src/System/FilePath.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": 284,
"size": 1045
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.CommRing.Integers where
open import Cubical.Foundations.Prelude
open import Cubical.Algebra.CommRing
open import Cubical.HITs.Ints.BiInvInt
renaming (
_+_ to _+ℤ_;
-_ to _-ℤ_;
+-assoc to +ℤ-assoc;
+-comm to +ℤ-comm
)
BiInvIntAsCommRing : CommRing {ℓ-zero}
BiInvIntAsCommRing =
makeCommRing
zero (suc zero) _+ℤ_ _·_ _-ℤ_
isSetBiInvInt
+ℤ-assoc +-zero +-invʳ +ℤ-comm
·-assoc ·-identityʳ
(λ x y z → sym (·-distribˡ x y z))
·-comm
|
{
"alphanum_fraction": 0.6636363636,
"avg_line_length": 22.9166666667,
"ext": "agda",
"hexsha": "a759762e226d60a93ff538a4ff2b64fe58f8d7ef",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "dan-iel-lee/cubical",
"max_forks_repo_path": "Cubical/Algebra/CommRing/Integers.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fd8059ec3eed03f8280b4233753d00ad123ffce8",
"max_issues_repo_issues_event_max_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-01-27T02:07:48.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "dan-iel-lee/cubical",
"max_issues_repo_path": "Cubical/Algebra/CommRing/Integers.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/Algebra/CommRing/Integers.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 204,
"size": 550
}
|
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020 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.Prelude
open import LibraBFT.Lemmas
open import LibraBFT.Base.PKCS
open import LibraBFT.Base.Types
open import LibraBFT.Abstract.Types
open import LibraBFT.Yasm.Base
open import LibraBFT.Yasm.AvailableEpochs using (AvailableEpochs) renaming (lookup'' to EC-lookup)
import LibraBFT.Yasm.AvailableEpochs as AE
-- This module provides some definitions and properties that facilitate
-- proofs of properties about a distributed system modeled by Yasm.System
-- paramaterized by some SystemParameters.
module LibraBFT.Yasm.Properties (parms : SystemParameters) where
open import LibraBFT.Yasm.System parms
open SystemParameters parms
open EpochConfig
-- A ValidPartForPK collects the assumptions about what a /part/ in the outputs of an honest verifier
-- satisfies: (i) the epoch field is consistent with the existent epochs and (ii) the verifier is
-- a member of the associated epoch config, and (iii) has the given PK in that epoch.
record ValidPartForPK {e}(𝓔s : AvailableEpochs e)(part : Part)(pk : PK) : Set₁ where
constructor mkValidPartForPK
field
vp-epoch : part-epoch part < e
vp-ec : EpochConfig
vp-ec-≡ : AE.lookup'' 𝓔s vp-epoch ≡ vp-ec
vp-member : Member vp-ec
vp-key : getPubKey vp-ec vp-member ≡ pk
open ValidPartForPK public
-- A valid part remains valid when new epochs are added
ValidPartForPK-stable-epoch : ∀{e part pk}{𝓔s : AvailableEpochs e}(𝓔 : EpochConfigFor e)
→ ValidPartForPK 𝓔s part pk
→ ValidPartForPK (AE.append 𝓔 𝓔s) part pk
ValidPartForPK-stable-epoch {pk = pk} {𝓔s} 𝓔 (mkValidPartForPK e ec refl emem vpk) = record
{ vp-epoch = ≤-step e
; vp-ec = ec
; vp-ec-≡ = AE.lookup''-≤-step-lemma 𝓔s 𝓔 e
; vp-member = emem
; vp-key = vpk
}
-- A valid part remains valid
ValidPartForPK-stable : ∀{e e'}{st : SystemState e}{st' : SystemState e'}
→ Step* st st' → ∀{part pk}
→ ValidPartForPK (availEpochs st) part pk
→ ValidPartForPK (availEpochs st') part pk
ValidPartForPK-stable step-0 v = v
ValidPartForPK-stable (step-s st (step-epoch 𝓔)) v
= ValidPartForPK-stable-epoch 𝓔 (ValidPartForPK-stable st v)
ValidPartForPK-stable (step-s st (step-peer _)) v
= ValidPartForPK-stable st v
-- We say that an implementation produces only valid parts iff all parts of every message in the
-- output of a 'StepPeerState' are either: (i) a valid new part (i.e., the part is valid and has
-- not been included in a previously sent message with the same signature), or (ii) the part been
-- included in a previously sent message with the same signature.
StepPeerState-AllValidParts : Set₁
StepPeerState-AllValidParts = ∀{e s m part pk outs α}{𝓔s : AvailableEpochs e}{st : SystemState e}
→ (r : ReachableSystemState st)
→ Meta-Honest-PK pk
→ StepPeerState α 𝓔s (msgPool st) (Map-lookup α (peerStates st)) s outs
→ m ∈ outs → part ⊂Msg m → (ver : WithVerSig pk part)
-- NOTE: this doesn't DIRECTLY imply that nobody else has sent a
-- message with the same signature just that the author of the part
-- hasn't.
→ (ValidPartForPK 𝓔s part pk × ¬ (MsgWithSig∈ pk (ver-signature ver) (msgPool st)))
⊎ MsgWithSig∈ pk (ver-signature ver) (msgPool st)
-- A /part/ was introduced by a specific step when:
IsValidNewPart : ∀{e e'}{pre : SystemState e}{post : SystemState e'} → Signature → PK → Step pre post → Set₁
IsValidNewPart _ _ (step-epoch _) = Lift (ℓ+1 0ℓ) ⊥
-- said step is a /step-peer/ and
IsValidNewPart {pre = pre} sig pk (step-peer pstep)
-- the part has never been seen before
= ¬ (MsgWithSig∈ pk sig (msgPool pre))
× Σ (MsgWithSig∈ pk sig (msgPool (StepPeer-post pstep)))
(λ m → ValidPartForPK (availEpochs pre) (msgPart m) pk)
-- When we can prove that the implementation provided by 'parms' at the
-- top of this module satisfies 'StepPeerState-AllValidParts', we can
-- prove a number of useful structural properties:
-- TODO-2: Refactor into a file (LibraBFT.Yasm.Properties.Structural) later on
-- if this grows too large.
module Structural (sps-avp : StepPeerState-AllValidParts) where
-- We can unwind the state and highlight the step where a part was
-- originally sent. This 'unwind' function combined with Any-Step-elim
-- enables a powerful form of reasoning. The 'honestVoteEpoch' below
-- exemplifies this well.
unwind : ∀{e}{st : SystemState e}(tr : ReachableSystemState st)
→ ∀{p m σ pk} → Meta-Honest-PK pk
→ p ⊂Msg m → (σ , m) ∈ msgPool st → (ver : WithVerSig pk p)
→ Any-Step ((IsValidNewPart (ver-signature ver) pk)) tr
unwind (step-s tr (step-epoch _)) hpk p⊂m m∈sm sig
= step-there (unwind tr hpk p⊂m m∈sm sig)
unwind (step-s tr (step-peer {pid = β} {outs = outs} {pre = pre} sp)) hpk p⊂m m∈sm sig
with Any-++⁻ (List-map (β ,_) outs) {msgPool pre} m∈sm
...| inj₂ furtherBack = step-there (unwind tr hpk p⊂m furtherBack sig)
...| inj₁ thisStep
with sp
...| step-cheat fm isCheat
with thisStep
...| here refl
with isCheat p⊂m sig
...| inj₁ abs = ⊥-elim (hpk abs)
...| inj₂ sentb4
with unwind tr {p = msgPart sentb4} hpk (msg⊆ sentb4) (msg∈pool sentb4) (msgSigned sentb4)
...| res rewrite msgSameSig sentb4 = step-there res
unwind (step-s tr (step-peer {pid = β} {outs = outs} {pre = pre} sp)) hpk p⊂m m∈sm sig
| inj₁ thisStep
| step-honest x
with Any-satisfied-∈ (Any-map⁻ thisStep)
...| (m , refl , m∈outs)
with sps-avp tr hpk x m∈outs p⊂m sig
...| inj₂ sentb4 with unwind tr {p = msgPart sentb4} hpk (msg⊆ sentb4) (msg∈pool sentb4) (msgSigned sentb4)
...| res rewrite msgSameSig sentb4 = step-there res
unwind (step-s tr (step-peer {pid = β} {outs = outs} {pre = pre} sp)) {p} hpk p⊂m m∈sm sig
| inj₁ thisStep
| step-honest x
| (m , refl , m∈outs)
| inj₁ (valid-part , notBefore) =
step-here tr (notBefore , MsgWithSig∈-++ˡ (mkMsgWithSig∈ _ _ p⊂m β thisStep sig refl)
, valid-part)
-- Unwind is inconvenient to use by itself because we have to do
-- induction on Any-Step-elim. The 'honestPartValid' property below
-- provides a fairly general result conveniently: for every part
-- verifiable with an honest PK, there is a msg with the same
-- signature that is valid for some pid.
honestPartValid : ∀ {e st} → ReachableSystemState {e} st → ∀ {pk nm v sender}
→ Meta-Honest-PK pk
→ v ⊂Msg nm → (sender , nm) ∈ msgPool st → (ver : WithVerSig pk v)
→ Σ (MsgWithSig∈ pk (ver-signature ver) (msgPool st))
(λ msg → (ValidPartForPK (availEpochs st) (msgPart msg) pk))
honestPartValid {e} {st} r {pk = pk} hpk v⊂m m∈pool ver
-- We extract two pieces of important information from the place where the part 'v'
-- was first sent: (a) there is a message with the same signature /in the current pool/
-- and (b) its epoch is less than e.
= Any-Step-elim (λ { {st = step-epoch _} ()
; {st = step-peer ps} (_ , new , valid) tr
→ MsgWithSig∈-Step* tr new
, ValidPartForPK-stable tr
(subst (λ P → ValidPartForPK _ P pk)
(MsgWithSig∈-Step*-part tr new) valid)
})
(unwind r hpk v⊂m m∈pool ver)
-- Unforgeability is also an important property stating that every part that is
-- verified with an honest public key has either been sent by α or is a replay
-- of another message sent before.
ext-unforgeability'
: ∀{e α m part pk}{st : SystemState e} → ReachableSystemState st
-- If a message m has been sent by α, containing part
→ (α , m) ∈ msgPool st → part ⊂Msg m
-- And the part can be verified with an honest public key,
→ (sig : WithVerSig pk part) → Meta-Honest-PK pk
-- then either the part is a valid part by α (meaning that α can
-- sign the part itself) or a message with the same signature has
-- been sent previously.
→ ValidPartForPK (availEpochs st) part pk
⊎ MsgWithSig∈ pk (ver-signature sig) (msgPool st)
ext-unforgeability' (step-s st (step-epoch 𝓔)) m∈sm p⊆m sig hpk
= ⊎-map (ValidPartForPK-stable-epoch 𝓔) id (ext-unforgeability' st m∈sm p⊆m sig hpk)
ext-unforgeability' {part = part} (step-s st (step-peer {pid = β} {outs = outs} {pre = pre} sp)) m∈sm p⊆m sig hpk
with Any-++⁻ (List-map (β ,_) outs) {msgPool pre} m∈sm
...| inj₂ furtherBack = MsgWithSig∈-++ʳ <⊎$> (ext-unforgeability' st furtherBack p⊆m sig hpk)
...| inj₁ thisStep
with sp
...| step-cheat fm isCheat
with thisStep
...| here refl
with isCheat p⊆m sig
...| inj₁ abs = ⊥-elim (hpk abs)
...| inj₂ sentb4 = inj₂ (MsgWithSig∈-++ʳ sentb4)
ext-unforgeability' {m = m} {part = part} (step-s st (step-peer {pid = β} {outs = outs} {pre = pre} sp)) m∈sm p⊆m sig hpk
| inj₁ thisStep
| step-honest x
with Any-satisfied-∈ (Any-map⁻ thisStep)
...| (m , refl , m∈outs) = ⊎-map proj₁ MsgWithSig∈-++ʳ (sps-avp st hpk x m∈outs p⊆m sig)
-- The ext-unforgeability' property can be collapsed in a single clause.
-- TODO-2: so far, ext-unforgeability is used only to get a MsgWithSig∈ that is passed to
-- msgWithSigSentByAuthor, which duplicates some of the reasoning in the proof of
-- ext-unforgeability'; should these properties possibly be combined into one simpler proof?
ext-unforgeability
: ∀{e α₀ m part pk}{st : SystemState e} → ReachableSystemState st
→ (α₀ , m) ∈ msgPool st → part ⊂Msg m
→ (sig : WithVerSig pk part) → Meta-Honest-PK pk
→ MsgWithSig∈ pk (ver-signature sig) (msgPool st)
ext-unforgeability {_} {α₀} {m} {st = st} rst m∈sm p⊂m sig hpk
with ext-unforgeability' rst m∈sm p⊂m sig hpk
...| inj₁ p
= mkMsgWithSig∈ _ _ p⊂m α₀ m∈sm sig refl
...| inj₂ sentb4 = sentb4
¬cheatForgeNew : ∀ {e pid pk vsig mst outs m}{st : SystemState e}
→ (sp : StepPeer st pid mst outs)
→ outs ≡ m ∷ []
→ (ic : isCheat sp)
→ Meta-Honest-PK pk
→ MsgWithSig∈ pk vsig ((pid , m) ∷ msgPool st)
→ MsgWithSig∈ pk vsig (msgPool st)
¬cheatForgeNew sc@(step-cheat fm isCheat) refl _ hpk mws
with msg∈pool mws
...| there m∈pool = mkMsgWithSig∈ (msgWhole mws) (msgPart mws) (msg⊆ mws) (msgSender mws) m∈pool (msgSigned mws) (msgSameSig mws)
...| here m∈pool
with isCheat (subst (msgPart mws ⊂Msg_) (cong proj₂ m∈pool) (msg⊆ mws)) (msgSigned mws)
...| inj₁ dis = ⊥-elim (hpk dis)
...| inj₂ mws' rewrite msgSameSig mws = mws'
msgWithSigSentByAuthor : ∀ {e pk sig}{st : SystemState e}
→ ReachableSystemState st
→ Meta-Honest-PK pk
→ MsgWithSig∈ pk sig (msgPool st)
→ Σ (MsgWithSig∈ pk sig (msgPool st))
λ mws → ValidPartForPK (availEpochs st) (msgPart mws) pk
msgWithSigSentByAuthor step-0 _ ()
msgWithSigSentByAuthor (step-s {pre = pre} preach (step-epoch 𝓔)) hpk mws
rewrite step-epoch-does-not-send pre 𝓔
with msgWithSigSentByAuthor preach hpk mws
...| mws' , vpb = mws' , ValidPartForPK-stable {st = pre} (step-s step-0 (step-epoch 𝓔)) vpb
msgWithSigSentByAuthor {pk = pk} (step-s {pre = pre} preach (step-peer theStep@(step-cheat fm cheatCons))) hpk mws
with (¬cheatForgeNew theStep refl unit hpk mws)
...| mws'
with msgWithSigSentByAuthor preach hpk mws'
...| mws'' , vpb'' = MsgWithSig∈-++ʳ mws'' , vpb''
msgWithSigSentByAuthor {e} (step-s {pre = pre} preach (step-peer {pid = pid} {outs = outs} (step-honest sps))) hpk mws
with Any-++⁻ (List-map (pid ,_) outs) {msgPool pre} (msg∈pool mws)
...| inj₂ furtherBack
with msgWithSigSentByAuthor preach hpk (MsgWithSig∈-transp mws furtherBack)
...| mws' , vpb' = MsgWithSig∈-++ʳ mws' , vpb'
msgWithSigSentByAuthor {e} (step-s {pre = pre} preach (step-peer {pid = pid} {outs = outs} (step-honest sps))) hpk mws
| inj₁ thisStep
with Any-satisfied-∈ (Any-map⁻ thisStep)
...| (m' , refl , m∈outs)
with sps-avp preach hpk sps m∈outs (msg⊆ mws) (msgSigned mws)
...| inj₁ (vpbα₀ , _) = mws , vpbα₀
...| inj₂ mws'
with msgWithSigSentByAuthor preach hpk mws'
...| mws'' , vpb'' rewrite sym (msgSameSig mws) = MsgWithSig∈-++ʳ mws'' , vpb''
|
{
"alphanum_fraction": 0.6101365977,
"avg_line_length": 52.537254902,
"ext": "agda",
"hexsha": "bdfc81a45210c2a94bf14eaa0b73c8351632ae5e",
"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": "b7dd98dd90d98fbb934ef8cb4f3314940986790d",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "lisandrasilva/bft-consensus-agda-1",
"max_forks_repo_path": "LibraBFT/Yasm/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b7dd98dd90d98fbb934ef8cb4f3314940986790d",
"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": "lisandrasilva/bft-consensus-agda-1",
"max_issues_repo_path": "LibraBFT/Yasm/Properties.agda",
"max_line_length": 134,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b7dd98dd90d98fbb934ef8cb4f3314940986790d",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "lisandrasilva/bft-consensus-agda-1",
"max_stars_repo_path": "LibraBFT/Yasm/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4195,
"size": 13397
}
|
module Issue3080 where
open import Agda.Builtin.Nat
open import Agda.Builtin.Equality
data Fin (m : Nat) : Set where
fzero' : (n : Nat) (p : m ≡ suc n) → Fin m
fsuc' : (n : Nat) (p : m ≡ suc n) (i : Fin n) → Fin m
lift : (m : Nat) (i : Fin m) → Fin (suc m)
lift m (fzero' n p) = {!p!}
lift m (fsuc' n p i) = {!p!} -- Split on p here
module PatternSynonyms where
pattern fzero n = fzero' n refl
pattern fsuc n i = fsuc' n refl i
-- Splitting produces
--
-- lift .(suc n) (.Issue3080.PatternSynonyms.fsuc n i) = ?
--
-- which fails to parse.
|
{
"alphanum_fraction": 0.5905096661,
"avg_line_length": 22.76,
"ext": "agda",
"hexsha": "0af32696a6b97f91e57e08b41bcc3b29f336ebf9",
"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/Issue3080.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/Issue3080.agda",
"max_line_length": 60,
"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/Issue3080.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": 569
}
|
open import Relation.Binary.Core
module InsertSort.Impl1.Correctness.Order {A : Set}
(_≤_ : A → A → Set)
(tot≤ : Total _≤_) where
open import Data.List
open import Data.Sum
open import InsertSort.Impl1 _≤_ tot≤
open import List.Sorted _≤_
lemma-insert-sorted : {xs : List A}(x : A) → Sorted xs → Sorted (insert x xs)
lemma-insert-sorted {xs = .[]} x nils = singls x
lemma-insert-sorted {xs = .([ y ])} x (singls y)
with tot≤ x y
... | inj₁ x≤y = conss x≤y (singls y)
... | inj₂ y≤x = conss y≤x (singls x)
lemma-insert-sorted x (conss {y} {z} {ys} y≤z szys)
with tot≤ x y
... | inj₁ x≤y = conss x≤y (conss y≤z szys)
... | inj₂ y≤x
with tot≤ x z | lemma-insert-sorted x szys
... | inj₁ x≤z | _ = conss y≤x (conss x≤z szys)
... | inj₂ z≤x | h = conss y≤z h
theorem-insertSort-sorted : (xs : List A) → Sorted (insertSort xs)
theorem-insertSort-sorted [] = nils
theorem-insertSort-sorted (x ∷ xs) = lemma-insert-sorted x (theorem-insertSort-sorted xs)
|
{
"alphanum_fraction": 0.614017769,
"avg_line_length": 32.6774193548,
"ext": "agda",
"hexsha": "3068da93d10bacba9fe4bcf79b488018e4f890ae",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bgbianchi/sorting",
"max_forks_repo_path": "agda/InsertSort/Impl1/Correctness/Order.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bgbianchi/sorting",
"max_issues_repo_path": "agda/InsertSort/Impl1/Correctness/Order.agda",
"max_line_length": 90,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bgbianchi/sorting",
"max_stars_repo_path": "agda/InsertSort/Impl1/Correctness/Order.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z",
"num_tokens": 377,
"size": 1013
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Natural numbers represented in binary natively in Agda.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Nat.Binary where
open import Data.Nat.Binary.Base public
open import Data.Nat.Binary.Properties public using (_≟_)
|
{
"alphanum_fraction": 0.4739454094,
"avg_line_length": 28.7857142857,
"ext": "agda",
"hexsha": "9b84b0102e4814c473d7725f63986e13e9c913d6",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/Nat/Binary.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/Nat/Binary.agda",
"max_line_length": 72,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/Nat/Binary.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": 62,
"size": 403
}
|
open import Common.Prelude
open import Common.Reflection
module TermSplicingLooping where
mutual
f : Set -> Set
f = unquote (give (def (quote f) []))
|
{
"alphanum_fraction": 0.7243589744,
"avg_line_length": 17.3333333333,
"ext": "agda",
"hexsha": "b3a53e0ab722a88bea496c8862651002b8242b20",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/Fail/TermSplicingLooping.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/Fail/TermSplicingLooping.agda",
"max_line_length": 39,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/Fail/TermSplicingLooping.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": 44,
"size": 156
}
|
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Instance.Properties.Setoids.Complete where
open import Level
open import Data.Product using (Σ; proj₁; proj₂; _,_; Σ-syntax; _×_; -,_)
open import Function.Equality using (Π)
open import Relation.Binary using (Setoid; Rel)
open import Categories.Category using (Category; _[_,_])
open import Categories.Functor
open import Categories.Category.Instance.Setoids
open import Categories.Category.Complete
import Categories.Category.Construction.Cones as Co
open Π using (_⟨$⟩_)
Setoids-Complete : (o ℓ e c ℓ′ : Level) → Complete o ℓ e (Setoids (c ⊔ ℓ ⊔ o ⊔ ℓ′) (o ⊔ ℓ′))
Setoids-Complete o ℓ e c ℓ′ {J} F =
record
{ terminal = record
{ ⊤ = record
{ N = record
{ Carrier = Σ (∀ j → F₀.Carrier j)
(λ S → ∀ {X Y} (f : J [ X , Y ]) → [ F₀ Y ] F₁ f ⟨$⟩ S X ≈ S Y)
; _≈_ = λ { (S₁ , _) (S₂ , _) → ∀ j → [ F₀ j ] S₁ j ≈ S₂ j }
; isEquivalence = record
{ refl = λ j → F₀.refl j
; sym = λ a≈b j → F₀.sym j (a≈b j)
; trans = λ a≈b b≈c j → F₀.trans j (a≈b j) (b≈c j)
}
}
; apex = record
{ ψ = λ j → record
{ _⟨$⟩_ = λ { (S , _) → S j }
; cong = λ eq → eq j
}
; commute = λ { {X} {Y} X⇒Y {_ , eq} {y} f≈g → F₀.trans Y (eq X⇒Y) (f≈g Y) }
}
}
; ⊤-is-terminal = record
{ ! = λ {K} →
let module K = Cone K
in record
{ arr = record
{ _⟨$⟩_ = λ x → (λ j → K.ψ j ⟨$⟩ x) , λ f → K.commute f (Setoid.refl K.N)
; cong = λ a≈b j → Π.cong (K.ψ j) a≈b
}
; commute = λ x≈y → Π.cong (K.ψ _) x≈y
}
; !-unique = λ {K} f x≈y j →
let module K = Cone K
in F₀.sym j (Cone⇒.commute f (Setoid.sym K.N x≈y))
}
}
}
where open Functor F
open Co F
module J = Category J
module F₀ j = Setoid (F₀ j)
[_]_≈_ = Setoid._≈_
|
{
"alphanum_fraction": 0.4826560951,
"avg_line_length": 32.0317460317,
"ext": "agda",
"hexsha": "fd386cbd4891687b16a73c85b3c063ee3dc826df",
"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/Properties/Setoids/Complete.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/Properties/Setoids/Complete.agda",
"max_line_length": 92,
"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/Properties/Setoids/Complete.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": 736,
"size": 2018
}
|
module Ints.Add.Assoc where
open import Ints
open import Nats renaming (suc to nsuc; _+_ to _:+:_)
open import Nats.Add.Assoc
open import Nats.Add.Comm
open import Ints.Add.Comm
open import Equality
open import Function
------------------------------------------------------------------------
-- internal stuffs
private
0+a=a : ∀ a → + 0 + a ≡ a
0+a=a (+ n ) = refl
0+a=a (-[1+ n ]) = refl
a+0=a : ∀ a → a + + 0 ≡ a
a+0=a a rewrite int-add-comm a (+ 0) | 0+a=a a = refl
z+/b+c/=/z+b/+c : ∀ b c → + 0 + (b + c) ≡ (+ 0 + b) + c
z+/b+c/=/z+b/+c (+ a ) (+ b ) = refl
z+/b+c/=/z+b/+c (-[1+ a ]) (-[1+ b ]) = refl
z+/b+c/=/z+b/+c (+ a ) (-[1+ b ])
rewrite 0+a=a (a ⊖ nsuc b) = refl
z+/b+c/=/z+b/+c (-[1+ a ]) (+ b )
rewrite 0+a=a (b ⊖ nsuc a) = refl
a+b=a--b : ∀ a b → a + b ≡ a - (- b)
a+b=a--b a (+ zero ) = refl
a+b=a--b a (+ nsuc n)
rewrite a+b=a--b a (+ n) = refl
a+b=a--b a (-[1+ n ]) = refl
a-b+c=a+c-b : ∀ a b c → a ⊖ b + + c ≡ a :+: c ⊖ b
a-b+c=a+c-b zero zero _ = refl
a-b+c=a+c-b zero (nsuc _) _ = refl
a-b+c=a+c-b (nsuc _) zero _ = refl
a-b+c=a+c-b (nsuc a) (nsuc b) c = a-b+c=a+c-b a b c
a+/b-c/=a+b-c : ∀ a b c → + a + (b ⊖ c) ≡ a :+: b ⊖ c
a+/b-c/=a+b-c a b c
rewrite int-add-comm (+ a) $ b ⊖ c
| a-b+c=a+c-b b c a
| nat-add-comm a b
= refl
b-c-a=b-/c+a/ : ∀ a b c → b ⊖ c + -[1+ a ] ≡ b ⊖ (nsuc c :+: a)
b-c-a=b-/c+a/ _ zero zero = refl
b-c-a=b-/c+a/ _ zero (nsuc _) = refl
b-c-a=b-/c+a/ _ (nsuc _) zero = refl
b-c-a=b-/c+a/ a (nsuc b) (nsuc c) = b-c-a=b-/c+a/ a b c
-a+/b-c/=b-/a+c/ : ∀ a b c → -[1+ a ] + (b ⊖ c) ≡ b ⊖ (nsuc a :+: c)
-a+/b-c/=b-/a+c/ a b c
rewrite int-add-comm -[1+ a ] $ b ⊖ c
| b-c-a=b-/c+a/ a b c
| nat-add-comm a c
= 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 rewrite 0+a=a (b + c) | 0+a=a b = refl
a+/b+c/=/a+b/+c a (+ zero) c rewrite 0+a=a c | a+0=a a = refl
a+/b+c/=/a+b/+c a b (+ zero) rewrite a+0=a b | a+0=a (a + b) = refl
a+/b+c/=/a+b/+c (+ a) (+ b) (+ c)
rewrite nat-add-assoc a b c = refl
a+/b+c/=/a+b/+c -[1+ a ] -[1+ b ] (+ nsuc c)
rewrite -a+/b-c/=b-/a+c/ a c b = refl
a+/b+c/=/a+b/+c -[1+ a ] (+ nsuc b) -[1+ c ]
rewrite -a+/b-c/=b-/a+c/ a b c
| b-c-a=b-/c+a/ c b a
= refl
a+/b+c/=/a+b/+c (+ nsuc a) -[1+ b ] -[1+ c ]
rewrite b-c-a=b-/c+a/ c a b = refl
a+/b+c/=/a+b/+c (+ nsuc a) -[1+ b ] (+ nsuc c)
rewrite a-b+c=a+c-b a b $ nsuc c
| a+/b-c/=a+b-c (nsuc a) c b
| sym $ nat-add-assoc a 1 c
| nat-add-comm a 1
= refl
a+/b+c/=/a+b/+c -[1+ a ] (+ nsuc b) (+ nsuc c)
rewrite a-b+c=a+c-b b a (nsuc c) = refl
a+/b+c/=/a+b/+c -[1+ a ] -[1+ b ] -[1+ c ]
rewrite nat-add-comm a $ nsuc $ b :+: c
| nat-add-comm (b :+: c) a
| nat-add-assoc a b c
= refl
a+/b+c/=/a+b/+c (+ nsuc a) (+ nsuc b) -[1+ c ]
rewrite a+/b-c/=a+b-c (nsuc a) b c
| sym $ nat-add-assoc a 1 b
| nat-add-comm a 1
= refl
------------------------------------------------------------------------
-- public aliases
int-add-assoc : ∀ a b c → a + (b + c) ≡ a + b + c
int-add-assoc = a+/b+c/=/a+b/+c
|
{
"alphanum_fraction": 0.4029535865,
"avg_line_length": 31.9038461538,
"ext": "agda",
"hexsha": "d04f404e542244a215f564e981e3571ed953af1b",
"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/Ints/Add/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/Ints/Add/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/Ints/Add/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": 1453,
"size": 3318
}
|
mutual
data D : Set where
c : R → D
record R : Set where
inductive
field
out : D
open R
f : D → {A : Set} → A
f (c x) = f (out x)
-- should termination check
|
{
"alphanum_fraction": 0.527173913,
"avg_line_length": 11.5,
"ext": "agda",
"hexsha": "89d9e4ae6bf9feb377cd4bf8c103245e2c365240",
"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/TerminationInductiveProjectionFromVariable.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/TerminationInductiveProjectionFromVariable.agda",
"max_line_length": 27,
"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/TerminationInductiveProjectionFromVariable.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": 68,
"size": 184
}
|
{-
Functions building DUARels on constant families
-}
{-# OPTIONS --safe #-}
module Cubical.Displayed.Constant where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Displayed.Base
open import Cubical.Displayed.Subst
private
variable
ℓ ℓA ℓA' ℓP ℓ≅A ℓ≅A' ℓB ℓB' ℓ≅B ℓ≅B' ℓC ℓ≅C : Level
-- constant DUARel
module _ {A : Type ℓA} (𝒮-A : UARel A ℓ≅A)
{B : Type ℓB} (𝒮-B : UARel B ℓ≅B) where
open UARel 𝒮-B
open DUARel
𝒮ᴰ-const : DUARel 𝒮-A (λ _ → B) ℓ≅B
𝒮ᴰ-const ._≅ᴰ⟨_⟩_ b _ b' = b ≅ b'
𝒮ᴰ-const .uaᴰ b p b' = ua b b'
-- SubstRel for an arbitrary constant family
module _ {A : Type ℓA} (𝒮-A : UARel A ℓ≅A) (B : Type ℓB) where
open SubstRel
𝒮ˢ-const : SubstRel 𝒮-A (λ _ → B)
𝒮ˢ-const .SubstRel.act _ = idEquiv B
𝒮ˢ-const .SubstRel.uaˢ p b = transportRefl b
|
{
"alphanum_fraction": 0.6615384615,
"avg_line_length": 21.125,
"ext": "agda",
"hexsha": "0689104c28a440e5e8224b4a42b4cbd15fd72e7b",
"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/Displayed/Constant.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/Displayed/Constant.agda",
"max_line_length": 62,
"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/Displayed/Constant.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": 397,
"size": 845
}
|
{-# OPTIONS --without-K #-}
module sets.finite where
open import sets.finite.core public
|
{
"alphanum_fraction": 0.7333333333,
"avg_line_length": 18,
"ext": "agda",
"hexsha": "704e074db002e2f72cd0fe089cfdde941855984b",
"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/sets/finite.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/sets/finite.agda",
"max_line_length": 35,
"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/sets/finite.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": 20,
"size": 90
}
|
-- A Typed version of a subset of Landin's ISWIM from "The Next 700 Programming
-- Languages"
module ISWIM where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
_+_ : Nat -> Nat -> Nat
zero + m = m
suc n + m = suc (n + m)
{-# BUILTIN NATURAL Nat #-}
{-# BUILTIN ZERO zero #-}
{-# BUILTIN SUC suc #-}
{-# BUILTIN NATPLUS _+_ #-}
data Bool : Set where
true : Bool
false : Bool
module Syntax where
infixl 100 _∙_
infixl 80 _WHERE_ _PP_
infixr 60 _─→_
infixl 40 _,_
data Type : Set where
nat : Type
bool : Type
_─→_ : Type -> Type -> Type
data Context : Set where
ε : Context
_,_ : Context -> Type -> Context
data Var : Context -> Type -> Set where
vz : {Γ : Context}{τ : Type} -> Var (Γ , τ) τ
vs : {Γ : Context}{σ τ : Type} -> Var Γ τ -> Var (Γ , σ) τ
data Expr (Γ : Context) : Type -> Set where
var : {τ : Type} -> Var Γ τ -> Expr Γ τ
litNat : Nat -> Expr Γ nat
litBool : Bool -> Expr Γ bool
plus : Expr Γ (nat ─→ nat ─→ nat)
if : {τ : Type} -> Expr Γ (bool ─→ τ ─→ τ ─→ τ)
_∙_ : {σ τ : Type} -> Expr Γ (σ ─→ τ) -> Expr Γ σ -> Expr Γ τ
_WHERE_ : {σ τ ρ : Type} -> Expr (Γ , σ ─→ τ) ρ -> Expr (Γ , σ) τ -> Expr Γ ρ
_PP_ : {σ τ ρ : Type} -> Expr (Γ , σ ─→ τ) ρ -> Expr (Γ , σ) ρ -> Expr Γ ρ
-- ƛ x. e = f where f x = e
ƛ : {Γ : Context}{σ τ : Type} -> Expr (Γ , σ) τ -> Expr Γ (σ ─→ τ)
ƛ e = var vz WHERE e
module Cont (R : Set) where
C : Set -> Set
C a = (a -> R) -> R
callcc : {a : Set} -> (({b : Set} -> a -> C b) -> C a) -> C a
callcc {a} g = \k -> g (\x _ -> k x) k
return : {a : Set} -> a -> C a
return x = \k -> k x
infixr 10 _>>=_
_>>=_ : {a b : Set} -> C a -> (a -> C b) -> C b
(m >>= k) ret = m \x -> k x ret
module Semantics (R : Set) where
open module C = Cont R
open Syntax
infix 60 _!_
infixl 40 _||_
⟦_⟧type : Type -> Set
⟦_⟧type' : Type -> Set
⟦ nat ⟧type' = Nat
⟦ bool ⟧type' = Bool
⟦ σ ─→ τ ⟧type' = ⟦ σ ⟧type' -> ⟦ τ ⟧type
⟦ τ ⟧type = C ⟦ τ ⟧type'
data ⟦_⟧ctx : Context -> Set where
★ : ⟦ ε ⟧ctx
_||_ : {Γ : Context}{τ : Type} -> ⟦ Γ ⟧ctx -> ⟦ τ ⟧type' -> ⟦ Γ , τ ⟧ctx
_!_ : {Γ : Context}{τ : Type} -> ⟦ Γ ⟧ctx -> Var Γ τ -> ⟦ τ ⟧type'
★ ! ()
(ρ || v) ! vz = v
(ρ || v) ! vs x = ρ ! x
⟦_⟧ : {Γ : Context}{τ : Type} -> Expr Γ τ -> ⟦ Γ ⟧ctx -> ⟦ τ ⟧type
⟦ var x ⟧ ρ = return (ρ ! x)
⟦ litNat n ⟧ ρ = return n
⟦ litBool b ⟧ ρ = return b
⟦ plus ⟧ ρ = return \n -> return \m -> return (n + m)
⟦ f ∙ e ⟧ ρ = ⟦ e ⟧ ρ >>= \v ->
⟦ f ⟧ ρ >>= \w ->
w v
⟦ e WHERE f ⟧ ρ = ⟦ e ⟧ (ρ || (\x -> ⟦ f ⟧ (ρ || x)))
⟦ e PP f ⟧ ρ = callcc \k ->
let throw = \x -> ⟦ f ⟧ (ρ || x) >>= k
in ⟦ e ⟧ (ρ || throw)
⟦ if ⟧ ρ = return \x -> return \y -> return \z -> return (iff x y z)
where
iff : {A : Set} -> Bool -> A -> A -> A
iff true x y = x
iff false x y = y
module Test where
open Syntax
open module C = Cont Nat
open module S = Semantics Nat
run : Expr ε nat -> Nat
run e = ⟦ e ⟧ ★ \x -> x
-- 1 + 1
two : Expr ε nat
two = plus ∙ litNat 1 ∙ litNat 1
-- f 1 + f 2 where f x = x
three : Expr ε nat
three = plus ∙ (var vz ∙ litNat 1) ∙ (var vz ∙ litNat 2) WHERE var vz
-- 1 + f 1 where pp f x = x
one : Expr ε nat
one = plus ∙ litNat 1 ∙ (var vz ∙ litNat 1) PP var vz
open Test
data _==_ {a : Set}(x : a) : a -> Set where
refl : x == x
twoOK : run two == 2
twoOK = refl
threeOK : run three == 3
threeOK = refl
oneOK : run one == 1
oneOK = refl
open Cont
open Syntax
open Semantics
|
{
"alphanum_fraction": 0.4648838466,
"avg_line_length": 23.5796178344,
"ext": "agda",
"hexsha": "edfaa245d96a9151a45665eeffc99333fc2afdbc",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "np/agda-git-experiment",
"max_forks_repo_path": "examples/ISWIM.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "np/agda-git-experiment",
"max_issues_repo_path": "examples/ISWIM.agda",
"max_line_length": 81,
"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/ISWIM.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": 1535,
"size": 3702
}
|
postulate
P : {A : Set} → A → A → Set
p : {A : Set} {x : A} → P x x
q : {A : Set} (x : A) {y : A} → P x y → P x y
A : Set
record R (F : Set → Set) : Set₁ where
field
f₁ : (A → A) → F A → F A
f₂ : P (f₁ (λ x → x)) (λ (x : F A) → x)
open R ⦃ … ⦄ public
instance
r : R (λ O → O → O)
r = record
{ f₁ = λ f g x → f (g x)
; f₂ = p
}
postulate
F : Set → Set
instance
rF : R F
Foo : P (f₁ (λ x → x)) (λ (x : F A) → x)
Foo = q (f₁ (λ x → x)) f₂
-- An internal error has occurred. Please report this as a bug.
-- Location of the error:
-- src/full/Agda/TypeChecking/InstanceArguments.hs:224
|
{
"alphanum_fraction": 0.4825949367,
"avg_line_length": 18.0571428571,
"ext": "agda",
"hexsha": "1010e6175276654524de33021b215d27e60f4ee3",
"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/Issue1466.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/Issue1466.agda",
"max_line_length": 63,
"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/Issue1466.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": 275,
"size": 632
}
|
{-
Reflection-based tools for converting between iterated record types, particularly between
record types and iterated Σ-types.
See end of file for examples.
-}
{-# OPTIONS --cubical --no-exact-split --safe #-}
module Cubical.Reflection.RecordEquiv where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Data.List as List
open import Cubical.Data.Nat
open import Cubical.Data.Maybe as Maybe
open import Cubical.Data.Sigma
open import Agda.Builtin.String
import Agda.Builtin.Reflection as R
open import Cubical.Reflection.Base
Projections = Maybe (List R.Name)
-- Describes a correspondence between two iterated record types
RecordAssoc = List (Projections × Projections)
-- Describes a correspondence between a record type and an iterated Σ-types;
-- more convenient than RecordAssoc for this special case
data ΣFormat : Type where
leaf : R.Name → ΣFormat
_,_ : ΣFormat → ΣFormat → ΣFormat
unit : ΣFormat
infixr 4 _,_
flipRecordAssoc : RecordAssoc → RecordAssoc
flipRecordAssoc = List.map λ {p .fst → p .snd; p .snd → p .fst}
fstIdRecordAssoc : RecordAssoc → RecordAssoc
fstIdRecordAssoc = List.map λ {p .fst → p .fst; p .snd → p .fst}
List→ΣFormat : List R.Name → ΣFormat
List→ΣFormat [] = unit
List→ΣFormat (x ∷ []) = leaf x
List→ΣFormat (x ∷ y ∷ xs) = leaf x , List→ΣFormat (y ∷ xs)
ΣFormat→RecordAssoc : ΣFormat → RecordAssoc
ΣFormat→RecordAssoc = go []
where
go : List R.Name → ΣFormat → RecordAssoc
go prefix unit = [ just prefix , nothing ]
go prefix (leaf fieldName) = [ just prefix , just [ fieldName ] ]
go prefix (sig₁ , sig₂) =
go (quote fst ∷ prefix) sig₁ ++ go (quote snd ∷ prefix) sig₂
-- Derive the shape of the compound Σ-type
ΣFormat→Ty : ΣFormat → R.Type
ΣFormat→Ty unit = R.def (quote Unit) []
ΣFormat→Ty (leaf _) = R.unknown
ΣFormat→Ty (sig₁ , sig₂) =
R.def (quote Σ) (ΣFormat→Ty sig₁ v∷ R.lam R.visible (R.abs "_" (ΣFormat→Ty sig₂)) v∷ [])
recordName→isoTy : R.Name → R.Term → R.TC R.Term
recordName→isoTy name σShape =
R.inferType (R.def name []) >>= R.normalise >>= go []
where
go : List R.ArgInfo → R.Type → R.TC R.Term
go acc (R.pi (R.arg i argTy) (R.abs s ty)) =
liftTC (λ t → R.pi (R.arg i' argTy) (R.abs s t)) (go (i ∷ acc) ty)
where
i' = R.arg-info R.hidden (R.modality R.relevant R.quantity-ω)
go acc (R.agda-sort _) =
R.returnTC (R.def (quote Iso) (R.def name (makeArgs 0 [] acc) v∷ σShape v∷ []))
where
makeArgs : ℕ → List (R.Arg R.Term) → List R.ArgInfo → List (R.Arg R.Term)
makeArgs n acc [] = acc
makeArgs n acc (i ∷ infos) = makeArgs (suc n) (R.arg i (v n) ∷ acc) infos
go _ _ = R.typeError (R.strErr "Not a record type name: " ∷ R.nameErr name ∷ [])
projNames→Patterns : List R.Name → List (R.Arg R.Pattern)
projNames→Patterns = go []
where
go : List (R.Arg R.Pattern) → List R.Name → List (R.Arg R.Pattern)
go acc [] = acc
go acc (π ∷ projs) = go (varg (R.proj π) ∷ acc) projs
projNames→Term : R.Term → List R.Name → R.Term
projNames→Term term [] = term
projNames→Term term (π ∷ projs) = R.def π [ varg (projNames→Term term projs) ]
convertClauses : RecordAssoc → R.Term → List R.Clause
convertClauses al term = fixIfEmpty (List.filterMap makeClause al)
where
makeClause : Projections × Projections → Maybe R.Clause
makeClause (projl , just projr) =
just (R.clause [] (goPat [] projr) (Maybe.rec R.unknown goTm projl))
where
goPat : List (R.Arg R.Pattern) → List R.Name → List (R.Arg R.Pattern)
goPat acc [] = acc
goPat acc (π ∷ projs) = goPat (varg (R.proj π) ∷ acc) projs
goTm : List R.Name → R.Term
goTm [] = term
goTm (π ∷ projs) = R.def π [ varg (goTm projs) ]
makeClause (_ , nothing) = nothing
fixIfEmpty : List R.Clause → List R.Clause
fixIfEmpty [] = [ R.clause [] [] R.unknown ]
fixIfEmpty (c ∷ cs) = c ∷ cs
mapClause :
(List (String × R.Arg R.Type) → List (String × R.Arg R.Type))
→ (List (R.Arg R.Pattern) → List (R.Arg R.Pattern))
→ (R.Clause → R.Clause)
mapClause f g (R.clause tel ps t) = R.clause (f tel) (g ps) t
mapClause f g (R.absurd-clause tel ps) = R.absurd-clause (f tel) (g ps)
recordIsoΣClauses : ΣFormat → List R.Clause
recordIsoΣClauses σ =
funClauses (quote Iso.fun) Σ↔R ++
funClauses (quote Iso.inv) R↔Σ ++
pathClauses (quote Iso.rightInv) R↔Σ ++
pathClauses (quote Iso.leftInv) Σ↔R
where
R↔Σ = ΣFormat→RecordAssoc σ
Σ↔R = flipRecordAssoc R↔Σ
funClauses : R.Name → RecordAssoc → List R.Clause
funClauses name al =
List.map
(mapClause
(("_" , varg R.unknown) ∷_)
(λ ps → R.proj name v∷ R.var 0 v∷ ps))
(convertClauses al (v 0))
pathClauses : R.Name → RecordAssoc → List R.Clause
pathClauses name al =
List.map
(mapClause
(λ vs → ("_" , varg R.unknown) ∷ ("_" , varg R.unknown) ∷ vs)
(λ ps → R.proj name v∷ R.var 1 v∷ R.var 0 v∷ ps))
(convertClauses (fstIdRecordAssoc al) (v 1))
recordIsoΣTerm : ΣFormat → R.Term
recordIsoΣTerm σ = R.pat-lam (recordIsoΣClauses σ) []
-- with a provided ΣFormat for the record
declareRecordIsoΣ' : R.Name → ΣFormat → R.Name → R.TC Unit
declareRecordIsoΣ' idName σ recordName =
let σTy = ΣFormat→Ty σ in
recordName→isoTy recordName σTy >>= λ isoTy →
R.declareDef (varg idName) isoTy >>
R.defineFun idName (recordIsoΣClauses σ)
-- using the right-associated Σ given by the record fields
declareRecordIsoΣ : R.Name → R.Name → R.TC Unit
declareRecordIsoΣ idName recordName =
R.getDefinition recordName >>= λ where
(R.record-type _ fs) →
let σ = List→ΣFormat (List.map (λ {(R.arg _ n) → n}) fs) in
declareRecordIsoΣ' idName σ recordName
_ →
R.typeError (R.strErr "Not a record type name:" ∷ R.nameErr recordName ∷ [])
private
module Example where
variable
ℓ ℓ' : Level
A : Type ℓ
B : A → Type ℓ'
record Example0 {A : Type ℓ} (B : A → Type ℓ') : Type (ℓ-max ℓ ℓ') where
no-eta-equality -- works with or without eta equality
field
cool : A
fun : A
wow : B cool
-- Declares a function `Example0IsoΣ` that gives an isomorphism between the record type and a
-- right-associated nested Σ-type (with the parameters to Example0 as implict arguments).
unquoteDecl Example0IsoΣ = declareRecordIsoΣ Example0IsoΣ (quote Example0)
-- `Example0IsoΣ` has the type we expect
test0 : Iso (Example0 B) (Σ[ a ∈ A ] (Σ[ _ ∈ A ] B a))
test0 = Example0IsoΣ
-- A record with no fields is isomorphic to Unit
record Example1 : Type where
unquoteDecl Example1IsoΣ = declareRecordIsoΣ Example1IsoΣ (quote Example1)
test1 : Iso Example1 Unit
test1 = Example1IsoΣ
|
{
"alphanum_fraction": 0.6648777579,
"avg_line_length": 34.2244897959,
"ext": "agda",
"hexsha": "bba9fcd7973087ccdbd171286a7563a42de98b98",
"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/Reflection/RecordEquiv.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/Reflection/RecordEquiv.agda",
"max_line_length": 97,
"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/Reflection/RecordEquiv.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2233,
"size": 6708
}
|
module Oscar.Builtin.Nat where
open import Agda.Builtin.Nat public
using ()
renaming (Nat to ℕ; zero to ∅; suc to ↑_)
|
{
"alphanum_fraction": 0.7016129032,
"avg_line_length": 17.7142857143,
"ext": "agda",
"hexsha": "fbf56a8fd992158d4ef34f5fafdc7792990d31e2",
"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-2/Oscar/Builtin/Nat.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-2/Oscar/Builtin/Nat.agda",
"max_line_length": 43,
"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-2/Oscar/Builtin/Nat.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 38,
"size": 124
}
|
--
-- Created by Dependently-Typed Lambda Calculus on 2020-10-07
-- Isomorphism
-- Author: dplaindoux
--
{-# OPTIONS --without-K --no-sized-types --no-guardedness bbbbb#-}
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; cong; cong-app)
open Eq.≡-Reasoning
open import Data.Nat using (ℕ; zero; suc; _+_)
open import Data.Nat.Properties using (+-comm)
module Isomorphism where
_∘_ : ∀ {A B C : Set} → (B → C) → (A → B) → (A → C)
(g ∘ f) = λ x → g (f x)
-- Extensionality and function equivalence
_+′_ : ℕ → ℕ → ℕ
m +′ zero = m
m +′ suc n = suc (m +′ n)
same-app : ∀ (m n : ℕ) → m +′ n ≡ m + n
same-app m n rewrite +-comm m n = helper m n
where
helper : ∀ (m n : ℕ) → m +′ n ≡ n + m
helper m zero = refl
helper m (suc n) = cong suc (helper m n)
postulate
extensionality : ∀ {A B : Set} {f g : A → B}
→ (∀ (x : A) → f x ≡ g x)
-----------------------
→ f ≡ g
postulate
∀-extensionality : ∀ {A : Set} {B : A → Set} {f g : ∀(x : A) → B x}
→ (∀ (x : A) → f x ≡ g x)
-----------------------
→ f ≡ g
same : _+′_ ≡ _+_
same = ∀-extensionality (λ m → ∀-extensionality (λ n → same-app m n))
-- Isomorphism definition
infix 0 _≃_
record _≃_ (A B : Set) : Set where
field
to : A → B
from : B → A
from∘to : ∀ (x : A) → from (to x) ≡ x
to∘from : ∀ (y : B) → to (from y) ≡ y
open _≃_
≃-refl : ∀ {A : Set}
-----
→ A ≃ A
≃-refl =
record
{ to = λ{x → x}
; from = λ{y → y}
; from∘to = λ{x → refl}
; to∘from = λ{y → refl}
}
≃-sym : ∀ {A B : Set}
→ A ≃ B
-----
→ B ≃ A
≃-sym A≃B =
record
{ to = from A≃B
; from = to A≃B
; from∘to = to∘from A≃B
; to∘from = from∘to A≃B
}
≃-trans : ∀ {A B C : Set}
→ A ≃ B
→ B ≃ C
-----
→ A ≃ C
≃-trans A≃B B≃C =
record
{ to = to B≃C ∘ to A≃B
; from = from A≃B ∘ from B≃C
; from∘to = λ{x →
begin
((from A≃B ∘ from B≃C) ∘ (to B≃C ∘ to A≃B)) x
≡⟨⟩
(from A≃B ∘ from B≃C) ((to B≃C ∘ to A≃B) x)
≡⟨⟩
from A≃B (from B≃C (to B≃C (to A≃B x)))
≡⟨ cong (from A≃B) (from∘to B≃C (to A≃B x)) ⟩
from A≃B (to A≃B x)
≡⟨ from∘to A≃B x ⟩
x
∎}
; to∘from = λ{y →
begin
((to B≃C ∘ to A≃B) ∘ (from A≃B ∘ from B≃C)) y
≡⟨⟩
(to B≃C ∘ to A≃B) ((from A≃B ∘ from B≃C) y)
≡⟨⟩
to B≃C (to A≃B (from A≃B (from B≃C y)))
≡⟨ cong (to B≃C) (to∘from A≃B (from B≃C y)) ⟩
to B≃C (from B≃C y)
≡⟨ to∘from B≃C y ⟩
y
∎}
}
module ≃-Reasoning where
infix 1 ≃-begin_
infixr 2 _≃⟨_⟩_
infix 3 _≃-∎
≃-begin_ : ∀ {A B : Set}
→ A ≃ B
-----
→ A ≃ B
≃-begin A≃B = A≃B
_≃⟨_⟩_ : ∀ (A : Set) {B C : Set}
→ A ≃ B
→ B ≃ C
-----
→ A ≃ C
A ≃⟨ A≃B ⟩ B≃C = ≃-trans A≃B B≃C
_≃-∎ : ∀ (A : Set)
-----
→ A ≃ A
A ≃-∎ = ≃-refl
open ≃-Reasoning
infix 0 _≲_
record _≲_ (A B : Set) : Set where
field
to : A → B
from : B → A
from∘to : ∀ (x : A) → from (to x) ≡ x
open _≲_
≲-refl : ∀ {A : Set}
-----
→ A ≲ A
≲-refl =
record
{ to = λ{x → x}
; from = λ{y → y}
; from∘to = λ{x → refl}
}
≲-trans : ∀ {A B C : Set}
→ A ≲ B
→ B ≲ C
-----
→ A ≲ C
≲-trans A≲B B≲C =
record
{ to = λ{x → to B≲C (to A≲B x)}
; from = λ{y → from A≲B (from B≲C y)}
; from∘to = λ{x →
begin
((from A≲B ∘ from B≲C) ∘ (to B≲C ∘ to A≲B)) x
≡⟨⟩
(from A≲B ∘ from B≲C) ((to B≲C ∘ to A≲B) x)
≡⟨⟩
from A≲B (from B≲C (to B≲C (to A≲B x)))
≡⟨ cong (from A≲B) (from∘to B≲C (to A≲B x)) ⟩
from A≲B (to A≲B x)
≡⟨ from∘to A≲B x ⟩
x
∎}
}
≲-antisym : ∀ {A B : Set}
→ (A≲B : A ≲ B)
→ (B≲A : B ≲ A)
→ (to A≲B ≡ from B≲A)
→ (from A≲B ≡ to B≲A)
-------------------
→ A ≃ B
≲-antisym A≲B B≲A to≡from from≡to =
record
{ to = to A≲B
; from = from A≲B
; from∘to = from∘to A≲B
; to∘from = λ{y →
begin
(to A≲B ∘ from A≲B) y
≡⟨⟩
to A≲B (from A≲B y)
≡⟨ cong (to A≲B) (cong-app from≡to y) ⟩
to A≲B (to B≲A y)
≡⟨ cong-app to≡from (to B≲A y) ⟩
from B≲A (to B≲A y)
≡⟨ from∘to B≲A y ⟩
y
∎}
}
|
{
"alphanum_fraction": 0.4032294746,
"avg_line_length": 20.7405660377,
"ext": "agda",
"hexsha": "9e663fa6a13d048c475408ae39fd6a11e92b1bce",
"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": "a81447af3ab2ba898bb7d57be71369abbba12d81",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "d-plaindoux/colca",
"max_forks_repo_path": "src/exercices/Isomorphism.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a81447af3ab2ba898bb7d57be71369abbba12d81",
"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": "d-plaindoux/colca",
"max_issues_repo_path": "src/exercices/Isomorphism.agda",
"max_line_length": 69,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "a81447af3ab2ba898bb7d57be71369abbba12d81",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "d-plaindoux/colca",
"max_stars_repo_path": "src/exercices/Isomorphism.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-04T09:35:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-03-12T18:31:14.000Z",
"num_tokens": 2104,
"size": 4397
}
|
------------------------------------------------------------------------------
-- Logical Theory of Constructions for PCF (LTC-PCF)
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- Code accompanying the paper "Embedding a Logical Theory of
-- Constructions in Agda" by Ana Bove, Peter Dybjer and Andrés
-- Sicard-Ramírez (PLPV'09).
-- The code presented here does not match the paper exactly.
module LTC-PCF.README where
------------------------------------------------------------------------------
-- Description
-- Formalization of (a version of) Azcel's Logical Theory of
-- Constructions for PCF.
------------------------------------------------------------------------------
-- The axioms
open import LTC-PCF.Base
-- Properties
open import LTC-PCF.Base.Properties
------------------------------------------------------------------------------
-- Booleans
-- The inductive predicate
open import LTC-PCF.Data.Bool.Type
-- Properties
open import LTC-PCF.Data.Bool.Properties
------------------------------------------------------------------------------
-- Natural numberes
-- The arithmetical functions
open import LTC-PCF.Data.Nat
-- The inductive predicate
open import LTC-PCF.Data.Nat.Type
-- Properties
open import LTC-PCF.Data.Nat.Properties
-- Divisibility relation
open import LTC-PCF.Data.Nat.Divisibility.NotBy0.Properties
-- Induction
open import LTC-PCF.Data.Nat.Induction.NonAcc.Lexicographic
open import LTC-PCF.Data.Nat.Induction.NonAcc.WF
-- Inequalites
open import LTC-PCF.Data.Nat.Inequalities.EliminationProperties
open import LTC-PCF.Data.Nat.Inequalities.Properties
-- The recursive operator
open import LTC-PCF.Data.Nat.Rec.ConversionRules
------------------------------------------------------------------------------
-- A looping combinator
open import LTC-PCF.Loop
------------------------------------------------------------------------------
-- Verification of programs
-- The division algorithm: A non-structurally recursive algorithm
open import LTC-PCF.Program.Division.CorrectnessProof
-- The GCD algorithm: A non-structurally recursive algorithm
open import LTC-PCF.Program.GCD.Partial.CorrectnessProof
open import LTC-PCF.Program.GCD.Total.CorrectnessProof
|
{
"alphanum_fraction": 0.5596860801,
"avg_line_length": 30.6455696203,
"ext": "agda",
"hexsha": "eea83a65d25dd855848678959d155dcae93c9979",
"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/README.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/README.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "src/fot/LTC-PCF/README.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": 479,
"size": 2421
}
|
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
open import Categories.Functor.Bifunctor
module Categories.Diagram.Coend {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′}
(F : Bifunctor (Category.op C) C D) where
private
module C = Category C
module D = Category D
open D
open HomReasoning
variable
A B : Obj
f g : A ⇒ B
open import Level
open import Data.Product using (Σ; _,_)
open import Categories.Functor
open import Categories.Functor.Construction.Constant
open import Categories.NaturalTransformation.Dinatural
open import Categories.Morphism.Reasoning D
open Functor F
record Cowedge : Set (levelOfTerm F) where
field
E : Obj
dinatural : DinaturalTransformation F (const E)
module dinatural = DinaturalTransformation dinatural
Cowedge-∘ : (W : Cowedge) → Cowedge.E W ⇒ A → Cowedge
Cowedge-∘ {A = A} W f = record
{ E = A
; dinatural = extranaturalˡ (λ X → f ∘ dinatural.α X)
(assoc ○ ∘-resp-≈ʳ (extranatural-commˡ dinatural) ○ ⟺ assoc)
}
where open Cowedge W
record Coend : Set (levelOfTerm F) where
field
cowedge : Cowedge
module cowedge = Cowedge cowedge
open cowedge public
open Cowedge
field
factor : (W : Cowedge) → cowedge.E ⇒ E W
universal : ∀ {W : Cowedge} {A} → factor W ∘ cowedge.dinatural.α A ≈ dinatural.α W A
unique : ∀ {W : Cowedge} {g : cowedge.E ⇒ E W} → (∀ {A} → g ∘ cowedge.dinatural.α A ≈ dinatural.α W A) → factor W ≈ g
η-id : factor cowedge ≈ D.id
η-id = unique identityˡ
unique′ :(∀ {A} → f ∘ cowedge.dinatural.α A ≈ g ∘ cowedge.dinatural.α A) → f ≈ g
unique′ {f = f} {g = g} eq = ⟺ (unique {W = Cowedge-∘ cowedge f} refl) ○ unique (⟺ eq)
|
{
"alphanum_fraction": 0.6446233468,
"avg_line_length": 28.5081967213,
"ext": "agda",
"hexsha": "779b6442200727c4fcbc5fb72f6b967e066fccfd",
"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": "6ebc1349ee79669c5c496dcadd551d5bbefd1972",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Taneb/agda-categories",
"max_forks_repo_path": "Categories/Diagram/Coend.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972",
"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": "Taneb/agda-categories",
"max_issues_repo_path": "Categories/Diagram/Coend.agda",
"max_line_length": 124,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "6ebc1349ee79669c5c496dcadd551d5bbefd1972",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Taneb/agda-categories",
"max_stars_repo_path": "Categories/Diagram/Coend.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 594,
"size": 1739
}
|
module Plus where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
infixr 40 _+_
infix 10 _==_
_+_ : Nat -> Nat -> Nat
zero + m = m
suc n + m = suc (n + m)
data _==_ (x, y : Nat) : Set where
-- ...
postulate
refl : {n : Nat} -> n == n
cong : (f : Nat -> Nat){n, m : Nat} -> n == m -> f n == f m
plusZero : {n : Nat} -> n + zero == n
plusZero {zero} = refl
plusZero {suc n} = cong suc plusZero
|
{
"alphanum_fraction": 0.513253012,
"avg_line_length": 15.9615384615,
"ext": "agda",
"hexsha": "fda792d5c4bd00fcd8ae80ca74b82de638869124",
"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": "notes/talks/MetaVars/Plus.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": "notes/talks/MetaVars/Plus.agda",
"max_line_length": 61,
"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": "notes/talks/MetaVars/Plus.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": 166,
"size": 415
}
|
open import Common.Prelude renaming (return to foo)
main : IO Unit
main = foo unit
|
{
"alphanum_fraction": 0.75,
"avg_line_length": 16.8,
"ext": "agda",
"hexsha": "405aefc652fe4ca768cd4d45995dcd730d74bcdc",
"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/Compiler/simple/Issue1855.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/Compiler/simple/Issue1855.agda",
"max_line_length": 51,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Compiler/simple/Issue1855.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": 21,
"size": 84
}
|
-- There's something very strange going on with mutual and parameterised
-- modules. Can't reproduce the bug... :(
module Mutual where
data True : Set where
tt : True
data False : Set where
data _\/_ (A B : Set) : Set where
inl : A -> A \/ B
inr : B -> A \/ B
swap : {A B : Set} -> A \/ B -> B \/ A
swap (inl a) = inr a
swap (inr b) = inl b
module Foo (A : Set)(P : A -> Set) where
Q : A -> A -> Set
Q x y = P x \/ P y
mutual
data Nat : Set where
zero : Nat
suc : Nat -> Nat
Even : Nat -> Set
Even zero = True
Even (suc zero) = False
Even (suc (suc n)) = Even n
f : Nat -> Set
f zero = True
f (suc n) = Q n (suc n)
where
open module F = Foo Nat Even
g : (n : Nat) -> f n
g zero = tt
g (suc zero) = inl tt
g (suc (suc n)) = swap (g (suc n))
|
{
"alphanum_fraction": 0.5345679012,
"avg_line_length": 17.6086956522,
"ext": "agda",
"hexsha": "d851dbbc9cd5bc71b2c3636c4d0730babf3bba94",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/bugs/Mutual.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/bugs/Mutual.agda",
"max_line_length": 72,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/bugs/Mutual.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": 306,
"size": 810
}
|
open import Agda.Builtin.Bool
F : Bool → Set
F true = Bool
F _ = Bool
|
{
"alphanum_fraction": 0.6486486486,
"avg_line_length": 12.3333333333,
"ext": "agda",
"hexsha": "179aa0be5be554ee8655328386f20838aea20f3f",
"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/Issue3187.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/Issue3187.agda",
"max_line_length": 29,
"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/Issue3187.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": 25,
"size": 74
}
|
open import Relation.Binary.Core
module BHeap.Height {A : Set}
(_≤_ : A → A → Set)
(tot≤ : Total _≤_) where
open import Bound.Lower A
open import Bound.Lower.Order _≤_
open import BHeap _≤_
open import BHeap.Properties _≤_
open import Data.Nat renaming (_≤_ to _≤ₙ_)
open import Data.Nat.Properties
open import Data.Sum
open import Relation.Binary
open import Relation.Binary.PropositionalEquality hiding (trans)
open DecTotalOrder decTotalOrder hiding (refl)
theorem-height-merge : {b : Bound}{x : A}(b≤x : LeB b (val x))(l r : BHeap (val x)) → height (merge tot≤ l r) ≤ₙ height (nd b≤x l r)
theorem-height-merge _ lf r = ≤-step (reflexive refl)
theorem-height-merge _ l lf rewrite lemma-merge-lf tot≤ l
with total (height l) zero
... | inj₁ hl≤0 rewrite antisym hl≤0 z≤n = ≤-step (reflexive refl)
... | inj₂ 0≤hl = ≤-step (reflexive refl)
theorem-height-merge b≤x (nd {x = y} x≤y l r) (nd {x = y'} x≤y' l' r')
with tot≤ y y' | total (height (nd x≤y l r)) (height (nd x≤y' l' r'))
... | inj₁ y≤y' | inj₁ hylr≤hy'l'r'
with total (height (merge tot≤ l r)) (height (nd (lexy y≤y') l' r'))
... | inj₁ hmlr≤hy'l'r' = reflexive refl
... | inj₂ hy'l'r'≤hmlr rewrite antisym (trans (theorem-height-merge x≤y l r) hylr≤hy'l'r') hy'l'r'≤hmlr = reflexive refl
theorem-height-merge b≤x (nd {x = y} x≤y l r) (nd {x = y'} x≤y' l' r') | inj₁ y≤y' | inj₂ hy'l'r'≤hylr
with total (height (merge tot≤ l r)) (height (nd (lexy y≤y') l' r'))
... | inj₁ hmlr≤hy'l'r' = s≤s hy'l'r'≤hylr
... | inj₂ hy'l'r'≤hmlr = s≤s (theorem-height-merge x≤y l r)
theorem-height-merge b≤x (nd {x = y} x≤y l r) (nd {x = y'} x≤y' l' r') | inj₂ y'≤y | inj₁ hylr≤hy'l'r'
with total (height (nd (lexy y'≤y) l r)) (height (merge tot≤ l' r'))
... | inj₁ hylr≤hml'r' = s≤s (theorem-height-merge x≤y' l' r')
... | inj₂ hml'r'≤hylr = s≤s hylr≤hy'l'r'
theorem-height-merge b≤x (nd {x = y} x≤y l r) (nd {x = y'} x≤y' l' r') | inj₂ y'≤y | inj₂ hy'l'r'≤hylr
with total (height (nd (lexy y'≤y) l r)) (height (merge tot≤ l' r'))
... | inj₁ hylr≤hml'r' rewrite antisym (trans (theorem-height-merge x≤y' l' r') hy'l'r'≤hylr) hylr≤hml'r' = reflexive refl
... | inj₂ hml'r'≤hylr = reflexive refl
|
{
"alphanum_fraction": 0.6118391324,
"avg_line_length": 51.4651162791,
"ext": "agda",
"hexsha": "4ca8346c9ef57b9883c636d3f4acf1d933ef54b1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bgbianchi/sorting",
"max_forks_repo_path": "agda/BHeap/Height.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bgbianchi/sorting",
"max_issues_repo_path": "agda/BHeap/Height.agda",
"max_line_length": 132,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bgbianchi/sorting",
"max_stars_repo_path": "agda/BHeap/Height.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-24T22:11:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-05-21T12:50:35.000Z",
"num_tokens": 936,
"size": 2213
}
|
module Cats.Category.Constructions.Iso where
open import Relation.Binary using (IsEquivalence ; Setoid)
open import Level
open import Cats.Category.Base
open import Cats.Util.Conv
import Relation.Binary.EqReasoning as EqReasoning
import Cats.Category.Constructions.Epi as Epi
import Cats.Category.Constructions.Mono as Mono
module Build {lo la l≈} (Cat : Category lo la l≈) where
private open module Cat = Category Cat
open Cat.≈-Reasoning
open Epi.Build Cat
open Mono.Build Cat
record _≅_ (A B : Obj) : Set (lo ⊔ la ⊔ l≈) where
field
forth : A ⇒ B
back : B ⇒ A
back-forth : back ∘ forth ≈ id
forth-back : forth ∘ back ≈ id
open _≅_
instance
HasArrow-≅ : ∀ {A B} → HasArrow (A ≅ B) lo la l≈
HasArrow-≅ = record { Cat = Cat ; _⃗ = forth }
≅-equiv : IsEquivalence _≅_
≅-equiv = record { refl = refl ; sym = sym ; trans = trans }
where
refl : ∀ {A} → A ≅ A
refl {A} = record
{ forth = id
; back = id
; back-forth = id-l
; forth-back = id-l
}
sym : ∀ {A B} → A ≅ B → B ≅ A
sym iso = record
{ forth = back iso
; back = forth iso
; back-forth = forth-back iso
; forth-back = back-forth iso
}
trans : ∀ {A B C : Obj} → A ≅ B → B ≅ C → A ≅ C
trans {A} {B} {C} A≅B B≅C = record
{ forth = forth B≅C ∘ forth A≅B
; back = back A≅B ∘ back B≅C
; back-forth
= begin
(back A≅B ∘ back B≅C) ∘ forth B≅C ∘ forth A≅B
≈⟨ assoc ⟩
back A≅B ∘ back B≅C ∘ forth B≅C ∘ forth A≅B
≈⟨ ∘-resp-r (≈.trans unassoc (∘-resp-l (back-forth B≅C))) ⟩
back A≅B ∘ id ∘ forth A≅B
≈⟨ ∘-resp-r id-l ⟩
back A≅B ∘ forth A≅B
≈⟨ back-forth A≅B ⟩
id
∎
; forth-back
= begin
(forth B≅C ∘ forth A≅B) ∘ back A≅B ∘ back B≅C
≈⟨ assoc ⟩
forth B≅C ∘ forth A≅B ∘ back A≅B ∘ back B≅C
≈⟨ ∘-resp-r (≈.trans unassoc (∘-resp-l (forth-back A≅B))) ⟩
forth B≅C ∘ id ∘ back B≅C
≈⟨ ∘-resp-r id-l ⟩
forth B≅C ∘ back B≅C
≈⟨ forth-back B≅C ⟩
id
∎
}
≅-Setoid : Setoid lo (lo ⊔ la ⊔ l≈)
≅-Setoid = record
{ Carrier = Obj
; _≈_ = _≅_
; isEquivalence = ≅-equiv
}
module ≅ = IsEquivalence ≅-equiv
module ≅-Reasoning = EqReasoning ≅-Setoid
iso-mono : ∀ {A B} (iso : A ≅ B) → IsMono (forth iso)
iso-mono iso {g = g} {h} iso∘g≈iso∘h
= begin
g
≈⟨ ≈.sym id-l ⟩
id ∘ g
≈⟨ ∘-resp-l (≈.sym (back-forth iso)) ⟩
(back iso ∘ forth iso) ∘ g
≈⟨ assoc ⟩
back iso ∘ forth iso ∘ g
≈⟨ ∘-resp-r iso∘g≈iso∘h ⟩
back iso ∘ forth iso ∘ h
≈⟨ unassoc ⟩
(back iso ∘ forth iso) ∘ h
≈⟨ ∘-resp-l (back-forth iso) ⟩
id ∘ h
≈⟨ id-l ⟩
h
∎
iso-epi : ∀ {A B} (iso : A ≅ B) → IsEpi (forth iso)
iso-epi iso {g = g} {h} g∘iso≈h∘iso
= begin
g
≈⟨ ≈.sym id-r ⟩
g ∘ id
≈⟨ ∘-resp-r (≈.sym (forth-back iso)) ⟩
g ∘ forth iso ∘ back iso
≈⟨ unassoc ⟩
(g ∘ forth iso) ∘ back iso
≈⟨ ∘-resp-l g∘iso≈h∘iso ⟩
(h ∘ forth iso) ∘ back iso
≈⟨ assoc ⟩
h ∘ forth iso ∘ back iso
≈⟨ ∘-resp-r (forth-back iso) ⟩
h ∘ id
≈⟨ id-r ⟩
h
∎
|
{
"alphanum_fraction": 0.4425694066,
"avg_line_length": 26.2428571429,
"ext": "agda",
"hexsha": "9bfe04ea246b31345e4ad3e8d0031f6f9e0c8426",
"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": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "alessio-b-zak/cats",
"max_forks_repo_path": "Cats/Category/Constructions/Iso.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"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": "alessio-b-zak/cats",
"max_issues_repo_path": "Cats/Category/Constructions/Iso.agda",
"max_line_length": 75,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a3b69911c4c6ec380ddf6a0f4510d3a755734b86",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "alessio-b-zak/cats",
"max_stars_repo_path": "Cats/Category/Constructions/Iso.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1396,
"size": 3674
}
|
{-# OPTIONS --type-in-type #-}
module Fusion where
open import Data.Product renaming (proj₁ to ₁; proj₂ to ₂) hiding (map; zip)
open import Relation.Binary.PropositionalEquality
open import Data.Sum hiding (map)
open import Data.Bool
open import Data.Nat
open import Data.Unit
open import Data.Empty
open import Function
open import Data.Maybe hiding (map; zip; zipWith)
open import Data.List hiding (map; zip; _++_; filter; foldr; foldl; zipWith; drop; take)
module Stream1 where
data Step (S A : Set) : Set where
stop : Step S A
yield : A → S → Step S A
skip : S → Step S A
mapStep : ∀ {A A' S S'} → (A → A') → (S → S') → Step S A → Step S' A'
mapStep f g stop = stop
mapStep f g (yield a s) = yield (f a) (g s)
mapStep f g (skip s) = skip (g s)
record Stream (A : Set) : Set where
constructor stream
field
S : Set
seed : S
step : S → Step S A
open Stream public
infixr 4 _++_
_++_ : ∀ {A} → Stream A → Stream A → Stream A
S (xs ++ ys) = S xs ⊎ S ys
seed (xs ++ ys) = inj₁ (seed xs)
step (xs ++ ys) (inj₁ s ) with step xs s
... | stop = skip (inj₂ (seed ys))
... | yield a s' = yield a (inj₁ s')
... | skip s' = skip (inj₁ s')
step (xs ++ ys) (inj₂ s) = mapStep id inj₂ (step ys s)
filter : ∀ {A} → (A → Bool) → Stream A → Stream A
S (filter f as) = S as
seed (filter f as) = seed as
step (filter f as) s with step as s
... | stop = stop
... | yield a s' = if f a then yield a s' else skip s'
... | skip s' = skip s'
map : ∀ {A B} → (A → B) → Stream A → Stream B
S (map f as) = S as
seed (map f as) = seed as
step (map f as) = mapStep f id ∘ step as
empty : ∀ {A} → Stream A
S empty = ⊤
seed empty = tt
step empty = λ _ → stop
pure : ∀ {A} → A → Stream A
S (pure a) = Bool
seed (pure a) = true
step (pure a) false = stop
step (pure a) true = yield a false
bind : ∀ {A B} → Stream A → (A → Stream B) → Stream B
S (bind as f) = S as ⊎ (S as × ∃ (S ∘ f))
seed (bind as f) = inj₁ (seed as)
step (bind as f) (inj₁ s) with step as s
... | stop = stop
... | yield a s' = skip (inj₂ (s' , a , seed (f a)))
... | skip s' = skip (inj₁ s')
step (bind as f) (inj₂ (s , a , s')) with step (f a) s'
... | stop = skip (inj₁ s)
... | yield b s'' = yield b (inj₂ (s , a , s''))
... | skip s'' = skip (inj₂ (s , a , s''))
zip : ∀ {A B} → Stream A → Stream B → Stream (A × B)
S (zip {A} as bs) = S as × S bs × Maybe A
seed (zip {A} as bs) = seed as , seed bs , nothing
step (zip {A} as bs) (sa , sb , nothing) with step as sa
... | stop = stop
... | yield a sa' = skip (sa' , sb , just a)
... | skip sa' = skip (sa' , sb , nothing)
step (zip {A} as bs) (sa , sb , just a) with step bs sb
... | stop = stop
... | yield b sb' = yield (a , b) (sa , sb' , nothing)
... | skip sb' = skip (sa , sb' , just a)
{-# NON_TERMINATING #-}
foldr : ∀ {A B : Set} → (A → B → B) → B → Stream A → B
foldr f b (stream S s step) with step s
... | stop = b
... | yield a s' = f a (foldr f b (stream S s' step))
... | skip s' = foldr f b (stream S s' step)
{-# NON_TERMINATING #-}
foldl : ∀ {A B : Set} → (B → A → B) → B → Stream A → B
foldl f b (stream S s step) with step s
... | stop = b
... | yield a s' = foldl f (f b a) (stream S s' step)
... | skip s' = foldl f b (stream S s' step)
module Stream2 where
data Step (S A : Set) : Set where
stop : Step S A
yield : A → S → Step S A
skip : S → Step S A
mapStep : ∀ {A A' S S'} → (A → A') → (S → S') → Step S A → Step S' A'
mapStep f g stop = stop
mapStep f g (yield a s) = yield (f a) (g s)
mapStep f g (skip s) = skip (g s)
record Prod (A : Set) : Set where
constructor stream
field
S : Set
seed : S
step : S → Step S A
open Prod public
infixr 4 _++_
data Stream (A : Set) : Set where
prod : Prod A → Stream A
_++_ : Stream A → Stream A → Stream A
bind : ∀ {B} → Stream B → (B → Stream A) → Stream A
zipWith : ∀ {B C} → (B → C → A) → Stream B → Stream C → Stream A
filter : ∀ {A} → (A → Bool) → Stream A → Stream A
filter f (prod x) = {!!}
filter f (str ++ str₁) = filter f str ++ filter f str₁
filter f (bind str g) = bind str λ b → filter f (g b)
filter f (zipWith x str str₁) = {!!} -- issue
map : ∀ {A B} → (A → B) → Stream A → Stream B
map f (prod as) = {!!}
map f (as ++ as') = map f as ++ map f as'
map f (bind bs g) = bind bs λ b → map f (g b)
-- no bind fusion! (i.e. monad laws)
map f (zipWith g bc cs) = {!!} -- can convert to prod, but better to freely add map...
-- but then we don't have map fusion unless we just add it
-- perhaps first-order syntax is OK, if we hand-write
-- enough fusion?
{-# NON_TERMINATING #-}
foldr : ∀ {A B : Set} → (A → B → B) → B → Stream A → B
foldr f b (prod x) = {!!}
foldr f b (as ++ as') = foldr f (foldr f b as') as
foldr {A} {B} f b (bind {C} cs g) = foldr (λ c b → foldr f b (g c)) b cs
foldr {A} {B} f b (zipWith {C} {D} g cs ds) = {!!}
-- first I have to convert cs/ds to producers to fold them!
-- this means that optimization from first-order rep is blocked at the first zip!
-- general solution: robust producer-to-state-machine compilation
module Stream3 where
Step : Set → Set → Set
Step S A = (Step : Set) → Step → (A → S → Step) → Step
record Pull (A : Set) : Set where
constructor pull
field
S : Set
seed : S
step : S → Step S A
open Pull public
zip : ∀ {A B} → Pull A → Pull B → Pull (A × B)
S (zip as bs) = S as × S bs
seed (zip as bs) = seed as , seed bs
step (zip as bs) (sa , sb) _ stop yield =
step as sa _
stop
λ a sa' → step bs sb _
stop
λ b sb' → yield (a , b) (sa , sb')
map : ∀ {A B} → (A → B) → Pull A → Pull B
S (map f as) = S as
seed (map f as) = seed as
step (map f as) s _ stop yield = step as s _
stop
λ a s → yield (f a) s
{-# NON_TERMINATING #-}
find : ∀ {A S} → (A → Bool) → (S → Step S A) → S → Step S A
find f step s _ stop yield = step s _
stop
λ a s → if f a then yield a s
else find f step s _ stop yield
-- fusing filter without Skip!
-- we can inline continuations in tail-recursive functions, and skipping to the next
-- yield is such a loop
filter : ∀ {A} → (A → Bool) → Pull A → Pull A
S (filter f as) = S as
seed (filter f as) = seed as
step (filter f as) = find f (step as)
{-# NON_TERMINATING #-}
drop' : ∀ {A S} → ℕ → (S → Step S A) → S → S
drop' zero step s = s
drop' (suc n) step s = step s _ s λ a s → drop' n step s
drop : ∀ {A} → ℕ → Pull A → Pull A
S (drop n as) = S as
seed (drop n as) = drop' n (step as) (seed as)
step (drop n as) = step as
take : ∀ {A} → ℕ → Pull A → Pull A
S (take n as) = S as × ℕ
seed (take n as) = seed as , n
step (take n as) (s , zero) _ stop yield = stop
step (take n as) (s , suc x) _ stop yield = step as s _ stop λ a s → yield a (s , x)
infixr 4 _++_
_++_ : ∀ {A} → Pull A → Pull A → Pull A
S (xs ++ ys) = S xs ⊎ S ys
seed (xs ++ ys) = inj₁ (seed xs)
step (xs ++ ys) (inj₁ s) _ stop yield =
step xs s _
(step ys (seed ys) _
stop
λ a s → yield a (inj₂ s))
λ a s → yield a (inj₁ s)
step (xs ++ ys) (inj₂ s) _ stop yield =
step ys s _
stop
λ a s → yield a (inj₂ s)
{-# NON_TERMINATING #-}
bind' : ∀ {A B : Set} (as : Pull A) (f : A → Pull B)
→ S as × Maybe (∃ (S ∘ f)) → Step (S as × Maybe (∃ (S ∘ f))) B
bind' as f (sa , nothing) _ stop yield =
step as sa _
stop
λ a sa → step (f a) (seed (f a)) _
(bind' as f (sa , nothing) _ stop yield)
λ b sb → yield b (sa , (just (a , sb)))
bind' as f (sa , just (a , sb)) _ stop yield =
step (f a) sb _
(bind' as f (sa , nothing) _ stop yield)
λ b sb → yield b (sa , just (a , sb))
{-# NON_TERMINATING #-}
bindNothing' : ∀ {A B : Set} (as : Pull A) (f : A → Pull B)
→ S as → Step (S as × Maybe (∃ (S ∘ f))) B
bindJust' : ∀ {A B : Set} (as : Pull A) (f : A → Pull B)
→ S as × ∃ (S ∘ f) → Step (S as × Maybe (∃ (S ∘ f))) B
bindNothing' as f sa _ stop yield =
step as sa _
stop
λ a sa → bindJust' as f (sa , a , seed (f a)) _ stop yield
bindJust' as f (sa , a , sb) _ stop yield =
step (f a) sb _
(bindNothing' as f sa _ stop yield)
λ b sb → yield b (sa , just (a , sb))
bind : ∀ {A B} → Pull A → (A → Pull B) → Pull B
S (bind as f) = S as × Maybe (∃ (S ∘ f))
seed (bind as f) = seed as , nothing
step (bind as f) (sa , nothing) _ stop yield = bindNothing' as f sa _ stop yield
step (bind as f) (sa , just x) _ stop yield = bindJust' as f (sa , x) _ stop yield
|
{
"alphanum_fraction": 0.5102939557,
"avg_line_length": 33.5166051661,
"ext": "agda",
"hexsha": "089bcbb8833046e0c0d17c54ae53750d3586d417",
"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": "8876a92136e5d37f67e7a8cf52c88253ddf77d9f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "AndrasKovacs/staged",
"max_forks_repo_path": "notes/Fusion.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "8876a92136e5d37f67e7a8cf52c88253ddf77d9f",
"max_issues_repo_issues_event_max_datetime": "2022-02-05T10:17:38.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-07-16T04:06:01.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "AndrasKovacs/staged",
"max_issues_repo_path": "notes/Fusion.agda",
"max_line_length": 91,
"max_stars_count": 78,
"max_stars_repo_head_hexsha": "8876a92136e5d37f67e7a8cf52c88253ddf77d9f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "AndrasKovacs/staged",
"max_stars_repo_path": "notes/Fusion.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-29T20:12:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-04-22T12:51:02.000Z",
"num_tokens": 3273,
"size": 9083
}
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Results concerning uniqueness of identity proofs, with axiom K
------------------------------------------------------------------------
{-# OPTIONS --with-K --safe #-}
module Axiom.UniquenessOfIdentityProofs.WithK where
open import Axiom.UniquenessOfIdentityProofs
open import Relation.Binary.PropositionalEquality.Core
-- Axiom K implies UIP.
uip : ∀ {a A} → UIP {a} A
uip refl refl = refl
|
{
"alphanum_fraction": 0.5337301587,
"avg_line_length": 28,
"ext": "agda",
"hexsha": "a644b08db48a3faa6f993599fbb498ff33665eab",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Axiom/UniquenessOfIdentityProofs/WithK.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "omega12345/agda-mode",
"max_issues_repo_path": "test/asset/agda-stdlib-1.0/Axiom/UniquenessOfIdentityProofs/WithK.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Axiom/UniquenessOfIdentityProofs/WithK.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 100,
"size": 504
}
|
-- examples for termination checking mutual recursion
module Mutual where
data Odd : Set
data Even : Set where
zeroE : Even
succE : Odd -> Even
data Odd where
succO : Even -> Odd
addEO : Even -> Odd -> Odd
addOO : Odd -> Odd -> Even
addOO (succO x) y = succE (addEO x y)
addEO zeroE y = y
addEO (succE x) y = succO (addOO x y)
|
{
"alphanum_fraction": 0.6539589443,
"avg_line_length": 15.5,
"ext": "agda",
"hexsha": "6d580f8906da2fefaa69cbcecb32130ed9bfb77f",
"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/Termination/Mutual.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/Termination/Mutual.agda",
"max_line_length": 53,
"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/Termination/Mutual.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 109,
"size": 341
}
|
--{-# OPTIONS -v tc.pos:100 #-}
open import Agda.Builtin.Equality
data ⊥ : Set where
postulate
A : Set
R : A → Set
magic : ⊥ → A
magic ()
test : (a : ⊥) → magic a ≡ magic _
test a = refl
|
{
"alphanum_fraction": 0.5714285714,
"avg_line_length": 12.25,
"ext": "agda",
"hexsha": "bbf2eef60d33ce52a5ed19f190ef53f603983ccb",
"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/AbsurdMatchIsNeutral.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/AbsurdMatchIsNeutral.agda",
"max_line_length": 34,
"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/AbsurdMatchIsNeutral.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": 70,
"size": 196
}
|
module Main where
{-# IMPORT System.IO #-}
{-# IMPORT System.Environment #-}
open import Base
open import IO
open import IO.File
postulate
getArgs : IO (List String)
{-# COMPILED getArgs getArgs #-}
_`bindIO`_ : {A B : Set} -> IO A -> (A -> IO B) -> IO B
_`bindIO`_ = bindIO
main : IO Unit
main = getArgs `bindIO` mainWithArgs
where
mainWithArgs : List String -> IO Unit
mainWithArgs [] = putStrLn "Give a file name silly"
mainWithArgs (file :: []) =
runFileIO (
openFile file readMode >>= \h ->
-- hGetLine h hd >>= \s ->
-- hClose h hd >>= \_ ->
hGetContents h hd >>= \s ->
return s
) `bindIO` \s -> putStrLn s
mainWithArgs (_ :: _ :: _) =
putStrLn "Just one file will do, thank you very much."
|
{
"alphanum_fraction": 0.5604938272,
"avg_line_length": 23.8235294118,
"ext": "agda",
"hexsha": "55c57c56df5907dd4b53122b16123a95574f13ec",
"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/outdated-and-incorrect/fileIO/Main.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/outdated-and-incorrect/fileIO/Main.agda",
"max_line_length": 60,
"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/outdated-and-incorrect/fileIO/Main.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": 229,
"size": 810
}
|
-- A term model à la Beth
open import Library hiding (_∈_)
module TermModel (Base : Set) where
import Formulas ; open module Form = Formulas Base
import Derivations; open module Der = Derivations Base
-- Beth model
data Cover (Δ : Cxt) : Set where
idc : Cover Δ
bot : (t : Δ ⊢ False) → Cover Δ
node : ∀{A B} (t : Δ ⊢ A ∨ B) (C : Cover (Δ ∙ A)) (D : Cover (Δ ∙ B)) → Cover Δ
data _∈_ Γ : ({Δ} : Cxt) (C : Cover Δ) → Set where
here : Γ ∈ idc {Γ}
left : ∀{Δ A B C D}{t : Δ ⊢ A ∨ B} (e : Γ ∈ C) → Γ ∈ node t C D
right : ∀{Δ A B C D}{t : Δ ⊢ A ∨ B} (e : Γ ∈ D) → Γ ∈ node t C D
coverWk : ∀{Γ Δ} {C : Cover Δ} (e : Γ ∈ C) → Γ ≤ Δ
coverWk here = id≤
coverWk (left e) = coverWk e • weak id≤
coverWk (right e) = coverWk e • weak id≤
transC : ∀{Γ} (C : Cover Γ) (f : ∀{Δ} → Δ ∈ C → Cover Δ) → Cover Γ
transC idc f = f here
transC (bot t) f = bot t
transC (node t C D) f = node t (transC C (f ∘ left)) (transC D (f ∘ right))
-- UNUSED:
trans∈ : ∀{Γ} (C : Cover Γ) (f : ∀{Δ} → Δ ∈ C → Cover Δ) →
∀ {Φ} {Δ} (e : Δ ∈ C) → Φ ∈ f e → Φ ∈ transC C f
trans∈ idc f here = id
trans∈ (bot t) f ()
trans∈ (node t C D) f (left e) = left ∘ trans∈ C (f ∘ left ) e
trans∈ (node t C D) f (right e) = right ∘ trans∈ D (f ∘ right) e
split∈ : ∀{Γ} (C : Cover Γ) (f : ∀{Δ} → Δ ∈ C → Cover Δ) {Φ} (e : Φ ∈ transC C f)
→ ∃ λ Δ → ∃ λ (e : Δ ∈ C) → Φ ∈ f e
split∈ idc f e = _ , _ , e
split∈ (bot t) f ()
split∈ (node t C D) f (left e) with split∈ C (f ∘ left) e
... | Δ , e₁ , e₂ = Δ , left e₁ , e₂
split∈ (node t C D) f (right e) with split∈ D (f ∘ right) e
... | Δ , e₁ , e₂ = Δ , right e₁ , e₂
-- Empty cover
EmptyCover : (Γ : Cxt) → Set
EmptyCover Γ = Σ (Cover Γ) λ C → ∀{Δ} → Δ ∈ C → ⊥
-- Empty cover is isomorphic to a witness of inconsistency
toEmptyCover : ∀{Γ} (t : Γ ⊢ False) → EmptyCover Γ
toEmptyCover t = bot t , λ()
fromEmptyCover : ∀{Γ} (ec : EmptyCover Γ) → Γ ⊢ False
fromEmptyCover (C , f) = reifyF C f
where
reifyF : ∀ {Γ} (C : Cover Γ) (f : ∀ {Δ} → Δ ∈ C → ⊥) → Γ ⊢ False
reifyF idc f = ⊥-elim (f here)
reifyF (bot t) f = t
reifyF (node t C D) f = orE t (reifyF C (f ∘ left)) (reifyF D (f ∘ right))
transE : ∀{Γ} (C : Cover Γ) (f : ∀{Δ} → Δ ∈ C → EmptyCover Δ) → EmptyCover Γ
transE C f = transC C (proj₁ ∘ f) , λ e → let _ , e₁ , e₂ = split∈ C (proj₁ ∘ f) e in f e₁ .proj₂ e₂
-- Paste (from Thorsten)
paste' : ∀{A Γ} (C : Cover Γ) (f : ∀{Δ} (e : Δ ∈ C) → Δ ⊢ A) → Γ ⊢ A
paste' idc f = f here
paste' (bot t) f = falseE t
paste' (node t C D) f = orE t (paste' C (f ∘ left)) (paste' D (f ∘ right))
-- Weakening Covers
monC : ∀{Γ Δ} (τ : Δ ≤ Γ) (C : Cover Γ) → Cover Δ
monC τ idc = idc
monC τ (bot t) = bot (monD τ t)
monC τ (node t C D) = node (monD τ t) (monC (lift τ) C) (monC (lift τ) D)
mon∈ : ∀{Γ Δ Φ} (C : Cover Γ) (τ : Δ ≤ Γ) (e : Φ ∈ monC τ C) → ∃ λ Ψ → Ψ ∈ C × Φ ≤ Ψ
mon∈ {Γ} {Δ} {.Δ} idc τ here = _ , here , τ
mon∈ {Γ} {Δ} {Φ} (bot t) τ ()
mon∈ {Γ} {Δ} {Φ} (node t C D) τ (left e) with mon∈ C (lift τ) e
... | Ψ , e' , σ = Ψ , left e' , σ
mon∈ {Γ} {Δ} {Φ} (node t C D) τ (right e) with mon∈ D (lift τ) e
... | Ψ , e' , σ = Ψ , right e' , σ
-- The syntactic Beth model
T⟦_⟧ : (A : Form) (Γ : Cxt) → Set
T⟦ Atom P ⟧ Γ = Γ ⊢ Atom P
T⟦ True ⟧ Γ = ⊤
T⟦ False ⟧ Γ = EmptyCover Γ
T⟦ A ∨ B ⟧ Γ = ∃ λ (C : Cover Γ) → ∀{Δ} → Δ ∈ C → T⟦ A ⟧ Δ ⊎ T⟦ B ⟧ Δ
T⟦ A ∧ B ⟧ Γ = T⟦ A ⟧ Γ × T⟦ B ⟧ Γ
T⟦ A ⇒ B ⟧ Γ = ∀{Δ} (τ : Δ ≤ Γ) → T⟦ A ⟧ Δ → T⟦ B ⟧ Δ
monT : ∀ A {Γ Δ} (τ : Δ ≤ Γ) → T⟦ A ⟧ Γ → T⟦ A ⟧ Δ
monT (Atom P) τ t = monD τ t
monT True τ _ = _
monT False τ (C , f) = monC τ C , λ {Φ} e → f (proj₁ (proj₂ (mon∈ C τ e)))
monT (A ∨ B) {Γ} {Δ} τ (C , f) = monC τ C , λ {Φ} e →
let Ψ , e' , σ = mon∈ C τ e
in map-⊎ (monT A σ) (monT B σ) (f {Ψ} e')
monT (A ∧ B) τ (a , b) = monT A τ a , monT B τ b
monT (A ⇒ B) τ f σ = f (σ • τ)
-- Reflection / reification
mutual
reflect : ∀{Γ} A (t : Γ ⊢ A) → T⟦ A ⟧ Γ
reflect (Atom P) t = t
reflect True t = _
reflect False = toEmptyCover
reflect (A ∨ B) t = node t idc idc , aux
where
aux : ∀{Δ} → Δ ∈ node t idc idc → T⟦ A ⟧ Δ ⊎ T⟦ B ⟧ Δ
aux (left here) = inj₁ (reflect A (hyp top))
aux (right here) = inj₂ (reflect B (hyp top))
reflect (A ∧ B) t = reflect A (andE₁ t) , reflect B (andE₂ t)
reflect (A ⇒ B) t τ a = reflect B (impE (monD τ t) (reify A a))
reify : ∀{Γ} A (⟦f⟧ : T⟦ A ⟧ Γ) → Γ ⊢ A
reify (Atom P) t = t
reify True _ = trueI
reify False = fromEmptyCover
reify (A ∨ B) (C , f) = paste' C ([ orI₁ ∘ reify A , orI₂ ∘ reify B ] ∘ f)
reify (A ∧ B) (a , b) = andI (reify A a) (reify B b)
reify (A ⇒ B) ⟦f⟧ = impI (reify B (⟦f⟧ (weak id≤) (reflect A (hyp top))))
-- In the absurd world, every proposition holds.
absurd : ∀{Γ A} (t : Γ ⊢ False) → T⟦ A ⟧ Γ
absurd t = reflect _ (falseE t)
-- We can paste in the model thanks to reflection and reification.
-- (However, this does not look nice, since it goes through terms.)
-- paste : ∀ {A Γ} (C : Cover Γ) (f : ∀{Δ} (e : Δ ∈ C) → T⟦ A ⟧ Δ) → T⟦ A ⟧ Γ
-- paste C f = reflect _ (paste' C (reify _ ∘ f))
-- Semantic paste:
paste : ∀ A {Γ} (C : Cover Γ) (f : ∀{Δ} (e : Δ ∈ C) → T⟦ A ⟧ Δ) → T⟦ A ⟧ Γ
paste (Atom P) = paste'
paste True C f = _
paste False C f = transE C f
paste (A ∨ B) C f = transC C (proj₁ ∘ f) , λ e → let _ , e₁ , e₂ = split∈ C (proj₁ ∘ f) e in f e₁ .proj₂ e₂
paste (A ∧ B) C f = paste A C (proj₁ ∘ f) , paste B C (proj₂ ∘ f)
paste (A ⇒ B) C f τ a = paste B (monC τ C) λ {Δ} e → let Ψ , e' , σ = mon∈ C τ e in f e' σ (monT A (coverWk e) a)
-- Fundamental theorem
-- Extension of T⟦_⟧ to contexts
G⟦_⟧ : ∀ (Γ Δ : Cxt) → Set
G⟦ ε ⟧ Δ = ⊤
G⟦ Γ ∙ A ⟧ Δ = G⟦ Γ ⟧ Δ × T⟦ A ⟧ Δ
monG : ∀{Γ Δ Φ} (τ : Φ ≤ Δ) → G⟦ Γ ⟧ Δ → G⟦ Γ ⟧ Φ
monG {ε} τ _ = _
monG {Γ ∙ A} τ (γ , a) = monG τ γ , monT A τ a
-- Variable case
fundH : ∀{Γ Δ A} (x : Hyp A Γ) (γ : G⟦ Γ ⟧ Δ) → T⟦ A ⟧ Δ
fundH top = proj₂
fundH (pop x) = fundH x ∘ proj₁
-- A lemma for the orElim case.
orElim : ∀ {Γ A B X} (C : Cover Γ) (f : {Δ : Cxt} → Δ ∈ C → T⟦ A ⟧ Δ ⊎ T⟦ B ⟧ Δ) →
(∀{Δ} (τ : Δ ≤ Γ) → T⟦ A ⟧ Δ → T⟦ X ⟧ Δ) →
(∀{Δ} (τ : Δ ≤ Γ) → T⟦ B ⟧ Δ → T⟦ X ⟧ Δ) →
T⟦ X ⟧ Γ
orElim C f g h = paste _ C λ e → [ g (coverWk e) , h (coverWk e) ] (f e)
-- falseElim :
falseElim : ∀{Γ A} (C : Cover Γ) (f : ∀{Δ} → Δ ∈ C → ⊥) → T⟦ A ⟧ Γ
falseElim C f = paste _ C (⊥-elim ∘ f)
-- The fundamental theorem
fund : ∀{Γ A} (t : Γ ⊢ A) {Δ} (γ : G⟦ Γ ⟧ Δ) → T⟦ A ⟧ Δ
fund (hyp x) = fundH x
fund (impI t) γ τ a = fund t (monG τ γ , a)
fund (impE t u) γ = fund t γ id≤ (fund u γ)
fund (andI t u) γ = fund t γ , fund u γ
fund (andE₁ t) = proj₁ ∘ fund t
fund (andE₂ t) = proj₂ ∘ fund t
fund (orI₁ t) γ = idc , inj₁ ∘ λ{ here → fund t γ }
fund (orI₂ t) γ = idc , inj₂ ∘ λ{ here → fund t γ }
fund (orE t u v) γ = uncurry orElim (fund t γ)
(λ τ a → fund u (monG τ γ , a))
(λ τ b → fund v (monG τ γ , b))
fund (falseE t) γ = uncurry falseElim (fund t γ)
fund trueI γ = _
-- -}
-- -}
-- Example:
|
{
"alphanum_fraction": 0.5,
"avg_line_length": 33.1866028708,
"ext": "agda",
"hexsha": "9aa0f99af0f73c7c9ea05e256e26b33afe46741d",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2021-02-25T20:39:03.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-11-13T16:01:46.000Z",
"max_forks_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "andreasabel/ipl",
"max_forks_repo_path": "src/TermModel.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "andreasabel/ipl",
"max_issues_repo_path": "src/TermModel.agda",
"max_line_length": 114,
"max_stars_count": 19,
"max_stars_repo_head_hexsha": "9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "andreasabel/ipl",
"max_stars_repo_path": "src/TermModel.agda",
"max_stars_repo_stars_event_max_datetime": "2021-04-27T19:10:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-16T08:08:51.000Z",
"num_tokens": 3327,
"size": 6936
}
|
------------------------------------------------------------------------
-- Decoding types and subtypes into SK terms and equality
------------------------------------------------------------------------
{-# OPTIONS --safe --exact-split --without-K #-}
module FOmegaInt.Undecidable.Decoding where
open import Data.List using ([]; _∷_)
open import Data.Product using (_,_; proj₁; proj₂; _×_)
open import Data.Fin using (zero; suc)
open import Data.Fin.Substitution
open import Data.Fin.Substitution.ExtraLemmas
open import Function using (_∘_)
open import Relation.Binary.PropositionalEquality hiding ([_])
open import FOmegaInt.Syntax
open import FOmegaInt.Kinding.Canonical as Canonical
open import FOmegaInt.Kinding.Canonical.Reduced as Reduced
open import FOmegaInt.Undecidable.SK
open import FOmegaInt.Undecidable.Encoding
open Syntax
open ElimCtx
open Substitution hiding (subst)
open Canonical.Kinding using (_⊢_<:_; _⊢_<:_⇇_; <:-⇇)
open Reduced.Kinding
open Encoding
open ≡-Reasoning
module V = VarSubst
module EL = TermLikeLemmas Substitution.termLikeLemmasElim
module ELV = LiftAppLemmas EL.varLiftAppLemmas
------------------------------------------------------------------------
-- Decoding of types into SK? terms
decode : Elim |Γ| → SK?Term
decode (var x₀ ∙ (a ∷ b ∷ _)) = K · (decode a) · (decode b)
decode (var x₁ ∙ (a ∷ b ∷ c ∷ _)) = S · (decode a) · (decode b) · (decode c)
decode (var x₂ ∙ (a ∷ b ∷ _)) = K · (decode a) · (decode b)
decode (var x₃ ∙ (a ∷ b ∷ c ∷ _)) = S · (decode a) · (decode b) · (decode c)
decode (var x₄ ∙ (a ∷ b ∷ _)) = decode a · decode b
decode (var x₅ ∙ _) = K
decode (var x₆ ∙ _) = S
decode (⊥ ∙ _) = ⊥
decode (⊤ ∙ _) = ⊤
{-# CATCHALL #-}
decode _ = ⊤
-- Decoding is the left-inverse of encoding.
--
-- NOTE. We encode SK terms but decode to SK? terms, so decoding is
-- strictly speaking only left-inverse when restricted to (pure) SK
-- terms. Hence the use of `inject' here.
decode-encode : ∀ t → decode (encode t) ≡ inject t
decode-encode S = refl
decode-encode K = refl
decode-encode (s · t) = cong₂ _·_ (decode-encode s) (decode-encode t)
-- Decoding subsumes squashing
decode-squash : ∀ (a : Elim |Γ|) → decode (squashElim a) ≡ decode a
decode-squash (var x₀ ∙ []) = refl -- degenerate case
decode-squash (var x₀ ∙ (_ ∷ [])) = refl -- degenerate case
decode-squash (var x₀ ∙ (a ∷ b ∷ _)) =
cong₂ (λ a b → K · a · b) (decode-squash a) (decode-squash b)
decode-squash (var x₁ ∙ []) = refl -- degenerate case
decode-squash (var x₁ ∙ (_ ∷ [])) = refl -- degenerate case
decode-squash (var x₁ ∙ (_ ∷ _ ∷ [])) = refl -- degenerate case
decode-squash (var x₁ ∙ (a ∷ b ∷ c ∷ _)) =
trans (cong (S · _ · _ ·_) (decode-squash c))
(cong₂ (λ a b → S · a · b · _) (decode-squash a) (decode-squash b))
decode-squash (var x₂ ∙ []) = refl -- degenerate case
decode-squash (var x₂ ∙ (_ ∷ [])) = refl -- degenerate case
decode-squash (var x₂ ∙ (a ∷ b ∷ _)) =
cong₂ (λ a b → K · a · b) (decode-squash a) (decode-squash b)
decode-squash (var x₃ ∙ []) = refl -- degenerate case
decode-squash (var x₃ ∙ (_ ∷ [])) = refl -- degenerate case
decode-squash (var x₃ ∙ (_ ∷ _ ∷ [])) = refl -- degenerate case
decode-squash (var x₃ ∙ (a ∷ b ∷ c ∷ _)) =
trans (cong (S · _ · _ ·_) (decode-squash c))
(cong₂ (λ a b → S · a · b · _) (decode-squash a) (decode-squash b))
decode-squash (var x₄ ∙ []) = refl -- degenerate case
decode-squash (var x₄ ∙ (_ ∷ [])) = refl -- degenerate case
decode-squash (var x₄ ∙ (a ∷ b ∷ _)) =
cong₂ _·_ (decode-squash a) (decode-squash b)
decode-squash (var x₅ ∙ as) = refl
decode-squash (var x₆ ∙ as) = refl
decode-squash (⊥ ∙ as) = refl
decode-squash (⊤ ∙ as) = refl
-- squashed cases
decode-squash (Π k a ∙ as) = refl
decode-squash ((a ⇒ b) ∙ as) = refl
decode-squash (Λ k a ∙ as) = refl
decode-squash (ƛ a b ∙ as) = refl
decode-squash (a ⊡ b ∙ as) = refl
-- Helper lemmas to be used when decoding kinding derivations.
⌜⌝-⌞⌟-∙∙ : ∀ {n} (a : Elim n) → ⌜ ⌞ a ⌟ ⌝ ∙∙ [] ≡ a
⌜⌝-⌞⌟-∙∙ a = begin
⌜ ⌞ a ⌟ ⌝ ∙∙ [] ≡⟨ ∙∙-[] ⌜ ⌞ a ⌟ ⌝ ⟩
⌜ ⌞ a ⌟ ⌝ ≡⟨ ⌜⌝∘⌞⌟-id a ⟩
a ∎
⌜⌝-⌞⌟-weaken-sub₁ : ∀ {n} (a b : Elim n) →
(⌜ weaken ⌞ a ⌟ ⌝ ∙∙ []) Elim[ ⌞ b ⌟ ] ≡ a
⌜⌝-⌞⌟-weaken-sub₁ a b = begin
(⌜ weaken ⌞ a ⌟ ⌝ ∙∙ []) Elim[ ⌞ b ⌟ ]
≡˘⟨ cong (λ a → (⌜ a ⌝ ∙∙ []) Elim[ ⌞ b ⌟ ]) (⌞⌟-/Var a) ⟩
(⌜ ⌞ weakenElim a ⌟ ⌝ ∙∙ []) Elim[ ⌞ b ⌟ ]
≡⟨ cong (_Elim[ ⌞ b ⌟ ]) (⌜⌝-⌞⌟-∙∙ (weakenElim a)) ⟩
weakenElim a Elim[ ⌞ b ⌟ ]
≡⟨ EL.weaken-sub a ⟩
a
∎
⌜⌝-⌞⌟-weaken-sub₂ : ∀ {n} (a b c : Elim n) →
((⌜ weaken (weaken ⌞ a ⌟) ⌝ ∙∙ []) Elim/ sub ⌞ b ⌟ ↑) Elim[ ⌞ c ⌟ ] ≡ a
⌜⌝-⌞⌟-weaken-sub₂ a b c = begin
((⌜ weaken (weaken ⌞ a ⌟) ⌝ ∙∙ []) Elim/ sub ⌞ b ⌟ ↑) Elim[ ⌞ c ⌟ ]
≡˘⟨ cong (λ a → ((⌜ a ⌝ ∙∙ []) Elim/ sub ⌞ b ⌟ ↑) Elim[ ⌞ c ⌟ ])
(trans (⌞⌟-/Var (weakenElim a)) (cong weaken (⌞⌟-/Var a))) ⟩
((⌜ ⌞ weakenElim (weakenElim a) ⌟ ⌝ ∙∙ []) Elim/ sub ⌞ b ⌟ ↑) Elim[ ⌞ c ⌟ ]
≡⟨ cong (λ a → (a Elim/ sub ⌞ b ⌟ ↑) Elim[ ⌞ c ⌟ ])
(⌜⌝-⌞⌟-∙∙ (weakenElim (weakenElim a))) ⟩
(weakenElim (weakenElim a) Elim/ sub ⌞ b ⌟ ↑) Elim[ ⌞ c ⌟ ]
≡⟨ cong (_Elim[ ⌞ c ⌟ ]) (sym (EL.weaken-/ (weakenElim a))) ⟩
weakenElim (weakenElim a Elim/ sub ⌞ b ⌟) Elim[ ⌞ c ⌟ ]
≡⟨ cong ((_Elim[ ⌞ c ⌟ ]) ∘ weakenElim) (EL.weaken-sub a) ⟩
weakenElim a Elim[ ⌞ c ⌟ ]
≡⟨ EL.weaken-sub a ⟩
a
∎
-- Decoding of (reduced) canonical type order into the SK? term order.
mutual
decode-∼ : ∀ {a b} → Γ-SK? ⊢ a ∼ b → decode a ≤SK? decode b
decode-∼ (∼-trans a∼b b∼c) = ≤?-trans (decode-∼ a∼b) (decode-∼ b∼c)
decode-∼ (∼-⊥ b⇉b⋯b) = ≤?-⊥
decode-∼ (∼-⊤ a⇉a⋯a) = ≤?-⊤
decode-∼ (∼-∙ (⇉-var x₀ _ refl) (∼-∷ _ _ a₁∼b₁ (∼-∷ _ _ a₂∼b₂ ∼-[]))) =
≤?-· (≤?-· ≤?-refl (decode-∼ a₁∼b₁)) (decode-∼ a₂∼b₂)
decode-∼ (∼-∙ (⇉-var x₁ _ refl)
(∼-∷ _ _ a₁∼b₁ (∼-∷ _ _ a₂∼b₂ (∼-∷ _ _ a₃∼b₃ ∼-[])))) =
≤?-· (≤?-· (≤?-· ≤?-refl (decode-∼ a₁∼b₁)) (decode-∼ a₂∼b₂))
(decode-∼ a₃∼b₃)
decode-∼ (∼-∙ (⇉-var x₂ _ refl) (∼-∷ _ _ a₁∼b₁ (∼-∷ _ _ a₂∼b₂ ∼-[]))) =
≤?-· (≤?-· ≤?-refl (decode-∼ a₁∼b₁)) (decode-∼ a₂∼b₂)
decode-∼ (∼-∙ (⇉-var x₃ _ refl)
(∼-∷ _ _ a₁∼b₁ (∼-∷ _ _ a₂∼b₂ (∼-∷ _ _ a₃∼b₃ ∼-[])))) =
≤?-· (≤?-· (≤?-· ≤?-refl (decode-∼ a₁∼b₁)) (decode-∼ a₂∼b₂))
(decode-∼ a₃∼b₃)
decode-∼ (∼-∙ (⇉-var x₄ _ refl) (∼-∷ _ _ a₁∼b₁ (∼-∷ _ _ a₂∼b₂ ∼-[]))) =
≤?-· (decode-∼ a₁∼b₁) (decode-∼ a₂∼b₂)
decode-∼ (∼-∙ (⇉-var x₅ _ refl) ∼-[]) = ≤?-refl
decode-∼ (∼-∙ (⇉-var x₆ _ refl) ∼-[]) = ≤?-refl
decode-∼ (∼-⟨| a⇉b⋯c) = proj₁ (decode-Ne⇉ a⇉b⋯c)
decode-∼ (∼-|⟩ a⇉b⋯c) = proj₂ (decode-Ne⇉ a⇉b⋯c)
decode-Ne⇉ : ∀ {a b c} → Γ-SK? ⊢Ne a ⇉ b ⋯ c →
decode b ≤SK? decode a × decode a ≤SK? decode c
decode-Ne⇉ (⇉-∙ (⇉-var x₀ _ refl) (⇉-∷ {a} a∈* (⇉-∷ {b} b∈* ⇉-[]))) =
subst (λ a′ → decode a′ ≤SK? K · (decode a) · (decode b))
(sym (⌜⌝-⌞⌟-weaken-sub₁ a b)) ≤?-Kexp ,
subst₂ (λ a′ b′ → K · decode a · decode b ≤SK?
K · decode a′ · decode b′)
(sym (⌜⌝-⌞⌟-weaken-sub₁ a b)) (sym (⌜⌝-⌞⌟-∙∙ b)) ≤?-refl
decode-Ne⇉ (⇉-∙ (⇉-var x₁ _ refl)
(⇉-∷ {a} a∈* (⇉-∷ {b} b∈* (⇉-∷ {c} c∈* ⇉-[])))) =
subst₂ (λ a′ b′ → decode a′ · decode c′ · (decode b′ · decode c′) ≤SK?
S · decode a · decode b · decode c)
(sym (⌜⌝-⌞⌟-weaken-sub₂ a b c)) (sym (⌜⌝-⌞⌟-weaken-sub₁ b c))
(subst (λ c′ → decode a · decode c′ · (decode b · decode c′) ≤SK?
S · decode a · decode b · decode c)
(sym (⌜⌝-⌞⌟-∙∙ c)) ≤?-Sexp) ,
subst₂ (λ a′ b′ → S · decode a · decode b · decode c ≤SK?
S · decode a′ · decode b′ · decode c′)
(sym (⌜⌝-⌞⌟-weaken-sub₂ a b c)) (sym (⌜⌝-⌞⌟-weaken-sub₁ b c))
(subst (λ c′ → S · decode a · decode b · decode c ≤SK?
S · decode a · decode b · decode c′)
(sym (⌜⌝-⌞⌟-∙∙ c)) ≤?-refl)
where c′ = ⌜ ⌞ c ⌟ ⌝ ∙∙ []
decode-Ne⇉ (⇉-∙ (⇉-var x₂ _ refl) (⇉-∷ {a} a∈* (⇉-∷ {b} b∈* ⇉-[]))) =
subst₂ (λ a′ b′ → K · decode a′ · decode b′ ≤SK?
K · decode a · decode b)
(sym (⌜⌝-⌞⌟-weaken-sub₁ a b)) (sym (⌜⌝-⌞⌟-∙∙ b)) ≤?-refl ,
subst (λ a′ → K · decode a · decode b ≤SK? decode a′)
(sym (⌜⌝-⌞⌟-weaken-sub₁ a b)) ≤?-Kred
decode-Ne⇉ (⇉-∙ (⇉-var x₃ _ refl)
(⇉-∷ {a} a∈* (⇉-∷ {b} b∈* (⇉-∷ {c} c∈* ⇉-[])))) =
subst₂ (λ a′ b′ → S · decode a′ · decode b′ · decode c′ ≤SK?
S · decode a · decode b · decode c)
(sym (⌜⌝-⌞⌟-weaken-sub₂ a b c)) (sym (⌜⌝-⌞⌟-weaken-sub₁ b c))
(subst (λ c′ → S · decode a · decode b · decode c′ ≤SK?
S · decode a · decode b · decode c)
(sym (⌜⌝-⌞⌟-∙∙ c)) ≤?-refl) ,
subst₂ (λ a′ b′ → S · decode a · decode b · decode c ≤SK?
decode a′ · decode c′ · (decode b′ · decode c′))
(sym (⌜⌝-⌞⌟-weaken-sub₂ a b c)) (sym (⌜⌝-⌞⌟-weaken-sub₁ b c))
(subst (λ c′ → S · decode a · decode b · decode c ≤SK?
decode a · decode c′ · (decode b · decode c′))
(sym (⌜⌝-⌞⌟-∙∙ c)) ≤?-Sred)
where c′ = ⌜ ⌞ c ⌟ ⌝ ∙∙ []
decode-Ne⇉ (⇉-∙ (⇉-var x₄ _ refl) (⇉-∷ a∈* (⇉-∷ b∈* ⇉-[]))) = ≤?-⊥ , ≤?-⊤
decode-Ne⇉ (⇉-∙ (⇉-var x₅ _ refl) ⇉-[]) = ≤?-⊥ , ≤?-⊤
decode-Ne⇉ (⇉-∙ (⇉-var x₆ _ refl) ⇉-[]) = ≤?-⊥ , ≤?-⊤
-- The SK? signature is a first-order context.
kdS-fo : FOKind (kdS {0})
kdS-fo = fo-⋯
kdK-fo : FOKind (kdK {0})
kdK-fo = fo-⋯
kdApp-fo : FOKind (kdApp {0})
kdApp-fo = fo-Π (fo-Π fo-⋯)
kdSRed-fo : FOKind (kdSRed {0})
kdSRed-fo = fo-Π (fo-Π (fo-Π fo-⋯))
kdKRed-fo : FOKind (kdKRed {0})
kdKRed-fo = fo-Π (fo-Π fo-⋯)
kdSExp-fo : FOKind (kdSExp {0})
kdSExp-fo = fo-Π (fo-Π (fo-Π fo-⋯))
kdKExp-fo : FOKind (kdKExp {0})
kdKExp-fo = fo-Π (fo-Π fo-⋯)
Γ-SK?-fo : FOCtx Γ-SK?
Γ-SK?-fo =
fo-∷ (fo-kd kdKExp-fo)
(fo-∷ (fo-kd kdSExp-fo)
(fo-∷ (fo-kd kdKRed-fo)
(fo-∷ (fo-kd kdSRed-fo)
(fo-∷ (fo-kd kdApp-fo)
(fo-∷ (fo-kd kdK-fo)
(fo-∷ (fo-kd kdS-fo) fo-[]))))))
-- Decoding of canonical subtyping into the SK? term order.
decode-<: : ∀ {a b} → Γ-SK? ⊢ a <: b → decode a ≤SK? decode b
decode-<: {a} {b} a<:b =
subst₂ (_≤SK?_) (decode-squash a) (decode-squash b)
(decode-∼ (reduce-<: Γ-SK?-fo a<:b))
decode-<:⇇ : ∀ {a b} → Γ-SK? ⊢ a <: b ⇇ ⌜*⌝ → decode a ≤SK? decode b
decode-<:⇇ {a} {b} (<:-⇇ _ _ a<:b) = decode-<: a<:b
-- Full decoding to SK term equality.
decode-<:⇇-encode : ∀ {s t} → Γ-SK? ⊢ encode s <: encode t ⇇ ⌜*⌝ → s ≡SK t
decode-<:⇇-encode {s} {t} es<:et⇇* =
inject-≤SK?-≡SK (subst₂ (_≤SK?_) (decode-encode s) (decode-encode t)
(decode-<:⇇ es<:et⇇*))
|
{
"alphanum_fraction": 0.4743356389,
"avg_line_length": 41.7794676806,
"ext": "agda",
"hexsha": "467fcb3e3a08f6ff96170ae773297c89bd19b655",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Blaisorblade/f-omega-int-agda",
"max_forks_repo_path": "src/FOmegaInt/Undecidable/Decoding.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Blaisorblade/f-omega-int-agda",
"max_issues_repo_path": "src/FOmegaInt/Undecidable/Decoding.agda",
"max_line_length": 79,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ae20dac2a5e0c18dff2afda4c19954e24d73a24f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Blaisorblade/f-omega-int-agda",
"max_stars_repo_path": "src/FOmegaInt/Undecidable/Decoding.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 5281,
"size": 10988
}
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.ZCohomology.Groups.WedgeOfSpheres where
open import Cubical.ZCohomology.Base
open import Cubical.ZCohomology.Properties
open import Cubical.ZCohomology.Groups.Unit
open import Cubical.ZCohomology.Groups.Sn
open import Cubical.ZCohomology.Groups.Wedge
open import Cubical.ZCohomology.Groups.Connected
open import Cubical.HITs.Sn
open import Cubical.HITs.S1
open import Cubical.Foundations.Prelude
open import Cubical.HITs.Susp
open import Cubical.HITs.Wedge
open import Cubical.HITs.Pushout
open import Cubical.HITs.Truncation renaming (elim to trElim)
open import Cubical.Algebra.Group
S¹⋁S¹ : Type₀
S¹⋁S¹ = S₊∙ 1 ⋁ S₊∙ 1
S²⋁S¹⋁S¹ : Type₀
S²⋁S¹⋁S¹ = S₊∙ 2 ⋁ (S¹⋁S¹ , inl base)
------------- H⁰(S¹⋁S¹) ------------
H⁰-S¹⋁S¹ : GroupIso (coHomGr 0 S¹⋁S¹) intGroup
H⁰-S¹⋁S¹ = H⁰-connected (inl base) (wedgeConnected _ _ (Sn-connected 0) (Sn-connected 0))
------------- H¹(S¹⋁S¹) ------------
H¹-S¹⋁S¹ : GroupIso (coHomGr 1 S¹⋁S¹) (dirProd intGroup intGroup)
H¹-S¹⋁S¹ = (Hⁿ-⋁ _ _ 0) □ dirProdGroupIso coHom1S1≃ℤ coHom1S1≃ℤ
------------- H⁰(S²⋁S¹⋁S¹) ---------
H⁰-S²⋁S¹⋁S¹ : GroupIso (coHomGr 0 S²⋁S¹⋁S¹) intGroup
H⁰-S²⋁S¹⋁S¹ = H⁰-connected (inl north)
(wedgeConnected _ _
(Sn-connected 1)
(wedgeConnected _ _
(Sn-connected 0)
(Sn-connected 0)))
------------- H¹(S²⋁S¹⋁S¹) ---------
H¹-S²⋁S¹⋁S¹ : GroupIso (coHomGr 1 S²⋁S¹⋁S¹) (dirProd intGroup intGroup)
H¹-S²⋁S¹⋁S¹ =
Hⁿ-⋁ (S₊∙ 2) (S¹⋁S¹ , inl base) 0
□ dirProdGroupIso (H¹-Sⁿ≅0 0) H¹-S¹⋁S¹
□ lUnitGroupIso
------------- H²(S²⋁S¹⋁S¹) ---------
H²-S²⋁S¹⋁S¹ : GroupIso (coHomGr 2 S²⋁S¹⋁S¹) intGroup
H²-S²⋁S¹⋁S¹ =
compGroupIso
(Hⁿ-⋁ _ _ 1)
(dirProdGroupIso {B = trivialGroup}
(invGroupIso (Hⁿ-Sⁿ≅ℤ 1))
((Hⁿ-⋁ _ _ 1) □ dirProdGroupIso (Hⁿ-S¹≅0 0) (Hⁿ-S¹≅0 0) □ rUnitGroupIso)
□ rUnitGroupIso)
private
open import Cubical.Data.Int
open import Cubical.Foundations.Equiv
open import Cubical.Data.Sigma
to₂ : coHom 2 S²⋁S¹⋁S¹ → Int
to₂ = GroupHom.fun (GroupIso.map H²-S²⋁S¹⋁S¹)
from₂ : Int → coHom 2 S²⋁S¹⋁S¹
from₂ = GroupIso.inv H²-S²⋁S¹⋁S¹
to₁ : coHom 1 S²⋁S¹⋁S¹ → Int × Int
to₁ = GroupHom.fun (GroupIso.map H¹-S²⋁S¹⋁S¹)
from₁ : Int × Int → coHom 1 S²⋁S¹⋁S¹
from₁ = GroupIso.inv H¹-S²⋁S¹⋁S¹
to₀ : coHom 0 S²⋁S¹⋁S¹ → Int
to₀ = GroupHom.fun (GroupIso.map H⁰-S²⋁S¹⋁S¹)
from₀ : Int → coHom 0 S²⋁S¹⋁S¹
from₀ = GroupIso.inv H⁰-S²⋁S¹⋁S¹
{-
-- Computes (a lot slower than for the torus)
test : to₁ (from₁ (1 , 0) +ₕ from₁ (0 , 1)) ≡ (1 , 1)
test = refl
-- Does not compute:
test2 : to₂ (from₂ 0) ≡ 0
test2 = refl
-}
|
{
"alphanum_fraction": 0.6403574088,
"avg_line_length": 30.1797752809,
"ext": "agda",
"hexsha": "408d3c9c20cca3e21fdcb737f89cd56a04fc51b4",
"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": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "ayberkt/cubical",
"max_forks_repo_path": "Cubical/ZCohomology/Groups/WedgeOfSpheres.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f",
"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": "ayberkt/cubical",
"max_issues_repo_path": "Cubical/ZCohomology/Groups/WedgeOfSpheres.agda",
"max_line_length": 89,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f25b8479fe8160fa4ddbb32e288ba26be6cc242f",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "ayberkt/cubical",
"max_stars_repo_path": "Cubical/ZCohomology/Groups/WedgeOfSpheres.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1297,
"size": 2686
}
|
open import Agda.Builtin.Size
mutual
data Unit (i : Size) : Set where
c : Unit′ i → Unit i
record Unit′ (i : Size) : Set where
coinductive
field
force : {j : Size< i} → Unit j
open Unit′ public
tail : Unit ∞ → Unit ∞
tail (c x) = force x
u : (∀ {i} → Unit′ i → Unit i) →
∀ {i} → Unit i
u cons = tail (cons λ { .force → u cons })
bad : Unit ∞
bad = u c
|
{
"alphanum_fraction": 0.5454545455,
"avg_line_length": 16.0416666667,
"ext": "agda",
"hexsha": "bd48583b211301d854a9e7dfff09d2cc583bd879",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue2985-1.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue2985-1.agda",
"max_line_length": 42,
"max_stars_count": 2,
"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/Issue2985-1.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": 143,
"size": 385
}
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
-- custom pushout for Blakers-Massey
module homotopy.blakersmassey.Pushout {i j k}
{A : Type i} {B : Type j} (Q : A → B → Type k) where
bmspan : Span {i} {j} {lmax i (lmax j k)}
bmspan = span A B (Σ A λ a → Σ B λ b → Q a b) fst (fst ∘ snd)
BMPushout : Type (lmax i (lmax j k))
BMPushout = Pushout bmspan
bmleft : A → BMPushout
bmleft = left
bmright : B → BMPushout
bmright = right
bmglue : ∀ {a b} → Q a b → bmleft a == bmright b
bmglue {a} {b} q = glue (a , b , q)
module BMPushoutElim {l} {P : BMPushout → Type l}
(bmleft* : (a : A) → P (bmleft a)) (bmright* : (b : B) → P (bmright b))
(bmglue* : ∀ {a b} (q : Q a b) → bmleft* a == bmright* b [ P ↓ bmglue q ]) where
private
module P = PushoutElim {d = bmspan} {P = P}
bmleft* bmright* (λ c → bmglue* (snd (snd c)))
f = P.f
glue-β : ∀ {a b} (q : Q a b) → apd f (bmglue q) == bmglue* q
glue-β q = P.glue-β (_ , _ , q)
BMPushout-elim = BMPushoutElim.f
module BMPushoutRec {l} {D : Type l}
(bmleft* : A → D) (bmright* : B → D)
(bmglue* : ∀ {a b} (q : Q a b) → bmleft* a == bmright* b) where
private
module P = PushoutRec {d = bmspan} {D = D}
bmleft* bmright* (λ c → bmglue* (snd (snd c)))
f = P.f
glue-β : ∀ {a b} (q : Q a b) → ap f (bmglue q) == bmglue* q
glue-β q = P.glue-β (_ , _ , q)
|
{
"alphanum_fraction": 0.5544918999,
"avg_line_length": 26.1153846154,
"ext": "agda",
"hexsha": "e438251be9da9b368be52bb4574e4f0c71931eba",
"lang": "Agda",
"max_forks_count": 50,
"max_forks_repo_forks_event_max_datetime": "2022-02-14T03:03:25.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-10T01:48:08.000Z",
"max_forks_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "timjb/HoTT-Agda",
"max_forks_repo_path": "theorems/homotopy/blakersmassey/Pushout.agda",
"max_issues_count": 31,
"max_issues_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_issues_repo_issues_event_max_datetime": "2021-10-03T19:15:25.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-03-05T20:09:00.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "timjb/HoTT-Agda",
"max_issues_repo_path": "theorems/homotopy/blakersmassey/Pushout.agda",
"max_line_length": 82,
"max_stars_count": 294,
"max_stars_repo_head_hexsha": "66f800adef943afdf08c17b8ecfba67340fead5e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "timjb/HoTT-Agda",
"max_stars_repo_path": "theorems/homotopy/blakersmassey/Pushout.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": 582,
"size": 1358
}
|
{-# OPTIONS --without-K --safe #-}
-- The category build from ObjectRestriction can be done so Functorially
module Categories.Functor.Construction.ObjectRestriction where
open import Level
open import Data.Product using (proj₁)
open import Relation.Unary using (Pred)
open import Function using () renaming (id to id→)
open import Categories.Category.Core
open import Categories.Category.Construction.ObjectRestriction
open import Categories.Functor.Core
open import Categories.Functor.Properties using (Faithful; Full)
private
variable
o ℓ e ℓ′ : Level
C : Category o ℓ e
RestrictionFunctor : {ℓ′ : Level} → (C : Category o ℓ e) → (E : Pred (Category.Obj C) ℓ′) → Functor (ObjectRestriction C E) C
RestrictionFunctor C E = record
{ F₀ = proj₁
; F₁ = id→
; identity = Equiv.refl
; homomorphism = Equiv.refl
; F-resp-≈ = id→
}
where
open Category C
RF-Faithful : {E : Pred (Category.Obj C) ℓ′} → Faithful (RestrictionFunctor C E)
RF-Faithful _ _ = id→
RF-Full : {E : Pred (Category.Obj C) ℓ′} → Full (RestrictionFunctor C E)
RF-Full {C = C} = record
{ from = record
{ _⟨$⟩_ = id→
; cong = id→
}
; right-inverse-of = λ _ → Category.Equiv.refl C
}
|
{
"alphanum_fraction": 0.6917293233,
"avg_line_length": 27.2045454545,
"ext": "agda",
"hexsha": "aa1174b9121961b3d7d8cfe90f6c703824006292",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Functor/Construction/ObjectRestriction.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Functor/Construction/ObjectRestriction.agda",
"max_line_length": 125,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Functor/Construction/ObjectRestriction.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": 371,
"size": 1197
}
|
open import Data.Nat using (_+_; _*_; zero; suc; ℕ)
open import Relation.Binary.PropositionalEquality as PropEq
using (_≡_; _≢_; refl; cong)
import Data.Nat.Properties
open Data.Nat.Properties.SemiringSolver
using (solve; _:=_; con; var; _:+_; _:*_; :-_; _:-_)
open PropEq.≡-Reasoning
lem1 : (4 + 6 ≡ 10)
lem1 = refl
lem3 : (x : ℕ) → (2 * (x + 4) ≡ 8 + 2 * x)
lem3 = solve 1 (λ x' → con 2 :* (x' :+ con 4) := con 8 :+ con 2 :* x') refl
sum : ℕ → ℕ
sum zero = 0
sum (suc n) = 1 + 2 * n + sum n
theorem : (n : ℕ) → (sum n ≡ n * n)
theorem 0 = refl
theorem (suc p) =
begin
sum (suc p)
≡⟨ refl ⟩
1 + 2 * p + sum p
≡⟨ cong (λ x → 1 + 2 * p + x) (theorem p)⟩
1 + 2 * p + p * p
≡⟨ solve 1 (λ p → con 1 :+ con 2 :* p :+ p :* p := (con 1 :+ p) :* (con 1 :+ p)) refl p ⟩
(1 + p) * (1 + p)
≡⟨ refl ⟩
(suc p) * (suc p)
∎
|
{
"alphanum_fraction": 0.4994179278,
"avg_line_length": 26.0303030303,
"ext": "agda",
"hexsha": "e85dd84ef58f8150694b82e8d876356adf84a123",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-07-18T22:03:24.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-07-18T22:03:24.000Z",
"max_forks_repo_head_hexsha": "9319c5c1e7d6eec0dc22bc8ae690dc362e9113b9",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "jota191/pml",
"max_forks_repo_path": "tests/comparison/sumodd.agda",
"max_issues_count": 36,
"max_issues_repo_head_hexsha": "9319c5c1e7d6eec0dc22bc8ae690dc362e9113b9",
"max_issues_repo_issues_event_max_datetime": "2020-02-08T09:43:31.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-11-01T16:27:45.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "jota191/pml",
"max_issues_repo_path": "tests/comparison/sumodd.agda",
"max_line_length": 91,
"max_stars_count": 15,
"max_stars_repo_head_hexsha": "9319c5c1e7d6eec0dc22bc8ae690dc362e9113b9",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "jota191/pml",
"max_stars_repo_path": "tests/comparison/sumodd.agda",
"max_stars_repo_stars_event_max_datetime": "2021-12-17T18:31:08.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-12-22T12:10:16.000Z",
"num_tokens": 402,
"size": 859
}
|
-- test for pattern matching on Strings
module StringPattern where
open import Common.IO
open import Common.Unit
open import Common.String
f : String → String
f "bla" = "found-bla"
f x = x
-- expected:
-- no-bla
-- found-bla
main : IO Unit
main =
putStrLn (f "no-bla") ,,
putStrLn (f "bla")
|
{
"alphanum_fraction": 0.6845637584,
"avg_line_length": 15.6842105263,
"ext": "agda",
"hexsha": "67fe1b11625367cee4e259b098783f182aca9a31",
"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/Compiler/simple/StringPattern.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/Compiler/simple/StringPattern.agda",
"max_line_length": 39,
"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/Compiler/simple/StringPattern.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": 87,
"size": 298
}
|
module Issue183 where
postulate A : Set
T : Set
T = A → A
data L (A : Set) : Set where
data E (x : T) : T → Set where
e : E x x
foo : (f : A → A) → L (E f (λ x → f x))
foo = λ _ → e
-- Previously:
-- An internal error has occurred. Please report this as a bug.
-- Location of the error: src/full/Agda/Syntax/Translation/AbstractToConcrete.hs:705
-- Should now give a proper error message.
-- E (_8 f) (_8 f) !=< L (E f f) of type Set
-- when checking that the expression e has type L (E f f)
|
{
"alphanum_fraction": 0.6274900398,
"avg_line_length": 20.9166666667,
"ext": "agda",
"hexsha": "24776b845f0a09fe430fee7e6c5d9a54e19f9d20",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-12T11:35:18.000Z",
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/Issue183.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/Issue183.agda",
"max_line_length": 84,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "477c8c37f948e6038b773409358fd8f38395f827",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "larrytheliquid/agda",
"max_stars_repo_path": "test/fail/Issue183.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": 167,
"size": 502
}
|
module Type.Proofs where
open import Logic
import Lvl
open import Type
|
{
"alphanum_fraction": 0.7662337662,
"avg_line_length": 12.8333333333,
"ext": "agda",
"hexsha": "06d6a32d14f432e7755593a2e2da4b2dbe2090a7",
"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/Proofs.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Type/Proofs.agda",
"max_line_length": 24,
"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/Proofs.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T06:53:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:58:13.000Z",
"num_tokens": 19,
"size": 77
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.