Search is not available for this dataset
text
string | meta
dict |
---|---|
{-# OPTIONS --without-K #-}
module ConcretePermutation where
import Level using (zero)
open import Data.Nat using (ℕ; _+_; _*_)
open import Data.Fin using (Fin)
open import Data.Product using (proj₁; proj₂)
open import Data.Vec using (tabulate)
open import Algebra using (CommutativeSemiring)
open import Algebra.Structures using
(IsSemigroup; IsCommutativeMonoid; IsCommutativeSemiring)
open import Relation.Binary using (IsEquivalence)
open import Relation.Binary.PropositionalEquality
using (_≡_; refl; sym; cong; cong₂; module ≡-Reasoning)
open import Equiv using (_≃_; sym≃;p∘!p≡id)
--
open import FinVec
using (FinVec; 1C; _∘̂_; _⊎c_; _×c_;
unite+; uniti+;
unite+r; uniti+r;
assocl+; assocr+;
swap+cauchy;
unite*; uniti*;
unite*r; uniti*r;
assocl*; assocr*;
swap⋆cauchy;
dist*+; factor*+;
distl*+; factorl*+;
right-zero*l; right-zero*r)
open import FinVecProperties
using (∘̂-assoc; ∘̂-lid; ∘̂-rid;
~⇒≡;
1C⊎1C≡1C; 1C×1C≡1C; 1C₀⊎x≡x;
⊎c-distrib; ×c-distrib;
unite+∘̂uniti+~id; uniti+∘̂unite+~id;
unite+r∘̂uniti+r~id; uniti+r∘̂unite+r~id;
assocl+∘̂assocr+~id; assocr+∘̂assocl+~id;
swap+-inv;
unite*∘̂uniti*~id; uniti*∘̂unite*~id;
unite*r∘̂uniti*r~id; uniti*r∘̂unite*r~id;
assocl*∘̂assocr*~id; assocr*∘̂assocl*~id;
swap*-inv;
dist*+∘̂factor*+~id; factor*+∘̂dist*+~id;
distl*+∘̂factorl*+~id; factorl*+∘̂distl*+~id;
right-zero*l∘̂right-zero*r~id; right-zero*r∘̂right-zero*l~id)
------------------------------------------------------------------------------
-- A concrete permutation has 4 components:
-- - the one-line notation for a permutation
-- - the one-line notation for the inverse permutation
-- - and 2 proofs that these are indeed inverses
record CPerm (values : ℕ) (size : ℕ) : Set where
constructor cp
field
π : FinVec values size
πᵒ : FinVec size values
αp : π ∘̂ πᵒ ≡ 1C
βp : πᵒ ∘̂ π ≡ 1C
------------------------------------------------------------------------------
-- Now the goal is to prove that CPerm m n is a commutative semiring
-- (including symmetry now)
-- First it is an equivalence relation
idp : ∀ {n} → CPerm n n
idp {n} = cp 1C 1C (∘̂-rid _) (∘̂-lid _)
symp : ∀ {m n} → CPerm m n → CPerm n m
symp (cp p₁ p₂ α β) = cp p₂ p₁ β α
transp : ∀ {m₁ m₂ m₃} → CPerm m₂ m₁ → CPerm m₃ m₂ → CPerm m₃ m₁
transp {n} (cp π πᵒ αp βp) (cp π₁ πᵒ₁ αp₁ βp₁) = cp (π ∘̂ π₁) (πᵒ₁ ∘̂ πᵒ) pf₁ pf₂
where
open ≡-Reasoning
pf₁ : (π ∘̂ π₁) ∘̂ (πᵒ₁ ∘̂ πᵒ) ≡ 1C
pf₁ =
begin (
(π ∘̂ π₁) ∘̂ (πᵒ₁ ∘̂ πᵒ) ≡⟨ ∘̂-assoc _ _ _ ⟩
((π ∘̂ π₁) ∘̂ πᵒ₁) ∘̂ πᵒ ≡⟨ cong (λ x → x ∘̂ πᵒ) (sym (∘̂-assoc _ _ _)) ⟩
(π ∘̂ (π₁ ∘̂ πᵒ₁)) ∘̂ πᵒ ≡⟨ cong (λ x → (π ∘̂ x) ∘̂ πᵒ) (αp₁) ⟩
(π ∘̂ 1C) ∘̂ πᵒ ≡⟨ cong (λ x → x ∘̂ πᵒ) (∘̂-rid _) ⟩
π ∘̂ πᵒ ≡⟨ αp ⟩
1C ∎)
pf₂ : (πᵒ₁ ∘̂ πᵒ) ∘̂ (π ∘̂ π₁) ≡ 1C
pf₂ =
begin (
(πᵒ₁ ∘̂ πᵒ) ∘̂ (π ∘̂ π₁) ≡⟨ ∘̂-assoc _ _ _ ⟩
((πᵒ₁ ∘̂ πᵒ) ∘̂ π) ∘̂ π₁ ≡⟨ cong (λ x → x ∘̂ π₁) (sym (∘̂-assoc _ _ _)) ⟩
(πᵒ₁ ∘̂ (πᵒ ∘̂ π)) ∘̂ π₁ ≡⟨ cong (λ x → (πᵒ₁ ∘̂ x) ∘̂ π₁) βp ⟩
(πᵒ₁ ∘̂ 1C) ∘̂ π₁ ≡⟨ cong (λ x → x ∘̂ π₁) (∘̂-rid _) ⟩
πᵒ₁ ∘̂ π₁ ≡⟨ βp₁ ⟩
1C ∎)
-- units
-- zero permutation
0p : CPerm 0 0
0p = idp {0}
-- Additive monoid
_⊎p_ : ∀ {m₁ m₂ n₁ n₂} → CPerm m₁ m₂ → CPerm n₁ n₂ → CPerm (m₁ + n₁) (m₂ + n₂)
_⊎p_ {m₁} {m₂} {n₁} {n₂} π₀ π₁ =
cp ((π π₀) ⊎c (π π₁)) ((πᵒ π₀) ⊎c (πᵒ π₁)) pf₁ pf₂
where
open CPerm
open ≡-Reasoning
pf₁ : (π π₀ ⊎c π π₁) ∘̂ (πᵒ π₀ ⊎c πᵒ π₁) ≡ 1C
pf₁ =
begin (
(π π₀ ⊎c π π₁) ∘̂ (πᵒ π₀ ⊎c πᵒ π₁)
≡⟨ ⊎c-distrib {p₁ = π π₀} ⟩
(π π₀ ∘̂ πᵒ π₀) ⊎c (π π₁ ∘̂ πᵒ π₁)
≡⟨ cong₂ _⊎c_ (αp π₀) (αp π₁) ⟩
1C {m₂} ⊎c 1C {n₂}
≡⟨ 1C⊎1C≡1C {m₂} ⟩
1C ∎)
pf₂ : (πᵒ π₀ ⊎c πᵒ π₁) ∘̂ (π π₀ ⊎c π π₁) ≡ 1C
pf₂ =
begin (
(πᵒ π₀ ⊎c πᵒ π₁) ∘̂ (π π₀ ⊎c π π₁)
≡⟨ ⊎c-distrib {p₁ = πᵒ π₀} ⟩
(πᵒ π₀ ∘̂ π π₀) ⊎c (πᵒ π₁ ∘̂ π π₁)
≡⟨ cong₂ _⊎c_ (βp π₀) (βp π₁) ⟩
1C {m₁} ⊎c 1C {n₁}
≡⟨ 1C⊎1C≡1C {m₁} ⟩
1C ∎ )
-- For the rest of the permutations, it is convenient to lift things from
-- FinVec in one go
mkPerm : {m n : ℕ} → (Fin m ≃ Fin n) → CPerm m n
mkPerm {m} {n} eq = cp p q p∘̂q≡1 q∘̂p≡1
where
f = proj₁ eq
g = proj₁ (sym≃ eq)
p = tabulate g -- note the flip!
q = tabulate f
q∘̂p≡1 = ~⇒≡ {f = g} {g = f} (p∘!p≡id {p = eq})
p∘̂q≡1 = ~⇒≡ {f = f} {g = g} (p∘!p≡id {p = sym≃ eq})
-- units
unite+p : {m : ℕ} → CPerm m (0 + m)
unite+p {m} =
cp (unite+ {m}) (uniti+ {m}) (unite+∘̂uniti+~id {m}) (uniti+∘̂unite+~id {m})
uniti+p : {m : ℕ} → CPerm (0 + m) m
uniti+p {m} = symp (unite+p {m})
unite+rp : {m : ℕ} → CPerm m (m + 0)
unite+rp {m} =
cp (unite+r {m}) (uniti+r) (unite+r∘̂uniti+r~id) (uniti+r∘̂unite+r~id)
uniti+rp : {m : ℕ} → CPerm (m + 0) m
uniti+rp {m} = symp (unite+rp {m})
-- commutativity
swap+p : {m n : ℕ} → CPerm (n + m) (m + n)
swap+p {m} {n} =
cp (swap+cauchy m n) (swap+cauchy n m) (swap+-inv {m}) (swap+-inv {n})
-- associativity
assocl+p : {m n o : ℕ} → CPerm ((m + n) + o) (m + (n + o))
assocl+p {m} =
cp
(assocl+ {m}) (assocr+ {m})
(assocl+∘̂assocr+~id {m}) (assocr+∘̂assocl+~id {m})
assocr+p : {m n o : ℕ} → CPerm (m + (n + o)) ((m + n) + o)
assocr+p {m} = symp (assocl+p {m})
-- Multiplicative monoid
_×p_ : ∀ {m₁ m₂ n₁ n₂} → CPerm m₁ m₂ → CPerm n₁ n₂ → CPerm (m₁ * n₁) (m₂ * n₂)
_×p_ {m₁} {m₂} {n₁} {n₂} π₀ π₁ =
cp ((π π₀) ×c (π π₁)) ((πᵒ π₀) ×c (πᵒ π₁)) pf₁ pf₂
where
open CPerm
open ≡-Reasoning
pf₁ : (π π₀ ×c π π₁) ∘̂ (πᵒ π₀ ×c πᵒ π₁) ≡ 1C
pf₁ =
begin (
(π π₀ ×c π π₁) ∘̂ (πᵒ π₀ ×c πᵒ π₁) ≡⟨ ×c-distrib {p₁ = π π₀} ⟩
(π π₀ ∘̂ πᵒ π₀) ×c (π π₁ ∘̂ πᵒ π₁) ≡⟨ cong₂ _×c_ (αp π₀) (αp π₁) ⟩
1C ×c 1C ≡⟨ 1C×1C≡1C ⟩
1C ∎)
pf₂ : (πᵒ π₀ ×c πᵒ π₁) ∘̂ (π π₀ ×c π π₁) ≡ 1C
pf₂ =
begin (
(πᵒ π₀ ×c πᵒ π₁) ∘̂ (π π₀ ×c π π₁) ≡⟨ ×c-distrib {p₁ = πᵒ π₀} ⟩
(πᵒ π₀ ∘̂ π π₀) ×c (πᵒ π₁ ∘̂ π π₁) ≡⟨ cong₂ _×c_ (βp π₀) (βp π₁) ⟩
1C ×c 1C ≡⟨ 1C×1C≡1C ⟩
1C ∎)
-- units
unite*p : {m : ℕ} → CPerm m (1 * m)
unite*p {m} =
cp (unite* {m}) (uniti* {m}) (unite*∘̂uniti*~id {m}) (uniti*∘̂unite*~id {m})
uniti*p : {m : ℕ} → CPerm (1 * m) m
uniti*p {m} = symp (unite*p {m})
unite*rp : {m : ℕ} → CPerm m (m * 1)
unite*rp {m} =
cp
(unite*r {m}) (uniti*r {m})
(unite*r∘̂uniti*r~id {m}) (uniti*r∘̂unite*r~id {m})
uniti*rp : {m : ℕ} → CPerm (m * 1) m
uniti*rp {m} = symp (unite*rp {m})
-- commutativity
swap*p : {m n : ℕ} → CPerm (n * m) (m * n)
swap*p {m} {n} =
cp (swap⋆cauchy m n) (swap⋆cauchy n m) (swap*-inv {m}) (swap*-inv {n})
-- associativity
assocl*p : {m n o : ℕ} → CPerm ((m * n) * o) (m * (n * o))
assocl*p {m} =
cp
(assocl* {m}) (assocr* {m})
(assocl*∘̂assocr*~id {m}) (assocr*∘̂assocl*~id {m})
assocr*p : {m n o : ℕ} → CPerm (m * (n * o)) ((m * n) * o)
assocr*p {m} = symp (assocl*p {m})
-- Distributivity
-- right-zero absorbing permutation
0pr : ∀ {n} → CPerm 0 (n * 0)
0pr {n} =
cp
(right-zero*l {n}) (right-zero*r {n})
(right-zero*l∘̂right-zero*r~id {n}) (right-zero*r∘̂right-zero*l~id {n})
-- and its symmetric version
0pl : ∀ {n} → CPerm (n * 0) 0
0pl {n} = symp (0pr {n})
distp : {m n o : ℕ} → CPerm (m * o + n * o) ((m + n) * o)
distp {m} {n} {o} =
cp
(dist*+ {m}) (factor*+ {m})
(dist*+∘̂factor*+~id {m}) (factor*+∘̂dist*+~id {m})
factorp : {m n o : ℕ} → CPerm ((m + n) * o) (m * o + n * o)
factorp {m} = symp (distp {m})
distlp : {m n o : ℕ} → CPerm (m * n + m * o) (m * (n + o))
distlp {m} {n} {o} =
cp
(distl*+ {m}) (factorl*+ {m})
(distl*+∘̂factorl*+~id {m}) (factorl*+∘̂distl*+~id {m})
factorlp : {m n o : ℕ} → CPerm (m * (n + o)) (m * n + m * o)
factorlp {m} = symp (distlp {m})
------------------------------------------------------------------------------
-- Commutative semiring structure
cpermIsEquiv : IsEquivalence {Level.zero} {Level.zero} {ℕ} CPerm
cpermIsEquiv = record {
refl = idp;
sym = symp;
trans = λ p q → transp q p
}
cpermPlusIsSG : IsSemigroup {Level.zero} {Level.zero} {ℕ} CPerm _+_
cpermPlusIsSG = record {
isEquivalence = cpermIsEquiv ;
assoc = λ m n o → assocl+p {m} {n} {o} ;
∙-cong = _⊎p_
}
cpermTimesIsSG : IsSemigroup {Level.zero} {Level.zero} {ℕ} CPerm _*_
cpermTimesIsSG = record {
isEquivalence = cpermIsEquiv ;
assoc = λ m n o → assocl*p {m} {n} {o} ;
∙-cong = _×p_
}
cpermPlusIsCM : IsCommutativeMonoid CPerm _+_ 0
cpermPlusIsCM = record {
isSemigroup = cpermPlusIsSG ;
identityˡ = λ m → idp ;
comm = λ m n → swap+p {n} {m}
}
cpermTimesIsCM : IsCommutativeMonoid CPerm _*_ 1
cpermTimesIsCM = record {
isSemigroup = cpermTimesIsSG ;
identityˡ = λ m → uniti*p {m} ;
comm = λ m n → swap*p {n} {m}
}
cpermIsCSR : IsCommutativeSemiring CPerm _+_ _*_ 0 1
cpermIsCSR = record {
+-isCommutativeMonoid = cpermPlusIsCM ;
*-isCommutativeMonoid = cpermTimesIsCM ;
distribʳ = λ o m n → factorp {m} {n} {o} ;
zeroˡ = λ m → 0p
}
cpermCSR : CommutativeSemiring Level.zero Level.zero
cpermCSR = record {
Carrier = ℕ ;
_≈_ = CPerm;
_+_ = _+_ ;
_*_ = _*_ ;
0# = 0 ;
1# = 1 ;
isCommutativeSemiring = cpermIsCSR
}
------------------------------------------------------------------------------
| {
"alphanum_fraction": 0.4944125326,
"avg_line_length": 28.8403614458,
"ext": "agda",
"hexsha": "bd03bee84547d5105197abd1695fc4b68927909e",
"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/Obsolete/ConcretePermutation2.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/Obsolete/ConcretePermutation2.agda",
"max_line_length": 81,
"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/Obsolete/ConcretePermutation2.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": 4699,
"size": 9575
} |
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-}
open import Light.Library.Data.Natural as ℕ using (ℕ)
open import Light.Package using (Package)
module Light.Literals.Natural ⦃ package : Package record { ℕ } ⦄ where
open import Light.Literals.Definition.Natural using (FromNatural)
open FromNatural using (convert)
instance from‐natural : FromNatural ℕ
convert from‐natural n = n
| {
"alphanum_fraction": 0.7686746988,
"avg_line_length": 31.9230769231,
"ext": "agda",
"hexsha": "c64a6fbeaf948e945533aafb3f136067fdeb4b59",
"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/Literals/Natural.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/Literals/Natural.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/Literals/Natural.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": 99,
"size": 415
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Decorated star-lists
------------------------------------------------------------------------
{-# OPTIONS --with-K --safe #-}
module Data.Star.Decoration where
open import Data.Unit
open import Function
open import Level
open import Relation.Binary
open import Relation.Binary.Construct.Closure.ReflexiveTransitive
-- A predicate on relation "edges" (think of the relation as a graph).
EdgePred : {ℓ r : Level} (p : Level) {I : Set ℓ} → Rel I r → Set (suc p ⊔ ℓ ⊔ r)
EdgePred p T = ∀ {i j} → T i j → Set p
data NonEmptyEdgePred {ℓ r p : Level} {I : Set ℓ} (T : Rel I r)
(P : EdgePred p T) : Set (ℓ ⊔ r ⊔ p) where
nonEmptyEdgePred : ∀ {i j} {x : T i j}
(p : P x) → NonEmptyEdgePred T P
-- Decorating an edge with more information.
data DecoratedWith {ℓ r p : Level} {I : Set ℓ} {T : Rel I r} (P : EdgePred p T)
: Rel (NonEmpty (Star T)) p where
↦ : ∀ {i j k} {x : T i j} {xs : Star T j k}
(p : P x) → DecoratedWith P (nonEmpty (x ◅ xs)) (nonEmpty xs)
module _ {ℓ r p : Level} {I : Set ℓ} {T : Rel I r} {P : EdgePred p T} where
edge : ∀ {i j} → DecoratedWith {T = T} P i j → NonEmpty T
edge (↦ {x = x} p) = nonEmpty x
decoration : ∀ {i j} → (d : DecoratedWith {T = T} P i j) →
P (NonEmpty.proof (edge d))
decoration (↦ p) = p
-- Star-lists decorated with extra information. All P xs means that
-- all edges in xs satisfy P.
All : ∀ {ℓ r p} {I : Set ℓ} {T : Rel I r} → EdgePred p T → EdgePred (ℓ ⊔ (r ⊔ p)) (Star T)
All P {j = j} xs =
Star (DecoratedWith P) (nonEmpty xs) (nonEmpty {y = j} ε)
-- We can map over decorated vectors.
gmapAll : ∀ {ℓ ℓ′ r p q} {I : Set ℓ} {T : Rel I r} {P : EdgePred p T}
{J : Set ℓ′} {U : Rel J r} {Q : EdgePred q U}
{i j} {xs : Star T i j}
(f : I → J) (g : T =[ f ]⇒ U) →
(∀ {i j} {x : T i j} → P x → Q (g x)) →
All P xs → All {T = U} Q (gmap f g xs)
gmapAll f g h ε = ε
gmapAll f g h (↦ x ◅ xs) = ↦ (h x) ◅ gmapAll f g h xs
-- Since we don't automatically have gmap id id xs ≡ xs it is easier
-- to implement mapAll in terms of map than in terms of gmapAll.
mapAll : ∀ {ℓ r p q} {I : Set ℓ} {T : Rel I r}
{P : EdgePred p T} {Q : EdgePred q T} {i j} {xs : Star T i j} →
(∀ {i j} {x : T i j} → P x → Q x) →
All P xs → All Q xs
mapAll {P = P} {Q} f ps = map F ps
where
F : DecoratedWith P ⇒ DecoratedWith Q
F (↦ x) = ↦ (f x)
-- We can decorate star-lists with universally true predicates.
decorate : ∀ {ℓ r p} {I : Set ℓ} {T : Rel I r} {P : EdgePred p T} {i j} →
(∀ {i j} (x : T i j) → P x) →
(xs : Star T i j) → All P xs
decorate f ε = ε
decorate f (x ◅ xs) = ↦ (f x) ◅ decorate f xs
-- We can append Alls. Unfortunately _◅◅_ does not quite work.
infixr 5 _◅◅◅_ _▻▻▻_
_◅◅◅_ : ∀ {ℓ r p} {I : Set ℓ} {T : Rel I r} {P : EdgePred p T}
{i j k} {xs : Star T i j} {ys : Star T j k} →
All P xs → All P ys → All P (xs ◅◅ ys)
ε ◅◅◅ ys = ys
(↦ x ◅ xs) ◅◅◅ ys = ↦ x ◅ xs ◅◅◅ ys
_▻▻▻_ : ∀ {ℓ r p} {I : Set ℓ} {T : Rel I r} {P : EdgePred p T}
{i j k} {xs : Star T j k} {ys : Star T i j} →
All P xs → All P ys → All P (xs ▻▻ ys)
_▻▻▻_ = flip _◅◅◅_
| {
"alphanum_fraction": 0.4968777877,
"avg_line_length": 35.03125,
"ext": "agda",
"hexsha": "24428a58436fb2b73321fd42dfaa1556f616c647",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "omega12345/agda-mode",
"max_forks_repo_path": "test/asset/agda-stdlib-1.0/Data/Star/Decoration.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/Star/Decoration.agda",
"max_line_length": 90,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "omega12345/agda-mode",
"max_stars_repo_path": "test/asset/agda-stdlib-1.0/Data/Star/Decoration.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": 1289,
"size": 3363
} |
module Category.Fibration where
open import Data.Product
open import Category.Category
open import Category.Subcategory
open import Category.Funct
| {
"alphanum_fraction": 0.8410596026,
"avg_line_length": 15.1,
"ext": "agda",
"hexsha": "203583786b520bb9c613036013f4cc05853b4056",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "heades/AUGL",
"max_forks_repo_path": "setoid-cats/Category/Fibration.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "heades/AUGL",
"max_issues_repo_path": "setoid-cats/Category/Fibration.agda",
"max_line_length": 32,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b33c6a59d664aed46cac8ef77d34313e148fecc2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "heades/AUGL",
"max_stars_repo_path": "setoid-cats/Category/Fibration.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 28,
"size": 151
} |
-- 2010-10-04
-- termination checker no longer counts stripping off a record constructor
-- as decrease
module Issue334 where
data Unit : Set where
unit : Unit
record E : Set where
inductive
constructor mkE
field
fromE : E
spam : Unit
f : E -> Set
f (mkE e unit) = f e
-- the record pattern translation does not apply to f
-- still, should not termination check, because
-- f (mkE e u) = f e
-- also does not!
| {
"alphanum_fraction": 0.6789838337,
"avg_line_length": 18.8260869565,
"ext": "agda",
"hexsha": "9861e38da4f53cabe6bf8115f214c579f8bc6491",
"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": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "hborum/agda",
"max_forks_repo_path": "test/Fail/Issue334.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"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": "hborum/agda",
"max_issues_repo_path": "test/Fail/Issue334.agda",
"max_line_length": 74,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "aac88412199dd4cbcb041aab499d8a6b7e3f4a2e",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "hborum/agda",
"max_stars_repo_path": "test/Fail/Issue334.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": 127,
"size": 433
} |
open import Relation.Binary.PropositionalEquality
open import Data.Unit using (⊤ ; tt)
open import Data.Product renaming (_×_ to _∧_ ; proj₁ to fst ; proj₂ to snd)
open import Data.Sum renaming (_⊎_ to _∨_ ; inj₁ to left ; inj₂ to right)
open import Data.Nat using (ℕ ; zero ; suc)
open import Data.Product renaming (proj₁ to fst ; proj₂ to snd)
open import Data.List hiding (length ; head)
{- --- 1. Order on natural numbers --- -}
data _≤_ : ℕ → ℕ → Set where
z≤n : {n : ℕ} → zero ≤ n
s≤s : {m n : ℕ} (m≤n : m ≤ n) → suc m ≤ suc n
{- 1.1 Compatibility with successor -}
≤-pred : {m n : ℕ} → (suc m ≤ suc n) → m ≤ n
≤-pred (s≤s i) = i
≤-suc : {m n : ℕ} → (m ≤ n) → suc m ≤ suc n
≤-suc i = s≤s i
{- 1.2 Reflexivity -}
≤-refl : (n : ℕ) → n ≤ n
≤-refl zero = z≤n
≤-refl (suc n) = s≤s (≤-refl n)
{- 1.3 Transitivity -}
≤-trans : {m n p : ℕ} → (m ≤ n) → (n ≤ p) → (m ≤ p)
≤-trans z≤n i2 = z≤n
≤-trans (s≤s i1) (s≤s i2) = ≤-suc (≤-trans i1 i2)
{- 1.4 Totality -}
_≤?_ : (m n : ℕ) → (m ≤ n) ∨ (n ≤ m)
zero ≤? n = left z≤n
suc m ≤? zero = right z≤n
suc m ≤? suc n with m ≤? n
... | left e = left (≤-suc e)
... | right e = right (≤-suc e)
{- --- 2. Insertion sort --- -}
{- 2.1 Insertion -}
insert : (x : ℕ) → (l : List ℕ) → List ℕ
insert x [] = x ∷ []
insert x (x₁ ∷ l) with x ≤? x₁
... | left e = x ∷ (x₁ ∷ l)
... | right e = x₁ ∷ (insert x l)
{- 2.2 Sorting -}
sort : List ℕ → List ℕ
sort [] = []
sort (x ∷ l) = insert x (sort l)
test : List ℕ
test = sort (4 ∷ 1 ∷ 45 ∷ 8 ∷ 32 ∷ 12 ∷ 1 ∷ [])
{- 2.3 The bounded below predicate -}
data _≤*_ : ℕ → List ℕ → Set where
[] : {x : ℕ} → x ≤* []
_∷_ : {x y : ℕ} → {l : List ℕ} → (x ≤ y) → (x ≤* l) → (x ≤* (y ∷ l))
{- 2.4 The sorted predicate -}
data sorted : (l : List ℕ) → Set where
[] : sorted []
_∷_ : {x : ℕ} → {l : List ℕ} → (x ≤* l) → sorted l → (sorted (x ∷ l))
{- 2.5 Insert is sorting -}
≤*-trans : {x y : ℕ} → (l : List ℕ) → x ≤ y → y ≤* l → x ≤* l
≤*-trans [] x≤y y≤*l = []
≤*-trans (x₁ ∷ l) x≤y (y≤x₁ ∷ y≤*l) = ≤-trans x≤y y≤x₁ ∷ ≤*-trans l x≤y y≤*l
sorted-lemma : {x y : ℕ} → (l : List ℕ) → x ≤ y → sorted (y ∷ l) → x ≤* (y ∷ l)
sorted-lemma l x≤y (y≤*l ∷ s) = x≤y ∷ (≤*-trans l x≤y y≤*l)
insert-lemma : (x y : ℕ) → (l : List ℕ) → y ≤ x → y ≤* l → y ≤* insert x l
insert-lemma x y [] y≤x y≤*l = y≤x ∷ []
insert-lemma x y (x₁ ∷ l) y≤x (y≤x₁ ∷ y≤*l) with x ≤? x₁
... | right x₁≤x = y≤x₁ ∷ insert-lemma x y l y≤x y≤*l
... | left x≤x₁ = y≤x ∷ (y≤x₁ ∷ y≤*l)
insert-sorting : (x : ℕ) → (l : List ℕ) → sorted l → sorted (insert x l)
insert-sorting x [] s = [] ∷ []
insert-sorting x (y ∷ l) (y≤*l ∷ s) with x ≤? y
... | left x≤y = (x≤y ∷ (≤*-trans l x≤y y≤*l)) ∷ (y≤*l ∷ s)
... | right y≤x = insert-lemma x y l y≤x y≤*l ∷ (insert-sorting x l s)
{- 2.6 Sort is sorting -}
sort-sorting : (l : List ℕ) → sorted (sort l)
sort-sorting [] = []
sort-sorting (x ∷ l) = insert-sorting x (sort l) (sort-sorting l)
{- 2.7 The problem of specification -}
{- Empty lists are always sorted, so always return an empty list -}
f : List ℕ → List ℕ
f l = []
f-sorting : (l : List ℕ) → sorted (f l)
f-sorting _ = []
{- 2.8 Intrinsic approach -}
mutual
data Sorted : Set where
nil : Sorted
cons : (x : ℕ) → (l : Sorted) → x ≤ (head x l) → Sorted
head : ℕ → Sorted → ℕ
head d nil = d
head d (cons x l x₁) = x
mutual
insert' : (x : ℕ) → Sorted → Sorted
insert' x nil = nil
insert' x (cons x₁ l x₁≤hd) with x ≤? x₁
... | left x≤x₁ = cons x (cons x₁ l x₁≤hd) x≤x₁
... | right x₁≤x = cons x₁ (insert' x l) (ins-lemma x x₁ l x₁≤x x₁≤hd)
{- In other words, y ≤ x and y ≤* l gives us y ≤* (insert x l) -}
ins-lemma : (x y : ℕ) → (l : Sorted) → y ≤ x → y ≤ head y l → y ≤ head y (insert' x l)
ins-lemma x y nil y≤x y≤hd = ≤-refl y
ins-lemma x y (cons x₁ l x₁≤hd) y≤x y≤hd with x ≤? x₁
... | left x≤x₁ = y≤x
... | right x₁≤x = y≤hd
sort' : (l : List ℕ) → Sorted
sort' [] = nil
sort' (x ∷ l) = insert' x (sort' l)
{- --- 4. Merge sort --- -}
{- 4.1 Splitting -}
split : {A : Set} → List A → List A × List A
split [] = [] , []
split (x ∷ []) = (x ∷ []) , []
split (x ∷ y ∷ l) =
let (l₁ , l₂) = split l in
x ∷ l₁ , y ∷ l₂
test-split : List ℕ × List ℕ
test-split = split (4 ∷ 1 ∷ 45 ∷ 8 ∷ 32 ∷ 12 ∷ 1 ∷ [])
{- 4.2 Merging -}
merge : (l m : List ℕ) → List ℕ
merge [] m = m
merge l [] = l
merge (x ∷ l) (y ∷ m) with x ≤? y
... | left x≤y = x ∷ (merge l (y ∷ m))
... | right y≤x = y ∷ (merge (x ∷ l) m)
{- 4.3 Sorting -}
{-# TERMINATING #-}
mergesort-v1 : List ℕ → List ℕ
mergesort-v1 [] = []
mergesort-v1 (x ∷ []) = x ∷ []
mergesort-v1 l =
let (l₁ , l₂) = split l in
merge (mergesort-v1 l₁) (mergesort-v1 l₂)
test-merge-v1 : List ℕ
test-merge-v1 = mergesort-v1 (4 ∷ 1 ∷ 45 ∷ 8 ∷ 32 ∷ 12 ∷ 1 ∷ [])
{- 4.4 Splitting is decreasing -}
data _<_ : ℕ → ℕ → Set where
s<s : {m n : ℕ} (m<n : suc m ≤ n) → m < n
length : {A : Set} (l : List A) → ℕ
length [] = zero
length (x ∷ l) = suc (length l)
test-length : ℕ
test-length = length (4 ∷ [])
{- Surprisingly we need this lemma to have a compact proof that splitting is decreasing -}
≤-to-suc : (m : ℕ) → m ≤ suc m
≤-to-suc zero = z≤n
≤-to-suc (suc m) = s≤s (≤-to-suc m)
{- Splitting is strictly decreasing only for lists with at least two elements
Another approach would be to add `2 ≤ length l` as an argument, but it
complicates the proof and Agda's pattern matching shows problematic behavior in that case
[see at the end] -}
<-split₁ : {A : Set} → (x y : A) → (l : List A)
→ length (fst (split (x ∷ y ∷ l))) < length (x ∷ y ∷ l)
<-split₁ x y [] = s<s (≤-refl 2)
<-split₁ x y (x₁ ∷ []) = s<s (s≤s (s≤s (≤-refl 1)))
<-split₁ x y (x₁ ∷ x₂ ∷ l) with <-split₁ x y l
... | s<s h = s<s (s≤s (s≤s (≤-trans (≤-to-suc (suc (length (fst (split l))))) h)))
<-split₂ : {A : Set} → (x y : A) → (l : List A)
→ length (snd (split (x ∷ y ∷ l))) < length (x ∷ y ∷ l)
<-split₂ x y [] = s<s (≤-refl 2)
<-split₂ x y (x₁ ∷ []) = s<s (s≤s (s≤s z≤n))
<-split₂ x y (x₁ ∷ x₂ ∷ l) with <-split₂ x y l
... | s<s h = s<s (s≤s (s≤s (≤-trans (≤-to-suc (suc (length (snd (split l))))) h)))
{- 4.5 The fuel definition of merge -}
{- Convenience function -}
<-to-≤ : {m n : ℕ} → m < n → suc m ≤ n
<-to-≤ (s<s m<n) = m<n
{- The key part of this definition is proving that the recursive calls are decreasing -}
mergesort-fuel : (n : ℕ) → (l : List ℕ) → (length l ≤ n) → List ℕ
mergesort-fuel n [] l≤n = []
mergesort-fuel n (x ∷ []) l≤n = x ∷ []
mergesort-fuel (suc n) (x ∷ y ∷ l) l≤n =
let (l₁ , l₂) = split (x ∷ y ∷ l) in
merge
(mergesort-fuel n l₁ (≤-trans (≤-pred (<-to-≤ (<-split₁ x y l))) (≤-pred l≤n)))
(mergesort-fuel n l₂ (≤-trans (≤-pred (<-to-≤ (<-split₂ x y l))) (≤-pred l≤n)))
mergesort : (l : List ℕ) → List ℕ
mergesort l = mergesort-fuel (length l) l (≤-refl (length l))
test-merge : List ℕ
test-merge = mergesort (4 ∷ 1 ∷ 45 ∷ 8 ∷ 32 ∷ 12 ∷ 1 ∷ [])
{- 4.6 Merge sort is sorting -}
{- Intrinsic approach: using the Sorted type -}
{- Step 1: merging two sorted lists produces a sorted list -}
mutual
merge' : (l m : Sorted) → Sorted
merge' nil m = m
merge' l nil = l
merge' (cons x l x≤l) (cons y m y≤m) with x ≤? y
... | left x≤y = cons x (merge' l (cons y m y≤m)) (merge-lemma x l (cons y m y≤m) x≤l x≤y)
... | right y≤x = cons y (merge' (cons x l x≤l) m) (merge-lemma y (cons x l x≤l) m y≤x y≤m)
{- Lemma: if x is a lower bound on both l and m, it's also a lower bound on the merged list -}
merge-lemma : (x : ℕ) → (l m : Sorted) → x ≤ head x l → x ≤ head x m
→ x ≤ head x (merge' l m)
merge-lemma x nil m x≤l x≤m = x≤m
merge-lemma x (cons y l y≤l) nil x≤l x≤m = x≤l
merge-lemma x (cons y l y≤l) (cons z m z≤m) x≤l x≤m with y ≤? z
... | left y≤z = x≤l
... | right z≤y = x≤m
{- Step 2: same-approach to mergesort-fuel -}
mergesort-fuel-v2 : (n : ℕ) → (l : List ℕ) → (length l ≤ n) → Sorted
mergesort-fuel-v2 _ [] _ = nil
mergesort-fuel-v2 _ (x ∷ []) _ = cons x nil (≤-refl x)
mergesort-fuel-v2 (suc n) (x ∷ y ∷ l) l≤n =
let (l₁ , l₂) = split (x ∷ y ∷ l) in
merge'
(mergesort-fuel-v2 n l₁ (≤-trans (≤-pred (<-to-≤ (<-split₁ x y l))) (≤-pred l≤n)))
(mergesort-fuel-v2 n l₂ (≤-trans (≤-pred (<-to-≤ (<-split₂ x y l))) (≤-pred l≤n)))
{- Step 3: mergesort-v3 comes to life -}
mergesort-v3 : List ℕ → Sorted
mergesort-v3 l = mergesort-fuel-v2 (length l) l (≤-refl (length l))
{- --- APPENDIX --- -}
{- Showcase: Agda's pattern matching forces us to consider a case where 2 ≤ 1 -}
<-split₁-x : {A : Set} → (l : List A) → 2 ≤ length l
→ length (fst (split l)) < length l
<-split₁-x (x ∷ []) (s≤s ())
<-split₁-x (x ∷ y ∷ l) 2≤l' with 2 ≤? length l
... | left 2≤l = s<s (s≤s (≤-trans (<-to-≤ (<-split₁-x l 2≤l)) (≤-to-suc (length l))))
... | right l≤2 = {!!} {- would need to refine l here -}
| {
"alphanum_fraction": 0.522420252,
"avg_line_length": 32.8694029851,
"ext": "agda",
"hexsha": "e812de867ec8ab087d9d8de304d7132d7e251a45",
"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": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "erwinkn/program-eq-proof",
"max_forks_repo_path": "TD7/Sort.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23",
"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": "erwinkn/program-eq-proof",
"max_issues_repo_path": "TD7/Sort.agda",
"max_line_length": 96,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "9a0d4a3f97103550a67e5e9ecbc8322bf0a8be23",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "erwinkn/program-eq-proof",
"max_stars_repo_path": "TD7/Sort.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3930,
"size": 8809
} |
record R : Set₁ where
X = Y -- should get error here
field A : Set
| {
"alphanum_fraction": 0.6164383562,
"avg_line_length": 14.6,
"ext": "agda",
"hexsha": "4fa0bf378f74d4dbefc0b2f1175bdbc858bd54d3",
"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/Issue783a.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/Issue783a.agda",
"max_line_length": 33,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Issue783a.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": 73
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Simple combinators working solely on and with functions
------------------------------------------------------------------------
-- The contents of this file can be accessed from `Function`.
{-# OPTIONS --without-K --safe #-}
module Function.Base where
open import Level
open import Strict
private
variable
a b c d e : Level
A : Set a
B : Set b
C : Set c
D : Set d
E : Set e
------------------------------------------------------------------------
-- Some simple functions
id : A → A
id x = x
const : A → B → A
const x = λ _ → x
------------------------------------------------------------------------
-- Operations on dependent functions
-- These are functions whose output has a type that depends on the
-- value of the input to the function.
infixr 9 _∘_
infixl 8 _ˢ_
infixl 0 _|>_
infix 0 case_return_of_
infixr -1 _$_ _$!_
-- Composition
_∘_ : ∀ {A : Set a} {B : A → Set b} {C : {x : A} → B x → Set c} →
(∀ {x} (y : B x) → C y) → (g : (x : A) → B x) →
((x : A) → C (g x))
f ∘ g = λ x → f (g x)
-- Flipping order of arguments
flip : ∀ {A : Set a} {B : Set b} {C : A → B → Set c} →
((x : A) (y : B) → C x y) → ((y : B) (x : A) → C x y)
flip f = λ y x → f x y
-- Application - note that _$_ is right associative, as in Haskell.
-- If you want a left associative infix application operator, use
-- Category.Functor._<$>_ from Category.Monad.Identity.IdentityMonad.
_$_ : ∀ {A : Set a} {B : A → Set b} →
((x : A) → B x) → ((x : A) → B x)
f $ x = f x
-- Strict (call-by-value) application
_$!_ : ∀ {A : Set a} {B : A → Set b} →
((x : A) → B x) → ((x : A) → B x)
_$!_ = flip force
-- Flipped application (aka pipe-forward)
_|>_ : ∀ {A : Set a} {B : A → Set b} →
(a : A) → (∀ a → B a) → B a
_|>_ = flip _$_
-- The S combinator - written infix as in Conor McBride's paper
-- "Outrageous but Meaningful Coincidences: Dependent type-safe syntax
-- and evaluation".
_ˢ_ : ∀ {A : Set a} {B : A → Set b} {C : (x : A) → B x → Set c} →
((x : A) (y : B x) → C x y) →
(g : (x : A) → B x) →
((x : A) → C x (g x))
f ˢ g = λ x → f x (g x)
-- Converting between implicit and explicit function spaces.
_$- : ∀ {A : Set a} {B : A → Set b} → ((x : A) → B x) → ({x : A} → B x)
f $- = f _
λ- : ∀ {A : Set a} {B : A → Set b} → ({x : A} → B x) → ((x : A) → B x)
λ- f = λ x → f
-- Case expressions (to be used with pattern-matching lambdas, see
-- README.Case).
case_return_of_ : ∀ {A : Set a} (x : A) (B : A → Set b) →
((x : A) → B x) → B x
case x return B of f = f x
------------------------------------------------------------------------
-- Non-dependent versions of dependent operations
-- Any of the above operations for dependent functions will also work
-- for non-dependent functions but sometimes Agda has difficulty
-- inferring the non-dependency. Primed (′ = \prime) versions of the
-- operations are therefore provided below that sometimes have better
-- inference properties.
infixr 9 _∘′_
infixl 0 _|>′_
infix 0 case_of_
infixr -1 _$′_ _$!′_
-- Composition
_∘′_ : (B → C) → (A → B) → (A → C)
f ∘′ g = _∘_ f g
-- Application
_$′_ : (A → B) → (A → B)
_$′_ = _$_
-- Strict (call-by-value) application
_$!′_ : (A → B) → (A → B)
_$!′_ = _$!_
-- Flipped application (aka pipe-forward)
_|>′_ : A → (A → B) → B
_|>′_ = _|>_
-- Case expressions (to be used with pattern-matching lambdas, see
-- README.Case).
case_of_ : A → (A → B) → B
case x of f = case x return _ of f
------------------------------------------------------------------------
-- Operations that are only defined for non-dependent functions
infixr 0 _-[_]-_
infixl 1 _on_
infixl 1 _⟨_⟩_
infixl 0 _∋_
-- Binary application
_⟨_⟩_ : A → (A → B → C) → B → C
x ⟨ f ⟩ y = f x y
-- Composition of a binary function with a unary function
_on_ : (B → B → C) → (A → B) → (A → A → C)
_*_ on f = λ x y → f x * f y
-- Composition of three binary functions
_-[_]-_ : (A → B → C) → (C → D → E) → (A → B → D) → (A → B → E)
f -[ _*_ ]- g = λ x y → f x y * g x y
-- In Agda you cannot annotate every subexpression with a type
-- signature. This function can be used instead.
_∋_ : (A : Set a) → A → A
A ∋ x = x
-- Conversely it is sometimes useful to be able to extract the
-- type of a given expression.
typeOf : {A : Set a} → A → Set a
typeOf {A = A} _ = A
-- Construct an element of the given type by instance search.
it : {A : Set a} → {{A}} → A
it {{x}} = x
| {
"alphanum_fraction": 0.5078947368,
"avg_line_length": 24.9180327869,
"ext": "agda",
"hexsha": "cd77ee5d48b7773d130484d3ce50571949fd0d54",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Function/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/Function/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/Function/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": 1507,
"size": 4560
} |
open import Relation.Binary.Core
module PLRTree.Insert {A : Set}
(_≤_ : A → A → Set)
(tot≤ : Total _≤_) where
open import Data.Sum
open import PLRTree {A}
insert : A → PLRTree → PLRTree
insert x leaf = node perfect x leaf leaf
insert x (node perfect y l r)
with tot≤ x y | l | r
... | inj₁ x≤y | leaf | leaf = node right x (node perfect y leaf leaf) leaf
... | inj₁ x≤y | _ | _ = node left x (insert y l) r
... | inj₂ y≤x | leaf | leaf = node right y (node perfect x leaf leaf) leaf
... | inj₂ y≤x | _ | _ = node left y (insert x l) r
insert x (node left y l r)
with tot≤ x y
... | inj₁ x≤y
with insert y l
... | node perfect y' l' r' = node right x (node perfect y' l' r') r
... | t = node left x t r
insert x (node left y l r) | inj₂ y≤x
with insert x l
... | node perfect y' l' r' = node right y (node perfect y' l' r') r
... | t = node left y t r
insert x (node right y l r)
with tot≤ x y
... | inj₁ x≤y
with insert y r
... | node perfect y' l' r' = node perfect x l (node perfect y' l' r')
... | t = node right x l t
insert x (node right y l r) | inj₂ y≤x
with insert x r
... | node perfect y' l' r' = node perfect y l (node perfect y' l' r')
... | t = node right y l t
| {
"alphanum_fraction": 0.5626477541,
"avg_line_length": 33.3947368421,
"ext": "agda",
"hexsha": "816020d8f10d47441a705fa093c5a9a9e530c624",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bgbianchi/sorting",
"max_forks_repo_path": "agda/PLRTree/Insert.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bgbianchi/sorting",
"max_issues_repo_path": "agda/PLRTree/Insert.agda",
"max_line_length": 75,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b8d428bccbdd1b13613e8f6ead6c81a8f9298399",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bgbianchi/sorting",
"max_stars_repo_path": "agda/PLRTree/Insert.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": 445,
"size": 1269
} |
open import Common.Prelude
open import Common.Equality
infixr 5 _∷_
data Vec (A : Set) : Nat → Set where
[] : Vec A zero
_∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)
record Eq (A : Set) : Set where
field
_==_ : (x y : A) → Maybe (x ≡ y)
open Eq {{...}}
data Σ (A : Set) (B : A → Set) : Set where
_,_ : (x : A) → B x → Σ A B
eqNat : ∀ n m → Maybe (n ≡ m)
eqNat zero zero = just refl
eqNat zero (suc m) = nothing
eqNat (suc n) zero = nothing
eqNat (suc n) (suc m) with eqNat n m
eqNat (suc n) (suc m) | nothing = nothing
eqNat (suc n) (suc .n) | just refl = just refl
eqVec : ∀ {A n} {{EqA : Eq A}} (xs ys : Vec A n) → Maybe (xs ≡ ys)
eqVec [] [] = just refl
eqVec (x ∷ xs) ( y ∷ ys) with x == y | eqVec xs ys
eqVec (x ∷ xs) ( y ∷ ys) | nothing | _ = nothing
eqVec (x ∷ xs) ( y ∷ ys) | _ | nothing = nothing
eqVec (x ∷ xs) (.x ∷ .xs) | just refl | just refl = just refl
eqSigma : ∀ {A B} {{EqA : Eq A}} {{EqB : ∀ {x} → Eq (B x)}} (x y : Σ A B) → Maybe (x ≡ y)
eqSigma (x , y) (x₁ , y₁) with x == x₁
eqSigma (x , y) (x₁ , y₁) | nothing = nothing
eqSigma (x , y) (.x , y₁) | just refl with y == y₁
eqSigma (x , y) (.x , y₁) | just refl | nothing = nothing
eqSigma (x , y) (.x , .y) | just refl | just refl = just refl
instance
EqNat : Eq Nat
EqNat = record { _==_ = eqNat }
EqVec : ∀ {A n} {{_ : Eq A}} → Eq (Vec A n)
EqVec = record { _==_ = eqVec }
EqSigma : ∀ {A B} {{_ : Eq A}} {{_ : ∀ {x} → Eq (B x)}} → Eq (Σ A B)
EqSigma = record { _==_ = eqSigma }
cmpSigma : (xs ys : Σ Nat (Vec Nat)) → Maybe (xs ≡ ys)
cmpSigma xs ys = xs == ys
| {
"alphanum_fraction": 0.519675203,
"avg_line_length": 29.6481481481,
"ext": "agda",
"hexsha": "e099c6ebd303784b5c639810b8160d4b6e570e14",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "test/Succeed/DependentInstanceSearch.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "redfish64/autonomic-agda",
"max_issues_repo_path": "test/Succeed/DependentInstanceSearch.agda",
"max_line_length": 89,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/Succeed/DependentInstanceSearch.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": 669,
"size": 1601
} |
-- Quotient category
{-# OPTIONS --safe #-}
module Cubical.Categories.Constructions.Quotient where
open import Cubical.Categories.Category.Base
open import Cubical.Categories.Functor.Base
open import Cubical.Categories.Limits.Terminal
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Prelude
open import Cubical.HITs.SetQuotients renaming ([_] to ⟦_⟧)
private
variable
ℓ ℓ' ℓq : Level
module _ (C : Category ℓ ℓ') where
open Category C
module _ (_~_ : {x y : ob} (f g : Hom[ x , y ] ) → Type ℓq)
(~refl : {x y : ob} (f : Hom[ x , y ] ) → f ~ f)
(~cong : {x y z : ob}
(f f' : Hom[ x , y ]) → f ~ f'
→ (g g' : Hom[ y , z ]) → g ~ g'
→ (f ⋆ g) ~ (f' ⋆ g')) where
private
Hom[_,_]/~ = λ (x y : ob) → Hom[ x , y ] / _~_
module _ {x y z : ob} where
_⋆/~_ : Hom[ x , y ]/~ → Hom[ y , z ]/~ → Hom[ x , z ]/~
_⋆/~_ = rec2 squash/ (λ f g → ⟦ f ⋆ g ⟧)
(λ f f' g f~f' → eq/ _ _ (~cong _ _ f~f' _ _ (~refl _)))
(λ f g g' g~g' → eq/ _ _ (~cong _ _ (~refl _) _ _ g~g'))
module _ {x y : ob} where
⋆/~IdL : (f : Hom[ x , y ]/~) → (⟦ id ⟧ ⋆/~ f) ≡ f
⋆/~IdL = elimProp (λ _ → squash/ _ _) (λ _ → cong ⟦_⟧ (⋆IdL _))
⋆/~IdR : (f : Hom[ x , y ]/~) → (f ⋆/~ ⟦ id ⟧) ≡ f
⋆/~IdR = elimProp (λ _ → squash/ _ _) (λ _ → cong ⟦_⟧ (⋆IdR _))
module _ {x y z w : ob} where
⋆/~Assoc : (f : Hom[ x , y ]/~)
(g : Hom[ y , z ]/~)
(h : Hom[ z , w ]/~)
→ ((f ⋆/~ g) ⋆/~ h) ≡ (f ⋆/~ (g ⋆/~ h))
⋆/~Assoc = elimProp3 (λ _ _ _ → squash/ _ _) (λ _ _ _ → cong ⟦_⟧ (⋆Assoc _ _ _))
open Category
QuotientCategory : Category ℓ (ℓ-max ℓ' ℓq)
QuotientCategory .ob = ob C
QuotientCategory .Hom[_,_] x y = (C [ x , y ]) / _~_
QuotientCategory .id = ⟦ id C ⟧
QuotientCategory ._⋆_ = _⋆/~_
QuotientCategory .⋆IdL = ⋆/~IdL
QuotientCategory .⋆IdR = ⋆/~IdR
QuotientCategory .⋆Assoc = ⋆/~Assoc
QuotientCategory .isSetHom = squash/
private
C/~ = QuotientCategory
-- Quotient map
open Functor
QuoFunctor : Functor C C/~
QuoFunctor .F-ob x = x
QuoFunctor .F-hom = ⟦_⟧
QuoFunctor .F-id = refl
QuoFunctor .F-seq f g = refl
-- Quotients preserve initial / terminal objects
isInitial/~ : {z : ob C} → isInitial C z → isInitial C/~ z
isInitial/~ zInit x = ⟦ zInit x .fst ⟧ , elimProp (λ _ → squash/ _ _)
λ f → eq/ _ _ (subst (_~ f) (sym (zInit x .snd f)) (~refl _))
isFinal/~ : {z : ob C} → isFinal C z → isFinal C/~ z
isFinal/~ zFinal x = ⟦ zFinal x .fst ⟧ , elimProp (λ _ → squash/ _ _)
λ f → eq/ _ _ (subst (_~ f) (sym (zFinal x .snd f)) (~refl _))
| {
"alphanum_fraction": 0.4967695621,
"avg_line_length": 33.5662650602,
"ext": "agda",
"hexsha": "82b0c2d8524c45d629af0cee654abf407263da27",
"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": "7b41b9171f90473efc98487cb2ea7a4d02320cb2",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "barrettj12/cubical",
"max_forks_repo_path": "Cubical/Categories/Constructions/Quotient.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7b41b9171f90473efc98487cb2ea7a4d02320cb2",
"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": "barrettj12/cubical",
"max_issues_repo_path": "Cubical/Categories/Constructions/Quotient.agda",
"max_line_length": 86,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "7b41b9171f90473efc98487cb2ea7a4d02320cb2",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "barrettj12/cubical",
"max_stars_repo_path": "Cubical/Categories/Constructions/Quotient.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1114,
"size": 2786
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Foundations.Pointed.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed.Base
open import Cubical.Foundations.Function
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.Sigma
private
variable
ℓ ℓ' ℓA ℓB ℓC ℓD : Level
-- the default pointed Π-type: A is pointed, and B has a base point in the chosen fiber
Π∙ : (A : Pointed ℓ) (B : typ A → Type ℓ') (ptB : B (pt A)) → Type (ℓ-max ℓ ℓ')
Π∙ A B ptB = Σ[ f ∈ ((a : typ A) → B a) ] f (pt A) ≡ ptB
-- the unpointed Π-type becomes a pointed type if the fibers are all pointed
Πᵘ∙ : (A : Type ℓ) (B : A → Pointed ℓ') → Pointed (ℓ-max ℓ ℓ')
Πᵘ∙ A B .fst = ∀ a → typ (B a)
Πᵘ∙ A B .snd a = pt (B a)
-- if the base and all fibers are pointed, we have the pointed pointed Π-type
Πᵖ∙ : (A : Pointed ℓ) (B : typ A → Pointed ℓ') → Pointed (ℓ-max ℓ ℓ')
Πᵖ∙ A B .fst = Π∙ A (typ ∘ B) (pt (B (pt A)))
Πᵖ∙ A B .snd .fst a = pt (B a)
Πᵖ∙ A B .snd .snd = refl
-- the default pointed Σ-type is just the Σ-type, but as a pointed type
Σ∙ : (A : Pointed ℓ) (B : typ A → Type ℓ') (ptB : B (pt A)) → Pointed (ℓ-max ℓ ℓ')
Σ∙ A B ptB .fst = Σ[ a ∈ typ A ] B a
Σ∙ A B ptB .snd .fst = pt A
Σ∙ A B ptB .snd .snd = ptB
-- version if B is a family of pointed types
Σᵖ∙ : (A : Pointed ℓ) (B : typ A → Pointed ℓ') → Pointed (ℓ-max ℓ ℓ')
Σᵖ∙ A B = Σ∙ A (typ ∘ B) (pt (B (pt A)))
_×∙_ : (A∙ : Pointed ℓ) (B∙ : Pointed ℓ') → Pointed (ℓ-max ℓ ℓ')
(A∙ ×∙ B∙) .fst = (typ A∙) × (typ B∙)
(A∙ ×∙ B∙) .snd .fst = pt A∙
(A∙ ×∙ B∙) .snd .snd = pt B∙
-- composition of pointed maps
_∘∙_ : {A : Pointed ℓA} {B : Pointed ℓB} {C : Pointed ℓC}
(g : B →∙ C) (f : A →∙ B) → (A →∙ C)
((g , g∙) ∘∙ (f , f∙)) .fst x = g (f x)
((g , g∙) ∘∙ (f , f∙)) .snd = (cong g f∙) ∙ g∙
-- pointed identity
id∙ : (A : Pointed ℓA) → (A →∙ A)
id∙ A .fst x = x
id∙ A .snd = refl
-- constant pointed map
const∙ : (A : Pointed ℓA) (B : Pointed ℓB) → (A →∙ B)
const∙ _ B .fst _ = B .snd
const∙ _ B .snd = refl
-- left identity law for pointed maps
∘∙-idˡ : {A : Pointed ℓA} {B : Pointed ℓB} (f : A →∙ B) → f ∘∙ id∙ A ≡ f
∘∙-idˡ f = ΣPathP ( refl , (lUnit (f .snd)) ⁻¹ )
-- right identity law for pointed maps
∘∙-idʳ : {A : Pointed ℓA} {B : Pointed ℓB} (f : A →∙ B) → id∙ B ∘∙ f ≡ f
∘∙-idʳ f = ΣPathP ( refl , (rUnit (f .snd)) ⁻¹ )
-- associativity for composition of pointed maps
∘∙-assoc : {A : Pointed ℓA} {B : Pointed ℓB} {C : Pointed ℓC} {D : Pointed ℓD}
(h : C →∙ D) (g : B →∙ C) (f : A →∙ B)
→ (h ∘∙ g) ∘∙ f ≡ h ∘∙ (g ∘∙ f)
∘∙-assoc (h , h∙) (g , g∙) (f , f∙) = ΣPathP (refl , q)
where
q : (cong (h ∘ g) f∙) ∙ (cong h g∙ ∙ h∙) ≡ cong h (cong g f∙ ∙ g∙) ∙ h∙
q = ( (cong (h ∘ g) f∙) ∙ (cong h g∙ ∙ h∙)
≡⟨ refl ⟩
(cong h (cong g f∙)) ∙ (cong h g∙ ∙ h∙)
≡⟨ assoc (cong h (cong g f∙)) (cong h g∙) h∙ ⟩
(cong h (cong g f∙) ∙ cong h g∙) ∙ h∙
≡⟨ cong (λ p → p ∙ h∙) ((cong-∙ h (cong g f∙) g∙) ⁻¹) ⟩
(cong h (cong g f∙ ∙ g∙) ∙ h∙) ∎ )
| {
"alphanum_fraction": 0.5325137496,
"avg_line_length": 36.7976190476,
"ext": "agda",
"hexsha": "6cd19b915ea423117c132735a1879d8528d2e85b",
"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": "60226aacd7b386aef95d43a0c29c4eec996348a8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "L-TChen/cubical",
"max_forks_repo_path": "Cubical/Foundations/Pointed/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "60226aacd7b386aef95d43a0c29c4eec996348a8",
"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": "L-TChen/cubical",
"max_issues_repo_path": "Cubical/Foundations/Pointed/Properties.agda",
"max_line_length": 87,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "60226aacd7b386aef95d43a0c29c4eec996348a8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "L-TChen/cubical",
"max_stars_repo_path": "Cubical/Foundations/Pointed/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1544,
"size": 3091
} |
{-# OPTIONS --safe #-}
module Definition.Typed.EqRelInstance where
open import Definition.Untyped
open import Definition.Typed
open import Definition.Typed.Properties
open import Definition.Typed.Weakening
open import Definition.Typed.Properties
open import Definition.Typed.Reduction
open import Definition.Typed.EqualityRelation
open import Tools.Function
Urefl : ∀ {r l Γ} → ⊢ Γ → Γ ⊢ (Univ r l) ≡ (Univ r l) ^ [ ! , next l ]
Urefl {l = ⁰} ⊢Γ = refl (univ (univ 0<1 ⊢Γ))
Urefl {l = ¹} ⊢Γ = refl (Uⱼ ⊢Γ)
instance eqRelInstance : EqRelSet
eqRelInstance = eqRel _⊢_≡_^_ _⊢_≡_∷_^_ _⊢_≡_∷_^_
idᶠ idᶠ idᶠ univ un-univ≡
sym genSym genSym trans genTrans genTrans
conv conv wkEq wkEqTerm wkEqTerm
reduction reductionₜ
Urefl (refl ∘ᶠ univ 0<1) (refl ∘ᶠ ℕⱼ) (refl ∘ᶠ Emptyⱼ)
Π-cong ∃-cong (refl ∘ᶠ zeroⱼ) suc-cong
(λ lF lG x x₁ x₂ x₃ x₄ x₅ → η-eq lF lG x x₁ x₂ x₅)
genVar app-cong natrec-cong Emptyrec-cong
Id-cong
(λ ⊢Γ → Id-cong (refl (ℕⱼ ⊢Γ)))
(λ ⊢Γ → Id-cong (refl (ℕⱼ ⊢Γ)) (refl (zeroⱼ ⊢Γ)))
(λ ⊢Γ t → Id-cong (refl (ℕⱼ ⊢Γ)) (suc-cong t))
(λ ⊢Γ → Id-cong (refl (univ 0<1 ⊢Γ)))
(λ ⊢Γ → Id-cong (refl (univ 0<1 ⊢Γ)) (refl (ℕⱼ ⊢Γ)))
(λ ⊢A B → Id-cong (refl (univ 0<1 (wfEq (univ ⊢A)))) ⊢A B)
cast-cong
(λ ⊢Γ → cast-cong (refl (ℕⱼ ⊢Γ)))
(λ ⊢Γ → cast-cong (refl (ℕⱼ ⊢Γ)) (refl (ℕⱼ ⊢Γ)))
cast-cong
(λ ⊢A ⊢P P → cast-cong (refl (ℕⱼ (wf (univ ⊢A)))) P)
(λ ⊢A ⊢P P → cast-cong P (refl (ℕⱼ (wf (univ ⊢A)))))
(λ ⊢A ⊢P P ⊢A' ⊢P' P' → cast-cong P P')
(λ ⊢A ⊢P P ⊢A' ⊢P' P' → cast-cong P P')
proof-irrelevance
| {
"alphanum_fraction": 0.4736323312,
"avg_line_length": 45.0888888889,
"ext": "agda",
"hexsha": "1d8a07eba8b2e69f7fc305589a6001685beb4462",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2022-02-15T19:42:19.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-01-26T14:55:51.000Z",
"max_forks_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "CoqHott/logrel-mltt",
"max_forks_repo_path": "Definition/Typed/EqRelInstance.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "CoqHott/logrel-mltt",
"max_issues_repo_path": "Definition/Typed/EqRelInstance.agda",
"max_line_length": 81,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "CoqHott/logrel-mltt",
"max_stars_repo_path": "Definition/Typed/EqRelInstance.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-17T16:13:53.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-06-21T08:39:01.000Z",
"num_tokens": 792,
"size": 2029
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Abstract.Types
open import LibraBFT.Abstract.Types.EpochConfig
open import Util.Lemmas
open import Util.Prelude
open WithAbsVote
-- For each desired property (VotesOnce and PreferredRoundRule), we have a
-- module containing a Type that defines a property that an implementation
-- should prove, and a proof that it implies the corresponding rule used by
-- the abstract proofs. Then, we use those proofs to instantiate thmS5,
-- and the use thmS5 to prove a number of correctness conditions.
--
-- TODO-1: refactor this file to separate the definitions and proofs of
-- VotesOnce and PreferredRoundRule from their use in proving the correctness
-- properties.
module LibraBFT.Abstract.Properties
(UID : Set)
(_≟UID_ : (u₀ u₁ : UID) → Dec (u₀ ≡ u₁))
(NodeId : Set)
(𝓔 : EpochConfig UID NodeId)
(𝓥 : VoteEvidence UID NodeId 𝓔)
where
open import LibraBFT.Abstract.Records UID _≟UID_ NodeId 𝓔 𝓥
open import LibraBFT.Abstract.Records.Extends UID _≟UID_ NodeId 𝓔 𝓥
open import LibraBFT.Abstract.RecordChain UID _≟UID_ NodeId 𝓔 𝓥
open import LibraBFT.Abstract.RecordChain.Assumptions UID _≟UID_ NodeId 𝓔 𝓥
open import LibraBFT.Abstract.System UID _≟UID_ NodeId 𝓔 𝓥
open import LibraBFT.Abstract.RecordChain.Properties UID _≟UID_ NodeId 𝓔 𝓥
open EpochConfig 𝓔
module WithAssumptions {ℓ}
(InSys : Record → Set ℓ)
(no-collisions-InSys : NoCollisions InSys)
(votes-once : VotesOnlyOnceRule InSys)
(preferred-round : PreferredRoundRule InSys)
where
open All-InSys-props InSys
CommitsDoNotConflict : ∀{q q'}
→ {rc : RecordChain (Q q)} → All-InSys rc
→ {rc' : RecordChain (Q q')} → All-InSys rc'
→ {b b' : Block}
→ CommitRule rc b
→ CommitRule rc' b'
→ (B b) ∈RC rc' ⊎ (B b') ∈RC rc
CommitsDoNotConflict ais ais' cr cr'
with WithInvariants.thmS5 InSys votes-once preferred-round ais ais' cr cr'
-- We use the implementation-provided evidence that Block ids are injective among
-- Block actually in the system to dismiss the first possibility
...| inj₁ ((_ , neq , h≡) , (is1 , is2)) = ⊥-elim (neq (no-collisions-InSys is1 is2 h≡))
...| inj₂ corr = corr
-- When we are dealing with a /Complete/ InSys predicate, we can go a few steps
-- further and prove that commits do not conflict even if we have only partial
-- knowledge about Records represented in the system.
module _ (∈QC⇒AllSent : Complete InSys) where
-- For a /complete/ system (i.e., one in which peers vote for a Block only if
-- they know of a RecordChain up to that Block whose Records are all InSys), we
-- can prove that CommitRules based on RecordChainFroms similarly do not
-- conflict, provided all of the Records in the RecordChainFroms are InSys.
-- This enables peers not participating in consensus to confirm commits even if
-- they are sent only a "commit certificate" that contains enough of a
-- RecordChain to confirm the CommitRule. Note that it is this "sending" that
-- justfies the assumption that the RecordChainFroms on which the CommitRules
-- are based are All-InSys.
CommitsDoNotConflict'
: ∀{o o' q q'}
→ {rcf : RecordChainFrom o (Q q)} → All-InSys rcf
→ {rcf' : RecordChainFrom o' (Q q')} → All-InSys rcf'
→ {b b' : Block}
→ CommitRuleFrom rcf b
→ CommitRuleFrom rcf' b'
→ Σ (RecordChain (Q q')) ((B b) ∈RC_)
⊎ Σ (RecordChain (Q q)) ((B b') ∈RC_)
CommitsDoNotConflict' {cb} {q = q} {q'} {rcf} rcfAll∈sys {rcf'} rcf'All∈sys crf crf'
with bft-property (qVotes-C1 q) (qVotes-C1 q')
...| α , α∈qmem , α∈q'mem , hα
with Any-sym (Any-map⁻ α∈qmem) | Any-sym (Any-map⁻ α∈q'mem)
...| α∈q | α∈q'
with ∈QC⇒AllSent {q = q} hα α∈q (rcfAll∈sys here) | ∈QC⇒AllSent {q = q'} hα α∈q' (rcf'All∈sys here)
...| ab , (arc , ais) , ab←q | ab' , (arc' , ais') , ab←q'
with crf⇒cr rcf (step arc ab←q) crf | crf⇒cr rcf' (step arc' ab←q') crf'
...| inj₁ ((_ , neq , h≡) , (is1 , is2)) | _ = ⊥-elim (neq (no-collisions-InSys (rcfAll∈sys is1) (ais (∈RC-simple-¬here arc ab←q (λ ()) is2)) h≡))
...| inj₂ _ | inj₁ ((_ , neq , h≡) , (is1 , is2)) = ⊥-elim (neq (no-collisions-InSys (rcf'All∈sys is1) (ais' (∈RC-simple-¬here arc' ab←q' (λ ()) is2)) h≡))
...| inj₂ cr | inj₂ cr'
with CommitsDoNotConflict (All-InSys-step ais ab←q (rcfAll∈sys here)) (All-InSys-step ais' ab←q' (rcf'All∈sys here)) cr cr'
...| inj₁ b∈arc' = inj₁ (step arc' ab←q' , b∈arc')
...| inj₂ b'∈arc = inj₂ (step arc ab←q , b'∈arc)
| {
"alphanum_fraction": 0.6428140704,
"avg_line_length": 50.2525252525,
"ext": "agda",
"hexsha": "292920876b47a7cb25264c5352c144eb479d19ee",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_forks_repo_path": "src/LibraBFT/Abstract/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_issues_repo_path": "src/LibraBFT/Abstract/Properties.agda",
"max_line_length": 174,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_stars_repo_path": "src/LibraBFT/Abstract/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1639,
"size": 4975
} |
module Data.List.First.Properties {ℓ}{A : Set ℓ} where
open import Data.Product
open import Data.List
open import Data.List.Any
open import Relation.Binary.PropositionalEquality
open import Function
open import Data.Empty
open import Data.List.First
open import Data.List.Membership.Propositional
first⟶∈ : ∀ {B : A → Set} {x l} → First B x l → (x ∈ l × B x)
first⟶∈ (here {x = x} p) = here refl , p
first⟶∈ (there x' ¬px f) with (first⟶∈ f)
first⟶∈ (there x' ¬px f) | x∈l , p = there x∈l , p
first-unique : ∀ {P : A → Set}{x y v} → First P x v → First P y v → x ≡ y
first-unique (here x) (here y) = refl
first-unique (here {x = x} px) (there .x ¬px r) = ⊥-elim (¬px px)
first-unique (there x ¬px l) (here {x = .x} px) = ⊥-elim (¬px px)
first-unique (there x' _ l) (there .x' _ r) = first-unique l r
| {
"alphanum_fraction": 0.6400996264,
"avg_line_length": 36.5,
"ext": "agda",
"hexsha": "cf04cce1e0d6821b487b102225c4fb2320e8e8c8",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-12-28T17:38:05.000Z",
"max_forks_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "metaborg/mj.agda",
"max_forks_repo_path": "src/Data/List/First/Properties.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_issues_repo_issues_event_max_datetime": "2020-10-14T13:41:58.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-13T13:03:47.000Z",
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "metaborg/mj.agda",
"max_issues_repo_path": "src/Data/List/First/Properties.agda",
"max_line_length": 73,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "0c096fea1716d714db0ff204ef2a9450b7a816df",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "metaborg/mj.agda",
"max_stars_repo_path": "src/Data/List/First/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-24T08:02:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-11-17T17:10:36.000Z",
"num_tokens": 301,
"size": 803
} |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
module Categories.Category.Construction.Spans {o ℓ e} (𝒞 : Category o ℓ e) where
open import Level
open import Categories.Category.Diagram.Span 𝒞
open import Categories.Morphism.Reasoning 𝒞
open Category 𝒞
open HomReasoning
open Equiv
open Span
open Span⇒
Spans : Obj → Obj → Category (o ⊔ ℓ) (o ⊔ ℓ ⊔ e) e
Spans X Y = record
{ Obj = Span X Y
; _⇒_ = Span⇒
; _≈_ = λ f g → arr f ≈ arr g
; id = id-span⇒
; _∘_ = _∘ₛ_
; assoc = assoc
; sym-assoc = sym-assoc
; identityˡ = identityˡ
; identityʳ = identityʳ
; identity² = identity²
; equiv = record
{ refl = refl
; sym = sym
; trans = trans
}
; ∘-resp-≈ = ∘-resp-≈
}
| {
"alphanum_fraction": 0.6260273973,
"avg_line_length": 18.7179487179,
"ext": "agda",
"hexsha": "f986671266897c40901ef01e1843bb536fbf231f",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Construction/Spans.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Construction/Spans.agda",
"max_line_length": 80,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Construction/Spans.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": 276,
"size": 730
} |
{- Definition of join for ◇ and associated lemmas. -}
module TemporalOps.Diamond.JoinLemmas where
open import CategoryTheory.Categories
open import CategoryTheory.Instances.Reactive
open import CategoryTheory.Functor
open import CategoryTheory.NatTrans
open import CategoryTheory.Monad
open import TemporalOps.Common
open import TemporalOps.Next
open import TemporalOps.Delay
open import TemporalOps.Diamond.Functor
open import TemporalOps.Diamond.Join
import Relation.Binary.PropositionalEquality as ≡
open import Data.Product
open import Relation.Binary.HeterogeneousEquality as ≅
using (_≅_ ; ≅-to-≡ ; ≡-to-≅ ; cong₂)
open import Data.Nat.Properties
using (+-identityʳ ; +-comm ; +-suc ; +-assoc)
open import Holes.Term using (⌞_⌟)
open import Holes.Cong.Propositional
-- | Auxiliary lemmas
-- Equality of two delayed values
◇-≅ : ∀{A : τ}{n n′ k k′ : ℕ}
-> {v : delay A by k at n} {v′ : delay A by k′ at n′}
-> (pk : k ≡ k′) (pn : n ≡ n′)
-> v ≅ v′
-> _≅_ {A = ◇ A at n} (k , v)
{B = ◇ A at n′} (k′ , v′)
◇-≅ refl refl ≅.refl = ≅.refl
-- | Lemmas involving μ
-- Two consecutive shifts can be composed
μ-shift-comp : ∀{A} {n k l : ℕ} {a : ◇ A at n}
-> μ-shift l (k + n) (μ-shift {A} k n a)
≅ μ-shift {A} (l + k) n a
μ-shift-comp {A} {n} {k} {l} {j , v} =
begin
μ-shift l (k + n) (μ-shift k n (j , v))
≡⟨⟩
μ-shift l (k + n) (k + j , v′)
≡⟨⟩
l + (k + j) , rew (sym (delay-+ l (k + j) (k + n))) v′
≅⟨ ◇-≅ (sym (+-assoc l k j)) ((sym (+-assoc l k n))) pr ⟩
(l + k) + j , rew (sym (delay-+ (l + k) j n)) v
≡⟨⟩
μ-shift (l + k) n (j , v)
∎
where
open ≅.≅-Reasoning
v′ : delay A by (k + j) at (k + n)
v′ = rew (sym (delay-+ k j n)) v
v≅v′ : v ≅ v′
v≅v′ = rew-to-≅ (sym (delay-+ k j n))
pr : rew (sym (delay-+ l (k + j) (k + n))) v′
≅ rew (sym (delay-+ (l + k) j n)) v
pr = delay-assoc-sym l k j n v′ v (≅.sym v≅v′)
private module μ = _⟹_ μ-◇
open ≅.≅-Reasoning
-- Shift and multiplication can be interchanged
μ-interchange : ∀{A}{n k : ℕ}{a : ◇ ◇ A at n}
-> μ.at A (k + n) (μ-shift k n a)
≅ μ-shift k n (μ.at A n a)
μ-interchange {A} {n} {k} {l , y} with inspect (compareLeq l n)
μ-interchange {A} {.(l + m)} {k} {l , v} | snd==[ .l + m ] with≡ pf =
begin
μ.at A (k + (l + m)) (μ-shift k (l + m) (l , v))
≡⟨⟩
μ.at A (k + (l + m)) (k + l , rew (sym (delay-+ k l (l + m))) v)
≡⟨⟩
μ-compare A (k + (l + m)) (k + l) v′ (compareLeq (k + l) (k + (l + m)))
≅⟨
≅-cong₃ (λ x y z → μ-compare A x (k + l) y z)
(≡-to-≅ (sym (+-assoc k l m))) v′≅v″ (compare-snd-+-assoc l m k pf)
⟩
μ-compare A ((k + l) + m) (k + l) v″ (snd==[ (k + l) + m ])
≡⟨⟩
μ-shift (k + l) m ⌞ rew (delay-+-left0 (k + l) m) v″ ⌟
≡⟨ cong! (pr k l m v″ v v″≅v) ⟩
μ-shift (k + l) m (rew (delay-+-left0 l m) v)
≅⟨ ≅.sym ( μ-shift-comp {A} {m} {l} {k} {(rew (delay-+-left0 l m) v)} ) ⟩
μ-shift k (l + m) (μ-shift l m (rew (delay-+-left0 l m) v))
≡⟨⟩
μ-shift k (l + m) (μ-compare A (l + m) l v ⌞ snd==[ l + m ] ⌟)
≡⟨ cong! (sym pf) ⟩
μ-shift k (l + m) (μ-compare A (l + m) l v (compareLeq l (l + m)))
≡⟨⟩
μ-shift k (l + m) (μ.at A (l + m) (l , v))
∎
where
v′ : delay ◇ A by (k + l) at (k + (l + m))
v′ = rew (sym (delay-+ k l (l + m))) v
v≅v′ : v ≅ v′
v≅v′ = rew-to-≅ (sym (delay-+ k l (l + m)))
lemma-assoc : ∀{A : τ} -> (a b c : ℕ)
-> delay ◇ A by (a + b) at (a + (b + c))
≡ delay ◇ A by (a + b) at ((a + b) + c)
lemma-assoc a b c rewrite sym (+-assoc a b c) = refl
v″ : delay ◇ A by (k + l) at ((k + l) + m)
v″ = (rew (lemma-assoc k l m) v′)
v′≅v″ : v′ ≅ v″
v′≅v″ = rew-to-≅ (lemma-assoc k l m)
v″≅v : v″ ≅ v
v″≅v = ≅.trans (≅.sym v′≅v″) (≅.sym v≅v′)
pr : ∀{A} (k l m : ℕ) -> Proof-≡ (delay-+-left0 {A} (k + l) m)
(delay-+-left0 {A} l m)
pr zero l m v .v ≅.refl = refl
pr (suc k) l m = pr k l m
-- l = n + suc j
μ-interchange {A} {.n} {k} {.(n + suc l) , v} | fst==suc[ n + l ] with≡ pf =
begin
μ.at A (k + n) (μ-shift k n (n + suc l , v))
≡⟨⟩
μ.at A (k + n) (k + (n + suc l) , rew (sym (delay-+ k (n + suc l) n)) v)
≡⟨⟩
μ-compare A (k + n) (k + (n + suc l)) v′ (compareLeq (k + (n + suc l)) (k + n))
≅⟨ ≅-cong₃ ((λ x y z → μ-compare A (k + n) x y z))
(≡-to-≅ (sym (+-assoc k n (suc l)))) v′≅v″ (compare-fst-+-assoc n l k pf) ⟩
μ-compare A (k + n) ((k + n) + suc l) v″ fst==suc[ (k + n) + l ]
≡⟨⟩
(k + n) + suc l , rew (delay-⊤ (k + n) l) top.tt
≅⟨ ◇-≅ (+-assoc k n (suc l)) refl (pr n k l) ⟩
k + (n + suc l) , rew (sym (delay-+ k (n + suc l) n)) (rew (delay-⊤ n l) top.tt)
≡⟨⟩
μ-shift k n (n + suc l , rew (delay-⊤ n l) top.tt)
≡⟨⟩
μ-shift k n (μ-compare A n (n + suc l) v ⌞ fst==suc[ n + l ] ⌟)
≡⟨ cong! (sym pf) ⟩
μ-shift k n (μ-compare A n (n + suc l) v (compareLeq (n + suc l) n))
≡⟨⟩
μ-shift k n (μ.at A n (n + suc l , v))
∎
where
v′ : delay ◇ A by (k + (n + suc l)) at (k + n)
v′ = (rew (sym (delay-+ k (n + suc l) n)) v)
lemma-assoc : ∀{A : τ} -> (a b c : ℕ)
-> delay ◇ A by (a + (b + c)) at (a + b)
≡ delay ◇ A by ((a + b) + c) at (a + b)
lemma-assoc {A} a b c rewrite sym (+-assoc a b c) = refl
v″ : delay ◇ A by ((k + n) + suc l) at (k + n)
v″ = (rew (lemma-assoc k n (suc l)) v′)
v′≅v″ : v′ ≅ v″
v′≅v″ = rew-to-≅ (lemma-assoc k n (suc l))
pr : ∀{A} (n k l : ℕ)
-> rew (delay-⊤ {A} (k + n) l) top.tt
≅ rew (sym (delay-+ {A} k (n + suc l) n)) (rew (delay-⊤ n l) top.tt)
pr n zero l = ≅.refl
pr n (suc k) l = pr n k l
| {
"alphanum_fraction": 0.448322374,
"avg_line_length": 37.5379746835,
"ext": "agda",
"hexsha": "8d71ed018919d6e7f85f82fcc2c153126f1e6964",
"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": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DimaSamoz/temporal-type-systems",
"max_forks_repo_path": "src/TemporalOps/Diamond/JoinLemmas.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"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": "DimaSamoz/temporal-type-systems",
"max_issues_repo_path": "src/TemporalOps/Diamond/JoinLemmas.agda",
"max_line_length": 88,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "7d993ba55e502d5ef8707ca216519012121a08dd",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DimaSamoz/temporal-type-systems",
"max_stars_repo_path": "src/TemporalOps/Diamond/JoinLemmas.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-04T09:33:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-05-31T20:37:04.000Z",
"num_tokens": 2607,
"size": 5931
} |
{-# OPTIONS --omega-in-omega --no-termination-check --overlapping-instances #-}
module Light.Subtyping where
open import Light.Level using (_⊔_ ; ++_)
open import Light.Variable.Levels
open import Light.Variable.Sets
record DirectSubtyping (𝕒 : Set aℓ) (𝕓 : Set bℓ) : Set (aℓ ⊔ bℓ) where
constructor #_
field cast₁ : 𝕒 → 𝕓
open DirectSubtyping ⦃ ... ⦄ public
record StrictSubtyping (𝕒 : Set aℓ) (𝕓 : Set aℓ) : Set (++ aℓ)
data Subtyping {aℓ} : ∀ (𝕒 : Set aℓ) (𝕓 : Set aℓ) → Set (++ aℓ)
record StrictSubtyping {aℓ} 𝕒 𝕓 where
inductive
instance constructor transitivity′
field {Thing} : Set aℓ
field ⦃ direct ⦄ : DirectSubtyping 𝕒 Thing
field ⦃ indirect ⦄ : Subtyping Thing 𝕓
data Subtyping where
instance reflexivity : Subtyping 𝕒 𝕒
instance from‐strict : ∀ ⦃ strict : StrictSubtyping 𝕒 𝕓 ⦄ → Subtyping 𝕒 𝕓
cast : ∀ ⦃ subtyping : Subtyping 𝕒 𝕓 ⦄ → 𝕒 → 𝕓
cast ⦃ subtyping = reflexivity ⦄ a = a
cast ⦃ subtyping = from‐strict ⦄ a = cast (cast₁ a)
-- Note: These cannot be instances, they must be written explicitly.
transitivity′′ : ∀ ⦃ a‐to‐b : Subtyping 𝕒 𝕓 ⦄ ⦃ b‐to‐c : Subtyping 𝕓 𝕔 ⦄ → DirectSubtyping 𝕒 𝕔
transitivity′′ ⦃ a‐to‐b = a‐to‐b ⦄ ⦃ b‐to‐c = b‐to‐c ⦄ = # λ a → cast ⦃ subtyping = b‐to‐c ⦄ (cast ⦃ subtyping = a‐to‐b ⦄ a)
transitivity : ∀ ⦃ a‐to‐b : Subtyping 𝕒 𝕓 ⦄ ⦃ b‐to‐c : Subtyping 𝕓 𝕔 ⦄ → Subtyping 𝕒 𝕔
transitivity ⦃ a‐to‐b = a‐to‐b ⦄ ⦃ b‐to‐c = b‐to‐c ⦄ = from‐strict where instance _ = transitivity′′ ⦃ a‐to‐b = a‐to‐b ⦄ ⦃ b‐to‐c = b‐to‐c ⦄
module _ ⦃ c‐to‐a : Subtyping 𝕔 𝕒 ⦄ ⦃ b‐to‐d : Subtyping 𝕓 𝕕 ⦄ where
instance
explicit‐variance : DirectSubtyping (𝕒 → 𝕓) (𝕔 → 𝕕)
implicit‐variance : DirectSubtyping (∀ {a : 𝕒} → 𝕓) (∀ {c : 𝕔} → 𝕕)
instance‐variance : DirectSubtyping (∀ ⦃ a : 𝕒 ⦄ → 𝕓) (∀ ⦃ c : 𝕔 ⦄ → 𝕕)
explicit‐variance = # λ f c → cast ⦃ subtyping = b‐to‐d ⦄ (f (cast c))
implicit‐variance = # λ f {c = c} → cast ⦃ subtyping = b‐to‐d ⦄ (f {a = cast c})
instance‐variance = # λ f ⦃ c = c ⦄ → cast ⦃ subtyping = b‐to‐d ⦄ (f ⦃ a = cast c ⦄)
| {
"alphanum_fraction": 0.6025824964,
"avg_line_length": 45.4565217391,
"ext": "agda",
"hexsha": "9206df919aa233c4d66cc2acae4ac5a75918f4d4",
"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/Subtyping.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/Subtyping.agda",
"max_line_length": 140,
"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/Subtyping.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": 935,
"size": 2091
} |
module Issue561 where
open import Common.Char
open import Common.Prelude
primitive
primIsDigit : Char → Bool
postulate
IO : Set → Set
return : ∀ {A} → A → IO A
{-# BUILTIN IO IO #-}
main : IO Bool
main = return true | {
"alphanum_fraction": 0.6740088106,
"avg_line_length": 13.3529411765,
"ext": "agda",
"hexsha": "c501c0900987bfa92108700dcf553ea4d5c3af7f",
"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/Issue561.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/Issue561.agda",
"max_line_length": 27,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "4383a3d20328a6c43689161496cee8eb479aca08",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "dagit/agda",
"max_stars_repo_path": "test/succeed/Issue561.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": 66,
"size": 227
} |
{-# OPTIONS --without-K #-}
module library.types.Types where
open import library.Basics
open import library.types.Empty public
open import library.types.Unit public
open import library.types.Bool public
open import library.types.Nat public
open import library.types.Int public
open import library.types.TLevel public
open import library.types.Paths public
open import library.types.Sigma public
open import library.types.Pi public
open import library.types.Coproduct public
open import library.types.Lift public
open import library.types.Circle public
open import library.types.Span public
open import library.types.Pushout public
open import library.types.PushoutFlattening public
open import library.types.Suspension public
open import library.types.Join public
open import library.types.Torus public
open import library.types.Truncation public
open import library.types.Cospan public
open import library.types.Pullback public
open import library.types.Group public
open import library.types.Groupoid public
open import library.types.GroupSet public
open import library.types.KG1 public
open import library.types.Pointed public
open import library.types.LoopSpace public
open import library.types.HomotopyGroup public
open import library.types.PathSet public
open import library.types.FundamentalGroupoid public
open import library.types.Cover public
open import library.types.OneSkeleton public
open import library.types.PathSeq public
-- This should probably not be exported
-- module Generic1HIT {i j} (A : Type i) (B : Type j) (f g : B → A) where
-- open import library.types.Generic1HIT A B f g public
| {
"alphanum_fraction": 0.8253869969,
"avg_line_length": 36.7045454545,
"ext": "agda",
"hexsha": "7cef038a31f13d10b2c1c20558ae23fc0d886e2c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nicolaikraus/HoTT-Agda",
"max_forks_repo_path": "nicolai/anonymousExistence/library/types/Types.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nicolaikraus/HoTT-Agda",
"max_issues_repo_path": "nicolai/anonymousExistence/library/types/Types.agda",
"max_line_length": 73,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "939a2d83e090fcc924f69f7dfa5b65b3b79fe633",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nicolaikraus/HoTT-Agda",
"max_stars_repo_path": "nicolai/anonymousExistence/library/types/Types.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-30T00:17:55.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-06-30T00:17:55.000Z",
"num_tokens": 343,
"size": 1615
} |
record Unit : Set where
constructor tt
postulate
C : Set
c : C
g : C
f : Unit → C
f tt = c
record R : Set where
constructor r
g = c
| {
"alphanum_fraction": 0.595890411,
"avg_line_length": 8.1111111111,
"ext": "agda",
"hexsha": "34e1daa952f89f7e35b0049e5f65fd3c62d4e10f",
"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/Issue2981.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/Issue2981.agda",
"max_line_length": 23,
"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/Issue2981.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 53,
"size": 146
} |
-- A variant of code reported by Andreas Abel (who suggested that this
-- way to trigger the bug might have been due to NAD).
{-# OPTIONS --guardedness --sized-types #-}
open import Agda.Builtin.Sigma
open import Agda.Builtin.Size
data ⊥ : Set where
record Delay (A : Set) : Set where
coinductive
constructor ♯
field ♭ : Σ A λ _ → ⊥ → Delay A
-- Recursive in order to please the termination checker.
open Delay
data D : Size → Set where
inn : ∀ i → Delay (D i) → D (↑ i)
iter : ∀{i} → D i → ⊥
iter (inn i t) = iter (fst (♭ t))
-- Should be rejected by the termination checker.
bla : Delay (D ∞)
♭ bla = inn ∞ bla , λ()
false : ⊥
false = iter (fst (♭ bla))
| {
"alphanum_fraction": 0.6356932153,
"avg_line_length": 21.1875,
"ext": "agda",
"hexsha": "7ca3fab3c3da3daf66884841040b11e5455068ba",
"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/Issue1209-4.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/Issue1209-4.agda",
"max_line_length": 70,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue1209-4.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": 212,
"size": 678
} |
test = forall _let_ → Set
| {
"alphanum_fraction": 0.6923076923,
"avg_line_length": 13,
"ext": "agda",
"hexsha": "24570870f4f790e442a3dd92743fa4dcbfe88e63",
"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/InvalidNamePartKeyword.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/InvalidNamePartKeyword.agda",
"max_line_length": 25,
"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/InvalidNamePartKeyword.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 9,
"size": 26
} |
module SystemF.BigStep.Types where
open import Prelude
-- types are indexed by the number of open tvars
infixl 10 _⇒_
data Type (n : ℕ) : Set where
Unit : Type n
ν : (i : Fin n) → Type n
_⇒_ : Type n → Type n → Type n
∀' : Type (suc n) → Type n
open import Data.Fin.Substitution
open import Data.Vec
module App {T} (l : Lift T Type )where
open Lift l hiding (var)
_/_ : ∀ {m n} → Type m → Sub T m n → Type n
Unit / s = Unit
ν i / s = lift (lookup i s)
(a ⇒ b) / s = (a / s) ⇒ (b / s)
∀' x / s = ∀' (x / (s ↑))
open Application (record { _/_ = _/_ }) using (_/✶_)
open import Data.Star
Unit-/✶-↑✶ : ∀ k {m n} (ρs : Subs T m n) → Unit /✶ ρs ↑✶ k ≡ Unit
Unit-/✶-↑✶ k ε = refl
Unit-/✶-↑✶ k (x ◅ ρs) = cong₂ _/_ (Unit-/✶-↑✶ k ρs) refl
∀-/✶-↑✶ : ∀ k {m n t} (ρs : Subs T m n) →
∀' t /✶ ρs ↑✶ k ≡ ∀' (t /✶ ρs ↑✶ suc k)
∀-/✶-↑✶ k ε = refl
∀-/✶-↑✶ k (ρ ◅ ρs) = cong₂ _/_ (∀-/✶-↑✶ k ρs) refl
⇒-/✶-↑✶ : ∀ k {m n t₁ t₂} (ρs : Subs T m n) →
t₁ ⇒ t₂ /✶ ρs ↑✶ k ≡ (t₁ /✶ ρs ↑✶ k) ⇒ (t₂ /✶ ρs ↑✶ k)
⇒-/✶-↑✶ k ε = refl
⇒-/✶-↑✶ k (ρ ◅ ρs) = cong₂ _/_ (⇒-/✶-↑✶ k ρs) refl
tmSubst : TermSubst Type
tmSubst = record { var = ν; app = App._/_ }
open TermSubst tmSubst hiding (var; subst) public
module Lemmas where
open import Data.Fin.Substitution.Lemmas
tyLemmas : TermLemmas Type
tyLemmas = record
{ termSubst = tmSubst
; app-var = refl
; /✶-↑✶ = Lemma./✶-↑✶
}
where
module Lemma {T₁ T₂} {lift₁ : Lift T₁ Type} {lift₂ : Lift T₂ Type} where
open Lifted lift₁ using () renaming (_↑✶_ to _↑✶₁_; _/✶_ to _/✶₁_)
open Lifted lift₂ using () renaming (_↑✶_ to _↑✶₂_; _/✶_ to _/✶₂_)
/✶-↑✶ : ∀ {m n} (ρs₁ : Subs T₁ m n) (ρs₂ : Subs T₂ m n) →
(∀ k x → ν x /✶₁ ρs₁ ↑✶₁ k ≡ ν x /✶₂ ρs₂ ↑✶₂ k) →
∀ k t → t /✶₁ ρs₁ ↑✶₁ k ≡ t /✶₂ ρs₂ ↑✶₂ k
/✶-↑✶ ρs₁ ρs₂ hyp k Unit =
begin _ ≡⟨ App.Unit-/✶-↑✶ _ k ρs₁ ⟩ Unit ≡⟨ sym $ App.Unit-/✶-↑✶ _ k ρs₂ ⟩ _ ∎
/✶-↑✶ ρs₁ ρs₂ hyp k (ν i) = hyp k i
/✶-↑✶ ρs₁ ρs₂ hyp k (a ⇒ b) = begin
_ ≡⟨ App.⇒-/✶-↑✶ _ k ρs₁ ⟩
(a /✶₁ ρs₁ ↑✶₁ k) ⇒ (b /✶₁ ρs₁ ↑✶₁ k) ≡⟨ cong₂ _⇒_ (/✶-↑✶ ρs₁ ρs₂ hyp k a)
((/✶-↑✶ ρs₁ ρs₂ hyp k b)) ⟩
(a /✶₂ ρs₂ ↑✶₂ k) ⇒ (b /✶₂ ρs₂ ↑✶₂ k) ≡⟨ sym $ App.⇒-/✶-↑✶ _ k ρs₂ ⟩
_ ∎
/✶-↑✶ ρs₁ ρs₂ hyp k (∀' x) = begin
_ ≡⟨ App.∀-/✶-↑✶ _ k ρs₁ ⟩
∀' (x /✶₁ ρs₁ ↑✶₁ (suc k)) ≡⟨ cong ∀' (/✶-↑✶ ρs₁ ρs₂ hyp (suc k) x) ⟩
∀' (x /✶₂ ρs₂ ↑✶₂ (suc k)) ≡⟨ sym $ App.∀-/✶-↑✶ _ k ρs₂ ⟩
_ ∎
open TermLemmas tyLemmas public hiding (var)
| {
"alphanum_fraction": 0.4499812664,
"avg_line_length": 32.5487804878,
"ext": "agda",
"hexsha": "dcb5acf35308f7bcd79e254be15f06f9773adde2",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ef2e347a4470e55083c83b743efbc2902ef1ad22",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "ElessarWebb/implicits.agda",
"max_forks_repo_path": "src/SystemF/BigStep/Types.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ef2e347a4470e55083c83b743efbc2902ef1ad22",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "ElessarWebb/implicits.agda",
"max_issues_repo_path": "src/SystemF/BigStep/Types.agda",
"max_line_length": 86,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "ef2e347a4470e55083c83b743efbc2902ef1ad22",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "ajrouvoet/implicits.agda",
"max_stars_repo_path": "src/SystemF/BigStep/Types.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z",
"num_tokens": 1395,
"size": 2669
} |
record R (A : Set) : Set where
constructor c₂
field
f : A → A
open module R′ (A : Set) (r : R A) = R {A = A} r
renaming (f to f′)
_ : (@0 A : Set) → R A → A → A
_ = λ A → f′ {A = A}
| {
"alphanum_fraction": 0.4639175258,
"avg_line_length": 17.6363636364,
"ext": "agda",
"hexsha": "17f044e265ad41c67b1f4616f656d921dd5969ef",
"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/Issue4786b.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/Issue4786b.agda",
"max_line_length": 48,
"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/Issue4786b.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": 86,
"size": 194
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.Magma.Properties where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Algebra
open import Cubical.Algebra.Magma.Morphism
open import Cubical.Algebra.Magma.MorphismProperties public
using (MagmaPath; uaMagma; carac-uaMagma; Magma≡; caracMagma≡)
private
variable
ℓ : Level
isPropIsMagma : {M : Type ℓ} {_•_ : Op₂ M} → isProp (IsMagma M _•_)
isPropIsMagma (ismagma x) (ismagma y) = cong ismagma (isPropIsSet x y)
| {
"alphanum_fraction": 0.7662116041,
"avg_line_length": 29.3,
"ext": "agda",
"hexsha": "026e13ca1f05f51643b49a5b86adbb381c2498e1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bijan2005/univalent-foundations",
"max_forks_repo_path": "Cubical/Algebra/Magma/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "bijan2005/univalent-foundations",
"max_issues_repo_path": "Cubical/Algebra/Magma/Properties.agda",
"max_line_length": 70,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "737f922d925da0cd9a875cb0c97786179f1f4f61",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bijan2005/univalent-foundations",
"max_stars_repo_path": "Cubical/Algebra/Magma/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 185,
"size": 586
} |
module Numeral.Natural.Oper.Summation.Range where
import Lvl
open import Data.List
open import Data.List.Functions
open import Numeral.Natural
open import Type
_‥_ : ℕ → ℕ → List(ℕ)
_ ‥ 𝟎 = ∅
𝟎 ‥ 𝐒 b = 𝟎 ⊰ map 𝐒(𝟎 ‥ b)
𝐒 a ‥ 𝐒 b = map 𝐒(a ‥ b)
‥_ : ℕ → List(ℕ)
‥ b = 𝟎 ‥ b
_‥₌_ : ℕ → ℕ → List(ℕ)
a ‥₌ b = a ‥ 𝐒(b)
‥₌_ : ℕ → List(ℕ)
‥₌ b = 𝟎 ‥₌ b
| {
"alphanum_fraction": 0.5524861878,
"avg_line_length": 16.4545454545,
"ext": "agda",
"hexsha": "052e0d431aeee23990ef8451247e0da1fae561b5",
"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/Oper/Summation/Range.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/Oper/Summation/Range.agda",
"max_line_length": 49,
"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/Oper/Summation/Range.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": 200,
"size": 362
} |
{-# OPTIONS --without-K --safe #-}
module Dodo.Unary.Equality where
-- Stdlib imports
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl)
open import Level using (Level; _⊔_)
open import Function using (_∘_)
open import Relation.Unary using (Pred)
-- # Definitions
infix 4 _⊆₁'_ _⊆₁_ _⇔₁_
-- Binary relation subset helper. Generally, use `_⊆₁_` (below).
_⊆₁'_ : {a ℓ₁ ℓ₂ : Level} {A : Set a}
→ (P : Pred A ℓ₁)
→ (R : Pred A ℓ₂)
→ Set (a ⊔ ℓ₁ ⊔ ℓ₂)
_⊆₁'_ {A = A} P R = ∀ (x : A) → P x → R x
-- Somehow, Agda cannot infer P and R from `P ⇒ R`, and requires them explicitly passed.
-- For proof convenience, wrap the proof in this structure, which explicitly conveys P and R
-- to the type-checker.
data _⊆₁_ {a ℓ₁ ℓ₂ : Level} {A : Set a} (P : Pred A ℓ₁) (R : Pred A ℓ₂) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where
⊆: : P ⊆₁' R → P ⊆₁ R
data _⇔₁_ {a ℓ₁ ℓ₂ : Level} {A : Set a} (P : Pred A ℓ₁) (R : Pred A ℓ₂) : Set (a ⊔ ℓ₁ ⊔ ℓ₂) where
⇔: : P ⊆₁' R → R ⊆₁' P → P ⇔₁ R
-- # Helpers
⇔₁-intro : {a ℓ₁ ℓ₂ : Level} {A : Set a}
→ {P : Pred A ℓ₁} {R : Pred A ℓ₂}
→ P ⊆₁ R
→ R ⊆₁ P
→ P ⇔₁ R
⇔₁-intro (⊆: P⊆R) (⊆: R⊆P) = ⇔: P⊆R R⊆P
⇔₁-compose : ∀ {a b ℓ₁ ℓ₂ ℓ₃ ℓ₄ : Level} {A : Set a} {B : Set b}
{P : Pred A ℓ₁} {Q : Pred A ℓ₂} {R : Pred B ℓ₃} {S : Pred B ℓ₄}
→ ( P ⊆₁ Q → R ⊆₁ S )
→ ( Q ⊆₁ P → S ⊆₁ R )
→ P ⇔₁ Q
→ R ⇔₁ S
⇔₁-compose ⊆-proof ⊇-proof (⇔: P⊆Q R⊆S) = ⇔₁-intro (⊆-proof (⊆: P⊆Q)) (⊇-proof (⊆: R⊆S))
-- # Properties
-- ## Properties: ⊆₁
module _ {a ℓ : Level} {A : Set a} {R : Pred A ℓ} where
⊆₁-refl : R ⊆₁ R
⊆₁-refl = ⊆: (λ _ Rx → Rx)
module _ {a ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a} {P : Pred A ℓ₁} {Q : Pred A ℓ₂} {R : Pred A ℓ₃} where
⊆₁-trans : P ⊆₁ Q → Q ⊆₁ R → P ⊆₁ R
⊆₁-trans (⊆: P⊆Q) (⊆: Q⊆R) = ⊆: (λ x Qx → Q⊆R x (P⊆Q x Qx))
-- ## Properties: ⇔₁
module _ {a ℓ : Level} {A : Set a} {R : Pred A ℓ} where
⇔₁-refl : R ⇔₁ R
⇔₁-refl = ⇔₁-intro ⊆₁-refl ⊆₁-refl
module _ {a ℓ₁ ℓ₂ : Level} {A : Set a} {Q : Pred A ℓ₁} {R : Pred A ℓ₂} where
⇔₁-sym : Q ⇔₁ R → R ⇔₁ Q
-- WARNING: Do *NOT* use `Symmetric _⇔_`. It messes up the universe levels.
⇔₁-sym (⇔: Q⊆R R⊆Q) = ⇔: R⊆Q Q⊆R
module _ {a ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a}
{P : Pred A ℓ₁} {Q : Pred A ℓ₂} {R : Pred A ℓ₃} where
⇔₁-trans : P ⇔₁ Q → Q ⇔₁ R → P ⇔₁ R
⇔₁-trans (⇔: P⊆Q Q⊆P) (⇔: Q⊆R R⊆Q) = ⇔₁-intro (⊆₁-trans (⊆: P⊆Q) (⊆: Q⊆R)) (⊆₁-trans (⊆: R⊆Q) (⊆: Q⊆P))
-- # Operations
-- ## Operations: ⇔₁ and ⊆₁ conversion
un-⊆₁ : ∀ {a ℓ₁ ℓ₂ : Level} {A : Set a} {P : Pred A ℓ₁} {R : Pred A ℓ₂}
→ P ⊆₁ R
→ P ⊆₁' R
un-⊆₁ (⊆: P⊆R) = P⊆R
unlift-⊆₁ : ∀ {a b ℓ₁ ℓ₂ ℓ₃ ℓ₄ : Level} {A : Set a} {B : Set b}
{P : Pred A ℓ₁} {Q : Pred A ℓ₂} {R : Pred B ℓ₃} {S : Pred B ℓ₄}
→ ( P ⊆₁ Q → R ⊆₁ S )
→ ( P ⊆₁' Q → R ⊆₁' S )
unlift-⊆₁ f P⊆Q = un-⊆₁ (f (⊆: P⊆Q))
lift-⊆₁ : ∀ {a b ℓ₁ ℓ₂ ℓ₃ ℓ₄ : Level} {A : Set a} {B : Set b}
{P : Pred A ℓ₁} {Q : Pred A ℓ₂} {R : Pred B ℓ₃} {S : Pred B ℓ₄}
→ ( P ⊆₁' Q → R ⊆₁' S )
→ ( P ⊆₁ Q → R ⊆₁ S )
lift-⊆₁ f (⊆: P⊆Q) = ⊆: (f P⊆Q)
⇔₁-to-⊆₁ : {a ℓ₁ ℓ₂ : Level} {A : Set a} {P : Pred A ℓ₁} {Q : Pred A ℓ₂}
→ P ⇔₁ Q
------
→ P ⊆₁ Q
⇔₁-to-⊆₁ (⇔: P⊆Q _) = ⊆: P⊆Q
⇔₁-to-⊇₁ : {a ℓ₁ ℓ₂ : Level} {A : Set a} {P : Pred A ℓ₁} {Q : Pred A ℓ₂}
→ P ⇔₁ Q
------
→ Q ⊆₁ P
⇔₁-to-⊇₁ (⇔: _ Q⊆P) = ⊆: Q⊆P
-- ## Operations: ⊆₁
⊆₁-apply : ∀ {a ℓ₁ ℓ₂ : Level} {A : Set a}
{P : Pred A ℓ₁} {Q : Pred A ℓ₂}
→ P ⊆₁ Q
→ {x : A}
→ P x
-------
→ Q x
⊆₁-apply (⊆: P⊆Q) {x} = P⊆Q x
⊆₁-substˡ : ∀ {a ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a}
{P : Pred A ℓ₁} {Q : Pred A ℓ₂} {R : Pred A ℓ₃} {x : A}
→ P ⇔₁ Q
→ P ⊆₁ R
------
→ Q ⊆₁ R
⊆₁-substˡ (⇔: _ Q⊆P) P⊆R = ⊆₁-trans (⊆: Q⊆P) P⊆R
⊆₁-substʳ : ∀ {a ℓ₁ ℓ₂ ℓ₃ : Level} {A : Set a}
{P : Pred A ℓ₁} {Q : Pred A ℓ₂} {R : Pred A ℓ₃}
→ Q ⇔₁ R
→ P ⊆₁ Q
------
→ P ⊆₁ R
⊆₁-substʳ (⇔: Q⊆R _) P⊆Q = ⊆₁-trans P⊆Q (⊆: Q⊆R)
≡-to-⊆₁ : {a b ℓ : Level} {A : Set a}
{P : Pred A ℓ} {Q : Pred A ℓ}
→ P ≡ Q
------
→ P ⊆₁ Q
≡-to-⊆₁ refl = ⊆: (λ _ Px → Px)
-- ## Operations: ⇔₁
⇔₁-apply-⊆₁ : {a ℓ₁ ℓ₂ : Level} {A : Set a}
{P : Pred A ℓ₁} {Q : Pred A ℓ₂}
→ P ⇔₁ Q
→ {x : A}
→ P x
-------
→ Q x
⇔₁-apply-⊆₁ = ⊆₁-apply ∘ ⇔₁-to-⊆₁
⇔₁-apply-⊇₁ : {a ℓ₁ ℓ₂ : Level} {A : Set a}
{P : Pred A ℓ₁} {Q : Pred A ℓ₂}
→ P ⇔₁ Q
→ {x : A}
→ Q x
-------
→ P x
⇔₁-apply-⊇₁ = ⊆₁-apply ∘ ⇔₁-to-⊇₁
≡-to-⇔₁ : {a ℓ : Level} {A : Set a}
{P : Pred A ℓ} {Q : Pred A ℓ}
→ P ≡ Q
------
→ P ⇔₁ Q
≡-to-⇔₁ refl = ⇔₁-intro ⊆₁-refl ⊆₁-refl
-- # Reasoning
-- ## Reasoning: ⊆₁
module ⊆₁-Reasoning {a ℓ₁ : Level} {A : Set a} where
infix 3 _⊆₁∎
infixr 2 step-⊆₁
infix 1 begin⊆₁_
begin⊆₁_ : {ℓ₂ : Level} {P : Pred A ℓ₁} {Q : Pred A ℓ₂}
→ P ⊆₁ Q
------
→ P ⊆₁ Q
begin⊆₁_ P⊆Q = P⊆Q
step-⊆₁ : ∀ {ℓ₂ ℓ₃ : Level}
→ (P : Pred A ℓ₁)
→ {Q : Pred A ℓ₂}
→ {R : Pred A ℓ₃}
→ Q ⊆₁ R
→ P ⊆₁ Q
------
→ P ⊆₁ R
step-⊆₁ P Q⊆R P⊆Q = ⊆₁-trans P⊆Q Q⊆R
_⊆₁∎ : ∀ (P : Pred A ℓ₁) → P ⊆₁ P
_⊆₁∎ _ = ⊆₁-refl
syntax step-⊆₁ P Q⊆R P⊆Q = P ⊆₁⟨ P⊆Q ⟩ Q⊆R
-- ## Reasoning: ⇔₁
module ⇔₁-Reasoning {a ℓ₁ : Level} {A : Set a} where
infix 3 _⇔₁∎
infixr 2 _⇔₁⟨⟩_ step-⇔₁
infix 1 begin⇔₁_
begin⇔₁_ : {ℓ₂ : Level} {P : Pred A ℓ₁} {Q : Pred A ℓ₂}
→ P ⇔₁ Q
------
→ P ⇔₁ Q
begin⇔₁_ P⇔Q = P⇔Q
_⇔₁⟨⟩_ : {ℓ₂ : Level}
(P : Pred A ℓ₁)
→ {Q : Pred A ℓ₂}
→ P ⇔₁ Q
---------------
→ P ⇔₁ Q
_ ⇔₁⟨⟩ x≡y = x≡y
step-⇔₁ : ∀ {ℓ₂ ℓ₃ : Level}
→ (P : Pred A ℓ₁)
→ {Q : Pred A ℓ₂}
→ {R : Pred A ℓ₃}
→ Q ⇔₁ R
→ P ⇔₁ Q
---------------
→ P ⇔₁ R
step-⇔₁ _ Q⇔R P⇔Q = ⇔₁-trans P⇔Q Q⇔R
_⇔₁∎ : ∀ (P : Pred A ℓ₁) → P ⇔₁ P
_⇔₁∎ _ = ⇔₁-refl
syntax step-⇔₁ P Q⇔R P⇔Q = P ⇔₁⟨ P⇔Q ⟩ Q⇔R
| {
"alphanum_fraction": 0.4535633386,
"avg_line_length": 22.7738095238,
"ext": "agda",
"hexsha": "9dbb5bc235547a69f75a5ed064778825198ad2fb",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "sourcedennis/agda-dodo",
"max_forks_repo_path": "src/Dodo/Unary/Equality.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "sourcedennis/agda-dodo",
"max_issues_repo_path": "src/Dodo/Unary/Equality.agda",
"max_line_length": 105,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "376f0ccee1e1aa31470890e494bcb534324f598a",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "sourcedennis/agda-dodo",
"max_stars_repo_path": "src/Dodo/Unary/Equality.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3386,
"size": 5739
} |
{-# OPTIONS --cubical --safe --postfix-projections #-}
module Data.Bool.Properties where
open import Prelude
open import Data.Bool
open import Data.Unit.Properties
T? : ∀ x → Dec (T x)
T? x .does = x
T? false .why = ofⁿ id
T? true .why = ofʸ tt
isPropT : ∀ x → isProp (T x)
isPropT false = isProp⊥
isPropT true = isProp⊤
discreteBool : Discrete Bool
discreteBool false y .does = not y
discreteBool true y .does = y
discreteBool false false .why = ofʸ refl
discreteBool false true .why = ofⁿ λ p → subst (bool ⊤ ⊥) p tt
discreteBool true false .why = ofⁿ λ p → subst (bool ⊥ ⊤) p tt
discreteBool true true .why = ofʸ refl
| {
"alphanum_fraction": 0.6942675159,
"avg_line_length": 25.12,
"ext": "agda",
"hexsha": "fd7e1d1806d3b77763ebef1094a1ae63c0da358d",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/combinatorics-paper",
"max_forks_repo_path": "agda/Data/Bool/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/combinatorics-paper",
"max_issues_repo_path": "agda/Data/Bool/Properties.agda",
"max_line_length": 62,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/combinatorics-paper",
"max_stars_repo_path": "agda/Data/Bool/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z",
"num_tokens": 218,
"size": 628
} |
{-# OPTIONS --without-K #-}
module P where
open import Data.Empty
open import Data.Unit
open import Data.Sum
open import Data.Product
open import Relation.Binary.PropositionalEquality
------------------------------------------------------------------------------
-- For now, a groupoid is just a set
Groupoid : Set₁
Groupoid = Set
mutual
-- types
data B : Set where
ZERO : B
ONE : B
_+_ : B → B → B
_*_ : B → B → B
_~_ : {b : B} → ⟦ b ⟧ → ⟦ b ⟧ → B
-- values
⟦_⟧ : B → Groupoid
⟦ ZERO ⟧ = ⊥
⟦ ONE ⟧ = ⊤
⟦ b₁ + b₂ ⟧ = ⟦ b₁ ⟧ ⊎ ⟦ b₂ ⟧
⟦ b₁ * b₂ ⟧ = ⟦ b₁ ⟧ × ⟦ b₂ ⟧
⟦ v₁ ~ v₂ ⟧ = v₁ ≡ v₂
-- pointed types
data PB : Set where
POINTED : Σ B (λ b → ⟦ b ⟧) → PB
RECIP : PB → PB
-- lift B type constructors to pointed types
_++_ : PB → PB → PB
(POINTED (b₁ , v₁)) ++ (POINTED (b₂ , v₂)) = POINTED (b₁ + b₂ , inj₁ v₁)
_ ++ _ = {!!}
_**_ : PB → PB → PB
(POINTED (b₁ , v₁)) ** (POINTED (b₂ , v₂)) = POINTED (b₁ * b₂ , (v₁ , v₂))
_ ** _ = {!!}
-- All the pi combinators now work on pointed types
data _⟷_ : PB → PB → Set₁ where
swap⋆ : {pb₁ pb₂ : PB} → (pb₁ ** pb₂) ⟷ (pb₂ ** pb₁)
eta : {pb : PB} → POINTED (ONE , tt) ⟷ RECIP pb
-- induction principle to reason about identities; needed ???
ind : {b : B} →
(C : (v₁ v₂ : ⟦ b ⟧) → (p : ⟦ _~_ {b} v₁ v₂ ⟧) → Set) →
(c : (v : ⟦ b ⟧) → C v v refl) →
(v₁ v₂ : ⟦ b ⟧) → (p : ⟦ _~_ {b} v₁ v₂ ⟧) → C v₁ v₂ p
ind C c v .v refl = c v
-- Examples
Bool : B
Bool = ONE + ONE
false : ⟦ Bool ⟧
false = inj₁ tt
true : ⟦ Bool ⟧
true = inj₂ tt
pb1 : PB
pb1 = POINTED (Bool , false)
pb2 : PB
pb2 = POINTED (Bool , true)
FalseID : B
FalseID = _~_ {Bool} false false
pb3 : PB
pb3 = POINTED (FalseID , refl)
FalseID^2 : B
FalseID^2 = _~_ {FalseID} refl refl
pb4 : PB
pb4 = POINTED (FalseID^2 , refl)
------------------------------------------------------------------------------
| {
"alphanum_fraction": 0.4620030196,
"avg_line_length": 20.4845360825,
"ext": "agda",
"hexsha": "c8bb82142c853b3d48b3c9e71bf6518c9e42305f",
"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": "P.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": "P.agda",
"max_line_length": 79,
"max_stars_count": 14,
"max_stars_repo_head_hexsha": "003835484facfde0b770bc2b3d781b42b76184c1",
"max_stars_repo_licenses": [
"BSD-2-Clause"
],
"max_stars_repo_name": "JacquesCarette/pi-dual",
"max_stars_repo_path": "P.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": 749,
"size": 1987
} |
-- Basic intuitionistic logic of proofs, without ∨, ⊥, or +.
-- Gentzen-style formalisation of syntax with context pairs.
-- Normal forms and neutrals.
module BasicILP.Syntax.DyadicGentzenNormalForm where
open import BasicILP.Syntax.DyadicGentzen public
-- Derivations.
mutual
-- Normal forms, or introductions.
infix 3 _⊢ⁿᶠ_
data _⊢ⁿᶠ_ : Cx² Ty Box → Ty → Set where
neⁿᶠ : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ⁿᵉ A → Γ ⁏ Δ ⊢ⁿᶠ A
lamⁿᶠ : ∀ {A B Γ Δ} → Γ , A ⁏ Δ ⊢ⁿᶠ B → Γ ⁏ Δ ⊢ⁿᶠ A ▻ B
boxⁿᶠ : ∀ {Ψ Ω A Γ Δ} → (x : Ψ ⁏ Ω ⊢ A)
→ Γ ⁏ Δ ⊢ⁿᶠ [ Ψ ⁏ Ω ⊢ x ] A
pairⁿᶠ : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ⁿᶠ A → Γ ⁏ Δ ⊢ⁿᶠ B → Γ ⁏ Δ ⊢ⁿᶠ A ∧ B
unitⁿᶠ : ∀ {Γ Δ} → Γ ⁏ Δ ⊢ⁿᶠ ⊤
-- Neutrals, or eliminations.
infix 3 _⊢ⁿᵉ_
data _⊢ⁿᵉ_ : Cx² Ty Box → Ty → Set where
varⁿᵉ : ∀ {A Γ Δ} → A ∈ Γ → Γ ⁏ Δ ⊢ⁿᵉ A
appⁿᵉ : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ⁿᵉ A ▻ B → Γ ⁏ Δ ⊢ⁿᶠ A → Γ ⁏ Δ ⊢ⁿᵉ B
mvarⁿᵉ : ∀ {Ψ Ω A x Γ Δ} → [ Ψ ⁏ Ω ⊢ x ] A ∈ Δ
→ {{_ : Γ ⁏ Δ ⊢⋆ⁿᶠ Ψ}}
→ {{_ : Γ ⁏ Δ ⊢⍟ⁿᶠ Ω}}
→ Γ ⁏ Δ ⊢ⁿᵉ A
unboxⁿᵉ : ∀ {Ψ Ω A C x Γ Δ} → Γ ⁏ Δ ⊢ⁿᵉ [ Ψ ⁏ Ω ⊢ x ] A
→ Γ ⁏ Δ , [ Ψ ⁏ Ω ⊢ x ] A ⊢ⁿᶠ C
→ Γ ⁏ Δ ⊢ⁿᵉ C
fstⁿᵉ : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ⁿᵉ A ∧ B → Γ ⁏ Δ ⊢ⁿᵉ A
sndⁿᵉ : ∀ {A B Γ Δ} → Γ ⁏ Δ ⊢ⁿᵉ A ∧ B → Γ ⁏ Δ ⊢ⁿᵉ B
infix 3 _⊢⋆ⁿᶠ_
_⊢⋆ⁿᶠ_ : Cx² Ty Box → Cx Ty → Set
Γ ⁏ Δ ⊢⋆ⁿᶠ ∅ = 𝟙
Γ ⁏ Δ ⊢⋆ⁿᶠ Ξ , A = Γ ⁏ Δ ⊢⋆ⁿᶠ Ξ × Γ ⁏ Δ ⊢ⁿᶠ A
infix 3 _⊢⍟ⁿᶠ_
_⊢⍟ⁿᶠ_ : Cx² Ty Box → Cx Box → Set
Γ ⁏ Δ ⊢⍟ⁿᶠ ∅ = 𝟙
Γ ⁏ Δ ⊢⍟ⁿᶠ Ξ , [ Ψ ⁏ Ω ⊢ x ] A = Γ ⁏ Δ ⊢⍟ⁿᶠ Ξ × Γ ⁏ Δ ⊢ⁿᶠ [ Ψ ⁏ Ω ⊢ x ] A
infix 3 _⊢⋆ⁿᵉ_
_⊢⋆ⁿᵉ_ : Cx² Ty Box → Cx Ty → Set
Γ ⁏ Δ ⊢⋆ⁿᵉ ∅ = 𝟙
Γ ⁏ Δ ⊢⋆ⁿᵉ Ξ , A = Γ ⁏ Δ ⊢⋆ⁿᵉ Ξ × Γ ⁏ Δ ⊢ⁿᵉ A
infix 3 _⊢⍟ⁿᵉ_
_⊢⍟ⁿᵉ_ : Cx² Ty Box → Cx Box → Set
Γ ⁏ Δ ⊢⍟ⁿᵉ ∅ = 𝟙
Γ ⁏ Δ ⊢⍟ⁿᵉ Ξ , [ Ψ ⁏ Ω ⊢ x ] A = Γ ⁏ Δ ⊢⍟ⁿᵉ Ξ × Γ ⁏ Δ ⊢ⁿᵉ [ Ψ ⁏ Ω ⊢ x ] A
-- Translation to simple terms.
mutual
nf→tm : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ⁿᶠ A → Γ ⁏ Δ ⊢ A
nf→tm (neⁿᶠ t) = ne→tm t
nf→tm (lamⁿᶠ t) = lam (nf→tm t)
nf→tm (boxⁿᶠ t) = box t
nf→tm (pairⁿᶠ t u) = pair (nf→tm t) (nf→tm u)
nf→tm unitⁿᶠ = unit
ne→tm : ∀ {A Γ Δ} → Γ ⁏ Δ ⊢ⁿᵉ A → Γ ⁏ Δ ⊢ A
ne→tm (varⁿᵉ i) = var i
ne→tm (appⁿᵉ t u) = app (ne→tm t) (nf→tm u)
ne→tm (mvarⁿᵉ i {{ts}} {{us}}) = mvar i {{nf→tm⋆ ts}} {{nf→tm⍟ us}}
ne→tm (unboxⁿᵉ t u) = unbox (ne→tm t) (nf→tm u)
ne→tm (fstⁿᵉ t) = fst (ne→tm t)
ne→tm (sndⁿᵉ t) = snd (ne→tm t)
nf→tm⋆ : ∀ {Ξ Γ Δ} → Γ ⁏ Δ ⊢⋆ⁿᶠ Ξ → Γ ⁏ Δ ⊢⋆ Ξ
nf→tm⋆ {∅} ∙ = ∙
nf→tm⋆ {Ξ , A} (ts , t) = nf→tm⋆ ts , nf→tm t
nf→tm⍟ : ∀ {Ξ Γ Δ} → Γ ⁏ Δ ⊢⍟ⁿᶠ Ξ → Γ ⁏ Δ ⊢⍟ Ξ
nf→tm⍟ {∅} ∙ = ∙
nf→tm⍟ {Ξ , _} (ts , t) = nf→tm⍟ ts , nf→tm t
ne→tm⋆ : ∀ {Ξ Γ Δ} → Γ ⁏ Δ ⊢⋆ⁿᵉ Ξ → Γ ⁏ Δ ⊢⋆ Ξ
ne→tm⋆ {∅} ∙ = ∙
ne→tm⋆ {Ξ , A} (ts , t) = ne→tm⋆ ts , ne→tm t
ne→tm⍟ : ∀ {Ξ Γ Δ} → Γ ⁏ Δ ⊢⍟ⁿᵉ Ξ → Γ ⁏ Δ ⊢⍟ Ξ
ne→tm⍟ {∅} ∙ = ∙
ne→tm⍟ {Ξ , _} (ts , t) = ne→tm⍟ ts , ne→tm t
-- Monotonicity with respect to context inclusion.
mutual
mono⊢ⁿᶠ : ∀ {A Γ Γ′ Δ} → Γ ⊆ Γ′ → Γ ⁏ Δ ⊢ⁿᶠ A → Γ′ ⁏ Δ ⊢ⁿᶠ A
mono⊢ⁿᶠ η (neⁿᶠ t) = neⁿᶠ (mono⊢ⁿᵉ η t)
mono⊢ⁿᶠ η (lamⁿᶠ t) = lamⁿᶠ (mono⊢ⁿᶠ (keep η) t)
mono⊢ⁿᶠ η (boxⁿᶠ t) = boxⁿᶠ t
mono⊢ⁿᶠ η (pairⁿᶠ t u) = pairⁿᶠ (mono⊢ⁿᶠ η t) (mono⊢ⁿᶠ η u)
mono⊢ⁿᶠ η unitⁿᶠ = unitⁿᶠ
mono⊢ⁿᵉ : ∀ {A Γ Γ′ Δ} → Γ ⊆ Γ′ → Γ ⁏ Δ ⊢ⁿᵉ A → Γ′ ⁏ Δ ⊢ⁿᵉ A
mono⊢ⁿᵉ η (varⁿᵉ i) = varⁿᵉ (mono∈ η i)
mono⊢ⁿᵉ η (appⁿᵉ t u) = appⁿᵉ (mono⊢ⁿᵉ η t) (mono⊢ⁿᶠ η u)
mono⊢ⁿᵉ η (mvarⁿᵉ i {{ts}} {{us}}) = mvarⁿᵉ i {{mono⊢⋆ⁿᶠ η ts}} {{mono⊢⍟ⁿᶠ η us}}
mono⊢ⁿᵉ η (unboxⁿᵉ t u) = unboxⁿᵉ (mono⊢ⁿᵉ η t) (mono⊢ⁿᶠ η u)
mono⊢ⁿᵉ η (fstⁿᵉ t) = fstⁿᵉ (mono⊢ⁿᵉ η t)
mono⊢ⁿᵉ η (sndⁿᵉ t) = sndⁿᵉ (mono⊢ⁿᵉ η t)
mono⊢⋆ⁿᶠ : ∀ {Ξ Γ Γ′ Δ} → Γ ⊆ Γ′ → Γ ⁏ Δ ⊢⋆ⁿᶠ Ξ → Γ′ ⁏ Δ ⊢⋆ⁿᶠ Ξ
mono⊢⋆ⁿᶠ {∅} η ∙ = ∙
mono⊢⋆ⁿᶠ {Ξ , A} η (ts , t) = mono⊢⋆ⁿᶠ η ts , mono⊢ⁿᶠ η t
mono⊢⍟ⁿᶠ : ∀ {Ξ Γ Γ′ Δ} → Γ ⊆ Γ′ → Γ ⁏ Δ ⊢⍟ⁿᶠ Ξ → Γ′ ⁏ Δ ⊢⍟ⁿᶠ Ξ
mono⊢⍟ⁿᶠ {∅} η ∙ = ∙
mono⊢⍟ⁿᶠ {Ξ , _} η (ts , t) = mono⊢⍟ⁿᶠ η ts , mono⊢ⁿᶠ η t
mono⊢⋆ⁿᵉ : ∀ {Ξ Γ Γ′ Δ} → Γ ⊆ Γ′ → Γ ⁏ Δ ⊢⋆ⁿᵉ Ξ → Γ′ ⁏ Δ ⊢⋆ⁿᵉ Ξ
mono⊢⋆ⁿᵉ {∅} η ∙ = ∙
mono⊢⋆ⁿᵉ {Ξ , A} η (ts , t) = mono⊢⋆ⁿᵉ η ts , mono⊢ⁿᵉ η t
mono⊢⍟ⁿᵉ : ∀ {Ξ Γ Γ′ Δ} → Γ ⊆ Γ′ → Γ ⁏ Δ ⊢⍟ⁿᵉ Ξ → Γ′ ⁏ Δ ⊢⍟ⁿᵉ Ξ
mono⊢⍟ⁿᵉ {∅} η ∙ = ∙
mono⊢⍟ⁿᵉ {Ξ , _} η (ts , t) = mono⊢⍟ⁿᵉ η ts , mono⊢ⁿᵉ η t
-- Monotonicity with respect to modal context inclusion.
mutual
mmono⊢ⁿᶠ : ∀ {A Γ Δ Δ′} → Δ ⊆ Δ′ → Γ ⁏ Δ ⊢ⁿᶠ A → Γ ⁏ Δ′ ⊢ⁿᶠ A
mmono⊢ⁿᶠ θ (neⁿᶠ t) = neⁿᶠ (mmono⊢ⁿᵉ θ t)
mmono⊢ⁿᶠ θ (lamⁿᶠ t) = lamⁿᶠ (mmono⊢ⁿᶠ θ t)
mmono⊢ⁿᶠ θ (boxⁿᶠ t) = boxⁿᶠ t
mmono⊢ⁿᶠ θ (pairⁿᶠ t u) = pairⁿᶠ (mmono⊢ⁿᶠ θ t) (mmono⊢ⁿᶠ θ u)
mmono⊢ⁿᶠ θ unitⁿᶠ = unitⁿᶠ
mmono⊢ⁿᵉ : ∀ {A Γ Δ Δ′} → Δ ⊆ Δ′ → Γ ⁏ Δ ⊢ⁿᵉ A → Γ ⁏ Δ′ ⊢ⁿᵉ A
mmono⊢ⁿᵉ θ (varⁿᵉ i) = varⁿᵉ i
mmono⊢ⁿᵉ θ (appⁿᵉ t u) = appⁿᵉ (mmono⊢ⁿᵉ θ t) (mmono⊢ⁿᶠ θ u)
mmono⊢ⁿᵉ θ (mvarⁿᵉ i {{ts}} {{us}}) = mvarⁿᵉ (mono∈ θ i) {{mmono⊢⋆ⁿᶠ θ ts}} {{mmono⊢⍟ⁿᶠ θ us}}
mmono⊢ⁿᵉ θ (unboxⁿᵉ t u) = unboxⁿᵉ (mmono⊢ⁿᵉ θ t) (mmono⊢ⁿᶠ (keep θ) u)
mmono⊢ⁿᵉ θ (fstⁿᵉ t) = fstⁿᵉ (mmono⊢ⁿᵉ θ t)
mmono⊢ⁿᵉ θ (sndⁿᵉ t) = sndⁿᵉ (mmono⊢ⁿᵉ θ t)
mmono⊢⋆ⁿᶠ : ∀ {Ξ Γ Δ Δ′} → Δ ⊆ Δ′ → Γ ⁏ Δ ⊢⋆ⁿᶠ Ξ → Γ ⁏ Δ′ ⊢⋆ⁿᶠ Ξ
mmono⊢⋆ⁿᶠ {∅} θ ∙ = ∙
mmono⊢⋆ⁿᶠ {Ξ , A} θ (ts , t) = mmono⊢⋆ⁿᶠ θ ts , mmono⊢ⁿᶠ θ t
mmono⊢⍟ⁿᶠ : ∀ {Ξ Γ Δ Δ′} → Δ ⊆ Δ′ → Γ ⁏ Δ ⊢⍟ⁿᶠ Ξ → Γ ⁏ Δ′ ⊢⍟ⁿᶠ Ξ
mmono⊢⍟ⁿᶠ {∅} θ ∙ = ∙
mmono⊢⍟ⁿᶠ {Ξ , _} θ (ts , t) = mmono⊢⍟ⁿᶠ θ ts , mmono⊢ⁿᶠ θ t
mmono⊢⋆ⁿᵉ : ∀ {Ξ Γ Δ Δ′} → Δ ⊆ Δ′ → Γ ⁏ Δ ⊢⋆ⁿᵉ Ξ → Γ ⁏ Δ′ ⊢⋆ⁿᵉ Ξ
mmono⊢⋆ⁿᵉ {∅} θ ∙ = ∙
mmono⊢⋆ⁿᵉ {Ξ , A} θ (ts , t) = mmono⊢⋆ⁿᵉ θ ts , mmono⊢ⁿᵉ θ t
mmono⊢⍟ⁿᵉ : ∀ {Ξ Γ Δ Δ′} → Δ ⊆ Δ′ → Γ ⁏ Δ ⊢⍟ⁿᵉ Ξ → Γ ⁏ Δ′ ⊢⍟ⁿᵉ Ξ
mmono⊢⍟ⁿᵉ {∅} θ ∙ = ∙
mmono⊢⍟ⁿᵉ {Ξ , _} θ (ts , t) = mmono⊢⍟ⁿᵉ θ ts , mmono⊢ⁿᵉ θ t
-- Monotonicity using context pairs.
mono²⊢ⁿᶠ : ∀ {A Π Π′} → Π ⊆² Π′ → Π ⊢ⁿᶠ A → Π′ ⊢ⁿᶠ A
mono²⊢ⁿᶠ (η , θ) = mono⊢ⁿᶠ η ∘ mmono⊢ⁿᶠ θ
mono²⊢ⁿᵉ : ∀ {A Π Π′} → Π ⊆² Π′ → Π ⊢ⁿᵉ A → Π′ ⊢ⁿᵉ A
mono²⊢ⁿᵉ (η , θ) = mono⊢ⁿᵉ η ∘ mmono⊢ⁿᵉ θ
-- Generalised reflexivity.
refl⊢⋆ⁿᵉ : ∀ {Γ Ψ Δ} → {{_ : Ψ ⊆ Γ}} → Γ ⁏ Δ ⊢⋆ⁿᵉ Ψ
refl⊢⋆ⁿᵉ {∅} {{done}} = ∙
refl⊢⋆ⁿᵉ {Γ , A} {{skip η}} = mono⊢⋆ⁿᵉ weak⊆ (refl⊢⋆ⁿᵉ {{η}})
refl⊢⋆ⁿᵉ {Γ , A} {{keep η}} = mono⊢⋆ⁿᵉ weak⊆ (refl⊢⋆ⁿᵉ {{η}}) , varⁿᵉ top
| {
"alphanum_fraction": 0.4260408781,
"avg_line_length": 35.8967391304,
"ext": "agda",
"hexsha": "c05b48cd7c96633d14e39502e6ca0636da6c575c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_forks_repo_licenses": [
"X11"
],
"max_forks_repo_name": "mietek/hilbert-gentzen",
"max_forks_repo_path": "BasicILP/Syntax/DyadicGentzenNormalForm.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_issues_repo_issues_event_max_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-06-10T09:11:22.000Z",
"max_issues_repo_licenses": [
"X11"
],
"max_issues_repo_name": "mietek/hilbert-gentzen",
"max_issues_repo_path": "BasicILP/Syntax/DyadicGentzenNormalForm.agda",
"max_line_length": 96,
"max_stars_count": 29,
"max_stars_repo_head_hexsha": "fcd187db70f0a39b894fe44fad0107f61849405c",
"max_stars_repo_licenses": [
"X11"
],
"max_stars_repo_name": "mietek/hilbert-gentzen",
"max_stars_repo_path": "BasicILP/Syntax/DyadicGentzenNormalForm.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-01T10:29:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-07-03T18:51:56.000Z",
"num_tokens": 4912,
"size": 6605
} |
module EquationalTheory where
open import Library
open import Syntax
open import RenamingAndSubstitution
-- Single collapsing substitution.
sub1 : ∀{Γ σ τ} → Tm Γ σ → Tm (Γ , σ) τ → Tm Γ τ
sub1 {Γ}{σ}{τ} u t = sub (subId , u) t
-- Typed β-η-equality.
data _≡βη_ {Γ : Cxt} : ∀{σ} → Tm Γ σ → Tm Γ σ → Set where
-- Axioms.
beta≡ : ∀{σ τ} {t : Tm (Γ , σ) τ} {u : Tm Γ σ} →
--------------------------
app (abs t) u ≡βη sub1 u t
eta≡ : ∀{σ τ} (t : Tm Γ (σ ⇒ τ)) →
-------------------------------------
abs (app (weak _ t) (var zero)) ≡βη t
-- Congruence rules.
var≡ : ∀{σ} (x : Var Γ σ) →
---------------
var x ≡βη var x
abs≡ : ∀{σ τ}{t t' : Tm (Γ , σ) τ} →
t ≡βη t' →
----------------
abs t ≡βη abs t'
app≡ : ∀{σ τ}{t t' : Tm Γ (σ ⇒ τ)}{u u' : Tm Γ σ} →
t ≡βη t' → u ≡βη u' →
---------------------
app t u ≡βη app t' u'
-- Equivalence rules.
refl≡ : ∀{a} (t {t'} : Tm Γ a) →
t ≡ t' →
-------
t ≡βη t'
sym≡ : ∀{a}{t t' : Tm Γ a}
(t'≡t : t' ≡βη t) →
-----------------
t ≡βη t'
trans≡ : ∀{a}{t₁ t₂ t₃ : Tm Γ a}
(t₁≡t₂ : t₁ ≡βη t₂) (t₂≡t₃ : t₂ ≡βη t₃) →
----------------------------------
t₁ ≡βη t₃
-- A calculation on renamings needed for renaming of eta≡.
ren-eta≡ : ∀ {Γ Δ a b} (t : Tm Γ (a ⇒ b)) (ρ : Ren Δ Γ) →
ren (wkr ρ , zero) (ren (wkr renId) t) ≡ ren (wkr {σ = a} renId) (ren ρ t)
ren-eta≡ t ρ = begin
ren (wkr ρ , zero) (ren (wkr renId) t) ≡⟨ sym (rencomp _ _ _) ⟩
ren (renComp (wkr ρ , zero) (wkr renId)) t ≡⟨ cong (λ ρ₁ → ren ρ₁ t) (lemrr _ _ _) ⟩
ren (renComp (wkr ρ) renId) t ≡⟨ cong (λ ρ₁ → ren ρ₁ t) (ridr _) ⟩
ren (wkr ρ) t ≡⟨ cong (λ ρ₁ → ren ρ₁ t) (cong wkr (sym (lidr _))) ⟩
ren (wkr (renComp renId ρ)) t ≡⟨ cong (λ ρ₁ → ren ρ₁ t) (sym (wkrcomp _ _)) ⟩
ren (renComp (wkr renId) ρ) t ≡⟨ rencomp _ _ _ ⟩
ren (wkr renId) (ren ρ t) ∎ where open ≡-Reasoning
-- Definitional equality is closed under renaming.
ren≡βη : ∀{Γ a} {t : Tm Γ a}{t' : Tm Γ a} → t ≡βη t' → ∀{Δ}(ρ : Ren Δ Γ) →
ren ρ t ≡βη ren ρ t'
ren≡βη (beta≡ {t = t}{u = u}) ρ = trans≡ beta≡ $ refl≡ _ $
trans (subren (subId , ren ρ u) (liftr ρ) t)
(trans (cong (λ xs → sub xs t)
(cong₂ Sub._,_
(trans (lemsr subId (ren ρ u) ρ)
(trans (sidl (ren2sub ρ)) (sym $ sidr (ren2sub ρ))))
(ren2subren ρ u)))
(sym $ rensub ρ (subId , u) t))
-- TODO: factor out reasoning about renamings and substitutions
ren≡βη (eta≡ {a} t) ρ rewrite ren-eta≡ t ρ = eta≡ (ren ρ t)
-- OLD:
-- ren≡βη (eta≡ t) ρ = trans≡
-- (abs≡ (app≡ (refl≡ _
-- (trans (sym $ rencomp (liftr ρ) (wkr renId) t)
-- (trans (cong (λ xs → ren xs t)
-- (trans (lemrr (wkr ρ) zero renId)
-- (trans (ridr (wkr ρ))
-- (trans (cong wkr (sym (lidr ρ)))
-- (sym (wkrcomp renId ρ))))))
-- (rencomp (wkr renId) ρ t))))
-- (refl≡ _)))
-- (eta≡ _)
ren≡βη (var≡ x) ρ = var≡ (lookr ρ x)
ren≡βη (abs≡ p) ρ = abs≡ (ren≡βη p (liftr ρ))
ren≡βη (app≡ p q) ρ = app≡ (ren≡βη p ρ) (ren≡βη q ρ)
ren≡βη (refl≡ _ refl) ρ = refl≡ _ refl
ren≡βη (sym≡ p) ρ = sym≡ (ren≡βη p ρ)
ren≡βη (trans≡ p q) ρ = trans≡ (ren≡βη p ρ) (ren≡βη q ρ)
| {
"alphanum_fraction": 0.412132753,
"avg_line_length": 31.4188034188,
"ext": "agda",
"hexsha": "263fc8ecf44c872e82c79ad6ff9e0664e0ce5974",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2018-02-23T18:22:17.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-11-10T16:44:52.000Z",
"max_forks_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2",
"max_forks_repo_licenses": [
"Unlicense"
],
"max_forks_repo_name": "ryanakca/strong-normalization",
"max_forks_repo_path": "agda/EquationalTheory.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2",
"max_issues_repo_issues_event_max_datetime": "2018-02-20T14:54:18.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-02-14T16:42:36.000Z",
"max_issues_repo_licenses": [
"Unlicense"
],
"max_issues_repo_name": "ryanakca/strong-normalization",
"max_issues_repo_path": "agda/EquationalTheory.agda",
"max_line_length": 98,
"max_stars_count": 32,
"max_stars_repo_head_hexsha": "79d97481f3312c2d30a823c3b1bcb8ae871c2fe2",
"max_stars_repo_licenses": [
"Unlicense"
],
"max_stars_repo_name": "ryanakca/strong-normalization",
"max_stars_repo_path": "agda/EquationalTheory.agda",
"max_stars_repo_stars_event_max_datetime": "2021-03-05T12:12:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-05-22T14:33:27.000Z",
"num_tokens": 1533,
"size": 3676
} |
open import Relation.Binary.Core
module InsertSort.Impl2.Correctness.Order {A : Set}
(_≤_ : A → A → Set)
(tot≤ : Total _≤_) where
open import Data.List
open import Function using (_∘_)
open import InsertSort.Impl2 _≤_ tot≤
open import List.Sorted _≤_
open import OList _≤_
open import OList.Properties _≤_
theorem-insertSort-sorted : (xs : List A) → Sorted (forget (insertSort xs))
theorem-insertSort-sorted = lemma-olist-sorted ∘ insertSort
| {
"alphanum_fraction": 0.6880165289,
"avg_line_length": 26.8888888889,
"ext": "agda",
"hexsha": "5c5eb1adf544eaccaed903f1de698fd789748710",
"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/Impl2/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/Impl2/Correctness/Order.agda",
"max_line_length": 75,
"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/Impl2/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": 138,
"size": 484
} |
{-# OPTIONS --prop #-}
open import Agda.Builtin.Nat
data T : Nat → Prop where
To : T zero
Tn : ∀ n → T n
ummm : ∀ n → T n → {! !}
ummm n t = {! t !}
| {
"alphanum_fraction": 0.4905660377,
"avg_line_length": 14.4545454545,
"ext": "agda",
"hexsha": "650a037cd0f99fa634297ebc535d99bad7f06882",
"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/Issue5210.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/Issue5210.agda",
"max_line_length": 28,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/interaction/Issue5210.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": 61,
"size": 159
} |
-- A variant of code reported by Andreas Abel.
{-# OPTIONS --guardedness --sized-types #-}
open import Common.Coinduction renaming (∞ to Delay)
open import Common.Size
open import Common.Product
data ⊥ : Set where
record Stream (A : Set) : Set where
inductive
constructor delay
field
force : Delay (A × Stream A)
open Stream
head : ∀{A} → Stream A → A
head s = proj₁ (♭ (force s))
-- This type should be empty, as Stream A is isomorphic to ℕ → A.
data D : (i : Size) → Set where
lim : ∀ i → Stream (D i) → D (↑ i)
-- Emptiness witness for D.
empty : ∀ i → D i → ⊥
empty .(↑ i) (lim i s) = empty i (head s)
-- BAD: But we can construct an inhabitant.
inh : Stream (D ∞)
inh = delay (♯ (lim ∞ inh , inh)) -- Should be rejected by termination checker.
absurd : ⊥
absurd = empty ∞ (lim ∞ inh)
| {
"alphanum_fraction": 0.6382716049,
"avg_line_length": 23.1428571429,
"ext": "agda",
"hexsha": "fbf2529caf66cd3a37c8e29c78b1428e1adc2d58",
"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/Issue1209-2.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue1209-2.agda",
"max_line_length": 79,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue1209-2.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 251,
"size": 810
} |
open import Oscar.Prelude
open import Oscar.Class
open import Oscar.Class.IsPrecategory
open import Oscar.Class.IsCategory
open import Oscar.Class.HasEquivalence
open import Oscar.Class.Reflexivity
open import Oscar.Class.Symmetry
open import Oscar.Class.Transextensionality
open import Oscar.Class.Transassociativity
open import Oscar.Class.Transleftidentity
open import Oscar.Class.Transrightidentity
open import Oscar.Class.Transitivity
open import Oscar.Class.Precategory
open import Oscar.Class.Category
open import Oscar.Property.Setoid.Proposequality
open import Oscar.Property.Setoid.Proposextensequality
open import Oscar.Data.Proposequality
import Oscar.Class.Reflexivity.Function
import Oscar.Class.Transextensionality.Proposequality
module Oscar.Property.Category.Function where
module _ {𝔬 : Ł} where
instance
TransitivityFunction : Transitivity.class Function⟦ 𝔬 ⟧
TransitivityFunction .⋆ f g = g ∘ f
module _ {𝔬 : Ł} where
instance
HasEquivalenceFunction : ∀ {A B : Ø 𝔬} → HasEquivalence (Function⟦ 𝔬 ⟧ A B) 𝔬
HasEquivalenceFunction .⋆ = _≡̇_
HasEquivalenceFunction .Rℭlass.⋆⋆ = !
instance
TransassociativityFunction : Transassociativity.class Function⟦ 𝔬 ⟧ _≡̇_ transitivity
TransassociativityFunction .⋆ _ _ _ _ = ∅
instance
𝓣ransextensionalityFunctionProposextensequality : Transextensionality.class Function⟦ 𝔬 ⟧ Proposextensequality transitivity
𝓣ransextensionalityFunctionProposextensequality .⋆ {f₂ = f₂} f₁≡̇f₂ g₁≡̇g₂ x rewrite f₁≡̇f₂ x = g₁≡̇g₂ (f₂ x)
instance
IsPrecategoryFunction : IsPrecategory Function⟦ 𝔬 ⟧ _≡̇_ transitivity
IsPrecategoryFunction = ∁
instance
TransleftidentityFunction : Transleftidentity.class Function⟦ 𝔬 ⟧ _≡̇_ ε transitivity
TransleftidentityFunction .⋆ _ = ∅
TransrightidentityFunction : Transrightidentity.class Function⟦ 𝔬 ⟧ _≡̇_ ε transitivity
TransrightidentityFunction .⋆ _ = ∅
instance
IsCategoryFunction : IsCategory Function⟦ 𝔬 ⟧ _≡̇_ ε transitivity
IsCategoryFunction = ∁
PrecategoryFunction : Precategory _ _ _
PrecategoryFunction = ∁ Function⟦ 𝔬 ⟧ Proposextensequality transitivity
CategoryFunction : Category _ _ _
CategoryFunction = ∁ Function⟦ 𝔬 ⟧ Proposextensequality ε transitivity
| {
"alphanum_fraction": 0.7801857585,
"avg_line_length": 31.4027777778,
"ext": "agda",
"hexsha": "3ab8115e5252a26b83382fbaf11a0c16caa3a3cd",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-3/src/Oscar/Property/Category/Function.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-3/src/Oscar/Property/Category/Function.agda",
"max_line_length": 127,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-3/src/Oscar/Property/Category/Function.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 679,
"size": 2261
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Floats
------------------------------------------------------------------------
module Data.Float where
open import Data.Bool hiding (_≟_)
open import Relation.Nullary.Decidable
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality as PropEq using (_≡_)
open import Relation.Binary.PropositionalEquality.TrustMe
open import Data.String using (String)
postulate
Float : Set
{-# BUILTIN FLOAT Float #-}
primitive
primFloatEquality : Float → Float → Bool
primShowFloat : Float → String
show : Float → String
show = primShowFloat
_≟_ : (x y : Float) → Dec (x ≡ y)
x ≟ y with primFloatEquality x y
... | true = yes trustMe
... | false = no whatever
where postulate whatever : _
| {
"alphanum_fraction": 0.6016949153,
"avg_line_length": 25.0303030303,
"ext": "agda",
"hexsha": "87162bde7b67c0e260dd8ad2f9c8ccbb1f01742c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "qwe2/try-agda",
"max_forks_repo_path": "agda-stdlib-0.9/src/Data/Float.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "qwe2/try-agda",
"max_issues_repo_path": "agda-stdlib-0.9/src/Data/Float.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "qwe2/try-agda",
"max_stars_repo_path": "agda-stdlib-0.9/src/Data/Float.agda",
"max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z",
"num_tokens": 182,
"size": 826
} |
module Issue2447.Type-error where
import Issue2447.M
Rejected : Set
Rejected = Set
| {
"alphanum_fraction": 0.7882352941,
"avg_line_length": 12.1428571429,
"ext": "agda",
"hexsha": "fbca91b19494673ce5339919637198b2f6106440",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/interaction/Issue2447/Type-error.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/interaction/Issue2447/Type-error.agda",
"max_line_length": 33,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/interaction/Issue2447/Type-error.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": 22,
"size": 85
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import Groups.Homomorphisms.Definition
open import Groups.Definition
open import Setoids.Setoids
open import Rings.Definition
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
module Rings.Homomorphisms.Definition where
record RingHom {m n o p : _} {A : Set m} {B : Set n} {SA : Setoid {m} {o} A} {SB : Setoid {n} {p} B} {_+A_ : A → A → A} {_*A_ : A → A → A} (R : Ring SA _+A_ _*A_) {_+B_ : B → B → B} {_*B_ : B → B → B} (S : Ring SB _+B_ _*B_) (f : A → B) : Set (m ⊔ n ⊔ o ⊔ p) where
open Ring S
open Group additiveGroup
open Setoid SB
field
preserves1 : f (Ring.1R R) ∼ 1R
ringHom : {r s : A} → f (r *A s) ∼ (f r) *B (f s)
groupHom : GroupHom (Ring.additiveGroup R) additiveGroup f
| {
"alphanum_fraction": 0.6183699871,
"avg_line_length": 38.65,
"ext": "agda",
"hexsha": "e4bb44a362e1ccf19150471837f9ad5fba15ed60",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Rings/Homomorphisms/Definition.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Rings/Homomorphisms/Definition.agda",
"max_line_length": 264,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Rings/Homomorphisms/Definition.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z",
"num_tokens": 302,
"size": 773
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Relation.Binary.Base where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.Fiberwise
open import Cubical.Data.Sigma
open import Cubical.HITs.SetQuotients.Base
open import Cubical.HITs.PropositionalTruncation.Base
private
variable
ℓA ℓ≅A ℓA' ℓ≅A' : Level
Rel : ∀ {ℓ} (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))
Rel A B ℓ' = A → B → Type ℓ'
PropRel : ∀ {ℓ} (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))
PropRel A B ℓ' = Σ[ R ∈ Rel A B ℓ' ] ∀ a b → isProp (R a b)
idPropRel : ∀ {ℓ} (A : Type ℓ) → PropRel A A ℓ
idPropRel A .fst a a' = ∥ a ≡ a' ∥
idPropRel A .snd _ _ = squash
invPropRel : ∀ {ℓ ℓ'} {A B : Type ℓ}
→ PropRel A B ℓ' → PropRel B A ℓ'
invPropRel R .fst b a = R .fst a b
invPropRel R .snd b a = R .snd a b
compPropRel : ∀ {ℓ ℓ' ℓ''} {A B C : Type ℓ}
→ PropRel A B ℓ' → PropRel B C ℓ'' → PropRel A C (ℓ-max ℓ (ℓ-max ℓ' ℓ''))
compPropRel R S .fst a c = ∥ Σ[ b ∈ _ ] (R .fst a b × S .fst b c) ∥
compPropRel R S .snd _ _ = squash
graphRel : ∀ {ℓ} {A B : Type ℓ} → (A → B) → Rel A B ℓ
graphRel f a b = f a ≡ b
module BinaryRelation {ℓ ℓ' : Level} {A : Type ℓ} (R : Rel A A ℓ') where
isRefl : Type (ℓ-max ℓ ℓ')
isRefl = (a : A) → R a a
isSym : Type (ℓ-max ℓ ℓ')
isSym = (a b : A) → R a b → R b a
isTrans : Type (ℓ-max ℓ ℓ')
isTrans = (a b c : A) → R a b → R b c → R a c
record isEquivRel : Type (ℓ-max ℓ ℓ') where
constructor equivRel
field
reflexive : isRefl
symmetric : isSym
transitive : isTrans
isPropValued : Type (ℓ-max ℓ ℓ')
isPropValued = (a b : A) → isProp (R a b)
isEffective : Type (ℓ-max ℓ ℓ')
isEffective =
(a b : A) → isEquiv (eq/ {R = R} a b)
impliesIdentity : Type _
impliesIdentity = {a a' : A} → (R a a') → (a ≡ a')
-- the total space corresponding to the binary relation w.r.t. a
relSinglAt : (a : A) → Type (ℓ-max ℓ ℓ')
relSinglAt a = Σ[ a' ∈ A ] (R a a')
-- the statement that the total space is contractible at any a
contrRelSingl : Type (ℓ-max ℓ ℓ')
contrRelSingl = (a : A) → isContr (relSinglAt a)
isUnivalent : Type (ℓ-max ℓ ℓ')
isUnivalent = (a a' : A) → (R a a') ≃ (a ≡ a')
contrRelSingl→isUnivalent : isRefl → contrRelSingl → isUnivalent
contrRelSingl→isUnivalent ρ c a a' = isoToEquiv i
where
h : isProp (relSinglAt a)
h = isContr→isProp (c a)
aρa : relSinglAt a
aρa = a , ρ a
Q : (y : A) → a ≡ y → _
Q y _ = R a y
i : Iso (R a a') (a ≡ a')
Iso.fun i r = cong fst (h aρa (a' , r))
Iso.inv i = J Q (ρ a)
Iso.rightInv i = J (λ y p → cong fst (h aρa (y , J Q (ρ a) p)) ≡ p)
(J (λ q _ → cong fst (h aρa (a , q)) ≡ refl)
(J (λ α _ → cong fst α ≡ refl) refl
(isContr→isProp (isProp→isContrPath h aρa aρa) refl (h aρa aρa)))
(sym (JRefl Q (ρ a))))
Iso.leftInv i r = J (λ w β → J Q (ρ a) (cong fst β) ≡ snd w)
(JRefl Q (ρ a)) (h aρa (a' , r))
isUnivalent→contrRelSingl : isUnivalent → contrRelSingl
isUnivalent→contrRelSingl u a = q
where
abstract
f : (x : A) → a ≡ x → R a x
f x p = invEq (u a x) p
t : singl a → relSinglAt a
t (x , p) = x , f x p
q : isContr (relSinglAt a)
q = isOfHLevelRespectEquiv 0 (t , totalEquiv _ _ f λ x → invEquiv (u a x) .snd)
(isContrSingl a)
EquivRel : ∀ {ℓ} (A : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))
EquivRel A ℓ' = Σ[ R ∈ Rel A A ℓ' ] BinaryRelation.isEquivRel R
EquivPropRel : ∀ {ℓ} (A : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))
EquivPropRel A ℓ' = Σ[ R ∈ PropRel A A ℓ' ] BinaryRelation.isEquivRel (R .fst)
record RelIso {A : Type ℓA} (_≅_ : Rel A A ℓ≅A)
{A' : Type ℓA'} (_≅'_ : Rel A' A' ℓ≅A') : Type (ℓ-max (ℓ-max ℓA ℓA') (ℓ-max ℓ≅A ℓ≅A')) where
constructor reliso
field
fun : A → A'
inv : A' → A
rightInv : (a' : A') → fun (inv a') ≅' a'
leftInv : (a : A) → inv (fun a) ≅ a
open BinaryRelation
RelIso→Iso : {A : Type ℓA} {A' : Type ℓA'}
(_≅_ : Rel A A ℓ≅A) (_≅'_ : Rel A' A' ℓ≅A')
(uni : impliesIdentity _≅_) (uni' : impliesIdentity _≅'_)
(f : RelIso _≅_ _≅'_)
→ Iso A A'
Iso.fun (RelIso→Iso _ _ _ _ f) = RelIso.fun f
Iso.inv (RelIso→Iso _ _ _ _ f) = RelIso.inv f
Iso.rightInv (RelIso→Iso _ _ uni uni' f) a'
= uni' (RelIso.rightInv f a')
Iso.leftInv (RelIso→Iso _ _ uni uni' f) a
= uni (RelIso.leftInv f a)
| {
"alphanum_fraction": 0.5508279187,
"avg_line_length": 33.3636363636,
"ext": "agda",
"hexsha": "b2e98004c8174b70a322ee8e4c597713e33b68e8",
"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": "60226aacd7b386aef95d43a0c29c4eec996348a8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "L-TChen/cubical",
"max_forks_repo_path": "Cubical/Relation/Binary/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "60226aacd7b386aef95d43a0c29c4eec996348a8",
"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": "L-TChen/cubical",
"max_issues_repo_path": "Cubical/Relation/Binary/Base.agda",
"max_line_length": 106,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "60226aacd7b386aef95d43a0c29c4eec996348a8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "L-TChen/cubical",
"max_stars_repo_path": "Cubical/Relation/Binary/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1950,
"size": 4771
} |
module Thesis.SIRelBigStep.Types where
open import Data.Empty
open import Data.Product
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality
open import Relation.Binary hiding (_⇒_)
data Type : Set where
_⇒_ : (σ τ : Type) → Type
pair : (σ τ : Type) → Type
nat : Type
infixr 20 _⇒_
open import Base.Syntax.Context Type public
open import Base.Syntax.Vars Type public
-- Decidable equivalence for types and contexts. Needed later for ⊕ on closures.
⇒-inj : ∀ {τ1 τ2 τ3 τ4 : Type} → _≡_ {A = Type} (τ1 ⇒ τ2) (τ3 ⇒ τ4) → τ1 ≡ τ3 × τ2 ≡ τ4
⇒-inj refl = refl , refl
pair-inj : ∀ {τ1 τ2 τ3 τ4 : Type} → _≡_ {A = Type} (pair τ1 τ2) (pair τ3 τ4) → τ1 ≡ τ3 × τ2 ≡ τ4
pair-inj refl = refl , refl
_≟Type_ : (τ1 τ2 : Type) → Dec (τ1 ≡ τ2)
(τ1 ⇒ τ2) ≟Type (τ3 ⇒ τ4) with τ1 ≟Type τ3 | τ2 ≟Type τ4
(τ1 ⇒ τ2) ≟Type (.τ1 ⇒ .τ2) | yes refl | yes refl = yes refl
(τ1 ⇒ τ2) ≟Type (.τ1 ⇒ τ4) | yes refl | no ¬q = no (λ x → ¬q (proj₂ (⇒-inj x)))
(τ1 ⇒ τ2) ≟Type (τ3 ⇒ τ4) | no ¬p | q = no (λ x → ¬p (proj₁ (⇒-inj x)))
(τ1 ⇒ τ2) ≟Type pair τ3 τ4 = no (λ ())
(τ1 ⇒ τ2) ≟Type nat = no (λ ())
pair τ1 τ2 ≟Type (τ3 ⇒ τ4) = no (λ ())
pair τ1 τ2 ≟Type pair τ3 τ4 with τ1 ≟Type τ3 | τ2 ≟Type τ4
pair τ1 τ2 ≟Type pair .τ1 .τ2 | yes refl | yes refl = yes refl
pair τ1 τ2 ≟Type pair τ3 τ4 | yes p | no ¬q = no (λ x → ¬q (proj₂ (pair-inj x)))
pair τ1 τ2 ≟Type pair τ3 τ4 | no ¬p | q = no (λ x → ¬p (proj₁ (pair-inj x)))
pair τ1 τ2 ≟Type nat = no (λ ())
nat ≟Type pair τ1 τ2 = no (λ ())
nat ≟Type (τ1 ⇒ τ2) = no (λ ())
nat ≟Type nat = yes refl
•-inj : ∀ {τ1 τ2 : Type} {Γ1 Γ2 : Context} → _≡_ {A = Context} (τ1 • Γ1) (τ2 • Γ2) → τ1 ≡ τ2 × Γ1 ≡ Γ2
•-inj refl = refl , refl
_≟Ctx_ : (Γ1 Γ2 : Context) → Dec (Γ1 ≡ Γ2)
∅ ≟Ctx ∅ = yes refl
∅ ≟Ctx (τ2 • Γ2) = no (λ ())
(τ1 • Γ1) ≟Ctx ∅ = no (λ ())
(τ1 • Γ1) ≟Ctx (τ2 • Γ2) with τ1 ≟Type τ2 | Γ1 ≟Ctx Γ2
(τ1 • Γ1) ≟Ctx (.τ1 • .Γ1) | yes refl | yes refl = yes refl
(τ1 • Γ1) ≟Ctx (.τ1 • Γ2) | yes refl | no ¬q = no (λ x → ¬q (proj₂ (•-inj x)))
(τ1 • Γ1) ≟Ctx (τ2 • Γ2) | no ¬p | q = no (λ x → ¬p (proj₁ (•-inj x)))
≟Ctx-refl : ∀ Γ → Γ ≟Ctx Γ ≡ yes refl
≟Ctx-refl Γ with Γ ≟Ctx Γ
≟Ctx-refl Γ | yes refl = refl
≟Ctx-refl Γ | no ¬p = ⊥-elim (¬p refl)
| {
"alphanum_fraction": 0.567788899,
"avg_line_length": 37.2542372881,
"ext": "agda",
"hexsha": "cd464dcb127572be89b31bae44b356451ac42be5",
"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": "Thesis/SIRelBigStep/Types.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": "Thesis/SIRelBigStep/Types.agda",
"max_line_length": 102,
"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": "Thesis/SIRelBigStep/Types.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": 1028,
"size": 2198
} |
module MLib.Prelude where
open import MLib.Prelude.FromStdlib public
module Fin where
open import MLib.Prelude.Fin public
open Fin using (Fin; zero; suc) hiding (module Fin) public
| {
"alphanum_fraction": 0.7891891892,
"avg_line_length": 23.125,
"ext": "agda",
"hexsha": "b2a0e872289d45d72e86ef156b053f2d645a144b",
"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": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "bch29/agda-matrices",
"max_forks_repo_path": "src/MLib/Prelude.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"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": "bch29/agda-matrices",
"max_issues_repo_path": "src/MLib/Prelude.agda",
"max_line_length": 58,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e26ae2e0aa7721cb89865aae78625a2f3fd2b574",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "bch29/agda-matrices",
"max_stars_repo_path": "src/MLib/Prelude.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 50,
"size": 185
} |
open import Agda.Builtin.Nat
data Vec (A : Set) : Nat → Set where
[] : Vec A 0
_∷_ : ∀ {n} → A → Vec A n → Vec A (suc n)
infixr 5 _∷_ _++_
_++_ : ∀ {A m n} → Vec A m → Vec A n → Vec A (m + n)
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ xs ++ ys
T : ∀ {A n} → Vec A n → Set
T [] = Nat
T (x ∷ xs) = Vec Nat 0
foo : ∀ {A} m n (xs : Vec A m) (ys : Vec A n) → T (xs ++ ys)
foo m n xs ys with {m + n} | xs ++ ys
... | [] = 0
... | z ∷ zs = []
| {
"alphanum_fraction": 0.4196428571,
"avg_line_length": 21.3333333333,
"ext": "agda",
"hexsha": "e142ead3221da25efb4883bdee2b837221c91c17",
"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/Issue500.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/Issue500.agda",
"max_line_length": 60,
"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/Issue500.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": 208,
"size": 448
} |
module HelloWorld where
open import Common.IO
open import Common.Unit
main : IO Unit
main = putStr "Hello World"
| {
"alphanum_fraction": 0.7739130435,
"avg_line_length": 14.375,
"ext": "agda",
"hexsha": "91635498ed30afd8cd14b790de7b1f6fc8e6832b",
"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/Compiler/simple/HelloWorld.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/Compiler/simple/HelloWorld.agda",
"max_line_length": 27,
"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/Compiler/simple/HelloWorld.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": 27,
"size": 115
} |
open import Agda.Builtin.Equality
data D (A : Set) : Set where
{-# INJECTIVE D #-}
test : {A₁ A₂ : Set} → D A₁ ≡ D A₂ → A₁ ≡ A₂
test refl = refl
postulate f : Set → Set
{-# INJECTIVE f #-}
test₂ : {A₁ A₂ : Set} → f A₁ ≡ f A₂ → A₁ ≡ A₂
test₂ refl = refl
| {
"alphanum_fraction": 0.5769230769,
"avg_line_length": 15.2941176471,
"ext": "agda",
"hexsha": "d81e6b612bf280a399d9536a2498ee52da4f749a",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/Succeed/InjectivePragma.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/Succeed/InjectivePragma.agda",
"max_line_length": 45,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/Succeed/InjectivePragma.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": 107,
"size": 260
} |
module Avionics.Bool where
open import Data.Bool using (Bool; true; false; _∧_; T)
open import Data.Unit using (⊤; tt)
open import Data.Product using (_×_; _,_)
open import Relation.Binary.PropositionalEquality using (_≡_; refl; inspect; [_])
--open import Avionics.Product using (_×_; ⟨_,_⟩)
--TODO: Replace with T⇔≡ from standard library
≡→T : ∀ {b : Bool} → b ≡ true → T b
≡→T refl = tt
T→≡ : ∀ {b : Bool} → T b → b ≡ true
T→≡ {true} tt = refl
T∧→× : ∀ {x y} → T (x ∧ y) → (T x) × (T y)
T∧→× {true} {true} tt = tt , tt
--TODO: Find a way to extract the function below from `T-∧` (standard library)
--T∧→× {x} {y} = ? -- Equivalence.to (T-∧ {x} {y})
×→T∧ : ∀ {x y} → (T x) × (T y) → T (x ∧ y)
×→T∧ {true} {true} (tt , tt) = tt
lem∧ : {a b : Bool} → a ∧ b ≡ true → a ≡ true × b ≡ true
lem∧ {true} {true} refl = refl , refl
∧≡true→×≡ : ∀ {A B : Set} {f : A → Bool} {g : B → Bool}
(n : A) (m : B)
→ f n ∧ g m ≡ true
→ f n ≡ true × g m ≡ true
∧≡true→×≡ {f = f} {g = g} n m fn∧gm≡true = lem∧ {f n} {g m} fn∧gm≡true
| {
"alphanum_fraction": 0.5185185185,
"avg_line_length": 30.9705882353,
"ext": "agda",
"hexsha": "4e96c41f120683694c7efdefa75ed0795efc33ef",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2020-09-20T00:36:09.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-09-20T00:36:09.000Z",
"max_forks_repo_head_hexsha": "896e67a2ad21041a1c9ef5f3ad6318c67d730341",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "RPI-WCL/safety-envelopes-sentinels",
"max_forks_repo_path": "agda/Avionics/Bool.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "896e67a2ad21041a1c9ef5f3ad6318c67d730341",
"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": "RPI-WCL/safety-envelopes-sentinels",
"max_issues_repo_path": "agda/Avionics/Bool.agda",
"max_line_length": 81,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "896e67a2ad21041a1c9ef5f3ad6318c67d730341",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "RPI-WCL/safety-envelopes-sentinels",
"max_stars_repo_path": "agda/Avionics/Bool.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 457,
"size": 1053
} |
{-# OPTIONS --universe-polymorphism #-}
open import Level
open import Categories.Category
module Categories.Power.Functorial {o ℓ e : Level} (C : Category o ℓ e) where
open import Relation.Binary.PropositionalEquality using (≡-irrelevance)
open import Data.Unit using (⊤; tt)
open import Function using () renaming (_∘_ to _∙_)
open import Relation.Binary using (module IsEquivalence)
open import Categories.Support.PropositionalEquality
import Categories.Power as Power
open Power C
open import Categories.Functor hiding (identityˡ) renaming (_≡_ to _≡F_; _∘_ to _∘F_; id to idF)
open import Categories.NaturalTransformation using (NaturalTransformation; module NaturalTransformation)
open import Categories.Discrete
open import Categories.Equivalence.Strong hiding (module Equiv)
open Category using (Obj)
open Category C using (_⇒_; _∘_; _≡_; module Equiv)
open import Categories.FunctorCategory
open import Categories.Lift
open import Categories.NaturalIsomorphism as NI using (NaturalIsomorphism; module NaturalIsomorphism)
open Functor using () renaming (F₀ to map₀; F₁ to map₁)
open NaturalTransformation using (η)
z : Level
z = o ⊔ ℓ ⊔ e
open import Categories.Categories using (Categories)
import Categories.Morphisms as M
open M (Categories z z e) using (_≅_)
exp→functor₀ : ∀ {I} → Obj (Exp I) → Functor (Discrete I) C
exp→functor₀ X =
record
{ F₀ = X
; F₁ = my-F₁
; identity = Equiv.refl
; homomorphism = λ {_ _ _ A≣B B≣C} → my-homomorphism A≣B B≣C
; F-resp-≡ = λ {_ _ e1 e2} _ → Equiv.reflexive (≣-cong my-F₁ (≡-irrelevance e1 e2))
}
where
my-F₁ : ∀ {A B} → (A ≣ B) → (X A ⇒ X B)
my-F₁ ≣-refl = C.id
.my-homomorphism : ∀ {A B C} (A≣B : A ≣ B) (B≣C : B ≣ C) → my-F₁ (≣-trans A≣B B≣C) ≡ my-F₁ B≣C ∘ my-F₁ A≣B
my-homomorphism ≣-refl ≣-refl = Equiv.sym C.identityˡ
exp→functor₁ : ∀ {I} {X Y} → Exp I [ X , Y ] → NaturalTransformation (exp→functor₀ X) (exp→functor₀ Y)
exp→functor₁ {X = X} {Y} F = record { η = F; commute = my-commute }
where
.my-commute : ∀ {A B} (A≣B : A ≣ B) → F B ∘ map₁ (exp→functor₀ X) A≣B ≡ map₁ (exp→functor₀ Y) A≣B ∘ F A
my-commute ≣-refl = Equiv.trans C.identityʳ (Equiv.sym C.identityˡ)
exp→functor : ∀ {I} → Functor (Exp I) (Functors (Discrete I) C)
exp→functor =
record
{ F₀ = exp→functor₀
; F₁ = exp→functor₁
; identity = Equiv.refl
; homomorphism = Equiv.refl
; F-resp-≡ = λ eqs {x} → eqs x
}
functor→exp : ∀ {I} → Functor (Functors (Discrete I) C) (Exp I)
functor→exp =
record
{ F₀ = Functor.F₀
; F₁ = NaturalTransformation.η
; identity = λ _ → Equiv.refl
; homomorphism = λ _ → Equiv.refl
; F-resp-≡ = λ eqs i → eqs {i}
}
semicanonical : ∀ {I} → (F : Functor (Discrete I) C) → F ≡F (exp→functor₀ (map₀ F))
semicanonical {I} F ≣-refl = ≡⇒∼ F.identity
where
module F = Functor F
open Heterogeneous C
exp≋functor : ∀ {I} → StrongEquivalence (Exp I) (Functors (Discrete I) C)
exp≋functor {I} = record
{ F = exp→functor
; G = functor→exp
; weak-inverse = record
{ F∘G≅id = record
{ F⇒G = record
{ η = Sc.F⇐G
; commute = λ f → Equiv.trans C.identityˡ (Equiv.sym C.identityʳ)
}
; F⇐G = record
{ η = Sc.F⇒G
; commute = λ f → Equiv.trans C.identityˡ (Equiv.sym C.identityʳ)
}
; iso = λ X → record { isoˡ = C.identityˡ; isoʳ = C.identityˡ }
}
; G∘F≅id = IsEquivalence.refl NI.equiv
}
}
where
FDIC = Functors (Discrete I) C
module Sc (X : Obj FDIC) = NaturalIsomorphism (NI.≡→iso X (exp→functor₀ (map₀ X)) (semicanonical X))
exp≅functor : (ext : ∀ {a b} {A : Set a} {B : A → Set b} (f g : (x : A) → B x) → (∀ x → f x ≣ g x) → f ≣ g) → (id-propositionally-unique : (A : C.Obj) (f : A ⇒ A) → .(f ≡ C.id) → f ≣ C.id) → ∀ {I} → LiftC z z e (Exp I) ≅ Functors (Discrete I) C
exp≅functor ext id-propositionally-unique {I} =
record
{ f = LiftFˡ exp→functor
; g = LiftFʳ functor→exp
; iso = record
{ isoˡ = λ f → Heterogeneous.refl _
; isoʳ = λ {A B} f → ir A B f
}
}
where
FDIC = Functors (Discrete I) C
f∘g = LiftFˡ exp→functor ∘F LiftFʳ functor→exp
squash : ∀ (A : Obj FDIC) → Obj FDIC
squash A = exp→functor₀ (map₀ A)
≣-cong′ : ∀ {a b} {A : Set a} {B : Set b} {x y : A} (f : (z : A) → (y ≣ z) → B) → (eq : x ≣ y) → f x (≣-sym eq) ≣ f y ≣-refl
≣-cong′ f ≣-refl = ≣-refl
squash-does-nothing : (A : Obj FDIC) → squash A ≣ A
squash-does-nothing A = ≣-cong′ {B = Obj FDIC} (λ f eq → record {
F₀ = map₀ A;
F₁ = λ {i j : I} → f i j;
identity = λ {i} → ≣-subst (λ f → f i i ≣-refl ≡ C.id) eq (Functor.identity A {i});
homomorphism = λ {i j k i≣j j≣k} → ≣-subst (λ f → f i k (≣-trans i≣j j≣k) ≡ f j k j≣k ∘ f i j i≣j) eq (Functor.homomorphism A {f = i≣j} {j≣k});
F-resp-≡ = λ {i j ij ji} → ≣-subst (λ f → ⊤ → f i j ij ≡ f i j ji) eq (Functor.F-resp-≡ A {i} {j} {ij} {ji}) })
lemma₃
where
.lemma₁ : (i : I) (eq : i ≣ i) → map₁ A eq ≡ C.id
lemma₁ i eq = Equiv.trans (Functor.F-resp-≡ A tt) (Functor.identity A)
lemma₂ : (i j : I) (eq : i ≣ j) → map₁ (squash A) eq ≣ map₁ A eq
lemma₂ i .i ≣-refl = ≣-sym (id-propositionally-unique (map₀ A i) (map₁ A ≣-refl) (lemma₁ i ≣-refl))
lemma₃ : (λ (i j : I) → map₁ (squash A) {i} {j}) ≣ (λ (i j : I) → map₁ A {i} {j})
lemma₃ = ext (λ (i j : I) → map₁ (squash A)) (λ (i j : I) → map₁ A)
(λ (i : I) → ext (λ (j : I) → map₁ (squash A)) (λ (j : I) → map₁ A)
(λ (j : I) → ext (map₁ (squash A)) (map₁ A) (lemma₂ i j)))
∼-subst : ∀ {o ℓ e} {C : Category o ℓ e} {A B A′ B′ : Obj C} (f : C [ A , B ]) (g : C [ A′ , B′ ]) (A′≣A : A′ ≣ A) (B′≣B : B′ ≣ B) → .(C [ ≣-subst (λ X → C [ X , B ]) A′≣A (≣-subst (λ Y → C [ A′ , Y ]) B′≣B g) ≡ f ]) → C [ g ∼ f ]
∼-subst {C = C} f g ≣-refl ≣-refl eq = ≡⇒∼ eq
where open Heterogeneous C
.∼-unsubst : ∀ {o ℓ e} {C : Category o ℓ e} {A B A′ B′ : Obj C} (f : C [ A , B ]) (g : C [ A′ , B′ ]) (A′≣A : A′ ≣ A) (B′≣B : B′ ≣ B) → C [ g ∼ f ] → C [ ≣-subst (λ X → C [ X , B ]) A′≣A (≣-subst (λ Y → C [ A′ , Y ]) B′≣B g) ≡ f ]
∼-unsubst f g ≣-refl ≣-refl (Heterogeneous.≡⇒∼ eq) = irr eq
where open Heterogeneous C
≣-subst-irrel : ∀ {a p} {A : Set a} (P : A → Set p) {x y : A} → (eq₁ eq₂ : x ≣ y) → ∀ {it} → ≣-subst P eq₁ it ≣ ≣-subst P eq₂ it
≣-subst-irrel _ ≣-refl ≣-refl = ≣-refl
≣-subst-cong : ∀ {a a′ p} {A : Set a} {A′ : Set a′} (P′ : A′ → Set p) (f : A → A′) {x y : A} (eq : x ≣ y) → ∀ {it} → ≣-subst (P′ ∙ f) eq it ≣ ≣-subst P′ (≣-cong f eq) it
≣-subst-cong P′ f ≣-refl = ≣-refl
≣-subst-fatten : ∀ {a a′ p} {A : Set a} {A′ : Set a′} (P′ : A′ → Set p) (f : A → A′) {x y : A} (eq : x ≣ y) (eq′ : f x ≣ f y) → ∀ {it} → ≣-subst (P′ ∙ f) eq it ≣ ≣-subst P′ eq′ it
≣-subst-fatten P′ f eq eq′ = ≣-trans (≣-subst-cong P′ f eq) (≣-subst-irrel P′ (≣-cong f eq) eq′)
η-under-substˡ : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {F F′ G : Functor C D} (α : NaturalTransformation F′ G) (F′≣F : F′ ≣ F) (c : Obj C) → η (≣-subst (λ H → NaturalTransformation H G) F′≣F α) c ≣ (≣-subst (λ (H : Functor C D) → D [ map₀ H c , map₀ G c ]) F′≣F (η α c))
η-under-substˡ α ≣-refl c = ≣-refl
η-under-substʳ : ∀ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {F G G′ : Functor C D} (α : NaturalTransformation F G′) (G′≣G : G′ ≣ G) (c : Obj C) → η (≣-subst (λ H → NaturalTransformation F H) G′≣G α) c ≣ (≣-subst (λ (H : Functor C D) → D [ map₀ F c , map₀ H c ]) G′≣G (η α c))
η-under-substʳ α ≣-refl c = ≣-refl
.lemma : (A B : Obj FDIC) (f : FDIC [ A , B ]) (i : I) → C [ η (≣-subst (λ X → FDIC [ X , B ]) (squash-does-nothing A) (≣-subst (λ Y → FDIC [ squash A , Y ]) (squash-does-nothing B) (map₁ f∘g f))) i ≡ η f i ]
lemma A B f i =
let loc X = map₀ X i in
let sqdnA = squash-does-nothing A in
let sqdnB = squash-does-nothing B in
let MESS = ≣-subst (λ Y → FDIC [ squash A , Y ]) sqdnB (map₁ f∘g f) in
C.Equiv.reflexive (
begin
η (≣-subst (λ X → FDIC [ X , B ]) sqdnA MESS) i
≣⟨ η-under-substˡ MESS sqdnA i ⟩
≣-subst (λ X → C [ loc X , loc B ]) sqdnA (η MESS i)
≣⟨ ≣-subst-fatten (λ c → C [ c , loc B ]) loc sqdnA ≣-refl ⟩
η (≣-subst (λ Y → FDIC [ squash A , Y ]) sqdnB (map₁ f∘g f)) i
≣⟨ η-under-substʳ (map₁ f∘g f) sqdnB i ⟩
≣-subst (λ Y → C [ loc A , loc Y ]) sqdnB (η (map₁ f∘g f) i)
≣⟨ ≣-subst-fatten (λ c → C [ loc A , c ]) loc sqdnB ≣-refl ⟩
η f i
∎)
where
open ≣-reasoning
ir : (A B : Obj FDIC) (f : FDIC [ A , B ]) → FDIC [ map₁ f∘g f ∼ f ]
ir A B f = ∼-subst {C = FDIC} f (map₁ f∘g f) (squash-does-nothing A) (squash-does-nothing B) (λ {x} → lemma A B f x)
| {
"alphanum_fraction": 0.5438436035,
"avg_line_length": 45.7958115183,
"ext": "agda",
"hexsha": "74bd3108b09b0bdc7f2ac3e6451618d904f28474",
"lang": "Agda",
"max_forks_count": 23,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z",
"max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "p-pavel/categories",
"max_forks_repo_path": "Categories/Power/Functorial.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "p-pavel/categories",
"max_issues_repo_path": "Categories/Power/Functorial.agda",
"max_line_length": 298,
"max_stars_count": 98,
"max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "copumpkin/categories",
"max_stars_repo_path": "Categories/Power/Functorial.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z",
"num_tokens": 3858,
"size": 8747
} |
{-# OPTIONS --without-K --exact-split --allow-unsolved-metas #-}
module 16-sets where
import 15-number-theory
open 15-number-theory public
| {
"alphanum_fraction": 0.7375886525,
"avg_line_length": 20.1428571429,
"ext": "agda",
"hexsha": "40246e32e45aa0e16e967e48d4c14c3ba2ed2fe9",
"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/16-sets.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/16-sets.agda",
"max_line_length": 64,
"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/16-sets.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 38,
"size": 141
} |
module examplesPaperJFP.ConsoleInterface where
open import examplesPaperJFP.NativeIOSafe
open import examplesPaperJFP.BasicIO hiding (main)
module _ where
data ConsoleCommand : Set where
getLine : ConsoleCommand
putStrLn : String → ConsoleCommand
ConsoleResponse : ConsoleCommand → Set
ConsoleResponse getLine = Maybe String
ConsoleResponse (putStrLn s) = Unit
ConsoleInterface : IOInterface
Command ConsoleInterface = ConsoleCommand
Response ConsoleInterface = ConsoleResponse
| {
"alphanum_fraction": 0.7752380952,
"avg_line_length": 29.1666666667,
"ext": "agda",
"hexsha": "9c9fda60d0d4f9c255fce95352433d32c36ba81e",
"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": "examples/examplesPaperJFP/ConsoleInterface.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": "examples/examplesPaperJFP/ConsoleInterface.agda",
"max_line_length": 50,
"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": "examples/examplesPaperJFP/ConsoleInterface.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": 125,
"size": 525
} |
------------------------------------------------------------------------
-- A variant of the set quotients from Quotient
------------------------------------------------------------------------
{-# OPTIONS --erased-cubical --safe #-}
-- Partly following the HoTT book.
--
-- Unlike the HoTT book, but following the cubical library (in which
-- set quotients were implemented by Zesen Qian and Anders Mörtberg),
-- the quotienting relations are not always required to be
-- propositional. Furthermore, unlike the code in the cubical library,
-- the set truncation constructor takes an argument stating that the
-- quotienting relation is propositional.
-- The module is parametrised by a notion of equality. The higher
-- constructors of the HIT defining quotients use path equality, but
-- the supplied notion of equality is used for many other things.
import Equality.Path as P
module Quotient.Set-truncated-if-propositional
{e⁺} (eq : ∀ {a p} → P.Equality-with-paths a p e⁺) where
private
open module D = P.Derived-definitions-and-properties eq hiding (elim)
open import Logical-equivalence using (_⇔_)
open import Prelude
open import Bijection equality-with-J using (_↔_)
open import Equality.Decidable-UIP equality-with-J
open import Equality.Path.Isomorphisms eq
open import Equivalence equality-with-J as Eq using (_≃_)
open import Equivalence-relation equality-with-J
open import Function-universe equality-with-J as F hiding (_∘_; id)
open import H-level equality-with-J as H
import H-level P.equality-with-J as PH
open import H-level.Closure equality-with-J
import H-level.Truncation.Church equality-with-J as Trunc
open import H-level.Truncation.Propositional eq as TruncP
using (∥_∥; ∣_∣; Surjective; Axiom-of-countable-choice)
open import Preimage equality-with-J using (_⁻¹_)
import Quotient eq as Quotient
import Quotient.Families-of-equivalence-classes equality-with-J as QF
open import Sum equality-with-J
open import Surjection equality-with-J using (_↠_)
open import Univalence-axiom equality-with-J
private
variable
a a₁ a₂ b p : Level
k : Isomorphism-kind
A A₁ A₂ B : Type a
P : A → Type p
e f r r₁ r₂ x y : A
R R₁ R₂ : A → A → Type r
------------------------------------------------------------------------
-- Quotients
-- The quotient type constructor.
infix 5 _/_
data _/_ (A : Type a) (R : A → A → Type r) : Type (a ⊔ r) where
[_] : A → A / R
[]-respects-relationᴾ : R x y → [ x ] P.≡ [ y ]
/-is-setᴾ : (∀ x y → Is-proposition (R x y)) →
P.Is-set (A / R)
-- [_] respects the quotient relation.
[]-respects-relation : R x y → _≡_ {A = A / R} [ x ] [ y ]
[]-respects-relation = _↔_.from ≡↔≡ ∘ []-respects-relationᴾ
-- If R is pointwise propositional, then A / R is a set.
/-is-set : (∀ x y → Is-proposition (R x y)) → Is-set (A / R)
/-is-set = _↔_.from (H-level↔H-level 2) ∘ /-is-setᴾ
------------------------------------------------------------------------
-- Eliminators
-- An eliminator, expressed using paths.
record Elimᴾ′ {A : Type a} {R : A → A → Type r} (P : A / R → Type p) :
Type (a ⊔ r ⊔ p) where
no-eta-equality
field
[]ʳ : ∀ x → P [ x ]
[]-respects-relationʳ :
(r : R x y) →
P.[ (λ i → P ([]-respects-relationᴾ r i)) ] []ʳ x ≡ []ʳ y
is-setʳ :
(prop : ∀ x y → Is-proposition (R x y))
{eq₁ eq₂ : x P.≡ y} {p : P x} {q : P y}
(eq₃ : P.[ (λ i → P (eq₁ i)) ] p ≡ q)
(eq₄ : P.[ (λ i → P (eq₂ i)) ] p ≡ q) →
P.[ (λ i → P.[ (λ j → P (/-is-setᴾ prop eq₁ eq₂ i j)) ] p ≡ q) ]
eq₃ ≡ eq₄
open Elimᴾ′ public
elimᴾ′ : Elimᴾ′ P → (x : A / R) → P x
elimᴾ′ {A = A} {R = R} {P = P} e = helper
where
module E = Elimᴾ′ e
helper : (x : A / R) → P x
helper [ x ] = E.[]ʳ x
helper ([]-respects-relationᴾ r i) = E.[]-respects-relationʳ r i
helper (/-is-setᴾ prop p q i j) =
E.is-setʳ prop (λ i → helper (p i)) (λ i → helper (q i)) i j
-- A possibly more useful eliminator, expressed using paths.
record Elimᴾ {A : Type a} {R : A → A → Type r} (P : A / R → Type p) :
Type (a ⊔ r ⊔ p) where
no-eta-equality
field
[]ʳ : ∀ x → P [ x ]
[]-respects-relationʳ :
(r : R x y) →
P.[ (λ i → P ([]-respects-relationᴾ r i)) ] []ʳ x ≡ []ʳ y
is-setʳ :
(∀ x y → Is-proposition (R x y)) →
∀ x → P.Is-set (P x)
open Elimᴾ public
elimᴾ : Elimᴾ P → (x : A / R) → P x
elimᴾ e = elimᴾ′ λ where
.[]ʳ → E.[]ʳ
.[]-respects-relationʳ → E.[]-respects-relationʳ
.is-setʳ prop → P.heterogeneous-UIP (E.is-setʳ prop) _
where
module E = Elimᴾ e
private
-- One can define elimᴾ′ using elimᴾ.
elimᴾ′₂ : Elimᴾ′ P → (x : A / R) → P x
elimᴾ′₂ {P = P} e = elimᴾ λ where
.[]ʳ → E.[]ʳ
.[]-respects-relationʳ → E.[]-respects-relationʳ
.is-setʳ prop x {y} {z} p q → $⟨ E.is-setʳ prop p q ⟩
P.[ (λ i →
P.[ (λ j → P (/-is-setᴾ prop P.refl P.refl i j)) ]
y ≡ z) ]
p ≡ q ↝⟨ P.subst (λ eq → P.[ (λ i → P.[ (λ j → P (eq i j)) ] y ≡ z) ] p ≡ q)
(PH.mono₁ 2 (/-is-setᴾ prop) _ _) ⟩
P.[ (λ _ → P.[ (λ _ → P x) ] y ≡ z) ] p ≡ q ↔⟨⟩
p P.≡ q □
where
module E = Elimᴾ′ e
-- A non-dependent eliminator, expressed using paths.
record Recᴾ {A : Type a} (R : A → A → Type r) (B : Type b) :
Type (a ⊔ r ⊔ b) where
no-eta-equality
field
[]ʳ : A → B
[]-respects-relationʳ : (r : R x y) → []ʳ x P.≡ []ʳ y
is-setʳ : (∀ x y → Is-proposition (R x y)) →
P.Is-set B
open Recᴾ public
recᴾ : Recᴾ R B → A / R → B
recᴾ r = elimᴾ λ where
.[]ʳ → R.[]ʳ
.[]-respects-relationʳ → R.[]-respects-relationʳ
.is-setʳ prop _ → R.is-setʳ prop
where
module R = Recᴾ r
-- An eliminator.
record Elim {A : Type a} {R : A → A → Type r} (P : A / R → Type p) :
Type (a ⊔ r ⊔ p) where
no-eta-equality
field
[]ʳ : ∀ x → P [ x ]
[]-respects-relationʳ :
(r : R x y) →
subst P ([]-respects-relation r) ([]ʳ x) ≡ []ʳ y
is-setʳ : (∀ x y → Is-proposition (R x y)) → ∀ x → Is-set (P x)
open Elim public
elim : Elim P → (x : A / R) → P x
elim e = elimᴾ λ where
.[]ʳ → E.[]ʳ
.[]-respects-relationʳ → subst≡→[]≡ ∘ E.[]-respects-relationʳ
.is-setʳ prop →
_↔_.to (H-level↔H-level 2) ∘ E.is-setʳ prop
where
module E = Elim e
-- A computation rule.
elim-[]-respects-relation :
dcong (elim e) ([]-respects-relation r) ≡ e .[]-respects-relationʳ r
elim-[]-respects-relation = dcong-subst≡→[]≡ (refl _)
-- A non-dependent eliminator.
record Rec {A : Type a} (R : A → A → Type r) (B : Type b) :
Type (a ⊔ r ⊔ b) where
no-eta-equality
field
[]ʳ : A → B
[]-respects-relationʳ : (r : R x y) → []ʳ x ≡ []ʳ y
is-setʳ : (∀ x y → Is-proposition (R x y)) → Is-set B
open Rec public
rec : Rec R B → A / R → B
rec r = recᴾ λ where
.[]ʳ → R.[]ʳ
.[]-respects-relationʳ → _↔_.to ≡↔≡ ∘ R.[]-respects-relationʳ
.is-setʳ → _↔_.to (H-level↔H-level 2) ∘ R.is-setʳ
where
module R = Rec r
-- A computation rule.
rec-[]-respects-relation :
cong (rec {R = R} {B = B} r₁)
([]-respects-relation {x = x} {y = y} r₂) ≡
r₁ .[]-respects-relationʳ r₂
rec-[]-respects-relation = cong-≡↔≡ (refl _)
-- A variant of elim that can be used if the motive composed with [_]
-- is a family of propositions.
--
-- I took the idea for this eliminator from Nicolai Kraus.
record Elim-prop
{A : Type a} {R : A → A → Type r} (P : A / R → Type p) :
Type (a ⊔ r ⊔ p) where
no-eta-equality
field
[]ʳ : ∀ x → P [ x ]
is-propositionʳ : ∀ x → Is-proposition (P [ x ])
open Elim-prop public
elim-prop : Elim-prop P → (x : A / R) → P x
elim-prop e = elim λ where
.[]ʳ → E.[]ʳ
.[]-respects-relationʳ _ → E.is-propositionʳ _ _ _
.is-setʳ _ → elim λ where
.[]ʳ → mono₁ 1 ∘ E.is-propositionʳ
.[]-respects-relationʳ _ → H-level-propositional ext 2 _ _
.is-setʳ _ _ → mono₁ 1 (H-level-propositional ext 2)
where
module E = Elim-prop e
-- A variant of rec that can be used if the motive is a proposition.
record Rec-prop (A : Type a) (B : Type b) : Type (a ⊔ b) where
no-eta-equality
field
[]ʳ : A → B
is-propositionʳ : Is-proposition B
open Rec-prop public
rec-prop : Rec-prop A B → A / R → B
rec-prop r = elim-prop λ where
.[]ʳ → R.[]ʳ
.is-propositionʳ _ → R.is-propositionʳ
where
module R = Rec-prop r
------------------------------------------------------------------------
-- Some properties
-- [_] is surjective.
[]-surjective : Surjective ([_] {R = R})
[]-surjective = elim-prop λ where
.[]ʳ x → ∣ x , refl _ ∣
.is-propositionʳ _ → TruncP.truncation-is-proposition
-- If the relation is a propositional equivalence relation, then it is
-- equivalent to equality under [_] (assuming propositional
-- extensionality).
--
-- The basic structure of this proof is that of Proposition 2 in
-- "Quotienting the Delay Monad by Weak Bisimilarity" by Chapman,
-- Uustalu and Veltri.
related≃[equal] :
{R : A → A → Type r} →
Propositional-extensionality r →
Is-equivalence-relation R →
(∀ {x y} → Is-proposition (R x y)) →
∀ {x y} → R x y ≃ _≡_ {A = A / R} [ x ] [ y ]
related≃[equal] {A = A} {r = r} {R = R}
prop-ext R-equiv R-prop {x = x} {y = y} =
_↠_.from (Eq.≃↠⇔ R-prop (/-is-set λ _ _ → R-prop))
(record
{ to = []-respects-relation
; from = λ [x]≡[y] →
$⟨ reflexive ⟩
proj₁ (R′ x [ x ]) ↝⟨ ≡⇒→ (cong (proj₁ ∘ R′ x) [x]≡[y]) ⟩
proj₁ (R′ x [ y ]) ↝⟨ id ⟩□
R x y □
})
where
open Is-equivalence-relation R-equiv
lemma : ∀ {x y z} → R y z → (R x y , R-prop) ≡ (R x z , R-prop)
lemma {x} {y} {z} =
R y z ↝⟨ (λ r → record
{ to = flip transitive r
; from = flip transitive (symmetric r)
}) ⟩
R x y ⇔ R x z ↔⟨ ⇔↔≡″ ext prop-ext ⟩□
(R x y , R-prop) ≡ (R x z , R-prop) □
R′ : A → A / R → Proposition r
R′ x = rec λ where
.[]ʳ y → R x y , R-prop
.[]-respects-relationʳ → lemma
.is-setʳ _ → Is-set-∃-Is-proposition ext prop-ext
-- Quotienting with equality (for a set) amounts to the same thing as
-- not quotienting at all.
/≡↔ : Is-set A → A / _≡_ ↔ A
/≡↔ A-set = record
{ surjection = record
{ logical-equivalence = record
{ from = [_]
; to = rec λ where
.[]ʳ → id
.[]-respects-relationʳ → id
.is-setʳ prop → prop _ _
}
; right-inverse-of = λ _ → refl _
}
; left-inverse-of = elim λ where
.[]ʳ _ → refl _
.is-setʳ prop _ → mono₁ 2 (/-is-set prop)
.[]-respects-relationʳ _ →
/-is-set (λ _ _ → A-set) _ _
}
-- Quotienting with a trivial, pointwise propositional relation
-- amounts to the same thing as using the propositional truncation
-- operator.
/trivial↔∥∥ :
(∀ x y → R x y) →
(∀ {x y} → Is-proposition (R x y)) →
A / R ↔ ∥ A ∥
/trivial↔∥∥ {A = A} {R = R} trivial prop = record
{ surjection = record
{ logical-equivalence = record
{ from = TruncP.rec /-prop [_]
; to = rec-prop λ where
.[]ʳ → ∣_∣
.is-propositionʳ → TruncP.truncation-is-proposition
}
; right-inverse-of = TruncP.elim
_
(λ _ → ⇒≡ 1 TruncP.truncation-is-proposition)
(λ _ → refl _)
}
; left-inverse-of = elim-prop λ where
.[]ʳ _ → refl _
.is-propositionʳ _ → /-is-set λ _ _ → prop
}
where
/-prop : Is-proposition (A / R)
/-prop = elim-prop λ where
.[]ʳ x → elim-prop λ where
.[]ʳ y → []-respects-relation (trivial x y)
.is-propositionʳ _ → /-is-set λ _ _ → prop
.is-propositionʳ _ →
Π-closure ext 1 λ _ →
/-is-set λ _ _ → prop
-- The previous property gives us an alternative to
-- constant-function≃∥inhabited∥⇒inhabited.
constant-function↔∥inhabited∥⇒inhabited :
Is-set B →
(∃ λ (f : A → B) → Constant f) ↔ (∥ A ∥ → B)
constant-function↔∥inhabited∥⇒inhabited {B = B} {A = A} B-set =
(∃ λ (f : A → B) → Constant f) ↝⟨ record
{ surjection = record
{ logical-equivalence = record
{ to = λ { (f , c) → rec λ where
.[]ʳ → f
.[]-respects-relationʳ _ → c _ _
.is-setʳ _ → B-set }
; from = λ f → (f ∘ [_])
, (λ _ _ → cong f ([]-respects-relation _))
}
; right-inverse-of = λ f → ⟨ext⟩ $ elim λ where
.[]ʳ _ → refl _
.[]-respects-relationʳ _ → B-set _ _
.is-setʳ _ _ → mono₁ 2 B-set
}
; left-inverse-of = λ _ → Σ-≡,≡→≡
(refl _)
((Π-closure ext 1 λ _ →
Π-closure ext 1 λ _ →
B-set) _ _)
} ⟩
(A / (λ _ _ → ⊤) → B) ↝⟨ →-cong₁ ext (/trivial↔∥∥ _ (mono₁ 0 ⊤-contractible)) ⟩□
(∥ A ∥ → B) □
-- The two directions of the proposition above compute in the
-- "right" way. Note that (at the time of writing) an analogue of
-- the second property below fails to hold definitionally for
-- constant-function≃∥inhabited∥⇒inhabited.
_ :
{B-set : Is-set B} →
_↔_.to (constant-function↔∥inhabited∥⇒inhabited B-set) f ∣ x ∣ ≡
proj₁ f x
_ = refl _
_ :
{B-set : Is-set B} →
proj₁ (_↔_.from (constant-function↔∥inhabited∥⇒inhabited B-set) f)
x ≡
f ∣ x ∣
_ = refl _
------------------------------------------------------------------------
-- Preservation lemmas
-- A preservation lemma for functions.
/-map :
((∀ x y → Is-proposition (R₁ x y)) →
(∀ x y → Is-proposition (R₂ x y))) →
(A₁→A₂ : A₁ → A₂) →
(∀ x y → R₁ x y → R₂ (A₁→A₂ x) (A₁→A₂ y)) →
A₁ / R₁ → A₂ / R₂
/-map {R₁ = R₁} {R₂ = R₂} prop A₁→A₂ R₁→R₂ = rec λ where
.[]ʳ → [_] ∘ A₁→A₂
.is-setʳ → /-is-set ∘ prop
.[]-respects-relationʳ {x = x} {y = y} →
R₁ x y ↝⟨ R₁→R₂ _ _ ⟩
R₂ (A₁→A₂ x) (A₁→A₂ y) ↝⟨ []-respects-relation ⟩□
[ A₁→A₂ x ] ≡ [ A₁→A₂ y ] □
-- A preservation lemma for logical equivalences.
/-cong-⇔ :
((∀ x y → Is-proposition (R₁ x y)) ⇔
(∀ x y → Is-proposition (R₂ x y))) →
(A₁⇔A₂ : A₁ ⇔ A₂) →
(∀ x y → R₁ x y → R₂ (_⇔_.to A₁⇔A₂ x) (_⇔_.to A₁⇔A₂ y)) →
(∀ x y → R₂ x y → R₁ (_⇔_.from A₁⇔A₂ x) (_⇔_.from A₁⇔A₂ y)) →
A₁ / R₁ ⇔ A₂ / R₂
/-cong-⇔ prop A₁⇔A₂ R₁→R₂ R₂→R₁ = record
{ to = /-map (_⇔_.to prop) (_⇔_.to A₁⇔A₂) R₁→R₂
; from = /-map (_⇔_.from prop) (_⇔_.from A₁⇔A₂) R₂→R₁
}
-- A preservation lemma for split surjections.
/-cong-↠ :
((∀ x y → Is-proposition (R₁ x y)) ⇔
(∀ x y → Is-proposition (R₂ x y))) →
(A₁↠A₂ : A₁ ↠ A₂) →
(∀ x y → R₁ x y ↠ R₂ (_↠_.to A₁↠A₂ x) (_↠_.to A₁↠A₂ y)) →
A₁ / R₁ ↠ A₂ / R₂
/-cong-↠ {R₁ = R₁} {R₂ = R₂} prop A₁↠A₂ R₁↠R₂ = record
{ logical-equivalence = /-cong-⇔
prop
(_↠_.logical-equivalence A₁↠A₂)
(λ x y → _↠_.to (R₁↠R₂ x y))
(λ x y → R₂ x y ↝⟨ ≡⇒↝ _ (sym $ cong₂ R₂ (right-inverse-of x) (right-inverse-of y)) ⟩
R₂ (to (from x)) (to (from y)) ↝⟨ _↠_.from (R₁↠R₂ _ _) ⟩□
R₁ (from x) (from y) □)
; right-inverse-of = elim λ where
.[]ʳ x →
[ to (from x) ] ≡⟨ cong [_] $ right-inverse-of x ⟩∎
[ x ] ∎
.is-setʳ prop _ → mono₁ 1 (/-is-set prop)
.[]-respects-relationʳ {x = x} {y = y} r →
let tr = λ x y → _↠_.to (R₁↠R₂ x y)
fr = λ x y →
_↠_.from (R₁↠R₂ (from x) (from y)) ∘
≡⇒↝ _
(sym (cong₂ R₂ (right-inverse-of x)
(right-inverse-of y)))
t = /-map (_⇔_.to prop) to tr
f = /-map (_⇔_.from prop) from fr
in
subst (λ x → t (f x) ≡ x)
([]-respects-relation r)
(cong [_] (right-inverse-of x)) ≡⟨ subst-in-terms-of-trans-and-cong ⟩
trans
(sym (cong (t ∘ f) ([]-respects-relation r)))
(trans (cong [_] (right-inverse-of x))
(cong id ([]-respects-relation r))) ≡⟨ cong₂ (λ eq₁ eq₂ → trans (sym eq₁)
(trans (cong [_] (right-inverse-of x)) eq₂))
(sym $ cong-∘ _ _ _)
(sym $ cong-id _) ⟩
trans
(sym (cong t (cong f ([]-respects-relation r))))
(trans (cong [_] (right-inverse-of x))
([]-respects-relation r)) ≡⟨ cong (λ eq → trans (sym (cong t eq))
(trans (cong [_] (right-inverse-of x))
([]-respects-relation r))) $
rec-[]-respects-relation ⟩
trans
(sym (cong t ([]-respects-relation (fr _ _ r))))
(trans (cong [_] (right-inverse-of x))
([]-respects-relation r)) ≡⟨ cong (λ eq → trans (sym eq)
(trans (cong [_] (right-inverse-of x))
([]-respects-relation r))) $
rec-[]-respects-relation ⟩
trans
(sym ([]-respects-relation (tr _ _ (fr _ _ r))))
(trans (cong [_] (right-inverse-of x))
([]-respects-relation r)) ≡⟨ cong (λ r′ → trans (sym ([]-respects-relation r′))
(trans (cong [_] (right-inverse-of x))
([]-respects-relation r))) $
_↠_.right-inverse-of (R₁↠R₂ _ _) _ ⟩
trans
(sym ([]-respects-relation
(≡⇒↝ _ (sym (cong₂ R₂ (right-inverse-of x)
(right-inverse-of y)))
r)))
(trans (cong [_] (right-inverse-of x))
([]-respects-relation r)) ≡⟨ lemma _ _ _ ⟩∎
cong [_] (right-inverse-of y) ∎
}
where
open _↠_ A₁↠A₂
lemma : ∀ _ _ _ → _
lemma x y r =
elim₁
(λ eq →
trans
(sym ([]-respects-relation
(≡⇒↝ _ (sym (cong₂ R₂ (right-inverse-of x) eq)) r)))
(trans (cong [_] (right-inverse-of x))
([]-respects-relation r)) ≡
cong [_] eq)
(elim₁
(λ eq →
trans
(sym ([]-respects-relation
(≡⇒↝ _ (sym (cong₂ R₂ eq (refl _))) r)))
(trans (cong [_] eq) ([]-respects-relation r)) ≡
cong [_] (refl _))
(trans
(sym ([]-respects-relation
(≡⇒↝ _ (sym (cong₂ R₂ (refl _) (refl _))) r)))
(trans (cong [_] (refl _)) ([]-respects-relation r)) ≡⟨ cong₂ (λ eq₁ eq₂ →
trans (sym ([]-respects-relation (≡⇒↝ _ eq₁ r)))
(trans eq₂ ([]-respects-relation r)))
(trans (cong sym $ cong₂-refl R₂) sym-refl)
(cong-refl _) ⟩
trans
(sym ([]-respects-relation (≡⇒↝ _ (refl _) r)))
(trans (refl _) ([]-respects-relation r)) ≡⟨ cong₂ (λ eq₁ eq₂ → trans (sym ([]-respects-relation eq₁)) eq₂)
(cong (_$ r) ≡⇒↝-refl)
(trans-reflˡ _) ⟩
trans
(sym ([]-respects-relation r))
([]-respects-relation r) ≡⟨ trans-symˡ _ ⟩
refl _ ≡⟨ sym $ cong-refl _ ⟩∎
cong [_] (refl _) ∎)
(right-inverse-of x))
(right-inverse-of y)
private
-- A preservation lemma for equivalences.
/-cong-≃ :
((∀ x y → Is-proposition (R₁ x y)) ⇔
(∀ x y → Is-proposition (R₂ x y))) →
(A₁≃A₂ : A₁ ≃ A₂) →
(∀ x y →
R₁ x y ≃ R₂ (to-implication A₁≃A₂ x) (to-implication A₁≃A₂ y)) →
A₁ / R₁ ≃ A₂ / R₂
/-cong-≃ {R₁ = R₁} {R₂ = R₂} prop A₁≃A₂ R₁≃R₂ = Eq.↔⇒≃ (record
{ surjection = /-cong-↠ prop (_≃_.surjection A₁≃A₂) λ x y →
R₁ x y ↔⟨ R₁≃R₂ x y ⟩□
R₂ (to x) (to y) □
; left-inverse-of = elim λ where
.[]ʳ x →
[ from (to x) ] ≡⟨ cong [_] $ left-inverse-of x ⟩∎
[ x ] ∎
.is-setʳ prop _ → mono₁ 1 (/-is-set prop)
.[]-respects-relationʳ {x = x} {y = y} r →
let tr = λ x y → _≃_.to (R₁≃R₂ x y)
fr = λ x y →
_≃_.from (R₁≃R₂ (from x) (from y)) ∘
≡⇒↝ _
(sym (cong₂ R₂ (right-inverse-of x)
(right-inverse-of y)))
t = /-map (_⇔_.to prop) to tr
f = /-map (_⇔_.from prop) from fr
in
subst (λ x → f (t x) ≡ x)
([]-respects-relation r)
(cong [_] (left-inverse-of x)) ≡⟨ subst-in-terms-of-trans-and-cong ⟩
trans
(sym (cong (f ∘ t) ([]-respects-relation r)))
(trans (cong [_] (left-inverse-of x))
(cong id ([]-respects-relation r))) ≡⟨ cong₂ (λ eq₁ eq₂ → trans (sym eq₁)
(trans (cong [_] (left-inverse-of x)) eq₂))
(sym $ cong-∘ _ _ _)
(sym $ cong-id _) ⟩
trans
(sym (cong f (cong t ([]-respects-relation r))))
(trans (cong [_] (left-inverse-of x))
([]-respects-relation r)) ≡⟨ cong (λ eq → trans (sym (cong f eq))
(trans (cong [_] (left-inverse-of x))
([]-respects-relation r))) $
rec-[]-respects-relation ⟩
trans
(sym (cong f ([]-respects-relation (tr _ _ r))))
(trans (cong [_] (left-inverse-of x))
([]-respects-relation r)) ≡⟨ cong (λ eq → trans (sym eq)
(trans (cong [_] (left-inverse-of x))
([]-respects-relation r))) $
rec-[]-respects-relation ⟩
trans
(sym ([]-respects-relation (fr _ _ (tr _ _ r))))
(trans (cong [_] (left-inverse-of x))
([]-respects-relation r)) ≡⟨ cong (λ r′ → trans (sym ([]-respects-relation r′))
(trans (cong [_] (left-inverse-of x))
([]-respects-relation r))) $
lemma₁ _ _ _ ⟩
trans
(sym ([]-respects-relation
(≡⇒↝ _ (sym (cong₂ R₁ (left-inverse-of x)
(left-inverse-of y)))
r)))
(trans (cong [_] (left-inverse-of x))
([]-respects-relation r)) ≡⟨ lemma₂ _ _ _ ⟩∎
cong [_] (left-inverse-of y) ∎
})
where
open _≃_ A₁≃A₂
lemma₀ : ∀ _ _ _ → _
lemma₀ x y r =
elim₁
(λ eq →
_≃_.from (R₁≃R₂ (from (to x)) _)
(≡⇒↝ _ (sym (cong₂ (λ x y → R₂ (to x) (to y))
(left-inverse-of x) eq))
(_≃_.to (R₁≃R₂ x y) r)) ≡
≡⇒↝ _ (sym (cong₂ R₁ (left-inverse-of x) eq)) r)
(elim₁
(λ eq →
_≃_.from (R₁≃R₂ _ _)
(≡⇒↝ _ (sym (cong₂ (λ x y → R₂ (to x) (to y))
eq (refl _)))
(_≃_.to (R₁≃R₂ x y) r)) ≡
≡⇒↝ _ (sym (cong₂ R₁ eq (refl _))) r)
(_≃_.from (R₁≃R₂ _ _)
(≡⇒↝ _ (sym (cong₂ (λ x y → R₂ (to x) (to y))
(refl _) (refl _)))
(_≃_.to (R₁≃R₂ x y) r)) ≡⟨ cong (λ eq → _≃_.from (R₁≃R₂ _ _) (≡⇒↝ _ eq (_≃_.to (R₁≃R₂ x y) r))) $
trans (cong sym $ cong₂-refl _) sym-refl ⟩
_≃_.from (R₁≃R₂ _ _) (≡⇒↝ _ (refl _) (_≃_.to (R₁≃R₂ x y) r)) ≡⟨ cong (_≃_.from (R₁≃R₂ _ _)) $ cong (_$ _≃_.to (R₁≃R₂ x y) r)
≡⇒↝-refl ⟩
_≃_.from (R₁≃R₂ _ _) (_≃_.to (R₁≃R₂ x y) r) ≡⟨ _≃_.left-inverse-of (R₁≃R₂ _ _) _ ⟩
r ≡⟨ sym $ cong (_$ r) ≡⇒↝-refl ⟩
≡⇒↝ _ (refl _) r ≡⟨ cong (λ eq → ≡⇒↝ _ eq r) $ sym $
trans (cong sym $ cong₂-refl _) sym-refl ⟩∎
≡⇒↝ _ (sym (cong₂ R₁ (refl _) (refl _))) r ∎)
(left-inverse-of x))
(left-inverse-of y)
lemma₁ : ∀ _ _ _ → _
lemma₁ x y r =
_≃_.from (R₁≃R₂ (from (to x)) (from (to y)))
(≡⇒↝ _ (sym (cong₂ R₂ (right-inverse-of (to x))
(right-inverse-of (to y))))
(_≃_.to (R₁≃R₂ x y) r)) ≡⟨⟩
_≃_.from (R₁≃R₂ (from (to x)) (from (to y)))
(≡⇒↝ _ (sym (trans (cong (flip R₂ _) (right-inverse-of (to x)))
(cong (R₂ _) (right-inverse-of (to y)))))
(_≃_.to (R₁≃R₂ x y) r)) ≡⟨ cong₂ (λ eq₁ eq₂ →
_≃_.from (R₁≃R₂ (from (to x)) (from (to y)))
(≡⇒↝ _ (sym (trans eq₁ eq₂)) (_≃_.to (R₁≃R₂ x y) r)))
(trans (cong (cong _) $ sym $ left-right-lemma _) (cong-∘ _ _ _))
(trans (cong (cong _) $ sym $ left-right-lemma _) (cong-∘ _ _ _)) ⟩
_≃_.from (R₁≃R₂ (from (to x)) (from (to y)))
(≡⇒↝ _ (sym (trans (cong (flip R₂ _ ∘ to) (left-inverse-of x))
(cong (R₂ _ ∘ to) (left-inverse-of y))))
(_≃_.to (R₁≃R₂ x y) r)) ≡⟨⟩
_≃_.from (R₁≃R₂ (from (to x)) (from (to y)))
(≡⇒↝ _ (sym (cong₂ (λ x y → R₂ (to x) (to y))
(left-inverse-of x)
(left-inverse-of y)))
(_≃_.to (R₁≃R₂ x y) r)) ≡⟨ lemma₀ _ _ _ ⟩∎
≡⇒↝ _ (sym (cong₂ R₁ (left-inverse-of x) (left-inverse-of y))) r ∎
lemma₂ : ∀ _ _ _ → _
lemma₂ x y r =
elim₁
(λ eq →
trans
(sym ([]-respects-relation
(≡⇒↝ _ (sym (cong₂ R₁ (left-inverse-of x) eq)) r)))
(trans (cong [_] (left-inverse-of x))
([]-respects-relation r)) ≡
cong [_] eq)
(elim₁
(λ eq →
trans
(sym ([]-respects-relation
(≡⇒↝ _ (sym (cong₂ R₁ eq (refl _))) r)))
(trans (cong [_] eq) ([]-respects-relation r)) ≡
cong [_] (refl _))
(trans
(sym ([]-respects-relation
(≡⇒↝ _ (sym (cong₂ R₁ (refl _) (refl _))) r)))
(trans (cong [_] (refl _)) ([]-respects-relation r)) ≡⟨ cong₂ (λ eq₁ eq₂ →
trans (sym ([]-respects-relation (≡⇒↝ _ eq₁ r)))
(trans eq₂ ([]-respects-relation r)))
(trans (cong sym $ cong₂-refl R₁) sym-refl)
(cong-refl _) ⟩
trans
(sym ([]-respects-relation (≡⇒↝ _ (refl _) r)))
(trans (refl _) ([]-respects-relation r)) ≡⟨ cong₂ (λ eq₁ eq₂ → trans (sym ([]-respects-relation eq₁)) eq₂)
(cong (_$ r) ≡⇒↝-refl)
(trans-reflˡ _) ⟩
trans
(sym ([]-respects-relation r))
([]-respects-relation r) ≡⟨ trans-symˡ _ ⟩
refl _ ≡⟨ sym $ cong-refl _ ⟩∎
cong [_] (refl _) ∎)
(left-inverse-of x))
(left-inverse-of y)
-- A preservation lemma for isomorphisms.
/-cong-↔ :
{A₁ : Type a₁} {R₁ : A₁ → A₁ → Type r₁}
{A₂ : Type a₂} {R₂ : A₂ → A₂ → Type r₂} →
((∀ x y → Is-proposition (R₁ x y)) ⇔
(∀ x y → Is-proposition (R₂ x y))) →
(A₁↔A₂ : A₁ ↔[ k ] A₂) →
(∀ x y →
R₁ x y ↔[ k ]
R₂ (to-implication A₁↔A₂ x) (to-implication A₁↔A₂ y)) →
A₁ / R₁ ↔[ k ] A₂ / R₂
/-cong-↔ {k = k} {R₁ = R₁} {R₂ = R₂} prop A₁↔A₂ R₁↔R₂ =
from-isomorphism $
/-cong-≃ prop A₁≃A₂ λ x y →
R₁ x y ↔⟨ R₁↔R₂ x y ⟩
R₂ (to-implication A₁↔A₂ x) (to-implication A₁↔A₂ y) ↝⟨ ≡⇒↝ _ $ cong₂ (λ f g → R₂ (f x) (g y))
(to-implication∘from-isomorphism k equivalence)
(to-implication∘from-isomorphism k equivalence) ⟩□
R₂ (_≃_.to A₁≃A₂ x) (_≃_.to A₁≃A₂ y) □
where
A₁≃A₂ = from-isomorphism A₁↔A₂
------------------------------------------------------------------------
-- The quotients defined here can be related to the ones defined in
-- Quotient
-- If the quotient relation is propositional, then the definition of
-- quotients given in Quotient is equivalent to the one given here.
/≃/ :
(∀ {x y} → Is-proposition (R x y)) →
A / R ≃ A Quotient./ R
/≃/ R-prop = Eq.↔⇒≃ (record
{ surjection = record
{ logical-equivalence = record
{ to = rec (λ where
.[]ʳ → Quotient.[_]
.[]-respects-relationʳ → Quotient.[]-respects-relation
.is-setʳ _ → Quotient./-is-set)
; from = Quotient.rec λ where
.Quotient.Rec.[]ʳ → [_]
.Quotient.Rec.[]-respects-relationʳ → []-respects-relation
.Quotient.Rec.is-setʳ → /-is-set λ _ _ → R-prop
}
; right-inverse-of = Quotient.elim-prop λ where
.Quotient.Elim-prop.[]ʳ _ → refl _
.Quotient.Elim-prop.is-propositionʳ _ → Quotient./-is-set
}
; left-inverse-of = elim-prop λ where
.Elim-prop.[]ʳ _ → refl _
.Elim-prop.is-propositionʳ _ → /-is-set λ _ _ → R-prop
})
------------------------------------------------------------------------
-- The quotients defined here can be related to the ones defined in
-- QF.Families-of-equivalence-classes
private
-- An alternative definition of the quotients from
-- QF.Families-of-equivalence-classes.
infix 5 _/′_
_/′_ : (A : Type a) → (A → A → Type a) → Type (lsuc a)
_/′_ {a = a} A R = ∃ λ (P : A → Type a) → ∥ (∃ λ x → R x ≡ P) ∥
/↔/′ : A QF./ R ↔ A /′ R
/↔/′ {A = A} {R = R} =
A QF./ R ↔⟨⟩
(∃ λ (P : A → Type _) → Trunc.∥ (∃ λ x → R x ≡ P) ∥ 1 _) ↝⟨ (∃-cong λ _ → inverse $ TruncP.∥∥↔∥∥ lzero) ⟩
(∃ λ (P : A → Type _) → ∥ (∃ λ x → R x ≡ P) ∥) ↔⟨⟩
A /′ R □
[_]′ : A → A /′ R
[_]′ = _↔_.to /↔/′ ∘ QF.[_]
rec′ :
{A : Type a} {R : A → A → Type a} →
(∀ {x} → R x x) →
(B : Type a) →
Is-set B →
(f : A → B) →
(∀ {x y} → R x y → f x ≡ f y) →
A /′ R → B
rec′ refl B B-set f R⇒≡ =
QF.rec ext refl B B-set f R⇒≡ ∘
_↔_.from /↔/′
elim-Prop′ :
{A : Type a} {R : A → A → Type a} →
QF.Strong-equivalence-with surjection R →
(B : A /′ R → Type (lsuc a)) →
(∀ x → Is-proposition (B [ x ]′)) →
(f : ∀ x → B [ x ]′) →
∀ x → B x
elim-Prop′ strong-equivalence B B-prop f x =
subst B (_↔_.right-inverse-of /↔/′ _) $
QF.elim-Prop
ext
strong-equivalence
(B ∘ _↔_.to /↔/′)
B-prop
f
(_↔_.from /↔/′ x)
-- If the relation is a propositional equivalence relation of a
-- certain size, then the quotients defined above are isomorphic to
-- families of equivalence relations, defined in a certain way
-- (assuming univalence).
/↔ :
{A : Type a} {R : A → A → Type a} →
Univalence a →
Univalence lzero →
Is-equivalence-relation R →
(∀ {x y} → Is-proposition (R x y)) →
A / R ↔ ∃ λ (P : A → Type a) → ∥ (∃ λ x → R x ≡ P) ∥
/↔ {a = a} {A = A} {R = R} univ univ₀ R-equiv R-prop = record
{ surjection = record
{ logical-equivalence = record
{ to = to
; from = from
}
; right-inverse-of = to∘from
}
; left-inverse-of = from∘to
}
where
R-is-strong-equivalence : QF.Strong-equivalence R
R-is-strong-equivalence =
QF.propositional-equivalence⇒strong-equivalence
ext univ R-equiv (λ _ _ → R-prop)
to : A / R → A /′ R
to = rec λ where
.[]ʳ → [_]′
.[]-respects-relationʳ {x = x} {y = y} →
R x y ↝⟨ _≃_.to (QF.related↝[equal] ext R-is-strong-equivalence) ⟩
QF.[ x ] ≡ QF.[ y ] ↝⟨ cong (_↔_.to /↔/′) ⟩□
[ x ]′ ≡ [ y ]′ □
.is-setʳ prop → $⟨ (λ {_ _} → QF.quotient's-h-level-is-1-+-relation's-h-level
ext univ univ₀ 1 (λ _ _ → R-prop)) ⟩
Is-set (A QF./ R) ↝⟨ H.respects-surjection (_↔_.surjection /↔/′) 2 ⟩□
Is-set (A /′ R) □
from : A /′ R → A / R
from = rec′
(Is-equivalence-relation.reflexive R-equiv)
_
(/-is-set λ _ _ → R-prop)
[_]
[]-respects-relation
to∘from : ∀ x → to (from x) ≡ x
to∘from = elim-Prop′
(QF.strong-equivalence⇒strong-equivalence-with
R-is-strong-equivalence)
_
(λ x → $⟨ (λ {_ _} → QF.quotient's-h-level-is-1-+-relation's-h-level
ext univ univ₀ 1 λ _ _ → R-prop) ⟩
Is-set (A QF./ R) ↝⟨ H.respects-surjection (_↔_.surjection /↔/′) 2 ⟩
Is-set (A /′ R) ↝⟨ +⇒≡ {n = 1} ⟩□
Is-proposition (to (from [ x ]′) ≡ [ x ]′) □)
(λ _ → refl _)
from∘to : ∀ x → from (to x) ≡ x
from∘to = elim-prop λ where
.[]ʳ _ → refl _
.is-propositionʳ _ → /-is-set λ _ _ → R-prop
-- If the relation is a propositional equivalence relation of a
-- certain size, then the definition of quotients given in
-- QF.Families-of-equivalence-classes is isomorphic to the one given
-- here (assuming univalence).
/↔/ :
{A : Type a} {R : A → A → Type a} →
Univalence a →
Univalence lzero →
Is-equivalence-relation R →
(R-prop : ∀ {x y} → Is-proposition (R x y)) →
A QF./ R ↔ A / R
/↔/ {a = a} {A = A} {R = R} univ univ₀ R-equiv R-prop =
A QF./ R ↔⟨⟩
(∃ λ (P : A → Type a) → Trunc.∥ (∃ λ x → R x ≡ P) ∥ 1 (lsuc a)) ↝⟨ (∃-cong λ _ → inverse $ TruncP.∥∥↔∥∥ lzero) ⟩
(∃ λ (P : A → Type a) → ∥ (∃ λ x → R x ≡ P) ∥) ↝⟨ inverse $ /↔ univ univ₀ R-equiv R-prop ⟩□
A / R □
------------------------------------------------------------------------
-- Various type formers commute with quotients
-- _⊎_ commutes with quotients if the relations are pointwise
-- propositional.
⊎/-comm :
(∀ {x y} → Is-proposition (R₁ x y)) →
(∀ {x y} → Is-proposition (R₂ x y)) →
(A₁ ⊎ A₂) / (R₁ ⊎ᴾ R₂) ↔ A₁ / R₁ ⊎ A₂ / R₂
⊎/-comm R₁-prop R₂-prop = record
{ surjection = record
{ logical-equivalence = record
{ to = rec λ where
.[]ʳ → ⊎-map [_] [_]
.is-setʳ prop → ⊎-closure 0 is-set₁ is-set₂
.[]-respects-relationʳ {x = inj₁ _} {y = inj₁ _} →
cong inj₁ ∘ []-respects-relation
.[]-respects-relationʳ {x = inj₂ _} {y = inj₂ _} →
cong inj₂ ∘ []-respects-relation
; from = Prelude.[ rec (λ where
.[]ʳ → [_] ∘ inj₁
.[]-respects-relationʳ → []-respects-relation
.is-setʳ prop → is-set₁₂)
, rec (λ where
.[]ʳ → [_] ∘ inj₂
.[]-respects-relationʳ → []-respects-relation
.is-setʳ prop → is-set₁₂)
]
}
; right-inverse-of =
Prelude.[ elim-prop (λ where
.[]ʳ _ → refl _
.is-propositionʳ _ → ⊎-closure 0 is-set₁ is-set₂)
, elim-prop (λ where
.[]ʳ _ → refl _
.is-propositionʳ _ → ⊎-closure 0 is-set₁ is-set₂)
]
}
; left-inverse-of = elim-prop λ where
.[]ʳ → Prelude.[ (λ _ → refl _) , (λ _ → refl _) ]
.is-propositionʳ _ → is-set₁₂
}
where
is-set₁ = /-is-set λ _ _ → R₁-prop
is-set₂ = /-is-set λ _ _ → R₂-prop
is-set₁₂ = /-is-set λ x y → ⊎ᴾ-preserves-Is-proposition
R₁-prop R₂-prop {x = x} {y = y}
-- Maybe commutes with quotients if the relation is pointwise
-- propositional.
--
-- Chapman, Uustalu and Veltri mention a similar result in
-- "Quotienting the Delay Monad by Weak Bisimilarity".
Maybe/-comm :
(∀ {x y} → Is-proposition (R x y)) →
Maybe A / Maybeᴾ R ↔ Maybe (A / R)
Maybe/-comm {A = A} {R = R} R-prop =
Maybe A / Maybeᴾ R ↝⟨ ⊎/-comm (↑-closure 1 (mono₁ 0 ⊤-contractible)) R-prop ⟩
⊤ / Trivial ⊎ A / R ↝⟨ /trivial↔∥∥ _ (↑-closure 1 (mono₁ 0 ⊤-contractible)) ⊎-cong F.id ⟩
∥ ⊤ ∥ ⊎ A / R ↝⟨ TruncP.∥∥↔ (mono₁ 0 ⊤-contractible) ⊎-cong F.id ⟩□
Maybe (A / R) □
-- A simplification lemma for Maybe/-comm.
Maybe/-comm-[] :
{R : A → A → Type r}
{R-prop : ∀ {x y} → Is-proposition (R x y)} →
_↔_.to (Maybe/-comm {R = R} R-prop) ∘ [_] ≡ ⊎-map id [_]
Maybe/-comm-[] {R-prop = R-prop} =
_↔_.to (Maybe/-comm R-prop) ∘ [_] ≡⟨⟩
⊎-map _ id ∘ ⊎-map _ id ∘ ⊎-map [_] [_] ≡⟨ cong (_∘ ⊎-map [_] [_]) $ sym $ ⟨ext⟩ ⊎-map-∘ ⟩
⊎-map _ id ∘ ⊎-map [_] [_] ≡⟨ sym $ ⟨ext⟩ ⊎-map-∘ ⟩∎
⊎-map id [_] ∎
-- The sigma type former commutes (kind of) with quotients, assuming
-- that certain families are propositional.
Σ/-comm :
{P : A / R → Type p} →
(∀ {x} → Is-proposition (P x)) →
(∀ {x y} → Is-proposition (R x y)) →
Σ (A / R) P ↔ Σ A (P ∘ [_]) / (R on proj₁)
Σ/-comm {A = A} {R = R} {P = P} P-prop R-prop = record
{ surjection = record
{ logical-equivalence = record
{ to =
uncurry $
elim λ where
.[]ʳ → curry [_]
.[]-respects-relationʳ {x = x} {y = y} r → ⟨ext⟩ λ P[y] →
subst (λ x → P x → Σ A (P ∘ [_]) / (R on proj₁))
([]-respects-relation r)
(curry [_] x) P[y] ≡⟨ subst-→-domain P {f = curry [_] _} ([]-respects-relation r) ⟩
[ (x , subst P (sym $ []-respects-relation r) P[y]) ] ≡⟨ []-respects-relation r ⟩∎
[ (y , P[y]) ] ∎
.is-setʳ prop _ →
Π-closure ext 2 λ _ →
/-is-set λ _ _ → prop _ _
; from = rec λ where
.[]ʳ → Σ-map [_] id
.is-setʳ _ →
Σ-closure 2 (/-is-set λ _ _ → R-prop) (λ _ → mono₁ 1 P-prop)
.[]-respects-relationʳ {x = (x₁ , x₂)} {y = (y₁ , y₂)} →
R x₁ y₁ ↝⟨ []-respects-relation ⟩
[ x₁ ] ≡ [ y₁ ] ↔⟨ ignore-propositional-component P-prop ⟩
([ x₁ ] , x₂) ≡ ([ y₁ ] , y₂) □
}
; right-inverse-of = elim-prop λ where
.[]ʳ _ → refl _
.is-propositionʳ _ → /-is-set λ _ _ → R-prop
}
; left-inverse-of = uncurry $ elim-prop λ where
.[]ʳ _ _ → refl _
.is-propositionʳ _ →
Π-closure ext 1 λ _ →
Σ-closure 2 (/-is-set λ _ _ → R-prop) (λ _ → mono₁ 1 P-prop)
}
-- The type former λ X → ℕ → X commutes with quotients, assuming that
-- the quotient relation is a propositional equivalence relation, and
-- also assuming countable choice and propositional extensionality.
--
-- This result is very similar to Proposition 5 in "Quotienting the
-- Delay Monad by Weak Bisimilarity" by Chapman, Uustalu and Veltri.
-- The forward component of the isomorphism. This component can be
-- defined without any extra assumptions.
ℕ→/-comm-to : (ℕ → A) / (ℕ →ᴾ R) → (ℕ → A / R)
ℕ→/-comm-to {A = A} = rec λ where
.[]ʳ f n → [ f n ]
.[]-respects-relationʳ r →
⟨ext⟩ ([]-respects-relation ∘ r)
.is-setʳ prop →
Π-closure ext 2 λ _ →
/-is-set (prop⇒prop prop)
where
prop⇒prop :
((f g : ℕ → A) → Is-proposition ((ℕ →ᴾ R) f g)) →
((x y : A) → Is-proposition (R x y))
prop⇒prop prop x y p q =
cong (_$ 0) $ prop (λ _ → x) (λ _ → y) (λ _ → p) (λ _ → q)
-- The isomorphism.
ℕ→/-comm :
{A : Type a} {R : A → A → Type r} →
Axiom-of-countable-choice (a ⊔ r) →
Propositional-extensionality r →
Is-equivalence-relation R →
(∀ {x y} → Is-proposition (R x y)) →
(ℕ → A) / (ℕ →ᴾ R) ↔ (ℕ → A / R)
ℕ→/-comm {A = A} {R = R} cc prop-ext R-equiv R-prop = record
{ surjection = record
{ logical-equivalence = record
{ to = ℕ→/-comm-to
; from = from unit
}
; right-inverse-of = to∘from unit
}
; left-inverse-of = from∘to unit
}
where
[_]→ : (ℕ → A) → (ℕ → A / R)
[ f ]→ n = [ f n ]
-- A module that is introduced to ensure that []→-surjective is not
-- in the same abstract block as the abstract definitions below.
module Dummy where
abstract
[]→-surjective : Surjective [_]→
[]→-surjective f = $⟨ []-surjective ⟩
Surjective [_] ↝⟨ (λ surj → surj ∘ f) ⦂ (_ → _) ⟩
(∀ n → ∥ (∃ λ x → [ x ] ≡ f n) ∥) ↔⟨ TruncP.countable-choice-bijection cc ⟩
∥ (∀ n → ∃ λ x → [ x ] ≡ f n) ∥ ↔⟨ TruncP.∥∥-cong ΠΣ-comm ⟩
∥ (∃ λ g → ∀ n → [ g n ] ≡ f n) ∥ ↔⟨⟩
∥ (∃ λ g → ∀ n → [ g ]→ n ≡ f n) ∥ ↔⟨ TruncP.∥∥-cong (∃-cong λ _ → Eq.extensionality-isomorphism ext) ⟩□
∥ (∃ λ g → [ g ]→ ≡ f) ∥ □
open Dummy
from₁ : ∀ f → [_]→ ⁻¹ f → ℕ→/-comm-to ⁻¹ f
from₁ f (g , [g]→≡f) =
[ g ]
, (ℕ→/-comm-to [ g ] ≡⟨⟩
[ g ]→ ≡⟨ [g]→≡f ⟩∎
f ∎)
from₁-constant : ∀ f → Constant (from₁ f)
from₁-constant f (g₁ , [g₁]→≡f) (g₂ , [g₂]→≡f) =
$⟨ (λ n → cong (_$ n) (
[ g₁ ]→ ≡⟨ [g₁]→≡f ⟩
f ≡⟨ sym [g₂]→≡f ⟩∎
[ g₂ ]→ ∎)) ⟩
(∀ n → [ g₁ ]→ n ≡ [ g₂ ]→ n) ↔⟨⟩
(∀ n → [ g₁ n ] ≡ [ g₂ n ]) ↔⟨ ∀-cong ext (λ _ → inverse $ related≃[equal] prop-ext R-equiv R-prop) ⟩
(∀ n → R (g₁ n) (g₂ n)) ↔⟨⟩
(ℕ →ᴾ R) g₁ g₂ ↝⟨ []-respects-relation ⟩
[ g₁ ] ≡ [ g₂ ] ↔⟨ ignore-propositional-component
(Π-closure ext 2 λ _ →
/-is-set λ _ _ → R-prop) ⟩□
([ g₁ ] , [g₁]→≡f) ≡ ([ g₂ ] , [g₂]→≡f) □
from₂ : Unit → ∀ f → ∥ [_]→ ⁻¹ f ∥ → ℕ→/-comm-to ⁻¹ f
from₂ unit f =
_≃_.to
(TruncP.constant-function≃∥inhabited∥⇒inhabited
(Σ-closure 2
(/-is-set λ _ _ →
→ᴾ-preserves-Is-proposition R ext R-prop) λ _ →
mono₁ 1 (Π-closure ext 2 (λ _ → /-is-set λ _ _ → R-prop))))
(from₁ f , from₁-constant f)
unblock-from₂ : ∀ x f p → from₂ x f ∣ p ∣ ≡ from₁ f p
unblock-from₂ unit _ _ = refl _
abstract
from₃ : Unit → (f : ℕ → A / R) → ℕ→/-comm-to ⁻¹ f
from₃ x f = from₂ x f ([]→-surjective f)
from : Unit → (ℕ → A / R) → (ℕ → A) / (ℕ →ᴾ R)
from x f = proj₁ (from₃ x f)
to∘from : ∀ x f → ℕ→/-comm-to (from x f) ≡ f
to∘from x f = proj₂ (from₃ x f)
from∘to : ∀ x f → from x (ℕ→/-comm-to f) ≡ f
from∘to x = elim-prop λ where
.[]ʳ f →
from x (ℕ→/-comm-to [ f ]) ≡⟨⟩
proj₁ (from₂ x [ f ]→ ([]→-surjective [ f ]→)) ≡⟨ cong (proj₁ ∘ from₂ x [ f ]→) $ TruncP.truncation-is-proposition _ _ ⟩
proj₁ (from₂ x [ f ]→ ∣ f , refl _ ∣) ≡⟨ cong proj₁ $ unblock-from₂ x _ (f , refl _) ⟩
proj₁ (from₁ [ f ]→ (f , refl _)) ≡⟨⟩
[ f ] ∎
.is-propositionʳ _ →
/-is-set λ _ _ →
→ᴾ-preserves-Is-proposition R ext R-prop
------------------------------------------------------------------------
-- Quotient-like eliminators
-- If there is a split surjection from a quotient type to some other
-- type, then one can construct a quotient-like eliminator for the
-- other type.
--
-- This kind of construction is used in "Quotienting the Delay Monad
-- by Weak Bisimilarity" by Chapman, Uustalu and Veltri.
↠-eliminator :
(surj : A / R ↠ B)
(P : B → Type p)
(p-[] : ∀ x → P (_↠_.to surj [ x ])) →
(∀ {x y} (r : R x y) →
subst P (cong (_↠_.to surj) ([]-respects-relation r)) (p-[] x) ≡
p-[] y) →
((∀ x y → Is-proposition (R x y)) → ∀ x → Is-set (P x)) →
∀ x → P x
↠-eliminator surj P p-[] ok P-set x =
subst P (_↠_.right-inverse-of surj x) p′
where
p′ : P (_↠_.to surj (_↠_.from surj x))
p′ = elim
(λ where
.[]ʳ → p-[]
.[]-respects-relationʳ {x = x} {y = y} r →
subst (P ∘ _↠_.to surj) ([]-respects-relation r) (p-[] x) ≡⟨ subst-∘ P (_↠_.to surj) ([]-respects-relation r) ⟩
subst P (cong (_↠_.to surj) ([]-respects-relation r)) (p-[] x) ≡⟨ ok r ⟩∎
p-[] y ∎
.is-setʳ prop _ → P-set prop _)
(_↠_.from surj x)
-- The eliminator "computes" in the "right" way for elements that
-- satisfy a certain property, assuming that the quotient relation is
-- pointwise propositional.
↠-eliminator-[] :
∀ (surj : A / R ↠ B)
(P : B → Type p)
(p-[] : ∀ x → P (_↠_.to surj [ x ]))
(ok : ∀ {x y} (r : R x y) →
subst P (cong (_↠_.to surj) ([]-respects-relation r)) (p-[] x) ≡
p-[] y)
(P-set : (∀ x y → Is-proposition (R x y)) → ∀ x → Is-set (P x))
x →
(∀ {x y} → Is-proposition (R x y)) →
_↠_.from surj (_↠_.to surj [ x ]) ≡ [ x ] →
↠-eliminator surj P p-[] ok P-set (_↠_.to surj [ x ]) ≡ p-[] x
↠-eliminator-[] {R = R} surj P p-[] ok P-set x R-prop hyp =
subst P (_↠_.right-inverse-of surj (_↠_.to surj [ x ]))
(elim e′ (_↠_.from surj (_↠_.to surj [ x ]))) ≡⟨ cong (λ p → subst P p (elim e′ _)) $
H.respects-surjection surj 2 (/-is-set λ _ _ → R-prop)
(_↠_.right-inverse-of surj (_↠_.to surj [ x ]))
(cong (_↠_.to surj) hyp) ⟩
subst P (cong (_↠_.to surj) hyp)
(elim e′ (_↠_.from surj (_↠_.to surj [ x ]))) ≡⟨ D.elim
(λ {x y} p → subst P (cong (_↠_.to surj) p) (elim e′ x) ≡ elim e′ y)
(λ y →
subst P (cong (_↠_.to surj) (refl _)) (elim e′ y) ≡⟨ cong (λ p → subst P p (elim e′ _)) $ cong-refl (_↠_.to surj) ⟩
subst P (refl _) (elim e′ y) ≡⟨ subst-refl P _ ⟩∎
elim e′ y ∎)
hyp ⟩
elim e′ [ x ] ≡⟨⟩
p-[] x ∎
where
e′ = _
-- If there is a bijection from a quotient type to some other type,
-- then one can also construct a quotient-like eliminator for the
-- other type.
↔-eliminator :
(bij : A / R ↔ B)
(P : B → Type p)
(p-[] : ∀ x → P (_↔_.to bij [ x ])) →
(∀ {x y} (r : R x y) →
subst P (cong (_↔_.to bij) ([]-respects-relation r)) (p-[] x) ≡
p-[] y) →
((∀ x y → Is-proposition (R x y)) → ∀ x → Is-set (P x)) →
∀ x → P x
↔-eliminator bij = ↠-eliminator (_↔_.surjection bij)
-- This latter eliminator always "computes" in the "right" way,
-- assuming that the quotient relation is pointwise propositional.
↔-eliminator-[] :
∀ (bij : A / R ↔ B)
(P : B → Type p)
(p-[] : ∀ x → P (_↔_.to bij [ x ]))
(ok : ∀ {x y} (r : R x y) →
subst P (cong (_↔_.to bij) ([]-respects-relation r)) (p-[] x) ≡
p-[] y)
(P-set : (∀ x y → Is-proposition (R x y)) → ∀ x → Is-set (P x)) x →
(∀ {x y} → Is-proposition (R x y)) →
↔-eliminator bij P p-[] ok P-set (_↔_.to bij [ x ]) ≡ p-[] x
↔-eliminator-[] bij P p-[] ok P-set x R-prop =
↠-eliminator-[] (_↔_.surjection bij) P p-[] ok P-set x
R-prop
(_↔_.left-inverse-of bij [ x ])
-- A quotient-like eliminator for functions of type ℕ → A / R, where R
-- is a propositional equivalence relation. Defined using countable
-- choice and propositional extensionality.
--
-- This eliminator is taken from Corollary 1 in "Quotienting the Delay
-- Monad by Weak Bisimilarity" by Chapman, Uustalu and Veltri.
ℕ→/-elim :
{A : Type a} {R : A → A → Type r} →
Axiom-of-countable-choice (a ⊔ r) →
Propositional-extensionality r →
Is-equivalence-relation R →
(∀ {x y} → Is-proposition (R x y)) →
(P : (ℕ → A / R) → Type p)
(p-[] : ∀ f → P (λ n → [ f n ])) →
(∀ {f g} (r : (ℕ →ᴾ R) f g) →
subst P (cong ℕ→/-comm-to ([]-respects-relation r)) (p-[] f) ≡
p-[] g) →
(∀ f → Is-set (P f)) →
∀ f → P f
ℕ→/-elim cc prop-ext R-equiv R-prop P p-[] ok P-set =
↔-eliminator
(ℕ→/-comm cc prop-ext R-equiv R-prop)
P p-[] ok (λ _ → P-set)
-- The eliminator "computes" in the "right" way.
ℕ→/-elim-[] :
∀ {A : Type a} {R : A → A → Type r}
(cc : Axiom-of-countable-choice (a ⊔ r))
(prop-ext : Propositional-extensionality r)
(R-equiv : Is-equivalence-relation R)
(R-prop : ∀ {x y} → Is-proposition (R x y))
(P : (ℕ → A / R) → Type p)
(p-[] : ∀ f → P (λ n → [ f n ]))
(ok : ∀ {f g} (r : (ℕ →ᴾ R) f g) →
subst P (cong ℕ→/-comm-to ([]-respects-relation r)) (p-[] f) ≡
p-[] g)
(P-set : ∀ f → Is-set (P f)) f →
ℕ→/-elim cc prop-ext R-equiv R-prop P p-[] ok P-set (λ n → [ f n ]) ≡
p-[] f
ℕ→/-elim-[] {R = R} cc prop-ext R-equiv R-prop P p-[] ok P-set f =
↔-eliminator-[]
(ℕ→/-comm cc prop-ext R-equiv R-prop)
P p-[] ok (λ _ → P-set) f
(→ᴾ-preserves-Is-proposition R ext R-prop)
| {
"alphanum_fraction": 0.4224935804,
"avg_line_length": 38.9712023038,
"ext": "agda",
"hexsha": "e6cfe153615730aeb85469afd73816209b61b11a",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/equality",
"max_forks_repo_path": "src/Quotient/Set-truncated-if-propositional.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/equality",
"max_issues_repo_path": "src/Quotient/Set-truncated-if-propositional.agda",
"max_line_length": 147,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "402b20615cfe9ca944662380d7b2d69b0f175200",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/equality",
"max_stars_repo_path": "src/Quotient/Set-truncated-if-propositional.agda",
"max_stars_repo_stars_event_max_datetime": "2021-09-02T17:18:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-05-21T22:58:50.000Z",
"num_tokens": 18248,
"size": 54131
} |
module List.Sorted {A : Set}(_≤_ : A → A → Set) where
open import Data.List
data Sorted : List A → Set where
nils : Sorted []
singls : (x : A)
→ Sorted [ x ]
conss : {x y : A}{xs : List A}
→ x ≤ y
→ Sorted (y ∷ xs)
→ Sorted (x ∷ y ∷ xs)
| {
"alphanum_fraction": 0.4048338369,
"avg_line_length": 19.4705882353,
"ext": "agda",
"hexsha": "b68d745bb730bf741c6a26f9bbe238a387173d9b",
"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/Sorted.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/Sorted.agda",
"max_line_length": 54,
"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/Sorted.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": 104,
"size": 331
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.TypeQuotients where
open import Cubical.HITs.TypeQuotients.Base public
open import Cubical.HITs.TypeQuotients.Properties public
| {
"alphanum_fraction": 0.8,
"avg_line_length": 33.3333333333,
"ext": "agda",
"hexsha": "19b37df11c2a09096145088644e54b7e353e07b0",
"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/HITs/TypeQuotients.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/HITs/TypeQuotients.agda",
"max_line_length": 56,
"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/HITs/TypeQuotients.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 54,
"size": 200
} |
{-
Descriptor language for easily defining structures
-}
{-# OPTIONS --cubical --no-import-sorts --no-exact-split --safe #-}
module Cubical.Structures.Macro where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.SIP
open import Cubical.Functions.FunExtEquiv
open import Cubical.Data.Sigma
open import Cubical.Data.Maybe
open import Cubical.Structures.Constant
open import Cubical.Structures.Function
open import Cubical.Structures.Maybe
open import Cubical.Structures.Parameterized
open import Cubical.Structures.Pointed
open import Cubical.Structures.Product
data TranspDesc (ℓ : Level) : Typeω where
-- constant structure: X ↦ A
constant : ∀ {ℓ'} (A : Type ℓ') → TranspDesc ℓ
-- pointed structure: X ↦ X
var : TranspDesc ℓ
-- product of structures S,T : X ↦ (S X × T X)
_,_ : (d₀ : TranspDesc ℓ) (d₁ : TranspDesc ℓ) → TranspDesc ℓ
-- functions between structures S,T: X ↦ (S X → T X)
function : (d₀ : TranspDesc ℓ) (d₁ : TranspDesc ℓ) → TranspDesc ℓ
-- Maybe on a structure S: X ↦ Maybe (S X)
maybe : TranspDesc ℓ → TranspDesc ℓ
-- arbitrary transport structure
foreign : ∀ {ℓ'} {S : Type ℓ → Type ℓ'} (α : EquivAction S) → TransportStr α → TranspDesc ℓ
data Desc (ℓ : Level) : Typeω where
-- constant structure: X ↦ A
constant : ∀ {ℓ'} (A : Type ℓ') → Desc ℓ
-- pointed structure: X ↦ X
var : Desc ℓ
-- product of structures S,T : X ↦ (S X × T X)
_,_ : (d₀ : Desc ℓ) (d₁ : Desc ℓ) → Desc ℓ
-- functions between structures S,T : X ↦ (S X → T X)
function : (d₀ : Desc ℓ) (d₁ : Desc ℓ) → Desc ℓ
-- functions between structures S,T where S is functorial : X ↦ (S X → T X)
function+ : (d₀ : TranspDesc ℓ) (d₁ : Desc ℓ) → Desc ℓ
-- Maybe on a structure S: X ↦ Maybe (S X)
maybe : Desc ℓ → Desc ℓ
-- univalent structure from transport structure
transpDesc : TranspDesc ℓ → Desc ℓ
-- arbitrary univalent notion of structure
foreign : ∀ {ℓ' ℓ''} {S : Type ℓ → Type ℓ'} (ι : StrEquiv S ℓ'') → UnivalentStr S ι → Desc ℓ
infixr 4 _,_
{- Transport structures -}
transpMacroLevel : ∀ {ℓ} → TranspDesc ℓ → Level
transpMacroLevel (constant {ℓ'} x) = ℓ'
transpMacroLevel {ℓ} var = ℓ
transpMacroLevel {ℓ} (d₀ , d₁) = ℓ-max (transpMacroLevel d₀) (transpMacroLevel d₁)
transpMacroLevel (function d₀ d₁) = ℓ-max (transpMacroLevel d₀) (transpMacroLevel d₁)
transpMacroLevel (maybe d) = transpMacroLevel d
transpMacroLevel (foreign {ℓ'} α τ) = ℓ'
-- Structure defined by a transport descriptor
TranspMacroStructure : ∀ {ℓ} (d : TranspDesc ℓ) → Type ℓ → Type (transpMacroLevel d)
TranspMacroStructure (constant A) X = A
TranspMacroStructure var X = X
TranspMacroStructure (d₀ , d₁) X = TranspMacroStructure d₀ X × TranspMacroStructure d₁ X
TranspMacroStructure (function d₀ d₁) X = TranspMacroStructure d₀ X → TranspMacroStructure d₁ X
TranspMacroStructure (maybe d) = MaybeStructure (TranspMacroStructure d)
TranspMacroStructure (foreign {S = S} α τ) = S
-- Action defined by a transport descriptor
transpMacroAction : ∀ {ℓ} (d : TranspDesc ℓ) → EquivAction (TranspMacroStructure d)
transpMacroAction (constant A) = constantEquivAction A
transpMacroAction var = pointedEquivAction
transpMacroAction (d₀ , d₁) = productEquivAction (transpMacroAction d₀) (transpMacroAction d₁)
transpMacroAction (function d₀ d₁) =
functionEquivAction (transpMacroAction d₀) (transpMacroAction d₁)
transpMacroAction (maybe d) = maybeEquivAction (transpMacroAction d)
transpMacroAction (foreign α _) = α
-- Action defines a transport structure
transpMacroTransportStr : ∀ {ℓ} (d : TranspDesc ℓ) → TransportStr (transpMacroAction d)
transpMacroTransportStr (constant A) = constantTransportStr A
transpMacroTransportStr var = pointedTransportStr
transpMacroTransportStr (d₀ , d₁) =
productTransportStr
(transpMacroAction d₀) (transpMacroTransportStr d₀)
(transpMacroAction d₁) (transpMacroTransportStr d₁)
transpMacroTransportStr (function d₀ d₁) =
functionTransportStr
(transpMacroAction d₀) (transpMacroTransportStr d₀)
(transpMacroAction d₁) (transpMacroTransportStr d₁)
transpMacroTransportStr (maybe d) =
maybeTransportStr (transpMacroAction d) (transpMacroTransportStr d)
transpMacroTransportStr (foreign α τ) = τ
{- General structures -}
macroStrLevel : ∀ {ℓ} → Desc ℓ → Level
macroStrLevel (constant {ℓ'} x) = ℓ'
macroStrLevel {ℓ} var = ℓ
macroStrLevel {ℓ} (d₀ , d₁) = ℓ-max (macroStrLevel d₀) (macroStrLevel d₁)
macroStrLevel {ℓ} (function+ d₀ d₁) = ℓ-max (transpMacroLevel d₀) (macroStrLevel d₁)
macroStrLevel (function d₀ d₁) = ℓ-max (macroStrLevel d₀) (macroStrLevel d₁)
macroStrLevel (maybe d) = macroStrLevel d
macroStrLevel (transpDesc d) = transpMacroLevel d
macroStrLevel (foreign {ℓ'} _ _) = ℓ'
macroEquivLevel : ∀ {ℓ} → Desc ℓ → Level
macroEquivLevel (constant {ℓ'} x) = ℓ'
macroEquivLevel {ℓ} var = ℓ
macroEquivLevel (d₀ , d₁) = ℓ-max (macroEquivLevel d₀) (macroEquivLevel d₁)
macroEquivLevel {ℓ} (function+ d₀ d₁) = ℓ-max (transpMacroLevel d₀) (macroEquivLevel d₁)
macroEquivLevel (function d₀ d₁) = ℓ-max (macroStrLevel d₀) (ℓ-max (macroEquivLevel d₀) (macroEquivLevel d₁))
macroEquivLevel (maybe d) = macroEquivLevel d
macroEquivLevel (transpDesc d) = transpMacroLevel d
macroEquivLevel (foreign {ℓ'' = ℓ''} _ _) = ℓ''
-- Structure defined by a descriptor
MacroStructure : ∀ {ℓ} (d : Desc ℓ) → Type ℓ → Type (macroStrLevel d)
MacroStructure (constant A) X = A
MacroStructure var X = X
MacroStructure (d₀ , d₁) X = MacroStructure d₀ X × MacroStructure d₁ X
MacroStructure (function+ d₀ d₁) X = TranspMacroStructure d₀ X → MacroStructure d₁ X
MacroStructure (function d₀ d₁) X = MacroStructure d₀ X → MacroStructure d₁ X
MacroStructure (maybe d) = MaybeStructure (MacroStructure d)
MacroStructure (transpDesc d) = TranspMacroStructure d
MacroStructure (foreign {S = S} _ _) = S
-- Notion of structured equivalence defined by a descriptor
MacroEquivStr : ∀ {ℓ} → (d : Desc ℓ) → StrEquiv {ℓ} (MacroStructure d) (macroEquivLevel d)
MacroEquivStr (constant A) = ConstantEquivStr A
MacroEquivStr var = PointedEquivStr
MacroEquivStr (d₀ , d₁) = ProductEquivStr (MacroEquivStr d₀) (MacroEquivStr d₁)
MacroEquivStr (function+ d₀ d₁) = FunctionEquivStr+ (transpMacroAction d₀) (MacroEquivStr d₁)
MacroEquivStr (function d₀ d₁) = FunctionEquivStr (MacroEquivStr d₀) (MacroEquivStr d₁)
MacroEquivStr (maybe d) = MaybeEquivStr (MacroEquivStr d)
MacroEquivStr (transpDesc d) = EquivAction→StrEquiv (transpMacroAction d)
MacroEquivStr (foreign ι _) = ι
-- Proof that structure induced by descriptor is univalent
MacroUnivalentStr : ∀ {ℓ} → (d : Desc ℓ) → UnivalentStr (MacroStructure d) (MacroEquivStr d)
MacroUnivalentStr (constant A) = constantUnivalentStr A
MacroUnivalentStr var = pointedUnivalentStr
MacroUnivalentStr (d₀ , d₁) =
productUnivalentStr
(MacroEquivStr d₀) (MacroUnivalentStr d₀)
(MacroEquivStr d₁) (MacroUnivalentStr d₁)
MacroUnivalentStr (function+ d₀ d₁) =
functionUnivalentStr+
(transpMacroAction d₀) (transpMacroTransportStr d₀)
(MacroEquivStr d₁) (MacroUnivalentStr d₁)
MacroUnivalentStr (function d₀ d₁) =
functionUnivalentStr
(MacroEquivStr d₀) (MacroUnivalentStr d₀)
(MacroEquivStr d₁) (MacroUnivalentStr d₁)
MacroUnivalentStr (maybe d) = maybeUnivalentStr (MacroEquivStr d) (MacroUnivalentStr d)
MacroUnivalentStr (transpDesc d) =
TransportStr→UnivalentStr (transpMacroAction d) (transpMacroTransportStr d)
MacroUnivalentStr (foreign _ θ) = θ
-- Module for easy importing
module Macro ℓ (d : Desc ℓ) where
structure = MacroStructure d
equiv = MacroEquivStr d
univalent = MacroUnivalentStr d
| {
"alphanum_fraction": 0.7447474879,
"avg_line_length": 43.7885714286,
"ext": "agda",
"hexsha": "a3d759af52a6c43a90fd265bc6f9506764041424",
"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/Structures/Macro.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/Structures/Macro.agda",
"max_line_length": 109,
"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/Structures/Macro.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2530,
"size": 7663
} |
------------------------------------------------------------------------
-- Lists where all elements satisfy a given property
------------------------------------------------------------------------
module Data.List.All where
open import Data.Function
open import Data.List as List hiding (map; all)
open import Data.List.Any as Any using (here; there)
open Any.Membership-≡ using (_∈_; _⊆_)
open import Data.Product as Prod using (_,_)
open import Relation.Nullary
import Relation.Nullary.Decidable as Dec
open import Relation.Unary using (Pred) renaming (_⊆_ to _⋐_)
open import Relation.Binary.PropositionalEquality
-- All P xs means that all elements in xs satisfy P.
infixr 5 _∷_
data All {A} (P : A → Set) : List A → Set where
[] : All P []
_∷_ : ∀ {x xs} (px : P x) (pxs : All P xs) → All P (x ∷ xs)
head : ∀ {A} {P : A → Set} {x xs} → All P (x ∷ xs) → P x
head (px ∷ pxs) = px
tail : ∀ {A} {P : A → Set} {x xs} → All P (x ∷ xs) → All P xs
tail (px ∷ pxs) = pxs
lookup : ∀ {A} {P : A → Set} {xs} → All P xs → (∀ {x} → x ∈ xs → P x)
lookup [] ()
lookup (px ∷ pxs) (here refl) = px
lookup (px ∷ pxs) (there x∈xs) = lookup pxs x∈xs
tabulate : ∀ {A} {P : A → Set} {xs} → (∀ {x} → x ∈ xs → P x) → All P xs
tabulate {xs = []} hyp = []
tabulate {xs = x ∷ xs} hyp = hyp (here refl) ∷ tabulate (hyp ∘ there)
map : ∀ {A} {P Q : Pred A} → P ⋐ Q → All P ⋐ All Q
map g [] = []
map g (px ∷ pxs) = g px ∷ map g pxs
all : ∀ {A} {P : A → Set} →
(∀ x → Dec (P x)) → (xs : List A) → Dec (All P xs)
all p [] = yes []
all p (x ∷ xs) with p x
all p (x ∷ xs) | yes px = Dec.map (_∷_ px , tail) (all p xs)
all p (x ∷ xs) | no ¬px = no (¬px ∘ head)
| {
"alphanum_fraction": 0.5119047619,
"avg_line_length": 33.6,
"ext": "agda",
"hexsha": "cad0e3d2a8a02b40a1a2339788ac29a433bd8f5a",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z",
"max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "isabella232/Lemmachine",
"max_forks_repo_path": "vendor/stdlib/src/Data/List/All.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/Lemmachine",
"max_issues_repo_path": "vendor/stdlib/src/Data/List/All.agda",
"max_line_length": 72,
"max_stars_count": 56,
"max_stars_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "isabella232/Lemmachine",
"max_stars_repo_path": "vendor/stdlib/src/Data/List/All.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": 599,
"size": 1680
} |
open import Agda.Builtin.List
open import Agda.Builtin.Reflection renaming (bindTC to _>>=_)
open import Agda.Builtin.Bool
open import Agda.Builtin.Equality
open import Agda.Builtin.Nat
open import Agda.Builtin.Sigma
data Unit : Set where
unit : Unit
data Empty : Set where
qq : ∀ {a} {A : Set a} → A → Term → TC _
qq t hole = withNormalisation true do
`t ← quoteTC t
``t ← quoteTC `t
unify hole ``t
macro
qU = qq {A = Unit → Set → Set}
qE = qq {A = Empty → Set → Set}
qA = qq {A = Set → Set}
case_of_ : ∀ {a b} {A : Set a} {B : Set b} → A → (A → B) → B
case x of f = f x
pattern vArg x = arg (arg-info visible relevant) x
pattern [_] x = x ∷ []
map : {A B : Set} → (A → B) → List A → List B
map f [] = []
map f (x ∷ xs) = f x ∷ map f xs
mkArgs : List Nat → List (Arg Term)
mkArgs = map λ i → vArg (var i [])
unit,X=>_∙_ : Nat → List Nat → Term
unit,X=> n ∙ args =
pat-lam [ clause [ "X" , vArg (agda-sort (lit 0)) ]
(vArg (con (quote unit) []) ∷ vArg (var 0) ∷ [])
(var n []) ]
(mkArgs args)
abs,X=>∙_ : List Nat → Term
abs,X=>∙ is = pat-lam [ absurd-clause ( ("()" , vArg (def (quote Empty) [])) ∷ ("X" , vArg (agda-sort (lit 0))) ∷ [])
(vArg absurd ∷ vArg (var 0) ∷ []) ]
(mkArgs is)
abs=>∙_ : List Nat → Term
abs=>∙ is = pat-lam [ absurd-clause [ "()" , vArg (def (quote Empty) []) ] (vArg absurd ∷ []) ]
(mkArgs is)
_ : qU (λ { unit X → X }) ≡ unit,X=> 0 ∙ []
_ = refl
_ : (B : Set) → qU (λ { unit X → B }) ≡ unit,X=> 1 ∙ []
_ = λ _ → refl
_ : qE (λ { () X }) ≡ abs,X=>∙ []
_ = refl
_ : (B : Set) → qE (λ { () X }) ≡ abs,X=>∙ []
_ = λ _ → refl
_ : (u : Unit) → qA (case u of λ { unit X → X }) ≡ (unit,X=> 0 ∙ [ 0 ])
_ = λ _ → refl
_ : (B : Set) (u : Unit) → qA (case u of λ { unit X → B }) ≡ unit,X=> 2 ∙ [ 0 ]
_ = λ _ _ → refl
_ : (B : Set) (e : Empty) → qA (case e of λ { () X }) ≡ abs,X=>∙ [ 0 ]
_ = λ _ _ → refl
_ : qE (λ ()) ≡ abs=>∙ []
_ = refl
_ : (B : Set) → qE (λ ()) ≡ abs=>∙ []
_ = λ _ → refl
_ : (B : Set) (e : Empty) → qA (case e of λ ()) ≡ abs=>∙ [ 0 ]
_ = λ _ _ → refl
module _ (A : Set) where
_ : qU (λ { unit X → X }) ≡ unit,X=> 0 ∙ []
_ = refl
_ : (B : Set) → qU (λ { unit X → B }) ≡ unit,X=> 1 ∙ []
_ = λ _ → refl
_ : qE (λ { () X }) ≡ abs,X=>∙ []
_ = refl
_ : (u : Unit) → qA (case u of λ { unit X → X }) ≡ (unit,X=> 0 ∙ [ 0 ])
_ = λ _ → refl
_ : (B : Set) (u : Unit) → qA (case u of λ { unit X → B }) ≡ unit,X=> 2 ∙ [ 0 ]
_ = λ _ _ → refl
_ : (B : Set) (e : Empty) → qA (case e of λ { () X }) ≡ abs,X=>∙ [ 0 ]
_ = λ _ _ → refl
_ : qE (λ ()) ≡ abs=>∙ []
_ = refl
_ : (B : Set) → qE (λ ()) ≡ abs=>∙ []
_ = λ _ → refl
_ : (B : Set) (e : Empty) → qA (case e of λ ()) ≡ abs=>∙ [ 0 ]
_ = λ _ _ → refl
| {
"alphanum_fraction": 0.4527836505,
"avg_line_length": 25.1150442478,
"ext": "agda",
"hexsha": "1fa1c3e46933fac7d8bd17b5cedf32225c37bee2",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "shlevy/agda",
"max_forks_repo_path": "test/Succeed/Issue2618.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue2618.agda",
"max_line_length": 118,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue2618.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1178,
"size": 2838
} |
module API.Theorems where
open import Algebra
open import Algebra.Theorems
open import API
open import Prelude
open import Reasoning
-- vertices [x] == vertex x
vertices-vertex : ∀ {A} {x : A} -> vertices [ x ] ≡ vertex x
vertices-vertex = +identity >> reflexivity
-- edge x y == clique [x, y]
edge-clique : ∀ {A} {x y : A} -> edge x y ≡ clique (x :: [ y ])
edge-clique = symmetry (R *right-identity)
-- vertices xs ⊆ clique xs
vertices-clique : ∀ {A} {xs : List A} -> vertices xs ⊆ clique xs
vertices-clique {_} {[]} = ⊆reflexivity
vertices-clique {a} {_ :: t} = ⊆transitivity (⊆right-monotony (vertices-clique {a} {t})) ⊆connect
-- clique (xs ++ ys) == connect (clique xs) (clique ys)
connect-clique : ∀ {A} {xs ys : List A} -> clique (xs ++ ys) ≡ connect (clique xs) (clique ys)
connect-clique {_} {[]} = symmetry *left-identity
connect-clique {a} {_ :: t} = R (connect-clique {a} {t}) >> *associativity
| {
"alphanum_fraction": 0.6201058201,
"avg_line_length": 36.3461538462,
"ext": "agda",
"hexsha": "520acc88c581f4874f9233e6bd2b65d3f09f8eed",
"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": "01f5f9f53ea81f692215300744aa77e26d8bf332",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/alga",
"max_forks_repo_path": "src/API/Theorems.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "01f5f9f53ea81f692215300744aa77e26d8bf332",
"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": "asr/alga",
"max_issues_repo_path": "src/API/Theorems.agda",
"max_line_length": 98,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "01f5f9f53ea81f692215300744aa77e26d8bf332",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/alga",
"max_stars_repo_path": "src/API/Theorems.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 301,
"size": 945
} |
module LC.Reduction where
open import LC.Base
open import LC.Subst
open import Data.Nat
open import Data.Nat.Properties
open import Relation.Nullary
-- β-reduction
infix 3 _β→_
data _β→_ : Term → Term → Set where
β-ƛ-∙ : ∀ {M N} → ((ƛ M) ∙ N) β→ (M [ N ])
β-ƛ : ∀ {M N} → M β→ N → ƛ M β→ ƛ N
β-∙-l : ∀ {L M N} → M β→ N → M ∙ L β→ N ∙ L
β-∙-r : ∀ {L M N} → M β→ N → L ∙ M β→ L ∙ N
open import Relation.Binary.Construct.Closure.ReflexiveTransitive
infix 2 _β→*_
_β→*_ : Term → Term → Set
_β→*_ = Star _β→_
{-# DISPLAY Star _β→_ = _β→*_ #-}
open import Relation.Binary.PropositionalEquality hiding ([_]; preorder)
≡⇒β→* : ∀ {M N} → M ≡ N → M β→* N
≡⇒β→* refl = ε
cong-var : ∀ {x y} → x ≡ y → var x β→* var y
cong-var {x} {y} refl = ε
cong-ƛ : {M N : Term} → M β→* N → ƛ M β→* ƛ N
cong-ƛ = gmap _ β-ƛ
cong-∙-l : {L M N : Term} → M β→* N → M ∙ L β→* N ∙ L
cong-∙-l = gmap _ β-∙-l
cong-∙-r : {L M N : Term} → M β→* N → L ∙ M β→* L ∙ N
cong-∙-r = gmap _ β-∙-r
cong-∙ : {M M' N N' : Term} → M β→* M' → N β→* N' → M ∙ N β→* M' ∙ N'
cong-∙ M→M' N→N' = (cong-∙-l M→M') ◅◅ (cong-∙-r N→N')
open import LC.Subst.Term
cong-lift : {n i : ℕ} {M N : Term} → M β→ N → lift n i M β→* lift n i N
cong-lift (β-ƛ M→N) = cong-ƛ (cong-lift M→N)
cong-lift (β-ƛ-∙ {M} {N}) = β-ƛ-∙ ◅ ≡⇒β→* (lemma M N)
cong-lift (β-∙-l M→N) = cong-∙-l (cong-lift M→N)
cong-lift (β-∙-r M→N) = cong-∙-r (cong-lift M→N)
cong-[]-r : ∀ L {M N i} → M β→ N → L [ M / i ] β→* L [ N / i ]
cong-[]-r (var x) {M} {N} {i} M→N with match x i
... | Under _ = ε
... | Exact _ = cong-lift M→N
... | Above _ _ = ε
cong-[]-r (ƛ L) M→N = cong-ƛ (cong-[]-r L M→N)
cong-[]-r (K ∙ L) M→N = cong-∙ (cong-[]-r K M→N) (cong-[]-r L M→N)
cong-[]-l : ∀ {M N L i} → M β→ N → M [ L / i ] β→* N [ L / i ]
cong-[]-l {ƛ M} (β-ƛ M→N) = cong-ƛ (cong-[]-l M→N)
cong-[]-l {.(ƛ K) ∙ M} {L = L} (β-ƛ-∙ {K}) = β-ƛ-∙ ◅ ≡⇒β→* (subst-lemma K M L)
cong-[]-l {K ∙ M} (β-∙-l M→N) = cong-∙-l (cong-[]-l M→N)
cong-[]-l {K ∙ M} (β-∙-r M→N) = cong-∙-r (cong-[]-l M→N)
cong-[] : {M M' N N' : Term} → M β→* M' → N β→* N' → M [ N ] β→* M' [ N' ]
cong-[] {M} ε ε = ε
cong-[] {M} {N = L} {N'} ε (_◅_ {j = N} L→N N→N') = M[L]→M[N] ◅◅ M[N]→M[N']
where
M[L]→M[N] : M [ L ] β→* M [ N ]
M[L]→M[N] = cong-[]-r M L→N
M[N]→M[N'] : M [ N ] β→* M [ N' ]
M[N]→M[N'] = cong-[] {M} ε N→N'
cong-[] {M} (K→M ◅ M→M') N→N' = cong-[]-l K→M ◅◅ cong-[] M→M' N→N'
| {
"alphanum_fraction": 0.4381709742,
"avg_line_length": 29.5882352941,
"ext": "agda",
"hexsha": "4ac1eae2d07c0eab6556c1eac17ff2596960da2b",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/bidirectional",
"max_forks_repo_path": "LC/Reduction.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "banacorn/bidirectional",
"max_issues_repo_path": "LC/Reduction.agda",
"max_line_length": 79,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "0c9a6e79c23192b28ddb07315b200a94ee900ca6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/bidirectional",
"max_stars_repo_path": "LC/Reduction.agda",
"max_stars_repo_stars_event_max_datetime": "2020-08-25T14:05:01.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-08-25T07:34:40.000Z",
"num_tokens": 1358,
"size": 2515
} |
-- Copyright: (c) 2016 Ertugrul Söylemez
-- License: BSD3
-- Maintainer: Ertugrul Söylemez <esz@posteo.de>
--
-- This module contains definitions that are fundamental and/or used
-- everywhere.
module Core where
open import Agda.Builtin.Equality public
renaming (refl to ≡-refl)
using (_≡_)
open import Agda.Builtin.FromNat public
open import Agda.Builtin.FromNeg public
open import Agda.Builtin.FromString public
open import Agda.Builtin.Unit using (⊤; tt) public
open import Agda.Primitive using (Level; lsuc; lzero; _⊔_) public
-- An empty type (or a false hypothesis).
data ⊥ : Set where
-- Dependent sums (or existential quantification).
record Σ {a b} (A : Set a) (B : A → Set b) : Set (a ⊔ b) where
constructor _,_
field
fst : A
snd : B fst
open Σ public
infixr 4 _,_
infixr 0 _because_ _because:_
∃ : ∀ {a b} {A : Set a} (B : A → Set b) → Set (a ⊔ b)
∃ = Σ _
_because_ : ∀ {a b} {A : Set a} {B : A → Set b} → (x : A) → B x → Σ A B
_because_ = _,_
_because:_ : ∀ {a b} {A : Set a} {B : A → Set b} → (x : A) → B x → Σ A B
_because:_ = _,_
_×_ : ∀ {a b} (A : Set a) (B : Set b) → Set (a ⊔ b)
A × B = Σ A (λ _ → B)
infixr 7 _×_
-- Tagged unions.
data Either {a} {b} (A : Set a) (B : Set b) : Set (a ⊔ b) where
Left : A → Either A B
Right : B → Either A B
-- Equivalence relations.
record Equiv {a r} (A : Set a) : Set (a ⊔ lsuc r) where
field
_≈_ : A → A → Set r
refl : ∀ {x} → x ≈ x
sym : ∀ {x y} → x ≈ y → y ≈ x
trans : ∀ {x y z} → x ≈ y → y ≈ z → x ≈ z
infix 4 _≈_
-- Helper functions for equational reasoning.
begin_ : ∀ {x y} → x ≈ y → x ≈ y
begin_ p = p
_≈[_]_ : ∀ x {y z} → x ≈ y → y ≈ z → x ≈ z
_ ≈[ x≈y ] y≈z = trans x≈y y≈z
_≈[]_ : ∀ x {y} → x ≈ y → x ≈ y
_ ≈[] p = p
_qed : ∀ (x : A) → x ≈ x
_qed _ = refl
infix 1 begin_
infixr 2 _≈[_]_ _≈[]_
infix 3 _qed
PropEq : ∀ {a} → (A : Set a) → Equiv A
PropEq A =
record {
_≈_ = _≡_;
refl = ≡-refl;
sym = sym';
trans = trans'
}
where
sym' : ∀ {x y} → x ≡ y → y ≡ x
sym' ≡-refl = ≡-refl
trans' : ∀ {x y z} → x ≡ y → y ≡ z → x ≡ z
trans' ≡-refl q = q
module PropEq {a} {A : Set a} = Equiv (PropEq A)
FuncEq : ∀ {a b} (A : Set a) (B : Set b) → Equiv (A → B)
FuncEq A B =
record {
_≈_ = λ f g → ∀ x → f x ≡ g x;
refl = λ _ → ≡-refl;
sym = λ p x → PropEq.sym (p x);
trans = λ p q x → PropEq.trans (p x) (q x)
}
module FuncEq {a b} {A : Set a} {B : Set b} = Equiv (FuncEq A B)
cong : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) {x y} → x ≡ y → f x ≡ f y
cong _ ≡-refl = ≡-refl
cong2 :
∀ {a b c} {A : Set a} {B : Set b} {C : Set c}
(f : A → B → C)
→ ∀ {x1 x2 : A} {y1 y2 : B}
→ x1 ≡ x2
→ y1 ≡ y2
→ f x1 y1 ≡ f x2 y2
cong2 _ ≡-refl ≡-refl = ≡-refl
-- Partial orders.
record PartialOrder {a re rl} (A : Set a) : Set (a ⊔ lsuc (re ⊔ rl)) where
field Eq : Equiv {r = re} A
module ≈ = Equiv Eq
open ≈ public using (_≈_)
field
_≤_ : (x : A) → (y : A) → Set rl
antisym : ∀ {x y} → x ≤ y → y ≤ x → x ≈ y
refl' : ∀ {x y} → x ≈ y → x ≤ y
trans : ∀ {x y z} → x ≤ y → y ≤ z → x ≤ z
infix 4 _≤_
refl : ∀ {x} → x ≤ x
refl = refl' ≈.refl
-- Helper functions for transitivity reasoning.
begin_ : ∀ {x y} → x ≤ y → x ≤ y
begin_ p = p
_≤[_]_ : ∀ x {y z} → x ≤ y → y ≤ z → x ≤ z
_ ≤[ x≤y ] y≤z = trans x≤y y≤z
_≤[]_ : ∀ x {y} → x ≤ y → x ≤ y
_ ≤[] p = p
_qed : ∀ (x : A) → x ≤ x
_qed _ = refl
infix 1 begin_
infixr 2 _≤[_]_ _≤[]_
infix 3 _qed
-- Total orders.
record TotalOrder {a re rl} (A : Set a) : Set (a ⊔ lsuc (re ⊔ rl)) where
field partialOrder : PartialOrder {a} {re} {rl} A
open PartialOrder partialOrder public
field
total : ∀ x y → Either (x ≤ y) (y ≤ x)
-- Low-priority function application.
_$_ : ∀ {a} {A : Set a} → A → A
_$_ f = f
infixr 0 _$_
-- Given two predicates, this is the predicate that requires both.
_and_ : ∀ {a r1 r2} {A : Set a} → (A → Set r1) → (A → Set r2) → A → Set (r1 ⊔ r2)
(P and Q) x = P x × Q x
infixr 6 _and_
-- Use instance resolution to find a value of the target type.
it : ∀ {a} {A : Set a} {{_ : A}} → A
it {{x}} = x
-- Not.
not : ∀ {a} → Set a → Set a
not A = A → ⊥
-- Given two predicates, this is the predicate that requires at least
-- one of them.
_or_ : ∀ {a r1 r2} {A : Set a} → (A → Set r1) → (A → Set r2) → A → Set (r1 ⊔ r2)
(P or Q) x = Either (P x) (Q x)
-- Values with inline type signatures.
the : ∀ {a} (A : Set a) → A → A
the _ x = x
-- Decidable properties.
data Decision {a} (P : Set a) : Set a where
yes : (p : P) → Decision P
no : (np : not P) → Decision P
| {
"alphanum_fraction": 0.5163511188,
"avg_line_length": 20.9369369369,
"ext": "agda",
"hexsha": "7c102e8cfabc63a931abd4b95569682dcaa75022",
"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": "d9245e5a8b2e902781736de09bd17e81022f6f13",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "esoeylemez/agda-simple",
"max_forks_repo_path": "Core.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d9245e5a8b2e902781736de09bd17e81022f6f13",
"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": "esoeylemez/agda-simple",
"max_issues_repo_path": "Core.agda",
"max_line_length": 81,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "d9245e5a8b2e902781736de09bd17e81022f6f13",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "esoeylemez/agda-simple",
"max_stars_repo_path": "Core.agda",
"max_stars_repo_stars_event_max_datetime": "2019-10-07T17:36:42.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-10-07T17:36:42.000Z",
"num_tokens": 2013,
"size": 4648
} |
module Oscar.Data.Term.AlphaConversion.internal {𝔣} (FunctionName : Set 𝔣) where
open import Oscar.Data.Term FunctionName
open import Oscar.Data.Equality
open import Oscar.Data.Fin
open import Oscar.Data.Vec
open import Oscar.Function
open import Oscar.Relation
infixr 19 _◂_ _◂s_
mutual
_◂_ : ∀ {m n} → m ⟨ Fin ⟩→ n → m ⟨ Term ⟩→ n
_◂_ f (i 𝑥) = i (f 𝑥)
_◂_ f leaf = leaf
_◂_ f (τ₁ fork τ₂) = (f ◂ τ₁) fork (f ◂ τ₂)
_◂_ f (function 𝑓 τs) = function 𝑓 (f ◂s τs)
_◂s_ : ∀ {m n} → m ⟨ Fin ⟩→ n → ∀ {N} → m ⟨ Terms N ⟩→ n
_◂s_ f [] = []
_◂s_ f (τ ∷ τs) = f ◂ τ ∷ f ◂s τs
mutual
◂-identity : ∀ {m} (τ : Term m) → id ◂ τ ≡ τ
◂-identity (i _) = refl
◂-identity leaf = refl
◂-identity (τ₁ fork τ₂) rewrite ◂-identity τ₁ | ◂-identity τ₂ = refl
◂-identity (function 𝑓 τs) rewrite ◂s-identity τs = refl
◂s-identity : ∀ {N m} (τs : Terms N m) → id ◂s τs ≡ τs
◂s-identity [] = refl
◂s-identity (τ ∷ τs) rewrite ◂-identity τ | ◂s-identity τs = refl
mutual
◂-associativity : ∀ {l m n} (f : l ⟨ Fin ⟩→ m) (g : m ⟨ Fin ⟩→ n) → (τ : Term l) → (g ∘ f) ◂ τ ≡ g ◂ f ◂ τ
◂-associativity _ _ (i _) = refl
◂-associativity _ _ leaf = refl
◂-associativity f g (τ₁ fork τ₂) rewrite ◂-associativity f g τ₁ | ◂-associativity f g τ₂ = refl
◂-associativity f g (function 𝑓 τs) rewrite ◂s-associativity f g τs = refl
◂s-associativity : ∀ {l m n} (f : l ⟨ Fin ⟩→ m) (g : m ⟨ Fin ⟩→ n) → ∀ {N} (x : Terms N l) → (g ∘ f) ◂s x ≡ g ◂s f ◂s x
◂s-associativity _ _ [] = refl
◂s-associativity f g (τ ∷ τs) rewrite ◂-associativity f g τ | ◂s-associativity f g τs = refl
mutual
◂-extensionality : ∀ {m n} {f g : m ⟨ Fin ⟩→ n} → f ≡̇ g → f ◂_ ≡̇ g ◂_
◂-extensionality f≡̇g (i 𝑥) rewrite f≡̇g 𝑥 = refl
◂-extensionality f≡̇g leaf = refl
◂-extensionality f≡̇g (τ₁ fork τ₂) rewrite ◂-extensionality f≡̇g τ₁ | ◂-extensionality f≡̇g τ₂ = refl
◂-extensionality f≡̇g (function 𝑓 τs) rewrite ◂s-extensionality f≡̇g τs = refl
◂s-extensionality : ∀ {m n} {f g : m ⟨ Fin ⟩→ n} → f ≡̇ g → ∀ {N} → _◂s_ f {N} ≡̇ _◂s_ g {N}
◂s-extensionality _ [] = refl
◂s-extensionality f≡̇g (τ ∷ τs) rewrite ◂-extensionality f≡̇g τ | ◂s-extensionality f≡̇g τs = refl
| {
"alphanum_fraction": 0.5818014706,
"avg_line_length": 35.6721311475,
"ext": "agda",
"hexsha": "0b29014f06d4c653c84758eb7bd93f58f45435b5",
"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/AlphaConversion/internal.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/AlphaConversion/internal.agda",
"max_line_length": 121,
"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/AlphaConversion/internal.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1023,
"size": 2176
} |
{-# OPTIONS --warning=error --safe --without-K #-}
open import LogicalFormulae
open import Numbers.Naturals.Definition
module Numbers.Naturals.Addition where
infix 15 _+N_
_+N_ : ℕ → ℕ → ℕ
zero +N y = y
succ x +N y = succ (x +N y)
{-# BUILTIN NATPLUS _+N_ #-}
addZeroRight : (x : ℕ) → (x +N zero) ≡ x
addZeroRight zero = refl
addZeroRight (succ x) rewrite addZeroRight x = refl
private
succExtracts : (x y : ℕ) → (x +N succ y) ≡ (succ (x +N y))
succExtracts zero y = refl
succExtracts (succ x) y = applyEquality succ (succExtracts x y)
succCanMove : (x y : ℕ) → (x +N succ y) ≡ (succ x +N y)
succCanMove x y = transitivity (succExtracts x y) refl
additionNIsCommutative : (x y : ℕ) → (x +N y) ≡ (y +N x)
additionNIsCommutative zero y = equalityCommutative (addZeroRight y)
additionNIsCommutative (succ x) zero = transitivity (addZeroRight (succ x)) refl
additionNIsCommutative (succ x) (succ y) = transitivity refl (applyEquality succ (transitivity (succCanMove x y) (additionNIsCommutative (succ x) y)))
addingPreservesEqualityRight : {a b : ℕ} (c : ℕ) → (a ≡ b) → (a +N c ≡ b +N c)
addingPreservesEqualityRight {a} {b} c pr = applyEquality (λ n -> n +N c) pr
addingPreservesEqualityLeft : {a b : ℕ} (c : ℕ) → (a ≡ b) → (c +N a ≡ c +N b)
addingPreservesEqualityLeft {a} {b} c pr = applyEquality (λ n -> c +N n) pr
additionNIsAssociative : (a b c : ℕ) → ((a +N b) +N c) ≡ (a +N (b +N c))
additionNIsAssociative zero b c = refl
additionNIsAssociative (succ a) zero c = transitivity (transitivity (applyEquality (λ n → n +N c) (applyEquality succ (addZeroRight a))) refl) (transitivity refl refl)
additionNIsAssociative (succ a) (succ b) c = transitivity refl (transitivity refl (transitivity (applyEquality succ (additionNIsAssociative a (succ b) c)) refl))
succIsAddOne : (a : ℕ) → succ a ≡ a +N succ zero
succIsAddOne a = equalityCommutative (transitivity (additionNIsCommutative a (succ zero)) refl)
canSubtractFromEqualityRight : {a b c : ℕ} → (a +N b ≡ c +N b) → a ≡ c
canSubtractFromEqualityRight {a} {zero} {c} pr = transitivity (equalityCommutative (addZeroRight a)) (transitivity pr (addZeroRight c))
canSubtractFromEqualityRight {a} {succ b} {c} pr rewrite additionNIsCommutative a (succ b) | additionNIsCommutative c (succ b) | additionNIsCommutative b a | additionNIsCommutative b c = canSubtractFromEqualityRight {a} {b} {c} (succInjective pr)
canSubtractFromEqualityLeft : {a b c : ℕ} → (a +N b ≡ a +N c) → b ≡ c
canSubtractFromEqualityLeft {a} {b} {c} pr rewrite additionNIsCommutative a b | additionNIsCommutative a c = canSubtractFromEqualityRight {b} {a} {c} pr
| {
"alphanum_fraction": 0.7035040431,
"avg_line_length": 51.94,
"ext": "agda",
"hexsha": "f892dbcfab15c9dc18dcc760328dc51d4dd72ce0",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Numbers/Naturals/Addition.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Numbers/Naturals/Addition.agda",
"max_line_length": 246,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Numbers/Naturals/Addition.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z",
"num_tokens": 911,
"size": 2597
} |
module ProcessSyntax where
open import Data.List
open import Typing
open import Syntax
-- processes
data Proc (Φ : TCtx) : Set where
exp : (e : Expr Φ TUnit)
→ Proc Φ
par : ∀ {Φ₁ Φ₂}
→ (sp : Split Φ Φ₁ Φ₂)
→ (P₁ : Proc Φ₁)
→ (P₂ : Proc Φ₂)
→ Proc Φ
res : (s : SType)
→ (P : Proc (TChan (SType.force s) ∷ TChan (SType.force (dual s)) ∷ Φ))
→ Proc Φ
| {
"alphanum_fraction": 0.5644329897,
"avg_line_length": 16.8695652174,
"ext": "agda",
"hexsha": "0340d5fa639aea8142c22b58c731f9292b40d667",
"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": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "peterthiemann/definitional-session",
"max_forks_repo_path": "src/ProcessSyntax.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c",
"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": "peterthiemann/definitional-session",
"max_issues_repo_path": "src/ProcessSyntax.agda",
"max_line_length": 75,
"max_stars_count": 9,
"max_stars_repo_head_hexsha": "c2213909c8a308fb1c1c1e4e789d65ba36f6042c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "peterthiemann/definitional-session",
"max_stars_repo_path": "src/ProcessSyntax.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-18T08:10:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-01-19T16:33:27.000Z",
"num_tokens": 156,
"size": 388
} |
------------------------------------------------------------------------------
-- Distributive laws on a binary operation: Task B
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module DistributiveLaws.TaskB-TopDownATP where
open import DistributiveLaws.Base
open import Common.FOL.Relation.Binary.EqReasoning
------------------------------------------------------------------------------
-- We found the longest chains of equalities from
-- DistributiveLaws.TaskB-I which are prove by the ATPs, following a
-- top-down approach.
prop₂ : ∀ u x y z → (x · y · (z · u)) ·
(( x · y · ( z · u)) · (x · z · (y · u))) ≡
x · z · (y · u)
prop₂ u x y z =
-- The numbering of the proof step justifications are associated with
-- the numbers used in DistributiveLaws.TaskB-I.
xy·zu · (xy·zu · xz·yu) ≡⟨ j₁₋₅ ⟩
xy·zu · (xz · xu·yu · (y·zu · xz·yu)) ≡⟨ j₅₋₉ ⟩
xy·zu · (xz · xyu · (yxz · yu)) ≡⟨ j₉₋₁₄ ⟩
xz · xyu · (yz · xyu) · (xz · xyu · (y·xu · z·yu)) ≡⟨ j₁₄₋₂₀ ⟩
xz · xyu · (y·xu · (y·yu · z·yu) · (z · xu·yu · (y·xu · z·yu))) ≡⟨ j₂₀₋₂₃ ⟩
xz · xyu · (y · xu·zu · (z · xu·yu · (y·xu · z·yu))) ≡⟨ j₂₃₋₂₅ ⟩
(xz · xyu) · (y · xu·zu · (z·xu · y·xu · z·yu)) ≡⟨ j₂₅₋₃₀ ⟩
xz · xyu · (y·zy · xzu) ≡⟨ j₃₀₋₃₅ ⟩
xz·yu ∎
where
-- Two variables abbreviations
xz = x · z
yu = y · u
yz = y · z
{-# ATP definitions xz yu yz #-}
-- Three variables abbreviations
xyu = x · y · u
xyz = x · y · z
xzu = x · z · u
yxz = y · x · z
{-# ATP definitions xyu xyz xzu yxz #-}
y·xu = y · (x · u)
y·yu = y · (y · u)
y·zu = y · (z · u)
y·zy = y · (z · y)
{-# ATP definitions y·xu y·yu y·zu y·zy #-}
z·xu = z · (x · u)
z·yu = z · (y · u)
{-# ATP definitions z·xu z·yu #-}
-- Four variables abbreviations
xu·yu = x · u · (y · u)
xu·zu = x · u · (z · u)
{-# ATP definitions xu·yu xu·zu #-}
xy·zu = x · y · (z · u)
{-# ATP definition xy·zu #-}
xz·yu = x · z · (y · u)
{-# ATP definition xz·yu #-}
-- Steps justifications
postulate j₁₋₅ : xy·zu · (xy·zu · xz·yu) ≡
xy·zu · (xz · xu·yu · (y·zu · xz·yu))
{-# ATP prove j₁₋₅ #-}
postulate j₅₋₉ : xy·zu · (xz · xu·yu · (y·zu · xz·yu)) ≡
xy·zu · (xz · xyu · (yxz · yu))
{-# ATP prove j₅₋₉ #-}
postulate j₉₋₁₄ : xy·zu · (xz · xyu · (yxz · yu)) ≡
xz · xyu · (yz · xyu) · (xz · xyu · (y·xu · z·yu))
{-# ATP prove j₉₋₁₄ #-}
postulate
j₁₄₋₂₀ : xz · xyu · (yz · xyu) · (xz · xyu · (y·xu · z·yu)) ≡
xz · xyu · (y·xu · (y·yu · z·yu) · (z · xu·yu · (y·xu · z·yu)))
{-# ATP prove j₁₄₋₂₀ #-}
postulate
j₂₀₋₂₃ : xz · xyu · (y·xu · (y·yu · z·yu) · (z · xu·yu · (y·xu · z·yu))) ≡
xz · xyu · (y · xu·zu · (z · xu·yu · (y·xu · z·yu)))
{-# ATP prove j₂₀₋₂₃ #-}
postulate j₂₃₋₂₅ : xz · xyu · (y · xu·zu · (z · xu·yu · (y·xu · z·yu))) ≡
(xz · xyu) · (y · xu·zu · (z·xu · y·xu · z·yu))
{-# ATP prove j₂₃₋₂₅ #-}
postulate j₂₅₋₃₀ : (xz · xyu) · (y · xu·zu · (z·xu · y·xu · z·yu)) ≡
xz · xyu · (y·zy · xzu)
{-# ATP prove j₂₅₋₃₀ #-}
postulate j₃₀₋₃₅ : xz · xyu · (y·zy · xzu) ≡ xz·yu
{-# ATP prove j₃₀₋₃₅ #-}
| {
"alphanum_fraction": 0.4074175824,
"avg_line_length": 33.0909090909,
"ext": "agda",
"hexsha": "30cde74d0802b99e9436da31bca028f19426b0d6",
"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/DistributiveLaws/TaskB-TopDownATP.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/DistributiveLaws/TaskB-TopDownATP.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/DistributiveLaws/TaskB-TopDownATP.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": 1480,
"size": 3640
} |
module Sandbox.IndRec where
-- Ornamental Algebras, Algebraic Ornaments, CONOR McBRIDE
-- https://personal.cis.strath.ac.uk/conor.mcbride/pub/OAAO/Ornament.pdf
-- A Finite Axiomtization of Inductive-Recursion definitions, Peter Dybjer, Anton Setzer
-- http://www.cse.chalmers.se/~peterd/papers/Finite_IR.pdf
open import Data.Product using (_×_; Σ; _,_)
open import Data.Bool
open import Data.Unit
open import Data.Empty
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning
data Desc : Set₁ where
arg : (A : Set) -- a bag of tags to choose constructors with
→ (A → Desc) -- given a tag, return the description of the constructor it corresponds to
→ Desc
rec : Desc → Desc -- recursive subnode
ret : Desc -- stop
-- the "decoder", "interpreter"
⟦_⟧ : Desc → Set → Set
⟦ arg A D ⟧ R = Σ A (λ a → ⟦ D a ⟧ R)
⟦ rec D ⟧ R = R × ⟦ D ⟧ R
⟦ ret ⟧ R = ⊤
-- "μ" in some other literature
data Data (D : Desc) : Set where
⟨_⟩ : ⟦ D ⟧ (Data D) → Data D -- or "in"
out : ∀ {D} → Data D → ⟦ D ⟧ (Data D)
out ⟨ x ⟩ = x
map : ∀ {A B} → (d : Desc) → (A → B) → ⟦ d ⟧ A → ⟦ d ⟧ B
map (arg A d) f (a , y) = a , (map (d a) f y)
map (rec desc) f (a , x) = (f a) , (map desc f x)
map (ret) f tt = tt
-- fold : ∀ {A} → (F : Desc) → (⟦ F ⟧ A → A) → Data F → A
-- fold F alg ⟨ x ⟩ = alg (map F (fold F alg) x)
-- mapFold F alg x = map F (fold F alg) x
-- fold F alg x = alg (mapFold F alg (out x))
-- mapFold F alg x = map F (λ y → alg (mapFold F alg (out y))) x
mapFold : ∀ {A} (F G : Desc) → (⟦ G ⟧ A → A) → ⟦ F ⟧ (Data G) → ⟦ F ⟧ A
mapFold (arg T decoder) G alg (t , cnstrctr) = t , (mapFold (decoder t) G alg cnstrctr)
mapFold (rec F) G alg (⟨ x ⟩ , xs) = alg (mapFold G G alg x) , mapFold F G alg xs
mapFold ret G alg x = tt
fold : ∀ {A} → (F : Desc) → (⟦ F ⟧ A → A) → Data F → A
fold F alg ⟨ x ⟩ = alg (mapFold F F alg x)
-- ℕ
ℕDesc : Desc
ℕDesc = arg Bool λ { false → ret
; true → rec ret }
ℕ : Set
ℕ = Data ℕDesc
zero : ℕ
zero = ⟨ (false , tt) ⟩
suc : ℕ → ℕ
suc n = ⟨ (true , (n , tt)) ⟩
-- induction principle on ℕ
indℕ : (P : ℕ → Set)
→ (P zero)
→ ((n : ℕ) → (P n) → (P (suc n)))
→ (x : ℕ)
→ P x
indℕ P base step ⟨ true , n-1 , _ ⟩ = step n-1 (indℕ P base step n-1)
indℕ P base step ⟨ false , _ ⟩ = base
_+_ : ℕ → ℕ → ℕ
x + y = indℕ (λ _ → ℕ) y (λ n x → suc x) x
-- Maybe
MaybeDesc : Set → Desc
MaybeDesc A = arg Bool (λ { false → ret ; true → arg A (λ x → ret) })
Maybe : Set → Set
Maybe A = Data (MaybeDesc A)
nothing : ∀ {A} → Maybe A
nothing = ⟨ (false , tt) ⟩
just : ∀ {A} → A → Maybe A
just a = ⟨ (true , (a , tt)) ⟩
mapMaybe : ∀ {A B} → (A → B) → Maybe A → Maybe B
mapMaybe f ⟨ true , a , tt ⟩ = ⟨ (true , ((f a) , tt)) ⟩
mapMaybe f ⟨ false , tt ⟩ = ⟨ false , tt ⟩
-- List
ListDesc : Set → Desc
ListDesc A = arg Bool (λ { false → ret ; true → arg A (λ _ → rec ret )})
List : Set → Set
List A = Data (ListDesc A)
nil : ∀ {A} → List A
nil = ⟨ (false , tt) ⟩
cons : ∀ {A} → A → List A → List A
cons x xs = ⟨ (true , (x , (xs , tt))) ⟩
foldList : ∀ {A B} (f : A → B → B) → B → List A → B
foldList {A} {B} f e xs = fold (ListDesc A) alg xs
where alg : ⟦ ListDesc A ⟧ B → B
alg (true , n , acc , tt) = f n acc
alg (false , tt) = e
| {
"alphanum_fraction": 0.5313630881,
"avg_line_length": 28.5862068966,
"ext": "agda",
"hexsha": "4fb1868c7608041e6e4b1ab79f59466587bfaa3c",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/numeral",
"max_forks_repo_path": "Sandbox/IndRec.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "banacorn/numeral",
"max_issues_repo_path": "Sandbox/IndRec.agda",
"max_line_length": 107,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/numeral",
"max_stars_repo_path": "Sandbox/IndRec.agda",
"max_stars_repo_stars_event_max_datetime": "2015-04-23T15:58:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-23T15:58:28.000Z",
"num_tokens": 1285,
"size": 3316
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Finite where
open import Level
open import Data.Nat using (ℕ)
open import Data.Fin
open import Categories.Adjoint.Equivalence
open import Categories.Category
open import Categories.Functor
open import Categories.Category.Finite.Fin
-- definition of a finite category
--
-- the idea is to require a functor from C to a category generated from a finite shape
-- is the right adjoint.
--
-- Question: it seems to me right adjoint is enough, though the original plan is to
-- use adjoint equivalence. intuitively, the shape category is an "overapproximation"
-- of C, which is a very strong constraint. so requiring adjoint equivalence sounds an
-- unnecessarily stronger constraint. is adjoint equivalence necessary?
--
-- Answer: probably yes. adjoint equivalence seems necessary as the notion needs to
-- show that shapes are preserved.
--
-- c.f. Categories.Adjoint.Equivalence.Properties.⊣equiv-preserves-diagram
record Finite {o ℓ e} (C : Category o ℓ e) : Set (o ⊔ ℓ ⊔ e) where
field
shape : FinCatShape
open FinCatShape public renaming (size to ∣Obj∣)
shapeCat : Category _ _ _
shapeCat = FinCategory shape
--
-- /------------\
-- < - \
-- C | S
-- \ - ^
-- \------------/
--
field
⊣equiv : ⊣Equivalence shapeCat C
module ⊣equiv = ⊣Equivalence ⊣equiv
open ⊣equiv public
| {
"alphanum_fraction": 0.688466948,
"avg_line_length": 29.0204081633,
"ext": "agda",
"hexsha": "6c9900f47a9f1b17a5414ffd4bf56a06b9cd9378",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MirceaS/agda-categories",
"max_forks_repo_path": "src/Categories/Category/Finite.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "MirceaS/agda-categories",
"max_issues_repo_path": "src/Categories/Category/Finite.agda",
"max_line_length": 86,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "58e5ec015781be5413bdf968f7ec4fdae0ab4b21",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MirceaS/agda-categories",
"max_stars_repo_path": "src/Categories/Category/Finite.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 367,
"size": 1422
} |
module Generic.Lib.Data.Maybe where
open import Data.Maybe.Base using (Maybe; just; nothing; maybe; maybe′; from-just; fromMaybe) public
open import Generic.Lib.Intro
open import Generic.Lib.Category
infixr 0 _?>_
instance
MaybeMonad : ∀ {α} -> RawMonad {α} Maybe
MaybeMonad = record
{ return = just
; _>>=_ = Data.Maybe.Base._>>=_
}
MaybeApplicative : ∀ {α} -> RawApplicative {α} Maybe
MaybeApplicative = rawIApplicative
MaybeFunctor : ∀ {α} -> RawFunctor {α} Maybe
MaybeFunctor = rawFunctor
_?>_ : ∀ {α} {A : Set α} -> Bool -> A -> Maybe A
true ?> x = just x
false ?> x = nothing
| {
"alphanum_fraction": 0.6601626016,
"avg_line_length": 23.6538461538,
"ext": "agda",
"hexsha": "e2fb283e3894058dd0b03b3fc2082c5d9c65c98f",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2021-01-27T12:57:09.000Z",
"max_forks_repo_forks_event_min_datetime": "2017-07-17T07:23:39.000Z",
"max_forks_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "turion/Generic",
"max_forks_repo_path": "src/Generic/Lib/Data/Maybe.agda",
"max_issues_count": 9,
"max_issues_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe",
"max_issues_repo_issues_event_max_datetime": "2022-01-04T15:43:14.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-04-06T18:58:09.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "turion/Generic",
"max_issues_repo_path": "src/Generic/Lib/Data/Maybe.agda",
"max_line_length": 100,
"max_stars_count": 30,
"max_stars_repo_head_hexsha": "e102b0ec232f2796232bd82bf8e3906c1f8a93fe",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "turion/Generic",
"max_stars_repo_path": "src/Generic/Lib/Data/Maybe.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-05T10:19:38.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-07-19T21:10:54.000Z",
"num_tokens": 192,
"size": 615
} |
open import Type
module Relator.Sets {ℓ ℓₑ ℓₛ} {E : Type{ℓₑ}} {S : Type{ℓₛ}} (_∈_ : E → S → Type{ℓ}) where
open import Functional
open import Logic.Propositional
open import Logic.Predicate
_∉_ : E → S → Type
_∉_ = (¬_) ∘₂ (_∈_)
_∋_ : S → E → Type
_∋_ = swap(_∈_)
_∌_ : S → E → Type
_∌_ = (¬_) ∘₂ (_∋_)
_⊆_ : S → S → Type
_⊆_ L₁ L₂ = ∀ₗ(x ↦ ((_→ᶠ_) on₂ (x ∈_)) L₁ L₂)
_⊇_ : S → S → Type
_⊇_ L₁ L₂ = ∀ₗ(x ↦ ((_←_) on₂ (x ∈_)) L₁ L₂)
_≡_ : S → S → Type
_≡_ L₁ L₂ = ∀ₗ(x ↦ ((_↔_) on₂ (x ∈_)) L₁ L₂)
_⊈_ : S → S → Type
_⊈_ = (¬_) ∘₂ (_⊆_)
_⊉_ : S → S → Type
_⊉_ = (¬_) ∘₂ (_⊇_)
_≢_ : S → S → Type
_≢_ = (¬_) ∘₂ (_≡_)
| {
"alphanum_fraction": 0.4871794872,
"avg_line_length": 17.8285714286,
"ext": "agda",
"hexsha": "d4a4951b497e6933fca4914a22846d57f4aa9722",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Lolirofle/stuff-in-agda",
"max_forks_repo_path": "Relator/Sets.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Lolirofle/stuff-in-agda",
"max_issues_repo_path": "Relator/Sets.agda",
"max_line_length": 89,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "70f4fba849f2fd779c5aaa5af122ccb6a5b271ba",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Lolirofle/stuff-in-agda",
"max_stars_repo_path": "Relator/Sets.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": 366,
"size": 624
} |
module Issue804 where
mutual
{-# NO_TERMINATION_CHECK #-}
Foo : Set
Foo = Foo
-- WAS: The pragma above doesn't apply to Foo. An informative error message
-- could be helpful.
-- NOW: The pragma does apply to Foo.
| {
"alphanum_fraction": 0.6919642857,
"avg_line_length": 16,
"ext": "agda",
"hexsha": "a8b48a2df240be37d6ab165a1155b53ccdb6f5d6",
"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/succeed/Issue804.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/succeed/Issue804.agda",
"max_line_length": 75,
"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/succeed/Issue804.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": 58,
"size": 224
} |
------------------------------------------------------------------------
-- A type used to index a combined definition of strong and weak
-- bisimilarity and expansion
------------------------------------------------------------------------
{-# OPTIONS --safe #-}
module Delay-monad.Bisimilarity.Kind where
open import Equality.Propositional
open import Prelude
-- The three different relations are defined as a single relation,
-- indexed by the Kind type.
data Not-strong-kind : Type where
weak expansion : Not-strong-kind
data Kind : Type where
strong : Kind
other : Not-strong-kind → Kind
-- Kind equality is decidable.
infix 4 _≟-Kind_ _≟-Not-strong-kind_
_≟-Not-strong-kind_ : Decidable-equality Not-strong-kind
weak ≟-Not-strong-kind weak = yes refl
weak ≟-Not-strong-kind expansion = no λ ()
expansion ≟-Not-strong-kind weak = no λ ()
expansion ≟-Not-strong-kind expansion = yes refl
_≟-Kind_ : Decidable-equality Kind
_≟-Kind_ strong strong = yes refl
_≟-Kind_ strong (other _) = no λ()
_≟-Kind_ (other _) strong = no λ()
_≟-Kind_ (other k₁) (other k₂) =
⊎-map (cong other)
(λ { hyp refl → hyp refl })
(k₁ ≟-Not-strong-kind k₂)
| {
"alphanum_fraction": 0.5958677686,
"avg_line_length": 29.512195122,
"ext": "agda",
"hexsha": "a8c5e999732a30ef11adbc768f237518eeccdc60",
"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": "495f9996673d0f1f34ce202902daaa6c39f8925e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/delay-monad",
"max_forks_repo_path": "src/Delay-monad/Bisimilarity/Kind.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "495f9996673d0f1f34ce202902daaa6c39f8925e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/delay-monad",
"max_issues_repo_path": "src/Delay-monad/Bisimilarity/Kind.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "495f9996673d0f1f34ce202902daaa6c39f8925e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/delay-monad",
"max_stars_repo_path": "src/Delay-monad/Bisimilarity/Kind.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 313,
"size": 1210
} |
{-# OPTIONS --safe --experimental-lossy-unification #-}
module Cubical.Algebra.CommRing.BinomialThm where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Data.Nat renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_ ; _^_ to _^ℕ_
; +-comm to +ℕ-comm
; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm
; _choose_ to _ℕchoose_ ; snotz to ℕsnotz)
open import Cubical.Data.Nat.Order
open import Cubical.Data.FinData
open import Cubical.Data.Empty as ⊥
open import Cubical.Algebra.Monoid.BigOp
open import Cubical.Algebra.Ring.BigOps
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.RingSolver.Reflection
private
variable
ℓ : Level
module BinomialThm (R' : CommRing ℓ) where
open CommRingStr (snd R')
open Exponentiation R'
open CommRingTheory R'
open Sum (CommRing→Ring R')
private R = fst R'
_choose_ : ℕ → ℕ → R
n choose zero = 1r
zero choose suc k = 0r
suc n choose suc k = n choose (suc k) + n choose k
n<k→nChooseK≡0 : ∀ n k → n < k → n choose k ≡ 0r
n<k→nChooseK≡0 zero zero (m , p) = ⊥.rec (ℕsnotz (sym (+ℕ-comm m 1) ∙ p))
n<k→nChooseK≡0 zero (suc k) (m , p) = refl
n<k→nChooseK≡0 (suc n) zero (m , p) = ⊥.rec (ℕsnotz {n = m +ℕ (suc n)} (sym (+-suc _ _) ∙ p))
n<k→nChooseK≡0 (suc n) (suc k) (m , p) = cong₂ (_+_) p1 p2 ∙ +Lid 0r
where
p1 : n choose suc k ≡ 0r
p1 = n<k→nChooseK≡0 n (suc k) (suc m , sym (+-suc _ _) ∙ p)
p2 : n choose k ≡ 0r
p2 = n<k→nChooseK≡0 n k (m , injSuc (sym (+-suc _ _) ∙ p))
nChooseN+1 : ∀ n → n choose (suc n) ≡ 0r
nChooseN+1 n = n<k→nChooseK≡0 n (suc n) (0 , refl)
BinomialVec : (n : ℕ) → R → R → FinVec R (suc n)
BinomialVec n x y i = (n choose (toℕ i)) · x ^ (toℕ i) · y ^ (n ∸ toℕ i)
BinomialThm : ∀ (n : ℕ) (x y : R) → (x + y) ^ n ≡ ∑ (BinomialVec n x y)
BinomialThm zero x y = solve R'
BinomialThm (suc n) x y =
(x + y) ^ suc n
≡⟨ refl ⟩
(x + y) · (x + y) ^ n
≡⟨ cong ((x + y) ·_) (BinomialThm n x y) ⟩
(x + y) · ∑ (BinomialVec n x y)
≡⟨ ·Ldist+ _ _ _ ⟩
x · ∑ (BinomialVec n x y) + y · ∑ (BinomialVec n x y)
≡⟨ cong₂ (_+_) (∑Mulrdist _ (BinomialVec n x y)) (∑Mulrdist _ (BinomialVec n x y)) ⟩
∑ (λ i → x · BinomialVec n x y i)
+ ∑ (λ i → y · BinomialVec n x y i)
≡⟨ refl ⟩
∑ {n = suc n} (λ i → x · ((n choose (toℕ i)) · x ^ (toℕ i) · y ^ (n ∸ toℕ i)))
+ ∑ {n = suc n} (λ i → y · ((n choose (toℕ i)) · x ^ (toℕ i) · y ^ (n ∸ toℕ i)))
≡⟨ cong₂ (_+_) (∑Ext xVecPath) (∑Ext yVecPath) ⟩
∑ xVec + ∑ yVec
≡⟨ cong (_+ ∑ yVec) (∑Last xVec) ⟩
∑ (xVec ∘ weakenFin) + xⁿ⁺¹ + (yⁿ⁺¹ + ∑ (yVec ∘ suc))
≡⟨ solve3 _ _ _ _ ⟩
yⁿ⁺¹ + (∑ (xVec ∘ weakenFin) + ∑ (yVec ∘ suc)) + xⁿ⁺¹
≡⟨ cong (λ s → yⁿ⁺¹ + s + xⁿ⁺¹) (sym (∑Split _ _)) ⟩
yⁿ⁺¹ + (∑ middleVec) + xⁿ⁺¹
≡⟨ cong (λ s → yⁿ⁺¹ + s + xⁿ⁺¹) (∑Ext middlePath) ⟩
yⁿ⁺¹ + ∑ ((BinomialVec (suc n) x y) ∘ weakenFin ∘ suc) + xⁿ⁺¹
≡⟨ refl ⟩
∑ ((BinomialVec (suc n) x y) ∘ weakenFin) + xⁿ⁺¹
≡⟨ cong (∑ ((BinomialVec (suc n) x y) ∘ weakenFin) +_) xⁿ⁺¹Path
∙ sym (∑Last (BinomialVec (suc n) x y)) ⟩
∑ (BinomialVec (suc n) x y) ∎
where
xVec : FinVec R (suc n)
xVec i = (n choose (toℕ i)) · x ^ (suc (toℕ i)) · y ^ (n ∸ toℕ i)
solve1 : ∀ x nci xⁱ yⁿ⁻ⁱ → x · (nci · xⁱ · yⁿ⁻ⁱ) ≡ nci · (x · xⁱ) · yⁿ⁻ⁱ
solve1 = solve R'
xVecPath : ∀ (i : Fin (suc n)) → x · ((n choose (toℕ i)) · x ^ (toℕ i) · y ^ (n ∸ toℕ i)) ≡ xVec i
xVecPath i = solve1 _ _ _ _
yVec : FinVec R (suc n)
yVec i = (n choose (toℕ i)) · x ^ (toℕ i) · y ^ (suc (n ∸ toℕ i))
solve2 : ∀ y nci xⁱ yⁿ⁻ⁱ → y · (nci · xⁱ · yⁿ⁻ⁱ) ≡ nci · xⁱ · (y · yⁿ⁻ⁱ)
solve2 = solve R'
yVecPath : ∀ (i : Fin (suc n)) → y · ((n choose (toℕ i)) · x ^ (toℕ i) · y ^ (n ∸ toℕ i)) ≡ yVec i
yVecPath i = solve2 _ _ _ _
xⁿ⁺¹ : R
xⁿ⁺¹ = xVec (fromℕ n)
yⁿ⁺¹ : R
yⁿ⁺¹ = yVec zero
xⁿ⁺¹Path : xⁿ⁺¹ ≡ BinomialVec (suc n) x y (fromℕ (suc n))
xⁿ⁺¹Path = cong (λ m → m · (x · x ^ toℕ (fromℕ n)) · y ^ (n ∸ toℕ (fromℕ n)))
(sym (+Lid _) ∙ cong (_+ (n choose toℕ (fromℕ n)))
(sym (subst (λ m → (n choose suc m) ≡ 0r) (sym (toFromId n)) (nChooseN+1 n))))
solve3 : ∀ sx sy xⁿ⁺¹ yⁿ⁺¹ → sx + xⁿ⁺¹ + (yⁿ⁺¹ + sy) ≡ yⁿ⁺¹ + (sx + sy) + xⁿ⁺¹
solve3 = solve R'
middleVec : FinVec R n
middleVec i = xVec (weakenFin i) + yVec (suc i)
middlePath : ∀ (i : Fin n) → middleVec i ≡ BinomialVec (suc n) x y (weakenFin (suc i))
middlePath i = transport (λ j →
(n choose toℕ (weakenFin i)) · (x · x ^ toℕ (weakenFin i)) · y ^ (n ∸ toℕ (weakenFin i))
+ (n choose suc (weakenRespToℕ i j)) · (x · x ^ (weakenRespToℕ i j)) · sym yHelper j
≡ ((n choose suc (toℕ (weakenFin i))) + (n choose toℕ (weakenFin i)))
· (x · x ^ toℕ (weakenFin i)) · y ^ (n ∸ toℕ (weakenFin i)))
(solve4 _ _ _ _)
where
yHelper : (y · y ^ (n ∸ suc (toℕ i))) ≡ y ^ (n ∸ toℕ (weakenFin i))
yHelper = cong (λ m → y · y ^ (n ∸ suc m)) (sym (weakenRespToℕ i))
∙ cong (y ^_) (≤-∸-suc (subst (λ m → suc m ≤ n) (sym (weakenRespToℕ _)) (toℕ<n i)))
solve4 : ∀ nci ncsi xxⁱ yⁿ⁻ⁱ → nci · xxⁱ · yⁿ⁻ⁱ + ncsi · xxⁱ · yⁿ⁻ⁱ ≡ (ncsi + nci) · xxⁱ · yⁿ⁻ⁱ
solve4 = solve R'
| {
"alphanum_fraction": 0.5307957154,
"avg_line_length": 39.3082706767,
"ext": "agda",
"hexsha": "3ed7696a919efc41b45aac439ea14fbc44a3efb5",
"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/Algebra/CommRing/BinomialThm.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/Algebra/CommRing/BinomialThm.agda",
"max_line_length": 100,
"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/Algebra/CommRing/BinomialThm.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2501,
"size": 5228
} |
postulate
Bool : Set
D : Bool → Set
f : (a : Bool) → D a
⟦_⟧ : ∀ {a} → D a → Bool
record State : Set where
field bool : Bool
open State {{...}}
postulate
guard : {S : Set} → ({{_ : S}} → Bool) → S
test : State
test = guard ⟦ f bool ⟧ -- doesn't work, used to work in agda 2.4
| {
"alphanum_fraction": 0.5233333333,
"avg_line_length": 16.6666666667,
"ext": "agda",
"hexsha": "507084a9a4a8429e83bf0ae87ace97cf134f1389",
"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/Issue1810.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/Issue1810.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/Succeed/Issue1810.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": 118,
"size": 300
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Unbundled where
-- This is basically identical to Category, except that the
-- Obj type is a parameter rather than a field.
open import Level
open import Function.Base using (flip)
open import Relation.Binary using (Rel; IsEquivalence)
record Category {o : Level} (Obj : Set o) (ℓ e : Level) : Set (suc (o ⊔ ℓ ⊔ e)) where
eta-equality
infix 4 _≈_ _⇒_
infixr 9 _∘_
field
_⇒_ : Rel Obj ℓ
_≈_ : ∀ {A B} → Rel (A ⇒ B) e
id : ∀ {A} → (A ⇒ A)
_∘_ : ∀ {A B C} → (B ⇒ C) → (A ⇒ B) → (A ⇒ C)
field
assoc : ∀ {A B C D} {f : A ⇒ B} {g : B ⇒ C} {h : C ⇒ D} → (h ∘ g) ∘ f ≈ h ∘ (g ∘ f)
-- We add a symmetric proof of associativity so that the opposite category of the
-- opposite category is definitionally equal to the original category. See how
-- `op` is implemented.
sym-assoc : ∀ {A B C D} {f : A ⇒ B} {g : B ⇒ C} {h : C ⇒ D} → h ∘ (g ∘ f) ≈ (h ∘ g) ∘ f
identityˡ : ∀ {A B} {f : A ⇒ B} → id ∘ f ≈ f
identityʳ : ∀ {A B} {f : A ⇒ B} → f ∘ id ≈ f
-- We add a proof of "neutral" identity proof, in order to ensure the opposite of
-- constant functor is definitionally equal to itself.
identity² : ∀ {A} → id ∘ id {A} ≈ id {A}
equiv : ∀ {A B} → IsEquivalence (_≈_ {A} {B})
∘-resp-≈ : ∀ {A B C} {f h : B ⇒ C} {g i : A ⇒ B} → f ≈ h → g ≈ i → f ∘ g ≈ h ∘ i
| {
"alphanum_fraction": 0.5405017921,
"avg_line_length": 37.7027027027,
"ext": "agda",
"hexsha": "8db4dbb7a5d5a729d9d02d49ca0e4c2c6d05cc34",
"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/Unbundled.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/Unbundled.agda",
"max_line_length": 91,
"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/Unbundled.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": 544,
"size": 1395
} |
open import Agda.Builtin.Unit
open import Agda.Builtin.Sigma
open import Agda.Builtin.List
open import Agda.Builtin.Equality
open import Agda.Builtin.Reflection renaming (bindTC to infixl 4 _>>=_)
macro
quoteDef : Name → Term → TC ⊤
quoteDef f hole = (getDefinition f >>= quoteTC) >>= unify hole
postulate
A : Set
B : A → Set
-- foo is projection-like
foo : (x : A) → B x → B x
foo x y = y
pattern vArg x = arg (arg-info visible relevant) x
test : quoteDef foo ≡
function
(clause
(("x" , vArg (def (quote A) [])) ∷
("y" , vArg (def (quote B) (vArg (var 0 []) ∷ [])))
∷ [])
(vArg (var 1) ∷ vArg (var 0) ∷ [])
(var 0 [])
∷ [])
test = refl
| {
"alphanum_fraction": 0.595065312,
"avg_line_length": 21.53125,
"ext": "agda",
"hexsha": "ef10eaca1ab6b97dab3cdb5fb1296c8e74cac119",
"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": "cb645fcad38f76a9bf37507583867595b5ce87a1",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "guilhermehas/agda",
"max_forks_repo_path": "test/Succeed/Issue5128.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "cb645fcad38f76a9bf37507583867595b5ce87a1",
"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": "guilhermehas/agda",
"max_issues_repo_path": "test/Succeed/Issue5128.agda",
"max_line_length": 71,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "cb645fcad38f76a9bf37507583867595b5ce87a1",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "guilhermehas/agda",
"max_stars_repo_path": "test/Succeed/Issue5128.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 239,
"size": 689
} |
-- Andreas, 2012-09-17 documenting an internal error in InternalToAbstract.hs
-- {-# OPTIONS -v syntax.reify.con:30 -v tc.with.type:30 #-}
module NameFirstIfHidden where
Total : (D : (A : Set) → A → Set)(A : Set) → Set
Total D A = forall a → D A a
data D (A : Set) : (a : A) → Set where
c : Total D A
postulate P : {A : Set}{a : A} → D A a → Set
f : (A : Set)(a : A) → P (c a) → D A a
f A a p with Total
... | _ = c a
-- should succeed, triggered an internal error before
| {
"alphanum_fraction": 0.60041841,
"avg_line_length": 28.1176470588,
"ext": "agda",
"hexsha": "f3a83046d8ae1ca1423ffd42b4df60d676c3993b",
"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/NameFirstIfHidden.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/NameFirstIfHidden.agda",
"max_line_length": 77,
"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/NameFirstIfHidden.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": 170,
"size": 478
} |
{-# OPTIONS --safe --warning=error --without-K #-}
open import Groups.Definition
open import Setoids.Setoids
open import Sets.EquivalenceRelations
open import Groups.Homomorphisms.Definition
open import Groups.Homomorphisms.Lemmas
open import Groups.Subgroups.Definition
open import Groups.Subgroups.Normal.Definition
open import Groups.Lemmas
module Groups.Homomorphisms.Kernel {a b c d : _} {A : Set a} {B : Set b} {S : Setoid {a} {c} A} {T : Setoid {b} {d} B} {_+G_ : A → A → A} {_+H_ : B → B → B} {G : Group S _+G_} {H : Group T _+H_} {f : A → B} (fHom : GroupHom G H f) where
open Setoid T
open Equivalence eq
groupKernelPred : A → Set d
groupKernelPred a = Setoid._∼_ T (f a) (Group.0G H)
groupKernelPredWd : {x y : A} → (Setoid._∼_ S x y) → groupKernelPred x → groupKernelPred y
groupKernelPredWd x=y fx=0 = transitive (GroupHom.wellDefined fHom (Equivalence.symmetric (Setoid.eq S) x=y)) fx=0
groupKernelIsSubgroup : Subgroup G groupKernelPred
Subgroup.closedUnderPlus groupKernelIsSubgroup fg=0 fh=0 = transitive (transitive (GroupHom.groupHom fHom) (Group.+WellDefined H fg=0 fh=0)) (Group.identLeft H)
Subgroup.containsIdentity groupKernelIsSubgroup = imageOfIdentityIsIdentity fHom
Subgroup.closedUnderInverse groupKernelIsSubgroup fg=0 = transitive (homRespectsInverse fHom) (transitive (inverseWellDefined H fg=0) (invIdent H))
Subgroup.isSubset groupKernelIsSubgroup = groupKernelPredWd
groupKernelIsNormalSubgroup : normalSubgroup G groupKernelIsSubgroup
groupKernelIsNormalSubgroup {g} fk=0 = transitive (transitive (transitive (GroupHom.groupHom fHom) (transitive (Group.+WellDefined H reflexive (transitive (GroupHom.groupHom fHom) (transitive (Group.+WellDefined H fk=0 reflexive) (Group.identLeft H)))) (symmetric (GroupHom.groupHom fHom)))) (GroupHom.wellDefined fHom (Group.invRight G {g}))) (imageOfIdentityIsIdentity fHom)
| {
"alphanum_fraction": 0.7688577586,
"avg_line_length": 58,
"ext": "agda",
"hexsha": "f9dd404b2a0e77150c93456ca390df6cff5a6f7c",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-29T13:23:07.000Z",
"max_forks_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Smaug123/agdaproofs",
"max_forks_repo_path": "Groups/Homomorphisms/Kernel.agda",
"max_issues_count": 14,
"max_issues_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_issues_repo_issues_event_max_datetime": "2020-04-11T11:03:39.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-06T21:11:59.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Smaug123/agdaproofs",
"max_issues_repo_path": "Groups/Homomorphisms/Kernel.agda",
"max_line_length": 376,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "0f4230011039092f58f673abcad8fb0652e6b562",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Smaug123/agdaproofs",
"max_stars_repo_path": "Groups/Homomorphisms/Kernel.agda",
"max_stars_repo_stars_event_max_datetime": "2022-01-28T06:04:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-08-08T12:44:19.000Z",
"num_tokens": 574,
"size": 1856
} |
open import Categories
open import Functors
open import RMonads
module RMonads.CatofRAdj {a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}{J : Fun C D}
(M : RMonad J) where
open import Library
open import RAdjunctions
open Fun
open Cat
record ObjAdj {e f} : Set ((a ⊔ b ⊔ c ⊔ d ⊔ lsuc e ⊔ lsuc f)) where
open RMonad M
field E : Cat {e}{f}
adj : RAdj J E
open RAdj adj
field law : R ○ L ≅ TFun M
ηlaw : ∀{X} → left (iden E {OMap L X}) ≅ η {X}
bindlaw : ∀{X Y}{f : Hom D (OMap J X) (T Y)} →
HMap R (right (subst (Hom D (OMap J X))
(fcong Y (cong OMap (sym law))) f))
≅ bind f
open ObjAdj
record HomAdj {e f}(A B : ObjAdj {e}{f}) : Set (a ⊔ b ⊔ c ⊔ d ⊔ lsuc (e ⊔ f))
where
constructor homadj
open RAdj
field K : Fun (E A) (E B)
Llaw : K ○ L (adj A) ≅ L (adj B)
Rlaw : R (adj A) ≅ R (adj B) ○ K
rightlaw : {X : Obj C}{Y : Obj (E A)}
{f : Hom D (OMap J X) (OMap (R (adj A)) Y)} →
HMap K (right (adj A) {X}{Y} f)
≅
right (adj B)
{X}
{OMap K Y}
(subst (Hom D (OMap J X))
(fcong Y (cong OMap Rlaw))
f)
open HomAdj
HomAdjEq : ∀{a b}{A B : ObjAdj {a}{b}}
(f g : HomAdj A B) → K f ≅ K g → f ≅ g
HomAdjEq {A = A}{B} (homadj K _ _ _) (homadj .K _ _ _) refl =
cong₃ (homadj K)
(ir _ _)
(ir _ _)
(iext λ _ → iext λ _ → iext λ _ → hir refl)
rightlawlem : ∀{e f}{E : Cat {e}{f}}(R : Fun E D)(L : Fun C E) →
(p : OMap R ≅ OMap (R ○ (IdF E))) →
(right : {X : Obj C} {Y : Obj E} →
Hom D (OMap J X) (OMap R Y) → Hom E (OMap L X) Y) →
{X : Obj C}{Y : Obj E}{f : Hom D (OMap J X) (OMap R Y)} →
right f ≅ right (subst (Hom D (OMap J X)) (fcong Y p) f)
rightlawlem R L refl right = refl
idLlaw : ∀{e f}(X : ObjAdj {e}{f}) →
IdF (E X) ○ RAdj.L (adj X) ≅ RAdj.L (adj X)
idLlaw X = FunctorEq _ _ refl refl
idRlaw : ∀{e f}(X : ObjAdj {e}{f}) →
RAdj.R (adj X) ≅ RAdj.R (adj X) ○ IdF (E X)
idRlaw X = FunctorEq _ _ refl refl
idrightlaw : ∀{e f}
(X : ObjAdj {e}{f}) →
{X₁ : Obj C} {Y : Obj (E X)}
{f : Hom D (OMap J X₁) (OMap (RAdj.R (adj X)) Y)} →
HMap (IdF (E X)) (RAdj.right (adj X) f)
≅
RAdj.right (adj X)
(subst (Hom D (OMap J X₁))
(fcong Y (cong OMap (idRlaw X)))
f)
idrightlaw X =
rightlawlem (R (adj X))
(L (adj X))
(cong OMap
(FunctorEq (R (adj X))
(R (adj X) ○ IdF (E X))
refl
refl))
(right (adj X))
where open RAdj
idHomAdj : ∀{e f}{X : ObjAdj {e}{f}} → HomAdj X X
idHomAdj {X = X} = record {
K = IdF (E X);
Llaw = idLlaw X;
Rlaw = idRlaw X;
rightlaw = idrightlaw X }
HMaplem : ∀{a b c d}{C : Cat {a}{b}}{D : Cat {c}{d}}{X X' Y Y' : Obj C} →
X ≅ X' → Y ≅ Y' →
{f : Hom C X Y}{f' : Hom C X' Y'} → f ≅ f' → (F : Fun C D) →
HMap F {X}{Y} f ≅ HMap F {X'}{Y'} f'
HMaplem refl refl refl F = refl
rightlawlem2 : ∀{e f g h i j}{E : Cat {e}{f}}{F : Cat {g}{h}}{G : Cat {i}{j}}
(J : Fun C D)
(RX : Fun E D)(LX : Fun C E)
(RY : Fun F D)(LY : Fun C F)
(RZ : Fun G D)(LZ : Fun C G)
(KA : Fun E F)(KB : Fun F G) →
(rightX : {X : Obj C}{Y : Obj E} →
Hom D (OMap J X) (OMap RX Y) → Hom E (OMap LX X) Y)
(rightY : {X : Obj C}{Y : Obj F} →
Hom D (OMap J X) (OMap RY Y) → Hom F (OMap LY X) Y)
(rightZ : {X : Obj C}{Y : Obj G} →
Hom D (OMap J X) (OMap RZ Y) → Hom G (OMap LZ X) Y) →
(p : RY ≅ RZ ○ KB)(q : RX ≅ RY ○ KA) →
(p' : KA ○ LX ≅ LY) →
(r : {X : Obj C}{Y : Obj F}{f : Hom D (OMap J X) (OMap RY Y)} →
HMap KB (rightY f)
≅
rightZ (subst (Hom D (OMap J X))
(fcong Y (cong OMap p))
f)) →
(s : {X : Obj C}{Y : Obj E}{f : Hom D (OMap J X) (OMap RX Y)} →
HMap KA (rightX f)
≅
rightY (subst (Hom D (OMap J X))
(fcong Y (cong OMap q))
f)) →
∀{A B}(h : Hom D (OMap J A) (OMap RX B)) →
HMap (KB ○ KA) (rightX h) ≅
rightZ
(subst (Hom D (OMap J A))
(fcong B (cong OMap (trans q (cong (λ F₁ → F₁ ○ KA) p))))
h)
rightlawlem2 J .((RZ ○ KB) ○ KA) LX .(RZ ○ KB) .(KA ○ LX) RZ LZ KA KB
rightX rightY rightZ refl refl refl r s h = trans (cong (HMap KB) s) r
compLlaw : ∀{e f}{X Y Z : ObjAdj {e}{f}} →
(f : HomAdj Y Z)(g : HomAdj X Y) →
(K f ○ K g) ○ RAdj.L (adj X) ≅ RAdj.L (adj Z)
compLlaw f g = FunctorEq
_
_
(ext (λ A → trans
(cong (OMap (K f)) (cong (λ F → OMap F A) (Llaw g)))
(cong (λ F → OMap F A) (Llaw f))))
(iext λ A → iext λ B → ext λ h → trans
(HMaplem
(cong (λ F → OMap F A) (Llaw g))
(cong (λ F → OMap F B) (Llaw g))
(cong (λ F → HMap F h) (Llaw g))
(K f))
(cong (λ F → HMap F h) (Llaw f)))
compRlaw : ∀{e f}{X Y Z : ObjAdj {e}{f}} →
(f : HomAdj Y Z)(g : HomAdj X Y) →
RAdj.R (adj X) ≅ RAdj.R (adj Z) ○ (K f ○ K g)
compRlaw f g = FunctorEq
_
_
(ext (λ A → trans
(cong (λ F → OMap F A) (Rlaw g))
(cong (λ F → OMap F (OMap (K g) A)) (Rlaw f))))
(iext λ A → iext λ B → ext λ h → trans
(cong (λ F → HMap F h) (Rlaw g))
(cong (λ F → HMap F (HMap (K g) h)) (Rlaw f)))
comprightlaw : ∀{e f}{X Y Z : ObjAdj {e}{f}} →
(f : HomAdj Y Z)(g : HomAdj X Y) →
{A : Obj C} {B : Obj (E X)}
{h : Hom D (OMap J A) (OMap (RAdj.R (adj X)) B)} →
HMap (K f ○ K g) (RAdj.right (adj X) h)
≅
RAdj.right (adj Z)
(subst (Hom D (OMap J A))
(fcong B (cong OMap (compRlaw f g)))
h)
comprightlaw {X = X}{Y}{Z} f g {A}{B}{h} = trans
(rightlawlem2 J (R (adj X)) (L (adj X)) (R (adj Y)) (L (adj Y))
(R (adj Z)) (L (adj Z)) (K g) (K f) (right (adj X)) (right (adj Y))
(right (adj Z)) (Rlaw f) (Rlaw g) (Llaw g) (rightlaw f)
(rightlaw g) h) (cong (right (adj Z)) (trans (stripsubst (Hom D (OMap J A)) h (fcong B (cong OMap (trans (Rlaw g) (cong (λ F → F ○ K g) (Rlaw f)))))) (sym (stripsubst (Hom D (OMap J A)) h (fcong B (cong OMap (compRlaw f g))))))) where open RAdj
compHomAdj : ∀{e f}{X Y Z : ObjAdj {e}{f}} →
HomAdj Y Z → HomAdj X Y → HomAdj X Z
compHomAdj f g = record {
K = K f ○ K g;
Llaw = compLlaw f g;
Rlaw = compRlaw f g;
rightlaw = comprightlaw f g }
idlHomAdj : ∀{e f}{X Y : ObjAdj {e}{f}}
{f : HomAdj X Y} → compHomAdj idHomAdj f ≅ f
idlHomAdj = HomAdjEq _ _ (FunctorEq _ _ refl refl)
idrHomAdj : ∀{e f}{X Y : ObjAdj {e}{f}}
{f : HomAdj X Y} → compHomAdj f idHomAdj ≅ f
idrHomAdj = HomAdjEq _ _ (FunctorEq _ _ refl refl)
assHomAdj : ∀{a b}{W X Y Z : ObjAdj {a}{b}}
{f : HomAdj Y Z} {g : HomAdj X Y} {h : HomAdj W X} →
compHomAdj (compHomAdj f g) h ≅ compHomAdj f (compHomAdj g h)
assHomAdj = HomAdjEq _ _ (FunctorEq _ _ refl refl)
CatofAdj : ∀{a b} → Cat
CatofAdj {a}{b} = record{
Obj = ObjAdj {a}{b};
Hom = HomAdj;
iden = idHomAdj;
comp = compHomAdj;
idl = idlHomAdj;
idr = idrHomAdj;
ass = λ{_ _ _ _ f g h} →
assHomAdj {f = f}{g}{h}}
| {
"alphanum_fraction": 0.4455870867,
"avg_line_length": 34.9181818182,
"ext": "agda",
"hexsha": "5bf2a7448adb57eed901b4b665ed52e931e0a917",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-11-04T21:33:13.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-11-04T21:33:13.000Z",
"max_forks_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "jmchapman/Relative-Monads",
"max_forks_repo_path": "RMonads/CatofRAdj.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865",
"max_issues_repo_issues_event_max_datetime": "2019-05-29T09:50:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-01-13T13:12:33.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "jmchapman/Relative-Monads",
"max_issues_repo_path": "RMonads/CatofRAdj.agda",
"max_line_length": 247,
"max_stars_count": 21,
"max_stars_repo_head_hexsha": "74707d3538bf494f4bd30263d2f5515a84733865",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "jmchapman/Relative-Monads",
"max_stars_repo_path": "RMonads/CatofRAdj.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-13T18:02:18.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-07-30T01:25:12.000Z",
"num_tokens": 3109,
"size": 7682
} |
{-# OPTIONS --universe-polymorphism #-}
open import Categories.Category
module Categories.Functor.Core where
open import Level
open import Categories.Support.EqReasoning
record Functor {o ℓ e o′ ℓ′ e′} (C : Category o ℓ e) (D : Category o′ ℓ′ e′) : Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′) where
eta-equality
private module C = Category C
private module D = Category D
field
F₀ : C.Obj → D.Obj
{F₁} : ∀ {A B} → C [ A , B ] → D [ F₀ A , F₀ B ]
.{identity} : ∀ {A} → D [ F₁ (C.id {A}) ≡ D.id ]
.{homomorphism} : ∀ {X Y Z} {f : C [ X , Y ]} {g : C [ Y , Z ]}
→ D [ F₁ (C [ g ∘ f ]) ≡ D [ F₁ g ∘ F₁ f ] ]
.{F-resp-≡} : ∀ {A B} {F G : C [ A , B ]} → C [ F ≡ G ] → D [ F₁ F ≡ F₁ G ]
op : Functor C.op D.op
op = record
{ F₀ = F₀
; F₁ = F₁
; identity = identity
; homomorphism = homomorphism
; F-resp-≡ = F-resp-≡
}
Endofunctor : ∀ {o ℓ e} → Category o ℓ e → Set _
Endofunctor C = Functor C C
Contravariant : ∀ {o ℓ e o′ ℓ′ e′} (C : Category o ℓ e) (D : Category o′ ℓ′ e′) → Set _
Contravariant C D = Functor C.op D
where module C = Category C
id : ∀ {o ℓ e} {C : Category o ℓ e} → Endofunctor C
id {C = C} = record
{ F₀ = λ x → x
; F₁ = λ x → x
; identity = refl
; homomorphism = refl
; F-resp-≡ = λ x → x
}
where open Category.Equiv C
infixr 9 _∘_
_∘_ : ∀ {o ℓ e} {o′ ℓ′ e′} {o′′ ℓ′′ e′′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {E : Category o′′ ℓ′′ e′′}
→ Functor D E → Functor C D → Functor C E
_∘_ {C = C} {D = D} {E = E} F G = record
{ F₀ = λ x → F₀ (G₀ x)
; F₁ = λ f → F₁ (G₁ f)
; identity = identity′
; homomorphism = homomorphism′
; F-resp-≡ = ∘-resp-≡′
}
where
module C = Category C
module D = Category D
module E = Category E
module F = Functor F
module G = Functor G
open F
open G renaming (F₀ to G₀; F₁ to G₁; F-resp-≡ to G-resp-≡)
.identity′ : ∀ {A} → E [ F₁ (G₁ (C.id {A})) ≡ E.id ]
identity′ = begin
F₁ (G₁ C.id)
≈⟨ F-resp-≡ G.identity ⟩
F₁ D.id
≈⟨ F.identity ⟩
E.id
∎
where
open SetoidReasoning E.hom-setoid
.homomorphism′ : ∀ {X Y Z} {f : C [ X , Y ]} {g : C [ Y , Z ]}
→ E [ F₁ (G₁ (C [ g ∘ f ])) ≡ E [ F₁ (G₁ g) ∘ F₁ (G₁ f) ] ]
homomorphism′ {f = f} {g = g} = begin
F₁ (G₁ (C [ g ∘ f ]))
≈⟨ F-resp-≡ G.homomorphism ⟩
F₁ (D [ G₁ g ∘ G₁ f ])
≈⟨ F.homomorphism ⟩
(E [ F₁ (G₁ g) ∘ F₁ (G₁ f) ])
∎
where
open SetoidReasoning E.hom-setoid
.∘-resp-≡′ : ∀ {A B} {F G : C [ A , B ]}
→ C [ F ≡ G ] → E [ F₁ (G₁ F) ≡ F₁ (G₁ G) ]
∘-resp-≡′ = λ x → F-resp-≡ (G-resp-≡ x)
| {
"alphanum_fraction": 0.4489012905,
"avg_line_length": 28.9595959596,
"ext": "agda",
"hexsha": "978b4dcfa52ba5ea3da143eb1c17c5dabb1923d0",
"lang": "Agda",
"max_forks_count": 23,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T13:50:56.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-05T13:03:09.000Z",
"max_forks_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "p-pavel/categories",
"max_forks_repo_path": "Categories/Functor/Core.agda",
"max_issues_count": 19,
"max_issues_repo_head_hexsha": "e41aef56324a9f1f8cf3cd30b2db2f73e01066f2",
"max_issues_repo_issues_event_max_datetime": "2019-08-09T16:31:40.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-05-23T06:47:10.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "p-pavel/categories",
"max_issues_repo_path": "Categories/Functor/Core.agda",
"max_line_length": 115,
"max_stars_count": 98,
"max_stars_repo_head_hexsha": "36f4181d751e2ecb54db219911d8c69afe8ba892",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "copumpkin/categories",
"max_stars_repo_path": "Categories/Functor/Core.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-08T05:20:36.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-04-15T14:57:33.000Z",
"num_tokens": 1172,
"size": 2867
} |
module FunClause where
f
: {A : Set}
→ A
→ A
f x
= y
where
y = x
z = x
data List
(A : Set)
: Set
where
nil
: List A
cons
: A
→ List A
→ List A
snoc
: {A : Set}
→ List A
→ A
→ List A
snoc nil y
= cons y nil
snoc (cons x xs) y
= cons x (snoc xs y)
| {
"alphanum_fraction": 0.4577922078,
"avg_line_length": 8.5555555556,
"ext": "agda",
"hexsha": "8c31638ca693c757831afb87f5d285e6469be542",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2022-03-01T16:38:14.000Z",
"max_forks_repo_forks_event_min_datetime": "2022-03-01T16:38:14.000Z",
"max_forks_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "msuperdock/agda-unused",
"max_forks_repo_path": "data/declaration/FunClause.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "msuperdock/agda-unused",
"max_issues_repo_path": "data/declaration/FunClause.agda",
"max_line_length": 22,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "f327f9aab8dcb07022b857736d8201906bba02e9",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "msuperdock/agda-unused",
"max_stars_repo_path": "data/declaration/FunClause.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-01T16:38:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-29T09:38:43.000Z",
"num_tokens": 137,
"size": 308
} |
------------------------------------------------------------------------
-- Brandt and Henglein's subterm relation
------------------------------------------------------------------------
module RecursiveTypes.Subterm where
open import Algebra
open import Data.Fin using (Fin; zero; suc; lift)
open import Data.Nat
open import Data.List using (List; []; _∷_; [_]; _++_)
open import Data.List.Properties
open import Data.List.Relation.Unary.Any using (here; there)
open import Data.List.Relation.Unary.Any.Properties
using (++↔; map-with-∈↔)
open import Data.List.Membership.Propositional
open import Data.List.Membership.Propositional.Properties
open import Data.List.Relation.Binary.BagAndSetEquality as BSEq
open import Data.List.Relation.Binary.Subset.Propositional
open import Data.List.Relation.Binary.Subset.Propositional.Properties
open import Data.Product
open import Data.Sum
open import Function.Base
open import Function.Equality using (_⟨$⟩_)
open import Function.Inverse using (module Inverse)
open import Relation.Binary
import Relation.Binary.Reasoning.Preorder as PreR
import Relation.Binary.Reasoning.Setoid as EqR
import Relation.Binary.PropositionalEquality as P
open import Data.Fin.Substitution
private
open module SetM {A : Set} =
CommutativeMonoid (BSEq.commutativeMonoid set A)
using (_≈_)
open import RecursiveTypes.Syntax
open import RecursiveTypes.Substitution
hiding (subst) renaming (id to idˢ)
open // using (_//_)
------------------------------------------------------------------------
-- Subterms
-- The subterm relation.
infix 4 _⊑_
data _⊑_ {n} : Ty n → Ty n → Set where
refl : ∀ {τ} → τ ⊑ τ
unfold : ∀ {σ τ₁ τ₂} (σ⊑ : σ ⊑ unfold[μ τ₁ ⟶ τ₂ ]) → σ ⊑ μ τ₁ ⟶ τ₂
⟶ˡ : ∀ {σ τ₁ τ₂} (σ⊑τ₁ : σ ⊑ τ₁) → σ ⊑ τ₁ ⟶ τ₂
⟶ʳ : ∀ {σ τ₁ τ₂} (σ⊑τ₂ : σ ⊑ τ₂) → σ ⊑ τ₁ ⟶ τ₂
-- Some simple consequences.
unfold′ : ∀ {n} {τ₁ τ₂ : Ty (suc n)} →
unfold[μ τ₁ ⟶ τ₂ ] ⊑ μ τ₁ ⟶ τ₂
unfold′ = unfold refl
⟶ˡ′ : ∀ {n} {τ₁ τ₂ : Ty n} → τ₁ ⊑ τ₁ ⟶ τ₂
⟶ˡ′ = ⟶ˡ refl
⟶ʳ′ : ∀ {n} {τ₁ τ₂ : Ty n} → τ₂ ⊑ τ₁ ⟶ τ₂
⟶ʳ′ = ⟶ʳ refl
-- The subterm relation is transitive.
trans : ∀ {n} {σ τ χ : Ty n} →
σ ⊑ τ → τ ⊑ χ → σ ⊑ χ
trans σ⊑τ refl = σ⊑τ
trans σ⊑τ (unfold τ⊑) = unfold (trans σ⊑τ τ⊑)
trans σ⊑τ (⟶ˡ τ⊑δ₁) = ⟶ˡ (trans σ⊑τ τ⊑δ₁)
trans σ⊑τ (⟶ʳ τ⊑δ₂) = ⟶ʳ (trans σ⊑τ τ⊑δ₂)
------------------------------------------------------------------------
-- Subterm closure
-- The list τ_∗ contains exactly the subterms of τ (possibly with
-- duplicates).
--
-- The important property is completeness, which ensures that the
-- number of distinct subterms of a given type is always finite.
mutual
infix 7 _∗ _∗′
_∗ : ∀ {n} → Ty n → List (Ty n)
τ ∗ = τ ∷ τ ∗′
_∗′ : ∀ {n} → Ty n → List (Ty n)
(τ₁ ⟶ τ₂) ∗′ = τ₁ ∗ ++ τ₂ ∗
(μ τ₁ ⟶ τ₂) ∗′ = (τ₁ ⟶ τ₂ ∷ τ₁ ∗ ++ τ₂ ∗) // sub (μ τ₁ ⟶ τ₂)
τ ∗′ = []
------------------------------------------------------------------------
-- Soundness
-- _/_ is monotonous in its left argument.
/-monoˡ : ∀ {m n σ τ} {ρ : Sub Ty m n} →
σ ⊑ τ → σ / ρ ⊑ τ / ρ
/-monoˡ refl = refl
/-monoˡ (⟶ˡ σ⊑τ₁) = ⟶ˡ (/-monoˡ σ⊑τ₁)
/-monoˡ (⟶ʳ σ⊑τ₂) = ⟶ʳ (/-monoˡ σ⊑τ₂)
/-monoˡ {ρ = ρ} (unfold {σ} {τ₁} {τ₂} σ⊑) =
unfold $ P.subst (λ χ → σ / ρ ⊑ χ)
(sub-commutes (τ₁ ⟶ τ₂))
(/-monoˡ σ⊑)
sub-⊑-μ : ∀ {n} {σ : Ty (suc n)} {τ₁ τ₂} →
σ ⊑ τ₁ ⟶ τ₂ → σ / sub (μ τ₁ ⟶ τ₂) ⊑ μ τ₁ ⟶ τ₂
sub-⊑-μ σ⊑τ₁⟶τ₂ = unfold (/-monoˡ σ⊑τ₁⟶τ₂)
-- All list elements are subterms.
sound : ∀ {n σ} (τ : Ty n) → σ ∈ τ ∗ → σ ⊑ τ
sound τ (here P.refl) = refl
sound (τ₁ ⟶ τ₂) (there σ∈) =
[ ⟶ˡ ∘ sound τ₁ , ⟶ʳ ∘ sound τ₂ ]′
(Inverse.from (++↔ {xs = τ₁ ∗}) ⟨$⟩ σ∈)
sound (μ τ₁ ⟶ τ₂) (there (here P.refl)) = unfold refl
sound (μ τ₁ ⟶ τ₂) (there (there σ∈))
with Inverse.from (map-∈↔ (λ σ → σ / sub (μ τ₁ ⟶ τ₂))
{xs = τ₁ ∗ ++ τ₂ ∗}) ⟨$⟩ σ∈
... | (χ , χ∈ , P.refl) =
sub-⊑-μ $ [ ⟶ˡ ∘ sound τ₁ , ⟶ʳ ∘ sound τ₂ ]′
(Inverse.from (++↔ {xs = τ₁ ∗}) ⟨$⟩ χ∈)
sound ⊥ (there ())
sound ⊤ (there ())
sound (var x) (there ())
------------------------------------------------------------------------
-- Completeness
++-lemma : ∀ {A} xs ys {zs : List A} →
(xs ++ zs) ++ (ys ++ zs) ≈ (xs ++ ys) ++ zs
++-lemma xs ys {zs} = begin
(xs ++ zs) ++ (ys ++ zs) ≈⟨ SetM.assoc xs zs (ys ++ zs) ⟩
xs ++ (zs ++ (ys ++ zs)) ≈⟨ SetM.∙-cong (SetM.refl {x = xs}) (begin
zs ++ (ys ++ zs) ≈⟨ SetM.∙-cong (SetM.refl {x = zs}) (SetM.comm ys zs) ⟩
zs ++ (zs ++ ys) ≈⟨ SetM.sym $ SetM.assoc zs zs ys ⟩
(zs ++ zs) ++ ys ≈⟨ SetM.∙-cong (++-idempotent zs) SetM.refl ⟩
zs ++ ys ≈⟨ SetM.comm zs ys ⟩
ys ++ zs ∎) ⟩
xs ++ (ys ++ zs) ≈⟨ SetM.sym $ SetM.assoc xs ys zs ⟩
(xs ++ ys) ++ zs ∎
where open EqR ([ set ]-Equality _)
open BSEq.⊆-Reasoning
mutual
-- Weakening "commutes" with _∗.
wk-∗-commute : ∀ k {n} (σ : Ty (k + n)) →
σ / wk ↑⋆ k ∗ ⊆ σ ∗ // wk ↑⋆ k
wk-∗-commute k σ (here P.refl) = here P.refl
wk-∗-commute k σ (there •∈•) = there $ wk-∗′-commute k σ •∈•
wk-∗′-commute : ∀ k {n} (σ : Ty (k + n)) →
σ / wk ↑⋆ k ∗′ ⊆ σ ∗′ // wk ↑⋆ k
wk-∗′-commute k (σ₁ ⟶ σ₂) = begin
σ₁ ⟶ σ₂ / wk ↑⋆ k ∗′ ≡⟨ P.refl ⟩
σ₁ / wk ↑⋆ k ∗ ++ σ₂ / wk ↑⋆ k ∗ ⊆⟨ ++⁺ (wk-∗-commute k σ₁)
(wk-∗-commute k σ₂) ⟩
σ₁ ∗ // wk ↑⋆ k ++ σ₂ ∗ // wk ↑⋆ k ≡⟨ P.sym $ map-++-commute
(λ σ → σ / wk ↑⋆ k) (σ₁ ∗) (σ₂ ∗) ⟩
(σ₁ ∗ ++ σ₂ ∗) // wk ↑⋆ k ≡⟨ P.refl ⟩
σ₁ ⟶ σ₂ ∗′ // wk ↑⋆ k ∎
wk-∗′-commute k (μ σ₁ ⟶ σ₂) = begin
(μ σ₁ ⟶ σ₂) / wk ↑⋆ k ∗′ ≡⟨ P.refl ⟩
σ₁ ⟶ σ₂ / wk ↑⋆ (suc k) / sub (σ / wk ↑⋆ k) ∷
(σ₁ / wk ↑⋆ (suc k) ∗ ++ σ₂ / wk ↑⋆ (suc k) ∗)
// sub (σ / wk ↑⋆ k) ⊆⟨ ++⁺ lem₁ lem₂ ⟩
σ₁ ⟶ σ₂ / sub σ / wk ↑⋆ k ∷
(σ₁ ∗ ++ σ₂ ∗) // sub σ // wk ↑⋆ k ≡⟨ P.refl ⟩
μ σ₁ ⟶ σ₂ ∗′ // wk ↑⋆ k ∎
where
σ = μ σ₁ ⟶ σ₂
lem₁ : _ ⊆ _
lem₁ = begin
[ σ₁ ⟶ σ₂ / wk ↑⋆ (suc k) / sub (σ / wk ↑⋆ k) ] ≡⟨ P.cong [_] $ P.sym $
sub-commutes (σ₁ ⟶ σ₂) ⟩
[ σ₁ ⟶ σ₂ / sub σ / wk ↑⋆ k ] ∎
lem₂ : _ ⊆ _
lem₂ = begin
(σ₁ / wk ↑⋆ (suc k) ∗ ++
σ₂ / wk ↑⋆ (suc k) ∗) // sub (σ / wk ↑⋆ k) ⊆⟨ map⁺ _ (++⁺ (wk-∗-commute (suc k) σ₁)
(wk-∗-commute (suc k) σ₂)) ⟩
(σ₁ ∗ // wk ↑⋆ (suc k) ++
σ₂ ∗ // wk ↑⋆ (suc k)) // sub (σ / wk ↑⋆ k) ≡⟨ P.cong (λ σs → σs // sub (σ / wk ↑⋆ k)) $
P.sym $ map-++-commute
(λ σ → σ / wk ↑⋆ suc k) (σ₁ ∗) (σ₂ ∗) ⟩
(σ₁ ∗ ++ σ₂ ∗) // wk ↑⋆ (suc k) // sub (σ / wk ↑⋆ k) ≡⟨ P.sym $ //.sub-commutes (σ₁ ∗ ++ σ₂ ∗) ⟩
(σ₁ ∗ ++ σ₂ ∗) // sub σ // wk ↑⋆ k ∎
wk-∗′-commute k (var x) = begin
var x / wk ↑⋆ k ∗′ ≡⟨ P.cong _∗′ (var-/-wk-↑⋆ k x) ⟩
var (lift k suc x) ∗′ ≡⟨ P.refl ⟩
[] ⊆⟨ (λ ()) ⟩
var x ∗′ // wk ↑⋆ k ∎
wk-∗′-commute k ⊥ = λ ()
wk-∗′-commute k ⊤ = λ ()
-- Substitution "commutes" with _∗.
sub-∗′-commute-var : ∀ k {n} x (τ : Ty n) →
var x / sub τ ↑⋆ k ∗′ ⊆ τ ∗ // wk⋆ k
sub-∗′-commute-var zero zero τ = begin
τ ∗′ ⊆⟨ there ⟩
τ ∗ ≡⟨ P.sym $ //.id-vanishes (τ ∗) ⟩
τ ∗ // wk⋆ zero ∎
sub-∗′-commute-var zero (suc x) τ = begin
var x / idˢ ∗′ ≡⟨ P.cong _∗′ (id-vanishes (var x)) ⟩
var x ∗′ ≡⟨ P.refl ⟩
[] ⊆⟨ (λ ()) ⟩
τ ∗ // wk⋆ zero ∎
sub-∗′-commute-var (suc k) zero τ = begin
[] ⊆⟨ (λ ()) ⟩
τ ∗ // wk⋆ (suc k) ∎
sub-∗′-commute-var (suc k) (suc x) τ = begin
var (suc x) / sub τ ↑⋆ suc k ∗′ ≡⟨ P.cong _∗′ (suc-/-↑ {ρ = sub τ ↑⋆ k} x) ⟩
var x / sub τ ↑⋆ k / wk ∗′ ⊆⟨ wk-∗′-commute zero (var x / sub τ ↑⋆ k) ⟩
var x / sub τ ↑⋆ k ∗′ // wk ⊆⟨ map⁺ _ (sub-∗′-commute-var k x τ) ⟩
τ ∗ // wk⋆ k // wk ≡⟨ P.sym $ //./-weaken (τ ∗) ⟩
τ ∗ // wk⋆ (suc k) ∎
sub-∗-commute : ∀ k {n} σ (τ : Ty n) →
σ / sub τ ↑⋆ k ∗ ⊆ σ ∗ // sub τ ↑⋆ k ++ τ ∗ // wk⋆ k
sub-∗-commute k σ τ (here P.refl) = here P.refl
sub-∗-commute k ⊥ τ •∈• = Inverse.to ++↔ ⟨$⟩ inj₁ •∈•
sub-∗-commute k ⊤ τ •∈• = Inverse.to ++↔ ⟨$⟩ inj₁ •∈•
sub-∗-commute k (var x) τ (there •∈•) = there $ sub-∗′-commute-var k x τ •∈•
sub-∗-commute k (σ₁ ⟶ σ₂) τ {χ} (there •∈•) = there $
χ ∈⟨ •∈• ⟩
(σ₁ / ρ) ∗ ++ (σ₂ / ρ) ∗ ⊆⟨ ++⁺ (sub-∗-commute k σ₁ τ)
(sub-∗-commute k σ₂ τ) ⟩
(σ₁ ∗ // ρ ++ τ ∗ // wk⋆ k) ++
(σ₂ ∗ // ρ ++ τ ∗ // wk⋆ k) ∼⟨ ++-lemma (σ₁ ∗ // ρ) (σ₂ ∗ // ρ) ⟩
(σ₁ ∗ // ρ ++ σ₂ ∗ // ρ) ++
τ ∗ // wk⋆ k ≡⟨ P.cong₂ _++_
(P.sym $ map-++-commute (λ σ → σ / ρ) (σ₁ ∗) (σ₂ ∗))
P.refl ⟩
(σ₁ ∗ ++ σ₂ ∗) // ρ ++ τ ∗ // wk⋆ k ∎
where ρ = sub τ ↑⋆ k
sub-∗-commute k (μ σ₁ ⟶ σ₂) τ (there (here P.refl)) =
there $ here $ P.sym $ sub-commutes (σ₁ ⟶ σ₂)
sub-∗-commute k (μ σ₁ ⟶ σ₂) τ {χ} (there (there •∈•)) = there $ there $
χ ∈⟨ •∈• ⟩
((σ₁ / ρ ↑) ∗ ++ (σ₂ / ρ ↑) ∗) // sub (σ / ρ) ⊆⟨ map⁺ _ (begin
(σ₁ / ρ ↑) ∗ ++ (σ₂ / ρ ↑) ∗ ⊆⟨ ++⁺ (sub-∗-commute (suc k) σ₁ τ)
(sub-∗-commute (suc k) σ₂ τ) ⟩
(σ₁ ∗ // ρ ↑ ++ τ ∗ // wk⋆ (suc k)) ++
(σ₂ ∗ // ρ ↑ ++ τ ∗ // wk⋆ (suc k)) ∼⟨ ++-lemma (σ₁ ∗ // ρ ↑) (σ₂ ∗ // ρ ↑) ⟩
(σ₁ ∗ // ρ ↑ ++ σ₂ ∗ // ρ ↑) ++
τ ∗ // wk⋆ (suc k) ≡⟨ P.cong₂ _++_
(P.sym $ map-++-commute
(λ σ → σ / ρ ↑) (σ₁ ∗) (σ₂ ∗))
P.refl ⟩
(σ₁ ∗ ++ σ₂ ∗) // ρ ↑ ++
τ ∗ // wk⋆ (suc k) ∎) ⟩
((σ₁ ∗ ++ σ₂ ∗) // ρ ↑ ++
τ ∗ // wk⋆ (suc k)) // sub (σ / ρ) ≡⟨ map-++-commute (λ χ → χ / sub (σ / ρ))
((σ₁ ∗ ++ σ₂ ∗) // ρ ↑) _ ⟩
(σ₁ ∗ ++ σ₂ ∗) // ρ ↑ // sub (σ / ρ) ++
τ ∗ // wk⋆ (suc k) // sub (σ / ρ) ≡⟨ P.cong₂ _++_
(P.sym $ //.sub-commutes (σ₁ ∗ ++ σ₂ ∗))
lem ⟩
(σ₁ ∗ ++ σ₂ ∗) // sub σ // ρ ++
τ ∗ // wk⋆ k ∎
where
ρ = sub τ ↑⋆ k
σ = μ σ₁ ⟶ σ₂
lem = ≡R.begin
τ ∗ // wk⋆ (suc k) // sub (σ / ρ) ≡R.≡⟨ P.cong₂ _//_ (//./-weaken (τ ∗)) P.refl ⟩
τ ∗ // wk⋆ k // wk // sub (σ / ρ) ≡R.≡⟨ //.wk-sub-vanishes (τ ∗ // wk⋆ k) ⟩
τ ∗ // wk⋆ k ≡R.∎
where
module ≡R = P.≡-Reasoning
-- The list contains all subterms.
complete : ∀ {n} {σ τ : Ty n} → σ ⊑ τ → σ ∈ τ ∗
complete refl = here P.refl
complete (⟶ˡ σ⊑τ₁) = there (Inverse.to ++↔ ⟨$⟩ inj₁ (complete σ⊑τ₁))
complete (⟶ʳ σ⊑τ₂) = there (Inverse.to (++↔ {P = P._≡_ _} {xs = _ ∗}) ⟨$⟩ inj₂ (complete σ⊑τ₂))
complete (unfold {σ} {τ₁} {τ₂} σ⊑) =
σ ∈⟨ complete σ⊑ ⟩
unfold[μ τ₁ ⟶ τ₂ ] ∗ ⊆⟨ sub-∗-commute zero (τ₁ ⟶ τ₂) τ ⟩
τ₁ ⟶ τ₂ ∗ // sub τ ++ τ ∗ // idˢ ≡⟨ P.cong (_++_ (τ₁ ⟶ τ₂ ∗ // sub τ))
(//.id-vanishes (τ ∗)) ⟩
τ ∗′ ++ τ ∗ ⊆⟨ ++⁺ (there {x = τ} {xs = τ ∗′}) id ⟩
τ ∗ ++ τ ∗ ∼⟨ ++-idempotent (τ ∗) ⟩
τ ∗ ∎
where τ = μ τ₁ ⟶ τ₂
------------------------------------------------------------------------
-- A wrapper function
-- Pairs up subterms with proofs.
subtermsOf : ∀ {n} (τ : Ty n) → List (∃ λ σ → σ ⊑ τ)
subtermsOf τ = map-with-∈ (τ ∗) (-,_ ∘′ sound τ)
-- subtermsOf is complete.
subtermsOf-complete : ∀ {n} {σ τ : Ty n} →
σ ⊑ τ → ∃ λ σ⊑τ → (σ , σ⊑τ) ∈ subtermsOf τ
subtermsOf-complete {σ = σ} {τ} σ⊑τ =
(-, Inverse.to (map-with-∈↔ {f = -,_ ∘′ sound τ}) ⟨$⟩
(σ , complete σ⊑τ , P.refl))
| {
"alphanum_fraction": 0.3758508663,
"avg_line_length": 41.0412698413,
"ext": "agda",
"hexsha": "3b87b4754f644efb711ebc79a1720ef32acbf912",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "nad/codata",
"max_forks_repo_path": "RecursiveTypes/Subterm.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "nad/codata",
"max_issues_repo_path": "RecursiveTypes/Subterm.agda",
"max_line_length": 111,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "1b90445566df0d3b4ba6e31bd0bac417b4c0eb0e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "nad/codata",
"max_stars_repo_path": "RecursiveTypes/Subterm.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-13T14:48:45.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-02-13T14:48:45.000Z",
"num_tokens": 5407,
"size": 12928
} |
-- {-# OPTIONS -v reify:80 #-}
open import Common.Prelude
open import Common.Reflection
open import Common.Equality
module Issue1345 (A : Set) where
unquoteDecl idNat = define (vArg idNat)
(funDef (pi (vArg (def (quote Nat) [])) (abs "" (def (quote Nat) [])))
(clause (vArg (var "") ∷ []) (var 0 []) ∷ []))
thm : ∀ n → idNat n ≡ n
thm n = refl
| {
"alphanum_fraction": 0.6,
"avg_line_length": 24,
"ext": "agda",
"hexsha": "c10a4393509a34b5df9e8f909b4b1d6e6570dd19",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "redfish64/autonomic-agda",
"max_forks_repo_path": "test/Succeed/Issue1345.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "redfish64/autonomic-agda",
"max_issues_repo_path": "test/Succeed/Issue1345.agda",
"max_line_length": 72,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "c0ae7d20728b15d7da4efff6ffadae6fe4590016",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "redfish64/autonomic-agda",
"max_stars_repo_path": "test/Succeed/Issue1345.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 120,
"size": 360
} |
------------------------------------------------------------------------------
-- Testing the erasing of the duplicate definitions required by a conjecture
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module DuplicateAgdaDefinitions1 where
infix 7 _≈_
------------------------------------------------------------------------------
postulate
D : Set
_≈_ : D → D → Set
Eq : D → D → Set
Eq x y = x ≈ y
{-# ATP definition Eq #-}
postulate Eq-trans : ∀ {x y z} → Eq x y → Eq y z → Eq x z
postulate Eq-trans₂ : ∀ {w x y z} → Eq w x → Eq x y → Eq y z → Eq w z
{-# ATP prove Eq-trans₂ Eq-trans #-}
| {
"alphanum_fraction": 0.4024691358,
"avg_line_length": 28.9285714286,
"ext": "agda",
"hexsha": "209ab067d8c79a74ad96f20fb29c66396b086f43",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z",
"max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/apia",
"max_forks_repo_path": "test/Succeed/fol-theorems/DuplicateAgdaDefinitions1.agda",
"max_issues_count": 121,
"max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/apia",
"max_issues_repo_path": "test/Succeed/fol-theorems/DuplicateAgdaDefinitions1.agda",
"max_line_length": 78,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/apia",
"max_stars_repo_path": "test/Succeed/fol-theorems/DuplicateAgdaDefinitions1.agda",
"max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z",
"num_tokens": 175,
"size": 810
} |
{-# OPTIONS --cubical --safe --postfix-projections #-}
module Cardinality.Infinite.ManifestEnumerable where
open import Prelude
open import Data.List.Kleene
open import Data.Fin
import Data.Nat as ℕ
open import Data.Nat using (_+_)
open import Cubical.Data.Sigma.Properties
open import Cubical.Foundations.Prelude using (J)
import Data.List.Kleene.Membership as Kleene
open import Codata.Stream
open import Cardinality.Infinite.Split
open import HITs.PropositionalTruncation.Sugar
private
variable
u : Level
U : A → Type u
s : Level
S : ℕ → Type s
-- ℰ : Type a → Type a
-- ℰ A = Σ[ xs ⦂ Stream A ] Π[ x ⦂ A ] ∥ x ∈ xs ∥
-- ℰ≡ℕ↠ : ℰ A ≡ (ℕ ↠ A)
-- ℰ≡ℕ↠ = refl
-- _∥Σ∥_ : ℰ A → (∀ x → ℰ (U x)) → ℰ (Σ A U)
-- (xs ∥Σ∥ ys) .fst = cantor (xs .fst) (fst ∘ ys)
-- (xs ∥Σ∥ ys) .snd (x , y) =
-- concat-∈
-- (x , y)
-- (xs .fst * (fst ∘ ys)) ∥$∥
-- ⦇ (*-cover x (xs .fst) y (fst ∘ ys)) (xs .snd x) (ys x .snd y) ⦈
| {
"alphanum_fraction": 0.6052910053,
"avg_line_length": 24.8684210526,
"ext": "agda",
"hexsha": "d2cd9196708f2358332b9c38c061b69b75271db5",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-01-05T14:05:30.000Z",
"max_forks_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/combinatorics-paper",
"max_forks_repo_path": "agda/Cardinality/Infinite/ManifestEnumerable.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/combinatorics-paper",
"max_issues_repo_path": "agda/Cardinality/Infinite/ManifestEnumerable.agda",
"max_line_length": 71,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/combinatorics-paper",
"max_stars_repo_path": "agda/Cardinality/Infinite/ManifestEnumerable.agda",
"max_stars_repo_stars_event_max_datetime": "2021-01-05T15:32:14.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-01-05T14:07:44.000Z",
"num_tokens": 373,
"size": 945
} |
{-# OPTIONS --rewriting #-}
open import Agda.Primitive
open import Agda.Builtin.Equality
open import Agda.Builtin.Equality.Rewrite
variable
ℓ ℓ' : Level
A : Set ℓ
B : Set ℓ'
x y z : A
sym : x ≡ y → y ≡ x
sym refl = refl
_∙_ : x ≡ y → y ≡ z → x ≡ z
refl ∙ refl = refl
leftId : (p : x ≡ y) → refl ∙ p ≡ p
leftId refl = refl
rightId : (p : x ≡ y) → p ∙ refl ≡ p
rightId refl = refl
transport : (P : A → Set ℓ') → x ≡ y → P x → P y
transport _ refl px = px
ap : (f : A → B) → x ≡ y → f x ≡ f y
ap _ refl = refl
apd : (P : A → Set ℓ') → (f : (a : A) → P a) → (p : x ≡ y) → transport P p (f x) ≡ f y
apd _ _ refl = refl
postulate
Size : Set
base : Size
next : Size → Size
inf : Size
lim : next inf ≡ inf
postulate
elim : (P : Size → Set ℓ) →
(pb : P base) →
(pn : (s : Size) → P s → P (next s)) →
(pi : P inf) →
-- (elim P pb pn pi pl (next inf)) = (elim P pb pn pi pl inf)
(pl : transport P lim (pn inf pi) ≡ pi) →
(s : Size) → P s
elim-base : (P : Size → Set ℓ) →
(pb : P base) →
(pn : (s : Size) → P s → P (next s)) →
(pi : P inf) →
(pl : transport P lim (pn inf pi) ≡ pi) →
elim P pb pn pi pl base ≡ pb
elim-next : (P : Size → Set ℓ) →
(pb : P base) →
(pn : (s : Size) → P s → P (next s)) →
(pi : P inf) →
(pl : transport P lim (pn inf pi) ≡ pi) →
(s : Size) →
elim P pb pn pi pl (next s) ≡ pn s (elim P pb pn pi pl s)
elim-inf : (P : Size → Set ℓ) →
(pb : P base) →
(pn : (s : Size) → P s → P (next s)) →
(pi : P inf) →
(pl : transport P lim (pn inf pi) ≡ pi) →
elim P pb pn pi pl inf ≡ pi
{-# REWRITE elim-base elim-next elim-inf #-}
postulate
elim-lim : (P : Size → Set ℓ) →
(pb : P base) →
(pn : (s : Size) → P s → P (next s)) →
(pi : P inf) →
(pl : transport P lim (pn inf pi) ≡ pi) →
apd P (elim P pb pn pi pl) lim ≡ pl
{-# REWRITE elim-lim #-}
-- postulate lim-refl : transport (λ s → s ≡ inf) lim lim ≡ refl
absurd : ∀ {A s} → base ≡ next s → A
absurd {A} p =
let discr : Size → Set
discr = elim (λ _ → Set) Size (λ _ _ → A) A (apd (λ _ → Set) (λ _ → A) lim)
in transport discr p base
inj : ∀ {s t} → next s ≡ next t → s ≡ t
inj {s} {t} p =
let pred : Size → Size
pred = elim (λ _ → Size) base (λ s _ → s) inf (apd (λ _ → Size) (λ s → inf) lim)
in ap pred p
data Nat : Size → Set where
zero : (s : Size) → Nat (next s)
succ : (s : Size) → Nat s → Nat (next s)
prev : (P : Size → Set ℓ') → P (next inf) → P inf
prev P pni = transport P lim pni
double' : ∀ s → Nat s → Nat inf
double' _ (zero _) = prev Nat (zero inf)
double' _ (succ s n) = prev Nat (succ inf (prev Nat (succ inf (double' s n))))
-- pn inf pi ≡ pi
-- zero: zero = ?pi
-- next: succ _ (succ _ ?pi) = ?pi
double : ∀ s → Nat s → Nat inf
double = elim (λ s → Nat s → Nat inf) {! !} {! !} {! !} {! !}
| {
"alphanum_fraction": 0.5036751838,
"avg_line_length": 25.5089285714,
"ext": "agda",
"hexsha": "eb7498be611cf566e38ee38fca41ac8fec7c15ab",
"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": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "ionathanch/msc-thesis",
"max_forks_repo_path": "code/InftyHIT.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c",
"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": "ionathanch/msc-thesis",
"max_issues_repo_path": "code/InftyHIT.agda",
"max_line_length": 86,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "8fe15af8f9b5021dc50bcf96665e0988abf28f3c",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "ionathanch/msc-thesis",
"max_stars_repo_path": "code/InftyHIT.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1169,
"size": 2857
} |
----------------------------------------------------------------------------
-- Well-founded induction on the relation _◁_
----------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- N.B This module does not contain combined proofs, but it imports
-- modules which contain combined proofs.
module FOT.FOTC.Program.McCarthy91.WF-Relation.Induction.NonAcc.WellFoundedATP
where
open import FOTC.Base
open import FOTC.Data.Nat
open import FOTC.Program.McCarthy91.McCarthy91
open import FOTC.Program.McCarthy91.WF-Relation
open import FOTC.Program.McCarthy91.WF-Relation.PropertiesATP
----------------------------------------------------------------------------
-- Adapted from FOTC.Data.Nat.Induction.WellFoundedI.wfInd-LT₁.
{-# TERMINATING #-}
◁-wfind : (P : D → Set) →
(∀ {n} → N n → (∀ {m} → N m → m ◁ n → P m) → P n) →
∀ {n} → N n → P n
◁-wfind P h Nn = h Nn (helper Nn)
where
helper : ∀ {n m} → N n → N m → m ◁ n → P m
helper Nn nzero 0◁n = ⊥-elim (0◁x→⊥ Nn 0◁n)
-- This equation does not pass the termination check.
helper nzero (nsucc Nm) Sm◁0 = h (nsucc Nm)
(λ {m'} Nm' m'◁Sm →
let m'◁0 : m' ◁ zero
m'◁0 = ◁-trans Nm' (nsucc Nm) nzero m'◁Sm Sm◁0
in helper nzero Nm' m'◁0
)
-- Other version of the previous equation (this version neither
-- pass the termination check).
-- helper nzero (nsucc {m} Nm) Sm◁0 = h (nsucc Nm)
-- (λ {m'} Nm' m'◁Sm →
-- let m'◁m : MCR m' m
-- m'◁m = x◁Sy→x◁y Nm' Nm m'◁Sm
-- in helper Nm Nm' m'◁m
-- )
-- Other version of the previous equation (this version neither
-- pass the termination check).
-- helper nzero Nm m◁0 = h Nm
-- (λ {m'} Nm' m'◁m →
-- let m'◁0 : MCR m' zero
-- m'◁0 = ◁-trans Nm' Nm nzero m'◁m m◁0
-- in helper nzero Nm' m'◁0
-- )
-- Other version of the previous equation (this version neither
-- pass the termination check).
-- helper {m = m} nzero Nm m◁0 =
-- h Nm (λ {m'} Nm' m'◁m → helper Nm Nm' m'◁m)
helper (nsucc {n} Nn) (nsucc {m} Nm) Sm◁Sn = helper Nn (nsucc Nm) Sm◁n
where
Sm◁n : succ₁ m ◁ n
Sm◁n = x◁Sy→x◁y (nsucc Nm) Nn Sm◁Sn
| {
"alphanum_fraction": 0.5055716054,
"avg_line_length": 32.7432432432,
"ext": "agda",
"hexsha": "f7af352dafdcb3434d2e5cb1cb0a0cfe9706c09a",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "notes/FOT/FOTC/Program/McCarthy91/WF-Relation/Induction/NonAcc/WellFoundedATP.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "notes/FOT/FOTC/Program/McCarthy91/WF-Relation/Induction/NonAcc/WellFoundedATP.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/FOT/FOTC/Program/McCarthy91/WF-Relation/Induction/NonAcc/WellFoundedATP.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": 841,
"size": 2423
} |
{-# OPTIONS --no-qualified-instances #-}
module NoQualifiedInstances-ParameterizedImport where
postulate
T : Set
open import NoQualifiedInstances.ParameterizedImport.A T as A
postulate
f : {{A.I}} → A.I
test : A.I
test = f
| {
"alphanum_fraction": 0.7284482759,
"avg_line_length": 15.4666666667,
"ext": "agda",
"hexsha": "21e726a409a09ebfed61ad609cf80db575785147",
"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/NoQualifiedInstances-ParameterizedImport.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/NoQualifiedInstances-ParameterizedImport.agda",
"max_line_length": 61,
"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/NoQualifiedInstances-ParameterizedImport.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": 63,
"size": 232
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020, 2021 Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
module LibraBFT.ImplShared.Util.Dijkstra.All where
open import Dijkstra.All public
open import LibraBFT.ImplShared.LBFT public
| {
"alphanum_fraction": 0.7925531915,
"avg_line_length": 34.1818181818,
"ext": "agda",
"hexsha": "6ccef438d4836931355b08045ea0c497d7c4b620",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_forks_repo_path": "src/LibraBFT/ImplShared/Util/Dijkstra/All.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_issues_repo_path": "src/LibraBFT/ImplShared/Util/Dijkstra/All.agda",
"max_line_length": 111,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_stars_repo_path": "src/LibraBFT/ImplShared/Util/Dijkstra/All.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 100,
"size": 376
} |
{-# OPTIONS --allow-unsolved-metas #-}
module lambda.system-d where
open import Data.Nat
open import Data.Fin hiding (lift)
open import lambda.vec
open import lambda.untyped
infixr 21 _∧_
infixr 22 _⇒_
data type : Set where
base : ℕ → type
_⇒_ _∧_ : type → type → type
context : ℕ → Set
context = vec type
infix 10 _⊢_∶_
data _⊢_∶_ {n : ℕ} (Γ : context n) : term n → type → Set where
ax : ∀ {i} → Γ ⊢ var i ∶ lookup i Γ
lam : ∀ {A B x} → Γ ▸ A ⊢ x ∶ B → Γ ⊢ lam x ∶ A ⇒ B
app : ∀ {A B x y} → Γ ⊢ x ∶ (A ⇒ B) → Γ ⊢ y ∶ A → Γ ⊢ app x y ∶ B
∧ⁱ : ∀ {A B x} → Γ ⊢ x ∶ A → Γ ⊢ x ∶ B → Γ ⊢ x ∶ A ∧ B
∧ᵉˡ : ∀ {A B x} → Γ ⊢ x ∶ A ∧ B → Γ ⊢ x ∶ A
∧ᵉʳ : ∀ {A B x} → Γ ⊢ x ∶ A ∧ B → Γ ⊢ x ∶ B
⊢_∶_ : term 0 → type → Set
⊢ x ∶ t = ε ⊢ x ∶ t
-- This lemma is actually false, because i did not setup the context
-- inclusions properly. It's not really complicated to fix: just
-- transpose the whole machinery from lambda.stack to lambda.vec. The
-- only thing is that it's a bit long and boring to get the same job
-- done on an indexed datatype. Substitution is hard to get right...
lift-p : ∀ {n A X Γ} {x : term n} → Γ ⊢ x ∶ A → Γ ▸ X ⊢ lift x ∶ A
lift-p ax = ax
lift-p (lam x) = {!!}
lift-p (app x y) = app (lift-p x) (lift-p y)
lift-p (∧ⁱ x₁ x₂) = ∧ⁱ (lift-p x₁) (lift-p x₂)
lift-p (∧ᵉˡ x) = ∧ᵉˡ (lift-p x)
lift-p (∧ᵉʳ x) = ∧ᵉʳ (lift-p x)
↑-p : ∀ {n m X Γ Δ} {ρ : Fin n → term m} →
((i : Fin n) → Δ ⊢ ρ i ∶ lookup i Γ) →
(i : Fin (suc n)) → (Δ ▸ X) ⊢ ↑ ρ i ∶ lookup i (Γ ▸ X)
↑-p ρT zero = ax
↑-p ρT (suc i) = lift-p (ρT i)
subst-p : ∀ {n m A} {x : term n} {Γ : context n} {Δ : context m} {ρ : Fin n → term m} →
Γ ⊢ x ∶ A → ((i : Fin n) → Δ ⊢ ρ i ∶ lookup i Γ) → Δ ⊢ subst x ρ ∶ A
subst-p (ax {i}) ρT = ρT i
subst-p (lam x) ρT = lam (subst-p x (↑-p ρT))
subst-p (app x y) ρT = app (subst-p x ρT) (subst-p y ρT)
subst-p (∧ⁱ x₁ x₂) ρT = ∧ⁱ (subst-p x₁ ρT) (subst-p x₂ ρT)
subst-p (∧ᵉˡ x) ρT = ∧ᵉˡ (subst-p x ρT)
subst-p (∧ᵉʳ x) ρT = ∧ᵉʳ (subst-p x ρT)
| {
"alphanum_fraction": 0.5331658291,
"avg_line_length": 32.0967741935,
"ext": "agda",
"hexsha": "afa42cf36eb729e74377e950d75417371cdc60cb",
"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": "09a231d9b3057d57b864070188ed9fe14a07eda2",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "Lapin0t/lambda",
"max_forks_repo_path": "lambda/system-d.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "09a231d9b3057d57b864070188ed9fe14a07eda2",
"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": "Lapin0t/lambda",
"max_issues_repo_path": "lambda/system-d.agda",
"max_line_length": 87,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "09a231d9b3057d57b864070188ed9fe14a07eda2",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "Lapin0t/lambda",
"max_stars_repo_path": "lambda/system-d.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 943,
"size": 1990
} |
module README where
------------------------------------------------------------------------
-- The Agda "standard" library, version 0.2
--
-- Author: Nils Anders Danielsson, with contributions from
-- Jean-Philippe Bernardy, Samuel Bronson, Liang-Ting Chen, Dan Doel,
-- Patrik Jansson, Shin-Cheng Mu, and Ulf Norell
------------------------------------------------------------------------
-- This version of the library has been tested using Agda 2.2.4.
-- Note that no guarantees are currently made about forwards or
-- backwards compatibility, the library is still at an experimental
-- stage.
-- To make use of the library, add the path to the library’s root
-- directory (src) to the Agda search path, either using the
-- --include-path flag or by customising the Emacs mode variable
-- agda2-include-dirs (M-x customize-group RET agda2 RET).
-- To compile programs using some of the IO functions you need to
-- install the Haskell package utf8-string (available from Hackage).
-- Contributions to this library are welcome. Please send
-- contributions in the form of darcs patches (run
-- darcs send --output <patch file> and attach the patch file to an
-- email), and include a statement saying that you agree to release
-- your library patches under the library's licence.
------------------------------------------------------------------------
-- Module hierarchy
------------------------------------------------------------------------
-- The top-level module names of the library are currently allocated
-- as follows:
--
-- • Algebra
-- Abstract algebra (monoids, groups, rings etc.), along with
-- properties needed to specify these structures (associativity,
-- commutativity, etc.), and operations on and proofs about the
-- structures.
-- • Category
-- Category theory-inspired idioms used to structure functional
-- programs (functors and monads, for instance).
-- • Coinduction
-- Support for coinduction.
-- • Data
-- Data types and properties about data types. (Also some
-- combinators working solely on and with functions; see
-- Data.Function.)
-- • Foreign
-- Related to the foreign function interface.
-- • Induction
-- A general framework for induction (includes lexicographic and
-- well-founded induction).
-- • IO
-- Input/output-related functions.
-- • Relation
-- Properties of and proofs about relations (mostly homogeneous
-- binary relations).
-- • Size
-- Sizes used by the sized types mechanism.
------------------------------------------------------------------------
-- A selection of useful library modules
------------------------------------------------------------------------
-- Note that module names in source code are often hyperlinked to the
-- corresponding module. In the Emacs mode you can follow these
-- hyperlinks by typing M-. or clicking with the middle mouse button.
-- • Some data types
import Data.Bool -- Booleans.
import Data.Char -- Characters.
import Data.Empty -- The empty type.
import Data.Fin -- Finite sets.
import Data.List -- Lists.
import Data.Maybe -- The maybe type.
import Data.Nat -- Natural numbers.
import Data.Product -- Products.
import Data.Stream -- Streams.
import Data.String -- Strings.
import Data.Sum -- Disjoint sums.
import Data.Unit -- The unit type.
import Data.Vec -- Fixed-length vectors.
-- • Some types used to structure computations
import Category.Functor -- Functors.
import Category.Applicative -- Applicative functors.
import Category.Monad -- Monads.
-- • Equality
-- Propositional equality:
import Relation.Binary.PropositionalEquality
-- Convenient syntax for "equational reasoning" using a preorder:
import Relation.Binary.PreorderReasoning
-- Solver for commutative ring or semiring equalities:
import Algebra.RingSolver
-- • Properties of functions, sets and relations
-- Monoids, rings and similar algebraic structures:
import Algebra
-- Negation, decidability, and similar operations on sets:
import Relation.Nullary
-- Properties of homogeneous binary relations:
import Relation.Binary
-- • Induction
-- An abstraction of various forms of recursion/induction:
import Induction
-- Well-founded induction:
import Induction.WellFounded
-- Various forms of induction for natural numbers:
import Induction.Nat
-- • Support for coinduction
import Coinduction
-- • IO
import IO
------------------------------------------------------------------------
-- Record hierarchies
------------------------------------------------------------------------
-- When an abstract hierarchy of some sort (for instance semigroup →
-- monoid → group) is included in the library the basic approach is to
-- specify the properties of every concept in terms of a record
-- containing just properties, parameterised on the underlying
-- operations, sets etc.:
--
-- record IsSemigroup {A} (≈ : Rel A) (∙ : Op₂ A) : Set where
-- open FunctionProperties ≈
-- field
-- isEquivalence : IsEquivalence ≈
-- assoc : Associative ∙
-- ∙-pres-≈ : ∙ Preserves₂ ≈ ⟶ ≈ ⟶ ≈
--
-- More specific concepts are then specified in terms of the simpler
-- ones:
--
-- record IsMonoid {A} (≈ : Rel A) (∙ : Op₂ A) (ε : A) : Set where
-- open FunctionProperties ≈
-- field
-- isSemigroup : IsSemigroup ≈ ∙
-- identity : Identity ε ∙
--
-- open IsSemigroup isSemigroup public
--
-- Note here that open IsSemigroup isSemigroup public ensures that the
-- fields of the isSemigroup record can be accessed directly; this
-- technique enables the user of an IsMonoid record to use underlying
-- records without having to manually open an entire record hierarchy.
-- This is not always possible, though. Consider the following definition
-- of preorders:
--
-- record IsPreorder {A : Set}
-- (_≈_ : Rel A) -- The underlying equality.
-- (_∼_ : Rel A) -- The relation.
-- : Set where
-- field
-- isEquivalence : IsEquivalence _≈_
-- -- Reflexivity is expressed in terms of an underlying equality:
-- reflexive : _≈_ ⇒ _∼_
-- trans : Transitive _∼_
-- ∼-resp-≈ : _∼_ Respects₂ _≈_
--
-- module Eq = IsEquivalence isEquivalence
--
-- refl : Reflexive _∼_
-- refl = reflexive Eq.refl
--
-- The Eq module in IsPreorder is not opened publicly, because it
-- contains some fields which clash with fields or other definitions
-- in IsPreorder.
-- Records packing up properties with the corresponding operations,
-- sets, etc. are sometimes also defined:
--
-- record Semigroup : Set₁ where
-- infixl 7 _∙_
-- infix 4 _≈_
-- field
-- carrier : Set
-- _≈_ : Rel carrier
-- _∙_ : Op₂ carrier
-- isSemigroup : IsSemigroup _≈_ _∙_
--
-- open IsSemigroup isSemigroup public
--
-- setoid : Setoid
-- setoid = record { isEquivalence = isEquivalence }
--
-- record Monoid : Set₁ where
-- infixl 7 _∙_
-- infix 4 _≈_
-- field
-- carrier : Set
-- _≈_ : Rel carrier
-- _∙_ : Op₂ carrier
-- ε : carrier
-- isMonoid : IsMonoid _≈_ _∙_ ε
--
-- open IsMonoid isMonoid public
--
-- semigroup : Semigroup
-- semigroup = record { isSemigroup = isSemigroup }
--
-- open Semigroup semigroup public using (setoid)
--
-- Note that the Monoid record does not include a Semigroup field.
-- Instead the Monoid /module/ includes a "repackaging function"
-- semigroup which converts a Monoid to a Semigroup.
-- The above setup may seem a bit complicated, but we think it makes the
-- library quite easy to work with, while also providing enough
-- flexibility.
------------------------------------------------------------------------
-- More documentation
------------------------------------------------------------------------
-- Some examples showing where the natural numbers and some related
-- operations and properties are defined, and how they can be used:
import README.Nat
------------------------------------------------------------------------
-- Core modules
------------------------------------------------------------------------
-- Some modules have names ending in ".Core". These modules are
-- internal, and have (mostly) been created to avoid mutual recursion
-- between modules. They should not be imported directly; their
-- contents are reexported by other modules.
------------------------------------------------------------------------
-- All library modules
------------------------------------------------------------------------
-- For short descriptions of every library module, see Everything:
import Everything
| {
"alphanum_fraction": 0.6081311923,
"avg_line_length": 34.0348837209,
"ext": "agda",
"hexsha": "25afe9794ab6ca522bd5779aba95e3ca09035671",
"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/README.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/README.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/README.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": 1927,
"size": 8781
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Functors
------------------------------------------------------------------------
-- Note that currently the functor laws are not included here.
module Category.Functor where
open import Function
open import Level
record RawFunctor {ℓ} (F : Set ℓ → Set ℓ) : Set (suc ℓ) where
infixl 4 _<$>_ _<$_
field
_<$>_ : ∀ {A B} → (A → B) → F A → F B
_<$_ : ∀ {A B} → A → F B → F A
x <$ y = const x <$> y
| {
"alphanum_fraction": 0.4230769231,
"avg_line_length": 23.6363636364,
"ext": "agda",
"hexsha": "3fc7676ebb5fb2e484a0cddb73bc78829188a480",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "qwe2/try-agda",
"max_forks_repo_path": "agda-stdlib-0.9/src/Category/Functor.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "qwe2/try-agda",
"max_issues_repo_path": "agda-stdlib-0.9/src/Category/Functor.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9d4c43b1609d3f085636376fdca73093481ab882",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "qwe2/try-agda",
"max_stars_repo_path": "agda-stdlib-0.9/src/Category/Functor.agda",
"max_stars_repo_stars_event_max_datetime": "2016-10-20T15:52:05.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-10-20T15:52:05.000Z",
"num_tokens": 139,
"size": 520
} |
------------------------------------------------------------------------------
-- Testing variable names clash
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module VariableNamesClash where
postulate
D : Set
_≡_ : D → D → Set
a b : D
postulate a≡b : a ≡ b
{-# ATP axiom a≡b #-}
foo : (n : D) → a ≡ b
foo n = prf n
where
-- The translation of this postulate must use two diferents
-- quantified variables names e.g. ∀ x. ∀ y. a ≡ b.
postulate prf : (n : D) → a ≡ b
{-# ATP prove prf #-}
| {
"alphanum_fraction": 0.427769986,
"avg_line_length": 26.4074074074,
"ext": "agda",
"hexsha": "655bd656dc4238f3435e01a727d0d63280ba0b9a",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2016-08-03T03:54:55.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-05-10T23:06:19.000Z",
"max_forks_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/apia",
"max_forks_repo_path": "test/Succeed/fol-theorems/VariableNamesClash.agda",
"max_issues_count": 121,
"max_issues_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_issues_repo_issues_event_max_datetime": "2018-04-22T06:01:44.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-25T13:22:12.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/apia",
"max_issues_repo_path": "test/Succeed/fol-theorems/VariableNamesClash.agda",
"max_line_length": 78,
"max_stars_count": 10,
"max_stars_repo_head_hexsha": "a66c5ddca2ab470539fd68c42c4fbd45f720d682",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/apia",
"max_stars_repo_path": "test/Succeed/fol-theorems/VariableNamesClash.agda",
"max_stars_repo_stars_event_max_datetime": "2019-12-03T13:44:25.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-09-03T20:54:16.000Z",
"num_tokens": 178,
"size": 713
} |
-- Solver for Functor
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
open import Categories.Functor renaming (id to idF)
module Experiment.Categories.Solver.Functor
{o ℓ e o′ ℓ′ e′} {𝒞 : Category o ℓ e} {𝒟 : Category o′ ℓ′ e′}
(F : Functor 𝒞 𝒟)
where
open import Level
open import Relation.Binary using (Rel)
import Categories.Morphism.Reasoning as MR
import Experiment.Categories.Solver.Category
module 𝒞 = Category 𝒞
module CS = Experiment.Categories.Solver.Category 𝒞
open CS using (:id; _:∘_; ∥_∥) renaming (∥-∥ to ∥-∥′) public
open Category 𝒟
open HomReasoning
open MR 𝒟
open Functor F
private
variable
A B C D E : Obj
infixr 9 _:∘_
data Expr : Rel Obj (o ⊔ o′ ⊔ ℓ ⊔ ℓ′) where
:id : Expr A A
_:∘_ : Expr B C → Expr A B → Expr A C
:F₁ : ∀ {A B} → CS.Expr A B → Expr (F₀ A) (F₀ B)
∥_∥ : A ⇒ B → Expr A B
-- Semantics
⟦_⟧ : Expr A B → A ⇒ B
⟦ :id ⟧ = id
⟦ e₁ :∘ e₂ ⟧ = ⟦ e₁ ⟧ ∘ ⟦ e₂ ⟧
⟦ :F₁ e ⟧ = F₁ CS.⟦ e ⟧
⟦ ∥ f ∥ ⟧ = f
F₁⟦_⟧N∘_ : ∀ {B C} → CS.Expr B C → A ⇒ F₀ B → A ⇒ F₀ C
F₁⟦ :id ⟧N∘ g = g
F₁⟦ e₁ :∘ e₂ ⟧N∘ g = F₁⟦ e₁ ⟧N∘ (F₁⟦ e₂ ⟧N∘ g)
F₁⟦ ∥ f ∥ ⟧N∘ g = F₁ f ∘ g
⟦_⟧N∘_ : Expr B C → A ⇒ B → A ⇒ C
⟦ :id ⟧N∘ g = g
⟦ e₁ :∘ e₂ ⟧N∘ g = ⟦ e₁ ⟧N∘ (⟦ e₂ ⟧N∘ g)
⟦ :F₁ e ⟧N∘ g = F₁⟦ e ⟧N∘ g
⟦ ∥ f ∥ ⟧N∘ g = f ∘ g
⟦_⟧N : Expr A B → A ⇒ B
⟦ e ⟧N = ⟦ e ⟧N∘ id
F₁⟦e⟧N∘f≈F₁⟦e⟧∘f : ∀ {B C} (e : CS.Expr B C) (g : A ⇒ F₀ B) →
F₁⟦ e ⟧N∘ g ≈ F₁ CS.⟦ e ⟧ ∘ g
F₁⟦e⟧N∘f≈F₁⟦e⟧∘f :id g = begin
g ≈˘⟨ identityˡ ⟩
id ∘ g ≈˘⟨ identity ⟩∘⟨refl ⟩
F₁ 𝒞.id ∘ g ∎
F₁⟦e⟧N∘f≈F₁⟦e⟧∘f (e₁ :∘ e₂) g = begin
F₁⟦ e₁ ⟧N∘ (F₁⟦ e₂ ⟧N∘ g) ≈⟨ F₁⟦e⟧N∘f≈F₁⟦e⟧∘f e₁ (F₁⟦ e₂ ⟧N∘ g) ⟩
F₁ CS.⟦ e₁ ⟧ ∘ (F₁⟦ e₂ ⟧N∘ g) ≈⟨ pushʳ (F₁⟦e⟧N∘f≈F₁⟦e⟧∘f e₂ g) ⟩
(F₁ CS.⟦ e₁ ⟧ ∘ F₁ CS.⟦ e₂ ⟧) ∘ g ≈˘⟨ homomorphism ⟩∘⟨refl ⟩
F₁ (CS.⟦ e₁ ⟧ 𝒞.∘ CS.⟦ e₂ ⟧) ∘ g ∎
F₁⟦e⟧N∘f≈F₁⟦e⟧∘f ∥ x ∥ g = refl
⟦e⟧N∘f≈⟦e⟧∘f : (e : Expr B C) (g : A ⇒ B) → ⟦ e ⟧N∘ g ≈ ⟦ e ⟧ ∘ g
⟦e⟧N∘f≈⟦e⟧∘f :id g = ⟺ identityˡ
⟦e⟧N∘f≈⟦e⟧∘f (e₁ :∘ e₂) g = begin
⟦ e₁ ⟧N∘ (⟦ e₂ ⟧N∘ g) ≈⟨ ⟦e⟧N∘f≈⟦e⟧∘f e₁ (⟦ e₂ ⟧N∘ g) ⟩
⟦ e₁ ⟧ ∘ (⟦ e₂ ⟧N∘ g) ≈⟨ pushʳ (⟦e⟧N∘f≈⟦e⟧∘f e₂ g) ⟩
(⟦ e₁ ⟧ ∘ ⟦ e₂ ⟧) ∘ g ∎
⟦e⟧N∘f≈⟦e⟧∘f (:F₁ e) g = F₁⟦e⟧N∘f≈F₁⟦e⟧∘f e g
⟦e⟧N∘f≈⟦e⟧∘f ∥ f ∥ g = refl
⟦e⟧N≈⟦e⟧ : (e : Expr A B) → ⟦ e ⟧N ≈ ⟦ e ⟧
⟦e⟧N≈⟦e⟧ e = ⟦e⟧N∘f≈⟦e⟧∘f e id ○ identityʳ
solve : (e₁ e₂ : Expr A B) → ⟦ e₁ ⟧N ≈ ⟦ e₂ ⟧N → ⟦ e₁ ⟧ ≈ ⟦ e₂ ⟧
solve e₁ e₂ eq = begin
⟦ e₁ ⟧ ≈˘⟨ ⟦e⟧N≈⟦e⟧ e₁ ⟩
⟦ e₁ ⟧N ≈⟨ eq ⟩
⟦ e₂ ⟧N ≈⟨ ⟦e⟧N≈⟦e⟧ e₂ ⟩
⟦ e₂ ⟧ ∎
∥-∥ : ∀ {f : A ⇒ B} → Expr A B
∥-∥ {f = f} = ∥ f ∥
| {
"alphanum_fraction": 0.4565217391,
"avg_line_length": 26.5567010309,
"ext": "agda",
"hexsha": "388284763c06517a6f81d1ffff6fee4b4c5e8fb8",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "rei1024/agda-misc",
"max_forks_repo_path": "Experiment/Categories/Solver/Functor.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "rei1024/agda-misc",
"max_issues_repo_path": "Experiment/Categories/Solver/Functor.agda",
"max_line_length": 75,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "37200ea91d34a6603d395d8ac81294068303f577",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "rei1024/agda-misc",
"max_stars_repo_path": "Experiment/Categories/Solver/Functor.agda",
"max_stars_repo_stars_event_max_datetime": "2020-04-21T00:03:43.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-07T17:49:42.000Z",
"num_tokens": 1714,
"size": 2576
} |
module Thesis.LangChanges where
open import Thesis.Changes
open import Thesis.IntChanges
open import Thesis.Types
open import Thesis.Contexts
open import Thesis.Environments
open import Relation.Binary.PropositionalEquality
Chτ : (τ : Type) → Set
Chτ τ = ⟦ Δt τ ⟧Type
ΔΓ : Context → Context
ΔΓ ∅ = ∅
ΔΓ (τ • Γ) = Δt τ • τ • ΔΓ Γ
ChΓ : ∀ (Γ : Context) → Set
ChΓ Γ = ⟦ ΔΓ Γ ⟧Context
[_]τ_from_to_ : ∀ (τ : Type) → (dv : Chτ τ) → (v1 v2 : ⟦ τ ⟧Type) → Set
isCompChangeStructureτ : ∀ τ → IsCompChangeStructure ⟦ τ ⟧Type ⟦ Δt τ ⟧Type [ τ ]τ_from_to_
changeStructureτ : ∀ τ → ChangeStructure ⟦ τ ⟧Type
changeStructureτ τ = record { isCompChangeStructure = isCompChangeStructureτ τ }
instance
ichangeStructureτ : ∀ {τ} → ChangeStructure ⟦ τ ⟧Type
ichangeStructureτ {τ} = changeStructureτ τ
[ σ ⇒ τ ]τ df from f1 to f2 =
∀ (da : Chτ σ) (a1 a2 : ⟦ σ ⟧Type) →
[ σ ]τ da from a1 to a2 → [ τ ]τ df a1 da from f1 a1 to f2 a2
[ unit ]τ tt from tt to tt = ⊤
[ int ]τ dv from v1 to v2 = v1 + dv ≡ v2
[ pair σ τ ]τ (da , db) from (a1 , b1) to (a2 , b2) = [ σ ]τ da from a1 to a2 × [ τ ]τ db from b1 to b2
[ sum σ τ ]τ dv from v1 to v2 = sch_from_to_ dv v1 v2
isCompChangeStructureτ (σ ⇒ τ) = ChangeStructure.isCompChangeStructure (funCS {{changeStructureτ σ}} {{changeStructureτ τ}})
isCompChangeStructureτ unit = ChangeStructure.isCompChangeStructure unitCS
isCompChangeStructureτ int = ChangeStructure.isCompChangeStructure intCS
isCompChangeStructureτ (pair σ τ) = ChangeStructure.isCompChangeStructure (pairCS {{changeStructureτ σ}} {{changeStructureτ τ}})
isCompChangeStructureτ (sum σ τ) = ChangeStructure.isCompChangeStructure (sumCS {{changeStructureτ σ}} {{changeStructureτ τ}})
open import Data.Unit
-- We can define an alternative semantics for contexts, that defines environments as nested products:
⟦_⟧Context-prod : Context → Set
⟦ ∅ ⟧Context-prod = ⊤
⟦ τ • Γ ⟧Context-prod = ⟦ τ ⟧Type × ⟦ Γ ⟧Context-prod
-- And define a change structure for such environments, reusing the change
-- structure constructor for pairs. However, this change structure does not
-- duplicate base values in the environment. We probably *could* define a
-- different change structure for pairs that gives the right result.
changeStructureΓ-old : ∀ Γ → ChangeStructure ⟦ Γ ⟧Context-prod
changeStructureΓ-old ∅ = unitCS
changeStructureΓ-old (τ • Γ) = pairCS {{changeStructureτ τ}} {{changeStructureΓ-old Γ}}
data [_]Γ_from_to_ : ∀ Γ → ChΓ Γ → (ρ1 ρ2 : ⟦ Γ ⟧Context) → Set where
v∅ : [ ∅ ]Γ ∅ from ∅ to ∅
_v•_ : ∀ {τ Γ dv v1 v2 dρ ρ1 ρ2} →
(dvv : [ τ ]τ dv from v1 to v2) →
(dρρ : [ Γ ]Γ dρ from ρ1 to ρ2) →
[ τ • Γ ]Γ (dv • v1 • dρ) from (v1 • ρ1) to (v2 • ρ2)
module _ where
_e⊕_ : ∀ {Γ} → ⟦ Γ ⟧Context → ChΓ Γ → ⟦ Γ ⟧Context
_e⊕_ ∅ ∅ = ∅
_e⊕_ (v • ρ) (dv • _ • dρ) = v ⊕ dv • ρ e⊕ dρ
_e⊝_ : ∀ {Γ} → ⟦ Γ ⟧Context → ⟦ Γ ⟧Context → ChΓ Γ
_e⊝_ ∅ ∅ = ∅
_e⊝_ (v₂ • ρ₂) (v₁ • ρ₁) = v₂ ⊝ v₁ • v₁ • ρ₂ e⊝ ρ₁
isEnvCompCS : ∀ Γ → IsCompChangeStructure ⟦ Γ ⟧Context (ChΓ Γ) [ Γ ]Γ_from_to_
efromto→⊕ : ∀ {Γ} (dρ : ChΓ Γ) (ρ1 ρ2 : ⟦ Γ ⟧Context) →
[ Γ ]Γ dρ from ρ1 to ρ2 → (ρ1 e⊕ dρ) ≡ ρ2
efromto→⊕ .∅ .∅ .∅ v∅ = refl
efromto→⊕ .(_ • _ • _) .(_ • _) .(_ • _) (dvv v• dρρ) =
cong₂ _•_ (fromto→⊕ _ _ _ dvv) (efromto→⊕ _ _ _ dρρ)
e⊝-fromto : ∀ {Γ} → (ρ1 ρ2 : ⟦ Γ ⟧Context) → [ Γ ]Γ ρ2 e⊝ ρ1 from ρ1 to ρ2
e⊝-fromto ∅ ∅ = v∅
e⊝-fromto (v1 • ρ1) (v2 • ρ2) = ⊝-fromto v1 v2 v• e⊝-fromto ρ1 ρ2
_e⊚_ : ∀ {Γ} → ChΓ Γ → ChΓ Γ → ChΓ Γ
_e⊚_ {∅} ∅ ∅ = ∅
_e⊚_ {τ • Γ} (dv1 • v1 • dρ1) (dv2 • _ • dρ2) = dv1 ⊚[ ⟦ τ ⟧Type ] dv2 • v1 • dρ1 e⊚ dρ2
e⊚-fromto : ∀ Γ → (ρ1 ρ2 ρ3 : ⟦ Γ ⟧Context) (dρ1 dρ2 : ChΓ Γ) →
[ Γ ]Γ dρ1 from ρ1 to ρ2 →
[ Γ ]Γ dρ2 from ρ2 to ρ3 → [ Γ ]Γ (dρ1 e⊚ dρ2) from ρ1 to ρ3
e⊚-fromto ∅ ∅ ∅ ∅ ∅ ∅ v∅ v∅ = v∅
e⊚-fromto (τ • Γ) (v1 • ρ1) (v2 • ρ2) (v3 • ρ3)
(dv1 • (.v1 • dρ1)) (dv2 • (.v2 • dρ2))
(dvv1 v• dρρ1) (dvv2 v• dρρ2) =
⊚-fromto v1 v2 v3 dv1 dv2 dvv1 dvv2
v•
e⊚-fromto Γ ρ1 ρ2 ρ3 dρ1 dρ2 dρρ1 dρρ2
isEnvCompCS Γ = record
{ isChangeStructure = record
{ _⊕_ = _e⊕_
; fromto→⊕ = efromto→⊕
; _⊝_ = _e⊝_
; ⊝-fromto = e⊝-fromto
}
; _⊚_ = _e⊚_
; ⊚-fromto = e⊚-fromto Γ
}
changeStructureΓ : ∀ Γ → ChangeStructure ⟦ Γ ⟧Context
changeStructureΓ Γ = record { isCompChangeStructure = isEnvCompCS Γ }
instance
ichangeStructureΓ : ∀ {Γ} → ChangeStructure ⟦ Γ ⟧Context
ichangeStructureΓ {Γ} = changeStructureΓ Γ
changeStructureΓτ : ∀ Γ τ → ChangeStructure (⟦ Γ ⟧Context → ⟦ τ ⟧Type)
changeStructureΓτ Γ τ = funCS
instance
ichangeStructureΓτ : ∀ {Γ τ} → ChangeStructure (⟦ Γ ⟧Context → ⟦ τ ⟧Type)
ichangeStructureΓτ {Γ} {τ} = changeStructureΓτ Γ τ
| {
"alphanum_fraction": 0.6182166418,
"avg_line_length": 37.592,
"ext": "agda",
"hexsha": "d3bad4009ccca3e55e00df8a9d973a186219947c",
"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": "Thesis/LangChanges.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": "Thesis/LangChanges.agda",
"max_line_length": 128,
"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": "Thesis/LangChanges.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": 2115,
"size": 4699
} |
{-# OPTIONS --cubical --guardedness --safe #-}
module Data.PolyP.Universe where
open import Prelude hiding (_⟨_⟩_)
open import Data.Vec.Iterated
open import Data.Fin.Indexed
--------------------------------------------------------------------------------
--
-- The Universe of functors we're interested in.
--
--------------------------------------------------------------------------------
data Functor (n : ℕ) : Type where
! : Fin n → Functor n
_⊕_ : (F G : Functor n) → Functor n
_⊗_ : (F G : Functor n) → Functor n
μ⟨_⟩ : Functor (suc n) → Functor n
⓪ : Functor n
① : Functor n
infixl 6 _⊕_
infixl 7 _⊗_
Params : ℕ → Type₁
Params = Vec Type
variable
n m k : ℕ
F G : Functor n
As Bs : Params n
---------------------------------------------------------------------------------
--
-- Interpretation
--
---------------------------------------------------------------------------------
mutual
⟦_⟧ : Functor n → Params n → Type
⟦ ! i ⟧ xs = xs [ i ]
⟦ F ⊕ G ⟧ xs = ⟦ F ⟧ xs ⊎ ⟦ G ⟧ xs
⟦ F ⊗ G ⟧ xs = ⟦ F ⟧ xs × ⟦ G ⟧ xs
⟦ μ⟨ F ⟩ ⟧ xs = μ F xs
⟦ ⓪ ⟧ xs = ⊥
⟦ ① ⟧ xs = ⊤
record μ (F : Functor (suc n)) (As : Params n) : Type where
pattern; inductive; constructor ⟨_⟩
field unwrap : ⟦ F ⟧ (μ F As ∷ As)
open μ public
| {
"alphanum_fraction": 0.4079754601,
"avg_line_length": 25.0769230769,
"ext": "agda",
"hexsha": "8917daa12417924921f58144a0d67d9ce5db7656",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-playground",
"max_forks_repo_path": "Data/PolyP/Universe.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-playground",
"max_issues_repo_path": "Data/PolyP/Universe.agda",
"max_line_length": 81,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-playground",
"max_stars_repo_path": "Data/PolyP/Universe.agda",
"max_stars_repo_stars_event_max_datetime": "2021-11-16T08:11:34.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-09-11T17:45:41.000Z",
"num_tokens": 416,
"size": 1304
} |
------------------------------------------------------------------------------
-- The alternating bit protocol (ABP) is correct
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- This module proves the correctness of the ABP by simplifing the
-- formalization in Dybjer and Sander (1989) using a stronger (maybe
-- invalid) co-induction principle.
module FOT.FOTC.Program.ABP.StrongerInductionPrinciple.CorrectnessProofI where
open import FOT.FOTC.Relation.Binary.Bisimilarity.Type
open import FOT.FOTC.Program.ABP.StrongerInductionPrinciple.LemmaI
open import FOTC.Base
open import FOTC.Base.List
open import FOTC.Data.Stream.Type
open import FOTC.Data.Stream.Equality.PropertiesI
open import FOTC.Program.ABP.ABP hiding ( B )
open import FOTC.Program.ABP.Fair.Type
open import FOTC.Program.ABP.Terms
open import FOTC.Relation.Binary.Bisimilarity.Type
------------------------------------------------------------------------------
-- Main theorem.
abpCorrect : ∀ {b is os₁ os₂} → Bit b → Stream is → Fair os₁ → Fair os₂ →
is ≈ abpTransfer b os₁ os₂ is
abpCorrect {b} {is} {os₁} {os₂} Bb Sis Fos₁ Fos₂ = ≈-stronger-coind B h refl
where
B : D → D → Set
B xs ys = xs ≡ xs
h : B is (abpTransfer b os₁ os₂ is) →
∃[ i' ] ∃[ is' ] ∃[ js' ]
is ≡ i' ∷ is' ∧ abpTransfer b os₁ os₂ is ≡ i' ∷ js' ∧ B is' js'
h _ with Stream-out Sis
... | i' , is' , prf₁ , Sis' with lemma Bb Fos₁ Fos₂ prf₂
where
aux₁ aux₂ aux₃ aux₄ aux₅ : D
aux₁ = send b
aux₂ = ack b
aux₃ = out b
aux₄ = corrupt os₁
aux₅ = corrupt os₂
prf₂ : S b (i' ∷ is') os₁ os₂
(has aux₁ aux₂ aux₃ aux₄ aux₅ (i' ∷ is'))
(hbs aux₁ aux₂ aux₃ aux₄ aux₅ (i' ∷ is'))
(hcs aux₁ aux₂ aux₃ aux₄ aux₅ (i' ∷ is'))
(hds aux₁ aux₂ aux₃ aux₄ aux₅ (i' ∷ is'))
(abpTransfer b os₁ os₂ (i' ∷ is'))
prf₂ = has-eq aux₁ aux₂ aux₃ aux₄ aux₅ (i' ∷ is')
, hbs-eq aux₁ aux₂ aux₃ aux₄ aux₅ (i' ∷ is')
, hcs-eq aux₁ aux₂ aux₃ aux₄ aux₅ (i' ∷ is')
, hds-eq aux₁ aux₂ aux₃ aux₄ aux₅ (i' ∷ is')
, trans (abpTransfer-eq b os₁ os₂ (i' ∷ is'))
(transfer-eq aux₁ aux₂ aux₃ aux₄ aux₅ (i' ∷ is'))
... | js' , prf₃ = i'
, is'
, js'
, prf₁
, subst (λ t → abpTransfer b os₁ os₂ t ≡ i' ∷ js' )
(sym prf₁)
prf₃
, refl
------------------------------------------------------------------------------
-- abpTransfer produces a Stream.
abpTransfer-Stream : ∀ {b is os₁ os₂} →
Bit b →
Stream is →
Fair os₁ →
Fair os₂ →
Stream (abpTransfer b os₁ os₂ is)
abpTransfer-Stream Bb Sis Fos₁ Fos₂ = ≈→Stream₂ (abpCorrect Bb Sis Fos₁ Fos₂)
------------------------------------------------------------------------------
-- References
--
-- Dybjer, Peter and Sander, Herbert P. (1989). A Functional
-- Programming Approach to the Specification and Verification of
-- Concurrent Systems. Formal Aspects of Computing 1, pp. 303–319.
| {
"alphanum_fraction": 0.504857227,
"avg_line_length": 38.6022727273,
"ext": "agda",
"hexsha": "66e4a31c586e40715be0fedd57a96b723267b78b",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2018-03-14T08:50:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2016-09-19T14:18:30.000Z",
"max_forks_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "asr/fotc",
"max_forks_repo_path": "notes/FOT/FOTC/Program/ABP/StrongerInductionPrinciple/CorrectnessProofI.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_issues_repo_issues_event_max_datetime": "2017-01-01T14:34:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-10-12T17:28:16.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "asr/fotc",
"max_issues_repo_path": "notes/FOT/FOTC/Program/ABP/StrongerInductionPrinciple/CorrectnessProofI.agda",
"max_line_length": 78,
"max_stars_count": 11,
"max_stars_repo_head_hexsha": "2fc9f2b81052a2e0822669f02036c5750371b72d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/fotc",
"max_stars_repo_path": "notes/FOT/FOTC/Program/ABP/StrongerInductionPrinciple/CorrectnessProofI.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": 1025,
"size": 3397
} |
{-# OPTIONS --safe #-}
module Cubical.Categories.Instances.Rings where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Algebra.Ring
open import Cubical.Categories.Category
open Category
open RingHoms
RingsCategory : ∀ {ℓ} → Category (ℓ-suc ℓ) ℓ
ob RingsCategory = Ring _
Hom[_,_] RingsCategory = RingHom
id RingsCategory {R} = idRingHom R
_⋆_ RingsCategory = compRingHom
⋆IdL RingsCategory = compIdRingHom
⋆IdR RingsCategory = idCompRingHom
⋆Assoc RingsCategory = compAssocRingHom
isSetHom RingsCategory = isSetRingHom _ _
| {
"alphanum_fraction": 0.7665562914,
"avg_line_length": 26.2608695652,
"ext": "agda",
"hexsha": "f36e336bec572a6c269c787452220e9e92b789c9",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Seanpm2001-web/cubical",
"max_forks_repo_path": "Cubical/Categories/Instances/Rings.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58f2d0dd07e51f8aa5b348a522691097b6695d1c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Seanpm2001-web/cubical",
"max_issues_repo_path": "Cubical/Categories/Instances/Rings.agda",
"max_line_length": 47,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "9acdecfa6437ec455568be4e5ff04849cc2bc13b",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "FernandoLarrain/cubical",
"max_stars_repo_path": "Cubical/Categories/Instances/Rings.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-05T00:28:39.000Z",
"max_stars_repo_stars_event_min_datetime": "2022-03-05T00:28:39.000Z",
"num_tokens": 176,
"size": 604
} |
-- Algorithmic equality.
{-# OPTIONS --without-K --safe #-}
module Definition.Conversion where
open import Definition.Untyped
open import Definition.Typed
open import Tools.Nat
open import Tools.Product
import Tools.PropositionalEquality as PE
infix 10 _⊢_~_↑_
infix 10 _⊢_~_↓_
infix 10 _⊢_[conv↑]_
infix 10 _⊢_[conv↓]_
infix 10 _⊢_[conv↑]_∷_
infix 10 _⊢_[conv↓]_∷_
mutual
-- Neutral equality.
data _⊢_~_↑_ (Γ : Con Term) : (k l A : Term) → Set where
var-refl : ∀ {x y A}
→ Γ ⊢ var x ∷ A
→ x PE.≡ y
→ Γ ⊢ var x ~ var y ↑ A
app-cong : ∀ {k l t v F G}
→ Γ ⊢ k ~ l ↓ Π F ▹ G
→ Γ ⊢ t [conv↑] v ∷ F
→ Γ ⊢ k ∘ t ~ l ∘ v ↑ G [ t ]
fst-cong : ∀ {p r F G}
→ Γ ⊢ p ~ r ↓ Σ F ▹ G
→ Γ ⊢ fst p ~ fst r ↑ F
snd-cong : ∀ {p r F G}
→ Γ ⊢ p ~ r ↓ Σ F ▹ G
→ Γ ⊢ snd p ~ snd r ↑ G [ fst p ]
natrec-cong : ∀ {k l h g a₀ b₀ F G}
→ Γ ∙ ℕ ⊢ F [conv↑] G
→ Γ ⊢ a₀ [conv↑] b₀ ∷ F [ zero ]
→ Γ ⊢ h [conv↑] g ∷ Π ℕ ▹ (F ▹▹ F [ suc (var 0) ]↑)
→ Γ ⊢ k ~ l ↓ ℕ
→ Γ ⊢ natrec F a₀ h k ~ natrec G b₀ g l ↑ F [ k ]
Emptyrec-cong : ∀ {k l F G}
→ Γ ⊢ F [conv↑] G
→ Γ ⊢ k ~ l ↓ Empty
→ Γ ⊢ Emptyrec F k ~ Emptyrec G l ↑ F
-- Neutral equality with types in WHNF.
record _⊢_~_↓_ (Γ : Con Term) (k l B : Term) : Set where
inductive
constructor [~]
field
A : Term
D : Γ ⊢ A ⇒* B
whnfB : Whnf B
k~l : Γ ⊢ k ~ l ↑ A
-- Type equality.
record _⊢_[conv↑]_ (Γ : Con Term) (A B : Term) : Set where
inductive
constructor [↑]
field
A′ B′ : Term
D : Γ ⊢ A ⇒* A′
D′ : Γ ⊢ B ⇒* B′
whnfA′ : Whnf A′
whnfB′ : Whnf B′
A′<>B′ : Γ ⊢ A′ [conv↓] B′
-- Type equality with types in WHNF.
data _⊢_[conv↓]_ (Γ : Con Term) : (A B : Term) → Set where
U-refl : ⊢ Γ → Γ ⊢ U [conv↓] U
ℕ-refl : ⊢ Γ → Γ ⊢ ℕ [conv↓] ℕ
Empty-refl : ⊢ Γ → Γ ⊢ Empty [conv↓] Empty
Unit-refl : ⊢ Γ → Γ ⊢ Unit [conv↓] Unit
ne : ∀ {K L}
→ Γ ⊢ K ~ L ↓ U
→ Γ ⊢ K [conv↓] L
Π-cong : ∀ {F G H E}
→ Γ ⊢ F
→ Γ ⊢ F [conv↑] H
→ Γ ∙ F ⊢ G [conv↑] E
→ Γ ⊢ Π F ▹ G [conv↓] Π H ▹ E
Σ-cong : ∀ {F G H E}
→ Γ ⊢ F
→ Γ ⊢ F [conv↑] H
→ Γ ∙ F ⊢ G [conv↑] E
→ Γ ⊢ Σ F ▹ G [conv↓] Σ H ▹ E
-- Term equality.
record _⊢_[conv↑]_∷_ (Γ : Con Term) (t u A : Term) : Set where
inductive
constructor [↑]ₜ
field
B t′ u′ : Term
D : Γ ⊢ A ⇒* B
d : Γ ⊢ t ⇒* t′ ∷ B
d′ : Γ ⊢ u ⇒* u′ ∷ B
whnfB : Whnf B
whnft′ : Whnf t′
whnfu′ : Whnf u′
t<>u : Γ ⊢ t′ [conv↓] u′ ∷ B
-- Term equality with types and terms in WHNF.
data _⊢_[conv↓]_∷_ (Γ : Con Term) : (t u A : Term) → Set where
ℕ-ins : ∀ {k l}
→ Γ ⊢ k ~ l ↓ ℕ
→ Γ ⊢ k [conv↓] l ∷ ℕ
Empty-ins : ∀ {k l}
→ Γ ⊢ k ~ l ↓ Empty
→ Γ ⊢ k [conv↓] l ∷ Empty
Unit-ins : ∀ {k l}
→ Γ ⊢ k ~ l ↓ Unit
→ Γ ⊢ k [conv↓] l ∷ Unit
ne-ins : ∀ {k l M N}
→ Γ ⊢ k ∷ N
→ Γ ⊢ l ∷ N
→ Neutral N
→ Γ ⊢ k ~ l ↓ M
→ Γ ⊢ k [conv↓] l ∷ N
univ : ∀ {A B}
→ Γ ⊢ A ∷ U
→ Γ ⊢ B ∷ U
→ Γ ⊢ A [conv↓] B
→ Γ ⊢ A [conv↓] B ∷ U
zero-refl : ⊢ Γ → Γ ⊢ zero [conv↓] zero ∷ ℕ
suc-cong : ∀ {m n}
→ Γ ⊢ m [conv↑] n ∷ ℕ
→ Γ ⊢ suc m [conv↓] suc n ∷ ℕ
η-eq : ∀ {f g F G}
→ Γ ⊢ f ∷ Π F ▹ G
→ Γ ⊢ g ∷ Π F ▹ G
→ Function f
→ Function g
→ Γ ∙ F ⊢ wk1 f ∘ var 0 [conv↑] wk1 g ∘ var 0 ∷ G
→ Γ ⊢ f [conv↓] g ∷ Π F ▹ G
Σ-η : ∀ {p r F G}
→ Γ ⊢ p ∷ Σ F ▹ G
→ Γ ⊢ r ∷ Σ F ▹ G
→ Product p
→ Product r
→ Γ ⊢ fst p [conv↑] fst r ∷ F
→ Γ ⊢ snd p [conv↑] snd r ∷ G [ fst p ]
→ Γ ⊢ p [conv↓] r ∷ Σ F ▹ G
η-unit : ∀ {k l}
→ Γ ⊢ k ∷ Unit
→ Γ ⊢ l ∷ Unit
→ Whnf k
→ Whnf l
→ Γ ⊢ k [conv↓] l ∷ Unit
star-refl : ∀ {Γ} → ⊢ Γ → Γ ⊢ star [conv↓] star ∷ Unit
star-refl ⊢Γ = η-unit (starⱼ ⊢Γ) (starⱼ ⊢Γ) starₙ starₙ
| {
"alphanum_fraction": 0.3575976231,
"avg_line_length": 30.2051282051,
"ext": "agda",
"hexsha": "2d8b03698065950b4d9e15ef8ce4c2409732f126",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Vtec234/logrel-mltt",
"max_forks_repo_path": "Definition/Conversion.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Vtec234/logrel-mltt",
"max_issues_repo_path": "Definition/Conversion.agda",
"max_line_length": 69,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "4746894adb5b8edbddc8463904ee45c2e9b29b69",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Vtec234/logrel-mltt",
"max_stars_repo_path": "Definition/Conversion.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1891,
"size": 4712
} |
{-# OPTIONS --without-K #-}
open import HoTT
open import cohomology.Theory
{- Ordinary cohomology groups of the n-torus Tⁿ = (S¹)ⁿ.
- We have Cᵏ(Tⁿ) == C⁰(S⁰)^(n choose' k) where _choose'_ defined as below.
- This argument could give Cᵏ((Sᵐ)ⁿ) with a little more work. -}
module cohomology.Torus {i} (OT : OrdinaryTheory i) where
open OrdinaryTheory OT
open import cohomology.Sn OT
open import cohomology.SphereProduct cohomology-theory
open import cohomology.Unit cohomology-theory
{- Almost n choose k, but with n choose' O = 0 for any n. -}
_choose'_ : ℕ → ℤ → ℕ
n choose' negsucc _ = 0
n choose' pos O = 0
n choose' pos (S O) = n
O choose' pos (S (S k)) = 0
S n choose' pos (S (S k)) = (n choose' (pos (S (S k)))) + (n choose' (pos (S k)))
_-⊙Torus : ℕ → Ptd i
O -⊙Torus = ⊙Lift ⊙Unit
(S n) -⊙Torus = ⊙Lift {j = i} ⊙S¹ ⊙× (n -⊙Torus)
C-nTorus : (k : ℤ) (n : ℕ)
→ C k (n -⊙Torus) == C 0 (⊙Lift ⊙S⁰) ^ᴳ (n choose' k)
C-nTorus (negsucc k) O = C-Unit (negsucc k)
C-nTorus (negsucc k) (S n) =
C-Sphere× (negsucc k) 1 (n -⊙Torus)
∙ ap (λ K → K ×ᴳ (C (negsucc k) (n -⊙Torus)
×ᴳ C (negsucc k) (⊙Susp^ 1 (n -⊙Torus))))
(C-Sphere-≠ (negsucc k) 1 (ℤ-negsucc≠pos _ _))
∙ ×ᴳ-unit-l {G = C (negsucc k) (n -⊙Torus)
×ᴳ C (negsucc k) (⊙Susp (n -⊙Torus))}
∙ ap (λ K → K ×ᴳ C (negsucc k) (⊙Susp (n -⊙Torus)))
(C-nTorus (negsucc k) n)
∙ ×ᴳ-unit-l {G = C (negsucc k) (⊙Susp (n -⊙Torus))}
∙ group-ua (C-Susp (negsucc (S k)) (n -⊙Torus))
∙ C-nTorus (negsucc (S k)) n
C-nTorus (pos O) O = C-Unit (pos O)
C-nTorus (pos O) (S n) =
C-Sphere× (pos O) 1 (n -⊙Torus)
∙ ap (λ K → K ×ᴳ (C 0 (n -⊙Torus) ×ᴳ C 0 (⊙Susp (n -⊙Torus))))
(C-Sphere-≠ (pos O) 1 (pos-≠ (ℕ-O≠S _)))
∙ ×ᴳ-unit-l {G = C 0 (n -⊙Torus) ×ᴳ C 0 (⊙Susp (n -⊙Torus))}
∙ ap (λ K → K ×ᴳ C 0 (⊙Susp (n -⊙Torus)))
(C-nTorus 0 n)
∙ ×ᴳ-unit-l {G = C 0 (⊙Susp (n -⊙Torus))}
∙ group-ua (C-Susp (negsucc O) (n -⊙Torus))
∙ C-nTorus (negsucc O) n
C-nTorus (pos (S O)) O = C-Unit 1
C-nTorus (pos (S O)) (S n) =
C-Sphere× 1 1 (n -⊙Torus)
∙ ap (λ K → K ×ᴳ (C 1 (n -⊙Torus)
×ᴳ C 1 (⊙Susp (n -⊙Torus))))
(C-Sphere-diag 1)
∙ ap (λ K → C 0 (⊙Lift ⊙S⁰) ×ᴳ K)
(ap2 _×ᴳ_
(C-nTorus 1 n)
(group-ua (C-Susp 0 (n -⊙Torus)) ∙ C-nTorus 0 n)
∙ ×ᴳ-unit-r {G = C 0 (⊙Lift ⊙S⁰) ^ᴳ (n choose' 1)})
C-nTorus (pos (S (S k))) O =
C-Unit (pos (S (S k)))
C-nTorus (pos (S (S k))) (S n) =
C-Sphere× (pos (S (S k))) 1 (n -⊙Torus)
∙ ap (λ K → K ×ᴳ (C (pos (S (S k))) (n -⊙Torus)
×ᴳ C (pos (S (S k))) (⊙Susp (n -⊙Torus))))
(C-Sphere-≠ (pos (S (S k))) 1 (pos-≠ (ℕ-S-≠ (ℕ-S≠O k))))
∙ ×ᴳ-unit-l {G = (C (pos (S (S k))) (n -⊙Torus))
×ᴳ (C (pos (S (S k))) (⊙Susp (n -⊙Torus)))}
∙ ap2 _×ᴳ_ (C-nTorus (pos (S (S k))) n)
(group-ua (C-Susp (pos (S k)) (n -⊙Torus)) ∙ C-nTorus (pos (S k)) n)
∙ ^ᴳ-sum (C 0 (⊙Lift ⊙S⁰)) (n choose' pos (S (S k))) (n choose' pos (S k))
| {
"alphanum_fraction": 0.5038244097,
"avg_line_length": 34.1704545455,
"ext": "agda",
"hexsha": "ed1b50e21b6a8fd4cca392670cb6e0e46ea8fdb1",
"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/cohomology/Torus.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/cohomology/Torus.agda",
"max_line_length": 81,
"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/cohomology/Torus.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1535,
"size": 3007
} |
module Languages.ILL.TypeCheck where
open import bool
open import maybe
open import Languages.ILL.TypeSyntax
open import Languages.ILL.Syntax
open import Utils.HaskellTypes
open import Utils.HaskellFunctions
open import Utils.Exception
data StateT (s : Set) (m : Set → Set) (a : Set) : Set where
stateT : (s → m (Prod a s)) → StateT s m a
runStateT : ∀{s m a} → StateT s m a → (s → m (Prod a s))
runStateT (stateT f) = f
returnSTE : ∀{s A} → A → StateT s (Either Exception) A
returnSTE x = stateT (λ y → right (x , y))
infixl 20 _>>=STE_
_>>=STE_ : ∀{s A B} → StateT s (Either Exception) A → (A → StateT s (Either Exception) B) → StateT s (Either Exception) B
(stateT st) >>=STE f = stateT (λ y → st y >>=E (λ p → runStateT (f (fst p)) (snd p)))
infixl 20 _>>STE_
_>>STE_ : ∀{s A B} → StateT s (Either Exception) A → StateT s (Either Exception) B → StateT s (Either Exception) B
c₁ >>STE c₂ = c₁ >>=STE (λ _ → c₂)
throw : ∀{s A} → Exception → StateT s (Either Exception) A
throw x = stateT (λ _ → error x)
lift : ∀{s A} → Either Exception A → StateT s (Either Exception) A
lift (Left x) = stateT (λ _ → error x)
lift (Right x) = stateT (λ y → right (x , y))
get : ∀{S} → StateT S (Either Exception) S
get = stateT (λ x → right (x , x))
put : ∀{S} → S → StateT S (Either Exception) Unit
put s = stateT (λ x → Right (triv , s))
CTXEl : Set
CTXEl = Prod String Type
CTX : Set
CTX = List CTXEl
CTXV-eq : CTXEl → CTXEl → 𝔹
CTXV-eq (x , ty) (y , ty') = x str-eq y
TC : Set → Set
TC = StateT CTX (Either Exception)
_isDisjointWith_ : CTX → CTX → TC Unit
ctx₁ isDisjointWith ctx₂ with disjoint CTXV-eq ctx₁ ctx₂
... | tt = returnSTE triv
... | ff = throw TypeErrorDuplicatedFreeVar
getTypeCTX : String → CTX → maybe Type
getTypeCTX x ctx = lookup _str-eq_ x ctx
{-# TERMINATING #-}
subctxFV : CTX → Term → Either Exception CTX
subctxFV ctx Triv = right []
subctxFV ctx t@(FVar x) with getTypeCTX x ctx
... | just ty = right ((x , ty) :: [])
... | nothing = error VarNotInCtx
subctxFV ctx (BVar _ _ _) = right []
subctxFV ctx (Let t₁ _ _ t₂) =
(subctxFV ctx t₁) >>=E
(λ l₁ → (subctxFV ctx t₂) >>=E
λ l₂ → right (l₁ ++ l₂))
subctxFV ctx (Lam _ _ t) = subctxFV ctx t
subctxFV ctx (App t₁ t₂) =
(subctxFV ctx t₁) >>=E
(λ l₁ → (subctxFV ctx t₂) >>=E
λ l₂ → right (l₁ ++ l₂))
subctxFV ctx (Tensor t₁ t₂) =
(subctxFV ctx t₁) >>=E
(λ l₁ → (subctxFV ctx t₂) >>=E
λ l₂ → right (l₁ ++ l₂))
subctxFV ctx (Promote ms t) =
mctx₁ >>=E
(λ ctx₁ → (subctxFV ctx t) >>=E
(λ ctx₂ → right (ctx₁ ++ ctx₂)))
where
aux = (λ m r →
(subctxFV ctx (fstT m)) >>=E
(λ l₁ → r >>=E
(λ l₂ → right (l₁ ++ l₂))))
mctx₁ = foldr aux (right []) ms
subctxFV ctx (Discard t₁ t₂) =
(subctxFV ctx t₁) >>=E
(λ l₁ → (subctxFV ctx t₂) >>=E
λ l₂ → right (l₁ ++ l₂))
subctxFV ctx (Copy t₁ _ t₂) =
(subctxFV ctx t₁) >>=E
(λ l₁ → (subctxFV ctx t₂) >>=E
λ l₂ → right (l₁ ++ l₂))
subctxFV ctx (Derelict t) = subctxFV ctx t
isTop : Type → TC Type
isTop Top = returnSTE Top
isTop _ = throw TypeErrorLetNotTop
isTensor : Type → TC (Prod Type Type)
isTensor (Tensor x y) = returnSTE (x , y)
isTensor _ = throw TypeErrorLetNotTensor
isBang : Type → TC Type
isBang (Bang ty) = returnSTE ty
isBang _ = throw TypeErrorPromoteNotBang
isImp : Type → TC (Prod Type Type)
isImp (Imp A B) = returnSTE (A , B)
isImp _ = throw TypeErrorAppNotImp
_tyEq_ : Type → Type → TC Unit
_tyEq_ ty₁ ty₂ with ty₁ eq-type ty₂
... | tt = returnSTE triv
... | ff = throw TypeErrorTypesNotEqual
{-# TERMINATING #-}
typeCheck' : Term → TC Type
typeCheck' Triv = get >>=STE checkCTX
where
checkCTX : CTX → TC Type
checkCTX [] = returnSTE Top
checkCTX _ = throw NonEmptyCtx
typeCheck' (FVar x) = get >>=STE checkCtx
where
checkCtx : CTX → TC Type
checkCtx ((y , ty) :: []) with x str-eq y
... | tt = returnSTE ty
... | ff = throw VarNotInCtx
checkCtx _ = throw NonLinearCtx
typeCheck' (BVar _ _ _) = throw NonlocallyClosed
typeCheck' (Let t₁ ty PTriv t₂) =
get >>=STE
(λ ctx → lift (subctxFV ctx t₁) >>=STE
(λ ctx₁ → lift (subctxFV ctx t₂) >>=STE
λ ctx₂ → (ctx₁ isDisjointWith ctx₂) >>STE
((put ctx₁) >>STE typeCheck' t₁) >>=STE
(λ ty₁ → isTop ty₁ >>STE
(put ctx₂ >>STE typeCheck' t₂))))
typeCheck' (Let t₁ ty (PTensor x y) t₂) =
get >>=STE
(λ ctx → lift (subctxFV ctx t₁) >>=STE
(λ ctx₁ → lift (subctxFV ctx t₂) >>=STE
(λ ctx₂ → (ctx₁ isDisjointWith ctx₂) >>STE
((put ctx₁) >>STE
typeCheck' t₁) >>=STE
(λ ty₁ → (isTensor ty₁) >>=STE
(λ tys → let A = fst tys
B = snd tys
t₂' = open-t 0 y RLPV (FVar y) (open-t 0 x LLPV (FVar x) t₂)
in put ((x , A) :: (y , B) :: ctx₂) >>STE typeCheck' t₂')))))
typeCheck' (Lam x ty t) =
get >>=STE
(λ ctx → (put ((x , ty) :: ctx)) >>STE
typeCheck' (open-t 0 x BV (FVar x) t) >>=STE
(λ ty₂ → returnSTE (Imp ty ty₂)))
typeCheck' (App t₁ t₂) =
get >>=STE
(λ ctx → lift (subctxFV ctx t₁) >>=STE
(λ ctx₁ → lift (subctxFV ctx t₂) >>=STE
(λ ctx₂ → (ctx₁ isDisjointWith ctx₂) >>STE
(put ctx₁) >>STE (typeCheck' t₁) >>=STE
(λ ty₁ → isImp ty₁ >>=STE
(λ tys → (put ctx₂) >>STE (typeCheck' t₂) >>=STE
(λ ty₂ → ((fst tys) tyEq ty₂) >>STE returnSTE (snd tys)))))))
typeCheck' (Tensor t₁ t₂) =
get >>=STE
(λ ctx → lift (subctxFV ctx t₁) >>=STE
(λ ctx₁ → lift (subctxFV ctx t₂) >>=STE
(λ ctx₂ → (ctx₁ isDisjointWith ctx₂) >>STE
(put ctx₁) >>STE typeCheck' t₁ >>=STE
(λ ty₁ → (put ctx₂) >>STE typeCheck' t₂ >>=STE
(λ ty₂ → returnSTE (Tensor ty₁ ty₂))))))
typeCheck' (Promote ms t) =
put [] >>STE getSubctxs ms
>>=STE areDisjointCtxs
>>STE checkVectorOpenTerm ms t
>>=STE typeCheck'
>>=STE (λ ty → returnSTE (Bang ty))
where
getSubctxs : List (Triple Term String Type) → TC (List CTX)
getSubctxs ((triple t _ _) :: rest) =
get >>=STE
(λ ctx → (lift (subctxFV ctx t)) >>=STE
(λ ctx' → (getSubctxs rest) >>=STE
(λ r → returnSTE (ctx' :: r))))
getSubctxs l = returnSTE []
areDisjointCtxs : List CTX → TC Unit
areDisjointCtxs [] = returnSTE triv
areDisjointCtxs (ctx₁ :: rest) = aux ctx₁ rest >>STE areDisjointCtxs rest
where
aux : CTX → List CTX → TC Unit
aux ctx₁ (ctx₂ :: rest) = (ctx₁ isDisjointWith ctx₂) >>STE aux ctx₁ rest
aux _ [] = returnSTE triv
checkVectorTerm : Term → TC Type
checkVectorTerm t =
get >>=STE
(λ ctx → lift (subctxFV ctx t) >>=STE
(λ ctx₁ → (put ctx₁) >>STE
typeCheck' t))
checkVectorOpenTerm : List (Triple Term String Type) → Term → TC Term
checkVectorOpenTerm [] t = throw IllformedPromote
checkVectorOpenTerm (triple t₁ x₁ ty₁ :: rest) t =
get >>=STE
(λ ctx → checkVectorTerm t₁ >>=STE
(λ ty₁' → (isBang ty₁' >>STE (ty₁ tyEq ty₁')) >>STE
(put ((x₁ , ty₁) :: ctx) >>STE
((checkVectorOpenTerm rest t) >>=STE
(λ t' → returnSTE (open-t 0 x₁ PBV (FVar x₁) t'))))))
typeCheck' (Discard t₁ t₂) = get >>=STE
(λ ctx → lift (subctxFV ctx t₁) >>=STE
(λ ctx₁ → lift (subctxFV ctx t₂) >>=STE
(λ ctx₂ → (ctx₁ isDisjointWith ctx₂) >>STE
(put ctx₁) >>STE typeCheck' t₁
>>=STE isBang
>>STE (put ctx₂)
>>STE typeCheck' t₂)))
typeCheck' (Copy t₁ (x , y) t₂) =
get >>=STE
(λ ctx → lift (subctxFV ctx t₁) >>=STE
(λ ctx₁ → lift (subctxFV ctx t₂) >>=STE
(λ ctx₂ → (ctx₁ isDisjointWith ctx₂) >>STE
(put ctx₁) >>STE typeCheck' t₁ >>=STE
(λ ty₁ → isBang ty₁ >>STE
(put ((x , ty₁) :: (y , ty₁) :: ctx₂) >>STE typeCheck' t₂')))))
where
t₂' = open-t 0 y RCPV (FVar y) (open-t 0 x LCPV (FVar x) t₂)
typeCheck' (Derelict t) = typeCheck' t >>=STE isBang
typeCheck : Term → Either Exception Type
typeCheck t with runStateT (typeCheck' t) []
... | Left e = Left e
... | Right (ty , _) = right ty
| {
"alphanum_fraction": 0.5727682377,
"avg_line_length": 33.7901234568,
"ext": "agda",
"hexsha": "8eca4c7a89a2f7a8dbb763c1822a7f5193ec937a",
"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": "c83f5d8201362b26a749138f6dbff2dd509f85b1",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "heades/Agda-LLS",
"max_forks_repo_path": "Source/ALL/Languages/ILL/TypeCheck.agda",
"max_issues_count": 2,
"max_issues_repo_head_hexsha": "c83f5d8201362b26a749138f6dbff2dd509f85b1",
"max_issues_repo_issues_event_max_datetime": "2017-04-05T17:30:16.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-03-27T14:52:46.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "heades/Agda-LLS",
"max_issues_repo_path": "Source/ALL/Languages/ILL/TypeCheck.agda",
"max_line_length": 121,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "c83f5d8201362b26a749138f6dbff2dd509f85b1",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "heades/Agda-LLS",
"max_stars_repo_path": "Source/ALL/Languages/ILL/TypeCheck.agda",
"max_stars_repo_stars_event_max_datetime": "2019-08-02T23:41:23.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-04-09T20:53:53.000Z",
"num_tokens": 2941,
"size": 8211
} |
module Examples.Resolution where
open import Prelude
open import Implicits.Syntax
open import Implicits.Syntax.Type.Constructors
open import Implicits.WellTyped
open import Implicits.Substitutions
open import Extensions.ListFirst
open Rules
unit = 0
-- simple implicit resolution by implication
module ex₁ where
r : Type zero
r = ∀' (tp-weaken tnat ⇒ (TVar zero))
-- proof that the above type is a rule
r-isrule : IsRule r
r-isrule = ∀'-rule (rule (tp-weaken tnat) (TVar zero))
-- the context used
K = tnat ∷K nil
-- partial implicit resolution
-- as described by Oliveira et al
module ex₂ where
r : Type zero
r = (tnat ⇒ TC unit ⇒ TC unit)
-- proof that the above type is a rule
r-isrule : IsRule r
r-isrule = rule tnat (TC unit ⇒ TC unit)
K : Ktx 0 1
K = TC unit ∷K nil
-- higher order resolution
module ex₃ where
r : Type zero
r = ∀' ((TC unit ⇒ TVar zero) ⇒ (TVar zero ×' TVar zero))
r' : Type zero
r' = (TC unit ⇒ tnat) ⇒ (tnat ×' tnat)
r-isrule : IsRule r
r-isrule = ∀'-rule (rule (TC unit ⇒ TVar zero) (TVar zero ×' TVar zero))
r'-isrule : IsRule r'
r'-isrule = rule (TC unit ⇒ tnat) (tnat ×' tnat)
K : Ktx 0 1
K = (TC unit ⇒ tnat) ∷K nil
| {
"alphanum_fraction": 0.6605960265,
"avg_line_length": 21.9636363636,
"ext": "agda",
"hexsha": "dc4fc2ff361b1829073002cfcc4a413a5ee3d311",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "metaborg/ts.agda",
"max_forks_repo_path": "src/Examples/Resolution.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "metaborg/ts.agda",
"max_issues_repo_path": "src/Examples/Resolution.agda",
"max_line_length": 74,
"max_stars_count": 4,
"max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "metaborg/ts.agda",
"max_stars_repo_path": "src/Examples/Resolution.agda",
"max_stars_repo_stars_event_max_datetime": "2021-05-07T04:08:41.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-04-05T17:57:11.000Z",
"num_tokens": 405,
"size": 1208
} |
module foldr-monoid-foldl where
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; sym; trans; cong)
open Eq.≡-Reasoning
open import lists using (List; []; _∷_; [_]; [_,_]; [_,_,_]; foldr; IsMonoid)
open IsMonoid
open import foldl using (foldl)
postulate
-- 外延性の公理
extensionality : ∀ {A B : Set} {f g : A → B}
→ (∀ (x : A) → f x ≡ g x)
-----------------------
→ f ≡ g
-- foldr-monoidのfoldl版
-- _⊗_ と e がモノイドをなすとき、任意の値でfoldを再表現できる
foldl-monoid : ∀ {A : Set} → (_⊗_ : A → A → A) (e : A) → IsMonoid _⊗_ e
→ ∀ (xs : List A) (y : A) → foldl _⊗_ y xs ≡ y ⊗ (foldl _⊗_ e xs)
foldl-monoid _⊗_ e ⊗-monoid [] y =
begin
foldl _⊗_ y []
≡⟨⟩
y
≡⟨ sym (identityʳ ⊗-monoid y) ⟩
y ⊗ e
≡⟨⟩
y ⊗ (foldl _⊗_ e [])
∎
foldl-monoid _⊗_ e ⊗-monoid (x ∷ xs) y =
begin
foldl _⊗_ y (x ∷ xs)
≡⟨⟩
foldl _⊗_ (y ⊗ x) xs
≡⟨ foldl-monoid _⊗_ e ⊗-monoid xs (y ⊗ x) ⟩
(y ⊗ x) ⊗ (foldl _⊗_ e xs)
≡⟨ assoc ⊗-monoid y x (foldl _⊗_ e xs) ⟩
y ⊗ (x ⊗ (foldl _⊗_ e xs))
≡⟨ cong (y ⊗_) (sym (foldl-monoid _⊗_ e ⊗-monoid xs x)) ⟩
y ⊗ (foldl _⊗_ x xs)
≡⟨ cong (λ e⊗x → y ⊗ (foldl _⊗_ e⊗x xs)) (sym (identityˡ ⊗-monoid x)) ⟩
y ⊗ (foldl _⊗_ (e ⊗ x) xs)
≡⟨⟩
y ⊗ (foldl _⊗_ e (x ∷ xs))
∎
-- 外延性の公理を用いた証明のための補題
lemma : ∀ {A : Set} → (_⊗_ : A → A → A) (e : A) → IsMonoid _⊗_ e
→ ∀ (xs : List A) → foldr _⊗_ e xs ≡ foldl _⊗_ e xs
lemma _⊗_ e ⊗-monoid [] =
begin
foldr _⊗_ e []
≡⟨⟩
e
≡⟨⟩
foldl _⊗_ e []
∎
lemma _⊗_ e ⊗-monoid (x ∷ xs) =
begin
foldr _⊗_ e (x ∷ xs)
≡⟨⟩
x ⊗ (foldr _⊗_ e xs)
≡⟨ cong (x ⊗_) (lemma _⊗_ e ⊗-monoid xs) ⟩
x ⊗ (foldl _⊗_ e xs)
≡⟨ sym (foldl-monoid _⊗_ e ⊗-monoid xs x) ⟩
foldl _⊗_ x xs
≡⟨ cong (λ e⊗x → foldl _⊗_ e⊗x xs) (sym (identityˡ ⊗-monoid x)) ⟩
foldl _⊗_ (e ⊗ x) xs
≡⟨⟩
foldl _⊗_ e (x ∷ xs)
∎
-- _⊗_ と e がモノイドをなすとき、foldrとfoldlが等しくなることの証明
foldr-monoid-foldl : ∀ {A : Set} → (_⊗_ : A → A → A) (e : A) → IsMonoid _⊗_ e
→ foldr _⊗_ e ≡ foldl _⊗_ e
foldr-monoid-foldl _⊗_ e ⊗-monoid = extensionality (lemma _⊗_ e ⊗-monoid)
| {
"alphanum_fraction": 0.514175877,
"avg_line_length": 26.3417721519,
"ext": "agda",
"hexsha": "e0e7bfe265eaefab7238e2c496186578f5b288bb",
"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": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "akiomik/plfa-solutions",
"max_forks_repo_path": "part1/lists/foldr-monoid-foldl.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547",
"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": "akiomik/plfa-solutions",
"max_issues_repo_path": "part1/lists/foldr-monoid-foldl.agda",
"max_line_length": 77,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "df7722b88a9b3dfde320a690b78c4c1ef8c7c547",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "akiomik/plfa-solutions",
"max_stars_repo_path": "part1/lists/foldr-monoid-foldl.agda",
"max_stars_repo_stars_event_max_datetime": "2020-07-07T09:42:22.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-07-07T09:42:22.000Z",
"num_tokens": 1193,
"size": 2081
} |
module Human.Empty where
data Empty : Set where
void : ∀ {P : Set} → Empty → P
void ()
| {
"alphanum_fraction": 0.6292134831,
"avg_line_length": 12.7142857143,
"ext": "agda",
"hexsha": "a090a7abc08b6a64533178b760242aa36a0bf993",
"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": "b509eb4c4014605facfb4ee5c807cd07753d4477",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "MaisaMilena/JuiceMaker",
"max_forks_repo_path": "src/Human/Empty.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477",
"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": "MaisaMilena/JuiceMaker",
"max_issues_repo_path": "src/Human/Empty.agda",
"max_line_length": 30,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "b509eb4c4014605facfb4ee5c807cd07753d4477",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "MaisaMilena/JuiceMaker",
"max_stars_repo_path": "src/Human/Empty.agda",
"max_stars_repo_stars_event_max_datetime": "2020-11-28T05:46:27.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-03-29T17:35:20.000Z",
"num_tokens": 26,
"size": 89
} |