Search is not available for this dataset
text
string | meta
dict |
---|---|
{-# OPTIONS --without-K #-}
module WithoutK7 where
data I : Set where
i : I
data D (x : I) : Set where
d : D x
data P (x : I) : D x → Set where
Foo : ∀ x → P x (d {x = x}) → Set
Foo x ()
| {
"alphanum_fraction": 0.5153061224,
"avg_line_length": 13.0666666667,
"ext": "agda",
"hexsha": "3a20e1cae8827f4cbbdc429d3a633a9ffaa9d708",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "np/agda-git-experiment",
"max_forks_repo_path": "test/fail/WithoutK7.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "np/agda-git-experiment",
"max_issues_repo_path": "test/fail/WithoutK7.agda",
"max_line_length": 33,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "np/agda-git-experiment",
"max_stars_repo_path": "test/fail/WithoutK7.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": 74,
"size": 196
} |
module Issue249-2 where
postulate
A B : Set
module A where
X = A
Y = B
-- open A renaming (X to C; Y to C)
open A using (X) renaming (Y to X)
| {
"alphanum_fraction": 0.614379085,
"avg_line_length": 10.9285714286,
"ext": "agda",
"hexsha": "e0c62ef50f8287370a0eaaacc5d1756d30e40675",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue249-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/Fail/Issue249-2.agda",
"max_line_length": 35,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue249-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": 56,
"size": 153
} |
open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl)
open import Data.Fin using (Fin)
open import Data.Nat using (ℕ)
open import Data.Product using (_×_; _,_)
open import Data.Vec using (Vec; lookup; _[_]≔_)
open import Common
data Local (n : ℕ) : Set where
endL : Local n
sendSingle recvSingle : Fin n -> Label -> Local n -> Local n
private
variable
n : ℕ
p p′ q : Fin n
l l′ : Label
lSub lSub′ : Local n
endL≢sendSingle : ∀ { lSub } -> endL {n} ≢ sendSingle q l lSub
endL≢sendSingle ()
endL≢recvSingle : ∀ { lSub } -> endL {n} ≢ recvSingle q l lSub
endL≢recvSingle ()
sendSingle-injective :
sendSingle {n} p l lSub ≡ sendSingle p′ l′ lSub′
-> p ≡ p′ × l ≡ l′ × lSub ≡ lSub′
sendSingle-injective refl = refl , refl , refl
recvSingle-injective :
recvSingle {n} p l lSub ≡ recvSingle p′ l′ lSub′
-> p ≡ p′ × l ≡ l′ × lSub ≡ lSub′
recvSingle-injective refl = refl , refl , refl
Configuration : ℕ -> Set
Configuration n = Vec (Local n) n
data _-_→l_ {n : ℕ} : (Fin n × Local n) -> Action n -> (Fin n × Local n) -> Set where
→l-send :
∀ { lp lpSub }
-> (p : Fin n)
-> lp ≡ sendSingle q l lpSub
-> (p≢q : p ≢ q)
-> (p , lp) - (action p q p≢q l) →l (p , lpSub)
→l-recv :
∀ { lp lpSub }
-> (p : Fin n)
-> lp ≡ recvSingle q l lpSub
-> (q≢p : q ≢ p)
-> (p , lp) - (action q p q≢p l) →l (p , lpSub)
data _-_→c_ {n : ℕ} : Configuration n -> Action n -> Configuration n -> Set where
→c-comm :
∀ { lp lp′ lq lq′ c′ p≢q-p p≢q-q }
-> (c : Configuration n)
-> (p≢q : p ≢ q)
-> lp ≡ lookup c p
-> lq ≡ lookup c q
-> c′ ≡ c [ p ]≔ lp′ [ q ]≔ lq′
-> (p , lp) - (action p q p≢q-p l) →l (p , lp′)
-> (q , lq) - (action p q p≢q-q l) →l (q , lq′)
-> c - (action p q p≢q l) →c c′
| {
"alphanum_fraction": 0.5475264036,
"avg_line_length": 28.109375,
"ext": "agda",
"hexsha": "ef9e873dfb78a911d1adc52aa60bac6ded7ffd17",
"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": "3d12eed9d340207d242d70f43c6b34e01d3620de",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "fangyi-zhou/mpst-in-agda",
"max_forks_repo_path": "Local.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "3d12eed9d340207d242d70f43c6b34e01d3620de",
"max_issues_repo_issues_event_max_datetime": "2021-11-24T11:30:17.000Z",
"max_issues_repo_issues_event_min_datetime": "2021-08-31T10:15:38.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "fangyi-zhou/mpst-in-agda",
"max_issues_repo_path": "Local.agda",
"max_line_length": 85,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "3d12eed9d340207d242d70f43c6b34e01d3620de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "fangyi-zhou/mpst-in-agda",
"max_stars_repo_path": "Local.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-14T17:36:53.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-08-14T17:36:53.000Z",
"num_tokens": 716,
"size": 1799
} |
module Test where
open import Algebra using (CommutativeRing; IsCommutativeRing)
open import Assume using (assume)
import Data.Nat as ℕ
open ℕ using (ℕ; zero; suc)
import Data.Fin as F
open F using (Fin)
open import Relation.Binary using (Rel; Setoid; _Preserves_⟶_)
open import Function using (Inverse; _on_; _∘_; _|>_; id; flip)
open import Algebra.Module using (Module)
module Mod = Module
open import Data.Product using (_,_; proj₂; _×_)
open import Algebra.Module.Construct.DirectProduct using () renaming (⟨module⟩ to ×-module)
open import Level using (_⊔_; Level; 0ℓ; Lift)
open import Data.Vec.Recursive
open import Algebra.Module.Vec.Recursive
module _
{r ℓ} {CR : CommutativeRing r ℓ}
where
-- D B k is the solution to
-- (A → X) → A ^ suc k → B
-- i.e. D B k ~ A ^ k → B
open Module
D : ∀ {m ℓm} (M : Module CR m ℓm) → ℕ → Set _
D {m = m} M k = ∀ {X : Set m} → X ^ suc k → Carrierᴹ M
const
: ∀ {m ℓm} {{M : Module CR m ℓm}}
→ ∀ {k} → Carrierᴹ M → D M k
const {k = zero} c x = c
const {{M}} {k = suc k} c v = 0ᴹ M
double
: ∀ {m ℓm} {{M : Module CR m ℓm}}
→ ∀ {k} → D M k → D M k
double {{M}} x y = let x' = x y in _+ᴹ_ M x' x'
-- D : Level → ∀ {n ℓn} (N : Module CR n ℓn) → ℕ → Set _
-- D m N k = {M : Set m} → M → M ^ k → Carrierᴹ N
-- compose
-- : ∀ {x} {X : Set x}
-- → ∀ {n ℓn} {N : Module CR n ℓn}
-- → ∀ {o ℓo} {O : Module CR o ℓo}
-- → ∀ {k} → (f : X → D N k) → (g : Carrierᴹ N → D O k)
-- → X → D O k
-- compose = ?
-- _th-derivative_ : ∀ k → (D k → D k) → M.Carrierᴹ → N.Carrierᴹ
-- k th-derivative f = {! !}
-- TODO
-- can we use M → D N k everywhere?!
-- data D : ℕ → Set (m ⊔ n) where
-- z : N.Carrierᴹ → D zero
-- d : ∀ {k} → (fx : N.Carrierᴹ) → (dfx : M.Carrierᴹ → D k) → D (suc k)
-- module _
-- {r ℓ} {CR : CommutativeRing r ℓ}
-- {m ℓm} {M : Module CR m ℓm}
-- {n ℓn} {N : Module CR n ℓn}
-- where
-- private
-- module CR = CommutativeRing CR
-- module M = Module M
-- module N = Module N
-- private
-- module dmod where
-- Carrierᴹ : ∀ {k : ℕ} → Set (m ⊔ n)
-- Carrierᴹ {k} = D M N k
-- _≈ᴹ_ : ∀ {k} → Rel (D M N k) (m ⊔ ℓn)
-- _≈ᴹ_ (z x) (z y) = Lift (m ⊔ ℓn) (x N.≈ᴹ y)
-- _≈ᴹ_ (d fx dfx) (d fy dfy) = (fx N.≈ᴹ fy) × (∀ v → dfx v ≈ᴹ dfy v)
-- _+ᴹ_ : ∀ {k} → (x y : D M N k) → D M N k
-- _+ᴹ_ (z x) (z y) = z (x N.+ᴹ y)
-- _+ᴹ_ (d fx dfx) (d fy dfy) = d (fx N.+ᴹ fy) λ v → dfx v +ᴹ dfy v
-- _*ₗ_ : ∀ {k} → (s : CR.Carrier) (x : D M N k) → D M N k
-- _*ₗ_ s (z x) = z (s N.*ₗ x)
-- _*ₗ_ s (d fx dfx) = d (s N.*ₗ fx) λ v → s *ₗ dfx v
-- _*ᵣ_ : ∀ {k} → (x : D M N k) (s : CR.Carrier) → D M N k
-- _*ᵣ_ = flip _*ₗ_
-- 0ᴹ : ∀ {k} → D M N k
-- 0ᴹ {zero} = z N.0ᴹ
-- 0ᴹ {suc k} = d N.0ᴹ λ v → 0ᴹ
-- -ᴹ_ : ∀ {k} → D M N k → D M N k
-- -ᴹ_ (z x) = z (N.-ᴹ x)
-- -ᴹ_ (d fx dfx) = d (N.-ᴹ fx) λ v → -ᴹ dfx v
-- instance
-- D-module : ∀ {k : ℕ} → Module CR _ _
-- D-module {k} =
-- record
-- { Carrierᴹ = dmod.Carrierᴹ {k}
-- ; isModule = assume
-- ; dmod
-- }
-- private variable k : ℕ
-- run : D M N k → N.Carrierᴹ
-- run (z x) = x
-- run (d x _) = x
-- extract : D M N zero → N.Carrierᴹ
-- extract = run
-- diff : M.Carrierᴹ → D M N (suc k) → D M N k
-- diff v (d _ x) = x v
-- konst _# : ∀ (c : N.Carrierᴹ) → D M N k
-- konst {k = zero} c = z c
-- konst {k = suc k} c = d c (λ v → konst N.0ᴹ)
-- x # = konst x
-- jacobian : (df : D M N 1) (v : M.Carrierᴹ) → N.Carrierᴹ
-- jacobian df v = df |> diff v |> extract
-- hessian : (df : D M N 2) (v v' : M.Carrierᴹ) → N.Carrierᴹ
-- hessian df v v' = df |> diff v |> diff v' |> extract
-- hack : ∀ {l} → D M N (suc l) → D M N l
-- hack {zero} (d fx dfx) = z fx
-- hack {suc l} (d fx dfx) = d fx λ v → hack {l} (dfx v)
module _ where
import Real as ℝ
open ℝ using (ℝ)
open import Data.Vec.Recursive
ℝ-isCommutativeRing : IsCommutativeRing ℝ._≈_ ℝ._+_ ℝ._*_ ℝ.-_ 0.0 1.0
ℝ-isCommutativeRing = assume
instance
ℝ-commutativeRing : CommutativeRing 0ℓ 0ℓ
ℝ-commutativeRing = record { isCommutativeRing = ℝ-isCommutativeRing }
ℝ-cr : CommutativeRing 0ℓ 0ℓ
ℝ-cr = ℝ-commutativeRing
private
ℝ-mod' : Module ℝ-commutativeRing 0ℓ 0ℓ
ℝ-mod' = U.⟨module⟩
where import Algebra.Module.Construct.TensorUnit as U
ℝ^ : ∀ n → Module ℝ-commutativeRing 0ℓ 0ℓ
ℝ^ n = ℝ-mod' ^ᴹ n
ℝ-mod : Module ℝ-commutativeRing 0ℓ 0ℓ
ℝ-mod = ℝ^ 1
exp : ∀ {k} → D ℝ-mod k → D ℝ-mod k
exp {0} f x = ℝ.e^ f x
exp {1} f' xdx = let (fx , f'x) = f xdx in {! (ℝ.e^ fx) ℝ.* f'x !}
exp {k} f y = {! !}
-- -- TODO
-- -- is this really the identity?
-- var : ∀ {rank k} (c : Mod.Carrierᴹ (ℝ^ rank)) → D (ℝ^ rank) (ℝ^ rank) k
-- var {rank} {zero} c = z c
-- var {rank} {suc n} c = d c (λ v → konst (replicate rank 1.0))
-- instance
-- ℝ^n : ∀ {n} → Module ℝ-cr 0ℓ 0ℓ
-- ℝ^n {n} = ℝ^ n
-- infixl 6 _+_ _-_
-- infixl 7 _*_
-- -- linear and bilinear forms
-- _*_
-- : ∀ {m ℓm} {M : Module ℝ-cr m ℓm} {k rank}
-- → (x y : D M (ℝ^ rank) k)
-- → D M (ℝ^ rank) k
-- open Module {{...}}
-- _+_ _-_
-- : ∀ {r ℓ} {CR : CommutativeRing r ℓ} {m ℓm} {{M : Module CR m ℓm}} (x y : Mod.Carrierᴹ M)
-- → Mod.Carrierᴹ M
-- x + y = x +ᴹ y
-- x - y = x +ᴹ (-ᴹ y)
-- _*_ {rank = rank} (z x) (z y) = z (zipWith ℝ._*_ rank x y)
-- _*_ {rank = rank} dfx@(d fx f'x) dgx@(d gx g'x) =
-- d (zipWith ℝ._*_ rank fx gx) (λ v → hack dfx * g'x v + hack dgx * f'x v)
-- -- convenience function
-- _>-<_
-- : ∀ {k}
-- → (f : ℝ → ℝ) (f' : ∀ {l} → D ℝ-mod ℝ-mod l → D ℝ-mod ℝ-mod l)
-- → D ℝ-mod ℝ-mod k → D ℝ-mod ℝ-mod k
-- (f >-< _) (z x) = z (f x)
-- (f >-< f') dfx@(d x dx) = d (f x) λ v → dx v * f' (hack dfx)
-- ε : ∀ {rank} → Fin rank → ℝ ^ rank
-- ε {zero} n = _
-- ε {suc zero} _ = 1.0
-- ε {2+ rank} F.zero = 1.0 , Mod.0ᴹ (ℝ^ (suc rank))
-- ε {2+ rank} (F.suc n) = Mod.0ᴹ ℝ-mod , ε n
-- ∇_ grad : ∀ {rank} → D (ℝ^ rank) (ℝ^ 1) 1 → ℝ ^ rank
-- ∇_ {rank = rank} f = map (jacobian f) rank unitvecs
-- where
-- unitvecs : (ℝ ^ rank) ^ rank
-- unitvecs = map ε rank (tabulate rank id)
-- grad = ∇_
-- infixl 8 _**_
-- infixr 9 -_
-- infixr 9 e^_
-- -_
-- : ∀ {r ℓ} {CR : CommutativeRing r ℓ} {m ℓm} {{M : Module CR m ℓm}} (x : Mod.Carrierᴹ M)
-- → Mod.Carrierᴹ M
-- -_ x = -ᴹ x
-- ℝ-sgn : ℝ → ℝ
-- ℝ-sgn x = if does (0.0 ℝ.≤? x) then 1.0 else ℝ.- 1.0
-- where
-- open import Data.Bool using (if_then_else_)
-- open import Relation.Nullary using (does)
-- ℝ-abs : ℝ → ℝ
-- ℝ-abs x = x ℝ.* ℝ-sgn x
-- -- the first is the zero-order
-- poly : ∀ {rank k} → ℝ ^ suc rank → D ℝ-mod ℝ-mod k → D ℝ-mod ℝ-mod k
-- poly {rank = zero} cs x = konst cs
-- poly {rank = suc rank} (c , cs) x = konst c + x * poly cs x
-- pow : ℕ → ∀ {k} → D ℝ-mod ℝ-mod k → D ℝ-mod ℝ-mod k
-- pow 0 x = konst 1.0
-- pow 1 x = x
-- pow (suc n) dx = dx * pow n dx
-- log e^_ recip abs sgn : ∀ {k} → D ℝ-mod ℝ-mod k → D ℝ-mod ℝ-mod k
-- log = ℝ.log >-< recip ∘ abs
-- recip (z x) = z (1.0 ℝ.÷ x)
-- recip dfx@(d fx f'x) = d (1.0 ℝ.÷ fx) λ x → - (f'x x * tmp * tmp)
-- where
-- tmp = recip (hack dfx)
-- abs = ℝ-abs >-< sgn
-- sgn = ℝ-sgn >-< λ _ → 0ᴹ
-- e^ z x = z (ℝ.e^ x)
-- e^ dfx@(d fx f'x) = d (run tmp) λ v → f'x v * tmp
-- where
-- tmp = e^ hack dfx
-- infixl 7 _÷_
-- _÷_ _**_ : ∀ {k} (x y : D ℝ-mod ℝ-mod k) → D ℝ-mod ℝ-mod k
-- x ÷ y = x * recip x
-- x ** y = e^ y * log x
-- _! : ℕ → ℕ
-- 0 ! = 1
-- 1 ! = 1
-- sucn@(suc n) ! = sucn ℕ.* (n !)
-- sterling : ∀ {k} → ℕ → D ℝ-mod ℝ-mod k
-- sterling {k} m = m' * log m' - m'
-- where
-- m' : D ℝ-mod ℝ-mod k
-- m' = ℝ.fromℕ m #
-- -- without the constant denominator term
-- logPoisson' : ∀ {n} → ℕ → D ℝ-mod ℝ-mod n → D ℝ-mod ℝ-mod n
-- logPoisson' k λ' = k' * log λ' - λ'
-- where k' = ℝ.fromℕ k #
-- logPoisson : ∀ {n} → ℕ → D ℝ-mod ℝ-mod n → D ℝ-mod ℝ-mod n
-- logPoisson k λ' = logPoisson' k λ' - sterling k
-- -- descend : ∀ {rank} (f : D (ℝ^ rank) 1 → D ℝ-mod 1) (steps : ℕ) (start : ℝ ^ rank) → ℝ ^ rank
-- -- descend f zero start = start
-- -- descend f (suc steps) start = {! !}
-- module _ where
-- open import Relation.Binary.PropositionalEquality using (refl)
-- _ : (∇ (var 1.0 * var 1.0)) ℝ.≈ 2.0
-- _ = refl
-- -- -- -- _ : run e^_ 2.0 ℝ.≈ (ℝ.e^ 2.0)
-- -- -- -- _ = refl
-- -- -- -- testpoly : ∀ {n} → D ℝ-mod n → D ℝ-mod n
-- -- -- -- testpoly = poly (1.0 , 2.0 , 3.0)
-- -- -- -- _ : run testpoly 2.0 ℝ.≈ (1.0 + 4.0 + 12.0)
-- -- -- -- _ = refl
-- -- -- -- _ : ∇ testpoly [ 2.0 ] ℝ.≈ (0.0 + 2.0 + 3.0 ℝ.* 2.0 ℝ.* 2.0)
-- -- -- -- _ = refl
-- -- -- -- _ : ∇ testpoly [ 7.0 ] ℝ.≈ (0.0 + 2.0 + 2.0 ℝ.* 3.0 ℝ.* 7.0)
-- -- -- -- _ = refl
-- -- -- -- _ : hessian e^_ 1.0 1.0 0.0 ℝ.≈ (ℝ.e^ 1.0)
-- -- -- -- _ = refl
-- -- -- -- asdf : D ℝ-mod 2
-- -- -- -- asdf = e^ var (2.0 , 1.0 , 0.0)
-- -- -- -- _ : hessian (poly (1.0 , 2.0 , 3.0)) 1.0 1.0 0.0 ℝ.≈ (2.0 ℝ.* 3.0)
-- -- -- -- _ = refl
-- -- -- -- _ : ∇ log [ 1.0 ] ℝ.≈ 1.0
-- -- -- -- _ = refl
-- -- -- -- _ : ∇ log [ -ᴹ 1.0 ] ℝ.≈ 1.0
-- -- -- -- _ = refl
-- -- -- -- _ : ∇ sgn [ 2.0 ] ℝ.≈ 0.0
-- -- -- -- _ = refl
-- -- -- -- _ : ∇ abs [ 2.0 ] ℝ.≈ 1.0
-- -- -- -- _ = refl
-- -- -- -- _ : run abs (- 2.0) ℝ.≈ 2.0
-- -- -- -- _ = refl
-- -- -- -- _ : ∇ abs [ - 1.0 ] ℝ.≈ (- 1.0)
-- -- -- -- _ = refl
-- -- -- -- _ : ∇ recip [ - 2.0 ] ℝ.≈ (- 0.25)
-- -- -- -- _ = refl
-- -- -- -- _ : ∇ log [ 2.0 ] ℝ.≈ 0.5
-- -- -- -- _ = refl | {
"alphanum_fraction": 0.4570149557,
"avg_line_length": 26.0716180371,
"ext": "agda",
"hexsha": "1a2a09e996b976d19aa195b12d74b2e4573290f1",
"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": "78c3dec24834ffeca5e74cb75578e9b210a5be62",
"max_forks_repo_licenses": [
"CC0-1.0"
],
"max_forks_repo_name": "cspollard/diff",
"max_forks_repo_path": "src/Test.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "78c3dec24834ffeca5e74cb75578e9b210a5be62",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"CC0-1.0"
],
"max_issues_repo_name": "cspollard/diff",
"max_issues_repo_path": "src/Test.agda",
"max_line_length": 100,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "78c3dec24834ffeca5e74cb75578e9b210a5be62",
"max_stars_repo_licenses": [
"CC0-1.0"
],
"max_stars_repo_name": "cspollard/diff",
"max_stars_repo_path": "src/Test.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4499,
"size": 9829
} |
{-# OPTIONS --without-K #-}
open import HoTT
open import cohomology.CofiberSequence
open import cohomology.FunctionOver
module cohomology.MayerVietoris {i} where
{- Mayer-Vietoris Sequence: Given a span X ←f– Z –g→ Y, the cofiber space
of the natural map [reglue : X ∨ Y → X ⊔_Z Y] (defined below) is equivalent
to the suspension of Z. -}
{- Relevant functions -}
module MayerVietorisFunctions (ps : ⊙Span {i} {i} {i}) where
open ⊙Span ps
module Reglue = WedgeRec
{X = ⊙Span.X ps} {Y = ⊙Span.Y ps} {C = fst (⊙Pushout ps)}
left right (! (ap left (snd f)) ∙ glue (snd Z) ∙' ap right (snd g))
reglue : X ∨ Y → fst (⊙Pushout ps)
reglue = Reglue.f
⊙reglue : fst (X ⊙∨ Y ⊙→ ⊙Pushout ps)
⊙reglue = (reglue , idp)
module MVDiff = SuspensionRec (fst Z) {C = Suspension (X ∨ Y)}
(north _)
(north _)
(λ z → merid _ (winl (fst f z)) ∙ ! (merid _ (winr (fst g z))))
mv-diff : Suspension (fst Z) → Suspension (X ∨ Y)
mv-diff = MVDiff.f
⊙mv-diff : fst (⊙Susp Z ⊙→ ⊙Susp (X ⊙∨ Y))
⊙mv-diff = (mv-diff , idp)
{- We use path induction (via [⊙pushout-J]) to assume that the
basepoint preservation paths of the span maps are [idp]. The module
[Base] contains the proof of the theorem for this case. -}
module MayerVietorisBase
{A B : Type i} (Z : Ptd i) (f : fst Z → A) (g : fst Z → B) where
X = ⊙[ A , f (snd Z) ]
Y = ⊙[ B , g (snd Z) ]
ps = ⊙span X Y Z (f , idp) (g , idp)
F : fst (Z ⊙→ X)
F = (f , idp)
G : fst (Z ⊙→ Y)
G = (g , idp)
open MayerVietorisFunctions ps
{- Definition of the maps
into : Cofiber reglue → ΣZ
out : ΣZ → Cofiber reglue
-}
private
into-glue-square :
Square idp idp (ap (ext-glue ∘ reglue) wglue) (merid _ (snd Z))
into-glue-square =
connection ⊡v∙
! (ap-∘ ext-glue reglue wglue ∙ ap (ap ext-glue) Reglue.glue-β
∙ ExtGlue.glue-β (snd Z))
module IntoGlue = WedgeElim {P = λ xy → north _ == ext-glue (reglue xy)}
(λ _ → idp)
(λ _ → merid _ (snd Z))
(↓-cst=app-from-square into-glue-square)
into-glue = IntoGlue.f
module Into = CofiberRec reglue (north _) ext-glue into-glue
private
out-glue-and-square : (z : fst Z)
→ Σ (cfbase reglue == cfbase reglue)
(λ p → Square (cfglue _ (winl (f z))) p
(ap (cfcod _) (glue z)) (cfglue _ (winr (g z))))
out-glue-and-square z = fill-square-top _ _ _
out-glue = fst ∘ out-glue-and-square
out-square = snd ∘ out-glue-and-square
module Out = SuspensionRec (fst Z) {C = Cofiber reglue}
(cfbase _)
(cfbase _)
out-glue
into = Into.f
out = Out.f
{- [out] is a right inverse for [into] -}
private
into-out-sq : (z : fst Z) →
Square idp (ap into (ap out (merid _ z))) (merid _ z) (merid _ (snd Z))
into-out-sq z =
(ap (ap into) (Out.glue-β z) ∙v⊡
(! (Into.glue-β (winl (f z)))) ∙h⊡
ap-square into (out-square z)
⊡h∙ (Into.glue-β (winr (g z))))
⊡v∙ (∘-ap into (cfcod _) (glue z) ∙ ExtGlue.glue-β z)
into-out : ∀ σ → into (out σ) == σ
into-out = Suspension-elim (fst Z)
idp
(merid _ (snd Z))
(λ z → ↓-∘=idf-from-square into out (into-out-sq z))
{- [out] is a left inverse for [into] -}
{- [out] is left inverse on codomain part of cofiber space,
- i.e. [out (into (cfcod _ γ)) == cfcod _ γ] -}
private
out-into-cod-square : (z : fst Z) →
Square (cfglue reglue (winl (f z)))
(ap (out ∘ ext-glue {s = ⊙span-out ps}) (glue z))
(ap (cfcod _) (glue z)) (cfglue _ (winr (g z)))
out-into-cod-square z =
(ap-∘ out ext-glue (glue z)
∙ ap (ap out) (ExtGlue.glue-β z) ∙ Out.glue-β z)
∙v⊡ out-square z
module OutIntoCod = PushoutElim
{d = ⊙span-out ps} {P = λ γ → out (into (cfcod _ γ)) == cfcod _ γ}
(λ x → cfglue _ (winl x))
(λ y → cfglue _ (winr y))
(λ z → ↓-='-from-square (out-into-cod-square z))
out-into-cod = OutIntoCod.f
{- Cube move lemma for the left inverse coherence. This is used to
build up a right square (in this case starting from a cube filler) -}
private
square-push-rb : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A} {b : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : a₁₀ == b}
(q : b == a₁₁) (sq : Square p₀₋ p₋₀ p₋₁ (p₁₋ ∙ q))
→ Square p₀₋ p₋₀ (p₋₁ ∙' ! q) p₁₋
square-push-rb {p₁₋ = idp} idp sq = sq
right-from-bot-lemma : ∀ {i} {A : Type i}
{a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ a₀₀₁ a₀₁₁ a₁₀₁ a₁₁₁ b₀ b₁ : A}
{p₀₋₀ : a₀₀₀ == a₀₁₀} {p₋₀₀ : a₀₀₀ == a₁₀₀}
{p₋₁₀ : a₀₁₀ == a₁₁₀} {p₁₋₀ : a₁₀₀ == a₁₁₀}
{sq₋₋₀ : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀} -- left
{p₀₋₁ : a₀₀₁ == a₀₁₁} {p₋₀₁ : a₀₀₁ == a₁₀₁}
{p₋₁₁ : a₀₁₁ == a₁₁₁} {p₁₋₁ : a₁₀₁ == a₁₁₁}
(sq₋₋₁ : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁) -- right
{p₀₀₋ : a₀₀₀ == a₀₀₁} {p₀₁₋ : a₀₁₀ == b₀}
{p₁₀₋ : a₁₀₀ == a₁₀₁} {p₁₁₋ : a₁₁₀ == b₁}
{q₀₋ : a₀₁₁ == b₀} {q₋₁ : b₀ == b₁} {q₁₋ : a₁₁₁ == b₁}
{sq₀₋₋ : Square p₀₋₀ p₀₀₋ p₀₁₋ (p₀₋₁ ∙ q₀₋)} -- back
{sq₋₀₋ : Square p₋₀₀ p₀₀₋ p₁₀₋ p₋₀₁} -- top
{sq₋₁₋ : Square p₋₁₀ p₀₁₋ p₁₁₋ q₋₁} -- bottom
{sq₁₋₋ : Square p₁₋₀ p₁₀₋ p₁₁₋ (p₁₋₁ ∙ q₁₋)} -- front
(sq' : Square q₀₋ p₋₁₁ q₋₁ q₁₋)
(cu : Cube sq₋₋₀ sq₋₋₁ (square-push-rb q₀₋ sq₀₋₋)
sq₋₀₋ (sq₋₁₋ ⊡h' !□h (square-symmetry sq'))
(square-push-rb q₁₋ sq₁₋₋))
→ Cube sq₋₋₀ (sq₋₋₁ ⊡v sq') sq₀₋₋ sq₋₀₋ sq₋₁₋ sq₁₋₋
right-from-bot-lemma sq₋₋₁ ids cu = right-from-bot-lemma' sq₋₋₁ cu
where
right-from-bot-lemma' : ∀ {i} {A : Type i}
{a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ a₀₀₁ a₀₁₁ a₁₀₁ a₁₁₁ : A}
{p₀₋₀ : a₀₀₀ == a₀₁₀} {p₋₀₀ : a₀₀₀ == a₁₀₀}
{p₋₁₀ : a₀₁₀ == a₁₁₀} {p₁₋₀ : a₁₀₀ == a₁₁₀}
{sq₋₋₀ : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀} -- left
{p₀₋₁ : a₀₀₁ == a₀₁₁} {p₋₀₁ : a₀₀₁ == a₁₀₁}
{p₋₁₁ : a₀₁₁ == a₁₁₁} {p₁₋₁ : a₁₀₁ == a₁₁₁}
(sq₋₋₁ : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁) -- right
{p₀₀₋ : a₀₀₀ == a₀₀₁} {p₀₁₋ : a₀₁₀ == a₀₁₁}
{p₁₀₋ : a₁₀₀ == a₁₀₁} {p₁₁₋ : a₁₁₀ == a₁₁₁}
{sq₀₋₋ : Square p₀₋₀ p₀₀₋ p₀₁₋ (p₀₋₁ ∙ idp)} -- back
{sq₋₀₋ : Square p₋₀₀ p₀₀₋ p₁₀₋ p₋₀₁} -- top
{sq₋₁₋ : Square p₋₁₀ p₀₁₋ p₁₁₋ p₋₁₁} -- bottom
{sq₁₋₋ : Square p₁₋₀ p₁₀₋ p₁₁₋ (p₁₋₁ ∙ idp)} -- front
(cu : Cube sq₋₋₀ sq₋₋₁ (square-push-rb idp sq₀₋₋) sq₋₀₋
(sq₋₁₋ ⊡h' !□h (square-symmetry vid-square))
(square-push-rb idp sq₁₋₋))
→ Cube sq₋₋₀ (sq₋₋₁ ⊡v vid-square) sq₀₋₋ sq₋₀₋ sq₋₁₋ sq₁₋₋
right-from-bot-lemma' ids cu = cu
{- Proving the coherence term for the left inverse. This means proving
[(w : X ∨ Y) → Square idp (ap out (ap into (glue w)))
(cfglue _ w) (out-into-cod (reglue w))]
-}
private
out-into-sql : (x : fst X) → Square idp (ap out (into-glue (winl x)))
(cfglue _ (winl x)) (cfglue _ (winl x))
out-into-sql x = connection
out-into-fill : Σ (Square idp (ap out (glue (snd Z))) idp idp) (λ sq →
Cube (out-into-sql (snd X)) sq
(natural-square (λ _ → idp) wglue)
(natural-square (ap out ∘ into-glue) wglue)
(natural-square (cfglue _) wglue
⊡h' !□h (square-symmetry connection))
(square-push-rb (cfglue _ (winr (snd Y)))
(natural-square (out-into-cod ∘ reglue) wglue)))
out-into-fill = fill-cube-right _ _ _ _ _
{- [fst out-into-fill] is chosen so that we can prove
[out-into-sql == out-into-sqr [ ⋯ ↓ ⋯ ]];
this is proven by massaging [out-into-fill-cube] into the right shape.
The trick is that the type of [out-into-fill-square] is independent of
[y], so we can pick it to give the right result at the basepoint.
-}
out-into-sqr : (y : fst Y)
→ Square idp (ap out (into-glue (winr y)))
(cfglue _ (winr y)) (cfglue _ (winr y))
out-into-sqr y = fst out-into-fill ⊡v connection
out-into : ∀ κ → out (into κ) == κ
out-into = Cofiber-elim reglue
idp out-into-cod
(λ w → ↓-∘=idf-from-square out into $
ap (ap out) (Into.glue-β w) ∙v⊡
Wedge-elim
{P = λ w → Square idp (ap out (into-glue w))
(cfglue _ w) (out-into-cod (reglue w))}
out-into-sql
out-into-sqr
(cube-to-↓-square $
right-from-bot-lemma (fst out-into-fill) connection $
(snd out-into-fill))
w)
{- equivalence and paths -}
eq : Cofiber reglue ≃ Suspension (fst Z)
eq = equiv into out into-out out-into
path : Cofiber reglue == Suspension (fst Z)
path = ua eq
⊙path : ⊙Cof ⊙reglue == ⊙Susp Z
⊙path = ⊙ua eq idp
{- Transporting [cfcod reglue] over the equivalence -}
cfcod-over : ⊙cfcod ⊙reglue == ⊙ext-glue
[ (λ W → fst (⊙Pushout ps ⊙→ W)) ↓ ⊙path ]
cfcod-over =
codomain-over-⊙equiv (⊙cfcod ⊙reglue) eq idp ▹ lemma
where
lemma : (into , idp) ⊙∘ ⊙cfcod ⊙reglue == ⊙ext-glue
lemma = pair= idp $
ap into (! (cfglue reglue (winl (snd X)))) ∙ idp
=⟨ ap-! into (cfglue reglue (winl (snd X))) |in-ctx (λ w → w ∙ idp) ⟩
! (ap into (cfglue reglue (winl (snd X)))) ∙ idp
=⟨ Into.glue-β (winl (snd X)) |in-ctx (λ w → ! w ∙ idp) ⟩
idp ∎
{- Transporting [ext-glue] over the equivalence. Uses the same sort of
- cube technique as in the proof of [⊙path]. -}
private
square-push-rt : ∀ {i} {A : Type i} {a₀₀ a₀₁ a₁₀ a₁₁ : A} {b : A}
{p₀₋ : a₀₀ == a₀₁} {p₋₀ : a₀₀ == a₁₀} {p₋₁ : a₀₁ == a₁₁} {p₁₋ : b == a₁₁}
(q : a₁₀ == b) (sq : Square p₀₋ p₋₀ p₋₁ (q ∙' p₁₋))
→ Square p₀₋ (p₋₀ ∙' q) p₋₁ p₁₋
square-push-rt {p₁₋ = idp} idp sq = sq
right-from-top-lemma : ∀ {i} {A : Type i}
{a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ a₀₀₁ a₀₁₁ a₁₀₁ a₁₁₁ b₀ b₁ : A}
{p₀₋₀ : a₀₀₀ == a₀₁₀} {p₋₀₀ : a₀₀₀ == a₁₀₀}
{p₋₁₀ : a₀₁₀ == a₁₁₀} {p₁₋₀ : a₁₀₀ == a₁₁₀}
{sq₋₋₀ : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀} -- left
{p₀₋₁ : a₀₀₁ == a₀₁₁} {p₋₀₁ : a₀₀₁ == a₁₀₁}
{p₋₁₁ : a₀₁₁ == a₁₁₁} {p₁₋₁ : a₁₀₁ == a₁₁₁}
(sq₋₋₁ : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁) -- right
{p₀₀₋ : a₀₀₀ == b₀ {-a₀₀₁-}} {p₀₁₋ : a₀₁₀ == a₀₁₁}
{p₁₀₋ : a₁₀₀ == b₁ {-a₁₀₁-}} {p₁₁₋ : a₁₁₀ == a₁₁₁}
{q₀₋ : b₀ == a₀₀₁} {q₋₀ : b₀ == b₁} {q₁₋ : b₁ == a₁₀₁}
{sq₀₋₋ : Square p₀₋₀ p₀₀₋ p₀₁₋ (q₀₋ ∙' p₀₋₁)} -- back
{sq₋₀₋ : Square p₋₀₀ p₀₀₋ p₁₀₋ q₋₀} -- top
{sq₋₁₋ : Square p₋₁₀ p₀₁₋ p₁₁₋ p₋₁₁} -- bottom
{sq₁₋₋ : Square p₁₋₀ p₁₀₋ p₁₁₋ (q₁₋ ∙' p₁₋₁)} -- front
(sq' : Square q₀₋ q₋₀ p₋₀₁ q₁₋)
(cu : Cube sq₋₋₀ sq₋₋₁ (square-push-rt q₀₋ sq₀₋₋)
(sq₋₀₋ ⊡h' square-symmetry sq') sq₋₁₋
(square-push-rt q₁₋ sq₁₋₋))
→ Cube sq₋₋₀ (sq' ⊡v' sq₋₋₁) sq₀₋₋ sq₋₀₋ sq₋₁₋ sq₁₋₋
right-from-top-lemma sq₋₋₁ ids cu = right-from-top-lemma' sq₋₋₁ cu
where
right-from-top-lemma' : ∀ {i} {A : Type i}
{a₀₀₀ a₀₁₀ a₁₀₀ a₁₁₀ a₀₀₁ a₀₁₁ a₁₀₁ a₁₁₁ : A}
{p₀₋₀ : a₀₀₀ == a₀₁₀} {p₋₀₀ : a₀₀₀ == a₁₀₀}
{p₋₁₀ : a₀₁₀ == a₁₁₀} {p₁₋₀ : a₁₀₀ == a₁₁₀}
{sq₋₋₀ : Square p₀₋₀ p₋₀₀ p₋₁₀ p₁₋₀} -- left
{p₀₋₁ : a₀₀₁ == a₀₁₁} {p₋₀₁ : a₀₀₁ == a₁₀₁}
{p₋₁₁ : a₀₁₁ == a₁₁₁} {p₁₋₁ : a₁₀₁ == a₁₁₁}
(sq₋₋₁ : Square p₀₋₁ p₋₀₁ p₋₁₁ p₁₋₁) -- right
{p₀₀₋ : a₀₀₀ == a₀₀₁} {p₀₁₋ : a₀₁₀ == a₀₁₁}
{p₁₀₋ : a₁₀₀ == a₁₀₁} {p₁₁₋ : a₁₁₀ == a₁₁₁}
{sq₀₋₋ : Square p₀₋₀ p₀₀₋ p₀₁₋ (idp ∙' p₀₋₁)} -- back
{sq₋₀₋ : Square p₋₀₀ p₀₀₋ p₁₀₋ p₋₀₁} -- top
{sq₋₁₋ : Square p₋₁₀ p₀₁₋ p₁₁₋ p₋₁₁} -- bottom
{sq₁₋₋ : Square p₁₋₀ p₁₀₋ p₁₁₋ (idp ∙' p₁₋₁)} -- front
(cu : Cube sq₋₋₀ sq₋₋₁ (square-push-rt idp sq₀₋₋)
(sq₋₀₋ ⊡h' square-symmetry vid-square) sq₋₁₋
(square-push-rt idp sq₁₋₋))
→ Cube sq₋₋₀ (vid-square ⊡v' sq₋₋₁) sq₀₋₋ sq₋₀₋ sq₋₁₋ sq₁₋₋
right-from-top-lemma' ids cu = cu
ext-over : ⊙ext-glue == ⊙mv-diff
[ (λ W → fst (W ⊙→ ⊙Susp (X ⊙∨ Y))) ↓ ⊙path ]
ext-over = ⊙λ= fn-lemma idp ◃ domain-over-⊙equiv ⊙mv-diff _ _
where
fn-lemma : ∀ κ → ext-glue κ == mv-diff (into κ)
fn-lemma = Cofiber-elim reglue
idp fn-cod
(λ w → ↓-='-from-square $
ExtGlue.glue-β w ∙v⊡
fn-coh w
⊡v∙ ! (ap-∘ mv-diff into (glue w) ∙ ap (ap mv-diff) (Into.glue-β w)))
where
fn-cod : (γ : fst (⊙Pushout ps))
→ ext-glue (cfcod reglue γ) == mv-diff (ext-glue γ)
fn-cod = Pushout-elim
(λ x → ! (merid _ (winl x)))
(λ y → ! (merid _ (winr y)))
(λ z → ↓-='-from-square $
ap-cst (south _) (glue z) ∙v⊡
(bl-square (merid _ (winl (f z))) ⊡h connection)
⊡v∙ ! (ap-∘ mv-diff ext-glue (glue z)
∙ ap (ap mv-diff) (ExtGlue.glue-β z)
∙ MVDiff.glue-β z))
fn-fill : Σ (Square idp idp (ap mv-diff (merid _ (snd Z))) idp)
(λ sq → Cube (tr-square (merid _ (winl (snd X)))) sq
(natural-square (λ _ → idp) wglue)
(natural-square (merid _) wglue
⊡h' square-symmetry (tr-square (merid _ (winr (snd Y)))))
(natural-square (ap mv-diff ∘ into-glue) wglue)
(square-push-rt (! (merid _ (winr (snd Y))))
(natural-square (fn-cod ∘ reglue) wglue)))
fn-fill = fill-cube-right _ _ _ _ _
fn-coh : (w : X ∨ Y)
→ Square idp (merid _ w) (ap mv-diff (into-glue w)) (fn-cod (reglue w))
fn-coh = Wedge-elim
(λ x → tr-square (merid _ (winl x)))
(λ y → tr-square (merid _ (winr y)) ⊡v' (fst fn-fill))
(cube-to-↓-square $ right-from-top-lemma
(fst fn-fill)
(tr-square (merid _ (winr (snd Y))))
(snd fn-fill))
{- Main results -}
module MayerVietoris (ps : ⊙Span {i} {i} {i}) where
private
record Results (ps : ⊙Span {i} {i} {i}) : Type (lsucc i) where
open ⊙Span ps
open MayerVietorisFunctions ps public
field
eq : Cofiber reglue ≃ Suspension (fst Z)
path : Cofiber reglue == Suspension (fst Z)
⊙path : ⊙Cof ⊙reglue == ⊙Susp Z
cfcod-over : ⊙cfcod ⊙reglue == ⊙ext-glue
[ (λ W → fst (⊙Pushout ps ⊙→ W)) ↓ ⊙path ]
ext-over : ⊙ext-glue == ⊙mv-diff
[ (λ W → fst (W ⊙→ ⊙Susp (X ⊙∨ Y))) ↓ ⊙path ]
results : Results ps
results = ⊙pushout-J Results base-results ps
where
base-results : ∀ {A} {B} Z (f : fst Z → A) (g : fst Z → B) →
Results (⊙span _ _ Z (f , idp) (g , idp))
base-results Z f g = record {
eq = eq;
path = path;
⊙path = ⊙path;
cfcod-over = cfcod-over;
ext-over = ext-over}
where open MayerVietorisBase Z f g
open Results results public
| {
"alphanum_fraction": 0.5126044756,
"avg_line_length": 37.4646464646,
"ext": "agda",
"hexsha": "c847806fc9e583328e2fb0e4cf429a1929e359db",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "danbornside/HoTT-Agda",
"max_forks_repo_path": "cohomology/MayerVietoris.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "danbornside/HoTT-Agda",
"max_issues_repo_path": "cohomology/MayerVietoris.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "1695a7f3dc60177457855ae846bbd86fcd96983e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "danbornside/HoTT-Agda",
"max_stars_repo_path": "cohomology/MayerVietoris.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 6626,
"size": 14836
} |
module Id1 where
import Level
open import Data.Empty using (⊥)
open import Data.Unit using (⊤)
open import Data.Bool using (Bool)
open import Data.Sum using (_⊎_)
open import Data.Nat
open import Data.Product
open import Data.Vec
open import Function using (id)
-- Study identity types from first principles
-- As we have seen for the previous types, we need to define the type,
-- its constructors, and then focus on the recursion and induction
-- principles. All computations and all properties of the identity
-- type should be derivable from these (recursion and induction)
-- principles.
------------------------------------------------------------------------------
data _≡_ {A : Set} : (x y : A) → Set where
refl : (x : A) → x ≡ x
-- We have to write (refl x) for some x. This is different from the
-- Agda library which leaves the 'x' implicit
infix 4 _≡_
{--
Convention:
multiplicative precedence 7
additive precedence 6
equality and comparison precedence 4
--}
-- Simple examples
private
p₁ : 3 ≡ 3
p₁ = refl 3
p₂ : 3 * 1 ≡ 1 + 2
p₂ = refl (4 ∸ 1)
-- Let's try to derive the recursion principle for identity
-- types... This type has one constructor just like ⊤ in some sense.
-- Recall the recursion principle for ⊤:
-- rec⊤ : (C : Set) → C → (v : ⊤) → C
-- So at first approximation, the recursion principle for ≡ looks like:
--
-- rec≡ : (C : Set) → C → ({A : Set} {x y : A} (p : x ≡ y) → C)
--
-- In the case of ⊤, we wanted to map the element of ⊤ to an element
-- of C. For ≡, we also want to map the element of (x ≡ y) to an
-- element of C. Note that the element of (x ≡ y) is some kind of
-- relation between x and y so it makes sense to insist that the
-- target C is also a relation between x and y, i.e., we map relations
-- to relations.
-- So as a second approximation, the recursion principle for ≡ looks like:
--
-- rec≡ : {A : Set} {x y : A} →
-- (R : A → A → Set) → R x y → (p : x ≡ y) → R x y
--
-- In the case of ⊤, the second argument to the recursion operation
-- specified an element of C which would serve as the target for
-- tt. Now in the case of ≡, we want to specify an element of R x y
-- which would be the target of refl. This requires two adjustments:
-- first the second argument of type (R x y) makes no sense in general
-- as we don't want to insist that the relation R is universal (i.e.,
-- holds between arbitrary x and y). Second we must insist that the
-- relation R is reflexive.
rec≡ : {A : Set} →
(R : A → A → Set) {reflexiveR : {a : A} → R a a} →
({x y : A} (p : x ≡ y) → R x y)
rec≡ R {reflR} (refl y) = reflR {y}
-- A special case of reflexive relations on A is the class of
-- functions from C a -> C a for some predicate C. Let's specialize
-- the above recursion principle to this special case.
rec≡S : {A : Set} {C : A → Set} →
({x y : A} (p : x ≡ y) → C x → C y)
rec≡S {C = C} p = rec≡ (λ a b → C a → C b) {id} p
-- Or we can prove the specialized version directly (rename to subst)
subst : {A : Set} {C : A → Set} →
({x y : A} (p : x ≡ y) → C x → C y)
subst {x = x} {y = .x} (refl .x) = id
-- So the recursion principle for the identity type says
-- equals may be substituted for equals OR
-- indiscernability of identicals OR
-- every type family respects equality
-- Examples:
private
ex₁ : ∀ {n} → (p : n + 0 ≡ n) → (n + 0 > 0) → (n > 0)
ex₁ {n} p = subst {C = λ m → m > 0} {n + 0} {n} p
ex₂ : ∀ {A n} → (p : n + 0 ≡ n) → (Vec A (n + 0)) → (Vec A n)
ex₂ {A} {n} p = subst {C = λ m → Vec A m} {n + 0} {n} p
{--
From Data.Nat library:
data _≤_ : Rel ℕ Level.zero where
z≤n : ∀ {n} → zero ≤ n
s≤s : ∀ {m n} (m≤n : m ≤ n) → suc m ≤ suc n
--}
≤-reflexive : {a : ℕ} → a ≤ a
≤-reflexive {zero} = z≤n
≤-reflexive {suc a} = s≤s (≤-reflexive {a})
ex₃ : ∀ {n} → (p : n + 0 ≡ n) → (n + 0 ≤ n)
ex₃ {n} = rec≡ {ℕ} (_≤_) {≤-reflexive} {n + 0} {n}
------------------------------------------------------------------------------
-- Now let's look at the induction principle for identity types
-- Our usual idiom is to use the same code for the recursion principle
-- and just make the eliminator a dependent function
-- Let's look at rec≡ again
-- rec≡ : {A : Set} →
-- (R : A → A → Set) {reflexiveR : {a : A} → R a a} →
-- ({x y : A} (p : x ≡ y) → R x y)
-- rec≡ R {reflR} (refl y) = reflR {y}
-- The relation R is already dependent on x and y; we just need to
-- make it dependent on p too
ind≡ : {A : Set} →
(R : (x : A) → (y : A) → (p : x ≡ y) → Set)
{reflexiveR : {a : A} → R a a (refl a)} →
({x y : A} (p : x ≡ y) → R x y p)
ind≡ R {reflR} (refl y) = reflR {y}
-- Changing some implicit argument to being explicit and vice-versa,
-- and changing names of bound variables we get:
J : {A : Set} →
(R : {x y : A} → (p : x ≡ y) → Set)
(r : (a : A) → R (refl a)) →
({a b : A} (p : a ≡ b) → R p)
J R r (refl y) = r y
-- Examples
sym : {A : Set} {x y : A} → (x ≡ y) → (y ≡ x)
sym = J (λ {x} {y} p → y ≡ x) (λ a → refl a)
-- Next we want to prove:
-- trans : {A : Set} {x y z : A} → (x ≡ y) → (y ≡ z) → (x ≡ z)
-- if we try to directly use J we discover that the definition of R
-- (λ {x} {y} p → y ≡ z → x ≡ z)
-- refers to an unbound z
trans' : {A : Set} {x y : A} → (x ≡ y) → ((z : A) → (q : y ≡ z) → (x ≡ z))
trans' {A} =
J (λ {x} {y} p → ((z : A) → (q : y ≡ z) → (x ≡ z)))
(λ a z → id)
-- then
trans : {A : Set} {x y z : A} → (x ≡ y) → (y ≡ z) → (x ≡ z)
trans {A} {x} {y} {z} p q = trans' {A} {x} {y} p z q
-- trans' refl q will simplify to q because we did induction on the first argument
idR : {A : Set} {x y : A} (q : x ≡ y) → trans (refl x) q ≡ q
idR q = refl q
-- but trans' p refl will NOT simplify
-- idL : {A : Set} {x y : A} (p : x ≡ y) → trans p (refl y) ≡ p
-- idL p = refl p -- does not work
-- We can do induction on the right and get the reverse situation
-- OR we can do induction twice and lose BOTH and ONLY get
-- trans refl refl = refl
-- Even though this seems "worse", it is symmetric at least and easy to work is.
trans2' : {A : Set} {x y : A} → (x ≡ y) → ((z : A) → (q : y ≡ z) → (x ≡ z))
trans2' {A} =
J (λ {x} {y} p → ((z : A) → (q : y ≡ z) → (x ≡ z)))
(λ a z → J (λ {x'} {y'} q → x' ≡ y') (λ b → refl b))
trans2 : {A : Set} {x y z : A} → (x ≡ y) → (y ≡ z) → (x ≡ z)
trans2 {A} {x} {y} {z} p q = trans2' {A} {x} {y} p z q
idLR : {A : Set} {a : A} → trans2 (refl a) (refl a) ≡ refl a
idLR {A} {a} = refl (refl a)
------------------------------------------------------------------------------
-- If we restrict ourselves to proofs about "points" like numbers,
-- booleans, etc. all we are saying is that if we normalize the
-- calculation for each point they each reduce to same identical
-- result. Things get much more interesting if we start thinking about
-- identity in higher universes... So for example, say we want to
-- prove that groups are the same, in that case we might have to prove
-- that two types are the same etc. Unfortunately J by itself is
-- helpless here... This motivates the univalence axiom to be discussed next...
------------------------------------------------------------------------------
| {
"alphanum_fraction": 0.5464812009,
"avg_line_length": 32.7072072072,
"ext": "agda",
"hexsha": "9ef58ff62d135584dbc2c014adcc7955085ff25e",
"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": "b05c58ffdaed99932ca2acc632deca8d14742b04",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "andmkent/misc-HoTT",
"max_forks_repo_path": "Id1.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04",
"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": "andmkent/misc-HoTT",
"max_issues_repo_path": "Id1.agda",
"max_line_length": 82,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "b05c58ffdaed99932ca2acc632deca8d14742b04",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "andmkent/misc-HoTT",
"max_stars_repo_path": "Id1.agda",
"max_stars_repo_stars_event_max_datetime": "2016-01-26T18:17:16.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-01-26T18:17:16.000Z",
"num_tokens": 2543,
"size": 7261
} |
module automaton where
open import Data.Nat
open import Data.List
open import Relation.Binary.PropositionalEquality hiding ( [_] )
open import logic
record Automaton ( Q : Set ) ( Σ : Set )
: Set where
field
δ : Q → Σ → Q
aend : Q → Bool
open Automaton
accept : { Q : Set } { Σ : Set }
→ Automaton Q Σ
→ Q
→ List Σ → Bool
accept M q [] = aend M q
accept M q ( H ∷ T ) = accept M ( δ M q H ) T
moves : { Q : Set } { Σ : Set }
→ Automaton Q Σ
→ Q → List Σ → Q
moves M q [] = q
moves M q ( H ∷ T ) = moves M ( δ M q H) T
trace : { Q : Set } { Σ : Set }
→ Automaton Q Σ
→ Q → List Σ → List Q
trace {Q} { Σ} M q [] = q ∷ []
trace {Q} { Σ} M q ( H ∷ T ) = q ∷ trace M ( (δ M) q H ) T
reachable : { Q : Set } { Σ : Set }
→ (M : Automaton Q Σ )
→ (astart q : Q )
→ (L : List Σ ) → Set
reachable M astart q L = moves M astart L ≡ q
| {
"alphanum_fraction": 0.5010893246,
"avg_line_length": 22.3902439024,
"ext": "agda",
"hexsha": "8d0cee92d3dfdb6a69a27cb6f29c04be71b20bff",
"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": "eba0538f088f3d0c0fedb19c47c081954fbc69cb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "shinji-kono/automaton-in-agda",
"max_forks_repo_path": "src/automaton.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb",
"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": "shinji-kono/automaton-in-agda",
"max_issues_repo_path": "src/automaton.agda",
"max_line_length": 64,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "eba0538f088f3d0c0fedb19c47c081954fbc69cb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "shinji-kono/automaton-in-agda",
"max_stars_repo_path": "src/automaton.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 359,
"size": 918
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- All library modules, along with short descriptions
------------------------------------------------------------------------
-- Note that core modules are not included.
module Everything where
-- Definitions of algebraic structures like monoids and rings
-- (packed in records together with sets, operations, etc.)
open import Algebra
-- Solver for equations in commutative monoids
open import Algebra.CommutativeMonoidSolver
-- An example of how Algebra.CommutativeMonoidSolver can be used
open import Algebra.CommutativeMonoidSolver.Example
-- Properties of functions, such as associativity and commutativity
open import Algebra.FunctionProperties
-- Relations between properties of functions, such as associativity and
-- commutativity
open import Algebra.FunctionProperties.Consequences
-- Solver for equations in commutative monoids
open import Algebra.IdempotentCommutativeMonoidSolver
-- An example of how Algebra.IdempotentCommutativeMonoidSolver can be
-- used
open import Algebra.IdempotentCommutativeMonoidSolver.Example
-- Solver for monoid equalities
open import Algebra.Monoid-solver
-- Morphisms between algebraic structures
open import Algebra.Morphism
-- Some defined operations (multiplication by natural number and
-- exponentiation)
open import Algebra.Operations
-- Some derivable properties
open import Algebra.Properties.AbelianGroup
-- Some derivable properties
open import Algebra.Properties.BooleanAlgebra
-- Boolean algebra expressions
open import Algebra.Properties.BooleanAlgebra.Expression
-- Some derivable properties
open import Algebra.Properties.DistributiveLattice
-- Some derivable properties
open import Algebra.Properties.Group
-- Some derivable properties
open import Algebra.Properties.Lattice
-- Some derivable properties
open import Algebra.Properties.Ring
-- Solver for commutative ring or semiring equalities
open import Algebra.RingSolver
-- Commutative semirings with some additional structure ("almost"
-- commutative rings), used by the ring solver
open import Algebra.RingSolver.AlmostCommutativeRing
-- Some boring lemmas used by the ring solver
open import Algebra.RingSolver.Lemmas
-- Instantiates the ring solver, using the natural numbers as the
-- coefficient "ring"
open import Algebra.RingSolver.Natural-coefficients
-- Instantiates the ring solver with two copies of the same ring with
-- decidable equality
open import Algebra.RingSolver.Simple
-- Some algebraic structures (not packed up with sets, operations,
-- etc.)
open import Algebra.Structures
-- Applicative functors
open import Category.Applicative
-- Indexed applicative functors
open import Category.Applicative.Indexed
-- Applicative functors on indexed sets (predicates)
open import Category.Applicative.Predicate
-- Functors
open import Category.Functor
-- The identity functor
open import Category.Functor.Identity
-- Functors on indexed sets (predicates)
open import Category.Functor.Predicate
-- Monads
open import Category.Monad
-- A delimited continuation monad
open import Category.Monad.Continuation
-- The identity monad
open import Category.Monad.Identity
-- Indexed monads
open import Category.Monad.Indexed
-- The partiality monad
open import Category.Monad.Partiality
-- An All predicate for the partiality monad
open import Category.Monad.Partiality.All
-- Monads on indexed sets (predicates)
open import Category.Monad.Predicate
-- The state monad
open import Category.Monad.State
-- Basic types related to coinduction
open import Coinduction
-- AVL trees
open import Data.AVL
-- Types and functions which are used to keep track of height
-- invariants in AVL Trees
open import Data.AVL.Height
-- Indexed AVL trees
open import Data.AVL.Indexed
-- Finite maps with indexed keys and values, based on AVL trees
open import Data.AVL.IndexedMap
-- Keys for AVL trees
-- The key type extended with a new minimum and maximum.
open import Data.AVL.Key
-- Finite sets, based on AVL trees
open import Data.AVL.Sets
-- A binary representation of natural numbers
open import Data.Bin
-- Properties of the binary representation of natural numbers
open import Data.Bin.Properties
-- Booleans
open import Data.Bool
-- The type for booleans and some operations
open import Data.Bool.Base
-- A bunch of properties
open import Data.Bool.Properties
-- Showing booleans
open import Data.Bool.Show
-- Bounded vectors
open import Data.BoundedVec
-- Bounded vectors (inefficient, concrete implementation)
open import Data.BoundedVec.Inefficient
-- Characters
open import Data.Char
-- Basic definitions for Characters
open import Data.Char.Base
-- "Finite" sets indexed on coinductive "natural" numbers
open import Data.Cofin
-- Coinductive lists
open import Data.Colist
-- Infinite merge operation for coinductive lists
open import Data.Colist.Infinite-merge
-- Coinductive "natural" numbers
open import Data.Conat
-- Containers, based on the work of Abbott and others
open import Data.Container
-- Properties related to ◇
open import Data.Container.Any
-- Container combinators
open import Data.Container.Combinator
-- The free monad construction on containers
open import Data.Container.FreeMonad
-- Indexed containers aka interaction structures aka polynomial
-- functors. The notation and presentation here is closest to that of
-- Hancock and Hyvernat in "Programming interfaces and basic topology"
-- (2006/9).
open import Data.Container.Indexed
-- Indexed container combinators
open import Data.Container.Indexed.Combinator
-- The free monad construction on indexed containers
open import Data.Container.Indexed.FreeMonad
-- Coinductive vectors
open import Data.Covec
-- Lists with fast append
open import Data.DifferenceList
-- Natural numbers with fast addition (for use together with
-- DifferenceVec)
open import Data.DifferenceNat
-- Vectors with fast append
open import Data.DifferenceVec
-- Digits and digit expansions
open import Data.Digit
-- Empty type
open import Data.Empty
-- An irrelevant version of ⊥-elim
open import Data.Empty.Irrelevant
-- Finite sets
open import Data.Fin
-- Decision procedures for finite sets and subsets of finite sets
open import Data.Fin.Dec
-- Properties related to Fin, and operations making use of these
-- properties (or other properties not available in Data.Fin)
open import Data.Fin.Properties
-- Subsets of finite sets
open import Data.Fin.Subset
-- Some properties about subsets
open import Data.Fin.Subset.Properties
-- Substitutions
open import Data.Fin.Substitution
-- An example of how Data.Fin.Substitution can be used: a definition
-- of substitution for the untyped λ-calculus, along with some lemmas
open import Data.Fin.Substitution.Example
-- Substitution lemmas
open import Data.Fin.Substitution.Lemmas
-- Application of substitutions to lists, along with various lemmas
open import Data.Fin.Substitution.List
-- Floats
open import Data.Float
-- Directed acyclic multigraphs
open import Data.Graph.Acyclic
-- Integers
open import Data.Integer
-- Properties related to addition of integers
open import Data.Integer.Addition.Properties
-- Integers, basic types and operations
open import Data.Integer.Base
-- Divisibility and coprimality
open import Data.Integer.Divisibility
-- Properties related to multiplication of integers
open import Data.Integer.Multiplication.Properties
-- Some properties about integers
open import Data.Integer.Properties
-- Lists
open import Data.List
-- Lists where all elements satisfy a given property
open import Data.List.All
-- Properties related to All
open import Data.List.All.Properties
-- Lists where at least one element satisfies a given property
open import Data.List.Any
-- Properties related to bag and set equality
open import Data.List.Any.BagAndSetEquality
-- List membership and some related definitions
open import Data.List.Any.Membership
-- Properties related to propositional list membership
open import Data.List.Any.Membership.Properties
-- Data.List.Any.Membership instantiated with propositional equality,
-- along with some additional definitions.
open import Data.List.Any.Membership.Propositional
-- Properties related to propositional list membership
open import Data.List.Any.Membership.Propositional.Properties
-- Properties related to Any
open import Data.List.Any.Properties
-- Lists, basic types and operations
open import Data.List.Base
-- A categorical view of List
open import Data.List.Categorical
-- A data structure which keeps track of an upper bound on the number
-- of elements /not/ in a given list
open import Data.List.Countdown
-- Non-empty lists
open import Data.List.NonEmpty
-- Properties of non-empty lists
open import Data.List.NonEmpty.Properties
-- List-related properties
open import Data.List.Properties
-- Lexicographic ordering of lists
open import Data.List.Relation.NonStrictLex
-- Pointwise lifting of relations to lists
open import Data.List.Relation.Pointwise
-- Lexicographic ordering of lists
open import Data.List.Relation.StrictLex
-- Reverse view
open import Data.List.Reverse
-- M-types (the dual of W-types)
open import Data.M
-- Indexed M-types (the dual of indexed W-types aka Petersson-Synek
-- trees).
open import Data.M.Indexed
-- The Maybe type
open import Data.Maybe
-- The Maybe type and some operations
open import Data.Maybe.Base
-- Natural numbers
open import Data.Nat
-- Natural numbers, basic types and operations
open import Data.Nat.Base
-- Coprimality
open import Data.Nat.Coprimality
-- Integer division
open import Data.Nat.DivMod
-- Divisibility
open import Data.Nat.Divisibility
-- Greatest common divisor
open import Data.Nat.GCD
-- Boring lemmas used in Data.Nat.GCD and Data.Nat.Coprimality
open import Data.Nat.GCD.Lemmas
-- A generalisation of the arithmetic operations
open import Data.Nat.GeneralisedArithmetic
-- Definition of and lemmas related to "true infinitely often"
open import Data.Nat.InfinitelyOften
-- Least common multiple
open import Data.Nat.LCM
-- Primality
open import Data.Nat.Primality
-- A bunch of properties about natural number operations
open import Data.Nat.Properties
-- A bunch of properties about natural number operations
open import Data.Nat.Properties.Simple
-- Showing natural numbers
open import Data.Nat.Show
-- Transitive closures
open import Data.Plus
-- Products
open import Data.Product
-- N-ary products
open import Data.Product.N-ary
-- Properties of products
open import Data.Product.Properties
-- Lexicographic products of binary relations
open import Data.Product.Relation.NonStrictLex
-- Pointwise products of binary relations
open import Data.Product.Relation.Pointwise
-- Pointwise lifting of binary relations to sigma types
open import Data.Product.Relation.SigmaPointwise
-- Lexicographic products of binary relations
open import Data.Product.Relation.StrictLex
-- Rational numbers
open import Data.Rational
-- Properties of Rational numbers
open import Data.Rational.Properties
-- Reflexive closures
open import Data.ReflexiveClosure
-- Signs
open import Data.Sign
-- Some properties about signs
open import Data.Sign.Properties
-- The reflexive transitive closures of McBride, Norell and Jansson
open import Data.Star
-- Bounded vectors (inefficient implementation)
open import Data.Star.BoundedVec
-- Decorated star-lists
open import Data.Star.Decoration
-- Environments (heterogeneous collections)
open import Data.Star.Environment
-- Finite sets defined in terms of Data.Star
open import Data.Star.Fin
-- Lists defined in terms of Data.Star
open import Data.Star.List
-- Natural numbers defined in terms of Data.Star
open import Data.Star.Nat
-- Pointers into star-lists
open import Data.Star.Pointer
-- Some properties related to Data.Star
open import Data.Star.Properties
-- Vectors defined in terms of Data.Star
open import Data.Star.Vec
-- Streams
open import Data.Stream
-- Strings
open import Data.String
-- Strings
open import Data.String.Base
-- Sums (disjoint unions)
open import Data.Sum
-- Properties of sums (disjoint unions)
open import Data.Sum.Properties
-- Sums of binary relations
open import Data.Sum.Relation.General
-- Fixed-size tables of values, implemented as functions from 'Fin n'.
-- Similar to 'Data.Vec', but focusing on ease of retrieval instead of
-- ease of adding and removing elements.
open import Data.Table
-- Tables, basic types and operations
open import Data.Table.Base
-- Table-related properties
open import Data.Table.Properties
-- Pointwise table equality
open import Data.Table.Relation.Equality
-- Some unit types
open import Data.Unit
-- The unit type and the total relation on unit
open import Data.Unit.Base
-- Some unit types
open import Data.Unit.NonEta
-- Vectors
open import Data.Vec
-- Vectors where all elements satisfy a given property
open import Data.Vec.All
-- Properties related to All
open import Data.Vec.All.Properties
-- A categorical view of Vec
open import Data.Vec.Categorical
-- Code for converting Vec A n → B to and from n-ary functions
open import Data.Vec.N-ary
-- Some Vec-related properties
open import Data.Vec.Properties
-- Semi-heterogeneous vector equality
open import Data.Vec.Relation.Equality
-- Extensional pointwise lifting of relations to vectors
open import Data.Vec.Relation.ExtensionalPointwise
-- Inductive pointwise lifting of relations to vectors
open import Data.Vec.Relation.InductivePointwise
-- W-types
open import Data.W
-- Indexed W-types aka Petersson-Synek trees
open import Data.W.Indexed
-- Machine words
open import Data.Word
-- Type(s) used (only) when calling out to Haskell via the FFI
open import Foreign.Haskell
-- Simple combinators working solely on and with functions
open import Function
-- Bijections
open import Function.Bijection
-- Function setoids and related constructions
open import Function.Equality
-- Equivalence (coinhabitance)
open import Function.Equivalence
-- Injections
open import Function.Injection
-- Inverses
open import Function.Inverse
-- Left inverses
open import Function.LeftInverse
-- A universe which includes several kinds of "relatedness" for sets,
-- such as equivalences, surjections and bijections
open import Function.Related
-- Basic lemmas showing that various types are related (isomorphic or
-- equivalent or…)
open import Function.Related.TypeIsomorphisms
-- Surjections
open import Function.Surjection
-- IO
open import IO
-- Primitive IO: simple bindings to Haskell types and functions
open import IO.Primitive
-- An abstraction of various forms of recursion/induction
open import Induction
-- Lexicographic induction
open import Induction.Lexicographic
-- Various forms of induction for natural numbers
open import Induction.Nat
-- Well-founded induction
open import Induction.WellFounded
-- Universe levels
open import Level
-- Record types with manifest fields and "with", based on Randy
-- Pollack's "Dependently Typed Records in Type Theory"
open import Record
-- Support for reflection
open import Reflection
-- Properties of homogeneous binary relations
open import Relation.Binary
-- Some properties imply others
open import Relation.Binary.Consequences
-- Convenient syntax for equational reasoning
open import Relation.Binary.EqReasoning
-- Equivalence closures of binary relations
open import Relation.Binary.EquivalenceClosure
-- Many properties which hold for _∼_ also hold for flip _∼_
open import Relation.Binary.Flip
-- Heterogeneous equality
open import Relation.Binary.HeterogeneousEquality
-- Quotients for Heterogeneous equality
open import Relation.Binary.HeterogeneousEquality.Quotients
-- Example of a Quotient: ℤ as (ℕ × ℕ / ~)
open import Relation.Binary.HeterogeneousEquality.Quotients.Examples
-- Indexed binary relations
open import Relation.Binary.Indexed
-- Induced preorders
open import Relation.Binary.InducedPreorders
-- Order-theoretic lattices
open import Relation.Binary.Lattice
-- Lexicographic ordering of lists
open import Relation.Binary.List.NonStrictLex
-- Pointwise lifting of relations to lists
open import Relation.Binary.List.Pointwise
-- Lexicographic ordering of lists
open import Relation.Binary.List.StrictLex
-- Conversion of ≤ to <, along with a number of properties
open import Relation.Binary.NonStrictToStrict
-- Many properties which hold for _∼_ also hold for _∼_ on f
open import Relation.Binary.On
-- Order morphisms
open import Relation.Binary.OrderMorphism
-- Convenient syntax for "equational reasoning" using a partial order
open import Relation.Binary.PartialOrderReasoning
-- Convenient syntax for "equational reasoning" using a preorder
open import Relation.Binary.PreorderReasoning
-- Lexicographic products of binary relations
open import Relation.Binary.Product.NonStrictLex
-- Pointwise products of binary relations
open import Relation.Binary.Product.Pointwise
-- Lexicographic products of binary relations
open import Relation.Binary.Product.StrictLex
-- Properties satisfied by bounded join semilattices
open import Relation.Binary.Properties.BoundedJoinSemilattice
-- Properties satisfied by bounded meet semilattices
open import Relation.Binary.Properties.BoundedMeetSemilattice
-- Properties satisfied by decidable total orders
open import Relation.Binary.Properties.DecTotalOrder
-- Properties satisfied by join semilattices
open import Relation.Binary.Properties.JoinSemilattice
-- Properties satisfied by lattices
open import Relation.Binary.Properties.Lattice
-- Properties satisfied by meet semilattices
open import Relation.Binary.Properties.MeetSemilattice
-- Properties satisfied by posets
open import Relation.Binary.Properties.Poset
-- Properties satisfied by preorders
open import Relation.Binary.Properties.Preorder
-- Properties satisfied by strict partial orders
open import Relation.Binary.Properties.StrictPartialOrder
-- Properties satisfied by strict partial orders
open import Relation.Binary.Properties.StrictTotalOrder
-- Properties satisfied by total orders
open import Relation.Binary.Properties.TotalOrder
-- Propositional (intensional) equality
open import Relation.Binary.PropositionalEquality
-- An equality postulate which evaluates
open import Relation.Binary.PropositionalEquality.TrustMe
-- Helpers intended to ease the development of "tactics" which use
-- proof by reflection
open import Relation.Binary.Reflection
-- Convenient syntax for "equational reasoning" in multiple Setoids
open import Relation.Binary.SetoidReasoning
-- Pointwise lifting of binary relations to sigma types
open import Relation.Binary.Sigma.Pointwise
-- Some simple binary relations
open import Relation.Binary.Simple
-- Convenient syntax for "equational reasoning" using a strict partial
-- order
open import Relation.Binary.StrictPartialOrderReasoning
-- Conversion of < to ≤, along with a number of properties
open import Relation.Binary.StrictToNonStrict
-- Sums of binary relations
open import Relation.Binary.Sum
-- Symmetric closures of binary relations
open import Relation.Binary.SymmetricClosure
-- Pointwise lifting of relations to vectors
open import Relation.Binary.Vec.Pointwise
-- Operations on nullary relations (like negation and decidability)
open import Relation.Nullary
-- Operations on and properties of decidable relations
open import Relation.Nullary.Decidable
-- Implications of nullary relations
open import Relation.Nullary.Implication
-- Properties related to negation
open import Relation.Nullary.Negation
-- Products of nullary relations
open import Relation.Nullary.Product
-- Sums of nullary relations
open import Relation.Nullary.Sum
-- A universe of proposition functors, along with some properties
open import Relation.Nullary.Universe
-- Unary relations
open import Relation.Unary
-- Predicate transformers
open import Relation.Unary.PredicateTransformer
-- Sizes for Agda's sized types
open import Size
-- Strictness combinators
open import Strict
-- Universes
open import Universe
| {
"alphanum_fraction": 0.7984955664,
"avg_line_length": 25.4101265823,
"ext": "agda",
"hexsha": "579a48bc15183e94fae6de5be020964d2021d6df",
"lang": "Agda",
"max_forks_count": 304,
"max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z",
"max_forks_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "manikdv/plfa.github.io",
"max_forks_repo_path": "extra/extra/Everything.agda",
"max_issues_count": 323,
"max_issues_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4",
"max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z",
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "manikdv/plfa.github.io",
"max_issues_repo_path": "extra/extra/Everything.agda",
"max_line_length": 72,
"max_stars_count": 1003,
"max_stars_repo_head_hexsha": "8a2c2ace545092fd0e04bf5831ed458267f18ae4",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "manikdv/plfa.github.io",
"max_stars_repo_path": "extra/extra/Everything.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z",
"num_tokens": 4298,
"size": 20074
} |
open import Oscar.Prelude
open import Oscar.Class
open import Oscar.Class.Surjection
open import Oscar.Class.Smap
open import Oscar.Class.Transitivity
module Oscar.Class.Surjtranscommutativity where
module Surjtranscommutativity
{𝔬₁} {𝔒₁ : Ø 𝔬₁}
{𝔯₁} (_∼₁_ : 𝔒₁ → 𝔒₁ → Ø 𝔯₁)
{𝔬₂} {𝔒₂ : Ø 𝔬₂}
{𝔯₂} (_∼₂_ : 𝔒₂ → 𝔒₂ → Ø 𝔯₂)
{ℓ₂} (_∼̇₂_ : ∀ {x y} → x ∼₂ y → x ∼₂ y → Ø ℓ₂) (let infix 4 _∼̇₂_ ; _∼̇₂_ = _∼̇₂_)
{surjection : Surjection.type 𝔒₁ 𝔒₂}
(smap : Smap.type _∼₁_ _∼₂_ surjection surjection)
(transitivity₁ : Transitivity.type _∼₁_)
(let infixr 9 _∙₁_
_∙₁_ : FlipTransitivity.type _∼₁_
_∙₁_ g f = transitivity₁ f g)
(transitivity₂ : Transitivity.type _∼₂_)
(let infixr 9 _∙₂_
_∙₂_ : FlipTransitivity.type _∼₂_
_∙₂_ g f = transitivity₂ f g)
= ℭLASS (_∼₁_ ,, _∼₂_ ,, (λ {x y} → _∼̇₂_ {x} {y}) ,, surjection ,, (λ {x y} → smap {x} {y}) ,, (λ {x y z} → transitivity₁ {x} {y} {z}) ,, (λ {x y z} → transitivity₂ {x} {y} {z})) (∀ {x y z} (f : x ∼₁ y) (g : y ∼₁ z) → smap (g ∙₁ f) ∼̇₂ smap g ∙₂ smap f)
module Surjtranscommutativity!
{𝔬₁} {𝔒₁ : Ø 𝔬₁}
{𝔯₁} (_∼₁_ : 𝔒₁ → 𝔒₁ → Ø 𝔯₁)
{𝔬₂} {𝔒₂ : Ø 𝔬₂}
{𝔯₂} (_∼₂_ : 𝔒₂ → 𝔒₂ → Ø 𝔯₂)
{ℓ₂} (_∼̇₂_ : ∀ {x y} → x ∼₂ y → x ∼₂ y → Ø ℓ₂) (let infix 4 _∼̇₂_ ; _∼̇₂_ = _∼̇₂_)
⦃ I1 : Surjection.class 𝔒₁ 𝔒₂ ⦄
⦃ I2 : Smap!.class _∼₁_ _∼₂_ ⦄
⦃ I3 : Transitivity.class _∼₁_ ⦄
⦃ I4 : Transitivity.class _∼₂_ ⦄
= Surjtranscommutativity (_∼₁_) (_∼₂_) (λ {x y} → _∼̇₂_ {x} {y}) smap transitivity transitivity
module _
{𝔬₁} {𝔒₁ : Ø 𝔬₁}
{𝔯₁} {_∼₁_ : 𝔒₁ → 𝔒₁ → Ø 𝔯₁}
{𝔬₂} {𝔒₂ : Ø 𝔬₂}
{𝔯₂} {_∼₂_ : 𝔒₂ → 𝔒₂ → Ø 𝔯₂}
{ℓ₂} {_∼̇₂_ : ∀ {x y} → x ∼₂ y → x ∼₂ y → Ø ℓ₂}
{surjection : Surjection.type 𝔒₁ 𝔒₂}
{smap : Smap.type _∼₁_ _∼₂_ surjection surjection}
{transitivity₁ : Transitivity.type _∼₁_}
{transitivity₂ : Transitivity.type _∼₂_}
where
surjtranscommutativity = Surjtranscommutativity.method _∼₁_ _∼₂_ _∼̇₂_ smap transitivity₁ transitivity₂
⟪∙⟫-surjtranscommutativity-syntax = surjtranscommutativity
syntax ⟪∙⟫-surjtranscommutativity-syntax f g = g ⟪∙⟫ f
module _
{𝔬₁} {𝔒₁ : Ø 𝔬₁}
{𝔯₁} {_∼₁_ : 𝔒₁ → 𝔒₁ → Ø 𝔯₁}
{𝔬₂} {𝔒₂ : Ø 𝔬₂}
{𝔯₂} {_∼₂_ : 𝔒₂ → 𝔒₂ → Ø 𝔯₂}
{ℓ₂} {_∼̇₂_ : ∀ {x y} → x ∼₂ y → x ∼₂ y → Ø ℓ₂}
⦃ _ : Surjection.class 𝔒₁ 𝔒₂ ⦄
⦃ _ : Smap!.class _∼₁_ _∼₂_ ⦄
⦃ _ : Transitivity.class _∼₁_ ⦄
⦃ _ : Transitivity.class _∼₂_ ⦄
where
surjtranscommutativity! = Surjtranscommutativity!.method _∼₁_ _∼₂_ _∼̇₂_ ⦃ ! ⦄ ⦃ ! ⦄ ⦃ ! ⦄ ⦃ ! ⦄
⟪∙⟫!-surjtranscommutativity-syntax = surjtranscommutativity!
syntax ⟪∙⟫!-surjtranscommutativity-syntax f g = g ⟪∙⟫! f
module _
{𝔬₁} {𝔒₁ : Ø 𝔬₁}
{𝔯₁} {_∼₁_ : 𝔒₁ → 𝔒₁ → Ø 𝔯₁}
{𝔬₂} {𝔒₂ : Ø 𝔬₂}
{𝔯₂} {_∼₂_ : 𝔒₂ → 𝔒₂ → Ø 𝔯₂}
{ℓ₂} (_∼̇₂_ : ∀ {x y} → x ∼₂ y → x ∼₂ y → Ø ℓ₂)
{surjection : Surjection.type 𝔒₁ 𝔒₂}
{smap : Smap.type _∼₁_ _∼₂_ surjection surjection}
{transitivity₁ : Transitivity.type _∼₁_}
{transitivity₂ : Transitivity.type _∼₂_}
where
surjtranscommutativity[_] = Surjtranscommutativity.method _∼₁_ _∼₂_ _∼̇₂_ smap transitivity₁ transitivity₂
⟪∙⟫-surjtranscommutativity[]-syntax = surjtranscommutativity[_]
syntax ⟪∙⟫-surjtranscommutativity[]-syntax t f g = g ⟪∙⟫[ t ] f
module _
{𝔬₁} {𝔒₁ : Ø 𝔬₁}
{𝔯₁} {_∼₁_ : 𝔒₁ → 𝔒₁ → Ø 𝔯₁}
{𝔬₂} {𝔒₂ : Ø 𝔬₂}
{𝔯₂} {_∼₂_ : 𝔒₂ → 𝔒₂ → Ø 𝔯₂}
{ℓ₂} (_∼̇₂_ : ∀ {x y} → x ∼₂ y → x ∼₂ y → Ø ℓ₂)
⦃ _ : Surjection.class 𝔒₁ 𝔒₂ ⦄
⦃ _ : Smap!.class _∼₁_ _∼₂_ ⦄
⦃ _ : Transitivity.class _∼₁_ ⦄
⦃ _ : Transitivity.class _∼₂_ ⦄
where
surjtranscommutativity![_] = Surjtranscommutativity!.method _∼₁_ _∼₂_ _∼̇₂_ ⦃ ! ⦄ ⦃ ! ⦄ ⦃ ! ⦄ ⦃ ! ⦄
⟪∙⟫!-surjtranscommutativity[]-syntax = surjtranscommutativity![_]
syntax ⟪∙⟫!-surjtranscommutativity[]-syntax t f g = g ⟪∙⟫![ t ] f
| {
"alphanum_fraction": 0.5934981193,
"avg_line_length": 37.595959596,
"ext": "agda",
"hexsha": "a8a9bc4ffe5d8ce25a5f1acc179edf5feb401ad3",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-3/src/Oscar/Class/Surjtranscommutativity.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-3/src/Oscar/Class/Surjtranscommutativity.agda",
"max_line_length": 256,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-3/src/Oscar/Class/Surjtranscommutativity.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2111,
"size": 3722
} |
record Unit : Set where
instance
constructor tt
| {
"alphanum_fraction": 0.7222222222,
"avg_line_length": 13.5,
"ext": "agda",
"hexsha": "550a4b53e1d9233340d05644b965e4d431dfb7f8",
"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/Issue4380.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/Issue4380.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/Issue4380.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": 13,
"size": 54
} |
module TimeSpace where
open import Prelude as P
hiding
( [_]
; id
; _∘_
; _***_
)
open import Container.List
open import Pi.Util
{-
A universe of finite types.
-}
data U : Set where
𝟘 𝟙 : U
_⊕_ _⊗_ : U → U → U
infixr 6 _⊕_
infixr 7 _⊗_
{-
A collection of "primitive" isomorphisms.
Selection was based on accepted definitions of categorical structures.
Monoidal categories have left and right unitors, and associators;
braided monoidal categories have commutators.
While the left/right unitor pairs might be considered redundant in light of the commutative morphism,
I decided to keep them. By matching the morphisms of relevant categorical structures, we can
examine the various categorical coherence laws for time/space tradeoffs. This isn't necessary,
but I want to test the effects of the change on the structure of the proofs.
-}
data _≅_ : U → U → Set where
-- Coproduct monoid
⊕λ : ∀ {A}
→ 𝟘 ⊕ A ≅ A
⊕ρ : ∀ {A}
→ A ⊕ 𝟘 ≅ A
⊕σ : ∀ {A B}
→ A ⊕ B ≅ B ⊕ A
⊕α : ∀ {A B C}
→ (A ⊕ B) ⊕ C ≅ A ⊕ (B ⊕ C)
-- Product monoid
⊗λ : ∀ {A}
→ 𝟙 ⊗ A ≅ A
⊗ρ : ∀ {A}
→ A ⊗ 𝟙 ≅ A
⊗σ : ∀ {A B}
→ A ⊗ B ≅ B ⊗ A
⊗α : ∀ {A B C}
→ (A ⊗ B) ⊗ C ≅ A ⊗ (B ⊗ C)
-- Distributivity
δ : ∀ {A B C}
→ A ⊗ (B ⊕ C) ≅ (A ⊗ B) ⊕ (A ⊗ C)
infix 1 _≅_
{- Naming conventions:
*λ : left unitor : ε ∙ x ≅ x
*ρ : right unitor : x ∙ ε ≅ x
*α : associator : (x ∙ y) ∙ z ≅ x ∙ (y ∙ z)
*σ : braid : x ∙ y ≅ y ∙ x
⊗* : multiplicative variant, (𝟙 , ⊗)
⊕* : additive variant, (𝟘 , ⊕)
δ : distributor : x ⊗ (y ⊕ z) ≅ (x ⊗ y) ⊕ (x ⊗ z)
-}
infixr 5 _∘_
infix 1 _⟷_
data _⟷_ : U → U → Set where
[_] : ∀ {A B}
→ A ≅ B
→ A ⟷ B
id : ∀ {A}
→ A ⟷ A
_⁻¹ : ∀ {A B}
→ A ⟷ B
→ B ⟷ A
_∘_ : ∀ {A B C}
→ B ⟷ C
→ A ⟷ B
→ A ⟷ C
_⊗_ : ∀ {A B C D}
→ A ⟷ B
→ C ⟷ D
→ A ⊗ C ⟷ B ⊗ D
_⊕_ : ∀ {A B C D}
→ A ⟷ B
→ C ⟷ D
→ A ⊕ C ⟷ B ⊕ D
El : U → Set
El 𝟘 = ⊥
El 𝟙 = ⊤
El (A ⊕ B) = Either (El A) (El B)
El (A ⊗ B) = El A × El B
{-
bwd/fwd relate to the unitary morphisms,
while ap/ap⁻¹ relate to arbitrary morphisms.
-}
fwd : ∀ {A B}
→ A ≅ B
→ El A → El B
bwd : ∀ {A B}
→ A ≅ B
→ El B → El A
fwd ⊕λ (left ())
fwd ⊕λ (right x) = x
fwd ⊕ρ (left x) = x
fwd ⊕ρ (right ())
fwd ⊕σ (left x) = right x
fwd ⊕σ (right x) = left x
fwd ⊕α (left (left x)) = left x
fwd ⊕α (left (right x)) = right (left x)
fwd ⊕α (right x) = right (right x)
fwd ⊗λ (tt , x) = x
fwd ⊗ρ (x , tt) = x
fwd ⊗σ (x , y) = y , x
fwd ⊗α ((x , y) , z) = x , y , z
fwd δ (x , left y) = left (x , y)
fwd δ (x , right y) = right (x , y)
bwd ⊕λ x = right x
bwd ⊕ρ x = left x
bwd ⊕σ (left x) = right x
bwd ⊕σ (right x) = left x
bwd ⊕α (left x) = left (left x)
bwd ⊕α (right (left x)) = left (right x)
bwd ⊕α (right (right x)) = right x
bwd ⊗λ x = tt , x
bwd ⊗ρ x = x , tt
bwd ⊗σ (x , y) = y , x
bwd ⊗α (x , y , z) = (x , y) , z
bwd δ (left (x , y)) = x , left y
bwd δ (right (x , y)) = x , right y
fwd-bwd : ∀ {A B}
→ (f : A ≅ B)
→ bwd f P.∘ fwd f ≃ P.id
fwd-bwd ⊕λ (left ())
fwd-bwd ⊕λ (right x) = P.refl
fwd-bwd ⊕ρ (left x) = P.refl
fwd-bwd ⊕ρ (right ())
fwd-bwd ⊕σ (left x) = P.refl
fwd-bwd ⊕σ (right x) = P.refl
fwd-bwd ⊕α (left (left x)) = P.refl
fwd-bwd ⊕α (left (right x)) = P.refl
fwd-bwd ⊕α (right x) = P.refl
fwd-bwd ⊗λ (tt , x) = P.refl
fwd-bwd ⊗ρ (x , tt) = P.refl
fwd-bwd ⊗σ (x , y) = P.refl
fwd-bwd ⊗α ((x , y) , z) = P.refl
fwd-bwd δ (x , left y) = P.refl
fwd-bwd δ (x , right y) = P.refl
bwd-fwd : ∀ {A B}
→ (f : A ≅ B)
→ fwd f P.∘ bwd f ≃ P.id
bwd-fwd ⊕λ x = P.refl
bwd-fwd ⊕ρ x = P.refl
bwd-fwd ⊕σ (left x) = P.refl
bwd-fwd ⊕σ (right x) = P.refl
bwd-fwd ⊕α (left x) = P.refl
bwd-fwd ⊕α (right (left x)) = P.refl
bwd-fwd ⊕α (right (right x)) = P.refl
bwd-fwd ⊗λ x = P.refl
bwd-fwd ⊗ρ x = P.refl
bwd-fwd ⊗σ (x , y) = P.refl
bwd-fwd ⊗α (x , y , z) = P.refl
bwd-fwd δ (left (x , y)) = P.refl
bwd-fwd δ (right (x , y)) = P.refl
infixr 1 ap ap⁻¹
ap : ∀ {A B}
→ A ⟷ B
→ El A → El B
ap⁻¹ : ∀ {A B}
→ A ⟷ B
→ El B → El A
ap [ f ] = fwd f
ap id = P.id
ap (f ⁻¹) = ap⁻¹ f
ap (g ∘ f) = ap g P.∘ ap f
ap (f ⊗ g) = ap f *** ap g
ap (f ⊕ g) = ap f +++ ap g
ap⁻¹ [ f ] = bwd f
ap⁻¹ id = P.id
ap⁻¹ (f ⁻¹) = ap f
ap⁻¹ (g ∘ f) = ap⁻¹ f P.∘ ap⁻¹ g
ap⁻¹ (f ⊗ g) = ap⁻¹ f *** ap⁻¹ g
ap⁻¹ (f ⊕ g) = ap⁻¹ f +++ ap⁻¹ g
ap-inv : ∀ {A B}
→ (f : A ⟷ B)
→ ap⁻¹ f P.∘ ap f ≃ P.id
inv-ap : ∀ {A B}
→ (f : A ⟷ B)
→ ap f P.∘ ap⁻¹ f ≃ P.id
ap-inv [ f ] x = fwd-bwd f x
ap-inv id x = P.refl
ap-inv (f ⁻¹) x = inv-ap f x
ap-inv (g ∘ f) x =
ap⁻¹ f $≡ ap-inv g (ap f x)
⟨≡⟩ ap-inv f x
ap-inv (f ⊗ g) (x , y) = cong₂ _,_ (ap-inv f x) (ap-inv g y)
ap-inv (f ⊕ g) (left x) = left $≡ ap-inv f x
ap-inv (f ⊕ g) (right x) = right $≡ ap-inv g x
inv-ap [ f ] x = bwd-fwd f x
inv-ap id x = P.refl
inv-ap (f ⁻¹) x = ap-inv f x
inv-ap (g ∘ f) x =
ap g $≡ inv-ap f (ap⁻¹ g x)
⟨≡⟩ inv-ap g x
inv-ap (f ⊗ g) (x , y) = cong₂ _,_ (inv-ap f x) (inv-ap g y)
inv-ap (f ⊕ g) (left x) = left $≡ inv-ap f x
inv-ap (f ⊕ g) (right x) = right $≡ inv-ap g x
syntax fwd f x = f ♯ x
syntax bwd f x = f ♭ x
syntax ap f x = f ▸ x
syntax ap⁻¹ f x = f ◂ x
{-
The size of a type A is a natural number equal to the lub to any element of A.
We can also measure the size of an individual element of A, which may differ
for elements when there are sums present in A.
-}
size : U → Nat
size 𝟘 = 0
size 𝟙 = 1
size (A ⊕ B) = max (size A) (size B)
size (A ⊗ B) = size A + size B
sizeEl : ∀ A → El A → Nat
sizeEl 𝟘 ()
sizeEl 𝟙 tt = 1
sizeEl (A ⊕ B) (left x) = sizeEl A x
sizeEl (A ⊕ B) (right x) = sizeEl B x
sizeEl (A ⊗ B) (x , y) = sizeEl A x + sizeEl B y
{-
`path-length` calculates the total number of computation steps required,
according to a given valuation of the primitive isomorphisms. (see _≅_ type defn)
For any (f : A ⟷ B), the number of steps taken to transform an (x : El A) to (ap f x : El B)
depends on the value of `x`, due to the difference in steps between the two possible cases
of `path-length (f ⊕ g)`.
-}
module _ (t : ∀ {A B} → A ≅ B → El A → Nat) where
path-length : ∀ {A B} → A ⟷ B → El A → Nat
--| in the primitive case, we use the supplied valuation.
path-length [ f ] = t f
--| `id` has unit length. Although it does no work, an abstract machine processing
-- the morphism (f ∘ id) might still need to decompose the task into processing `f`,
-- and processing `id`.
path-length id _ = 1
--| the inverse of a morphism f takes the same number of steps to compute
-- as does f.
path-length (f ⁻¹) x = path-length f (ap⁻¹ f x)
--| composition is sequential, and so time is added.
path-length (g ∘ f) x = path-length f x + path-length g (ap f x)
--| the product tensor runs two processes in parallel, and so takes
-- the max time of the individual processes.
path-length (f ⊗ g) (x , y) = max (path-length f x) (path-length g y)
--| The coproduct tensor of two processes may take different amounts of
-- time to run, depending on from which side of the disjoint union
-- a particular input element is drawn.
path-length (f ⊕ g) (left x) = path-length f x
path-length (f ⊕ g) (right x) = path-length g x
{-
`circuit-length` is an upper bound of `path-length`, across all possible (x : El A).
Consequently, it is independent of any particular element (x : El A).
Here, a circuit is a spatial layout of a program in two dimensions, the "width" representing
"size", or memory usage, or storage requirements of a program, and the "length" representing
the stage of execution of the program.
-}
module _ (t : ∀ {A B} → A ≅ B → Nat) where
circuit-length : ∀ {A B} → A ⟷ B → Nat
circuit-length [ f ] = t f
circuit-length id = 1
circuit-length (f ⁻¹) = circuit-length f
circuit-length (g ∘ f) = circuit-length f + circuit-length g
circuit-length (f ⊗ g) = max (circuit-length f) (circuit-length g)
circuit-length (f ⊕ g) = max (circuit-length f) (circuit-length g)
{-
`circuit-width` measures the maximum width of the circuit described. viz. The maximum of the widths of all cross-section types.
-}
module _ (w : ∀ {A B} → A ≅ B → Nat) where
circuit-width : ∀ {A B} → A ⟷ B → Nat
circuit-width [ f ] = w f
circuit-width {A} id = size A
circuit-width (f ⁻¹) = circuit-width f
circuit-width (g ∘ f) = max (circuit-width f) (circuit-width g)
circuit-width (f ⊗ g) = circuit-width f + circuit-width g
circuit-width (f ⊕ g) = max (circuit-width f) (circuit-width g)
{-
Proposition: For any morphism f : A ⟷ B, (circuit-length f) is the least upper bound of (path-length f x), for any x.
-}
Max : ∀ A → (El A → Nat) → Nat
Max 𝟘 f = 0
Max 𝟙 f = f tt
Max (A ⊕ B) f = max (Max A (f P.∘ left)) (Max B (f P.∘ right))
Max (A ⊗ B) f = Max A λ a → Max B λ b → f (a , b)
Maximum : ∀ A (f : El A → Nat) (x : El A) → f x ≤ Max A f
Maximum 𝟘 f ()
Maximum 𝟙 f tt = diff! 0
Maximum (A ⊕ B) f (left x) = prf
where
MA : f (left x) ≤ Max A (f P.∘ left)
MA = Maximum A (f P.∘ left) x
prf : f (left x) ≤ max (Max A (f P.∘ left)) (Max B (f P.∘ right))
prf = {!!}
Maximum (A ⊕ B) f (right x) = prf
where
MB : f (right x) ≤ Max B (f P.∘ right)
MB = Maximum B (f P.∘ right) x
prf : f (right x) ≤ max (Max A (f P.∘ left)) (Max B (f P.∘ right))
prf = {!!}
Maximum (A ⊗ B) f (x , y) = {!!}
{-
Lemma: The max of a constant function is the value of the function.
-}
MaxConst : ∀ n A → El A → Max A (λ _ → n) ≡ n
MaxConst n 𝟘 ()
MaxConst n 𝟙 tt = P.refl
MaxConst n (A ⊕ B) (left x) = {!!}
MaxConst n (A ⊕ B) (right x) = {!!}
MaxConst n (A ⊗ B) (x , y) = {!!}
module _ (t : ∀ {A B} → A ≅ B → Nat) where
path≤circuit : ∀ {A B}
→ (f : A ⟷ B)
→ Max A (path-length (λ f _ → t f) f) ≤ circuit-length t f
path≤circuit [ f ] = {!!}
path≤circuit id = {!!}
path≤circuit (f ⁻¹) = {!!}
path≤circuit (g ∘ f) = {!!}
path≤circuit (f ⊗ g) = {!!}
path≤circuit (f ⊕ g) = {!!}
{-
Future work:
* Continue the literature search. Much of the underpinnings of this work are speculative,
such as the definitions of 'width' and 'length'.
* Continue the search for time/space invariants, and other properties of equivalence classes
of morphisms.
* Derive circuit-length circuit-width explicitly as LUBs
over element dependent metrics path-length and path-width (currently undefined).
* Find examples! The primitive objects and morphisms used here will only produce
straight-line programs.
* c.f. lit on complexity analysis and tradeoffs re. straight-line programs.
-}
-- These are the canonical equivalences arising from the categorical structure of a symmetric monoidal category.
-- I thought they might be a good place to start looking for nonzero time/space tradeoffs.
-- Should we investigate at all toward some form of distribuitive monoidal category?
{-
∘idₗ : ∀ {A B} (f : A ⟷ B) → id ∘ f ≅ f
∘idᵣ : ∀ {A B} (f : A ⟷ B) → f ∘ id ≅ f
∘invₗ : ∀ {A B} (f : A ⟷ B)
→ f ⁻¹ ∘ f ≅ id
∘invᵣ : ∀ {A B} (f : A ⟷ B)
→ f ∘ f ⁻¹ ≅ id
∘assoc : ∀ {A B C D}
→ (f : A ⟷ B) (g : B ⟷ C) (h : C ⟷ D)
→ (h ∘ g) ∘ f ≅ h ∘ (g ∘ f)
⁻¹cong : ∀ {A B}
→ {f g : A ⟷ B} → f ≅ g
→ f ⁻¹ ≅ g ⁻¹
∘cong : ∀ {A B C}
→ {f g : A ⟷ B} → f ≅ g
→ {h i : B ⟷ C} → h ≅ i
→ h ∘ f ≅ i ∘ g
⊗cong : ∀ {A B C D}
→ {f g : A ⟷ B} → f ≅ g
→ {h i : C ⟷ D} → h ≅ i
→ f ⊗ h ≅ g ⊗ i
⊕cong : ∀ {A B C D}
→ {f g : A ⟷ B} → f ≅ g
→ {h i : C ⟷ D} → h ≅ i
→ f ⊕ h ≅ g ⊕ i
∘/⁻¹ : ∀ {A B C}
→ (f : A ⟷ B) (g : B ⟷ C)
→ (g ∘ f) ⁻¹ ≅ f ⁻¹ ∘ g ⁻¹
⊗tri : ∀ {A B}
→ (id ⊗ [ ⊗λ ]) ∘ [ ⊗α ] ≅ [ ⊗ρ ] ⊗ id ∶ (A ⊗ 𝟙) ⊗ B ⟷ A ⊗ B
⊕tri : ∀ {A B}
→ (id ⊕ [ ⊕λ ]) ∘ [ ⊕α ] ≅ [ ⊕ρ ] ⊕ id ∶ (A ⊕ 𝟘) ⊕ B ⟷ A ⊕ B
⊕pent : ∀ {A B C D}
→ [ ⊕α ] ∘ [ ⊕α ] ≅ (id ⊕ [ ⊕α ]) ∘ [ ⊕α ] ∘ ([ ⊕α ] ⊕ id) ∶ ((A ⊕ B) ⊕ C) ⊕ D ⟷ A ⊕ (B ⊕ (C ⊕ D))
⊗pent : ∀ {A B C D}
→ [ ⊗α ] ∘ [ ⊗α ] ≅ (id ⊗ [ ⊗α ]) ∘ [ ⊗α ] ∘ ([ ⊗α ] ⊗ id) ∶ ((A ⊗ B) ⊗ C) ⊗ D ⟷ A ⊗ (B ⊗ (C ⊗ D))
⊗hex : ∀ {A B C}
→ (id ⊗ [ ⊗σ ]) ∘ [ ⊗α ] ∘ ([ ⊗σ ] ⊗ id) ≅ [ ⊗α ] ∘ [ ⊗σ ] ∘ [ ⊗α ] ∶ (A ⊗ B) ⊗ C ⟷ B ⊗ (C ⊗ A)
⊕hex : ∀ {A B C}
→ (id ⊕ [ ⊕σ ]) ∘ [ ⊕α ] ∘ ([ ⊕σ ] ⊕ id) ≅ [ ⊕α ] ∘ [ ⊕σ ] ∘ [ ⊕α ] ∶ (A ⊕ B) ⊕ C ⟷ B ⊕ (C ⊕ A)
⊗hex⁻¹ : ∀ {A B C}
→ ([ ⊗σ ] ⊗ id) ∘ [ ⊗α ] ⁻¹ ∘ (id ⊗ [ ⊗σ ]) ≅ [ ⊗α ] ⁻¹ ∘ [ ⊗σ ] ∘ [ ⊗α ] ⁻¹ ∶ A ⊗ (B ⊗ C) ⟷ (C ⊗ A) ⊗ B
⊕hex⁻¹ : ∀ {A B C}
→ ([ ⊕σ ] ⊕ id) ∘ [ ⊕α ] ⁻¹ ∘ (id ⊕ [ ⊕σ ]) ≅ [ ⊕α ] ⁻¹ ∘ [ ⊕σ ] ∘ [ ⊕α ] ⁻¹ ∶ A ⊕ (B ⊕ C) ⟷ (C ⊕ A) ⊕ B
-}
| {
"alphanum_fraction": 0.4835719054,
"avg_line_length": 30.5045248869,
"ext": "agda",
"hexsha": "a6f5ccd9279b991114eb66637c7cfd9735925312",
"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": "TimeSpace.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": "TimeSpace.agda",
"max_line_length": 128,
"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": "TimeSpace.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": 5631,
"size": 13483
} |
-- Was: test/Fail/Issue493
-- Andreas, 2020-06-08, issue #4737
-- Warn instead of hard error on useless hiding.
module _ where
module M where
postulate A B C : Set
data D : Set where
open M using (A) hiding (B; module D)
| {
"alphanum_fraction": 0.6885964912,
"avg_line_length": 19,
"ext": "agda",
"hexsha": "7d8d681b0ae0bc6df8e6ed575d3771ac46ef4f76",
"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/UselessHiding.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/UselessHiding.agda",
"max_line_length": 48,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/UselessHiding.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 73,
"size": 228
} |
{-# OPTIONS --cubical #-}
open import Agda.Primitive.Cubical
open import Agda.Builtin.Cubical.Path
data Interval : Set where
left right : Interval
path : left ≡ right
swap : Interval → Interval
swap left = right
swap right = left
swap (path i) = {!!}
| {
"alphanum_fraction": 0.7015503876,
"avg_line_length": 18.4285714286,
"ext": "agda",
"hexsha": "e39a3796fb7daf45c9223d3327210699f785b843",
"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/GoalConstraints.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/GoalConstraints.agda",
"max_line_length": 37,
"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/GoalConstraints.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": 72,
"size": 258
} |
{-# OPTIONS --rewriting #-}
module Issue4048 where
data _==_ {i} {A : Set i} : (x y : A) → Set i where
refl : {a : A} → a == a
{-# BUILTIN REWRITE _==_ #-}
postulate
Π : (A : Set) (B : A → Set) → Set
lam : {A : Set} {B : A → Set} (b : (a : A) → B a) → Π A B
app : {A : Set} {B : A → Set} (f : Π A B) (a : A) → B a
Π-β : {A : Set} {B : A → Set} (b : (a : A) → B a) (a : A) → app (lam b) a == b a
{-# REWRITE Π-β #-}
postulate
⊤ : Set
tt : ⊤
⊤-elim : ∀ {i} (A : ⊤ → Set i) (d : A tt) (x : ⊤) → A x
⊤-β : ∀ {i} (A : ⊤ → Set i) (d : A tt) → ⊤-elim A d tt == d
{-# REWRITE ⊤-β #-}
tt' : ⊤
tt' = tt
module _
(C : (p : ⊤) → Set)
(z : C tt)
where
F : (n p x : ⊤) → C p
F n p = app (⊤-elim (λ n → (p : ⊤) → Π ⊤ (λ _ → C p))
(⊤-elim _ (lam (⊤-elim _ z)))
n p)
F-red : F tt tt tt == z
F-red = refl
-- Bug?
F-red' : F tt tt' tt == z
F-red' = refl -- Not accepted, even though tt' is tt by definition.
| {
"alphanum_fraction": 0.3965517241,
"avg_line_length": 24.0487804878,
"ext": "agda",
"hexsha": "1ead735f83d208f20c09b678446c9024da75943c",
"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/Issue4048.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/Issue4048.agda",
"max_line_length": 82,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue4048.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": 460,
"size": 986
} |
module _ where
open import Common.Prelude hiding (_>>=_; _<$>_)
open import Common.Reflection
infixl 8 _<$>_
_<$>_ : ∀ {a b} {A : Set a} {B : Set b} → (A → B) → TC A → TC B
f <$> m = m >>= λ x → returnTC (f x)
macro
default : Tactic
default hole =
inferType hole >>= λ
{ (def (quote Nat) []) → unify hole (lit (nat 42))
; (def (quote Bool) []) → unify hole (con (quote false) [])
; (meta x _) → catchTC (blockOnMeta x) (typeError (strErr "impossible" ∷ []))
-- check that the block isn't caught
; _ → typeError (strErr "No default" ∷ [])
}
aNat : Nat
aNat = default
aBool : Bool
aBool = default
alsoNat : Nat
soonNat : _
soonNat = default
alsoNat = soonNat
| {
"alphanum_fraction": 0.554200542,
"avg_line_length": 21.7058823529,
"ext": "agda",
"hexsha": "44bf1a5b6d3159fe1db7b17e0a1e4f3602a10815",
"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/ReflectionBlockOnMeta.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/ReflectionBlockOnMeta.agda",
"max_line_length": 81,
"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/ReflectionBlockOnMeta.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 236,
"size": 738
} |
module MLib.Fin.Parts.Simple where
open import MLib.Prelude
open import MLib.Fin.Parts.Core
open import MLib.Fin.Parts
open import MLib.Fin.Parts.Nat
import MLib.Fin.Parts.Nat.Simple as PNS
open Nat using (_*_; _+_; _<_)
open Fin using (toℕ; fromℕ≤)
open Table
open PNS using (sum-replicate-*; repl)
asParts : ∀ {a b} → Fin (a * b) ↔ (Fin a × Fin b)
asParts {a} {b} = ≡.subst (λ n → Fin n ↔ (Fin a × Fin b)) (sum-replicate-* a b) (Parts.asParts (constParts a b))
fromParts : ∀ {a b} → Fin a × Fin b → Fin (a * b)
fromParts = Inverse.from asParts ⟨$⟩_
toParts : ∀ {a b} → Fin (a * b) → Fin a × Fin b
toParts = Inverse.to asParts ⟨$⟩_
fromParts³′ : ∀ {a b c} → Fin a × Fin b × Fin c → Fin (a * (b * c))
fromParts³′ {a} {b} {c} (i , j , k) = fromParts (i , fromParts (j , k))
fromParts³ : ∀ {a b c} → Fin a × Fin b × Fin c → Fin (a * b * c)
fromParts³ {a} {b} {c} (i , j , k) = fromParts (fromParts (i , j) , k)
private
fromParts′ : ∀ {a b} → Fin a × Fin b → Fin (sum (repl a b))
fromParts′ {a} {b} = Parts.fromParts (constParts a b)
toParts′ : ∀ {a b} → Fin (sum (repl a b)) → Fin a × Fin b
toParts′ {a} {b} = Parts.toParts (constParts a b)
asParts-prop : ∀ {a b} → asParts {a} {b} ≅ Parts.asParts (constParts a b)
asParts-prop {a} {b} = ≅.≡-subst-removable _ _ _
abstract
fromParts′-prop : ∀ {a b} (ij : Fin a × Fin b) → toℕ (fromParts ij) ≡ toℕ (fromParts′ ij)
fromParts′-prop {a} {b} ij =
≅.≅-to-≡ (≅.icong (λ n → Fin n ↔ (Fin a × Fin b))
(≡.sym (sum-replicate-* a b))
(λ {n} (ap : Fin n ↔ (Fin a × Fin b)) → toℕ (Inverse.from ap ⟨$⟩ ij))
asParts-prop)
toParts′-prop : ∀ {a b} {x : Fin (a * b)} {x′ : Fin (sum (repl a b))} → x ≅ x′ → Σ.map toℕ toℕ (toParts {a} x) ≡ Σ.map toℕ toℕ (toParts′ {a} x′)
toParts′-prop {a} {b} {x} {x′} x≅x′ =
≅.≅-to-≡ (≅.icong₂
(λ n → Fin n ↔ (Fin a × Fin b))
(≡.sym (sum-replicate-* a b))
(λ {n} (ap : Fin n ↔ (Fin a × Fin b)) x → Σ.map toℕ toℕ (Inverse.to ap ⟨$⟩ x))
asParts-prop
x≅x′)
fromParts³′-prop : ∀ {a b c} (i : Fin a) (j : Fin b) (k : Fin c) → toℕ (fromParts³′ (i , j , k)) ≡ PNS.fromParts³′ a b c (toℕ i , toℕ j , toℕ k)
fromParts³′-prop {a} {b} {c} i j k =
begin
toℕ (fromParts (i , fromParts (j , k))) ≡⟨ fromParts′-prop (i , _) ⟩
toℕ (fromParts′ (i , fromParts (j , k))) ≡⟨ Parts.fromParts-fromPartsℕ (constParts a (b * c)) i _ ⟩
Partsℕ.fromParts (constParts a (b * c)) (toℕ i , toℕ (fromParts (j , k))) ≡⟨ ≡.cong₂ (λ x y → Partsℕ.fromParts (constParts a x) (toℕ i , y))
(≡.sym (sum-replicate-* b c))
(fromParts′-prop (j , k)) ⟩
Partsℕ.fromParts (constParts a (sum (repl b c))) (toℕ i , toℕ (fromParts′ (j , k))) ≡⟨ ≡.sym (Parts.fromParts-fromPartsℕ (constParts a _) i _) ⟩
toℕ (Parts.fromParts (constParts a (sum (repl b c))) (i , fromParts′ (j , k))) ≡⟨ Parts.fromParts-fromPartsℕ (constParts a (sum (repl b c))) i _ ⟩
PNS.fromParts a (sum (repl b c)) (toℕ i , toℕ (fromParts′ (j , k))) ≡⟨ ≡.cong₂ (λ x y → PNS.fromParts a x (toℕ i , y))
(sum-replicate-* b c)
(Parts.fromParts-fromPartsℕ (constParts b c) j k) ⟩
PNS.fromParts a (b * c) (toℕ i , PNS.fromParts b c (toℕ j , toℕ k)) ∎
where
open ≡.Reasoning
fromParts³-prop : ∀ {a b c} (i : Fin a) (j : Fin b) (k : Fin c) → toℕ (fromParts³ (i , j , k)) ≡ PNS.fromParts³ a b c (toℕ i , toℕ j , toℕ k)
fromParts³-prop {a} {b} {c} i j k =
begin
toℕ (fromParts (fromParts (i , j) , k)) ≡⟨ fromParts′-prop (fromParts (i , j) , k) ⟩
toℕ (fromParts′ (fromParts (i , j) , k)) ≡⟨ Parts.fromParts-fromPartsℕ (constParts (a * b) c) (fromParts (i , j)) k ⟩
Partsℕ.fromParts (constParts (a * b) c) (toℕ (fromParts (i , j)) , toℕ k) ≡⟨ ≡.cong₂ (λ x y → Partsℕ.fromParts (constParts x c) (y , toℕ k))
(≡.sym (sum-replicate-* a b))
(fromParts′-prop (i , j)) ⟩
Partsℕ.fromParts (constParts (sum (repl a b)) c) (toℕ (fromParts′ (i , j)) , toℕ k) ≡⟨ ≡.sym (Parts.fromParts-fromPartsℕ (constParts _ c) (fromParts′ (i , j)) k) ⟩
toℕ (fromParts′ (fromParts′ (i , j) , k)) ≡⟨ Parts.fromParts-fromPartsℕ (constParts _ c) (fromParts′ (i , j)) k ⟩
PNS.fromParts (sum (repl a b)) c (toℕ (fromParts′ (i , j)) , toℕ k) ≡⟨ ≡.cong₂ (λ x y → PNS.fromParts x c (y , toℕ k))
(sum-replicate-* a b)
(Parts.fromParts-fromPartsℕ (constParts a b) i j) ⟩
PNS.fromParts (a * b) c (PNS.fromParts a b (toℕ i , toℕ j) , toℕ k) ∎
where open ≡.Reasoning
abstract
fromParts-assoc : ∀ {a b c} (ijk : Fin a × Fin b × Fin c) → fromParts³ ijk ≅ fromParts³′ ijk
fromParts-assoc {a} {b} {c} (i , j , k) =
Fin.toℕ-injective′ (begin
toℕ (fromParts³ (i , j , k)) ≡⟨ fromParts³-prop i j k ⟩
PNS.fromParts³ a b c (toℕ i , toℕ j , toℕ k) ≡⟨ ≡.sym (PNS.fromParts-assoc _ _ _ (Fin.bounded i) (Fin.bounded j) (Fin.bounded k)) ⟩
PNS.fromParts³′ a b c (toℕ i , toℕ j , toℕ k) ≡⟨ ≡.sym (fromParts³′-prop i j k) ⟩
toℕ (fromParts³′ (i , j , k)) ∎)
(Nat.*-assoc a _ _)
where open ≡.Reasoning
module _ (a b c : ℕ) where
toParts³ : Fin (a * b * c) → Fin a × Fin b × Fin c
toParts³ x =
let ij , k = toParts x
i , j = toParts ij
in i , j , k
toParts³′ : Fin (a * (b * c)) → Fin a × Fin b × Fin c
toParts³′ i =
let i₁ , i₂₃ = toParts i
i₂ , i₃ = toParts i₂₃
in i₁ , i₂ , i₃
abstract
fromParts³-toParts³ : ∀ i → fromParts³ (toParts³ i) ≡ i
fromParts³-toParts³ x =
let i , j , k = toParts³ x
open ≡.Reasoning
in begin
fromParts³ (toParts³ x) ≡⟨⟩
fromParts (fromParts (i , j) , k) ≡⟨ ≡.cong (fromParts ∘ (_, k)) (asParts {a} {b} .Inverse.left-inverse-of (toParts x .proj₁)) ⟩
fromParts {a * b} (toParts x) ≡⟨ asParts {a * b} .Inverse.left-inverse-of x ⟩
x ∎
toParts³′-fromParts³′ : ∀ ijk → toParts³′ (fromParts³′ ijk) ≡ ijk
toParts³′-fromParts³′ (i , j , k) =
let i′ , j′ , k′ = toParts³′ (fromParts³′ (i , j , k))
p , q = Σ.≡⇒≡×≡ (asParts .Inverse.right-inverse-of (i , fromParts (j , k)))
q′ = ≡.trans (≡.cong toParts q) (asParts .Inverse.right-inverse-of (j , k))
in Σ.≡×≡⇒≡ (p , q′)
toParts-assoc : {i : Fin (a * b * c)} {i′ : Fin (a * (b * c))} → i ≅ i′ → toParts³ i ≡ toParts³′ i′
toParts-assoc {i} {i′} eq =
begin
toParts³ i ≡⟨ ≡.sym (toParts³′-fromParts³′ _) ⟩
toParts³′ (fromParts³′ (toParts³ i)) ≡⟨ ≡.cong toParts³′ lem ⟩
toParts³′ i′ ∎
where
lem : fromParts³′ (toParts³ i) ≡ i′
lem = ≅.≅-to-≡ (
let open ≅.Reasoning
in begin
fromParts³′ (toParts³ i) ≅⟨ ≅.sym (fromParts-assoc (toParts³ i)) ⟩
fromParts³ (toParts³ i) ≡⟨ fromParts³-toParts³ i ⟩
i ≅⟨ eq ⟩
i′ ∎)
open ≡.Reasoning
toParts³-fromParts³ : ∀ ijk → toParts³ (fromParts³ ijk) ≡ ijk
toParts³-fromParts³ ijk =
begin
toParts³ (fromParts³ ijk) ≡⟨ toParts-assoc (fromParts-assoc ijk) ⟩
toParts³′ (fromParts³′ ijk) ≡⟨ toParts³′-fromParts³′ ijk ⟩
ijk ∎
where open ≡.Reasoning
fromParts³′-toParts³′ : ∀ k → fromParts³′ (toParts³′ k) ≡ k
fromParts³′-toParts³′ k =
let k′ = ≡.subst Fin (≡.sym (Nat.*-assoc a b c)) k
k′≅k = ≅.≡-subst-removable Fin _ k
in ≅.≅-to-≡ (begin
fromParts³′ (toParts³′ k ) ≡⟨ ≡.cong fromParts³′ (≡.sym (toParts-assoc k′≅k)) ⟩
fromParts³′ (toParts³ k′) ≅⟨ ≅.sym (fromParts-assoc (toParts³ k′)) ⟩
fromParts³ (toParts³ k′) ≡⟨ fromParts³-toParts³ k′ ⟩
k′ ≅⟨ k′≅k ⟩
k ∎)
where open ≅.Reasoning
asParts³ : Fin (a * b * c) ↔ (Fin a × Fin b × Fin c)
asParts³ = record
{ to = ≡.→-to-⟶ toParts³
; from = ≡.→-to-⟶ fromParts³
; inverse-of = record
{ left-inverse-of = fromParts³-toParts³
; right-inverse-of = toParts³-fromParts³
}
}
asParts³′ : Fin (a * (b * c)) ↔ (Fin a × Fin b × Fin c)
asParts³′ = record
{ to = ≡.→-to-⟶ toParts³′
; from = ≡.→-to-⟶ fromParts³′
; inverse-of = record
{ left-inverse-of = fromParts³′-toParts³′
; right-inverse-of = toParts³′-fromParts³′
}
}
abstract
toParts-1ˡ : ∀ {b} (x : Fin (1 * b)) (x′ : Fin b) → x ≅ x′ → toParts {1} x ≡ (zero , x′)
toParts-1ˡ {b} x x′ x≅x′ =
let i , j = toParts {1} x
i′ , j′ = toParts′ {1} x
i′′ , j′′ = Partsℕ.toParts (constParts 1 b) (toℕ x)
i≅i′ , j≅j′ = Σ.≡⇒≡×≡ (toParts′-prop {1} {x = x} {x′ = x} ≅.refl)
i′≅i′′ , j′≅j′′ = Σ.≡⇒≡×≡ (Parts.toParts-toPartsℕ (constParts 1 b) x)
p , q = Σ.≡⇒≡×≡ (PNS.toParts-1ˡ {b} _ (Nat.≤-trans (Fin.bounded x) (Nat.≤-reflexive (Nat.*-identityˡ _))))
open ≡.Reasoning
in Σ.≡×≡⇒≡
( Fin.toℕ-injective (begin
toℕ i ≡⟨ i≅i′ ⟩
toℕ i′ ≡⟨ i′≅i′′ ⟩
i′′ ≡⟨ p ⟩
0 ∎)
, Fin.toℕ-injective (begin
toℕ j ≡⟨ j≅j′ ⟩
toℕ j′ ≡⟨ j′≅j′′ ⟩
j′′ ≡⟨ q ⟩
toℕ x ≡⟨ ≅.≅-to-≡ (≅.icong Fin (Nat.*-identityˡ _) toℕ x≅x′) ⟩
toℕ x′ ∎)
)
toParts-1ʳ : ∀ {a} (x : Fin (a * 1)) (x′ : Fin a) → x ≅ x′ → toParts x ≡ (x′ , zero)
toParts-1ʳ {a} x x′ x≅x′ =
let x′′ : Fin (sum (repl a 1))
x′′ = ≡.subst Fin (≡.sym (sum-replicate-* a 1)) x
x≅x′′ = ≅.sym (≅.≡-subst-removable Fin (≡.sym (sum-replicate-* a 1)) x)
x′′≅x′ = ≅.trans (≅.sym x≅x′′) x≅x′
sra≡a = ≡.trans (sum-replicate-* a 1) (Nat.*-identityʳ a)
i , j = toParts x
i′ , j′ = toParts′ {a} {1} x′′
i′′ , j′′ = Partsℕ.toParts (constParts a 1) (toℕ x′′)
i≅i′ , j≅j′ = Σ.≡⇒≡×≡ (toParts′-prop {a} {x = x} {x′ = x′′} x≅x′′)
i′≅i′′ , j′≅j′′ = Σ.≡⇒≡×≡ (Parts.toParts-toPartsℕ (constParts a 1) x′′)
p , q = Σ.≡⇒≡×≡ (PNS.toParts-1ʳ {a} (toℕ x′′) (Nat.≤-trans (Nat.≤-reflexive (≅.≅-to-≡ (≅.icong Fin sra≡a (suc ∘ toℕ) x′′≅x′))) (Fin.bounded x′)))
open ≡.Reasoning
in Σ.≡×≡⇒≡
( Fin.toℕ-injective (begin
toℕ i ≡⟨ i≅i′ ⟩
toℕ i′ ≡⟨ i′≅i′′ ⟩
i′′ ≡⟨ p ⟩
toℕ x′′ ≡⟨ ≅.≅-to-≡ (≅.icong Fin sra≡a toℕ x′′≅x′) ⟩
toℕ x′ ∎)
, Fin.toℕ-injective (begin
toℕ j ≡⟨ j≅j′ ⟩
toℕ j′ ≡⟨ j′≅j′′ ⟩
j′′ ≡⟨ q ⟩
0 ∎)
)
| {
"alphanum_fraction": 0.4484103434,
"avg_line_length": 47.3694779116,
"ext": "agda",
"hexsha": "1fe6c7712f12baa3a3e1f80aeed555a848ab17a4",
"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/Fin/Parts/Simple.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/Fin/Parts/Simple.agda",
"max_line_length": 173,
"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/Fin/Parts/Simple.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4741,
"size": 11795
} |
open import Agda.Builtin.List
open import Agda.Builtin.Char
open import Agda.Builtin.Equality
postulate
A B : Set
b : B
f : List A → Char → B
f _ 'a' = b
f [] _ = b
f _ _ = b
test : ∀ xs → f xs 'a' ≡ b
test _ = refl
| {
"alphanum_fraction": 0.6061946903,
"avg_line_length": 14.125,
"ext": "agda",
"hexsha": "213d7a17935b9738f5b40f60185da71f6024e0b5",
"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/Issue3062.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/Issue3062.agda",
"max_line_length": 33,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/Issue3062.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-30T18:20:48.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-09T23:51:16.000Z",
"num_tokens": 90,
"size": 226
} |
{-# OPTIONS --sized-types #-}
module Builtin.Size where
open import Agda.Builtin.Size public
| {
"alphanum_fraction": 0.7446808511,
"avg_line_length": 18.8,
"ext": "agda",
"hexsha": "9d03b82f63737be4cc8da46c85bb728943cdfd8d",
"lang": "Agda",
"max_forks_count": 24,
"max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z",
"max_forks_repo_head_hexsha": "d704381936db6bd393e63aa2740345e7364f9732",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "UlfNorell/agda-prelude",
"max_forks_repo_path": "src/Builtin/Size.agda",
"max_issues_count": 59,
"max_issues_repo_head_hexsha": "d704381936db6bd393e63aa2740345e7364f9732",
"max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "UlfNorell/agda-prelude",
"max_issues_repo_path": "src/Builtin/Size.agda",
"max_line_length": 36,
"max_stars_count": 111,
"max_stars_repo_head_hexsha": "d704381936db6bd393e63aa2740345e7364f9732",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "UlfNorell/agda-prelude",
"max_stars_repo_path": "src/Builtin/Size.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z",
"num_tokens": 22,
"size": 94
} |
{-# OPTIONS --without-K --safe #-}
------------------------------------------------------------------------
-- Re-exports of the Data.List.Kleene module, renamed to duplicate the
-- Data.List API.
module Data.List.Kleene.AsList where
import Data.List.Kleene.Base as Kleene
open import Data.List.Kleene.Base
using
( []
)
renaming
( _⋆ to List
; foldr⋆ to foldr
; foldl⋆ to foldl
; _⋆++⋆_ to _++_
; map⋆ to map
; pure⋆ to pure
; _⋆<*>⋆_ to _<*>_
; _⋆>>=⋆_ to _>>=_
; mapAccumL⋆ to mapAccumL
; _[_]⋆ to _[_]
; applyUpTo⋆ to applyUpTo
; upTo⋆ to upTo
; intersperse⋆ to intersperse
; _⋆<|>⋆_ to _<|>_
; ⋆zipWith⋆ to zipWith
; unzipWith⋆ to unzipWith
; partitionSumsWith⋆ to partitionSumsWith
; ⋆transpose⋆ to transpose
; reverse⋆ to reverse
)
public
infixr 5 _∷_
pattern _∷_ x xs = Kleene.∹ x Kleene.& xs
scanr : ∀ {a b} {A : Set a} {B : Set b} → (A → B → B) → B → List A → List B
scanr f b xs = Kleene.∹ Kleene.scanr⋆ f b xs
scanl : ∀ {a b} {A : Set a} {B : Set b} → (B → A → B) → B → List A → List B
scanl f b xs = Kleene.∹ Kleene.scanl⋆ f b xs
tails : ∀ {a} {A : Set a} → List A → List (List A)
tails xs = foldr (λ x xs → (Kleene.∹ x) ∷ xs) ([] ∷ []) (Kleene.tails⋆ xs)
import Data.List.Kleene.Syntax
module Syntax = Data.List.Kleene.Syntax using (_]; _,_) renaming (⋆[_ to [_)
| {
"alphanum_fraction": 0.5471014493,
"avg_line_length": 26.0377358491,
"ext": "agda",
"hexsha": "b883440308cc999562bedd417479d86c464d8ebf",
"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": "a7e99bc288e12e83440c891dbd3e5077d9b1657e",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-kleene-lists",
"max_forks_repo_path": "Data/List/Kleene/AsList.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a7e99bc288e12e83440c891dbd3e5077d9b1657e",
"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-kleene-lists",
"max_issues_repo_path": "Data/List/Kleene/AsList.agda",
"max_line_length": 76,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a7e99bc288e12e83440c891dbd3e5077d9b1657e",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-kleene-lists",
"max_stars_repo_path": "Data/List/Kleene/AsList.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 555,
"size": 1380
} |
-- some examples for structural order in the termination checker
module StructuralOrder where
data Nat : Set where
zero : Nat
succ : Nat -> Nat
-- c t > t for any term t
-- e.g., succ (succ y) > succ y
plus : Nat -> Nat -> Nat
plus x (succ (succ y)) = succ (plus x (succ y))
plus x (succ zero) = succ x
plus x zero = x
-- constructor names do not matter
-- c (c' t) > c'' t
-- e.g. c0 (c1 x) > c0 x
-- c0 (c0 x) > c1 x
-- Actually constructor names does matter until the non-mattering is
-- implemented properly.
{- TEMPORARILY REMOVED by Ulf since there are problems with the constructor-name ignoring
data Bin : Set where
eps : Bin
c0 : Bin -> Bin
c1 : Bin -> Bin
foo : Bin -> Nat
foo eps = zero
foo (c0 eps) = zero
foo (c0 (c1 x)) = succ (foo (c0 x))
foo (c0 (c0 x)) = succ (foo (c1 x))
foo (c1 x) = succ (foo x)
-}
| {
"alphanum_fraction": 0.6142191142,
"avg_line_length": 23.1891891892,
"ext": "agda",
"hexsha": "fda1d5b2e71f26f5d21f0b047232625978d488ff",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "examples/Termination/StructuralOrder.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "examples/Termination/StructuralOrder.agda",
"max_line_length": 89,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "examples/Termination/StructuralOrder.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": 288,
"size": 858
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties related to ◇
------------------------------------------------------------------------
module Data.Container.Any where
open import Algebra
open import Data.Container as C
open import Data.Container.Combinator
using (module Composition) renaming (_∘_ to _⟨∘⟩_)
open import Data.Product as Prod hiding (swap)
open import Data.Sum
open import Function
open import Function.Equality using (_⟨$⟩_)
open import Function.Inverse as Inv using (_↔_; module Inverse)
open import Function.Related as Related using (Related)
open import Function.Related.TypeIsomorphisms
import Relation.Binary.HeterogeneousEquality as H
open import Relation.Binary.Product.Pointwise
open import Relation.Binary.PropositionalEquality as P
using (_≡_; _≗_; refl)
import Relation.Binary.Sigma.Pointwise as Σ
open Related.EquationalReasoning
private
module ×⊎ {k ℓ} = CommutativeSemiring (×⊎-CommutativeSemiring k ℓ)
-- ◇ can be expressed using _∈_.
↔∈ : ∀ {c} (C : Container c) {X : Set c}
{P : X → Set c} {xs : ⟦ C ⟧ X} →
◇ P xs ↔ (∃ λ x → x ∈ xs × P x)
↔∈ _ {P = P} {xs} = record
{ to = P.→-to-⟶ to
; from = P.→-to-⟶ from
; inverse-of = record
{ left-inverse-of = λ _ → refl
; right-inverse-of = to∘from
}
}
where
to : ◇ P xs → ∃ λ x → x ∈ xs × P x
to (p , Px) = (proj₂ xs p , (p , refl) , Px)
from : (∃ λ x → x ∈ xs × P x) → ◇ P xs
from (.(proj₂ xs p) , (p , refl) , Px) = (p , Px)
to∘from : to ∘ from ≗ id
to∘from (.(proj₂ xs p) , (p , refl) , Px) = refl
-- ◇ is a congruence for bag and set equality and related preorders.
cong : ∀ {k c} {C : Container c}
{X : Set c} {P₁ P₂ : X → Set c} {xs₁ xs₂ : ⟦ C ⟧ X} →
(∀ x → Related k (P₁ x) (P₂ x)) → xs₁ ∼[ k ] xs₂ →
Related k (◇ P₁ xs₁) (◇ P₂ xs₂)
cong {C = C} {P₁ = P₁} {P₂} {xs₁} {xs₂} P₁↔P₂ xs₁≈xs₂ =
◇ P₁ xs₁ ↔⟨ ↔∈ C ⟩
(∃ λ x → x ∈ xs₁ × P₁ x) ∼⟨ Σ.cong Inv.id (xs₁≈xs₂ ×-cong P₁↔P₂ _) ⟩
(∃ λ x → x ∈ xs₂ × P₂ x) ↔⟨ sym (↔∈ C) ⟩
◇ P₂ xs₂ ∎
-- Nested occurrences of ◇ can sometimes be swapped.
swap : ∀ {c} {C₁ C₂ : Container c} {X Y : Set c} {P : X → Y → Set c}
{xs : ⟦ C₁ ⟧ X} {ys : ⟦ C₂ ⟧ Y} →
let ◈ : ∀ {C : Container c} {X} → ⟦ C ⟧ X → (X → Set c) → Set c
◈ = λ {_} {_} → flip ◇ in
◈ xs (◈ ys ∘ P) ↔ ◈ ys (◈ xs ∘ flip P)
swap {c} {C₁} {C₂} {P = P} {xs} {ys} =
◇ (λ x → ◇ (P x) ys) xs ↔⟨ ↔∈ C₁ ⟩
(∃ λ x → x ∈ xs × ◇ (P x) ys) ↔⟨ Σ.cong Inv.id (λ {x} → Inv.id ⟨ ×⊎.*-cong {ℓ = c} ⟩ ↔∈ C₂ {P = P x}) ⟩
(∃ λ x → x ∈ xs × ∃ λ y → y ∈ ys × P x y) ↔⟨ Σ.cong Inv.id (λ {x} → ∃∃↔∃∃ {A = x ∈ xs} (λ _ y → y ∈ ys × P x y)) ⟩
(∃₂ λ x y → x ∈ xs × y ∈ ys × P x y) ↔⟨ ∃∃↔∃∃ (λ x y → x ∈ xs × y ∈ ys × P x y) ⟩
(∃₂ λ y x → x ∈ xs × y ∈ ys × P x y) ↔⟨ Σ.cong Inv.id (λ {y} → Σ.cong Inv.id (λ {x} →
(x ∈ xs × y ∈ ys × P x y) ↔⟨ sym $ ×⊎.*-assoc _ _ _ ⟩
((x ∈ xs × y ∈ ys) × P x y) ↔⟨ ×⊎.*-comm _ _ ⟨ ×⊎.*-cong {ℓ = c} ⟩ Inv.id ⟩
((y ∈ ys × x ∈ xs) × P x y) ↔⟨ ×⊎.*-assoc _ _ _ ⟩
(y ∈ ys × x ∈ xs × P x y) ∎)) ⟩
(∃₂ λ y x → y ∈ ys × x ∈ xs × P x y) ↔⟨ Σ.cong Inv.id (λ {y} → ∃∃↔∃∃ {B = y ∈ ys} (λ x _ → x ∈ xs × P x y)) ⟩
(∃ λ y → y ∈ ys × ∃ λ x → x ∈ xs × P x y) ↔⟨ Σ.cong Inv.id (λ {y} → Inv.id ⟨ ×⊎.*-cong {ℓ = c} ⟩ sym (↔∈ C₁ {P = flip P y})) ⟩
(∃ λ y → y ∈ ys × ◇ (flip P y) xs) ↔⟨ sym (↔∈ C₂) ⟩
◇ (λ y → ◇ (flip P y) xs) ys ∎
-- Nested occurrences of ◇ can sometimes be flattened.
flatten : ∀ {c} {C₁ C₂ : Container c} {X}
P (xss : ⟦ C₁ ⟧ (⟦ C₂ ⟧ X)) →
◇ (◇ P) xss ↔
◇ P (Inverse.from (Composition.correct C₁ C₂) ⟨$⟩ xss)
flatten {C₁ = C₁} {C₂} {X} P xss = record
{ to = P.→-to-⟶ t
; from = P.→-to-⟶ f
; inverse-of = record
{ left-inverse-of = λ _ → refl
; right-inverse-of = λ _ → refl
}
}
where
open Inverse
t : ◇ (◇ P) xss → ◇ P (from (Composition.correct C₁ C₂) ⟨$⟩ xss)
t (p₁ , p₂ , p) = ((p₁ , p₂) , p)
f : ◇ P (from (Composition.correct C₁ C₂) ⟨$⟩ xss) → ◇ (◇ P) xss
f ((p₁ , p₂) , p) = (p₁ , p₂ , p)
-- Sums commute with ◇ (for a fixed instance of a given container).
◇⊎↔⊎◇ : ∀ {c} {C : Container c} {X : Set c} {xs : ⟦ C ⟧ X}
{P Q : X → Set c} →
◇ (λ x → P x ⊎ Q x) xs ↔ (◇ P xs ⊎ ◇ Q xs)
◇⊎↔⊎◇ {xs = xs} {P} {Q} = record
{ to = P.→-to-⟶ to
; from = P.→-to-⟶ from
; inverse-of = record
{ left-inverse-of = from∘to
; right-inverse-of = [ (λ _ → refl) , (λ _ → refl) ]
}
}
where
to : ◇ (λ x → P x ⊎ Q x) xs → ◇ P xs ⊎ ◇ Q xs
to (pos , inj₁ p) = inj₁ (pos , p)
to (pos , inj₂ q) = inj₂ (pos , q)
from : ◇ P xs ⊎ ◇ Q xs → ◇ (λ x → P x ⊎ Q x) xs
from = [ Prod.map id inj₁ , Prod.map id inj₂ ]
from∘to : from ∘ to ≗ id
from∘to (pos , inj₁ p) = refl
from∘to (pos , inj₂ q) = refl
-- Products "commute" with ◇.
×◇↔◇◇× : ∀ {c} {C₁ C₂ : Container c}
{X Y} {P : X → Set c} {Q : Y → Set c}
{xs : ⟦ C₁ ⟧ X} {ys : ⟦ C₂ ⟧ Y} →
◇ (λ x → ◇ (λ y → P x × Q y) ys) xs ↔ (◇ P xs × ◇ Q ys)
×◇↔◇◇× {C₁ = C₁} {C₂} {P = P} {Q} {xs} {ys} = record
{ to = P.→-to-⟶ to
; from = P.→-to-⟶ from
; inverse-of = record
{ left-inverse-of = λ _ → refl
; right-inverse-of = λ _ → refl
}
}
where
to : ◇ (λ x → ◇ (λ y → P x × Q y) ys) xs → ◇ P xs × ◇ Q ys
to (p₁ , p₂ , p , q) = ((p₁ , p) , (p₂ , q))
from : ◇ P xs × ◇ Q ys → ◇ (λ x → ◇ (λ y → P x × Q y) ys) xs
from ((p₁ , p) , (p₂ , q)) = (p₁ , p₂ , p , q)
-- map can be absorbed by the predicate.
map↔∘ : ∀ {c} (C : Container c) {X Y : Set c}
(P : Y → Set c) {xs : ⟦ C ⟧ X} (f : X → Y) →
◇ P (C.map f xs) ↔ ◇ (P ∘ f) xs
map↔∘ _ _ _ = Inv.id
-- Membership in a mapped container can be expressed without reference
-- to map.
∈map↔∈×≡ : ∀ {c} (C : Container c) {X Y : Set c} {f : X → Y}
{xs : ⟦ C ⟧ X} {y} →
y ∈ C.map f xs ↔ (∃ λ x → x ∈ xs × y ≡ f x)
∈map↔∈×≡ {c} C {f = f} {xs} {y} =
y ∈ C.map f xs ↔⟨ map↔∘ C (_≡_ y) f ⟩
◇ (λ x → y ≡ f x) xs ↔⟨ ↔∈ C ⟩
(∃ λ x → x ∈ xs × y ≡ f x) ∎
-- map is a congruence for bag and set equality and related preorders.
map-cong : ∀ {k c} {C : Container c} {X Y : Set c}
{f₁ f₂ : X → Y} {xs₁ xs₂ : ⟦ C ⟧ X} →
f₁ ≗ f₂ → xs₁ ∼[ k ] xs₂ →
C.map f₁ xs₁ ∼[ k ] C.map f₂ xs₂
map-cong {c = c} {C} {f₁ = f₁} {f₂} {xs₁} {xs₂} f₁≗f₂ xs₁≈xs₂ {x} =
x ∈ C.map f₁ xs₁ ↔⟨ map↔∘ C (_≡_ x) f₁ ⟩
◇ (λ y → x ≡ f₁ y) xs₁ ∼⟨ cong {xs₁ = xs₁} {xs₂ = xs₂} (Related.↔⇒ ∘ helper) xs₁≈xs₂ ⟩
◇ (λ y → x ≡ f₂ y) xs₂ ↔⟨ sym (map↔∘ C (_≡_ x) f₂) ⟩
x ∈ C.map f₂ xs₂ ∎
where
helper : ∀ y → (x ≡ f₁ y) ↔ (x ≡ f₂ y)
helper y = record
{ to = P.→-to-⟶ (λ x≡f₁y → P.trans x≡f₁y ( f₁≗f₂ y))
; from = P.→-to-⟶ (λ x≡f₂y → P.trans x≡f₂y (P.sym $ f₁≗f₂ y))
; inverse-of = record
{ left-inverse-of = λ _ → P.proof-irrelevance _ _
; right-inverse-of = λ _ → P.proof-irrelevance _ _
}
}
-- Uses of linear morphisms can be removed.
remove-linear :
∀ {c} {C₁ C₂ : Container c} {X} {xs : ⟦ C₁ ⟧ X}
(P : X → Set c) (m : C₁ ⊸ C₂) →
◇ P (⟪ m ⟫⊸ xs) ↔ ◇ P xs
remove-linear {xs = xs} P m = record
{ to = P.→-to-⟶ t
; from = P.→-to-⟶ f
; inverse-of = record
{ left-inverse-of = f∘t
; right-inverse-of = t∘f
}
}
where
open Inverse
t : ◇ P (⟪ m ⟫⊸ xs) → ◇ P xs
t = Prod.map (_⟨$⟩_ (to (position⊸ m))) id
f : ◇ P xs → ◇ P (⟪ m ⟫⊸ xs)
f = Prod.map (_⟨$⟩_ (from (position⊸ m)))
(P.subst (P ∘ proj₂ xs)
(P.sym $ right-inverse-of (position⊸ m) _))
f∘t : f ∘ t ≗ id
f∘t (p₂ , p) = H.≅-to-≡ $
H.cong₂ _,_ (H.≡-to-≅ $ left-inverse-of (position⊸ m) p₂)
(H.≡-subst-removable
(P ∘ proj₂ xs)
(P.sym (right-inverse-of (position⊸ m)
(to (position⊸ m) ⟨$⟩ p₂)))
p)
t∘f : t ∘ f ≗ id
t∘f (p₁ , p) = H.≅-to-≡ $
H.cong₂ _,_ (H.≡-to-≅ $ right-inverse-of (position⊸ m) p₁)
(H.≡-subst-removable
(P ∘ proj₂ xs)
(P.sym (right-inverse-of (position⊸ m) p₁))
p)
-- Linear endomorphisms are identity functions if bag equality is
-- used.
linear-identity :
∀ {c} {C : Container c} {X} {xs : ⟦ C ⟧ X} (m : C ⊸ C) →
⟪ m ⟫⊸ xs ∼[ bag ] xs
linear-identity {xs = xs} m {x} =
x ∈ ⟪ m ⟫⊸ xs ↔⟨ remove-linear (_≡_ x) m ⟩
x ∈ xs ∎
-- If join can be expressed using a linear morphism (in a certain
-- way), then it can be absorbed by the predicate.
join↔◇ : ∀ {c} {C₁ C₂ C₃ : Container c} {X}
P (join′ : (C₁ ⟨∘⟩ C₂) ⊸ C₃) (xss : ⟦ C₁ ⟧ (⟦ C₂ ⟧ X)) →
let join : ∀ {X} → ⟦ C₁ ⟧ (⟦ C₂ ⟧ X) → ⟦ C₃ ⟧ X
join = λ {_} → ⟪ join′ ⟫⊸ ∘
_⟨$⟩_ (Inverse.from (Composition.correct C₁ C₂)) in
◇ P (join xss) ↔ ◇ (◇ P) xss
join↔◇ {C₁ = C₁} {C₂} P join xss =
◇ P (⟪ join ⟫⊸ xss′) ↔⟨ remove-linear P join ⟩
◇ P xss′ ↔⟨ sym $ flatten P xss ⟩
◇ (◇ P) xss ∎
where xss′ = Inverse.from (Composition.correct C₁ C₂) ⟨$⟩ xss
| {
"alphanum_fraction": 0.442303598,
"avg_line_length": 35.8549618321,
"ext": "agda",
"hexsha": "4f52fe244eaced749f773546b6f4ae8b805bbe57",
"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/Container/Any.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/Container/Any.agda",
"max_line_length": 129,
"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/Container/Any.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": 4182,
"size": 9394
} |
-- Andreas, 2019-08-20, issue #4012
-- unquoteDef and unquoteDecl should also work in abstract blocks.
open import Agda.Builtin.Reflection renaming (bindTC to _>>=_)
open import Agda.Builtin.List
open import Agda.Builtin.Equality
abstract
data D : Set where
c : D
f : D
unquoteDef f = do
qc ← quoteTC c -- Previously, there was a complaint here about c.
defineFun f (clause [] [] qc ∷ [])
unquoteDecl g = do
ty ← quoteTC D
_ ← declareDef (arg (arg-info visible relevant) g) ty
qc ← quoteTC c
defineFun g (clause [] [] qc ∷ [])
test : f ≡ g
test = refl
-- Expected error:
-- f !=< g of type D
-- when checking that the expression refl has type f ≡ g
| {
"alphanum_fraction": 0.6532374101,
"avg_line_length": 22.4193548387,
"ext": "agda",
"hexsha": "fc010159d4931581f1c59e99987bcf9c0df71d90",
"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/Fail/Issue4012.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/Fail/Issue4012.agda",
"max_line_length": 70,
"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/Fail/Issue4012.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 211,
"size": 695
} |
-- Andreas, 2019-10-21, issue #4049
-- reported and test case by andy-morris
open import Agda.Builtin.Size
data A : Size → Set
B = A
data A where
a : ∀ i → B i
-- WAS (2.6.0): internal error in Polarity.hs
-- Should succeed.
| {
"alphanum_fraction": 0.6551724138,
"avg_line_length": 15.4666666667,
"ext": "agda",
"hexsha": "bdc203cb3cf47f1af57274410aabf5c6475111d0",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-06-14T11:07:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-06-14T11:07:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/Issue4049.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/Issue4049.agda",
"max_line_length": 45,
"max_stars_count": 2,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue4049.agda",
"max_stars_repo_stars_event_max_datetime": "2020-09-20T00:28:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-10-29T09:40:30.000Z",
"num_tokens": 79,
"size": 232
} |
module SystemF.BigStep.Types where
open import Prelude
open import Data.List as List
-- 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 hiding (_∈_; map)
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
-- typing context
Ctx : ℕ → Set
Ctx n = List (Type n)
_+tm_ : ∀ {n} → Ctx n → Type n → Ctx n
Γ +tm a = a ∷ Γ
Var : ∀ {n} → Ctx n → Type n → Set
Var Γ a = a ∈ Γ
where
open import Data.List.Any
open Membership-≡
infixl 30 _ctx/_
_ctx/_ : ∀ {n m} → Ctx n → Sub Type n m → Ctx m
Γ ctx/ ρ = List.map (flip _/_ ρ) Γ
_+ty : ∀ {n} → Ctx n → Ctx (suc n)
Γ +ty = Γ ctx/ wk
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)
module CtxLemmas where
open import Data.List.Properties as ListProp using ()
open import Function as Fun
-- weakening followed by sub disappears on contexts
ctx/-wk-sub≡id : ∀ {n} (Γ : Ctx n) a → (Γ ctx/ wk) ctx/ (sub a) ≡ Γ
ctx/-wk-sub≡id Γ a = begin
_ ≡⟨ sym (ListProp.map-compose Γ) ⟩
map (λ x → x / wk / (sub a)) Γ ≡⟨ ListProp.map-cong Lemmas.wk-sub-vanishes Γ ⟩
map Fun.id Γ ≡⟨ ListProp.map-id Γ ⟩
_ ∎
-- weakening commutes with other substitutions on contexts
ctx/-wk-comm : ∀ {n m} (Γ : Ctx n) (ρ : Sub Type n m) → (Γ ctx/ ρ) ctx/ wk ≡ Γ ctx/ wk ctx/ (ρ ↑)
ctx/-wk-comm Γ ρ = begin
_ ≡⟨ sym $ ListProp.map-compose Γ ⟩
map (λ x → x / ρ / wk) Γ ≡⟨ ListProp.map-cong Lemmas.wk-commutes Γ ⟩
map (λ x → x / wk / ρ ↑) Γ ≡⟨ ListProp.map-compose Γ ⟩
_ ∎
| {
"alphanum_fraction": 0.4905176832,
"avg_line_length": 31.216,
"ext": "agda",
"hexsha": "0f4cab9943278b2fd2726433b22fcc4514b64ef6",
"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/SystemF/BigStep/Types.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/SystemF/BigStep/Types.agda",
"max_line_length": 99,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "7fe638b87de26df47b6437f5ab0a8b955384958d",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "metaborg/ts.agda",
"max_stars_repo_path": "src/SystemF/BigStep/Types.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1897,
"size": 3902
} |
module Tactic.Nat.Auto.Lemmas where
open import Prelude
open import Tactic.Nat.NF
open import Tactic.Nat.Exp
open import Container.Bag
open import Prelude.Nat.Properties
map++ : ∀ {a b} {A : Set a} {B : Set b} (f : A → B) (xs ys : List A) →
map f (xs ++ ys) ≡ map f xs ++ map f ys
map++ f [] ys = refl
map++ f (x ∷ xs) ys rewrite map++ f xs ys = refl
prod++ : (xs ys : List Nat) → productR (xs ++ ys) ≡ productR xs * productR ys
prod++ [] ys = sym (add-zero-r (productR ys))
prod++ (x ∷ xs) ys rewrite prod++ xs ys = mul-assoc x _ _
private
shuffle₁ : ∀ a b c d → a + ((b + c) + d) ≡ b + c + (a + d)
shuffle₁ a b c d rewrite add-assoc a (b + c) d
| add-commute a (b + c)
| add-assoc (b + c) a d
= refl
shuffle₂ : ∀ a b c d → a + b + (c + d) ≡ a + c + (b + d)
shuffle₂ a b c d rewrite add-assoc (a + b) c d
| sym (add-assoc a b c)
| add-commute b c
| add-assoc a c b
| add-assoc (a + c) b d
= refl
shuffle₃ : ∀ a b c d → (a * b) * (c * d) ≡ (a * c) * (b * d)
shuffle₃ a b c d rewrite mul-assoc (a * b) c d
| sym (mul-assoc a b c)
| mul-commute b c
| mul-assoc a c b
| mul-assoc (a * c) b d = refl
shuffle₄ : ∀ a b c d → a * (b * c * d) ≡ b * c * (a * d)
shuffle₄ a b c d rewrite mul-assoc a (b * c) d
| mul-commute a (b * c)
| mul-assoc (b * c) a d
= refl
module _ {Atom : Set} {{_ : Ord Atom}} where
⟨+⟩-sound : ∀ v₁ v₂ (ρ : Env Atom) → ⟦ v₁ +nf v₂ ⟧n ρ ≡ ⟦ v₁ ⟧n ρ + ⟦ v₂ ⟧n ρ
⟨+⟩-sound [] [] ρ = refl
⟨+⟩-sound [] (_ ∷ _) ρ = refl
⟨+⟩-sound (t ∷ v₁) [] ρ = sym (add-zero-r _)
⟨+⟩-sound ((i , t₁) ∷ v₁) ((j , t₂) ∷ v₂) ρ with compare t₁ t₂
... | less _ rewrite ⟨+⟩-sound v₁ ((j , t₂) ∷ v₂) ρ
= add-assoc (i * productR (map ρ t₁)) _ _
... | equal eq rewrite eq | ⟨+⟩-sound v₁ v₂ ρ
| mul-distr-r i j (productR (map ρ t₂))
= shuffle₂ (⟦ i , t₂ ⟧t ρ) (⟦ j , t₂ ⟧t ρ) _ _
... | greater _ rewrite ⟨+⟩-sound ((i , t₁) ∷ v₁) v₂ ρ
= shuffle₁ (⟦ j , t₂ ⟧t ρ) (⟦ i , t₁ ⟧t ρ) _ _
map-merge : ∀ x y (ρ : Env Atom) → productR (map ρ (merge x y)) ≡ productR (map ρ x) * productR (map ρ y)
map-merge [] [] ρ = refl
map-merge [] (x ∷ xs) ρ = sym (add-zero-r (productR (ρ x ∷ map ρ xs)))
map-merge (x ∷ xs) [] ρ = sym (mul-one-r _)
map-merge (x ∷ xs) (y ∷ ys) ρ with x <? y
... | true rewrite map-merge xs (y ∷ ys) ρ = mul-assoc (ρ x) _ _
... | false rewrite map-merge (x ∷ xs) ys ρ = shuffle₄ (ρ y) (ρ x) _ _
mulTm-sound : ∀ t t′ (ρ : Env Atom) →
⟦ mulTm t t′ ⟧t ρ ≡ ⟦ t ⟧t ρ * ⟦ t′ ⟧t ρ
mulTm-sound (a , x) (b , y) ρ rewrite map-merge x y ρ
= shuffle₃ a b _ _
mulTmDistr : ∀ t v (ρ : Env Atom) → ⟦ map (mulTm t) v ⟧n ρ ≡ ⟦ t ⟧t ρ * ⟦ v ⟧n ρ
mulTmDistr t [] ρ = sym (mul-zero-r (⟦ t ⟧t ρ))
mulTmDistr t (t′ ∷ v) ρ =
⟦ mulTm t t′ ⟧t ρ + ⟦ map (mulTm t) v ⟧n ρ
≡⟨ cong₂ _+_ (mulTm-sound t t′ ρ) (mulTmDistr t v ρ) ⟩
⟦ t ⟧t ρ * ⟦ t′ ⟧t ρ + ⟦ t ⟧t ρ * ⟦ v ⟧n ρ
≡⟨ mul-distr-l (⟦ t ⟧t ρ) _ _ ⟩ʳ
⟦ t ⟧t ρ * ⟦ t′ ∷ v ⟧n ρ ∎
sort-sound : ∀ xs ρ → ⟦ nf-sort xs ⟧n ρ ≡ ⟦ xs ⟧n ρ
sort-sound [] ρ = refl
sort-sound (x ∷ xs) ρ rewrite ⟨+⟩-sound [ x ] (nf-sort xs) ρ
| sort-sound xs ρ
| add-zero-r (⟦ x ⟧t ρ) = refl
⟨*⟩-sound : ∀ v₁ v₂ (ρ : Env Atom) → ⟦ v₁ *nf v₂ ⟧n ρ ≡ ⟦ v₁ ⟧n ρ * ⟦ v₂ ⟧n ρ
⟨*⟩-sound [] v₂ ρ = refl
⟨*⟩-sound (t ∷ v₁) v₂ ρ =
⟦ nf-sort (map (mulTm t) v₂) +nf (v₁ *nf v₂) ⟧n ρ
≡⟨ ⟨+⟩-sound (nf-sort (map (mulTm t) v₂)) (v₁ *nf v₂) ρ ⟩
⟦ nf-sort (map (mulTm t) v₂) ⟧n ρ + ⟦ v₁ *nf v₂ ⟧n ρ
≡⟨ cong (flip _+_ (⟦ v₁ *nf v₂ ⟧n ρ)) (sort-sound (map (mulTm t) v₂) ρ) ⟩
⟦ map (mulTm t) v₂ ⟧n ρ + ⟦ v₁ *nf v₂ ⟧n ρ
≡⟨ cong (_+_ (⟦ map (mulTm t) v₂ ⟧n ρ)) (⟨*⟩-sound v₁ v₂ ρ) ⟩
⟦ map (mulTm t) v₂ ⟧n ρ + ⟦ v₁ ⟧n ρ * ⟦ v₂ ⟧n ρ
≡⟨ cong (flip _+_ (⟦ v₁ ⟧n ρ * ⟦ v₂ ⟧n ρ)) (mulTmDistr t v₂ ρ) ⟩
⟦ t ⟧t ρ * ⟦ v₂ ⟧n ρ + ⟦ v₁ ⟧n ρ * ⟦ v₂ ⟧n ρ
≡⟨ mul-distr-r (⟦ t ⟧t ρ) _ _ ⟩ʳ
⟦ t ∷ v₁ ⟧n ρ * ⟦ v₂ ⟧n ρ ∎
sound : ∀ e (ρ : Env Atom) → ⟦ e ⟧e ρ ≡ ⟦ norm e ⟧n ρ
sound (var x) ρ = mul-one-r (ρ x) ʳ⟨≡⟩ add-zero-r _ ʳ⟨≡⟩ʳ add-zero-r _
sound (lit 0) ρ = refl
sound (lit (suc n)) ρ rewrite mul-one-r n
| add-commute n 1
= sym (add-zero-r _)
sound (e ⟨+⟩ e₁) ρ =
⟦ e ⟧e ρ + ⟦ e₁ ⟧e ρ
≡⟨ cong₂ _+_ (sound e ρ) (sound e₁ ρ) ⟩
⟦ norm e ⟧n ρ + ⟦ norm e₁ ⟧n ρ
≡⟨ ⟨+⟩-sound (norm e) (norm e₁) ρ ⟩ʳ
⟦ norm e +nf norm e₁ ⟧n ρ ∎
sound (e ⟨*⟩ e₁) ρ =
⟦ e ⟧e ρ * ⟦ e₁ ⟧e ρ
≡⟨ cong₂ _*_ (sound e ρ) (sound e₁ ρ) ⟩
⟦ norm e ⟧n ρ * ⟦ norm e₁ ⟧n ρ
≡⟨ ⟨*⟩-sound (norm e) (norm e₁) ρ ⟩ʳ
⟦ norm e *nf norm e₁ ⟧n ρ ∎
module _ (ρ₁ ρ₂ : Env Atom) (eq : ∀ x → ρ₁ x ≡ ρ₂ x) where
private
lem-eval-env-a : ∀ a → productR (map ρ₁ a) ≡ productR (map ρ₂ a)
lem-eval-env-a [] = refl
lem-eval-env-a (x ∷ xs) = _*_ $≡ eq x *≡ lem-eval-env-a xs
lem-eval-env-t : ∀ t → ⟦ t ⟧t ρ₁ ≡ ⟦ t ⟧t ρ₂
lem-eval-env-t (k , a) = _*_ k $≡ lem-eval-env-a a
lem-eval-env : ∀ n → ⟦ n ⟧n ρ₁ ≡ ⟦ n ⟧n ρ₂
lem-eval-env [] = refl
lem-eval-env (x ∷ n) = _+_ $≡ lem-eval-env-t x *≡ lem-eval-env n
| {
"alphanum_fraction": 0.4347979531,
"avg_line_length": 41.9777777778,
"ext": "agda",
"hexsha": "1fb82983168f93dca207e67d6059d2096e220df5",
"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": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "lclem/agda-prelude",
"max_forks_repo_path": "src/Tactic/Nat/Auto/Lemmas.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6",
"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": "lclem/agda-prelude",
"max_issues_repo_path": "src/Tactic/Nat/Auto/Lemmas.agda",
"max_line_length": 107,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "75016b4151ed601e28f4462cd7b6b1aaf5d0d1a6",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "lclem/agda-prelude",
"max_stars_repo_path": "src/Tactic/Nat/Auto/Lemmas.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2598,
"size": 5667
} |
postulate A : Set
| {
"alphanum_fraction": 0.7222222222,
"avg_line_length": 9,
"ext": "agda",
"hexsha": "069b71991e55c1635416a9fd452e9fee82bd9c43",
"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/Issue3257.tex.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/Issue3257.tex.agda",
"max_line_length": 17,
"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/Issue3257.tex.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": 6,
"size": 18
} |
module Rec1 where
import Rec2
y : ℕ
y = x
| {
"alphanum_fraction": 0.568627451,
"avg_line_length": 6.375,
"ext": "agda",
"hexsha": "2feb1f981ef075ed5b2c66e1908628076c4871d6",
"lang": "Agda",
"max_forks_count": 304,
"max_forks_repo_forks_event_max_datetime": "2022-03-28T11:35:02.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-07-16T18:24:59.000Z",
"max_forks_repo_head_hexsha": "5468837f55cbea38d5c5a163e1ea5d48edb92bcc",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "andorp/plfa.github.io",
"max_forks_repo_path": "extra/extra/Rec1.agda",
"max_issues_count": 323,
"max_issues_repo_head_hexsha": "5468837f55cbea38d5c5a163e1ea5d48edb92bcc",
"max_issues_repo_issues_event_max_datetime": "2022-03-30T07:42:57.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-07-05T22:34:34.000Z",
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "andorp/plfa.github.io",
"max_issues_repo_path": "extra/extra/Rec1.agda",
"max_line_length": 17,
"max_stars_count": 1003,
"max_stars_repo_head_hexsha": "5468837f55cbea38d5c5a163e1ea5d48edb92bcc",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "andorp/plfa.github.io",
"max_stars_repo_path": "extra/extra/Rec1.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-27T07:03:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-07-05T18:15:14.000Z",
"num_tokens": 20,
"size": 51
} |
module plfa-code.Naturals where
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
{-# BUILTIN NATURAL ℕ #-}
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl)
open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎)
_+_ : ℕ → ℕ → ℕ
zero + n = n
suc m + n = suc (m + n)
_ : 2 + 3 ≡ 5
_ = refl
_*_ : ℕ → ℕ → ℕ
zero * n = zero
suc m * n = n + (m * n)
_^_ : ℕ → ℕ → ℕ
n ^ zero = suc zero
n ^ (suc m) = n * (n ^ m)
_ : 3 ^ 4 ≡ 81
_ =
begin
3 ^ 4
≡⟨⟩
3 * (3 ^ 3)
≡⟨⟩
3 * (3 * (3 ^ 2))
≡⟨⟩
3 * (3 * (3 * (3 ^ 1)))
≡⟨⟩
3 * (3 * (3 * (3 * (3 ^ 0))))
≡⟨⟩
3 * (3 * (3 * (3 * 1)))
≡⟨⟩
81
∎
_∸_ : ℕ → ℕ → ℕ
m ∸ zero = m
zero ∸ suc n = zero
suc m ∸ suc n = m ∸ n
_ =
begin
3 ∸ 2
≡⟨⟩
2 ∸ 1
≡⟨⟩
1 ∸ 0
≡⟨⟩
1
∎
_ =
begin
2 ∸ 3
≡⟨⟩
1 ∸ 2
≡⟨⟩
0 ∸ 1
≡⟨⟩
0
∎
infixl 6 _+_ _∸_
infixl 7 _*_
data Bin : Set where
nil : Bin
x0_ : Bin → Bin
x1_ : Bin → Bin
inc : Bin → Bin
inc nil = x1 nil
inc (x0 t) = x1 t
inc (x1 t) = x0 (inc t)
_ : inc (x1 x1 x0 x1 nil) ≡ x0 x0 x1 x1 nil
_ = refl
_ : inc (x0 nil) ≡ x1 nil
_ = refl
_ : inc (x1 nil) ≡ x0 x1 nil
_ = refl
_ : inc (x0 x1 nil) ≡ x1 x1 nil
_ = refl
_ : inc (x1 x1 nil) ≡ x0 x0 x1 nil
_ = refl
to : ℕ → Bin
to 0 = x0 nil
to (suc n) = inc (to n)
from : Bin → ℕ
from nil = 0
from (x0 t) = (from t) * 2
from (x1 t) = (from t) * 2 + 1
_ : to 0 ≡ x0 nil
_ = refl
_ : to 1 ≡ x1 nil
_ = refl
_ : to 2 ≡ x0 x1 nil
_ = refl
_ : to 3 ≡ x1 x1 nil
_ = refl
_ : to 4 ≡ x0 x0 x1 nil
_ = refl
_ : 0 ≡ from (x0 nil)
_ = refl
_ : 1 ≡ from (x1 nil)
_ = refl
_ : 2 ≡ from (x0 x1 nil)
_ = refl
_ : 3 ≡ from (x1 x1 nil)
_ = refl
_ : 4 ≡ from (x0 x0 x1 nil)
_ = refl
| {
"alphanum_fraction": 0.4474885845,
"avg_line_length": 12.5142857143,
"ext": "agda",
"hexsha": "4dba82f3a117ac414a87d2107e2dea0061489b47",
"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": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "chirsz-ever/plfa-code",
"max_forks_repo_path": "src/plfa-code/Naturals.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3",
"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": "chirsz-ever/plfa-code",
"max_issues_repo_path": "src/plfa-code/Naturals.agda",
"max_line_length": 50,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "chirsz-ever/plfa-code",
"max_stars_repo_path": "src/plfa-code/Naturals.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 942,
"size": 1752
} |
{-# OPTIONS --without-K --safe #-}
module Definition.Typed.Consequences.Syntactic where
open import Definition.Untyped
open import Definition.Typed
open import Definition.Typed.Properties
open import Definition.Typed.EqRelInstance
open import Definition.LogicalRelation
open import Definition.LogicalRelation.Substitution
open import Definition.LogicalRelation.Substitution.Escape
open import Definition.LogicalRelation.Fundamental
open import Definition.Typed.Consequences.Injectivity
open import Tools.Product
-- Syntactic validity of type equality.
syntacticEq : ∀ {A B Γ} → Γ ⊢ A ≡ B → Γ ⊢ A × Γ ⊢ B
syntacticEq A≡B with fundamentalEq A≡B
syntacticEq A≡B | [Γ] , [A] , [B] , [A≡B] =
escapeᵛ [Γ] [A] , escapeᵛ [Γ] [B]
-- Syntactic validity of terms.
syntacticTerm : ∀ {t A Γ} → Γ ⊢ t ∷ A → Γ ⊢ A
syntacticTerm t with fundamentalTerm t
syntacticTerm t | [Γ] , [A] , [t] = escapeᵛ [Γ] [A]
-- Syntactic validity of term equality.
syntacticEqTerm : ∀ {t u A Γ} → Γ ⊢ t ≡ u ∷ A → Γ ⊢ A × (Γ ⊢ t ∷ A × Γ ⊢ u ∷ A)
syntacticEqTerm t≡u with fundamentalTermEq t≡u
syntacticEqTerm t≡u | [Γ] , modelsTermEq [A] [t] [u] [t≡u] =
escapeᵛ [Γ] [A] , escapeTermᵛ [Γ] [A] [t] , escapeTermᵛ [Γ] [A] [u]
-- Syntactic validity of type reductions.
syntacticRed : ∀ {A B Γ} → Γ ⊢ A ⇒* B → Γ ⊢ A × Γ ⊢ B
syntacticRed D with fundamentalEq (subset* D)
syntacticRed D | [Γ] , [A] , [B] , [A≡B] =
escapeᵛ [Γ] [A] , escapeᵛ [Γ] [B]
-- Syntactic validity of term reductions.
syntacticRedTerm : ∀ {t u A Γ} → Γ ⊢ t ⇒* u ∷ A → Γ ⊢ A × (Γ ⊢ t ∷ A × Γ ⊢ u ∷ A)
syntacticRedTerm d with fundamentalTermEq (subset*Term d)
syntacticRedTerm d | [Γ] , modelsTermEq [A] [t] [u] [t≡u] =
escapeᵛ [Γ] [A] , escapeTermᵛ [Γ] [A] [t] , escapeTermᵛ [Γ] [A] [u]
-- Syntactic validity of Π-types.
syntacticΠ : ∀ {Γ F G} → Γ ⊢ Π F ▹ G → Γ ⊢ F × Γ ∙ F ⊢ G
syntacticΠ ΠFG with injectivity (refl ΠFG)
syntacticΠ ΠFG | F≡F , G≡G = proj₁ (syntacticEq F≡F) , proj₁ (syntacticEq G≡G)
| {
"alphanum_fraction": 0.6628982528,
"avg_line_length": 38.1568627451,
"ext": "agda",
"hexsha": "db32abf9a2811327fb403cfe3245a353a55abdba",
"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": "2251b8da423be0c6fb916f2675d7bd8537e4cd96",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "loic-p/logrel-mltt",
"max_forks_repo_path": "Definition/Typed/Consequences/Syntactic.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96",
"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": "loic-p/logrel-mltt",
"max_issues_repo_path": "Definition/Typed/Consequences/Syntactic.agda",
"max_line_length": 81,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "2251b8da423be0c6fb916f2675d7bd8537e4cd96",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "loic-p/logrel-mltt",
"max_stars_repo_path": "Definition/Typed/Consequences/Syntactic.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 789,
"size": 1946
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Morphism.Universal where
open import Level
open import Categories.Category
open import Categories.Category.Construction.Comma
open import Categories.Functor
open import Categories.Object.Initial
record UniversalMorphism {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′}
(X : Category.Obj C) (F : Functor D C) : Set (e ⊔ ℓ ⊔ o′ ⊔ ℓ′ ⊔ e′) where
X↙F : Category _ _ _
X↙F = X ↙ F
private
module X↙F = Category X↙F
field
initial : Initial X↙F
module initial = Initial initial
open initial public
| {
"alphanum_fraction": 0.6563011457,
"avg_line_length": 25.4583333333,
"ext": "agda",
"hexsha": "29874568e00bdf675569ddca04e03eb7ed8a6f47",
"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/Morphism/Universal.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/Morphism/Universal.agda",
"max_line_length": 98,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Morphism/Universal.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": 185,
"size": 611
} |
{-# OPTIONS --without-K --safe #-}
module Util.HoTT.HLevel.Core where
open import Data.Nat using (_+_)
open import Level using (Lift ; lift ; lower)
open import Util.Prelude
open import Util.Relation.Binary.LogicalEquivalence using (_↔_ ; forth ; back)
open import Util.Relation.Binary.PropositionalEquality using
( Σ-≡⁺ ; Σ-≡⁻ ; Σ-≡⁺∘Σ-≡⁻ ; trans-injectiveˡ )
private
variable
α β γ : Level
A B C : Set α
IsContr : Set α → Set α
IsContr A = Σ[ x ∈ A ] (∀ y → x ≡ y)
IsProp : Set α → Set α
IsProp A = (x y : A) → x ≡ y
IsProp′ : Set α → Set α
IsProp′ A = (x y : A) → IsContr (x ≡ y)
IsProp→IsProp′ : IsProp A → IsProp′ A
IsProp→IsProp′ {A = A} A-prop x y = (A-prop x y) , canon
where
go : (p : x ≡ y) → trans p (A-prop y y) ≡ A-prop x y
go refl = refl
canon : (p : x ≡ y) → A-prop x y ≡ p
canon refl = trans-injectiveˡ (A-prop y y) (go (A-prop y y))
IsProp′→IsProp : IsProp′ A → IsProp A
IsProp′→IsProp A-prop x y = proj₁ (A-prop x y)
IsProp↔IsProp′ : IsProp A ↔ IsProp′ A
IsProp↔IsProp′ .forth = IsProp→IsProp′
IsProp↔IsProp′ .back = IsProp′→IsProp
IsSet : Set α → Set α
IsSet A = {x y : A} → IsProp (x ≡ y)
IsOfHLevel : ℕ → Set α → Set α
IsOfHLevel 0 A = IsContr A
IsOfHLevel 1 A = IsProp A
IsOfHLevel (suc (suc n)) A = {x y : A} → IsOfHLevel (suc n) (x ≡ y)
IsOfHLevel′ : ℕ → Set α → Set α
IsOfHLevel′ zero A = IsContr A
IsOfHLevel′ (suc n) A = ∀ {x y : A} → IsOfHLevel′ n (x ≡ y)
IsOfHLevel′→IsOfHLevel : ∀ n → IsOfHLevel′ n A → IsOfHLevel n A
IsOfHLevel′→IsOfHLevel zero A-contr = A-contr
IsOfHLevel′→IsOfHLevel (suc zero) A-prop = IsProp′→IsProp λ _ _ → A-prop
IsOfHLevel′→IsOfHLevel (suc (suc n)) A-level
= IsOfHLevel′→IsOfHLevel (suc n) A-level
IsOfHLevel→IsOfHLevel′ : ∀ n → IsOfHLevel n A → IsOfHLevel′ n A
IsOfHLevel→IsOfHLevel′ zero A-contr = A-contr
IsOfHLevel→IsOfHLevel′ (suc zero) A-prop = IsProp→IsProp′ A-prop _ _
IsOfHLevel→IsOfHLevel′ (suc (suc n)) A-level
= IsOfHLevel→IsOfHLevel′ (suc n) A-level
IsOfHLevel↔IsOfHLevel′ : ∀ n → IsOfHLevel n A ↔ IsOfHLevel′ n A
IsOfHLevel↔IsOfHLevel′ n .forth = IsOfHLevel→IsOfHLevel′ n
IsOfHLevel↔IsOfHLevel′ n .back = IsOfHLevel′→IsOfHLevel n
IsContr→IsProp : IsContr A → IsProp A
IsContr→IsProp (c , c-canon) x y = trans (sym (c-canon x)) (c-canon y)
IsOfHLevel-suc : ∀ n → IsOfHLevel n A → IsOfHLevel (suc n) A
IsOfHLevel-suc 0 A-contr = IsContr→IsProp A-contr
IsOfHLevel-suc 1 A-prop = IsOfHLevel-suc 0 (IsProp→IsProp′ A-prop _ _)
IsOfHLevel-suc (suc (suc n)) A-level-n = IsOfHLevel-suc (suc n) A-level-n
IsOfHLevel-suc-n : ∀ n m → IsOfHLevel n A → IsOfHLevel (m + n) A
IsOfHLevel-suc-n {A = A} n zero A-level = A-level
IsOfHLevel-suc-n n (suc m) A-level
= IsOfHLevel-suc (m + n) (IsOfHLevel-suc-n n m A-level)
IsProp→IsSet : IsProp A → IsSet A
IsProp→IsSet = IsOfHLevel-suc 1
IsContr→IsSet : IsContr A → IsSet A
IsContr→IsSet = IsOfHLevel-suc-n 0 2
record HLevel α n : Set (lsuc α) where
constructor HLevel⁺
field
type : Set α
level : IsOfHLevel n type
open HLevel public
HContr : ∀ α → Set (lsuc α)
HContr α = HLevel α 0
HProp : ∀ α → Set (lsuc α)
HProp α = HLevel α 1
HSet : ∀ α → Set (lsuc α)
HSet α = HLevel α 2
HLevel-suc : ∀ {α n} → HLevel α n → HLevel α (suc n)
HLevel-suc (HLevel⁺ A A-level) = HLevel⁺ A (IsOfHLevel-suc _ A-level)
⊤-IsContr : IsContr ⊤
⊤-IsContr = _ , λ _ → refl
⊤-IsProp : IsProp ⊤
⊤-IsProp = IsOfHLevel-suc 0 ⊤-IsContr
⊥-IsProp : IsProp ⊥
⊥-IsProp ()
×-IsProp : IsProp A → IsProp B → IsProp (A × B)
×-IsProp A-prop B-prop (x , y) (x′ , y′) = cong₂ _,_ (A-prop _ _) (B-prop _ _)
Lift-IsProp : IsProp A → IsProp (Lift α A)
Lift-IsProp A-prop (lift x) (lift y) = cong lift (A-prop _ _)
⊤-HProp : HProp 0ℓ
⊤-HProp = HLevel⁺ ⊤ ⊤-IsProp
⊥-HProp : HProp 0ℓ
⊥-HProp = HLevel⁺ ⊥ ⊥-IsProp
_×-HProp_ : HProp α → HProp β → HProp (α ⊔ℓ β)
A ×-HProp B = HLevel⁺ (A .type × B .type) (×-IsProp (A .level) (B .level))
Lift-HProp : ∀ α → HProp β → HProp (α ⊔ℓ β)
Lift-HProp α (HLevel⁺ A A-prop) = HLevel⁺ (Lift α A) (Lift-IsProp A-prop)
⊤-IsSet : IsSet ⊤
⊤-IsSet = IsOfHLevel-suc 1 ⊤-IsProp
⊥-IsSet : IsSet ⊥
⊥-IsSet = IsOfHLevel-suc 1 ⊥-IsProp
Σ-IsSet : {A : Set α} {B : A → Set β}
→ IsSet A
→ (∀ a → IsSet (B a))
→ IsSet (Σ A B)
Σ-IsSet A-set B-set p q
= trans (sym (Σ-≡⁺∘Σ-≡⁻ p))
(sym (trans (sym (Σ-≡⁺∘Σ-≡⁻ q))
(cong Σ-≡⁺ (Σ-≡⁺ (A-set _ _ , B-set _ _ _)))))
×-IsSet : IsSet A → IsSet B → IsSet (A × B)
×-IsSet A-set B-set = Σ-IsSet A-set (λ _ → B-set)
Lift-IsSet : IsSet A → IsSet (Lift α A)
Lift-IsSet A-set p q
= trans (sym (Lift-≡⁺∘Lift-≡⁻ p))
(sym (trans (sym (Lift-≡⁺∘Lift-≡⁻ q)) (cong Lift-≡⁺ (A-set _ _))))
where
Lift-≡⁻ : {x y : Lift α A} → x ≡ y → lower x ≡ lower y
Lift-≡⁻ refl = refl
Lift-≡⁺ : {x y : Lift α A} → lower x ≡ lower y → x ≡ y
Lift-≡⁺ refl = refl
Lift-≡⁻∘Lift-≡⁺ : {x y : Lift α A} (p : lower x ≡ lower y)
→ Lift-≡⁻ {α = α} (Lift-≡⁺ p) ≡ p
Lift-≡⁻∘Lift-≡⁺ refl = refl
Lift-≡⁺∘Lift-≡⁻ : {x y : Lift α A} (p : x ≡ y)
→ Lift-≡⁺ {α = α} (Lift-≡⁻ p) ≡ p
Lift-≡⁺∘Lift-≡⁻ refl = refl
⊤-HSet : HSet 0ℓ
⊤-HSet = HLevel⁺ ⊤ ⊤-IsSet
⊥-HSet : HSet 0ℓ
⊥-HSet = HLevel⁺ ⊥ ⊥-IsSet
Σ-HSet : (A : HSet α) (B : A .type → HSet β) → HSet (α ⊔ℓ β)
Σ-HSet A B
= HLevel⁺ (Σ (A .type) λ a → B a .type) (Σ-IsSet (A .level) (λ a → B a .level))
_×-HSet_ : HSet α → HSet β → HSet (α ⊔ℓ β)
A ×-HSet B = HLevel⁺ (A .type × B .type) (×-IsSet (A .level) (B .level))
Lift-HSet : ∀ α → HSet β → HSet (α ⊔ℓ β)
Lift-HSet α (HLevel⁺ B B-set) = HLevel⁺ (Lift α B) (Lift-IsSet B-set)
IsProp∧Pointed→IsContr : IsProp A → (a : A) → IsContr A
IsProp∧Pointed→IsContr A-prop a = a , λ b → A-prop a b
| {
"alphanum_fraction": 0.5998588567,
"avg_line_length": 24.2222222222,
"ext": "agda",
"hexsha": "1b39ec7af391d0011b0a119a5f4178b926a2459e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JLimperg/msc-thesis-code",
"max_forks_repo_path": "src/Util/HoTT/HLevel/Core.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JLimperg/msc-thesis-code",
"max_issues_repo_path": "src/Util/HoTT/HLevel/Core.agda",
"max_line_length": 81,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "104cddc6b65386c7e121c13db417aebfd4b7a863",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JLimperg/msc-thesis-code",
"max_stars_repo_path": "src/Util/HoTT/HLevel/Core.agda",
"max_stars_repo_stars_event_max_datetime": "2021-06-26T06:37:31.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-04-13T21:31:17.000Z",
"num_tokens": 2643,
"size": 5668
} |
{-# OPTIONS --cubical --safe #-}
module Data.Binary.Subtraction where
open import Data.Binary.Definition
open import Data.Nat
double : 𝔹 → 𝔹
double 0ᵇ = 0ᵇ
double (1ᵇ xs) = 2ᵇ double xs
double (2ᵇ xs) = 2ᵇ 1ᵇ xs
dec : 𝔹 → 𝔹
dec 0ᵇ = 0ᵇ
dec (2ᵇ xs) = 1ᵇ xs
dec (1ᵇ xs) = double xs
ones : ℕ → 𝔹 → 𝔹
ones zero xs = xs
ones (suc n) xs = ones n (1ᵇ xs)
fromZ₁ : ℕ → 𝔹 → 𝔹
fromZ₁ n 0ᵇ = 0ᵇ
fromZ₁ n (1ᵇ xs) = 2ᵇ ones n (double xs)
fromZ₁ n (2ᵇ xs) = 2ᵇ ones (suc n) xs
mutual
compl₁′ : ℕ → 𝔹 → 𝔹 → 𝔹
compl₁′ n 0ᵇ _ = 2ᵇ ones n 0ᵇ
compl₁′ n (1ᵇ xs) 0ᵇ = fromZ₁ (suc n) xs
compl₁′ n (2ᵇ xs) 0ᵇ = 2ᵇ ones n (double xs)
compl₁′ n (1ᵇ xs) (1ᵇ ys) = 2ᵇ ones n (compl₁′ 0 xs ys)
compl₁′ n (1ᵇ xs) (2ᵇ ys) = compl₁′ (suc n) xs ys
compl₁′ n (2ᵇ xs) (1ᵇ ys) = compl₂′ (suc n) xs ys
compl₁′ n (2ᵇ xs) (2ᵇ ys) = 2ᵇ ones n (compl₁′ 0 xs ys)
compl₂′ : ℕ → 𝔹 → 𝔹 → 𝔹
compl₂′ n xs 0ᵇ = fromZ₁ n xs
compl₂′ n 0ᵇ _ = 0ᵇ
compl₂′ n (1ᵇ xs) (1ᵇ ys) = compl₂′ (suc n) xs ys
compl₂′ n (1ᵇ xs) (2ᵇ ys) = 2ᵇ ones n (compl₁′ 0 xs ys)
compl₂′ n (2ᵇ xs) (1ᵇ ys) = 2ᵇ ones n (compl₂′ 0 xs ys)
compl₂′ n (2ᵇ xs) (2ᵇ ys) = compl₂′ (suc n) xs ys
mutual
compl₁ : 𝔹 → 𝔹 → 𝔹
compl₁ xs 0ᵇ = dec xs
compl₁ 0ᵇ _ = 1ᵇ 0ᵇ
compl₁ (1ᵇ xs) (1ᵇ ys) = 1ᵇ compl₁ xs ys
compl₁ (1ᵇ xs) (2ᵇ ys) = compl₁′ zero xs ys
compl₁ (2ᵇ xs) (1ᵇ ys) = compl₂′ zero xs ys
compl₁ (2ᵇ xs) (2ᵇ ys) = 1ᵇ compl₁ xs ys
compl₂ : 𝔹 → 𝔹 → 𝔹
compl₂ 0ᵇ _ = 0ᵇ
compl₂ xs 0ᵇ = xs
compl₂ (1ᵇ xs) (1ᵇ ys) = compl₂′ zero xs ys
compl₂ (1ᵇ xs) (2ᵇ ys) = 1ᵇ compl₁ xs ys
compl₂ (2ᵇ xs) (1ᵇ ys) = 1ᵇ compl₂ xs ys
compl₂ (2ᵇ xs) (2ᵇ ys) = compl₂′ zero xs ys
open import Data.Binary.Order
open import Data.Bool
infixl 6 _-_
_-_ : 𝔹 → 𝔹 → 𝔹
n - m = if n ≤ᴮ m then 0ᵇ else compl₂ n m
open import Data.Binary.Testers
open import Path using (refl)
_ : test _-_ _∸_ 30
_ = refl
| {
"alphanum_fraction": 0.5698924731,
"avg_line_length": 26.3918918919,
"ext": "agda",
"hexsha": "b238068d6164c5b194d828e994d8cec4744aeaf0",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-playground",
"max_forks_repo_path": "Data/Binary/Subtraction.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-playground",
"max_issues_repo_path": "Data/Binary/Subtraction.agda",
"max_line_length": 57,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-playground",
"max_stars_repo_path": "Data/Binary/Subtraction.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": 1100,
"size": 1953
} |
{-# OPTIONS --without-K --safe #-}
module Categories.Functor.Groupoid where
open import Level
open import Categories.Category
open import Categories.Category.Groupoid using (Groupoid; IsGroupoid)
open import Categories.Functor
import Categories.Morphism.Reasoning as MR
private
variable
o ℓ e : Level
C D : Category o ℓ e
-- functor respects groupoid inverse
module _ (GC : IsGroupoid C) (GD : IsGroupoid D) (F : Functor C D) where
private
module C = IsGroupoid GC
module D = IsGroupoid GD
open Functor F
open D
open HomReasoning
open MR D
F-resp-inv : ∀ {A B} (f : A C.⇒ B) → F₁ (f C.⁻¹) ≈ (F₁ f) ⁻¹
F-resp-inv f = begin
F₁ (f C.⁻¹) ≈⟨ introˡ D.iso.isoˡ ⟩
((F₁ f) ⁻¹ ∘ F₁ f) ∘ F₁ (f C.⁻¹) ≈˘⟨ pushʳ homomorphism ⟩
(F₁ f) ⁻¹ ∘ F₁ (f C.∘ f C.⁻¹) ≈⟨ elimʳ (F-resp-≈ C.iso.isoʳ ○ identity) ⟩
(F₁ f) ⁻¹ ∎
-- Nevertheless, create a |GrFunctor| that is typed over Groupoid instead of Category
GrFunctor : (A B : Groupoid o ℓ e) → Set _
GrFunctor A B = Functor (category A) (category B)
where open Groupoid
| {
"alphanum_fraction": 0.6232014388,
"avg_line_length": 29.2631578947,
"ext": "agda",
"hexsha": "b072256a20560c1e3ff14ec03366ebc73d26072b",
"lang": "Agda",
"max_forks_count": 64,
"max_forks_repo_forks_event_max_datetime": "2022-03-14T02:00:59.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-06-02T16:58:15.000Z",
"max_forks_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "Code-distancing/agda-categories",
"max_forks_repo_path": "src/Categories/Functor/Groupoid.agda",
"max_issues_count": 236,
"max_issues_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_issues_repo_issues_event_max_datetime": "2022-03-28T14:31:43.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-01T14:53:54.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "Code-distancing/agda-categories",
"max_issues_repo_path": "src/Categories/Functor/Groupoid.agda",
"max_line_length": 85,
"max_stars_count": 279,
"max_stars_repo_head_hexsha": "d9e4f578b126313058d105c61707d8c8ae987fa8",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "Trebor-Huang/agda-categories",
"max_stars_repo_path": "src/Categories/Functor/Groupoid.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": 403,
"size": 1112
} |
{-# OPTIONS --cubical --safe #-}
module Data.Probability where
open import Prelude
import Data.Nat as ℕ
import Data.Nat.Properties as ℕ
open import Data.Bits renaming (Bits to ℚ⁺; [] to 1ℚ; 0∷_ to lℚ; 1∷_ to rℚ)
open import Data.Bits.Equatable
open import Data.Bits.Fold
euclidian : ℕ → ℕ → ℕ → ℚ⁺
euclidian n m zero = 1ℚ
euclidian n m (suc s) =
if n ℕ.≡ᴮ m
then 1ℚ
else if n ℕ.<ᴮ m
then lℚ (euclidian n (m ℕ.∸ (1 ℕ.+ n)) s)
else rℚ (euclidian (n ℕ.∸ (1 ℕ.+ m)) m s)
normalise-suc : ℕ → ℕ → ℚ⁺
normalise-suc n m = euclidian n m (n ℕ.+ m)
data ℙ : Type where
ℙ⁰ : ℙ
ℙ¹ : ℙ
ℙ∙ : ℚ⁺ → ℙ
unEu : ℚ⁺ → ℙ
unEu 1ℚ = ℙ¹
unEu (lℚ x) = ℙ∙ x
unEu (rℚ x) = ℙ¹ -- won't happen
_/suc_ : ℕ → ℕ → ℙ
zero /suc d = ℙ⁰
suc n /suc d = unEu (normalise-suc n d)
_/_ : ℕ → ℕ → ℙ
n / zero = ℙ⁰
n / suc d = n /suc d
zer : (ℕ × ℕ) → (ℕ × ℕ)
zer (p , q) = p , suc p ℕ.+ q
one : (ℕ × ℕ) → (ℕ × ℕ)
one (p , q) = suc p ℕ.+ q , q
norm : (ℕ × ℕ) → ℕ × ℕ
norm (x , y) = suc x , suc y
prob : ℙ → (ℕ × ℕ)
prob ℙ⁰ = 0 , 1
prob ℙ¹ = 1 , 1
prob (ℙ∙ x) = norm (zer (foldr-bits zer one (0 , 0) x))
mul″ : ℙ → ℙ → ℙ
mul″ x y =
let xn , xd = prob x
yn , yd = prob y
in (xn ℕ.* yn) / (xd ℕ.* yd)
-- e = prob (5 /suc 22)
nextFrac : ℚ⁺ → ℚ⁺
nextFrac 1ℚ = lℚ 1ℚ
nextFrac (lℚ x) = rℚ x
nextFrac (rℚ x) = lℚ (nextFrac x)
open import Data.List
fracs : ℕ → List ℙ
fracs n = ℙ⁰ ∷ ℙ¹ ∷ go n 1ℚ
where
go : ℕ → ℚ⁺ → List ℙ
go zero x = []
go (suc n) x = ℙ∙ x ∷ go n (nextFrac x)
open import Data.List.Sugar using (liftA2)
-- mul′ : ℚ⁺ → ℚ⁺ → ℚ⁺
-- mul′ 1ℚ 1ℚ = lℚ (lℚ 1ℚ)
-- mul′ 1ℚ (lℚ ys) = {!!}
-- mul′ 1ℚ (rℚ ys) = {!!}
-- mul′ (lℚ xs) 1ℚ = {!!}
-- mul′ (lℚ xs) (lℚ ys) = {!!}
-- mul′ (lℚ xs) (rℚ ys) = {!!}
-- mul′ (rℚ xs) 1ℚ = {!!}
-- mul′ (rℚ xs) (lℚ ys) = {!!}
-- mul′ (rℚ xs) (rℚ ys) = {!!}
-- mul : ℙ → ℙ → ℙ
-- mul ℙ⁰ ys = ℙ⁰
-- mul ℙ¹ ys = ys
-- mul (ℙ∙ x) ℙ⁰ = ℙ⁰
-- mul xs ℙ¹ = xs
-- mul (ℙ∙ x) (ℙ∙ y) = ℙ∙ (mul′ x y)
-- testMul : ℕ → Type
-- testMul n = liftA2 mul xs xs ≡ liftA2 mul″ xs xs
-- where
-- xs : List ℙ
-- xs = fracs n
-- _ : testMul 5
-- _ = refl
| {
"alphanum_fraction": 0.5102625298,
"avg_line_length": 19.2201834862,
"ext": "agda",
"hexsha": "6c3e6db6f68de1f857ae05b1f405ad343fe415b7",
"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/Probability.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/Probability.agda",
"max_line_length": 75,
"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/Probability.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": 1106,
"size": 2095
} |
{-# OPTIONS --safe #-}
module Relation.Ternary.Separation.Construct.List {a} (A : Set a) where
open import Level
open import Data.Product
open import Data.List
open import Data.List.Properties using (++-isMonoid)
open import Data.List.Relation.Ternary.Interleaving.Propositional as I public
open import Data.List.Relation.Ternary.Interleaving.Properties
open import Data.List.Relation.Binary.Equality.Propositional
open import Data.List.Relation.Binary.Permutation.Inductive
open import Relation.Binary.PropositionalEquality as P hiding ([_])
open import Relation.Unary hiding (_∈_; _⊢_)
open import Relation.Ternary.Separation
private C = List A
instance separation : RawSep C
separation = record { _⊎_≣_ = Interleaving }
-- TODO add to stdlib
interleaving-assoc : ∀ {a b ab c abc : List A} →
Interleaving a b ab → Interleaving ab c abc →
∃ λ bc → Interleaving a bc abc × Interleaving b c bc
interleaving-assoc l (consʳ r) = let _ , p , q = interleaving-assoc l r in -, consʳ p , consʳ q
interleaving-assoc (consˡ l) (consˡ r) = let _ , p , q = interleaving-assoc l r in -, consˡ p , q
interleaving-assoc (consʳ l) (consˡ r) = let _ , p , q = interleaving-assoc l r in -, consʳ p , consˡ q
interleaving-assoc [] [] = [] , [] , []
instance list-has-sep : IsSep separation
list-has-sep = record
{ ⊎-comm = I.swap
; ⊎-assoc = interleaving-assoc
}
instance list-is-unital : IsUnitalSep _ _
IsUnitalSep.isSep list-is-unital = list-has-sep
IsUnitalSep.⊎-idˡ list-is-unital = right (≡⇒≋ P.refl)
IsUnitalSep.⊎-id⁻ˡ list-is-unital [] = refl
IsUnitalSep.⊎-id⁻ˡ list-is-unital (refl ∷ʳ px) = cong (_ ∷_) (⊎-id⁻ˡ px)
instance list-has-concat : IsConcattative separation
IsConcattative._∙_ list-has-concat = _++_
IsConcattative.⊎-∙ₗ list-has-concat {Φₑ = []} ps = ps
IsConcattative.⊎-∙ₗ list-has-concat {Φₑ = x ∷ Φₑ} ps = consˡ (⊎-∙ₗ ps)
instance list-unitalsep : UnitalSep _
list-unitalsep = record
{ isUnitalSep = list-is-unital }
instance list-resource : MonoidalSep _
list-resource = record
{ sep = separation
; isSep = list-has-sep
; isUnitalSep = list-is-unital
; isConcat = list-has-concat
; monoid = ++-isMonoid }
instance list-positive : IsPositive separation
list-positive = record
{ ⊎-εˡ = λ where [] → refl }
| {
"alphanum_fraction": 0.6875805758,
"avg_line_length": 36.9365079365,
"ext": "agda",
"hexsha": "7df6669cd00db583d53e7a773c4cef4361bfbd2c",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2020-05-23T00:34:36.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-01-30T14:15:14.000Z",
"max_forks_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "laMudri/linear.agda",
"max_forks_repo_path": "src/Relation/Ternary/Separation/Construct/List.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "laMudri/linear.agda",
"max_issues_repo_path": "src/Relation/Ternary/Separation/Construct/List.agda",
"max_line_length": 103,
"max_stars_count": 34,
"max_stars_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "laMudri/linear.agda",
"max_stars_repo_path": "src/Relation/Ternary/Separation/Construct/List.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-03T15:22:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-12-20T13:57:50.000Z",
"num_tokens": 779,
"size": 2327
} |
{-# OPTIONS --without-K --exact-split #-}
module quotient-groups where
import subgroups
open subgroups public
{- The left and right coset relation -}
left-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x y : type-Group G) → UU (l1 ⊔ l2)
left-coset-relation G H x =
fib ((mul-Group G x) ∘ (incl-group-Subgroup G H))
right-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x y : type-Group G) → UU (l1 ⊔ l2)
right-coset-relation G H x =
fib ((mul-Group' G x) ∘ (incl-group-Subgroup G H))
{- We show that the left coset relation is an equivalence relation -}
is-prop-left-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x y : type-Group G) → is-prop (left-coset-relation G H x y)
is-prop-left-coset-relation G H x =
is-prop-map-is-emb
( (mul-Group G x) ∘ (incl-group-Subgroup G H))
( is-emb-comp'
( mul-Group G x)
( incl-group-Subgroup G H)
( is-emb-is-equiv (mul-Group G x) (is-equiv-mul-Group G x))
( is-emb-incl-group-Subgroup G H))
is-reflexive-left-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x : type-Group G) → left-coset-relation G H x x
is-reflexive-left-coset-relation G H x =
pair ( unit-group-Subgroup G H)
( right-unit-law-Group G x)
is-symmetric-left-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x y : type-Group G) →
left-coset-relation G H x y → left-coset-relation G H y x
is-symmetric-left-coset-relation G H x y (pair z p) =
pair ( inv-group-Subgroup G H z)
( ap ( λ t → mul-Group G t
( incl-group-Subgroup G H
( inv-group-Subgroup G H z)))
( inv p) ∙
( ( is-associative-mul-Group G _ _ _) ∙
( ( ap (mul-Group G x) (right-inverse-law-Group G _)) ∙
( right-unit-law-Group G x))))
is-transitive-left-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x y z : type-Group G) →
left-coset-relation G H x y → left-coset-relation G H y z →
left-coset-relation G H x z
is-transitive-left-coset-relation G H x y z (pair h1 p1) (pair h2 p2) =
pair ( mul-group-Subgroup G H h1 h2)
( ( inv (is-associative-mul-Group G _ _ _)) ∙
( ( ap (λ t → mul-Group G t (incl-group-Subgroup G H h2)) p1) ∙ p2))
{- We show that the right coset relation is an equivalence relation -}
is-prop-right-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x y : type-Group G) → is-prop (right-coset-relation G H x y)
is-prop-right-coset-relation G H x =
is-prop-map-is-emb
( (mul-Group' G x) ∘ (incl-group-Subgroup G H))
( is-emb-comp'
( mul-Group' G x)
( incl-group-Subgroup G H)
( is-emb-is-equiv (mul-Group' G x) (is-equiv-mul-Group' G x))
( is-emb-incl-group-Subgroup G H))
is-reflexive-right-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x : type-Group G) → right-coset-relation G H x x
is-reflexive-right-coset-relation G H x =
pair ( unit-group-Subgroup G H)
( left-unit-law-Group G x)
is-symmetric-right-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x y : type-Group G) →
right-coset-relation G H x y → right-coset-relation G H y x
is-symmetric-right-coset-relation G H x y (pair z p) =
pair ( inv-group-Subgroup G H z)
( ( ap
( mul-Group G (incl-group-Subgroup G H (inv-group-Subgroup G H z)))
( inv p)) ∙
( ( inv (is-associative-mul-Group G _ _ _)) ∙
( ( ap (λ t → mul-Group G t x) (left-inverse-law-Group G _)) ∙
( left-unit-law-Group G x))))
is-transitive-right-coset-relation :
{l1 l2 : Level} (G : Group l1) (H : Subgroup l2 G) →
(x y z : type-Group G) →
right-coset-relation G H x y → right-coset-relation G H y z →
right-coset-relation G H x z
is-transitive-right-coset-relation G H x y z (pair h1 p1) (pair h2 p2) =
pair ( mul-group-Subgroup G H h2 h1)
( ( is-associative-mul-Group G _ _ _) ∙
( ( ap (mul-Group G (incl-group-Subgroup G H h2)) p1) ∙ p2))
| {
"alphanum_fraction": 0.6001940805,
"avg_line_length": 37.4727272727,
"ext": "agda",
"hexsha": "295cdf7cd7845789e4ba416771b96215abc99bc7",
"lang": "Agda",
"max_forks_count": 30,
"max_forks_repo_forks_event_max_datetime": "2022-03-16T00:33:50.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-09-26T09:08:57.000Z",
"max_forks_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9",
"max_forks_repo_licenses": [
"CC-BY-4.0"
],
"max_forks_repo_name": "UlrikBuchholtz/HoTT-Intro",
"max_forks_repo_path": "Agda/quotient-groups.agda",
"max_issues_count": 8,
"max_issues_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9",
"max_issues_repo_issues_event_max_datetime": "2020-10-16T15:27:01.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-06-18T04:16:04.000Z",
"max_issues_repo_licenses": [
"CC-BY-4.0"
],
"max_issues_repo_name": "UlrikBuchholtz/HoTT-Intro",
"max_issues_repo_path": "Agda/quotient-groups.agda",
"max_line_length": 78,
"max_stars_count": 333,
"max_stars_repo_head_hexsha": "1e1f8def50f9359928e52ebb2ee53ed1166487d9",
"max_stars_repo_licenses": [
"CC-BY-4.0"
],
"max_stars_repo_name": "UlrikBuchholtz/HoTT-Intro",
"max_stars_repo_path": "Agda/quotient-groups.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-22T23:50:15.000Z",
"max_stars_repo_stars_event_min_datetime": "2018-09-26T08:33:30.000Z",
"num_tokens": 1508,
"size": 4122
} |
-- Andreas, May - July 2016, implementing postfix projections
module Issue1963 where
module Prod where
record Σ (A : Set) (B : A → Set) : Set where
field fst : A
snd : B fst
open Σ
test : ∀{A} → A → Σ A λ _ → A
test = λ where
x .fst → x
x .snd → x
module Stream where
record Stream (A : Set) : Set where
coinductive
field head : A
tail : Stream A
open Stream
repeat : ∀{A} (a : A) → Stream A
repeat a .head = a
repeat a. tail = repeat a
zipWith : ∀{A B C} (f : A → B → C) (s : Stream A) (t : Stream B) → Stream C
zipWith f s t .head = f (s .head) (t .head)
zipWith f s t .tail = zipWith f (s .tail) (t .tail)
module Fib (Nat : Set) (zero one : Nat) (plus : Nat → Nat → Nat) where
{-# TERMINATING #-}
fib : Stream Nat
fib .head = zero
fib .tail .head = one
fib .tail .tail = zipWith plus fib (fib .tail)
| {
"alphanum_fraction": 0.5604883463,
"avg_line_length": 21.4523809524,
"ext": "agda",
"hexsha": "ab965b194c45e8570e97c67772e99c70a478c5f1",
"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/Issue1963.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/Issue1963.agda",
"max_line_length": 77,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/Succeed/Issue1963.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": 315,
"size": 901
} |
-- Omniscience principles
-- https://ncatlab.org/nlab/show/principle+of+omniscience
-- http://math.fau.edu/lubarsky/Separating%20LLPO.pdf
-- https://arxiv.org/pdf/1804.05495.pdf
-- https://www.cs.bham.ac.uk/~mhe/papers/omniscient-journal-revised.pdf
-- https://www.jaist.ac.jp/~t-nemoto/WMP.pdf
-- http://math.fau.edu/lubarsky/Separating%20LLPO.pdf
-- TODO
-- WKL: weak Koning's lemma
-- BE: Every real number in [0,1] has binary expansion
-- IVT: intermediate value theorem
-- BD-N
-- LLPOₙ
-- WKL <=> LLPO
{-# OPTIONS --without-K --safe --exact-split #-}
module Constructive.Axiom where
-- agda-stdlib
open import Level renaming (suc to lsuc; zero to lzero)
open import Data.Bool using (Bool; true; false)
open import Data.Empty using (⊥)
open import Data.Sum as Sum
open import Data.Product as Prod
open import Data.List using (List; []; _∷_; length)
open import Data.List.Relation.Binary.Prefix.Heterogeneous using (Prefix)
open import Data.Nat using (ℕ; _≤_; _<_; _+_; _*_)
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary using (¬_; Dec; yes; no)
open import Relation.Nullary.Decidable using (⌊_⌋)
open import Function
-- agda-misc
open import Constructive.Common
open import TypeTheory.HoTT.Base using (isProp)
---------------------------------------------------------------------------
-- Axioms
-- -i indicates instance
-- Law of Excluded middle
-- LEM
EM : ∀ a → Set (lsuc a)
EM a = ∀ {A : Set a} → Dec⊎ A
-- Double negation elimination
DNE : ∀ a → Set (lsuc a)
DNE a = ∀ {A : Set a} → Stable A
-- Peirce's law
Peirce-i : ∀ {a b} → Set a → Set b → Set (a ⊔ b)
Peirce-i A B = ((A → B) → A) → A
Peirce : ∀ a b → Set (lsuc (a ⊔ b))
Peirce a b = {A : Set a} {B : Set b} → Peirce-i A B
-- Material implication
MI-i : ∀ {a b} → Set a → Set b → Set (a ⊔ b)
MI-i A B = (A → B) → ¬ A ⊎ B
MI : ∀ a b → Set (lsuc (a ⊔ b))
MI a b = {A : Set a} {B : Set b} → MI-i A B
-- De Morgan's laws
-- DML
DEM₁-i : ∀ {a b} → Set a → Set b → Set (a ⊔ b)
DEM₁-i A B = ¬ (¬ A × ¬ B) → A ⊎ B
DEM₂-i : ∀ {a b} → Set a → Set b → Set (a ⊔ b)
DEM₂-i A B = ¬ (¬ A ⊎ ¬ B) → A × B
DEM₃-i : ∀ {a b} → Set a → Set b → Set (a ⊔ b)
DEM₃-i A B = ¬ (A × B) → ¬ A ⊎ ¬ B
DEM₁ : ∀ a b → Set (lsuc (a ⊔ b))
DEM₁ a b = {A : Set a} {B : Set b} → DEM₁-i A B
DEM₂ : ∀ a b → Set (lsuc (a ⊔ b))
DEM₂ a b = {A : Set a} {B : Set b} → DEM₂-i A B
DEM₃ : ∀ a b → Set (lsuc (a ⊔ b))
DEM₃ a b = {A : Set a} {B : Set b} → DEM₃-i A B
-- call/cc
Call/CC-i : ∀ {a} → Set a → Set a
Call/CC-i A = Peirce-i A ⊥
Call/CC : ∀ a → Set (lsuc a)
Call/CC a = ∀ {A : Set a} → Call/CC-i A
-- Gödel-Dummett logic
-- Dirk Gently's Principle (DGP)
DGP-i : ∀ {a b} → Set a → Set b → Set (a ⊔ b)
DGP-i A B = (A → B) ⊎ (B → A)
DGP : ∀ a b → Set (lsuc (a ⊔ b))
DGP a b = {A : Set a} {B : Set b} → DGP-i A B
-- Weak excluded middle
-- https://ncatlab.org/nlab/show/weak+excluded+middle
-- WLEM WPEM
WEM-i : ∀ {a} → Set a → Set a
WEM-i A = Dec⊎ (¬ A)
WEM : ∀ a → Set (lsuc a)
WEM a = {A : Set a} → WEM-i A
-- Double-negation shift
-- if domain of P is finite this can be proved.
-- https://ncatlab.org/nlab/show/double-negation+shift
DNS-i : ∀ {a p} {A : Set a} → (A → Set p) → Set (a ⊔ p)
DNS-i P = (∀ x → ¬ ¬ P x) → ¬ ¬ (∀ x → P x)
DNS : ∀ {a} (A : Set a) p → Set (a ⊔ lsuc p)
DNS A p = {P : A → Set p} → DNS-i P
-- Independence-of-premise
IP : ∀ p q r → Set (lsuc (p ⊔ q ⊔ r))
IP p q r = ∀ {P : Set p} {Q : Set q} {R : Q → Set r} →
Q → (P → Σ Q R) → (Σ Q λ x → (P → R x))
private
toPred : ∀ {a} {A : Set a} → (A → Bool) → (A → Set)
toPred P x = P x ≡ true
-- Searchable set
Searchable-i : ∀ {a p} {A : Set a} → (A → Set p) → Set (a ⊔ p)
Searchable-i P = DecU P → (∃ λ x₀ → P x₀ → ∀ x → P x)
Searchable : ∀ {a} (A : Set a) p → Set (a ⊔ lsuc p)
Searchable A p = {P : A → Set p} → Searchable-i P
Searchable-Bool : ∀ {a} → Set a → Set a
Searchable-Bool A = Σ ((A → Bool) → A)
λ ε → (P : A → Bool) → P (ε P) ≡ true → (x : A) → P x ≡ true
-- The limited principle of omniscience
-- https://ncatlab.org/nlab/show/principle+of+omniscience
-- Omniscient type
LPO-i : ∀ {a p} {A : Set a} → (A → Set p) → Set (a ⊔ p)
LPO-i P = DecU P → ∃ P ⊎ ¬ ∃ P
LPO : ∀ {a} (A : Set a) p → Set (a ⊔ lsuc p)
LPO A p = {P : A → Set p} → LPO-i P
LPO-Bool-i : ∀ {a} {A : Set a} → (A → Bool) → Set a
LPO-Bool-i P = ∃ (toPred P) ⊎ ¬ ∃ (toPred P)
LPO-Bool : ∀ {a} → Set a → Set a
LPO-Bool A = (P : A → Bool) → LPO-Bool-i P
-- http://www.cs.bham.ac.uk/~mhe/papers/omniscient-2011-07-06.pdf
LPO-Bool-Alt-i : ∀ {a} {A : Set a} → (A → Bool) → Set a
LPO-Bool-Alt-i P = (∃ λ x → P x ≡ false) ⊎ (∀ x → P x ≡ true)
LPO-Bool-Alt : ∀ {a} → Set a → Set a
LPO-Bool-Alt A = (P : A → Bool) → LPO-Bool-Alt-i P
-- Weak limited principle of omniscience
-- https://www.cs.bham.ac.uk/~mhe/papers/omniscient-journal-revised.pdf
-- http://math.fau.edu/lubarsky/Separating%20LLPO.pdf
-- ∀-PEM
WLPO-i : ∀ {a p} {A : Set a} → (A → Set p) → Set (a ⊔ p)
WLPO-i P = DecU P → (∀ x → P x) ⊎ ¬ (∀ x → P x)
WLPO : ∀ {a} (A : Set a) p → Set (a ⊔ lsuc p)
WLPO A p = {P : A → Set p} → WLPO-i P
-- Alternative form of WLPO
WLPO-Alt-i : ∀ {a p} {A : Set a} → (A → Set p) → Set (a ⊔ p)
WLPO-Alt-i P = DecU P → ¬ ∃ P ⊎ ¬ ¬ ∃ P
WLPO-Alt : ∀ {a} (A : Set a) p → Set (a ⊔ lsuc p)
WLPO-Alt A p = {P : A → Set p} → WLPO-Alt-i P
-- The lesser limited principle of omniscience
-- Σ⁰₁-DML
LLPO-i : ∀ {a p} {A : Set a} → (P Q : A → Set p) → Set (a ⊔ p)
LLPO-i P Q = DecU P → DecU Q → ¬ (∃ P × ∃ Q) → ¬ ∃ P ⊎ ¬ ∃ Q
LLPO : ∀ {a} (A : Set a) p → Set (a ⊔ lsuc p)
LLPO A p = {P Q : A → Set p} → LLPO-i P Q
LLPO-Alt-i : ∀ {a p} {A : Set a} → (P Q : A → Set p) → Set (a ⊔ p)
LLPO-Alt-i P Q = DecU P → DecU Q →
¬ ¬ ((∀ x → P x) ⊎ (∀ x → Q x)) → (∀ x → P x) ⊎ (∀ x → Q x)
LLPO-Alt : ∀ {a} (A : Set a) p → Set (a ⊔ lsuc p)
LLPO-Alt A p = {P Q : A → Set p} → LLPO-Alt-i P Q
LLPO-Bool-i : ∀ {a} {A : Set a} → (P Q : A → Bool) → Set a
LLPO-Bool-i P Q = ¬ (∃ (toPred P) × ∃ (toPred Q)) → ¬ ∃ (toPred P) ⊎ ¬ ∃ (toPred Q)
LLPO-Bool : ∀ {a} → Set a → Set a
LLPO-Bool A = (P Q : A → Bool) → LLPO-Bool-i P Q
LLPO-ℕ : ∀ p → Set (lsuc p)
LLPO-ℕ p = {P : ℕ → Set p} → DecU P → (∀ m n → m ≢ n → P m ⊎ P n) →
(∀ n → P (2 * n)) ⊎ (∀ n → P (1 + 2 * n))
-- Markov's principle
-- LPE
-- https://ncatlab.org/nlab/show/Markov%27s+principle
MP-i : ∀ {a p} {A : Set a} → (A → Set p) → Set (a ⊔ p)
MP-i P = DecU P → ¬ (∀ x → P x) → ∃ λ x → ¬ P x
MP : ∀ {a} (A : Set a) p → Set (a ⊔ lsuc p)
MP A p = {P : A → Set p} → MP-i P
-- Markov's rule
MR-i : ∀ {a p} {A : Set a} → (A → Set p) → Set (a ⊔ p)
MR-i P = DecU P → ¬ ¬ ∃ P → ∃ P
MR : ∀ {a} (A : Set a) p → Set (a ⊔ lsuc p)
MR A p = {P : A → Set p} → MR-i P
-- Weak Markov's principle
-- https://ncatlab.org/nlab/show/Markov%27s+principle
WMP-i : ∀ {a p} {A : Set a} → (A → Set p) → Set (a ⊔ lsuc p)
WMP-i {p = p} {A = A} P =
DecU P →
({Q : A → Set p} → DecU Q → ¬ ¬ ∃ Q ⊎ (¬ ¬ ∃ λ x → P x × ¬ Q x)) →
∃ P
WMP : ∀ {a} (A : Set a) p → Set (a ⊔ lsuc p)
WMP A p = {P : A → Set p} → WMP-i P
WMP-Bool-i : ∀ {a} {A : Set a} → (A → Bool) → Set a
WMP-Bool-i {A = A} P =
((Q : A → Bool) →
¬ ¬ ∃ (λ x → Q x ≡ true) ⊎ (¬ ¬ ∃ λ x → P x ≡ true × Q x ≢ true)) →
∃ λ x → P x ≡ true
WMP-Bool : ∀ {a} (A : Set a) → Set a
WMP-Bool A = (P : A → Bool) → WMP-Bool-i P
-- Disjunctive Markov’s principle
MP⊎-i : ∀ {a p} {A : Set a} → (P Q : A → Set p) → Set (a ⊔ p)
MP⊎-i P Q = DecU P → DecU Q → ¬ (¬ ∃ P × ¬ ∃ Q) → ¬ ¬ ∃ P ⊎ ¬ ¬ ∃ Q
MP⊎ : ∀ {a} (A : Set a) p → Set (a ⊔ lsuc p)
MP⊎ A p = {P Q : A → Set p} → MP⊎-i P Q
MP⊎-Bool-i : ∀ {a} {A : Set a} → (P Q : A → Bool) → Set a
MP⊎-Bool-i P Q = ¬ (¬ ∃ (toPred P) × ¬ ∃ (toPred Q)) →
¬ ¬ ∃ (toPred P) ⊎ ¬ ¬ ∃ (toPred Q)
MP⊎-Bool : ∀ {a} → Set a → Set a
MP⊎-Bool A = (P Q : A → Bool) → MP⊎-Bool-i P Q
MP⊎-Alt-i : ∀ {a p} {A : Set a} → (P Q : A → Set p) → Set (a ⊔ p)
MP⊎-Alt-i P Q = DecU P → DecU Q →
¬ ((∀ x → P x) × (∀ x → Q x)) → ¬ (∀ x → P x) ⊎ ¬ (∀ x → Q x)
MP⊎-Alt : ∀ {a} (A : Set a) p → Set (a ⊔ lsuc p)
MP⊎-Alt A p = {P Q : A → Set p} → MP⊎-Alt-i P Q
MP∨-i : ∀ {a p} {A : Set a} → (P Q : A → Set p) → Set (a ⊔ p)
MP∨-i P Q = DecU P → DecU Q →
¬ ¬ (∃ λ x → P x ⊎ Q x) → ¬ ¬ ∃ P ⊎ ¬ ¬ ∃ Q
MP∨ : ∀ {a} (A : Set a) p → Set (a ⊔ lsuc p)
MP∨ A p = {P Q : A → Set p} → MP∨-i P Q
-- Σ-DGP
-- Equivalent to LLPO
Σ-DGP-i : ∀ {a p} {A : Set a} (P Q : A → Set p) → Set (a ⊔ p)
Σ-DGP-i P Q = DecU P → DecU Q → DGP-i (∃ P) (∃ Q)
Σ-DGP : ∀ {a} (A : Set a) p → Set (a ⊔ lsuc p)
Σ-DGP A p = {P Q : A → Set p} → Σ-DGP-i P Q
-- Π-DGP
Π-DGP-i : ∀ {a p} {A : Set a} (P Q : A → Set p) → Set (a ⊔ p)
Π-DGP-i P Q = DecU P → DecU Q → DGP-i (∀ x → P x) (∀ x → Q x)
Π-DGP : ∀ {a} (A : Set a) p → Set (a ⊔ lsuc p)
Π-DGP A p = {P Q : A → Set p} → Π-DGP-i P Q
-- Σ-Π-DGP
Σ-Π-DGP-i : ∀ {a p} {A : Set a} (P Q : A → Set p) → Set (a ⊔ p)
Σ-Π-DGP-i P Q = DecU P → DecU Q → DGP-i (∃ P) (∀ x → Q x)
Σ-Π-DGP : ∀ {a} (A : Set a) p → Set (a ⊔ lsuc p)
Σ-Π-DGP A p = {P Q : A → Set p} → Σ-Π-DGP-i P Q
-- Σ-Call/CC
Σ-Call/CC-i : ∀ {a p} {A : Set a} (P : A → Set p) → Set (a ⊔ p)
Σ-Call/CC-i P = DecU P → Call/CC-i (∃ P)
Σ-Call/CC : ∀ {a} (A : Set a) p → Set (a ⊔ lsuc p)
Σ-Call/CC A p = {P : A → Set p} → Σ-Call/CC-i P
-- Σ-Σ-Peirce
Σ-Σ-Peirce-i : ∀ {a p} {A : Set a} (P Q : A → Set p) → Set (a ⊔ p)
Σ-Σ-Peirce-i P Q = DecU P → DecU Q → Peirce-i (∃ P) (∃ Q)
Σ-Σ-Peirce : ∀ {a} (A : Set a) p → Set (a ⊔ lsuc p)
Σ-Σ-Peirce A p = {P Q : A → Set p} → Σ-Σ-Peirce-i P Q
-- Σ-Π-Peirce
Σ-Π-Peirce-i : ∀ {a p} {A : Set a} (P Q : A → Set p) → Set (a ⊔ p)
Σ-Π-Peirce-i P Q = DecU P → DecU Q → Peirce-i (∃ P) (∀ x → Q x)
Σ-Π-Peirce : ∀ {a} (A : Set a) p → Set (a ⊔ lsuc p)
Σ-Π-Peirce A p = {P Q : A → Set p} → Σ-Π-Peirce-i P Q
-- Kripke's Schema
KS : ∀ {a} (A : Set a) p q → Set (a ⊔ lsuc p ⊔ lsuc q)
KS A p q = ∀ (P : Set p) → Σ (A → Set q) λ Q → DecU Q × (P <=> ∃ Q)
-- Principle of Finite Possiblity
-- Principle of inverse Decision (PID)
PFP : ∀ {a} (A : Set a) p q → Set (a ⊔ lsuc p ⊔ lsuc q)
PFP A p q = {P : A → Set p} → DecU P →
Σ (A → Set q) λ Q → DecU Q × ((∀ x → P x) <=> ∃ Q)
PFP-Bool-ℕ : Set
PFP-Bool-ℕ =
(α : ℕ → Bool) →
Σ (ℕ → Bool) (λ β → (∀ n → α n ≡ false) <=> ∃ λ n → β n ≡ true)
-- Weak Principle of Finite Possiblity
WPFP : ∀ {a} (A : Set a) p q → Set (a ⊔ lsuc p ⊔ lsuc q)
WPFP A p q = {P : A → Set p} → DecU P →
Σ (A → Set q) λ Q → DecU Q × ((∀ x → P x) <=> (¬ (∀ x → Q x)))
WPFP-Bool-ℕ : Set
WPFP-Bool-ℕ =
(α : ℕ → Bool) →
Σ (ℕ → Bool) λ β → (∀ n → α n ≡ false) <=> (¬ (∀ n → β n ≡ false))
-- https://plato.stanford.edu/entries/axiom-choice/choice-and-type-theory.html
ACLT : ∀ {a b} → Set a → Set b → ∀ p → Set (a ⊔ b ⊔ lsuc p)
ACLT A B p = {P : A → B → Set p} →
((x : A) → ∃ λ y → P x y) → Σ (A → B) λ f → (x : A) → P x (f x)
-- HoTT
EM⁻¹ : ∀ a → Set (lsuc a)
EM⁻¹ a = {A : Set a} → isProp A → Dec⊎ A
DNE⁻¹ : ∀ a → Set (lsuc a)
DNE⁻¹ a = {A : Set a} → isProp A → Stable A
-- WKL
takeT : ℕ → (ℕ → Bool) → List Bool
takeT ℕ.zero α = []
takeT (ℕ.suc n) α = α 0 ∷ takeT n (λ m → α (ℕ.suc m))
-- "THE WEAK KONIG LEMMA, BROUWER’S FAN THEOREM, DE MORGAN’S LAW, AND DEPENDENT CHOICE"
2^Bool* : Set₁
2^Bool* = List Bool → Set
IsDetachable : 2^Bool* → Set
IsDetachable T = DecU T
-- closed under restrictions
IsClosed : 2^Bool* → Set
IsClosed T = ∀ u v → Prefix _≡_ v u → T u → T v
IsInfinite : 2^Bool* → Set
IsInfinite T = ∀ n → ∃ λ u → T u × n ≡ length u
IsFinite : 2^Bool* → Set
IsFinite T = ∃ λ n → ∀ u → ¬ T u × n ≡ length u
IsWellFounded : 2^Bool* → Set
IsWellFounded T = Σ (ℕ → Bool) λ α → ∃ λ n → ¬ T (takeT n α)
HasInfinitePath : 2^Bool* → Set
HasInfinitePath T = Σ (ℕ → Bool) λ α → ∀ n → T (takeT n α)
IsTree : 2^Bool* → Set
IsTree T = IsDetachable T × IsClosed T
-- Weak Kőnig Lemma
WKL : Set₁
WKL = ∀ T → IsTree T → IsInfinite T → HasInfinitePath T
-- Brouwer’s Fan Theorem
FAN : Set₁
FAN = ∀ T → IsTree T → IsWellFounded T → IsFinite T
-- BD-N
Peseudobounded : (ℕ → Set) → Set
Peseudobounded S = (s : ℕ → ℕ) → (∀ n → S (s n)) → ∃ λ N → s N < N
| {
"alphanum_fraction": 0.4992097163,
"avg_line_length": 30.7442455243,
"ext": "agda",
"hexsha": "752adfaa036a08266a039e2f5e8d63931a944995",
"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": "Constructive/Axiom.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": "Constructive/Axiom.agda",
"max_line_length": 87,
"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": "Constructive/Axiom.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": 5571,
"size": 12021
} |
{-# OPTIONS --without-K --safe #-}
module Cats.Category.Fun.Facts.Terminal where
open import Cats.Category.Base
open import Cats.Category.Constructions.Terminal using (HasTerminal)
open import Cats.Category.Fun using (_↝_ ; ≈-intro)
open import Cats.Functor using (Functor)
open import Cats.Functor.Const using (Const)
open Functor
instance
hasTerminal : ∀ {lo la l≈ lo′ la′ l≈′}
→ {C : Category lo la l≈} {D : Category lo′ la′ l≈′}
→ {{_ : HasTerminal D}}
→ HasTerminal (C ↝ D)
hasTerminal {C = C} {D = D} {{D⊤}} = record
{ ⊤ = Const C ⊤
; isTerminal = λ X → record
{ arr = record
{ component = λ c → ! (fobj X c)
; natural = λ {c} {d} {f} → ⇒⊤-unique _ _
}
; unique = λ _ → ≈-intro (⇒⊤-unique _ _)
}
}
where
open HasTerminal D⊤
| {
"alphanum_fraction": 0.5847665848,
"avg_line_length": 27.1333333333,
"ext": "agda",
"hexsha": "7efc9e3a0ca49a51d077fd6d3c35b5da424abd80",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-18T15:35:07.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-18T15:35:07.000Z",
"max_forks_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "JLimperg/cats",
"max_forks_repo_path": "Cats/Category/Fun/Facts/Terminal.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "JLimperg/cats",
"max_issues_repo_path": "Cats/Category/Fun/Facts/Terminal.agda",
"max_line_length": 68,
"max_stars_count": 24,
"max_stars_repo_head_hexsha": "1ad7b243acb622d46731e9ae7029408db6e561f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "JLimperg/cats",
"max_stars_repo_path": "Cats/Category/Fun/Facts/Terminal.agda",
"max_stars_repo_stars_event_max_datetime": "2021-08-06T05:00:46.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-11-03T15:18:57.000Z",
"num_tokens": 273,
"size": 814
} |
open import Common.Bool
open import Common.Nat
data cheesy : Bool → Set where
chocolate : cheesy false
cheese : cheesy true
bread : ∀ x → cheesy x
foo : ∀ {x : Bool} → cheesy x → cheesy x → Bool
foo x chocolate = {!!}
foo x cheese = {!!}
foo x (bread false) = {!x!}
foo x (bread true) = {!!}
| {
"alphanum_fraction": 0.6091205212,
"avg_line_length": 21.9285714286,
"ext": "agda",
"hexsha": "8b9d6a4e3d3d45dc261f82fbd4a52af80aa7a867",
"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/Issue2609.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/Issue2609.agda",
"max_line_length": 47,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/interaction/Issue2609.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": 91,
"size": 307
} |
module Sessions.Syntax where
open import Sessions.Syntax.Types public
open import Sessions.Syntax.Expr public
open import Sessions.Syntax.Values public
| {
"alphanum_fraction": 0.8496732026,
"avg_line_length": 25.5,
"ext": "agda",
"hexsha": "a9472370210382590533070beb8e3af40de2a892",
"lang": "Agda",
"max_forks_count": 2,
"max_forks_repo_forks_event_max_datetime": "2020-05-23T00:34:36.000Z",
"max_forks_repo_forks_event_min_datetime": "2020-01-30T14:15:14.000Z",
"max_forks_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "laMudri/linear.agda",
"max_forks_repo_path": "src/Sessions/Syntax.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "laMudri/linear.agda",
"max_issues_repo_path": "src/Sessions/Syntax.agda",
"max_line_length": 41,
"max_stars_count": 34,
"max_stars_repo_head_hexsha": "461077552d88141ac1bba044aa55b65069c3c6c0",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "laMudri/linear.agda",
"max_stars_repo_path": "src/Sessions/Syntax.agda",
"max_stars_repo_stars_event_max_datetime": "2021-02-03T15:22:33.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-12-20T13:57:50.000Z",
"num_tokens": 26,
"size": 153
} |
module Data.Num.Bij.Convert where
open import Data.Num.Bij
open import Data.Num.Bij.Properties
open import Data.List hiding ([_])
open import Relation.Binary
open import Data.Nat using (ℕ; zero; suc; _+_; _*_)
open import Data.Product
open import Data.Nat.Properties
open import Data.Nat.Properties.Simple
open import Data.Nat.Etc
open import Relation.Nullary.Negation using (contradiction; contraposition)
open import Relation.Binary.PropositionalEquality as PropEq
using (_≡_; _≢_; refl; sym; cong; trans)
open PropEq.≡-Reasoning
import Level
{-
-- to ℕ, instance of Conversion
instance convNat : Conversion ℕ
convNat = conversion [_]' !_!'
where [_]' : ℕ → Bij
[ zero ]' = []
[ suc n ]' = incrB [ n ]'
!_!' : Bij → ℕ
! [] !' = 0
! one ∷ xs !' = 1 + 2 * ! xs !'
! two ∷ xs !' = 2 + 2 * ! xs !'
-}
-- Digit ⇒ ℕ
D[_]ℕ : DigitB → ℕ
D[ one ]ℕ = 1
D[ two ]ℕ = 2
-- ℕ ⇔ Bij
[_]B : ℕ → Bij
[ zero ]B = []
[ suc n ]B = incrB [ n ]B
[_]ℕ : Bij → ℕ
[ [] ]ℕ = 0
[ one ∷ xs ]ℕ = 1 + 2 * [ xs ]ℕ
[ two ∷ xs ]ℕ = 2 + 2 * [ xs ]ℕ
-- properties
[]ℕ-∷-hom : ∀ x xs → [ x ∷ xs ]ℕ ≡ D[ x ]ℕ + 2 * [ xs ]ℕ
[]ℕ-∷-hom one _ = refl
[]ℕ-∷-hom two _ = refl
[]ℕ-incrB-hom : ∀ xs → [ incrB xs ]ℕ ≡ suc [ xs ]ℕ
[]ℕ-incrB-hom [] = refl
[]ℕ-incrB-hom (one ∷ xs) = refl
[]ℕ-incrB-hom (two ∷ xs) =
begin
suc (2 * [ incrB xs ]ℕ)
≡⟨ cong (λ x → suc (2 * x)) ([]ℕ-incrB-hom xs) ⟩
suc (suc ([ xs ]ℕ + suc ([ xs ]ℕ + 0)))
≡⟨ cong (λ x → suc (suc x)) (+-suc [ xs ]ℕ ([ xs ]ℕ + 0)) ⟩
suc (suc (suc (2 * [ xs ]ℕ)))
∎
[]ℕ-+B-hom : ∀ xs ys → [ xs +B ys ]ℕ ≡ [ xs ]ℕ + [ ys ]ℕ
[]ℕ-+B-hom [] ys = refl
[]ℕ-+B-hom (x ∷ xs) [] = sym (+-right-identity [ x ∷ xs ]ℕ)
[]ℕ-+B-hom (one ∷ xs) (one ∷ ys) =
begin
2 + 2 * [ xs +B ys ]ℕ
≡⟨ cong (λ x → 2 + 2 * x) ([]ℕ-+B-hom xs ys) ⟩
2 + 2 * ([ xs ]ℕ + [ ys ]ℕ)
≡⟨ cong (λ x → 2 + x) (distrib-left-*-+ 2 [ xs ]ℕ [ ys ]ℕ) ⟩
2 + (2 * [ xs ]ℕ + 2 * [ ys ]ℕ)
≡⟨ cong suc (sym (+-suc (2 * [ xs ]ℕ) (2 * [ ys ]ℕ))) ⟩
suc (2 * [ xs ]ℕ + suc (2 * [ ys ]ℕ))
∎
[]ℕ-+B-hom (one ∷ xs) (two ∷ ys) =
begin
1 + 2 * [ incrB (xs +B ys) ]ℕ
≡⟨ cong (λ x → 1 + 2 * x) ([]ℕ-incrB-hom (xs +B ys)) ⟩
1 + 2 * (1 + [ xs +B ys ]ℕ)
≡⟨ cong (λ x → 1 + 2 * (1 + x)) ([]ℕ-+B-hom xs ys) ⟩
1 + 2 * suc ([ xs ]ℕ + [ ys ]ℕ)
≡⟨ cong suc (+-*-suc 2 ([ xs ]ℕ + [ ys ]ℕ)) ⟩
1 + (2 + 2 * ([ xs ]ℕ + [ ys ]ℕ))
≡⟨ cong (λ x → 1 + (2 + x)) (distrib-left-*-+ 2 [ xs ]ℕ [ ys ]ℕ) ⟩
1 + (2 + 2 * [ xs ]ℕ + 2 * [ ys ]ℕ)
≡⟨ cong (λ x → 1 + (x + 2 * [ ys ]ℕ)) (+-comm 2 (2 * [ xs ]ℕ)) ⟩
1 + (2 * [ xs ]ℕ + 2 + 2 * [ ys ]ℕ)
≡⟨ cong suc (+-assoc (2 * [ xs ]ℕ) 2 (2 * [ ys ]ℕ)) ⟩
1 + (2 * [ xs ]ℕ + (2 + (2 * [ ys ]ℕ)))
∎
[]ℕ-+B-hom (two ∷ xs) (one ∷ ys) =
begin
suc (2 * [ incrB (xs +B ys) ]ℕ)
≡⟨ cong (λ x → suc (2 * x)) ([]ℕ-incrB-hom (xs +B ys)) ⟩
suc (2 * suc [ xs +B ys ]ℕ)
≡⟨ cong (λ x → suc (2 * suc x)) ([]ℕ-+B-hom xs ys) ⟩
suc (2 * suc ([ xs ]ℕ + [ ys ]ℕ))
≡⟨ cong suc (+-*-suc 2 ([ xs ]ℕ + [ ys ]ℕ)) ⟩
suc (2 + 2 * ([ xs ]ℕ + [ ys ]ℕ))
≡⟨ cong (λ x → suc (2 + x)) (distrib-left-*-+ 2 [ xs ]ℕ [ ys ]ℕ) ⟩
suc (2 + 2 * [ xs ]ℕ + 2 * [ ys ]ℕ)
≡⟨ cong (λ x → suc (suc x)) (sym (+-suc (2 * [ xs ]ℕ) (2 * [ ys ]ℕ))) ⟩
suc (suc (2 * [ xs ]ℕ + suc (2 * [ ys ]ℕ)))
∎
[]ℕ-+B-hom (two ∷ xs) (two ∷ ys) =
begin
2 + (2 * [ incrB (xs +B ys) ]ℕ)
≡⟨ cong (λ x → 2 + (2 * x)) ([]ℕ-incrB-hom (xs +B ys)) ⟩
2 + (2 * suc [ xs +B ys ]ℕ)
≡⟨ cong (λ x → 2 + 2 * suc x) ([]ℕ-+B-hom xs ys) ⟩
2 + (2 * suc ([ xs ]ℕ + [ ys ]ℕ))
≡⟨ cong (λ x → 2 + x) (+-*-suc 2 ([ xs ]ℕ + [ ys ]ℕ)) ⟩
2 + (2 + 2 * ([ xs ]ℕ + [ ys ]ℕ))
≡⟨ cong (λ x → 2 + (2 + x)) (distrib-left-*-+ 2 [ xs ]ℕ [ ys ]ℕ) ⟩
2 + (2 + 2 * [ xs ]ℕ + 2 * [ ys ]ℕ)
≡⟨ cong (λ x → 2 + (x + 2 * [ ys ]ℕ)) (+-comm 2 (2 * [ xs ]ℕ)) ⟩
2 + (2 * [ xs ]ℕ + 2 + 2 * [ ys ]ℕ)
≡⟨ cong (λ x → 2 + x) (+-assoc (2 * [ xs ]ℕ) 2 (2 * [ ys ]ℕ)) ⟩
2 + (2 * [ xs ]ℕ + (2 + 2 * [ ys ]ℕ))
∎
[]ℕ-*2-hom : ∀ xs → [ *2 xs ]ℕ ≡ 2 * [ xs ]ℕ
[]ℕ-*2-hom [] = refl
[]ℕ-*2-hom (one ∷ xs) =
begin
2 + 2 * [ *2 xs ]ℕ
≡⟨ cong (λ x → 2 + 2 * x) ([]ℕ-*2-hom xs) ⟩
2 + 2 * (2 * [ xs ]ℕ)
≡⟨ cong suc (sym (+-suc (2 * [ xs ]ℕ) (2 * [ xs ]ℕ + zero))) ⟩
suc (2 * [ xs ]ℕ + suc (2 * [ xs ]ℕ + zero))
∎
[]ℕ-*2-hom (two ∷ xs) =
begin
2 + 2 * [ incrB (*2 xs) ]ℕ
≡⟨ cong (λ x → 2 + 2 * x) ([]ℕ-incrB-hom (*2 xs)) ⟩
2 + 2 * suc [ *2 xs ]ℕ
≡⟨ cong (λ x → 2 + 2 * suc x) ([]ℕ-*2-hom xs) ⟩
2 + 2 * suc (2 * [ xs ]ℕ)
≡⟨ cong (λ x → 2 + x) (sym (+-suc (2 * [ xs ]ℕ) (suc (2 * [ xs ]ℕ + zero)))) ⟩
2 + (2 * [ xs ]ℕ + suc (suc (2 * [ xs ]ℕ + zero)))
∎
[[]B]ℕ-id : ∀ n → [ [ n ]B ]ℕ ≡ n
[[]B]ℕ-id zero = refl
[[]B]ℕ-id (suc n) =
begin
[ incrB [ n ]B ]ℕ
≡⟨ []ℕ-incrB-hom [ n ]B ⟩
suc [ [ n ]B ]ℕ
≡⟨ cong suc ([[]B]ℕ-id n) ⟩
suc n
∎
[]ℕ-kernal : ∀ xs → [ xs ]ℕ ≡ 0 → xs ≡ []
[]ℕ-kernal [] pf = refl
[]ℕ-kernal (one ∷ xs) pf = contradiction pf (λ ())
[]ℕ-kernal (two ∷ xs) pf = contradiction pf (λ ())
[]ℕ-surjective : ∀ (x : ℕ) → ∃ (λ y → [ y ]ℕ ≡ x)
[]ℕ-surjective n = [ n ]B , [[]B]ℕ-id n
{-
[]ℕ-injective : ∀ x y → [ x ]ℕ ≡ [ y ]ℕ → x ≡ y
[]ℕ-injective [] [] pf = refl
[]ℕ-injective [] (y ∷ ys) pf = sym ([]ℕ-kernal (y ∷ ys) (sym pf))
[]ℕ-injective (x ∷ xs) [] pf = []ℕ-kernal (x ∷ xs) pf
[]ℕ-injective (one ∷ xs) (one ∷ ys) pf =
begin
one ∷ xs
≡⟨ cong (λ x → one ∷ x) ([]ℕ-injective xs ys {! !}) ⟩
one ∷ ys
∎
--let pf0 = trans pf (cong (λ x → 1 + 2 * x) {! !})
--in {! !}
[]ℕ-injective (one ∷ xs) (two ∷ ys) pf = {! !}
[]ℕ-injective (two ∷ xs) (y ∷ ys) pf = {! !}
-}
{-
begin
{! !}
≡⟨ {! !} ⟩
{! !}
≡⟨ {! !} ⟩
{! !}
≡⟨ {! !} ⟩
{! !}
≡⟨ {! !} ⟩
{! !}
∎
-}
| {
"alphanum_fraction": 0.3863969989,
"avg_line_length": 30.655,
"ext": "agda",
"hexsha": "e7012445e76e33f8f82cf00490b8e9cb4ef42118",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-05-30T05:50:50.000Z",
"max_forks_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/numeral",
"max_forks_repo_path": "legacy/Data/Num/Bij/Convert.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "banacorn/numeral",
"max_issues_repo_path": "legacy/Data/Num/Bij/Convert.agda",
"max_line_length": 82,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aae093cc9bf21f11064e7f7b12049448cd6449f1",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/numeral",
"max_stars_repo_path": "legacy/Data/Num/Bij/Convert.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": 3032,
"size": 6131
} |
open import Relation.Binary.Core
module PLRTree.Heap.Properties {A : Set}
(_≤_ : A → A → Set)
(trans≤ : Transitive _≤_) where
open import PLRTree {A}
open import PLRTree.Heap _≤_
lemma-≤-≤* : {x y : A}{t : PLRTree} → x ≤ y → y ≤* t → x ≤* t
lemma-≤-≤* {x = x} _ (lf≤* _) = lf≤* x
lemma-≤-≤* x≤y (nd≤* y≤z y≤*l y≤*r) = nd≤* (trans≤ x≤y y≤z) (lemma-≤-≤* x≤y y≤*l) (lemma-≤-≤* x≤y y≤*r)
| {
"alphanum_fraction": 0.4826789838,
"avg_line_length": 33.3076923077,
"ext": "agda",
"hexsha": "bf564f393a82f478db6e54121bcf173400cb2da8",
"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/Heap/Properties.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/Heap/Properties.agda",
"max_line_length": 103,
"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/Heap/Properties.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": 216,
"size": 433
} |
module Functional where
import Lvl
open import Type
infixl 10000 _∘_
infixl 10000 _⩺_
infixl 10000 _⩹_
infixl 30 _→ᶠ_ _←_ _←ᶠ_
infixr 0 _$_
private variable ℓ ℓ₁ ℓ₂ : Lvl.Level
private variable T X X₁ X₂ X₃ X₄ Y Y₁ Y₂ Y₃ Y₄ Z : Type{ℓ}
-- Converse of a function type
_←_ : Type{ℓ₁} → Type{ℓ₂} → Type{ℓ₁ Lvl.⊔ ℓ₂}
Y ← X = X → Y
-- Function type as a function
_→ᶠ_ : Type{ℓ₁} → Type{ℓ₂} → Type{ℓ₁ Lvl.⊔ ℓ₂}
X →ᶠ Y = X → Y
-- Converse function type as a function
_←ᶠ_ : Type{ℓ₁} → Type{ℓ₂} → Type{ℓ₁ Lvl.⊔ ℓ₂}
Y ←ᶠ X = Y ← X
-- The identity function.
-- Returns the applied argument.
id : T → T
id(x) = x
{-# INLINE id #-}
-- The constant function.
-- Returns the first argument independent of the second.
const : let _ = X in Y → (X → Y)
const(x)(_) = x
-- Function application as a function.
-- Applies the first argument on the function on the second argument.
apply : X → (X → Y) → Y
apply(x)(f) = f(x)
{-# INLINE apply #-}
-- Function application as an operator
_$_ : (X → Y) → X → Y
_$_ = id
{-# INLINE _$_ #-}
_$ᵢₘₚₗ_ : ({ _ : X } → Y) → (X → Y)
f $ᵢₘₚₗ x = f{x}
{-# INLINE _$ᵢₘₚₗ_ #-}
_$ᵢₙₛₜ_ : (⦃ _ : X ⦄ → Y) → (X → Y)
f $ᵢₙₛₜ x = f ⦃ x ⦄
{-# INLINE _$ᵢₙₛₜ_ #-}
-- Function application as an operator. Function to the left, value to the right.
_⩹_ : (X → Y) → X → Y
f ⩹ x = f(x)
{-# INLINE _⩹_ #-}
-- Function application as an operator. Value to the left, function to the right.
_⩺_ : X → (X → Y) → Y
x ⩺ f = f(x)
{-# INLINE _⩺_ #-}
-- Swapping the arguments of a binary operation
swap : (X → Y → Z) → (Y → X → Z)
swap f(y)(x) = f(x)(y)
{-# INLINE swap #-}
-- Function composition
_∘_ : let _ = X in (Y → Z) → (X → Y) → (X → Z)
(f ∘ g)(x) = f(g(x))
-- Function composition on implicit argument
_∘ᵢₘₚₗ_ : let _ = X in ({Y} → Z) → ({X} → Y) → ({X} → Z)
(f ∘ᵢₘₚₗ g){x} = f{g{x}}
-- Function composition on instance argument
_∘ᵢₙₛₜ_ : let _ = X in (⦃ Y ⦄ → Z) → (⦃ X ⦄ → Y) → (⦃ X ⦄ → Z)
(f ∘ᵢₙₛₜ g) ⦃ x ⦄ = f ⦃ g ⦃ x ⦄ ⦄
-- The S-combinator from combinatory logic.
-- It is sometimes described as a generalized version of the application operator or the composition operator.
-- Note: TODO: Applicative instance
_∘ₛ_ : (X → Y → Z) → (X → Y) → (X → Z)
(f ∘ₛ g)(x) = (f x) (g x)
_on₀_ : let _ = X in Z → (X → Y) → Z
((▫) on₀ f) = ▫ -- const
_on₁_ : let _ = X in (Y → Z) → (X → Y) → (X → Z)
((_▫) on₁ f)(y₁) = (f(y₁) ▫) on₀ f -- f(y₁) ▫
-- Function composition on a binary operator
-- A function is composed on every argument of the binary operator.
_on₂_ : let _ = X in (Y → Y → Z) → (X → Y) → (X → X → Z)
((_▫_) on₂ f)(y₁) = (f(y₁) ▫_) on₁ f -- f(y₁) ▫ f(y₂)
_on₃_ : let _ = X in (Y → Y → Y → Z) → (X → Y) → (X → X → X → Z)
((_▫_▫_) on₃ f)(y₁) = (f(y₁) ▫_▫_) on₂ f -- f(y₁) ▫ f(y₂) ▫ f(y₃)
-- TODO: Move these to Function.Multi
_∘₀_ : (Y → Z) → Y → Z
_∘₀_ = id
_∘₁_ : let _ = X₁ in (Y → Z) → (X₁ → Y) → (X₁ → Z)
_∘₁_ f = (f ∘₀_) ∘_
-- (f ∘₂ g)(x)(y) = f(g(x)(y))
_∘₂_ : let _ = X₁ ; _ = X₂ in (Y → Z) → (X₁ → X₂ → Y) → (X₁ → X₂ → Z)
_∘₂_ f = (f ∘₁_) ∘_
-- (f ∘₃ g)(x)(y)(z) = f(g(x)(y)(z))
_∘₃_ : let _ = X₁ ; _ = X₂ ; _ = X₃ in (Y → Z) → (X₁ → X₂ → X₃ → Y) → (X₁ → X₂ → X₃ → Z)
_∘₃_ f = (f ∘₂_) ∘_
-- (f ∘₄ g)(x)(y)(z)(w) = f(g(x)(y)(z)(w))
_∘₄_ : let _ = X₁ ; _ = X₂ ; _ = X₃ ; _ = X₄ in (Y → Z) → (X₁ → X₂ → X₃ → X₄ → Y) → (X₁ → X₂ → X₃ → X₄ → Z)
_∘₄_ f = (f ∘₃_) ∘_
-- map₂Arg₁ : let _ = X in (Y₁ → Y₂ → Z) → (X → Y₁) → (X → Y₂) → (X → Z)
-- map₂Arg₁ f g₁ g₂ x = f(g₁ x)(g₂ x)
-- map₂Arg₂ : let _ = X₁ ; _ = X₂ in (Y₁ → Y₂ → Z) → (X₁ → Y₁) → (X₂ → Y₂) → (X₁ → X₂ → Z)
-- map₂Arg₂ f g₁ g₂ x₁ x₂ = f(g₁ x₁)(g₂ x₂)
-- Function lifting //TODO: Consider removing because it is the same as _∘_
liftₗ : (X → Y) → ((Z → X) → (Z → Y))
liftₗ = _∘_ -- liftₗ(f) = f ∘_
liftᵣ : (X → Y) → ((Y → Z) → (X → Z))
liftᵣ = swap(_∘_) -- liftᵣ(f) = _∘ f
-- Applies an argument to two arguments of a binary function.
_$₂_ : (X → X → Y) → (X → Y)
f $₂ x = f x x
apply₂ : X → (X → X → Y) → Y
apply₂ x f = f x x
proj₂ₗ : X → Y → X
proj₂ₗ = const
proj₂ᵣ : X → Y → Y
proj₂ᵣ = const id
open import Syntax.Function public
| {
"alphanum_fraction": 0.5270704574,
"avg_line_length": 26.6118421053,
"ext": "agda",
"hexsha": "0b7ad9d0e08db6644c93d9717ede5e5ea9efab85",
"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": "Functional.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": "Functional.agda",
"max_line_length": 110,
"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": "Functional.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": 1953,
"size": 4045
} |
------------------------------------------------------------------------
-- Properties related to negation
------------------------------------------------------------------------
module Relation.Nullary.Negation where
open import Relation.Nullary
open import Relation.Unary
open import Data.Empty
open import Data.Function
open import Data.Product as Prod
open import Data.Fin
open import Data.Fin.Dec
open import Category.Monad
contradiction : ∀ {P whatever} → P → ¬ P → whatever
contradiction p ¬p = ⊥-elim (¬p p)
contraposition : ∀ {P Q} → (P → Q) → ¬ Q → ¬ P
contraposition f ¬q p = contradiction (f p) ¬q
-- Note also the following use of flip:
private
note : ∀ {P Q} → (P → ¬ Q) → Q → ¬ P
note = flip
------------------------------------------------------------------------
-- Quantifier juggling
∃⟶¬∀¬ : ∀ {A} {P : Pred A} → ∃ P → ¬ (∀ x → ¬ P x)
∃⟶¬∀¬ = flip uncurry
∀⟶¬∃¬ : ∀ {A} {P : Pred A} → (∀ x → P x) → ¬ ∃ λ x → ¬ P x
∀⟶¬∃¬ ∀xPx (x , ¬Px) = ¬Px (∀xPx x)
¬∃⟶∀¬ : ∀ {A} {P : Pred A} → ¬ ∃ (λ x → P x) → ∀ x → ¬ P x
¬∃⟶∀¬ = curry
∀¬⟶¬∃ : ∀ {A} {P : Pred A} → (∀ x → ¬ P x) → ¬ ∃ (λ x → P x)
∀¬⟶¬∃ = uncurry
∃¬⟶¬∀ : ∀ {A} {P : Pred A} → ∃ (λ x → ¬ P x) → ¬ (∀ x → P x)
∃¬⟶¬∀ = flip ∀⟶¬∃¬
-- When P is a decidable predicate over a finite set the following
-- lemma can be proved.
¬∀⟶∃¬ : ∀ n (P : Pred (Fin n)) → (∀ i → Dec (P i)) →
¬ (∀ i → P i) → ∃ λ i → ¬ P i
¬∀⟶∃¬ n P dec ¬P = Prod.map id proj₁ $ ¬∀⟶∃¬-smallest n P dec ¬P
------------------------------------------------------------------------
-- Double-negation
¬¬-map : ∀ {P Q} → (P → Q) → ¬ ¬ P → ¬ ¬ Q
¬¬-map f = contraposition (contraposition f)
¬¬-drop : {P : Set} → ¬ ¬ ¬ P → ¬ P
¬¬-drop ¬¬¬P P = ¬¬¬P (λ ¬P → ¬P P)
¬¬-drop-Dec : {P : Set} → Dec P → ¬ ¬ P → P
¬¬-drop-Dec (yes p) ¬¬p = p
¬¬-drop-Dec (no ¬p) ¬¬p = ⊥-elim (¬¬p ¬p)
¬-drop-Dec : {P : Set} → Dec (¬ ¬ P) → Dec (¬ P)
¬-drop-Dec (yes ¬¬p) = no ¬¬p
¬-drop-Dec (no ¬¬¬p) = yes (¬¬-drop ¬¬¬p)
-- Double-negation is a monad (if we assume that all elements of ¬ ¬ P
-- are equal).
¬¬-Monad : RawMonad (λ P → ¬ ¬ P)
¬¬-Monad = record
{ return = contradiction
; _>>=_ = λ x f → ¬¬-drop (¬¬-map f x)
}
¬¬-push : {P : Set} {Q : P → Set} →
¬ ¬ ((x : P) → Q x) → (x : P) → ¬ ¬ Q x
¬¬-push ¬¬P⟶Q P ¬Q = ¬¬P⟶Q (λ P⟶Q → ¬Q (P⟶Q P))
-- A double-negation-translated variant of excluded middle (or: every
-- nullary relation is decidable in the double-negation monad).
excluded-middle : {P : Set} → ¬ ¬ Dec P
excluded-middle ¬h = ¬h (no (λ p → ¬h (yes p)))
-- If whatever is instantiated with ¬ ¬ something, then this function
-- is call with current continuation in the double-negation monad, or,
-- if you will, a double-negation translation of Peirce's law.
--
-- In order to prove ¬ ¬ P one can assume ¬ P and prove ⊥. However, it
-- is sometimes nice to avoid leaving the double-negation monad; in
-- that case this function can be used (with whatever instantiated to
-- ⊥).
call/cc : ∀ {whatever P : Set} → ((P → whatever) → ¬ ¬ P) → ¬ ¬ P
call/cc hyp ¬p = hyp (λ p → ⊥-elim (¬p p)) ¬p
| {
"alphanum_fraction": 0.485164656,
"avg_line_length": 30.67,
"ext": "agda",
"hexsha": "2d2971e75210d3612cdcf63ad7c582fab8181300",
"lang": "Agda",
"max_forks_count": 3,
"max_forks_repo_forks_event_max_datetime": "2022-03-12T11:54:10.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-07-21T16:37:58.000Z",
"max_forks_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "isabella232/Lemmachine",
"max_forks_repo_path": "vendor/stdlib/src/Relation/Nullary/Negation.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "8ef786b40e4a9ab274c6103dc697dcb658cf3db3",
"max_issues_repo_issues_event_max_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_issues_event_min_datetime": "2022-03-12T12:17:51.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "larrytheliquid/Lemmachine",
"max_issues_repo_path": "vendor/stdlib/src/Relation/Nullary/Negation.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/Relation/Nullary/Negation.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": 1159,
"size": 3067
} |
open import Common.Prelude
open import Common.Reflection
open import Common.Equality
` : Term → Term
` (def f []) = con (quote def) (vArg (lit (qname f)) ∷ vArg (con (quote []) []) ∷ [])
` _ = lit (string "other")
macro
primQNameType : QName → Tactic
primQNameType f hole =
bindTC (getType f) λ a →
bindTC (normalise a) λ a →
give (` a) hole
A : Set
a : A
A = _
B : Set
b : B
B = _
aName=bName : primQNameType a ≡ primQNameType b
aName=bName = refl
a = 0
b = 1.0
empty : ⊥
empty with aName=bName
... | ()
| {
"alphanum_fraction": 0.6117424242,
"avg_line_length": 16,
"ext": "agda",
"hexsha": "85ca09ad4c1673487e9b33fe1055631a905a3310",
"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/Issue1371.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/Issue1371.agda",
"max_line_length": 85,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Fail/Issue1371.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": 191,
"size": 528
} |
-- Andreas, 2017-11-01, issue #2824
-- allow built-in pragmas in parametrized modules
{-# OPTIONS --rewriting #-}
open import Agda.Builtin.Equality
module _ (A : Set) where -- This is the top-level module header.
{-# BUILTIN REWRITE _≡_ #-}
postulate
P : A → Set
a b : A
a→b : a ≡ b
{-# REWRITE a→b #-}
test : P a → P b
test x = x
-- Should succeed.
| {
"alphanum_fraction": 0.6219178082,
"avg_line_length": 15.8695652174,
"ext": "agda",
"hexsha": "279b824d04637a5bcd853570970d287db8414b4d",
"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/Issue2824BuiltinRewriteInParametrizedModule.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/Issue2824BuiltinRewriteInParametrizedModule.agda",
"max_line_length": 65,
"max_stars_count": 1,
"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/Issue2824BuiltinRewriteInParametrizedModule.agda",
"max_stars_repo_stars_event_max_datetime": "2016-03-17T01:45:59.000Z",
"max_stars_repo_stars_event_min_datetime": "2016-03-17T01:45:59.000Z",
"num_tokens": 121,
"size": 365
} |
-- Andreas, 2019-11-06 issue #4168, version with shape-irrelevance.
-- Eta-contraction of records with all-irrelevant fields is unsound.
-- In this case, it lead to a compilation error.
{-# OPTIONS --irrelevant-projections #-}
-- {-# OPTIONS -v tc.cc:20 #-}
open import Agda.Builtin.Unit
open import Common.IO using (IO; return)
main : IO ⊤
main = return _
record Box (A : Set) : Set where
constructor box
field
..unbox : A
open Box
record R (M : Set → Set) : Set₁ where
field
bind : (A B : Set) → M A → (A → M B) → M B
open R
works : R Box
works .bind A B x g .unbox = unbox (g (unbox x))
test : R Box
test .bind A B x g = box (unbox (g (unbox x)))
-- WAS eta-contracted to: test .bind A B x g = g (unbox x)
-- crashing compilation.
-- Compilation should succeed.
| {
"alphanum_fraction": 0.6481012658,
"avg_line_length": 21.3513513514,
"ext": "agda",
"hexsha": "99c87e3f3b90aa0e51092a74d7f928aadb03ff5a",
"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/Issue4168-shirr.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/Issue4168-shirr.agda",
"max_line_length": 68,
"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/Issue4168-shirr.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": 250,
"size": 790
} |
open import Agda.Builtin.Bool
open import Agda.Builtin.Equality
open import Agda.Builtin.List
open import Agda.Builtin.Reflection renaming (bindTC to _>>=_)
open import Agda.Builtin.Unit
postulate
@0 A : Set
@0 _ : @0 Set → (Set → Set) → Set
_ = λ @0 where
A G → G A
@0 _ : @0 Set → (Set → Set) → Set
_ = λ @0 { A G → G A }
data ⊥ : Set where
@0 _ : @0 ⊥ → Set
_ = λ @0 { () }
@0 _ : @0 ⊥ → Set
_ = λ @0 where
()
@0 _ : @0 ⊥ → Set
_ =
λ @0
@ω
@erased
@plenty
@(tactic (λ _ → Set))
@irr
@irrelevant
@shirr
@shape-irrelevant
@relevant
@♭
@flat
@notlock
@lock
@tick where
()
F : ⊤ → ⊤
F = λ { tt → tt }
macro
`F : Term → TC ⊤
`F goal = do
F ← withNormalisation true (quoteTC F)
F ← quoteTC F
unify goal F
_ :
`F ≡
pat-lam
(clause []
(arg (arg-info visible relevant) (con (quote tt) []) ∷ [])
(con (quote tt) []) ∷
[])
[]
_ = refl
| {
"alphanum_fraction": 0.5131440589,
"avg_line_length": 14.6307692308,
"ext": "agda",
"hexsha": "dc86594aeac1fdac1efa42787635d8e42ed693ea",
"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": "aea2c53340f509c2c67157caeac360400ea6afbc",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "googleson78/agda",
"max_forks_repo_path": "test/Succeed/Issue4525.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "aea2c53340f509c2c67157caeac360400ea6afbc",
"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": "googleson78/agda",
"max_issues_repo_path": "test/Succeed/Issue4525.agda",
"max_line_length": 64,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "aea2c53340f509c2c67157caeac360400ea6afbc",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "googleson78/agda",
"max_stars_repo_path": "test/Succeed/Issue4525.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 371,
"size": 951
} |
-- Category of □-coalgebras
module SOAS.Abstract.Coalgebra {T : Set} where
open import SOAS.Common
open import SOAS.Construction.Structure as Structure
open import SOAS.Context
open import SOAS.ContextMaps.Combinators
open import SOAS.ContextMaps.CategoryOfRenamings {T}
open import SOAS.Sorting
open import SOAS.Families.Core {T}
open import SOAS.Variable
open import SOAS.Families.BCCC
open import Data.Unit using (tt)
open import SOAS.Abstract.Hom {T}
import SOAS.Abstract.Box {T} as □
private
variable
α : T
Γ Δ Θ : Ctx
-- Unsorted □-coalgebras
module Unsorted where
open □.Unsorted
record Coalg (X : Family) : Set where
field
r : X ⇾ □ X
counit : {t : X Γ} → r t id ≡ t
comult : {ρ : Γ ↝ Δ}{ϱ : Δ ↝ Θ}{t : X Γ}
→ r t (ϱ ∘ ρ) ≡ r (r t ρ) ϱ
-- Weakening of terms
wkr : (Θ : Ctx) → X Γ → X (Θ ∔ Γ)
wkr Θ t = r t (inr Θ)
wkl : (Γ : Ctx) → X Γ → X (Γ ∔ Θ)
wkl Γ t = r t (inl Γ)
wk : X Γ → X (α ∙ Γ)
wk t = r t old
-- Unsorted coalgebra homomorphism
record Coalg⇒ {X Y}(Xᵇ : Coalg X)(Yᵇ : Coalg Y) (f : X ⇾ Y) : Set where
private module X = Coalg Xᵇ
private module Y = Coalg Yᵇ
field
⟨r⟩ : {ρ : Γ ↝ Δ}{t : X Γ} → f (X.r t ρ) ≡ Y.r (f t) (ρ)
private module CoalgebraStructure = Structure 𝔽amilies Coalg
-- Eilenberg-Moore category of a comonad
ℂoalgebras : Category 1ℓ 0ℓ 0ℓ
ℂoalgebras = CoalgebraStructure.StructCat (record
{ IsHomomorphism = Coalg⇒
; id-hom = record { ⟨r⟩ = refl }
; comp-hom = λ{ g f record { ⟨r⟩ = g⟨r⟩ } record { ⟨r⟩ = f⟨r⟩ } → record
{ ⟨r⟩ = trans (cong g f⟨r⟩) g⟨r⟩ } }
})
module ℂoalg = Category ℂoalgebras
Coalgebra : Set₁
Coalgebra = ℂoalg.Obj
Coalgebra⇒ : Coalgebra → Coalgebra → Set
Coalgebra⇒ = ℂoalg._⇒_
module AsCoalgebra (Xᵇ : Coalgebra) where
open Object Xᵇ public renaming (𝐶 to X ; ˢ to ᵇ)
open Coalg ᵇ public
-- Terminal object is a coalgebra
⊤ᵇ : Coalg ⊤ₘ
⊤ᵇ = record { r = λ _ _ → tt ; counit = refl ; comult = refl }
-- □ X is the free coalgebra on X
□ᵇ : (X : Family) → Coalg (□ X)
□ᵇ X = record { r = λ b ρ ϱ → b (ϱ ∘ ρ) ; counit = refl ; comult = refl }
-- | Sorted □-coalgebras
module Sorted where
open □.Sorted
record Coalg (𝒳 : Familyₛ) : Set where
field
r : 𝒳 ⇾̣ □ 𝒳
counit : {t : 𝒳 α Γ} → r t id ≡ t
comult : {ρ : Γ ↝ Δ}{ϱ : Δ ↝ Θ}{t : 𝒳 α Γ}
→ r t (ϱ ∘ ρ) ≡ r (r t ρ) ϱ
-- Congruence in both arguments
r≈₁ : {ρ : Γ ↝ Δ}{t₁ t₂ : 𝒳 α Γ} → t₁ ≡ t₂ → r t₁ ρ ≡ r t₂ ρ
r≈₁ {ρ = ρ} p = cong (λ - → r - ρ) p
r≈₂ : {ρ₁ ρ₂ : Γ ↝ Δ}{t : 𝒳 α Γ}
→ ({τ : T}{x : ℐ τ Γ} → ρ₁ x ≡ ρ₂ x)
→ r t ρ₁ ≡ r t ρ₂
r≈₂ {t = t} p = cong (r t) (dext′ p)
wkr : (Θ : Ctx) → 𝒳 α Γ → 𝒳 α (Θ ∔ Γ)
wkr Θ t = r t (inr Θ)
wkl : (Γ : Ctx) → 𝒳 α Γ → 𝒳 α (Γ ∔ Θ)
wkl Γ t = r t (inl Γ)
wk : {τ : T} → 𝒳 α Γ → 𝒳 α (τ ∙ Γ)
wk t = r t old
-- Coalgebra homomorphism
record Coalg⇒ {𝒳 𝒴}(Xᵇ : Coalg 𝒳)(𝒴ᵇ : Coalg 𝒴) (f : 𝒳 ⇾̣ 𝒴) : Set where
private module 𝒳 = Coalg Xᵇ
private module 𝒴 = Coalg 𝒴ᵇ
field
⟨r⟩ : {ρ : Γ ↝ Δ}{t : 𝒳 α Γ} → f (𝒳.r t ρ) ≡ 𝒴.r (f t) (ρ)
private module CoalgebraStructure = Structure 𝔽amiliesₛ Coalg
-- Eilenberg-Moore category of a comonad
ℂoalgebras : Category 1ℓ 0ℓ 0ℓ
ℂoalgebras = CoalgebraStructure.StructCat (record
{ IsHomomorphism = Coalg⇒
; id-hom = record { ⟨r⟩ = refl }
; comp-hom = λ{ g f record { ⟨r⟩ = g⟨r⟩ } record { ⟨r⟩ = f⟨r⟩ } → record
{ ⟨r⟩ = trans (cong g f⟨r⟩) g⟨r⟩ } }
})
module ℂoalg = Category ℂoalgebras
Coalgebra : Set₁
Coalgebra = ℂoalg.Obj
Coalgebra⇒ : Coalgebra → Coalgebra → Set
Coalgebra⇒ = ℂoalg._⇒_
module AsCoalgebra (𝒳ᵇ : Coalgebra) where
open Object 𝒳ᵇ public renaming (𝐶 to 𝒳 ; ˢ to ᵈ)
-- 〖 𝒳 , 𝒴 〗 is a coalgebra for any 𝒳 and 𝒴
〖_,_〗ᵇ : (𝒳 𝒴 : Familyₛ) → Coalg (〖 𝒳 , 𝒴 〗)
〖 𝒳 , 𝒴 〗ᵇ = record { r = λ h ρ ϱ → h (ϱ ∘ ρ) ; counit = refl ; comult = refl }
-- □ 𝒳 is the free coalgebra on 𝒳
□ᵇ : (𝒳 : Familyₛ) → Coalg (□ 𝒳)
□ᵇ 𝒳 = 〖 ℐ , 𝒳 〗ᵇ
-- Pointed coalgebra
record Coalgₚ (𝒳 : Familyₛ) : Set where
field
ᵇ : Coalg 𝒳
η : ℐ ⇾̣ 𝒳
open Coalg ᵇ public
field
r∘η : {α : T}{Γ Δ : Ctx}{v : ℐ α Γ}{ρ : Γ ↝ Δ}
→ r (η v) ρ ≡ η (ρ v)
-- Pointed coalgebra homomorphism
record Coalgₚ⇒ {𝒳 𝒴 : Familyₛ}(𝒳ᴮ : Coalgₚ 𝒳)(𝒴ᴮ : Coalgₚ 𝒴)
(f : 𝒳 ⇾̣ 𝒴) : Set where
private module 𝒳 = Coalgₚ 𝒳ᴮ
private module 𝒴 = Coalgₚ 𝒴ᴮ
field
ᵇ⇒ : Coalg⇒ 𝒳.ᵇ 𝒴.ᵇ f
⟨η⟩ : {α : T}{Γ : Ctx}{v : ℐ α Γ}
→ f (𝒳.η v) ≡ 𝒴.η v
open Coalg⇒ ᵇ⇒ public
-- Pointed coalgebra of variables
ℐᵇ : Coalg ℐ
ℐᵇ = record { r = λ v ρ → ρ v ; counit = refl ; comult = refl }
ℐᴮ : Coalgₚ ℐ
ℐᴮ = record { ᵇ = ℐᵇ ; η = id ; r∘η = refl }
-- □ 𝒳 is free pointed coalgebra on pointed families
□ᴮ : (𝒳 : Familyₛ) → ℐ ⇾̣ 𝒳 → Coalgₚ (□ 𝒳)
□ᴮ 𝒳 η = record { ᵇ = □ᵇ 𝒳 ; η = λ v ρ → η (ρ v) ; r∘η = refl }
-- Identity and point are homomorphisms
idᴮ⇒ : {𝒳 : Familyₛ}{𝒳ᴮ : Coalgₚ 𝒳} → Coalgₚ⇒ 𝒳ᴮ 𝒳ᴮ id
idᴮ⇒ = record { ᵇ⇒ = record { ⟨r⟩ = refl } ; ⟨η⟩ = refl }
ηᴮ⇒ : {𝒳 : Familyₛ}(𝒳ᴮ : Coalgₚ 𝒳) → Coalgₚ⇒ ℐᴮ 𝒳ᴮ (Coalgₚ.η 𝒳ᴮ)
ηᴮ⇒ 𝒳ᴮ = record { ᵇ⇒ = record { ⟨r⟩ = sym (Coalgₚ.r∘η 𝒳ᴮ) } ; ⟨η⟩ = refl }
| {
"alphanum_fraction": 0.542481203,
"avg_line_length": 27.4226804124,
"ext": "agda",
"hexsha": "3b658d44e9bb381a931113045cb9aa730286b137",
"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": "b224d31e20cfd010b7c924ce940f3c2f417777e3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "k4rtik/agda-soas",
"max_forks_repo_path": "SOAS/Abstract/Coalgebra.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "b224d31e20cfd010b7c924ce940f3c2f417777e3",
"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": "k4rtik/agda-soas",
"max_issues_repo_path": "SOAS/Abstract/Coalgebra.agda",
"max_line_length": 81,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "b224d31e20cfd010b7c924ce940f3c2f417777e3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "k4rtik/agda-soas",
"max_stars_repo_path": "SOAS/Abstract/Coalgebra.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2650,
"size": 5320
} |
{-# OPTIONS --without-K --safe #-}
-- The identity pseudofunctor
module Categories.Pseudofunctor.Identity where
open import Data.Product using (_,_)
open import Categories.Bicategory using (Bicategory)
import Categories.Bicategory.Extras as BicategoryExt
open import Categories.Category using (Category)
open import Categories.Category.Instance.One using (shift)
open import Categories.Category.Product using (_⁂_)
open import Categories.Functor using (Functor; _∘F_) renaming (id to idF)
import Categories.Morphism.Reasoning as MorphismReasoning
open import Categories.NaturalTransformation using (NaturalTransformation)
open import Categories.NaturalTransformation.NaturalIsomorphism
using (NaturalIsomorphism; _≃_; niHelper)
open import Categories.Pseudofunctor using (Pseudofunctor)
open Category using (module HomReasoning)
open NaturalIsomorphism using (F⇒G; F⇐G)
-- The identity pseudofunctor
idP : ∀ {o ℓ e t} {C : Bicategory o ℓ e t} → Pseudofunctor C C
idP {o} {ℓ} {e} {t} {C = C} = record
{ P₀ = λ x → x
; P₁ = idF
; P-identity = P-identity
; P-homomorphism = P-homomorphism
; unitaryˡ = unitaryˡ
; unitaryʳ = unitaryʳ
; assoc = assoc
}
where
open BicategoryExt C
P-identity : ∀ {x} → id {x} ∘F shift o ℓ e ≃ idF ∘F id
P-identity {x} = niHelper (record
{ η = λ _ → id₂
; η⁻¹ = λ _ → id₂
; commute = λ _ → MorphismReasoning.id-comm-sym (hom x x)
; iso = λ _ → record { isoˡ = hom.identity² ; isoʳ = hom.identity² }
})
P-homomorphism : ∀ {x y z} → ⊚ ∘F (idF ⁂ idF) ≃ idF ∘F ⊚ {x} {y} {z}
P-homomorphism {x} {_} {z} = niHelper (record
{ η = λ _ → id₂
; η⁻¹ = λ _ → id₂
; commute = λ _ → MorphismReasoning.id-comm-sym (hom x z)
; iso = λ _ → record { isoˡ = hom.identity² ; isoʳ = hom.identity² }
})
Pid = λ {A} → NaturalTransformation.η (F⇒G (P-identity {A})) _
Phom = λ {x} {y} {z} f,g →
NaturalTransformation.η (F⇒G (P-homomorphism {x} {y} {z})) f,g
λ⇒ = unitorˡ.from
ρ⇒ = unitorʳ.from
α⇒ = associator.from
unitaryˡ : ∀ {x y} {f : x ⇒₁ y} →
let open ComHom in
[ id₁ ⊚₀ f ⇒ f ]⟨
Pid ⊚₁ id₂ ⇒⟨ id₁ ⊚₀ f ⟩
Phom (id₁ , f) ⇒⟨ id₁ ⊚₀ f ⟩
λ⇒
≈ λ⇒
⟩
unitaryˡ {x} {y} {f} = begin
λ⇒ ∘ᵥ Phom (id₁ , f) ∘ᵥ (Pid ⊚₁ id₂) ≈⟨ refl⟩∘⟨ elimʳ ⊚.identity ⟩
λ⇒ ∘ᵥ Phom (id₁ , f) ≈⟨ hom.identityʳ ⟩
λ⇒ ∎
where
open HomReasoning (hom x y)
open MorphismReasoning (hom x y)
unitaryʳ : ∀ {x y} {f : x ⇒₁ y} →
let open ComHom in
[ f ⊚₀ id₁ ⇒ f ]⟨
id₂ ⊚₁ Pid ⇒⟨ f ⊚₀ id₁ ⟩
Phom (f , id₁) ⇒⟨ f ⊚₀ id₁ ⟩
ρ⇒
≈ ρ⇒
⟩
unitaryʳ {x} {y} {f} = begin
ρ⇒ ∘ᵥ Phom (f , id₁) ∘ᵥ (id₂ ⊚₁ Pid) ≈⟨ refl⟩∘⟨ elimʳ ⊚.identity ⟩
ρ⇒ ∘ᵥ Phom (f , id₁) ≈⟨ hom.identityʳ ⟩
ρ⇒ ∎
where
open HomReasoning (hom x y)
open MorphismReasoning (hom x y)
assoc : ∀ {x y z w} {f : x ⇒₁ y} {g : y ⇒₁ z} {h : z ⇒₁ w} →
let open ComHom in
[ (h ⊚₀ g) ⊚₀ f ⇒ h ⊚₀ (g ⊚₀ f) ]⟨
Phom (h , g) ⊚₁ id₂ ⇒⟨ (h ⊚₀ g) ⊚₀ f ⟩
Phom (_ , f) ⇒⟨ (h ⊚₀ g) ⊚₀ f ⟩
α⇒
≈ α⇒ ⇒⟨ h ⊚₀ (g ⊚₀ f) ⟩
id₂ ⊚₁ Phom (g , f) ⇒⟨ h ⊚₀ (g ⊚₀ f) ⟩
Phom (h , _)
⟩
assoc {x} {_} {_} {w} {f} {g} {h} = begin
α⇒ ∘ᵥ Phom (_ , f) ∘ᵥ Phom (h , g) ⊚₁ id₂ ≈⟨ refl⟩∘⟨ elimʳ ⊚.identity ⟩
α⇒ ∘ᵥ Phom (_ , f) ≈⟨ hom.identityʳ ⟩
α⇒ ≈˘⟨ elimˡ ⊚.identity ⟩
id₂ ⊚₁ Phom (g , f) ∘ᵥ α⇒ ≈˘⟨ hom.identityˡ ⟩
Phom (h , _) ∘ᵥ id₂ ⊚₁ Phom (g , f) ∘ᵥ α⇒ ∎
where
open HomReasoning (hom x w)
open MorphismReasoning (hom x w)
| {
"alphanum_fraction": 0.4834054834,
"avg_line_length": 36.796460177,
"ext": "agda",
"hexsha": "4427c486c7c19ec4b81e29f241d2f6b3b9f2bbd4",
"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/Pseudofunctor/Identity.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/Pseudofunctor/Identity.agda",
"max_line_length": 78,
"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/Pseudofunctor/Identity.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": 1634,
"size": 4158
} |
{-# OPTIONS --cubical --safe #-}
module Data.Binary.Equatable where
open import Prelude
open import Data.Binary.Definition
open import Data.Bits.Equatable public
| {
"alphanum_fraction": 0.7804878049,
"avg_line_length": 20.5,
"ext": "agda",
"hexsha": "d84022c9ae4f4c6926249b3789c47e5bf52db8ee",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-11T12:30:21.000Z",
"max_forks_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-playground",
"max_forks_repo_path": "Data/Binary/Equatable.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-playground",
"max_issues_repo_path": "Data/Binary/Equatable.agda",
"max_line_length": 38,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "97a3aab1282b2337c5f43e2cfa3fa969a94c11b7",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-playground",
"max_stars_repo_path": "Data/Binary/Equatable.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": 38,
"size": 164
} |
-- Andreas, 2012-02-14, issue reported by Wolfram Kahl
-- {-# OPTIONS -v scope.top:10 #-}
module Issue562 where
data Bool : Set where true false : Bool
f : Bool → Bool
f b with b
f true | _ = b
-- WAS: panic unbound variable b
-- should be: Not in scope: b | {
"alphanum_fraction": 0.667953668,
"avg_line_length": 23.5454545455,
"ext": "agda",
"hexsha": "75919ec98ae61cadee5deef2abf5cefc60733285",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/Issue562.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/Issue562.agda",
"max_line_length": 54,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/fail/Issue562.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": 82,
"size": 259
} |
-- 2010-11-21
-- testing correct implementation of eta for records with higher-order fields
module Issue366 where
data Bool : Set where
true false : Bool
record R (A : Set) : Set where
constructor r
field
unR : A
open R
foo : Bool
foo = unR (r (unR (r (λ (_ : Bool) → false))
true))
-- before 2010-11-21, an incorrect implementation of eta-contraction
-- reduced foo to (unR true)
-- Error message was (due to clause compilation):
-- Incomplete pattern matching
data _==_ {A : Set}(a : A) : A -> Set where
refl : a == a
test : foo == false
test = refl
| {
"alphanum_fraction": 0.6501706485,
"avg_line_length": 19.5333333333,
"ext": "agda",
"hexsha": "c57f5df53e1046f5683fe9744361ac39c74c318b",
"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/Issue366.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/Issue366.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/Issue366.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": 173,
"size": 586
} |
module TerminationMixingTupledCurried where
data Nat : Set where
zero : Nat
succ : Nat -> Nat
data _×_ (A B : Set) : Set where
_,_ : A -> B -> A × B
good : Nat × Nat -> Nat -> Nat
good (succ x , y) z = good (x , succ y) (succ z)
good (x , succ y) z = good (x , y) x
good xy (succ z) = good xy z
good _ _ = zero
| {
"alphanum_fraction": 0.5688073394,
"avg_line_length": 20.4375,
"ext": "agda",
"hexsha": "2f224718319f3af18b3f7256165a1ece5e693df2",
"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/features/matrixShapedTerminationOrder/TerminationMixingTupledCurried.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/features/matrixShapedTerminationOrder/TerminationMixingTupledCurried.agda",
"max_line_length": 48,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/features/matrixShapedTerminationOrder/TerminationMixingTupledCurried.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": 120,
"size": 327
} |
{-# OPTIONS --safe #-}
module Cubical.Algebra.Group where
open import Cubical.Algebra.Group.Base public
open import Cubical.Algebra.Group.Properties public
| {
"alphanum_fraction": 0.7961783439,
"avg_line_length": 26.1666666667,
"ext": "agda",
"hexsha": "dfaeabcbd30d6e166efeb0ec9e09f9374315b9b2",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "thomas-lamiaux/cubical",
"max_forks_repo_path": "Cubical/Algebra/Group.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "thomas-lamiaux/cubical",
"max_issues_repo_path": "Cubical/Algebra/Group.agda",
"max_line_length": 51,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "58c0b83bb0fed0dc683f3d29b1709effe51c1689",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "thomas-lamiaux/cubical",
"max_stars_repo_path": "Cubical/Algebra/Group.agda",
"max_stars_repo_stars_event_max_datetime": "2021-10-31T17:32:49.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-10-31T17:32:49.000Z",
"num_tokens": 33,
"size": 157
} |
data Nat : Set where
zero : Nat
suc : Nat → Nat
test : ∀{N M : Nat} → Nat → Nat → Nat
test N M = {!.N N .M!}
-- Andreas, 2016-07-10, issue 2088
-- Changed behavior:
-- The hidden variables .N and .M are made visible
-- only the visible N is split.
| {
"alphanum_fraction": 0.6166007905,
"avg_line_length": 23,
"ext": "agda",
"hexsha": "d3e2bfbcdecafd4848abafff2f23d9f6e4068900",
"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/interaction/SplitOnHidden.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/interaction/SplitOnHidden.agda",
"max_line_length": 50,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "alhassy/agda",
"max_stars_repo_path": "test/interaction/SplitOnHidden.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": 87,
"size": 253
} |
postulate
A : Set
f : A → A
mutual
F : A → Set
F x = D (f x)
data D : A → Set where
c : (x : A) → F x
G : (x : A) → D x → Set₁
G _ (c _) = Set
| {
"alphanum_fraction": 0.4135802469,
"avg_line_length": 10.125,
"ext": "agda",
"hexsha": "94fadce8747b7994e9b505657d25dd9b11194777",
"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/Issue2919.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/Issue2919.agda",
"max_line_length": 24,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/Issue2919.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": 78,
"size": 162
} |
{-# OPTIONS --copatterns #-}
module Issue950b where
postulate
A : Set
record R : Set where
field
x : A
record S : Set where
field
y : A
open R
f : ?
x f = ?
-- Good error:
-- Cannot eliminate type ?0 with projection pattern x
-- when checking that the clause x f = ? has type ?0
| {
"alphanum_fraction": 0.6245847176,
"avg_line_length": 12.04,
"ext": "agda",
"hexsha": "ab274e68f9791caffca27a8bf9a14d49fb1dd0da",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue950b.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue950b.agda",
"max_line_length": 53,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue950b.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": 89,
"size": 301
} |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
module groups.KernelSndImageInl {i j k}
(G : Group i) {H : Group j} {K : Group k}
-- the argument [φ-snd], which is intended to be [φ ∘ᴳ ×-snd],
-- gives the possibility of making the second part
-- (the proof of being a group homomorphism) abstract.
(φ : H →ᴳ K) (φ-snd : G ×ᴳ H →ᴳ K)
(φ-snd-β : ∀ x → GroupHom.f φ-snd x == GroupHom.f φ (snd x))
(G×H-is-abelian : is-abelian (G ×ᴳ H))
where
open import groups.KernelImage
φ-snd (×ᴳ-inl {G = G} {H = H}) G×H-is-abelian
private
module G = Group G
module H = Group H
Ker-φ-snd-quot-Im-inl : Ker φ ≃ᴳ Ker/Im
Ker-φ-snd-quot-Im-inl = to-hom , is-eq to from to-from from-to where
to : Ker.El φ → Ker/Im.El
to (h , h-in-ker) = q[ (G.ident , h) , lemma ]
where abstract lemma = φ-snd-β (G.ident , h) ∙ h-in-ker
abstract
to-pres-comp : ∀ k₁ k₂ → to (Ker.comp φ k₁ k₂) == Ker/Im.comp (to k₁) (to k₂)
to-pres-comp _ _ = ap q[_] $ Ker.El=-out φ-snd $
pair×= (! (G.unit-l G.ident)) idp
to-hom : Ker φ →ᴳ Ker/Im
to-hom = group-hom to to-pres-comp
abstract
from' : Ker.El φ-snd → Ker.El φ
from' ((g , h) , h-in-ker) = h , ! (φ-snd-β (g , h)) ∙ h-in-ker
from-rel : ∀ {gh₁ gh₂} → ker/im-rel gh₁ gh₂ → from' gh₁ == from' gh₂
from-rel {gh₁} {gh₂} = Trunc-rec (Ker.El-is-set φ _ _)
(λ{(g , inl-g=h₁h₂⁻¹) → Ker.El=-out φ
(H.zero-diff-same (snd (fst gh₁)) (snd (fst gh₂)) (! (snd×= inl-g=h₁h₂⁻¹)))})
from : Ker/Im.El → Ker.El φ
from = SetQuot-rec (Ker.El-is-set φ) from' from-rel
abstract
to-from : ∀ g → to (from g) == g
to-from = SetQuot-elim
{P = λ g → to (from g) == g}
(λ _ → =-preserves-set Ker/Im.El-is-set)
(λ{((g , h) , h-in-ker) → quot-rel
[ G.inv g , ap2 _,_ (! (G.unit-l (G.inv g))) (! (H.inv-r h)) ]})
(λ _ → prop-has-all-paths-↓ (Ker/Im.El-is-set _ _))
from-to : ∀ g → from (to g) == g
from-to _ = Ker.El=-out φ idp
| {
"alphanum_fraction": 0.5336940482,
"avg_line_length": 34.4576271186,
"ext": "agda",
"hexsha": "34ebc3cea8ee93b271bc4a971c10e4cda200e882",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-12-26T21:31:57.000Z",
"max_forks_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "mikeshulman/HoTT-Agda",
"max_forks_repo_path": "theorems/groups/KernelSndImageInl.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "mikeshulman/HoTT-Agda",
"max_issues_repo_path": "theorems/groups/KernelSndImageInl.agda",
"max_line_length": 87,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e7d663b63d89f380ab772ecb8d51c38c26952dbb",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "mikeshulman/HoTT-Agda",
"max_stars_repo_path": "theorems/groups/KernelSndImageInl.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 806,
"size": 2033
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Data.Unit.Base where
-- Obtain Unit
open import Agda.Builtin.Unit public
renaming ( ⊤ to Unit )
| {
"alphanum_fraction": 0.703030303,
"avg_line_length": 23.5714285714,
"ext": "agda",
"hexsha": "7704ffbc29a9bd506a9246f0a3081e5ce340c946",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-22T02:02:01.000Z",
"max_forks_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "knrafto/cubical",
"max_forks_repo_path": "Cubical/Data/Unit/Base.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "knrafto/cubical",
"max_issues_repo_path": "Cubical/Data/Unit/Base.agda",
"max_line_length": 50,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "knrafto/cubical",
"max_stars_repo_path": "Cubical/Data/Unit/Base.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 43,
"size": 165
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Bisimilarity for Cowriter
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe --sized-types #-}
module Codata.Cowriter.Bisimilarity where
open import Level using (Level; _⊔_)
open import Size
open import Codata.Thunk
open import Codata.Cowriter
open import Relation.Binary
open import Relation.Binary.PropositionalEquality as Eq using (_≡_)
private
variable
a b c p q pq r s rs v w x : Level
A : Set a
B : Set b
C : Set c
V : Set v
W : Set w
X : Set x
i : Size
data Bisim {V : Set v} {W : Set w} {A : Set a} {B : Set b}
(R : REL V W r) (S : REL A B s) (i : Size) :
REL (Cowriter V A ∞) (Cowriter W B ∞) (r ⊔ s ⊔ v ⊔ w ⊔ a ⊔ b) where
[_] : ∀ {a b} → S a b → Bisim R S i [ a ] [ b ]
_∷_ : ∀ {x y xs ys} → R x y → Thunk^R (Bisim R S) i xs ys →
Bisim R S i (x ∷ xs) (y ∷ ys)
module _ {R : Rel W r} {S : Rel A s}
(refl^R : Reflexive R) (refl^S : Reflexive S) where
reflexive : Reflexive (Bisim R S i)
reflexive {x = [ a ]} = [ refl^S ]
reflexive {x = w ∷ ws} = refl^R ∷ λ where .force → reflexive
module _ {R : REL V W r} {S : REL W V s} {P : REL A B p} {Q : REL B A q}
(sym^RS : Sym R S) (sym^PQ : Sym P Q) where
symmetric : Sym (Bisim R P i) (Bisim S Q i)
symmetric [ a ] = [ sym^PQ a ]
symmetric (p ∷ ps) = sym^RS p ∷ λ where .force → symmetric (ps .force)
module _ {R : REL V W r} {S : REL W X s} {RS : REL V X rs}
{P : REL A B p} {Q : REL B C q} {PQ : REL A C pq}
(trans^RS : Trans R S RS) (trans^PQ : Trans P Q PQ) where
transitive : Trans (Bisim R P i) (Bisim S Q i) (Bisim RS PQ i)
transitive [ p ] [ q ] = [ trans^PQ p q ]
transitive (p ∷ ps) (q ∷ qs) =
trans^RS p q ∷ λ where .force → transitive (ps .force) (qs .force)
-- Pointwise Equality as a Bisimilarity
------------------------------------------------------------------------
module _ {W : Set w} {A : Set a} where
infix 1 _⊢_≈_
_⊢_≈_ : ∀ i → Cowriter W A ∞ → Cowriter W A ∞ → Set (a ⊔ w)
_⊢_≈_ = Bisim _≡_ _≡_
refl : Reflexive (i ⊢_≈_)
refl = reflexive Eq.refl Eq.refl
fromEq : ∀ {as bs} → as ≡ bs → i ⊢ as ≈ bs
fromEq Eq.refl = refl
sym : Symmetric (i ⊢_≈_)
sym = symmetric Eq.sym Eq.sym
trans : Transitive (i ⊢_≈_)
trans = transitive Eq.trans Eq.trans
module _ {R : Rel W r} {S : Rel A s}
(equiv^R : IsEquivalence R) (equiv^S : IsEquivalence S) where
private
module equiv^R = IsEquivalence equiv^R
module equiv^S = IsEquivalence equiv^S
isEquivalence : IsEquivalence (Bisim R S i)
isEquivalence = record
{ refl = reflexive equiv^R.refl equiv^S.refl
; sym = symmetric equiv^R.sym equiv^S.sym
; trans = transitive equiv^R.trans equiv^S.trans
}
setoid : Setoid w r → Setoid a s → Size → Setoid (w ⊔ a) (w ⊔ a ⊔ r ⊔ s)
setoid R S i = record
{ isEquivalence = isEquivalence (Setoid.isEquivalence R)
(Setoid.isEquivalence S) {i = i}
}
module ≈-Reasoning {W : Set w} {A : Set a} {i} where
open import Relation.Binary.Reasoning.Setoid
(setoid (Eq.setoid W) (Eq.setoid A) i) public
| {
"alphanum_fraction": 0.5368839914,
"avg_line_length": 31.1142857143,
"ext": "agda",
"hexsha": "78fc8cebf820b248feab06b70148f5b3d67f6610",
"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/Codata/Cowriter/Bisimilarity.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/Codata/Cowriter/Bisimilarity.agda",
"max_line_length": 78,
"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/Codata/Cowriter/Bisimilarity.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": 1158,
"size": 3267
} |
{-# OPTIONS --without-K #-}
module Ch2-3 where
open import Level hiding (lift)
open import Ch2-1
open import Ch2-2
-- p
-- x ~~~~~~~~~ y
--
--
-- P x --------> P y
--
-- Lemma 2.3.1 (transport)
transport : ∀ {a b} {A : Set a} {x y : A}
→ (P : A → Set b)
→ (p : x ≡ y)
→ P x → P y
transport {a} {b} {A} {x} {y} P p = J A D d x y p P
-- J A D d x y p P
where
-- the predicate
D : (x y : A) (p : x ≡ y) → Set (a ⊔ suc b)
D x y p = (P : A → Set b) → P x → P y
-- base case
d : (x : A) → D x x refl
d x P y = y
open import Data.Product
-- proof
-- +-----+ p +-----+
-- | x ~~~~~~~~~~~~~~~~ y |
-- | | | |
-- | P x |~~~~~~~~~~~~| P y |
-- +-----+ * +-----+
--
-- Lemma 2.3.2 (path lifting property)
lift : ∀ {a b} {A : Set a}
→ (P : A → Set b)
→ (proof : Σ[ x ∈ A ] P x)
→ (y : A)
→ (p : proj₁ proof ≡ y)
→ proof ≡ (y , transport P p (proj₂ proof))
lift {a} {b} {A} P proof y p = J A D d (proj₁ proof) y p (proj₂ proof)
where
-- the predicate
D : (x y : A) (p : x ≡ y) → Set (a ⊔ b)
D x y p = (u : P x) → (x , u) ≡ (y , transport P p u)
-- base case
d : (x : A) → D x x refl
d x u = refl
-- A
-- +----------------------------------------------+
-- | p |
-- | x ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ y |
-- | + + |
-- +----------------------------------------------+
-- | |
-- P x | P y |
-- +-------+ +----------------------------------+
-- | v | | * v |
-- | f x +-------> transport P p (f x) ~~~~~ f y |
-- | | | |
-- +-------+ +----------------------------------+
--
-- Lemma 2.3.4 (dependent map)
apd : ∀ {a b} {A : Set a} {x y : A}
→ {P : A → Set b}
→ (f : (z : A) → P z)
→ (p : x ≡ y)
→ transport P p (f x) ≡ f y
apd {a} {b} {A} {x} {y} {P} f p = J A D d x y p P f
where
-- the predicate
D : (x y : A) (p : x ≡ y) → _
D x y p = (P : A → Set b) (f : (z : A) → P z) → transport P p (f x) ≡ f y
-- base case
d : (x : A) → D x x refl
d x P f = refl
open import Function using (const; _∘_)
-- Lemma 2.3.5
transportconst : ∀ {a ℓ} {A : Set a} {x y : A}
→ {B : Set ℓ}
→ (p : x ≡ y)
→ (b : B)
→ transport (const B) p b ≡ b
transportconst {a} {ℓ} {A} {x} {y} {B} p b = J A D d x y p B b
where
-- the predicate
D : (x y : A) (p : x ≡ y) → _
D x y p = (B : Set ℓ) (b : B) → transport (const B) p b ≡ b
-- base case
d : (x : A) → D x x refl
d x B b = refl
open import Ch2-2
-- Lemma 2.3.8
lemma-2-3-8 : ∀ {a ℓ} {A : Set a} {B : Set ℓ} {x y : A}
→ (f : A → B)
→ (p : x ≡ y)
→ apd f p ≡ transportconst p (f x) ∙ ap f p
lemma-2-3-8 {a} {ℓ} {A} {B} {x} {y} f p = J {a} {a ⊔ ℓ} A D d x y p f
where
-- the predicate
D : (x y : A) (p : x ≡ y) → _
D x y p = (f : A → B) → apd f p ≡ transportconst p (f x) ∙ ap f p
-- base case
d : (x : A) → D x x refl
d x f = refl
-- Lemma 2.3.9
lemma-2-3-9 : ∀ {a b} {A : Set a} {x y z : A}
→ (P : A → Set b)
→ (p : x ≡ y)
→ (q : y ≡ z)
→ (u : P x)
→ transport P q (transport P p u) ≡ transport P (p ∙ q) u
lemma-2-3-9 {a} {b} {A} {x} {y} {z} P p q u = J A D d x y p P z q u
where
-- the predicate
D : (x y : A) (p : x ≡ y) → Set _
D x y p = (P : A → Set b) (z : A) (q : y ≡ z) (u : P x)
→ transport P q (transport P p u) ≡ transport P (p ∙ q) u
-- base case
d : (x : A) → D x x refl
d x P z q u = J A E e x z q P u
where
-- the predicate
E : (x z : A) (q : x ≡ z) → Set _
E x z q = (P : A → Set b) (u : P x)
→ transport P q (transport P refl u) ≡ transport P (refl ∙ q) u
-- base case
e : (x : A) → E x x refl
e x P u = refl
-- Lemma 2.3.10
lemma-2-3-10 : ∀ {a b c} {A : Set a} {B : Set b} {x y : A}
→ (P : B → Set c)
→ (f : A → B)
→ (p : x ≡ y)
→ (u : P (f x))
→ transport (P ∘ f) p u ≡ transport P (ap f p) u
lemma-2-3-10 {a} {b} {c} {A} {B} {x} {y} P f p u = J A D d x y p P f u
where
-- the predicate
D : (x y : A) (p : x ≡ y) → Set _
D x y p = (P : B → Set c) (f : A → B) (u : P (f x))
→ transport (P ∘ f) p u ≡ transport P (ap f p) u
-- base case
d : (x : A) → D x x refl
d x P f u = refl
-- Lemma 2.3.11
lemma-2-3-11 : {a b c : Level} {A : Set a} {x y : A}
→ (P : A → Set b) (Q : A → Set c)
→ (f : (z : A) → P z → Q z)
→ (p : x ≡ y)
→ (u : P x)
→ transport Q p (f x u) ≡ f y (transport P p u)
lemma-2-3-11 {a} {b} {c} {A} {x} {y} P Q f p u = J A D d x y p P Q f u
-- J A D d x y p {! !} {! !} {! !} {! !}
where
-- the predicate
D : (x y : A) (p : x ≡ y) → Set _
D x y p = (P : A → Set b) (Q : A → Set c) (f : (z : A) → P z → Q z) (u : P x)
→ transport Q p (f x u) ≡ f y (transport P p u)
-- base case
d : (x : A) → D x x refl
d x P Q f u = refl
| {
"alphanum_fraction": 0.3598432909,
"avg_line_length": 27.2994652406,
"ext": "agda",
"hexsha": "dcfaac7d15921f3446b3004f77a25b2e9d518847",
"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": "75eea99a879e100304bd48c538c9d2db0b4a4ff3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "banacorn/hott",
"max_forks_repo_path": "src/Ch2-3.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "75eea99a879e100304bd48c538c9d2db0b4a4ff3",
"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/hott",
"max_issues_repo_path": "src/Ch2-3.agda",
"max_line_length": 81,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "75eea99a879e100304bd48c538c9d2db0b4a4ff3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "banacorn/hott",
"max_stars_repo_path": "src/Ch2-3.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 2166,
"size": 5105
} |
module Rationals.Multiply.Comm where
open import Equality
open import Rationals
open import Nats.Multiply.Comm
------------------------------------------------------------------------
-- internal stuffs
private
a*b=b*a : ∀ x y → x * y ≡ y * x
a*b=b*a (a ÷ c) (b ÷ d)
rewrite nat-multiply-comm a b
| nat-multiply-comm c d
= refl
------------------------------------------------------------------------
-- public aliases
rational-multiply-comm : ∀ x y → x * y ≡ y * x
rational-multiply-comm = a*b=b*a
| {
"alphanum_fraction": 0.4523364486,
"avg_line_length": 23.2608695652,
"ext": "agda",
"hexsha": "e1e8ca4d2ed3b555d51509d9a342204627455cf5",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc",
"max_forks_repo_licenses": [
"Apache-2.0"
],
"max_forks_repo_name": "ice1k/Theorems",
"max_forks_repo_path": "src/Rationals/Multiply/Comm.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"Apache-2.0"
],
"max_issues_repo_name": "ice1k/Theorems",
"max_issues_repo_path": "src/Rationals/Multiply/Comm.agda",
"max_line_length": 72,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "7dc0ea4782a5ff960fe31bdcb8718ce478eaddbc",
"max_stars_repo_licenses": [
"Apache-2.0"
],
"max_stars_repo_name": "ice1k/Theorems",
"max_stars_repo_path": "src/Rationals/Multiply/Comm.agda",
"max_stars_repo_stars_event_max_datetime": "2020-04-15T15:28:03.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-04-15T15:28:03.000Z",
"num_tokens": 130,
"size": 535
} |
open import MLib.Algebra.PropertyCode
open import MLib.Algebra.PropertyCode.Structures
module MLib.Matrix {c ℓ} (struct : Struct bimonoidCode c ℓ) where
open import MLib.Prelude
open Struct struct
open import MLib.Algebra.Operations struct
open Table using (head; tail; rearrange; fromList; toList; _≗_)
open import MLib.Matrix.Core public
open import MLib.Matrix.Equality struct public
open import MLib.Matrix.Plus struct public
open import MLib.Matrix.Mul struct public
open import MLib.Matrix.Tensor struct public
open import MLib.Matrix.SemiTensor struct public
open FunctionProperties
| {
"alphanum_fraction": 0.8232323232,
"avg_line_length": 31.2631578947,
"ext": "agda",
"hexsha": "47a4357270cd32453b4c30bb5f243f78d1d6a2dd",
"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/Matrix.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/Matrix.agda",
"max_line_length": 65,
"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/Matrix.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 148,
"size": 594
} |
-- This file serves to aggregate all the top-level dependencies in the Silica project.
open import preservation
open import progress
| {
"alphanum_fraction": 0.8134328358,
"avg_line_length": 26.8,
"ext": "agda",
"hexsha": "ad292d398135db1f26eb02da70e96e8f63241544",
"lang": "Agda",
"max_forks_count": 11,
"max_forks_repo_forks_event_max_datetime": "2021-06-09T18:40:19.000Z",
"max_forks_repo_forks_event_min_datetime": "2018-05-24T08:20:52.000Z",
"max_forks_repo_head_hexsha": "bda0fac3aadfbce2eacdb89095d100125fa4fdd6",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "ivoysey/Obsidian",
"max_forks_repo_path": "formalization/all.agda",
"max_issues_count": 259,
"max_issues_repo_head_hexsha": "bda0fac3aadfbce2eacdb89095d100125fa4fdd6",
"max_issues_repo_issues_event_max_datetime": "2022-03-29T18:20:05.000Z",
"max_issues_repo_issues_event_min_datetime": "2017-08-18T19:50:41.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "ivoysey/Obsidian",
"max_issues_repo_path": "formalization/all.agda",
"max_line_length": 86,
"max_stars_count": 79,
"max_stars_repo_head_hexsha": "bda0fac3aadfbce2eacdb89095d100125fa4fdd6",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "ivoysey/Obsidian",
"max_stars_repo_path": "formalization/all.agda",
"max_stars_repo_stars_event_max_datetime": "2022-03-27T10:34:28.000Z",
"max_stars_repo_stars_event_min_datetime": "2017-08-19T16:24:10.000Z",
"num_tokens": 25,
"size": 134
} |
{-# OPTIONS --without-K --exact-split #-}
module 07-equivalences where
import 06-universes
open 06-universes public
-- Section 7.1 Homotopies
-- Definition 7.1.1
_~_ :
{i j : Level} {A : UU i} {B : A → UU j} (f g : (x : A) → B x) → UU (i ⊔ j)
f ~ g = (x : _) → Id (f x) (g x)
-- Definition 7.1.2
refl-htpy :
{i j : Level} {A : UU i} {B : A → UU j} {f : (x : A) → B x} → f ~ f
refl-htpy x = refl
{- Most of the time we get by with refl-htpy. However, sometimes Agda wants us
to specify the implicit argument. The it is easier to call refl-htpy' than
to use Agda's {f = ?} notation. -}
refl-htpy' :
{i j : Level} {A : UU i} {B : A → UU j} (f : (x : A) → B x) → f ~ f
refl-htpy' f = refl-htpy
htpy-inv :
{i j : Level} {A : UU i} {B : A → UU j} {f g : (x : A) → B x} →
(f ~ g) → (g ~ f)
htpy-inv H x = inv (H x)
_∙h_ :
{i j : Level} {A : UU i} {B : A → UU j} {f g h : (x : A) → B x} →
(f ~ g) → (g ~ h) → (f ~ h)
_∙h_ H K x = (H x) ∙ (K x)
htpy-concat :
{i j : Level} {A : UU i} {B : A → UU j} {f g : (x : A) → B x} →
(f ~ g) → (h : (x : A) → B x) → (g ~ h) → (f ~ h)
htpy-concat H h K x = concat (H x) (h x) (K x)
htpy-concat' :
{l1 l2 : Level} {A : UU l1} {B : A → UU l2}
(f : (x : A) → B x) {g h : (x : A) → B x} →
(g ~ h) → (f ~ g) → (f ~ h)
htpy-concat' f K H = H ∙h K
htpy-assoc :
{i j : Level} {A : UU i} {B : A → UU j} {f g h k : (x : A) → B x} →
(H : f ~ g) → (K : g ~ h) → (L : h ~ k) →
((H ∙h K) ∙h L) ~ (H ∙h (K ∙h L))
htpy-assoc H K L x = assoc (H x) (K x) (L x)
htpy-left-unit :
{i j : Level} {A : UU i} {B : A → UU j} {f g : (x : A) → B x}
{H : f ~ g} → (refl-htpy ∙h H) ~ H
htpy-left-unit x = left-unit
htpy-right-unit :
{i j : Level} {A : UU i} {B : A → UU j} {f g : (x : A) → B x}
{H : f ~ g} → (H ∙h refl-htpy) ~ H
htpy-right-unit x = right-unit
htpy-left-inv :
{i j : Level} {A : UU i} {B : A → UU j} {f g : (x : A) → B x}
(H : f ~ g) → ((htpy-inv H) ∙h H) ~ refl-htpy
htpy-left-inv H x = left-inv (H x)
htpy-right-inv :
{i j : Level} {A : UU i} {B : A → UU j} {f g : (x : A) → B x}
(H : f ~ g) → (H ∙h (htpy-inv H)) ~ refl-htpy
htpy-right-inv H x = right-inv (H x)
-- Definition 7.1.3
htpy-left-whisk :
{i j k : Level} {A : UU i} {B : UU j} {C : UU k}
(h : B → C) {f g : A → B} → (f ~ g) → ((h ∘ f) ~ (h ∘ g))
htpy-left-whisk h H x = ap h (H x)
_·l_ = htpy-left-whisk
htpy-right-whisk :
{i j k : Level} {A : UU i} {B : UU j} {C : UU k}
{g h : B → C} (H : g ~ h) (f : A → B) → ((g ∘ f) ~ (h ∘ f))
htpy-right-whisk H f x = H (f x)
_·r_ = htpy-right-whisk
-- Section 7.2 Bi-invertible maps
-- Definition 7.2.1
sec :
{i j : Level} {A : UU i} {B : UU j} (f : A → B) → UU (i ⊔ j)
sec {i} {j} {A} {B} f = Σ (B → A) (λ g → (f ∘ g) ~ id)
retr :
{i j : Level} {A : UU i} {B : UU j} (f : A → B) → UU (i ⊔ j)
retr {i} {j} {A} {B} f = Σ (B → A) (λ g → (g ∘ f) ~ id)
_retract-of_ :
{i j : Level} → UU i → UU j → UU (i ⊔ j)
A retract-of B = Σ (A → B) retr
section-retract-of :
{i j : Level} {A : UU i} {B : UU j} → A retract-of B → A → B
section-retract-of = pr1
retr-section-retract-of :
{i j : Level} {A : UU i} {B : UU j} (R : A retract-of B) →
retr (section-retract-of R)
retr-section-retract-of = pr2
retraction-retract-of :
{i j : Level} {A : UU i} {B : UU j} → (A retract-of B) → B → A
retraction-retract-of R = pr1 (retr-section-retract-of R)
is-retr-retraction-retract-of :
{i j : Level} {A : UU i} {B : UU j} (R : A retract-of B) →
((retraction-retract-of R) ∘ (section-retract-of R)) ~ id
is-retr-retraction-retract-of R = pr2 (retr-section-retract-of R)
is-equiv :
{i j : Level} {A : UU i} {B : UU j} (f : A → B) → UU (i ⊔ j)
is-equiv f = sec f × retr f
_≃_ :
{i j : Level} (A : UU i) (B : UU j) → UU (i ⊔ j)
A ≃ B = Σ (A → B) (λ f → is-equiv f)
map-equiv :
{i j : Level} {A : UU i} {B : UU j} → (A ≃ B) → (A → B)
map-equiv e = pr1 e
is-equiv-map-equiv :
{i j : Level} {A : UU i} {B : UU j} (e : A ≃ B) → is-equiv (map-equiv e)
is-equiv-map-equiv e = pr2 e
-- Remark 7.2.2
has-inverse :
{i j : Level} {A : UU i} {B : UU j} (f : A → B) → UU (i ⊔ j)
has-inverse {i} {j} {A} {B} f =
Σ (B → A) (λ g → ((f ∘ g) ~ id) × ((g ∘ f) ~ id))
is-equiv-has-inverse' :
{i j : Level} {A : UU i} {B : UU j} {f : A → B} →
has-inverse f → is-equiv f
is-equiv-has-inverse' (pair g (pair H K)) = pair (pair g H) (pair g K)
is-equiv-has-inverse :
{i j : Level} {A : UU i} {B : UU j} {f : A → B} →
(g : B → A) (H : (f ∘ g) ~ id) (K : (g ∘ f) ~ id) → is-equiv f
is-equiv-has-inverse g H K =
is-equiv-has-inverse' (pair g (pair H K))
-- Lemma 7.2.3
{- We now show that if f is an equivalence, then it has an inverse. -}
htpy-section-retraction :
{ i j : Level} {A : UU i} {B : UU j} {f : A → B}
( is-equiv-f : is-equiv f) →
( (pr1 (pr1 is-equiv-f))) ~ (pr1 (pr2 is-equiv-f))
htpy-section-retraction {i} {j} {A} {B} {f} (pair (pair g G) (pair h H)) =
(htpy-inv (H ·r g)) ∙h (h ·l G)
has-inverse-is-equiv :
{i j : Level} {A : UU i} {B : UU j} {f : A → B} →
is-equiv f → has-inverse f
has-inverse-is-equiv {i} {j} {A} {B} {f} (pair (pair g G) (pair h H)) =
let is-equiv-f = pair (pair g G) (pair h H) in
pair g (pair G (((htpy-section-retraction is-equiv-f) ·r f) ∙h H))
-- Corollary 7.2.4
inv-is-equiv :
{i j : Level} {A : UU i} {B : UU j} {f : A → B} → is-equiv f → B → A
inv-is-equiv is-equiv-f = pr1 (has-inverse-is-equiv is-equiv-f)
issec-inv-is-equiv :
{i j : Level} {A : UU i} {B : UU j} {f : A → B} →
(is-equiv-f : is-equiv f) → (f ∘ (inv-is-equiv is-equiv-f)) ~ id
issec-inv-is-equiv is-equiv-f = pr1 (pr2 (has-inverse-is-equiv is-equiv-f))
isretr-inv-is-equiv :
{i j : Level} {A : UU i} {B : UU j} {f : A → B} →
(is-equiv-f : is-equiv f) → ((inv-is-equiv is-equiv-f) ∘ f) ~ id
isretr-inv-is-equiv is-equiv-f = pr2 (pr2 (has-inverse-is-equiv is-equiv-f))
is-equiv-inv-is-equiv :
{i j : Level} {A : UU i} {B : UU j} {f : A → B} →
(is-equiv-f : is-equiv f) → is-equiv (inv-is-equiv is-equiv-f)
is-equiv-inv-is-equiv {i} {j} {A} {B} {f} is-equiv-f =
is-equiv-has-inverse f
( isretr-inv-is-equiv is-equiv-f)
( issec-inv-is-equiv is-equiv-f)
inv-map-equiv :
{i j : Level} {A : UU i} {B : UU j} → (A ≃ B) → (B → A)
inv-map-equiv e = inv-is-equiv (is-equiv-map-equiv e)
is-equiv-inv-map-equiv :
{i j : Level} {A : UU i} {B : UU j} (e : A ≃ B) → is-equiv (inv-map-equiv e)
is-equiv-inv-map-equiv e =
is-equiv-inv-is-equiv (is-equiv-map-equiv e)
inv-equiv :
{i j : Level} {A : UU i} {B : UU j} → (A ≃ B) → (B ≃ A)
inv-equiv e = pair (inv-map-equiv e) (is-equiv-inv-map-equiv e)
-- Remark 7.2.5
is-equiv-id :
{i : Level} (A : UU i) → is-equiv (id {i} {A})
is-equiv-id A = pair (pair id refl-htpy) (pair id refl-htpy)
equiv-id :
{i : Level} (A : UU i) → A ≃ A
equiv-id A = pair id (is-equiv-id A)
-- Example 7.2.6
inv-Π-swap :
{i j k : Level} {A : UU i} {B : UU j} (C : A → B → UU k) →
((y : B) (x : A) → C x y) → ((x : A) (y : B) → C x y)
inv-Π-swap C g x y = g y x
abstract
is-equiv-Π-swap :
{i j k : Level} {A : UU i} {B : UU j} (C : A → B → UU k) →
is-equiv (Π-swap {i} {j} {k} {A} {B} {C})
is-equiv-Π-swap C =
is-equiv-has-inverse
( inv-Π-swap C)
( refl-htpy)
( refl-htpy)
-- Section 7.3 The identity type of a Σ-type
-- Definition 7.3.1
Eq-Σ :
{i j : Level} {A : UU i} {B : A → UU j} (s t : Σ A B) → UU (i ⊔ j)
Eq-Σ {B = B} s t = Σ (Id (pr1 s) (pr1 t)) (λ α → Id (tr B α (pr2 s)) (pr2 t))
-- Lemma 7.3.2
reflexive-Eq-Σ :
{i j : Level} {A : UU i} {B : A → UU j} (s : Σ A B) → Eq-Σ s s
reflexive-Eq-Σ (pair a b) = pair refl refl
-- Definition 7.3.3
pair-eq :
{i j : Level} {A : UU i} {B : A → UU j} {s t : Σ A B} →
(Id s t) → Eq-Σ s t
pair-eq {s = s} refl = reflexive-Eq-Σ s
-- Theorem 7.3.4
eq-pair :
{i j : Level} {A : UU i} {B : A → UU j} {s t : Σ A B} →
(α : Id (pr1 s) (pr1 t)) → Id (tr B α (pr2 s)) (pr2 t) → Id s t
eq-pair {B = B} {pair x y} {pair .x .y} refl refl = refl
eq-pair' :
{i j : Level} {A : UU i} {B : A → UU j} {s t : Σ A B} →
Eq-Σ s t → Id s t
eq-pair' (pair α β) = eq-pair α β
isretr-pair-eq :
{i j : Level} {A : UU i} {B : A → UU j} (s t : Σ A B) →
((pair-eq {s = s} {t}) ∘ (eq-pair' {s = s} {t})) ~ id {A = Eq-Σ s t}
isretr-pair-eq (pair x y) (pair .x .y) (pair refl refl) = refl
issec-pair-eq :
{i j : Level} {A : UU i} {B : A → UU j} (s t : Σ A B) →
((eq-pair' {s = s} {t}) ∘ (pair-eq {s = s} {t})) ~ id
issec-pair-eq (pair x y) .(pair x y) refl = refl
abstract
is-equiv-eq-pair :
{i j : Level} {A : UU i} {B : A → UU j} (s t : Σ A B) →
is-equiv (eq-pair' {s = s} {t})
is-equiv-eq-pair s t =
is-equiv-has-inverse
( pair-eq)
( issec-pair-eq s t)
( isretr-pair-eq s t)
abstract
is-equiv-pair-eq :
{i j : Level} {A : UU i} {B : A → UU j} (s t : Σ A B) →
is-equiv (pair-eq {s = s} {t})
is-equiv-pair-eq s t =
is-equiv-has-inverse
( eq-pair')
( isretr-pair-eq s t)
( issec-pair-eq s t)
η-pair :
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} (t : Σ A B) →
Id (pair (pr1 t) (pr2 t)) t
η-pair t = eq-pair refl refl
{- For our convenience, we repeat the above argument for cartesian products. -}
Eq-prod :
{i j : Level} {A : UU i} {B : UU j} (s t : A × B) → UU (i ⊔ j)
Eq-prod s t = (Id (pr1 s) (pr1 t)) × (Id (pr2 s) (pr2 t))
{- We also define a function eq-pair-triv, which is like eq-pair but simplified
for the case where B is just a type. -}
eq-pair-triv' :
{i j : Level} {A : UU i} {B : UU j} (s t : prod A B) →
Eq-prod s t → Id s t
eq-pair-triv' (pair x y) (pair .x .y) (pair refl refl) = refl
eq-pair-triv :
{i j : Level} {A : UU i} {B : UU j} {s t : prod A B} →
Eq-prod s t → Id s t
eq-pair-triv {s = s} {t} = eq-pair-triv' s t
{- Ideally, we would use the 3-for-2 property of equivalences to show that
eq-pair-triv is an equivalence, using that eq-pair is an equivalence.
Indeed, there is an equivalence
(Id x x') × (Id y y') → Σ (Id x x') (λ p → Id (tr (λ x → B) p y) y').
However, to show that this map is an equivalence we either give a direct
proof (in which case we might as well have given a direct proof that
eq-pair-triv is an equivalence), or we use the fact that it is the induced
map on total spaces of a fiberwise equivalence (the topic of Lecture 8).
Thus it seems that a direct proof showing that eq-pair-triv is an
equivalence is quickest for now. -}
pair-eq-triv' :
{i j : Level} {A : UU i} {B : UU j} (s t : prod A B) →
Id s t → Eq-prod s t
pair-eq-triv' s t α = pair (ap pr1 α) (ap pr2 α)
isretr-pair-eq-triv' :
{i j : Level} {A : UU i} {B : UU j} (s t : prod A B) →
((pair-eq-triv' s t) ∘ (eq-pair-triv' s t)) ~ id
isretr-pair-eq-triv' (pair x y) (pair .x .y) (pair refl refl) = refl
issec-pair-eq-triv' :
{i j : Level} {A : UU i} {B : UU j} (s t : prod A B) →
((eq-pair-triv' s t) ∘ (pair-eq-triv' s t)) ~ id
issec-pair-eq-triv' (pair x y) (pair .x .y) refl = refl
abstract
is-equiv-eq-pair-triv' :
{i j : Level} {A : UU i} {B : UU j} (s t : prod A B) →
is-equiv (eq-pair-triv' s t)
is-equiv-eq-pair-triv' s t =
is-equiv-has-inverse
( pair-eq-triv' s t)
( issec-pair-eq-triv' s t)
( isretr-pair-eq-triv' s t)
-- Exercises
-- Exercise 7.1
{- We show that inv is an equivalence. -}
inv-inv :
{i : Level} {A : UU i} {x y : A} (p : Id x y) → Id (inv (inv p)) p
inv-inv refl = refl
abstract
is-equiv-inv :
{i : Level} {A : UU i} (x y : A) →
is-equiv (λ (p : Id x y) → inv p)
is-equiv-inv x y =
is-equiv-has-inverse inv inv-inv inv-inv
equiv-inv :
{i : Level} {A : UU i} (x y : A) → (Id x y) ≃ (Id y x)
equiv-inv x y = pair inv (is-equiv-inv x y)
{- We show that concat p is an equivalence, for any path p. -}
inv-concat :
{i : Level} {A : UU i} {x y : A} (p : Id x y) (z : A) →
(Id x z) → (Id y z)
inv-concat p = concat (inv p)
isretr-inv-concat :
{i : Level} {A : UU i} {x y : A} (p : Id x y) (z : A) →
((inv-concat p z) ∘ (concat p z)) ~ id
isretr-inv-concat refl z q = refl
issec-inv-concat :
{i : Level} {A : UU i} {x y : A} (p : Id x y) (z : A) →
((concat p z) ∘ (inv-concat p z)) ~ id
issec-inv-concat refl z refl = refl
abstract
is-equiv-concat :
{i : Level} {A : UU i} {x y : A} (p : Id x y) (z : A) →
is-equiv (concat p z)
is-equiv-concat p z =
is-equiv-has-inverse
( inv-concat p z)
( issec-inv-concat p z)
( isretr-inv-concat p z)
equiv-concat :
{i : Level} {A : UU i} {x y : A} (p : Id x y) (z : A) →
Id y z ≃ Id x z
equiv-concat p z = pair (concat p z) (is-equiv-concat p z)
{- We show that concat' q is an equivalence, for any path q. -}
concat' :
{i : Level} {A : UU i} (x : A) {y z : A} → Id y z → Id x y → Id x z
concat' x q p = p ∙ q
inv-concat' :
{i : Level} {A : UU i} (x : A) {y z : A} → Id y z →
Id x z → Id x y
inv-concat' x q = concat' x (inv q)
isretr-inv-concat' :
{i : Level} {A : UU i} (x : A) {y z : A} (q : Id y z) →
((inv-concat' x q) ∘ (concat' x q)) ~ id
isretr-inv-concat' x refl refl = refl
issec-inv-concat' :
{i : Level} {A : UU i} (x : A) {y z : A} (q : Id y z) →
((concat' x q) ∘ (inv-concat' x q)) ~ id
issec-inv-concat' x refl refl = refl
abstract
is-equiv-concat' :
{i : Level} {A : UU i} (x : A) {y z : A} (q : Id y z) →
is-equiv (concat' x q)
is-equiv-concat' x q =
is-equiv-has-inverse
( inv-concat' x q)
( issec-inv-concat' x q)
( isretr-inv-concat' x q)
equiv-concat' :
{i : Level} {A : UU i} (x : A) {y z : A} (q : Id y z) →
Id x y ≃ Id x z
equiv-concat' x q = pair (concat' x q) (is-equiv-concat' x q)
{- We show that tr B p is an equivalence, for an path p and any type family B.
-}
inv-tr :
{i j : Level} {A : UU i} (B : A → UU j) {x y : A} →
Id x y → B y → B x
inv-tr B p = tr B (inv p)
isretr-inv-tr :
{i j : Level} {A : UU i} (B : A → UU j) {x y : A}
(p : Id x y) → ((inv-tr B p ) ∘ (tr B p)) ~ id
isretr-inv-tr B refl b = refl
issec-inv-tr :
{i j : Level} {A : UU i} (B : A → UU j) {x y : A}
(p : Id x y) → ((tr B p) ∘ (inv-tr B p)) ~ id
issec-inv-tr B refl b = refl
abstract
is-equiv-tr :
{i j : Level} {A : UU i} (B : A → UU j) {x y : A}
(p : Id x y) → is-equiv (tr B p)
is-equiv-tr B p =
is-equiv-has-inverse
( inv-tr B p)
( issec-inv-tr B p)
( isretr-inv-tr B p)
equiv-tr :
{i j : Level} {A : UU i} (B : A → UU j) {x y : A}
(p : Id x y) → (B x) ≃ (B y)
equiv-tr B p = pair (tr B p) (is-equiv-tr B p)
-- Exercise 7.2
{- We prove the left unit law for coproducts. -}
inv-inr-coprod-empty :
{l : Level} (X : UU l) → coprod empty X → X
inv-inr-coprod-empty X (inr x) = x
issec-inv-inr-coprod-empty :
{l : Level} (X : UU l) → (inr ∘ (inv-inr-coprod-empty X)) ~ id
issec-inv-inr-coprod-empty X (inr x) = refl
isretr-inv-inr-coprod-empty :
{l : Level} (X : UU l) → ((inv-inr-coprod-empty X) ∘ inr) ~ id
isretr-inv-inr-coprod-empty X x = refl
is-equiv-inr-coprod-empty :
{l : Level} (X : UU l) → is-equiv (inr {A = empty} {B = X})
is-equiv-inr-coprod-empty X =
is-equiv-has-inverse
( inv-inr-coprod-empty X)
( issec-inv-inr-coprod-empty X)
( isretr-inv-inr-coprod-empty X)
left-unit-law-coprod :
{l : Level} (X : UU l) → X ≃ (coprod empty X)
left-unit-law-coprod X = pair inr (is-equiv-inr-coprod-empty X)
{- We prove the right unit law for coproducts. -}
inv-inl-coprod-empty :
{l : Level} (X : UU l) → (coprod X empty) → X
inv-inl-coprod-empty X (inl x) = x
issec-inv-inl-coprod-empty :
{l : Level} (X : UU l) → (inl ∘ (inv-inl-coprod-empty X)) ~ id
issec-inv-inl-coprod-empty X (inl x) = refl
isretr-inv-inl-coprod-empty :
{l : Level} (X : UU l) → ((inv-inl-coprod-empty X) ∘ inl) ~ id
isretr-inv-inl-coprod-empty X x = refl
is-equiv-inl-coprod-empty :
{l : Level} (X : UU l) → is-equiv (inl {A = X} {B = empty})
is-equiv-inl-coprod-empty X =
is-equiv-has-inverse
( inv-inl-coprod-empty X)
( issec-inv-inl-coprod-empty X)
( isretr-inv-inl-coprod-empty X)
right-unit-law-coprod :
{l : Level} (X : UU l) → X ≃ (coprod X empty)
right-unit-law-coprod X =
pair inl (is-equiv-inl-coprod-empty X)
{- We prove a left zero law for cartesian products. -}
inv-pr1-prod-empty :
{l : Level} (X : UU l) → empty → empty × X
inv-pr1-prod-empty X ()
issec-inv-pr1-prod-empty :
{l : Level} (X : UU l) → (pr1 ∘ (inv-pr1-prod-empty X)) ~ id
issec-inv-pr1-prod-empty X ()
isretr-inv-pr1-prod-empty :
{l : Level} (X : UU l) → ((inv-pr1-prod-empty X) ∘ pr1) ~ id
isretr-inv-pr1-prod-empty X (pair () x)
is-equiv-pr1-prod-empty :
{l : Level} (X : UU l) → is-equiv (pr1 {A = empty} {B = λ t → X})
is-equiv-pr1-prod-empty X =
is-equiv-has-inverse
( inv-pr1-prod-empty X)
( issec-inv-pr1-prod-empty X)
( isretr-inv-pr1-prod-empty X)
left-zero-law-prod :
{l : Level} (X : UU l) → (empty × X) ≃ empty
left-zero-law-prod X =
pair pr1 (is-equiv-pr1-prod-empty X)
{- We prove the right zero law for cartesian products. -}
inv-pr2-prod-empty :
{l : Level} (X : UU l) → empty → (X × empty)
inv-pr2-prod-empty X ()
issec-inv-pr2-prod-empty :
{l : Level} (X : UU l) → (pr2 ∘ (inv-pr2-prod-empty X)) ~ id
issec-inv-pr2-prod-empty X ()
isretr-inv-pr2-prod-empty :
{l : Level} (X : UU l) → ((inv-pr2-prod-empty X) ∘ pr2) ~ id
isretr-inv-pr2-prod-empty X (pair x ())
is-equiv-pr2-prod-empty :
{l : Level} (X : UU l) → is-equiv (pr2 {A = X} {B = λ x → empty})
is-equiv-pr2-prod-empty X =
is-equiv-has-inverse
( inv-pr2-prod-empty X)
( issec-inv-pr2-prod-empty X)
( isretr-inv-pr2-prod-empty X)
right-zero-law-prod :
{l : Level} (X : UU l) → (X × empty) ≃ empty
right-zero-law-prod X =
pair pr2 (is-equiv-pr2-prod-empty X)
-- Exercise 7.3
-- Exercise 7.3(a)
abstract
is-equiv-htpy :
{i j : Level} {A : UU i} {B : UU j} {f : A → B} (g : A → B) →
f ~ g → is-equiv g → is-equiv f
is-equiv-htpy g H (pair (pair gs issec) (pair gr isretr)) =
pair
( pair gs ((H ·r gs) ∙h issec))
( pair gr ((gr ·l H) ∙h isretr))
abstract
is-equiv-htpy' :
{i j : Level} {A : UU i} {B : UU j} (f : A → B) {g : A → B} →
f ~ g → is-equiv f → is-equiv g
is-equiv-htpy' f H = is-equiv-htpy f (htpy-inv H)
-- Exercise 7.3(b)
htpy-inv-is-equiv :
{i j : Level} {A : UU i} {B : UU j} {f f' : A → B} (H : f ~ f') →
(is-equiv-f : is-equiv f) (is-equiv-f' : is-equiv f') →
(inv-is-equiv is-equiv-f) ~ (inv-is-equiv is-equiv-f')
htpy-inv-is-equiv H is-equiv-f is-equiv-f' b =
( inv (isretr-inv-is-equiv is-equiv-f' (inv-is-equiv is-equiv-f b))) ∙
( ap (inv-is-equiv is-equiv-f')
( ( inv (H (inv-is-equiv is-equiv-f b))) ∙
( issec-inv-is-equiv is-equiv-f b)))
-- Exercise 7.4
-- Exercise 7.4(a)
{- Exercise 7.4 (a) asks to show that, given a commuting triangle f ~ g ∘ h and
a section s of h, we get a new commuting triangle g ~ f ∘ s. Moreover, under
the same assumptions it follows that f has a section if and only if g has a
section. -}
triangle-section :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k}
(f : A → X) (g : B → X) (h : A → B) (H : f ~ (g ∘ h)) (S : sec h) →
g ~ (f ∘ (pr1 S))
triangle-section f g h H (pair s issec) =
htpy-inv (( H ·r s) ∙h (g ·l issec))
section-comp :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k}
(f : A → X) (g : B → X) (h : A → B) (H : f ~ (g ∘ h)) →
sec h → sec f → sec g
section-comp f g h H sec-h sec-f =
pair (h ∘ (pr1 sec-f)) ((htpy-inv (H ·r (pr1 sec-f))) ∙h (pr2 sec-f))
section-comp' :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k}
(f : A → X) (g : B → X) (h : A → B) (H : f ~ (g ∘ h)) →
sec h → sec g → sec f
section-comp' f g h H sec-h sec-g =
pair
( (pr1 sec-h) ∘ (pr1 sec-g))
( ( H ·r ((pr1 sec-h) ∘ (pr1 sec-g))) ∙h
( ( g ·l ((pr2 sec-h) ·r (pr1 sec-g))) ∙h ((pr2 sec-g))))
-- Exercise 7.4(b)
{- Exercise 7.4 (b) is dual to exercise 5.5 (a). It asks to show that, given a
commuting triangle f ~ g ∘ h and a retraction r of g, we get a new commuting
triangle h ~ r ∘ f. Moreover, under these assumptions it also follows that f
has a retraction if and only if h has a retraction. -}
triangle-retraction :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k}
(f : A → X) (g : B → X) (h : A → B) (H : f ~ (g ∘ h)) (R : retr g) →
h ~ ((pr1 R) ∘ f)
triangle-retraction f g h H (pair r isretr) =
htpy-inv (( r ·l H) ∙h (isretr ·r h))
retraction-comp :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k}
(f : A → X) (g : B → X) (h : A → B) (H : f ~ (g ∘ h)) →
retr g → retr f → retr h
retraction-comp f g h H retr-g retr-f =
pair
( (pr1 retr-f) ∘ g)
( (htpy-inv ((pr1 retr-f) ·l H)) ∙h (pr2 retr-f))
retraction-comp' :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k}
(f : A → X) (g : B → X) (h : A → B) (H : f ~ (g ∘ h)) →
retr g → retr h → retr f
retraction-comp' f g h H retr-g retr-h =
pair
( (pr1 retr-h) ∘ (pr1 retr-g))
( ( ((pr1 retr-h) ∘ (pr1 retr-g)) ·l H) ∙h
( ((pr1 retr-h) ·l ((pr2 retr-g) ·r h)) ∙h (pr2 retr-h)))
-- Exercise 7.4(c)
{- In Exercise 7.4 (c) we use the constructions of parts (a) and (b) to derive
the 3-for-2 property of equivalences. -}
abstract
is-equiv-comp :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k}
(f : A → X) (g : B → X) (h : A → B) (H : f ~ (g ∘ h)) →
is-equiv h → is-equiv g → is-equiv f
is-equiv-comp f g h H (pair sec-h retr-h) (pair sec-g retr-g) =
pair
( section-comp' f g h H sec-h sec-g)
( retraction-comp' f g h H retr-g retr-h)
abstract
is-equiv-comp' :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k} (g : B → X) (h : A → B) →
is-equiv h → is-equiv g → is-equiv (g ∘ h)
is-equiv-comp' g h = is-equiv-comp (g ∘ h) g h refl-htpy
equiv-comp :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k} →
(B ≃ X) → (A ≃ B) → (A ≃ X)
equiv-comp g h =
pair ((pr1 g) ∘ (pr1 h)) (is-equiv-comp' (pr1 g) (pr1 h) (pr2 h) (pr2 g))
_∘e_ :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k} →
(B ≃ X) → (A ≃ B) → (A ≃ X)
_∘e_ = equiv-comp
abstract
is-equiv-left-factor :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k}
(f : A → X) (g : B → X) (h : A → B) (H : f ~ (g ∘ h)) →
is-equiv f → is-equiv h → is-equiv g
is-equiv-left-factor f g h H
( pair sec-f retr-f)
( pair (pair sh sh-issec) retr-h) =
pair
( section-comp f g h H (pair sh sh-issec) sec-f)
( retraction-comp' g f sh
( triangle-section f g h H (pair sh sh-issec))
( retr-f)
( pair h sh-issec))
abstract
is-equiv-left-factor' :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k} (g : B → X) (h : A → B) →
is-equiv (g ∘ h) → is-equiv h → is-equiv g
is-equiv-left-factor' g h =
is-equiv-left-factor (g ∘ h) g h refl-htpy
abstract
is-equiv-right-factor :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k}
(f : A → X) (g : B → X) (h : A → B) (H : f ~ (g ∘ h)) →
is-equiv g → is-equiv f → is-equiv h
is-equiv-right-factor f g h H
( pair sec-g (pair rg rg-isretr))
( pair sec-f retr-f) =
pair
( section-comp' h rg f
( triangle-retraction f g h H (pair rg rg-isretr))
( sec-f)
( pair g rg-isretr))
( retraction-comp f g h H (pair rg rg-isretr) retr-f)
abstract
is-equiv-right-factor' :
{i j k : Level} {A : UU i} {B : UU j} {X : UU k} (g : B → X) (h : A → B) →
is-equiv g → is-equiv (g ∘ h) → is-equiv h
is-equiv-right-factor' g h =
is-equiv-right-factor (g ∘ h) g h refl-htpy
-- Exercise 7.5
-- Exercise 7.5(a)
{- In this exercise we show that the negation function on the booleans is an
equivalence. Moreover, we show that any constant function on the booleans is
not an equivalence. -}
neg-neg-𝟚 : (neg-𝟚 ∘ neg-𝟚) ~ id
neg-neg-𝟚 true = refl
neg-neg-𝟚 false = refl
abstract
is-equiv-neg-𝟚 : is-equiv neg-𝟚
is-equiv-neg-𝟚 = is-equiv-has-inverse neg-𝟚 neg-neg-𝟚 neg-neg-𝟚
equiv-neg-𝟚 : bool ≃ bool
equiv-neg-𝟚 = pair neg-𝟚 is-equiv-neg-𝟚
-- Exercise 7.5(b)
abstract
not-true-is-false : ¬ (Id true false)
not-true-is-false p =
tr (Eq-𝟚 true) p (reflexive-Eq-𝟚 true)
-- Exercise 7.5(c)
abstract
not-equiv-const :
(b : bool) → ¬ (is-equiv (const bool bool b))
not-equiv-const true (pair (pair s issec) (pair r isretr)) =
not-true-is-false (issec false)
not-equiv-const false (pair (pair s issec) (pair r isretr)) =
not-true-is-false (inv (issec true))
-- Exercise 7.6
is-equiv-succ-ℤ : is-equiv succ-ℤ
is-equiv-succ-ℤ =
is-equiv-has-inverse pred-ℤ right-inverse-pred-ℤ left-inverse-pred-ℤ
equiv-succ-ℤ : ℤ ≃ ℤ
equiv-succ-ℤ = pair succ-ℤ is-equiv-succ-ℤ
-- Exercise 7.7
{- In this exercise we construct an equivalence from A + B to B + A, showing
that the coproduct is commutative. -}
swap-coprod :
{i j : Level} (A : UU i) (B : UU j) → coprod A B → coprod B A
swap-coprod A B (inl x) = inr x
swap-coprod A B (inr x) = inl x
swap-swap-coprod :
{i j : Level} (A : UU i) (B : UU j) →
((swap-coprod B A) ∘ (swap-coprod A B)) ~ id
swap-swap-coprod A B (inl x) = refl
swap-swap-coprod A B (inr x) = refl
abstract
is-equiv-swap-coprod :
{i j : Level} (A : UU i) (B : UU j) → is-equiv (swap-coprod A B)
is-equiv-swap-coprod A B =
is-equiv-has-inverse
( swap-coprod B A)
( swap-swap-coprod B A)
( swap-swap-coprod A B)
equiv-swap-coprod :
{i j : Level} (A : UU i) (B : UU j) → coprod A B ≃ coprod B A
equiv-swap-coprod A B = pair (swap-coprod A B) (is-equiv-swap-coprod A B)
swap-prod :
{i j : Level} (A : UU i) (B : UU j) → prod A B → prod B A
swap-prod A B t = pair (pr2 t) (pr1 t)
swap-swap-prod :
{i j : Level} (A : UU i) (B : UU j) →
((swap-prod B A) ∘ (swap-prod A B)) ~ id
swap-swap-prod A B (pair x y) = refl
abstract
is-equiv-swap-prod :
{i j : Level} (A : UU i) (B : UU j) →
is-equiv (swap-prod A B)
is-equiv-swap-prod A B =
is-equiv-has-inverse
( swap-prod B A)
( swap-swap-prod B A)
( swap-swap-prod A B)
equiv-swap-prod :
{i j : Level} (A : UU i) (B : UU j) → (A × B) ≃ (B × A)
equiv-swap-prod A B = pair (swap-prod A B) (is-equiv-swap-prod A B)
-- Exercise 7.8
{- In this exercise we show that if A is a retract of B, then so are its
identity types. -}
ap-retraction :
{i j : Level} {A : UU i} {B : UU j}
(i : A → B) (r : B → A) (H : (r ∘ i) ~ id)
(x y : A) → Id (i x) (i y) → Id x y
ap-retraction i r H x y p =
( inv (H x)) ∙ ((ap r p) ∙ (H y))
isretr-ap-retraction :
{i j : Level} {A : UU i} {B : UU j}
(i : A → B) (r : B → A) (H : (r ∘ i) ~ id)
(x y : A) → ((ap-retraction i r H x y) ∘ (ap i {x} {y})) ~ id
isretr-ap-retraction i r H x .x refl = left-inv (H x)
retr-ap :
{i j : Level} {A : UU i} {B : UU j} (i : A → B) →
retr i → (x y : A) → retr (ap i {x} {y})
retr-ap i (pair r H) x y =
pair (ap-retraction i r H x y) (isretr-ap-retraction i r H x y)
Id-retract-of-Id :
{i j : Level} {A : UU i} {B : UU j} (R : A retract-of B) →
(x y : A) → (Id x y) retract-of (Id (pr1 R x) (pr1 R y))
Id-retract-of-Id (pair i (pair r H)) x y =
pair
( ap i {x} {y})
( retr-ap i (pair r H) x y)
-- Exercise 7.9
Σ-assoc :
{i j k : Level} (A : UU i) (B : A → UU j) (C : (Σ A B) → UU k) →
Σ (Σ A B) C → Σ A (λ x → Σ (B x) (λ y → C (pair x y)))
Σ-assoc A B C (pair (pair x y) z) = pair x (pair y z)
Σ-assoc' :
{i j k : Level} (A : UU i) (B : A → UU j) (C : (Σ A B) → UU k) →
Σ A (λ x → Σ (B x) (λ y → C (pair x y))) → Σ (Σ A B) C
Σ-assoc' A B C t = pair (pair (pr1 t) (pr1 (pr2 t))) (pr2 (pr2 t))
Σ-assoc-assoc :
{i j k : Level} (A : UU i) (B : A → UU j)
(C : (Σ A B) → UU k) → ((Σ-assoc' A B C) ∘ (Σ-assoc A B C)) ~ id
Σ-assoc-assoc A B C (pair (pair x y) z) = refl
Σ-assoc-assoc' :
{i j k : Level} (A : UU i) (B : A → UU j)
(C : (Σ A B) → UU k) → ((Σ-assoc A B C) ∘ (Σ-assoc' A B C)) ~ id
Σ-assoc-assoc' A B C (pair x (pair y z)) = refl
abstract
is-equiv-Σ-assoc :
{i j k : Level} (A : UU i) (B : A → UU j)
(C : (Σ A B) → UU k) → is-equiv (Σ-assoc A B C)
is-equiv-Σ-assoc A B C =
is-equiv-has-inverse
( Σ-assoc' A B C)
( Σ-assoc-assoc' A B C)
( Σ-assoc-assoc A B C)
equiv-Σ-assoc :
{i j k : Level} (A : UU i) (B : A → UU j) (C : (Σ A B) → UU k) →
Σ (Σ A B) C ≃ Σ A (λ x → Σ (B x) (λ y → C (pair x y)))
equiv-Σ-assoc A B C =
pair (Σ-assoc A B C) (is-equiv-Σ-assoc A B C)
-- Exercise 7.10
Σ-swap :
{i j k : Level} (A : UU i) (B : UU j) (C : A → B → UU k) →
Σ A (λ x → Σ B (C x)) → Σ B (λ y → Σ A (λ x → C x y))
Σ-swap A B C t = pair (pr1 (pr2 t)) (pair (pr1 t) (pr2 (pr2 t)))
Σ-swap' :
{i j k : Level} (A : UU i) (B : UU j) (C : A → B → UU k) →
Σ B (λ y → Σ A (λ x → C x y)) → Σ A (λ x → Σ B (C x))
Σ-swap' A B C = Σ-swap B A (λ y x → C x y)
Σ-swap-swap :
{i j k : Level} (A : UU i) (B : UU j) (C : A → B → UU k) →
((Σ-swap' A B C) ∘ (Σ-swap A B C)) ~ id
Σ-swap-swap A B C (pair x (pair y z)) = refl
abstract
is-equiv-Σ-swap :
{i j k : Level} (A : UU i) (B : UU j) (C : A → B → UU k) →
is-equiv (Σ-swap A B C)
is-equiv-Σ-swap A B C =
is-equiv-has-inverse
( Σ-swap' A B C)
( Σ-swap-swap B A (λ y x → C x y))
( Σ-swap-swap A B C)
-- Exercise 7.11
abstract
is-equiv-add-ℤ-right :
(x : ℤ) → is-equiv (add-ℤ x)
is-equiv-add-ℤ-right x =
is-equiv-has-inverse
( add-ℤ (neg-ℤ x))
( λ y →
( inv (associative-add-ℤ x (neg-ℤ x) y)) ∙
( ap (λ t → add-ℤ t y) (right-inverse-law-add-ℤ x)))
( λ y →
( inv (associative-add-ℤ (neg-ℤ x) x y)) ∙
( ap (λ t → add-ℤ t y) (left-inverse-law-add-ℤ x)))
abstract
is-equiv-add-ℤ-left :
(y : ℤ) → is-equiv (λ x → add-ℤ x y)
is-equiv-add-ℤ-left y =
is-equiv-htpy (add-ℤ y)
( λ x → commutative-add-ℤ x y)
( is-equiv-add-ℤ-right y)
-- Exercise 7.12
-- Exercise 7.13
{- We construct the functoriality of coproducts. -}
functor-coprod :
{l1 l2 l1' l2' : Level} {A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'} →
(A → A') → (B → B') → coprod A B → coprod A' B'
functor-coprod f g (inl x) = inl (f x)
functor-coprod f g (inr y) = inr (g y)
htpy-functor-coprod :
{l1 l2 l1' l2' : Level} {A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'}
{f f' : A → A'} (H : f ~ f') {g g' : B → B'} (K : g ~ g') →
(functor-coprod f g) ~ (functor-coprod f' g')
htpy-functor-coprod H K (inl x) = ap inl (H x)
htpy-functor-coprod H K (inr y) = ap inr (K y)
id-functor-coprod :
{l1 l2 : Level} (A : UU l1) (B : UU l2) →
(functor-coprod (id {A = A}) (id {A = B})) ~ id
id-functor-coprod A B (inl x) = refl
id-functor-coprod A B (inr x) = refl
compose-functor-coprod :
{l1 l2 l1' l2' l1'' l2'' : Level}
{A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'}
{A'' : UU l1''} {B'' : UU l2''}
(f : A → A') (f' : A' → A'') (g : B → B') (g' : B' → B'') →
(functor-coprod (f' ∘ f) (g' ∘ g)) ~
((functor-coprod f' g') ∘ (functor-coprod f g))
compose-functor-coprod f f' g g' (inl x) = refl
compose-functor-coprod f f' g g' (inr y) = refl
abstract
is-equiv-functor-coprod :
{l1 l2 l1' l2' : Level} {A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'}
{f : A → A'} {g : B → B'} →
is-equiv f → is-equiv g → is-equiv (functor-coprod f g)
is-equiv-functor-coprod {A = A} {B = B} {A' = A'} {B' = B'} {f = f} {g = g}
(pair (pair sf issec-sf) (pair rf isretr-rf))
(pair (pair sg issec-sg) (pair rg isretr-rg)) =
pair
( pair
( functor-coprod sf sg)
( ( ( htpy-inv (compose-functor-coprod sf f sg g)) ∙h
( htpy-functor-coprod issec-sf issec-sg)) ∙h
( id-functor-coprod A' B')))
( pair
( functor-coprod rf rg)
( ( ( htpy-inv (compose-functor-coprod f rf g rg)) ∙h
( htpy-functor-coprod isretr-rf isretr-rg)) ∙h
( id-functor-coprod A B)))
equiv-functor-coprod :
{l1 l2 l1' l2' : Level} {A : UU l1} {B : UU l2} {A' : UU l1'} {B' : UU l2'} →
(A ≃ A') → (B ≃ B') → ((coprod A B) ≃ (coprod A' B'))
equiv-functor-coprod (pair e is-equiv-e) (pair f is-equiv-f) =
pair
( functor-coprod e f)
( is-equiv-functor-coprod is-equiv-e is-equiv-f)
-- Extra material
abstract
is-equiv-inv-con :
{i : Level} {A : UU i} {x y z : A} (p : Id x y)
(q : Id y z) (r : Id x z) → is-equiv (inv-con p q r)
is-equiv-inv-con refl q r = is-equiv-id (Id q r)
equiv-inv-con :
{i : Level} {A : UU i} {x y z : A} (p : Id x y) (q : Id y z) (r : Id x z) →
Id (p ∙ q) r ≃ Id q ((inv p) ∙ r)
equiv-inv-con p q r = pair (inv-con p q r) (is-equiv-inv-con p q r)
abstract
is-equiv-con-inv :
{i : Level} {A : UU i} {x y z : A} (p : Id x y)
(q : Id y z) (r : Id x z) → is-equiv (con-inv p q r)
is-equiv-con-inv p refl r =
is-equiv-comp'
( concat' p (inv right-unit))
( concat (inv right-unit) r)
( is-equiv-concat (inv right-unit) r)
( is-equiv-concat' p (inv right-unit))
equiv-con-inv :
{i : Level} {A : UU i} {x y z : A} (p : Id x y) (q : Id y z) (r : Id x z) →
Id (p ∙ q) r ≃ Id p (r ∙ (inv q))
equiv-con-inv p q r = pair (con-inv p q r) (is-equiv-con-inv p q r)
-- Extra constructions with homotopies
htpy-inv-con :
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g h : (x : A) → B x} →
(H : f ~ g) (K : g ~ h) (L : f ~ h) →
(H ∙h K) ~ L → K ~ ((htpy-inv H) ∙h L)
htpy-inv-con H K L M x = inv-con (H x) (K x) (L x) (M x)
htpy-con-inv :
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g h : (x : A) → B x} →
(H : f ~ g) (K : g ~ h) (L : f ~ h) →
(H ∙h K) ~ L → H ~ (L ∙h (htpy-inv K))
htpy-con-inv H K L M x = con-inv (H x) (K x) (L x) (M x)
htpy-ap-concat :
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g h : (x : A) → B x} →
(H : f ~ g) (K K' : g ~ h) →
K ~ K' → (H ∙h K) ~ (H ∙h K')
htpy-ap-concat {g = g} {h} H K K' L x =
ap (concat (H x) (h x)) (L x)
htpy-ap-concat' :
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g h : (x : A) → B x} →
(H H' : f ~ g) (K : g ~ h) →
H ~ H' → (H ∙h K) ~ (H' ∙h K)
htpy-ap-concat' H H' K L x =
ap (concat' _ (K x)) (L x)
htpy-distributive-inv-concat :
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g h : (x : A) → B x} →
(H : f ~ g) (K : g ~ h) →
(htpy-inv (H ∙h K)) ~ ((htpy-inv K) ∙h (htpy-inv H))
htpy-distributive-inv-concat H K x = distributive-inv-concat (H x) (K x)
htpy-ap-inv :
{l1 l2 : Level} {A : UU l1} {B : A → UU l2} {f g : (x : A) → B x} →
{H H' : f ~ g} →
H ~ H' → (htpy-inv H) ~ (htpy-inv H')
htpy-ap-inv K x = ap inv (K x)
htpy-left-whisk-htpy-inv :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {C : UU l3}
{f f' : A → B} (g : B → C) (H : f ~ f') →
(g ·l (htpy-inv H)) ~ htpy-inv (g ·l H)
htpy-left-whisk-htpy-inv g H x = ap-inv g (H x)
htpy-right-whisk-htpy-inv :
{l1 l2 l3 : Level} {A : UU l1} {B : UU l2} {C : UU l3}
{g g' : B → C} (H : g ~ g') (f : A → B) →
((htpy-inv H) ·r f) ~ (htpy-inv (H ·r f))
htpy-right-whisk-htpy-inv H f = refl-htpy
-- Old stuff
element :
{i : Level} {A : UU i} → A → unit → A
element a star = a
htpy-element-constant :
{i : Level} {A : UU i} (a : A) →
(element a) ~ (const unit A a)
htpy-element-constant a star = refl
ap-const :
{i j : Level} {A : UU i} {B : UU j} (b : B) (x y : A) →
(ap (const A B b) {x} {y}) ~ const (Id x y) (Id b b) refl
ap-const b x .x refl = refl
| {
"alphanum_fraction": 0.5226114922,
"avg_line_length": 30.5805047868,
"ext": "agda",
"hexsha": "92f0dac542b99e67b68d046b1157e180ca428ceb",
"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/07-equivalences.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/07-equivalences.agda",
"max_line_length": 80,
"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/07-equivalences.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 15443,
"size": 35137
} |
module Tactic.Nat.Coprime.Reflect where
import Agda.Builtin.Nat as Builtin
open import Prelude
open import Control.Monad.State
open import Control.Monad.Zero
open import Control.Monad.Transformer
open import Container.Traversable
open import Numeric.Nat.GCD
open import Tactic.Reflection
open import Tactic.Reflection.Parse
open import Tactic.Reflection.Quote
open import Tactic.Deriving.Quotable
open import Tactic.Nat.Coprime.Problem
-- Reflection --
instance
unquoteDecl QuoteExp = deriveQuotable QuoteExp (quote Exp)
unquoteDecl QuoteFormula = deriveQuotable QuoteFormula (quote Formula)
unquoteDecl QuoteProblem = deriveQuotable QuoteProblem (quote Problem)
data ExpF (A : Set) : Set where
atom : (x : Atom) → ExpF A
_⊗_ : (a b : A) → ExpF A
instance
FunExpF : Functor ExpF
fmap ⦃ FunExpF ⦄ f (atom x) = atom x
fmap ⦃ FunExpF ⦄ f (a ⊗ b) = f a ⊗ f b
TravExpF : Traversable ExpF
traverse ⦃ TravExpF ⦄ f (atom x) = pure (atom x)
traverse ⦃ TravExpF ⦄ f (a ⊗ b) = ⦇ f a ⊗ f b ⦈
foldExp : ExpF Exp → Exp
foldExp (atom x) = atom x
foldExp (a ⊗ b) = a ⊗ b
-- Requires normalisation!
matchExp : Term → Maybe (ExpF Term)
matchExp (def₂ (quote Builtin._*_) a b) = just (a ⊗ b)
matchExp _ = nothing
parseExp : Term → ParseTerm TC Exp
parseExp = parseTerm atom matchExp foldExp
parseEq : Term → ParseTerm TC (Term × Term)
parseEq (def (quote _≡_) (_ ∷ _ ∷ vArg x ∷ vArg y ∷ [])) = pure (x , y)
parseEq (meta x _) = lift (blockOnMeta! x)
parseEq _ = empty
parseGCD : Term → ParseTerm TC (Term × Term)
parseGCD (def (quote get-gcd) (_ ∷ _ ∷ vArg (def₂ (quote gcd) a b) ∷ [])) = pure (a , b)
parseGCD (meta x _) = lift (blockOnMeta x)
parseGCD t = empty
parseFormula : Term → ParseTerm TC Formula
parseFormula t = do
lhs , lit (nat 1) ← parseEq t where _ → empty
a , b ← parseGCD lhs
⦇ parseExp a ⋈ parseExp b ⦈
underBinder : ParseTerm TC ⊤
underBinder = _ <$ modify (second $ map $ first $ weaken 1)
-- Parse a Problem from the context and goal type.
parseProblem : List Term → Term → ParseTerm TC (Nat × List Term × Problem)
parseProblem [] t = do
φ ← parseFormula t
pure (0 , [] , ([] ⊨ φ))
parseProblem (h ∷ Δ) t =
caseM just <$> parseFormula h <|> pure nothing of λ where
(just ψ) → do
underBinder
fv , Hs , (Γ ⊨ φ) ← parseProblem Δ t
pure (suc fv , var fv [] ∷ Hs , (ψ ∷ Γ ⊨ φ))
nothing → do
underBinder
fv , Hs , Q ← parseProblem Δ t
pure (suc fv , Hs , Q)
buildEnv : List Nat → Env
buildEnv [] i = 0
buildEnv (x ∷ xs) zero = x
buildEnv (x ∷ xs) (suc i) = buildEnv xs i
quotedEnv : List Term → Term
quotedEnv ts = def₁ (quote buildEnv) (quoteList ts)
| {
"alphanum_fraction": 0.6642910728,
"avg_line_length": 28.6666666667,
"ext": "agda",
"hexsha": "16296cb525ec8938949cdd5b838471a177da0dbe",
"lang": "Agda",
"max_forks_count": 24,
"max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z",
"max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "L-TChen/agda-prelude",
"max_forks_repo_path": "src/Tactic/Nat/Coprime/Reflect.agda",
"max_issues_count": 59,
"max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "L-TChen/agda-prelude",
"max_issues_repo_path": "src/Tactic/Nat/Coprime/Reflect.agda",
"max_line_length": 88,
"max_stars_count": 111,
"max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "L-TChen/agda-prelude",
"max_stars_repo_path": "src/Tactic/Nat/Coprime/Reflect.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z",
"num_tokens": 906,
"size": 2666
} |
-- Andreas, 2012-06-05 let for record patterns
-- {-# OPTIONS --show-implicit #-}
-- {-# OPTIONS -v tc.term.let.pattern:100 #-}
-- {-# OPTIONS -v tc.lhs.top:100 #-}
module LetPair where
import Common.Level
open import Common.Equality
infixl 6 _×_
infixl 0 _,_
record _×_ (A B : Set) : Set where
constructor _,_
field
fst : A
snd : B
open _×_
swap : {A B : Set} → A × B → B × A
swap p =
let (a , b) = p
in (b , a)
prop_swap : {A B : Set}{p : A × B} →
(fst (swap p) ≡ snd p) ×
(snd (swap p) ≡ fst p)
prop_swap = refl , refl
rot3 : {A B C : Set} → A × B × C → B × C × A
rot3 = λ t → let
a , b , c = t
in b , c , a
postulate
A B C : Set
rot3' = λ t → let
x : A × B × C
x = t
a , b , c = x
in b , c , a
record ⊤ : Set where
constructor tt
test = let tt , _ = tt , tt in A
| {
"alphanum_fraction": 0.5185628743,
"avg_line_length": 16.3725490196,
"ext": "agda",
"hexsha": "55c2b7dc5ad9b7d4178541826587a2f2158a62e2",
"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/LetPair.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/LetPair.agda",
"max_line_length": 46,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "7f58030124fa99dfbf8db376659416f3ad8384de",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "cruhland/agda",
"max_stars_repo_path": "test/Succeed/LetPair.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": 328,
"size": 835
} |
{-# OPTIONS --cubical #-}
module ExerciseSession1 where
open import Part1 hiding (B)
-- We redefine B to be a family of types in this file
variable
B : A → Type ℓ
-- Exercise 1: state and prove funExt for dependent functions f g : (x : A) → B x
-- Exercise 2: generalize the type of cong to dependent function f : (x : A) → B x
-- (hint: the result should be a PathP)
-- Exercise 3 (easy) state and prove that inhabited propositions are contractible
-- We could have stated isProp as follows:
isProp' : Type ℓ → Type ℓ
isProp' A = (x y : A) → isContr (x ≡ y)
-- Exercise 4 (easy): prove that isProp' A implies isProp A
-- For the converse we need path composition, see ExerciseSession2
-- Exercise 5: prove isPropΠ
isPropΠ : (h : (x : A) → isProp (B x)) → isProp ((x : A) → B x)
isPropΠ h = {!!}
-- Exercise 6: prove the inverse of funExt (sometimes called happly)
funExt⁻ : {f g : (x : A) → B x} → f ≡ g → ((x : A) → f x ≡ g x)
funExt⁻ p = {!!}
-- Exercise 7: use funExt⁻ to prove isSetΠ
isSetΠ : (h : (x : A) → isSet (B x)) → isSet ((x : A) → B x)
isSetΠ h = {!!}
-- We could have defined the type of singletons as follows
singl' : {A : Type ℓ} (a : A) → Type ℓ
singl' {A = A} a = Σ[ x ∈ A ] x ≡ a
-- Exercise 8 (harder): prove the corresponding version of contractibility of singetons for singl'
-- (hint: use a suitable combinations of connections and _~)
isContrSingl' : (x : A) → isContr (singl' x)
isContrSingl' x = {!!}
| {
"alphanum_fraction": 0.6386206897,
"avg_line_length": 27.8846153846,
"ext": "agda",
"hexsha": "8862d2666ef1e603fca50c2d4c840b041d4b1869",
"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": "54b18e4adf890b3533bbefda373912423be7f490",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "tomdjong/EPIT-2020",
"max_forks_repo_path": "04-cubical-type-theory/material/ExerciseSession1.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490",
"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": "tomdjong/EPIT-2020",
"max_issues_repo_path": "04-cubical-type-theory/material/ExerciseSession1.agda",
"max_line_length": 98,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "54b18e4adf890b3533bbefda373912423be7f490",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "tomdjong/EPIT-2020",
"max_stars_repo_path": "04-cubical-type-theory/material/ExerciseSession1.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 490,
"size": 1450
} |
module Tabs where
-- Tabs are not treated as white space.
tab: : Set₁
tab: = Set
| {
"alphanum_fraction": 0.6705882353,
"avg_line_length": 12.1428571429,
"ext": "agda",
"hexsha": "b2d78c7cb472b5c0be3dfaa989bc682730b3a37a",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Tabs.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Tabs.agda",
"max_line_length": 39,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Tabs.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": 26,
"size": 85
} |
module Logic.Propositional.Theorems where
open import Data
open import Data.Either as Either using (_‖_)
open import Data.Tuple as Tuple using (_⨯_ ; _,_)
open import Functional
open import Logic
open import Logic.Propositional
import Lvl
open import Syntax.Type
open import Type
------------------------------------------
-- Reflexivity
module _ {ℓ} {P : Stmt{ℓ}} where
[↔]-reflexivity : (P ↔ P)
[↔]-reflexivity = [↔]-intro id id
[→]-reflexivity : (P → P)
[→]-reflexivity = id
------------------------------------------
-- Transitivity
module _ {ℓ₁}{ℓ₂}{ℓ₃} {P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}}{R : Stmt{ℓ₃}} where
[→]-transitivity : (P → Q) → (Q → R) → (P → R)
[→]-transitivity = liftᵣ
[↔]-transitivity : (P ↔ Q) → (Q ↔ R) → (P ↔ R)
[↔]-transitivity ([↔]-intro qp pq) ([↔]-intro rq qr) = [↔]-intro (qp ∘ rq) (qr ∘ pq)
[∧]-transitivity : (P ∧ Q) → (Q ∧ R) → (P ∧ R)
[∧]-transitivity ([∧]-intro p _) ([∧]-intro _ r) = [∧]-intro p r
------------------------------------------
-- Symmetry
module _ {ℓ₁}{ℓ₂} {P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} where
[∧]-symmetry : (P ∧ Q) → (Q ∧ P)
[∧]-symmetry = Tuple.swap
[∨]-symmetry : (P ∨ Q) → (Q ∨ P)
[∨]-symmetry = Either.swap
module _ {ℓ₁}{ℓ₂} {P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} where
[↔]-symmetry : (P ↔ Q) → (Q ↔ P)
[↔]-symmetry = [∧]-symmetry
------------------------------------------
-- Operators that implies other ones
module _ {ℓ₁}{ℓ₂} {P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} where
[∧]-to-[↔] : (P ∧ Q) → (P ↔ Q)
[∧]-to-[↔] ([∧]-intro p q) = [↔]-intro (const p) (const q)
[∧]-to-[→] : (P ∧ Q) → (P → Q)
[∧]-to-[→] ([∧]-intro p q) = const q
[∧]-to-[←] : (P ∧ Q) → (P ← Q)
[∧]-to-[←] ([∧]-intro p q) = const p
[∧]-to-[∨] : (P ∧ Q) → (P ∨ Q)
[∧]-to-[∨] ([∧]-intro p q) = [∨]-introₗ p
[∨]-to-[←][→] : (P ∨ Q) → (P ← Q)∨(P → Q)
[∨]-to-[←][→] ([∨]-introₗ p) = [∨]-introₗ (const p)
[∨]-to-[←][→] ([∨]-introᵣ q) = [∨]-introᵣ (const q)
------------------------------------------
-- Associativity (with respect to ↔)
module _ {ℓ₁}{ℓ₂}{ℓ₃} {P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}}{R : Stmt{ℓ₃}} where
[∧]-associativity : ((P ∧ Q) ∧ R) ↔ (P ∧ (Q ∧ R))
[∧]-associativity = [↔]-intro l r
where l : ((P ∧ Q) ∧ R) ← (P ∧ (Q ∧ R))
l ([∧]-intro p ([∧]-intro q r)) = [∧]-intro ([∧]-intro p q) r
r : ((P ∧ Q) ∧ R) → (P ∧ (Q ∧ R))
r ([∧]-intro ([∧]-intro p q) r) = [∧]-intro p ([∧]-intro q r)
[∨]-associativity : ((P ∨ Q) ∨ R) ↔ (P ∨ (Q ∨ R))
[∨]-associativity = [↔]-intro l r
where l : ((P ∨ Q) ∨ R) ← (P ∨ (Q ∨ R))
l ([∨]-introₗ p) = [∨]-introₗ([∨]-introₗ p)
l ([∨]-introᵣ([∨]-introₗ q)) = [∨]-introₗ([∨]-introᵣ q)
l ([∨]-introᵣ([∨]-introᵣ r)) = [∨]-introᵣ r
r : ((P ∨ Q) ∨ R) → (P ∨ (Q ∨ R))
r ([∨]-introₗ([∨]-introₗ p)) = [∨]-introₗ p
r ([∨]-introₗ([∨]-introᵣ q)) = [∨]-introᵣ([∨]-introₗ q)
r ([∨]-introᵣ r) = [∨]-introᵣ([∨]-introᵣ r)
-- TODO: According to https://math.stackexchange.com/questions/440261/associativity-of-iff , this is unprovable
{-[↔]-associativity : ∀{P Q R : Stmt} → ((P ↔ Q) ↔ R) ↔ (P ↔ (Q ↔ R))
[↔]-associativity {P}{Q}{R} = [↔]-intro [↔]-associativityₗ [↔]-associativityᵣ where
[↔]-associativityₗ : ((P ↔ Q) ↔ R) ← (P ↔ (Q ↔ R))
[↔]-associativityₗ ([↔]-intro yz2x x2yz) = [↔]-intro z2xy xy2z where
z2xy : (P ↔ Q) ← R
z2xy r = [↔]-intro y2x x2y where
y2x : Q → P
y2x q = yz2x([∧]-to-[↔]([∧]-intro q r))
x2y : P → Q
x2y p = [↔]-elimₗ (x2yz(p)) (r)
xy2z : (P ↔ Q) → R -- TODO: How?
xy2z ([↔]-intro y2x x2y) = ?
[↔]-associativityᵣ : ((P ↔ Q) ↔ R) → (P ↔ (Q ↔ R))
[↔]-associativityᵣ ([↔]-intro z2xy xy2z) = [↔]-intro yz2x x2yz where
yz2x : P ← (Q ↔ R)
yz2x ([↔]-intro z2y y2z) = ?
x2yz : P → (Q ↔ R)
x2yz p = [↔]-intro z2y y2z where
z2y : R → Q
z2y r = [↔]-elimᵣ (z2xy(r)) (p)
y2z : Q → R
y2z q = xy2z([∧]-to-[↔]([∧]-intro p q))
-}
------------------------------------------
-- Distributivity
module _ {ℓ₁}{ℓ₂}{ℓ₃} {P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}}{R : Stmt{ℓ₃}} where
[∧][∨]-distributivityₗ : (P ∧ (Q ∨ R)) ↔ (P ∧ Q)∨(P ∧ R)
[∧][∨]-distributivityₗ = [↔]-intro l r where
l : (P ∧ (Q ∨ R)) ← (P ∧ Q)∨(P ∧ R)
l([∨]-introₗ ([∧]-intro p q)) = [∧]-intro p ([∨]-introₗ q)
l([∨]-introᵣ ([∧]-intro p r)) = [∧]-intro p ([∨]-introᵣ r)
r : (P ∧ (Q ∨ R)) → (P ∧ Q)∨(P ∧ R)
r([∧]-intro p ([∨]-introₗ q)) = [∨]-introₗ([∧]-intro p q)
r([∧]-intro p ([∨]-introᵣ r)) = [∨]-introᵣ([∧]-intro p r)
[∧][∨]-distributivityᵣ : ((P ∨ Q) ∧ R) ↔ (P ∧ R)∨(Q ∧ R)
[∧][∨]-distributivityᵣ = [↔]-intro l r where
l : ((P ∨ Q) ∧ R) ← (P ∧ R)∨(Q ∧ R)
l([∨]-introₗ ([∧]-intro p r)) = [∧]-intro ([∨]-introₗ p) r
l([∨]-introᵣ ([∧]-intro q r)) = [∧]-intro ([∨]-introᵣ q) r
r : ((P ∨ Q) ∧ R) → (P ∧ R)∨(Q ∧ R)
r([∧]-intro ([∨]-introₗ p) r) = [∨]-introₗ([∧]-intro p r)
r([∧]-intro ([∨]-introᵣ q) r) = [∨]-introᵣ([∧]-intro q r)
[∨][∧]-distributivityₗ : (P ∨ (Q ∧ R)) ↔ (P ∨ Q)∧(P ∨ R)
[∨][∧]-distributivityₗ = [↔]-intro l r where
l : (P ∨ (Q ∧ R)) ← (P ∨ Q)∧(P ∨ R)
l([∧]-intro ([∨]-introₗ p) ([∨]-introₗ _)) = [∨]-introₗ(p)
l([∧]-intro ([∨]-introₗ p) ([∨]-introᵣ r)) = [∨]-introₗ(p)
l([∧]-intro ([∨]-introᵣ q) ([∨]-introₗ p)) = [∨]-introₗ(p)
l([∧]-intro ([∨]-introᵣ q) ([∨]-introᵣ r)) = [∨]-introᵣ([∧]-intro q r)
r : (P ∨ (Q ∧ R)) → (P ∨ Q)∧(P ∨ R)
r([∨]-introₗ p) = [∧]-intro ([∨]-introₗ p) ([∨]-introₗ p)
r([∨]-introᵣ ([∧]-intro q r)) = [∧]-intro ([∨]-introᵣ q) ([∨]-introᵣ r)
[∨][∧]-distributivityᵣ : ((P ∧ Q) ∨ R) ↔ (P ∨ R)∧(Q ∨ R)
[∨][∧]-distributivityᵣ = [↔]-intro l r where
l : ((P ∧ Q) ∨ R) ← (P ∨ R)∧(Q ∨ R)
l([∧]-intro ([∨]-introₗ p) ([∨]-introₗ q)) = [∨]-introₗ([∧]-intro p q)
l([∧]-intro ([∨]-introₗ p) ([∨]-introᵣ r)) = [∨]-introᵣ(r)
l([∧]-intro ([∨]-introᵣ r) ([∨]-introₗ q)) = [∨]-introᵣ(r)
l([∧]-intro ([∨]-introᵣ r) ([∨]-introᵣ _)) = [∨]-introᵣ(r)
r : ((P ∧ Q) ∨ R) → (P ∨ R)∧(Q ∨ R)
r([∨]-introₗ ([∧]-intro p q)) = [∧]-intro ([∨]-introₗ p) ([∨]-introₗ q)
r([∨]-introᵣ r) = [∧]-intro ([∨]-introᵣ r) ([∨]-introᵣ r)
------------------------------------------
-- Identity (with respect to →)
module _ {ℓ} {P : Stmt{ℓ}} where
[∧]-identityₗ : (⊤ ∧ P) → P
[∧]-identityₗ ([∧]-intro _ p) = p
[∧]-identityᵣ : (P ∧ ⊤) → P
[∧]-identityᵣ ([∧]-intro p _) = p
[∨]-identityₗ : (⊥ ∨ P) → P
[∨]-identityₗ ([∨]-introₗ ())
[∨]-identityₗ ([∨]-introᵣ p) = p
[∨]-identityᵣ : (P ∨ ⊥) → P
[∨]-identityᵣ ([∨]-introₗ p) = p
[∨]-identityᵣ ([∨]-introᵣ ())
[→]-identityₗ : (⊤ → P) → P
[→]-identityₗ f = f([⊤]-intro)
[∧]-nullifierₗ : (⊥ ∧ P) → ⊥
[∧]-nullifierₗ ([∧]-intro () _)
[∧]-nullifierᵣ : (P ∧ ⊥) → ⊥
[∧]-nullifierᵣ ([∧]-intro _ ())
module _ {ℓ₂}{ℓ₃} {_▫_ : Stmt{Lvl.𝟎} → Stmt{ℓ₂} → Stmt{ℓ₃}} where
[⊤]-as-nullifierₗ : ∀{P : Stmt} → (⊤ ▫ P) → ⊤
[⊤]-as-nullifierₗ _ = [⊤]-intro
module _ {ℓ₁}{ℓ₃} {_▫_ : Stmt{ℓ₁} → Stmt{Lvl.𝟎} → Stmt{ℓ₃}} where
[⊤]-as-nullifierᵣ : ∀{P : Stmt} → (P ▫ ⊤) → ⊤
[⊤]-as-nullifierᵣ _ = [⊤]-intro
------------------------------------------
-- Other
module _ {ℓ₁}{ℓ₂} {P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} where
[∨]-not-left : (P ∨ Q) → (¬ P) → Q
[∨]-not-left ([∨]-introₗ p) np = [⊥]-elim(np p)
[∨]-not-left ([∨]-introᵣ q) = const q
[∨]-not-right : (P ∨ Q) → (¬ Q) → P
[∨]-not-right ([∨]-introₗ p) = const p
[∨]-not-right ([∨]-introᵣ q) nq = [⊥]-elim(nq q)
module _ {ℓ₁}{ℓ₂}{ℓ₃} {P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}}{T : Stmt{ℓ₃}} where
[→]-lift : (P → Q) → ((T → P) → (T → Q))
[→]-lift = liftₗ
module _ {ℓ₁ ℓ₂} {P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} where
contrapositiveᵣ : (P → Q) → ((¬ P) ← (¬ Q))
contrapositiveᵣ = [→]-transitivity
contrapositive-variant : (P → (¬ Q)) ↔ ((¬ P) ← Q)
contrapositive-variant = [↔]-intro swap swap
modus-tollens : (P → Q) → (¬ Q) → (¬ P)
modus-tollens = contrapositiveᵣ
module _ {ℓ₁}{ℓ₂}{ℓ₃}{ℓ₄} {A : Stmt{ℓ₁}}{B : Stmt{ℓ₂}}{C : Stmt{ℓ₃}}{D : Stmt{ℓ₄}} where
constructive-dilemma : (A → B) → (C → D) → (A ∨ C) → (B ∨ D)
constructive-dilemma = [∨]-elim2
destructive-dilemma : (A → B) → (C → D) → ((¬ B) ∨ (¬ D)) → ((¬ A) ∨ (¬ C))
destructive-dilemma l r = [∨]-elim2 (contrapositiveᵣ l) (contrapositiveᵣ r)
module _ {ℓ} {P : Stmt{ℓ}} where
[¬¬]-intro : P → (¬¬ P)
[¬¬]-intro = apply
-- P → (P → ⊥) → ⊥
[¬¬¬]-elim : (¬ (¬ (¬ P))) → (¬ P)
[¬¬¬]-elim = contrapositiveᵣ [¬¬]-intro
module _ {ℓ₁}{ℓ₂}{ℓ₃} {P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}}{R : Stmt{ℓ₃}} where
[↔]-move-out-[∧]ᵣ : ((P ∧ R) ↔ (Q ∧ R)) → (R → (P ↔ Q))
[↔]-move-out-[∧]ᵣ ([↔]-intro qrpr prqr) r =
([↔]-intro
(q ↦ [∧]-elimₗ(qrpr([∧]-intro q r)))
(p ↦ [∧]-elimₗ(prqr([∧]-intro p r)))
)
[∧]-unaryOperatorₗ : (P ↔ Q) → ((P ∧ R) ↔ (Q ∧ R))
[∧]-unaryOperatorₗ ([↔]-intro qp pq) =
([↔]-intro
(qr ↦ [∧]-intro (qp([∧]-elimₗ qr)) ([∧]-elimᵣ qr))
(pr ↦ [∧]-intro (pq([∧]-elimₗ pr)) ([∧]-elimᵣ pr))
)
currying : (P → (Q → R)) ↔ ((P ∧ Q) → R)
currying = [↔]-intro Tuple.curry Tuple.uncurry
module _ {ℓ₁}{ℓ₂}{ℓ₃}{ℓ₄} {A : Stmt{ℓ₁}}{B : Stmt{ℓ₂}}{C : Stmt{ℓ₃}}{D : Stmt{ℓ₄}} where
[∧]-binaryOperator : (A ↔ C) → (B ↔ D) → ((A ∧ B) ↔ (C ∧ D))
[∧]-binaryOperator ([↔]-intro ca ac) ([↔]-intro db bd) = [↔]-intro (Tuple.map ca db) (Tuple.map ac bd)
[∨]-binaryOperator : (A ↔ C) → (B ↔ D) → ((A ∨ B) ↔ (C ∨ D))
[∨]-binaryOperator ([↔]-intro ca ac) ([↔]-intro db bd) = [↔]-intro (Either.map ca db) (Either.map ac bd)
module _ {ℓ₁}{ℓ₂} {P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} where
[↔]-not-left : (P ↔ Q) → (¬ P) → (¬ Q)
[↔]-not-left pq np q = np([↔]-elimₗ(q)(pq))
[↔]-not-right : (P ↔ Q) → (¬ Q) → (¬ P)
[↔]-not-right pq nq p = nq([↔]-elimᵣ(p)(pq))
[¬]-unaryOperator : (P ↔ Q) → ((¬ P) ↔ (¬ Q))
[¬]-unaryOperator pq = [↔]-intro ([↔]-not-right (pq)) ([↔]-not-left (pq))
module _ {ℓ₁}{ℓ₂} {P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} where
[↔]-elim-[∨] : (P ↔ Q) → (P ∨ Q) → (P ∧ Q)
[↔]-elim-[∨] (p↔q) ([∨]-introₗ p) = [∧]-intro p ([↔]-elimᵣ(p) p↔q)
[↔]-elim-[∨] (p↔q) ([∨]-introᵣ q) = [∧]-intro ([↔]-elimₗ(q) p↔q) q
module _ {ℓ} {P : Stmt{ℓ}} where
provable-top-equivalence : P → (P ↔ ⊤)
provable-top-equivalence p = [↔]-intro (const p) (const [⊤]-intro)
unprovable-bottom-equivalence : (¬ P) → (P ↔ ⊥)
unprovable-bottom-equivalence np = [↔]-intro [⊥]-elim np
------------------------------------------
-- Negation is almost preserved over the conjunction-dijunction dual (De-morgan's laws).
module _ {ℓ₁ ℓ₂} {P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} where
[¬]-preserves-[∧][∨]ₗ : (¬ (P ∧ Q)) ← ((¬ P) ∨ (¬ Q))
[¬]-preserves-[∧][∨]ₗ ([∨]-introₗ np) = np ∘ [∧]-elimₗ
[¬]-preserves-[∧][∨]ₗ ([∨]-introᵣ nq) = nq ∘ [∧]-elimᵣ
[¬]-preserves-[∨][∧] : (¬ (P ∨ Q)) ↔ ((¬ P) ∧ (¬ Q))
[¬]-preserves-[∨][∧] = [↔]-intro l r where
l : ¬(P ∨ Q) ← ((¬ P) ∧ (¬ Q))
l ([∧]-intro np nq) = [∨]-elim np nq
r : (¬ (P ∨ Q)) → ((¬ P) ∧ (¬ Q))
r f = [∧]-intro (f ∘ [∨]-introₗ) (f ∘ [∨]-introᵣ)
------------------------------------------
-- Conjunction and implication (Tuples and functions)
module _ {ℓ₁}{ℓ₂}{ℓ₃} {P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}}{R : Stmt{ℓ₃}} where
[→][∧]-assumption : ((P ∧ Q) → R) ↔ (P → Q → R)
[→][∧]-assumption = [↔]-intro Tuple.uncurry Tuple.curry
[→][∧]-distributivityₗ : (P → (Q ∧ R)) ↔ ((P → Q) ∧ (P → R))
[→][∧]-distributivityₗ = [↔]-intro l r
where l : ((P → Q) ∧ (P → R)) → (P → (Q ∧ R))
l ([∧]-intro pq pr) p = [∧]-intro (pq(p)) (pr(p))
r : ((P → Q) ∧ (P → R)) ← (P → (Q ∧ R))
r both = [∧]-intro ([∧]-elimₗ ∘ both) ([∧]-elimᵣ ∘ both)
[→][∨]-distributivityₗₗ : (P → (Q ∨ R)) ← ((P → Q) ∨ (P → R))
[→][∨]-distributivityₗₗ = l
where l : ((P → Q) ∨ (P → R)) → (P → (Q ∨ R))
l ([∨]-introₗ pq) p = [∨]-introₗ (pq(p))
l ([∨]-introᵣ pr) p = [∨]-introᵣ (pr(p))
[→ₗ][∨][∧]-preserving : ((P ∨ Q) → R) ↔ ((P → R) ∧ (Q → R))
[→ₗ][∨][∧]-preserving = [↔]-intro l r where
l : ((P ∨ Q) → R) ← ((P → R) ∧ (Q → R))
l ([∧]-intro pr qr) ([∨]-introₗ p) = pr p
l ([∧]-intro pr qr) ([∨]-introᵣ q) = qr q
r : ((P ∨ Q) → R) → ((P → R) ∧ (Q → R))
r pqr = [∧]-intro (pqr ∘ [∨]-introₗ) (pqr ∘ [∨]-introᵣ)
module _ {ℓ} {P : Stmt{ℓ}} where
non-contradiction : ¬(P ∧ (¬ P))
non-contradiction(p , np) = np p
------------------------------------------
-- Redundant formulas in operations
module _ {ℓ₁}{ℓ₂} {A : Stmt{ℓ₁}}{B : Stmt{ℓ₂}} where
[→]-redundancy : (A → A → B) → (A → B)
[→]-redundancy = _$₂_
module _ {ℓ} {A : Stmt{ℓ}} where
[∧]-redundancy : (A ∧ A) ↔ A
[∧]-redundancy = [↔]-intro ([∧]-intro $₂_) [∧]-elimₗ
[∨]-redundancy : (A ∨ A) ↔ A
[∨]-redundancy = [↔]-intro [∨]-introₗ ([∨]-elim id id)
------------------------------------------
-- Disjunctive forms
module _ {ℓ₁}{ℓ₂} {P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} where
-- Also called: Material implication
[→]-disjunctive-formₗ : (P → Q) ← ((¬ P) ∨ Q)
[→]-disjunctive-formₗ = [∨]-elim ([→]-lift [⊥]-elim) const
[↔]-disjunctive-formₗ : (P ↔ Q) ← ((P ∧ Q) ∨ ((¬ P) ∧ (¬ Q)))
[↔]-disjunctive-formₗ ([∨]-introₗ pq) = [∧]-to-[↔] pq
[↔]-disjunctive-formₗ ([∨]-introᵣ npnq) = Tuple.map ([⊥]-elim ∘_) ([⊥]-elim ∘_) (Tuple.swap npnq)
-- TODO: Probably unprovable
-- [↔]-disjunctive-formᵣ : ∀{P Q : Stmt} → (P ↔ Q) → ((P ∧ Q) ∨ ((¬ P) ∧ (¬ Q)))
-- [↔]-disjunctive-formᵣ ([↔]-intro qp pq) =
[¬→]-disjunctive-formₗ : ((¬ P) → Q) ← (P ∨ Q)
[¬→]-disjunctive-formₗ = [∨]-not-left
------------------------------------------
-- Conjuctive forms
-- TODO: None of them are provable?
-- [↔]-conjunctive-form : ∀{P Q : Stmt} → (P ↔ Q) ↔ ((P ∨ Q) ∧ ((¬ P) ∨ (¬ Q)))
-- [↔]-conjunctive-form ([↔]-intro qp pq) = [∨]-elim ([→]-lift [⊥]-elim) (const)
module _ {ℓ₁ ℓ₂} {P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} where
[→][∧]ᵣ : (P → Q) → ¬(P ∧ (¬ Q))
[→][∧]ᵣ f = Tuple.uncurry([¬¬]-intro ∘ f)
[¬→][∧]ₗ : ¬(P → Q) ← (P ∧ (¬ Q))
[¬→][∧]ₗ = swap [→][∧]ᵣ
[→¬]-¬[∧] : (P → (¬ Q)) ↔ ¬(P ∧ Q)
[→¬]-¬[∧] = currying
------------------------------------------
-- Equivalences (TODO: I remember these being defined somewhere else, but I am not sure. At least some special cases have been used somewhere else)
module _ where
private variable ℓ : Lvl.Level
private variable A A₁ A₂ B B₁ B₂ : Type{ℓ}
[∧]-map-[↔] : (A₁ ↔ A₂) → (B₁ ↔ B₂) → ((A₁ ∧ B₁) ↔ (A₂ ∧ B₂))
[∧]-map-[↔] a b = [↔]-intro (Tuple.map ([↔]-to-[←] a) ([↔]-to-[←] b)) (Tuple.map ([↔]-to-[→] a) ([↔]-to-[→] b))
[∧]-mapₗ-[↔] : (A₁ ↔ A₂) → ((A₁ ∧ B) ↔ (A₂ ∧ B))
[∧]-mapₗ-[↔] a = [∧]-map-[↔] a [↔]-reflexivity
[∧]-mapᵣ-[↔] : (B₁ ↔ B₂) → ((A ∧ B₁) ↔ (A ∧ B₂))
[∧]-mapᵣ-[↔] b = [∧]-map-[↔] [↔]-reflexivity b
[∨]-map-[↔] : (A₁ ↔ A₂) → (B₁ ↔ B₂) → ((A₁ ∨ B₁) ↔ (A₂ ∨ B₂))
[∨]-map-[↔] a b = [↔]-intro (Either.map ([↔]-to-[←] a) ([↔]-to-[←] b)) (Either.map ([↔]-to-[→] a) ([↔]-to-[→] b))
[∨]-mapₗ-[↔] : (A₁ ↔ A₂) → ((A₁ ∨ B) ↔ (A₂ ∨ B))
[∨]-mapₗ-[↔] a = [∨]-map-[↔] a [↔]-reflexivity
[∨]-mapᵣ-[↔] : (B₁ ↔ B₂) → ((A ∨ B₁) ↔ (A ∨ B₂))
[∨]-mapᵣ-[↔] b = [∨]-map-[↔] [↔]-reflexivity b
[↔]-map-[↔] : (A₁ ↔ A₂) → (B₁ ↔ B₂) → ((A₁ ↔ B₁) ↔ (A₂ ↔ B₂))
[↔]-map-[↔] a b =
[↔]-intro
(Tuple.map
(b₂a₂ ↦ [↔]-to-[←] a ∘ b₂a₂ ∘ [↔]-to-[→] b)
(a₂b₂ ↦ [↔]-to-[←] b ∘ a₂b₂ ∘ [↔]-to-[→] a)
)
(Tuple.map
(b₁a₁ ↦ [↔]-to-[→] a ∘ b₁a₁ ∘ [↔]-to-[←] b)
(a₁b₁ ↦ [↔]-to-[→] b ∘ a₁b₁ ∘ [↔]-to-[←] a)
)
[↔]-mapₗ-[↔] : (A₁ ↔ A₂) → ((A₁ ↔ B) ↔ (A₂ ↔ B))
[↔]-mapₗ-[↔] a = [↔]-map-[↔] a [↔]-reflexivity
[↔]-mapᵣ-[↔] : (B₁ ↔ B₂) → ((A ↔ B₁) ↔ (A ↔ B₂))
[↔]-mapᵣ-[↔] b = [↔]-map-[↔] [↔]-reflexivity b
[→]-map-[↔] : (A₁ ↔ A₂) → (B₁ ↔ B₂) → ((A₁ → B₁) ↔ (A₂ → B₂))
[→]-map-[↔] a b = [↔]-intro (ab ↦ [↔]-to-[←] b ∘ ab ∘ [↔]-to-[→] a) (ab ↦ [↔]-to-[→] b ∘ ab ∘ [↔]-to-[←] a)
------------------------------------------
-- Stuff related to classical logic
module _ {ℓ} {P : Stmt{ℓ}} where
[¬¬]-excluded-middle : ¬¬(P ∨ (¬ P))
[¬¬]-excluded-middle =
([¬]-intro(naorna ↦
((non-contradiction([∧]-intro
(([∨]-introᵣ
(([¬]-intro(a ↦
((non-contradiction([∧]-intro
(([∨]-introₗ a) :of: (P ∨ (¬ P)))
(naorna :of: ¬(P ∨ (¬ P)))
)) :of: ⊥)
)) :of: (¬ P))
) :of: (P ∨ (¬ P)))
(naorna :of: ¬(P ∨ (¬ P)))
)) :of: ⊥)
)) :of: ¬¬(P ∨ (¬ P))
-- Note:
-- ∀{P} → (P ∨ (¬ P)) ← ((¬¬ P) → P)
-- is not provable because the statement (P ∨ (¬ P)) requires a [¬¬]-elim.
-- TODO: ...I think? I do not think (∀{P} → ¬¬(P ∨ (¬ P)) → ((¬¬ P) ∨ (¬ P))) is provable.
[¬¬]-elim-from-excluded-middle : (P ∨ (¬ P)) → ((¬¬ P) → P)
[¬¬]-elim-from-excluded-middle ([∨]-introₗ p) (nnp) = p
[¬¬]-elim-from-excluded-middle ([∨]-introᵣ np) (nnp) = [⊥]-elim(nnp(np))
[¬¬]-elim-from-callcc : (∀{Q : Stmt{Lvl.𝟎}} → (((P → Q) → P) → P)) → ((¬¬ P) → P)
[¬¬]-elim-from-callcc (callcc) (nnp) = callcc{⊥} ([⊥]-elim ∘ nnp)
module _ {ℓ} where
[[¬¬]-elim]-[excluded-middle]-eqₗ : (∀{P : Stmt{ℓ}} → (¬¬ P) → P) ←ᶠ (∀{P : Stmt{ℓ}} → (P ∨ (¬ P)))
[[¬¬]-elim]-[excluded-middle]-eqₗ or {P} (nnp) with or
... | ([∨]-introₗ p ) = p
... | ([∨]-introᵣ np) = [⊥]-elim(nnp(np))
[[¬¬]-elim]-[excluded-middle]-eqᵣ : (∀{P : Stmt{ℓ}} → (¬¬ P) → P) → (∀{P : Stmt{ℓ}} → (P ∨ (¬ P)))
[[¬¬]-elim]-[excluded-middle]-eqᵣ (nnpp) = nnpp([¬¬]-excluded-middle)
-- TODO: https://math.stackexchange.com/questions/910240/equivalence-between-middle-excluded-law-and-double-negation-elimination-in-heyti
[callcc]-[[¬¬]-elim]-eqₗ : (∀{P : Stmt{ℓ}}{Q : Stmt{Lvl.𝟎}} → (((P → Q) → P) → P)) → (∀{P} → (¬¬ P) → P)
[callcc]-[[¬¬]-elim]-eqₗ (callcc) {P} (nnp) = callcc{P}{⊥} (np ↦ [⊥]-elim(nnp(np)))
[callcc]-[[¬¬]-elim]-eqᵣ : (∀{P : Stmt{ℓ}} → (¬¬ P) → P) → (∀{P Q : Stmt{ℓ}} → (((P → Q) → P) → P))
[callcc]-[[¬¬]-elim]-eqᵣ (nnpp) {P}{Q} (pqp) = nnpp([¬]-intro(np ↦ np(pqp(p ↦ [⊥]-elim(np p)))))
[callcc]-[excluded-middle]-eqₗ : (∀{P : Stmt{ℓ}} → (P ∨ (¬ P))) → (∀{P Q : Stmt{ℓ}} → (((P → Q) → P) → P))
[callcc]-[excluded-middle]-eqₗ or {P}{Q} (pqp) with or
... | ([∨]-introₗ p ) = p
... | ([∨]-introᵣ np) = pqp([⊥]-elim ∘ np)
[callcc]-[excluded-middle]-eqᵣ : (∀{P : Stmt{ℓ}}{Q : Stmt{Lvl.𝟎}} → (((P → Q) → P) → P)) → (∀{P : Stmt{ℓ}} → (P ∨ (¬ P)))
[callcc]-[excluded-middle]-eqᵣ (callcc) {P} = callcc{P ∨ (¬ P)}{⊥} (nor ↦ [⊥]-elim ([¬¬]-excluded-middle (nor)))
-- TODO: Does not have to be over all propositions P in assumption. Only wem P and wem Q are used.
weak-excluded-middle-[¬][∧]ₗ : (∀{P : Stmt{ℓ}} → (¬ P) ∨ (¬¬ P)) ↔ (∀{P : Stmt{ℓ}}{Q : Stmt{ℓ}} → ((¬ P) ∨ (¬ Q)) ← (¬ (P ∧ Q)))
weak-excluded-middle-[¬][∧]ₗ = [↔]-intro l r where
l : (∀{P : Stmt{ℓ}} → (¬ P) ∨ (¬¬ P)) ← (∀{P : Stmt{ℓ}}{Q : Stmt{ℓ}} → ((¬ P) ∨ (¬ Q)) ← (¬ (P ∧ Q)))
l [¬][∧]ₗ = [¬][∧]ₗ non-contradiction
r : (∀{P : Stmt{ℓ}} → (¬ P) ∨ (¬¬ P)) → (∀{P : Stmt{ℓ}}{Q : Stmt{ℓ}} → ((¬ P) ∨ (¬ Q)) ← (¬ (P ∧ Q)))
r wem {P = P} {Q = Q} npq with wem {P = P} | wem {P = Q}
r wem {P = P} {Q = Q} npq | [∨]-introₗ np | [∨]-introₗ nq = [∨]-introₗ np
r wem {P = P} {Q = Q} npq | [∨]-introₗ np | [∨]-introᵣ nnq = [∨]-introₗ np
r wem {P = P} {Q = Q} npq | [∨]-introᵣ nnp | [∨]-introₗ nq = [∨]-introᵣ nq
r wem {P = P} {Q = Q} npq | [∨]-introᵣ nnp | [∨]-introᵣ nnq = [∨]-introᵣ (q ↦ nnp (p ↦ npq ([∧]-intro p q)))
------------------------------------------
-- XOR
module _ {ℓ₁}{ℓ₂} {P : Stmt{ℓ₁}}{Q : Stmt{ℓ₂}} where
[⊕][↔]-contradiction : (P ⊕ Q) → (P ↔ Q) → ⊥
[⊕][↔]-contradiction ([⊕]-introₗ p nq) pq = nq([↔]-elimᵣ p pq)
[⊕][↔]-contradiction ([⊕]-introᵣ q np) pq = np([↔]-elimₗ q pq)
[⊕][∧]-contradiction : (P ⊕ Q) → (P ∧ Q) → ⊥
[⊕][∧]-contradiction xor = [⊕][↔]-contradiction xor ∘ [∧]-to-[↔]
[⊕]-not-both : (P ⊕ Q) → P → Q → ⊥
[⊕]-not-both = Tuple.curry ∘ [⊕][∧]-contradiction
[⊕]-not-left : (P ⊕ Q) → P → (¬ Q)
[⊕]-not-left = [⊕]-not-both
[⊕]-not-right : (P ⊕ Q) → Q → (¬ P)
[⊕]-not-right = swap ∘ [⊕]-not-both
[⊕]-to-[∨] : (P ⊕ Q) → (P ∨ Q)
[⊕]-to-[∨] ([⊕]-introₗ p _) = [∨]-introₗ p
[⊕]-to-[∨] ([⊕]-introᵣ q _) = [∨]-introᵣ q
[⊕]-to-[¬∨] : (P ⊕ Q) → ((¬ P) ∨ (¬ Q))
[⊕]-to-[¬∨] ([⊕]-introₗ _ nq) = [∨]-introᵣ nq
[⊕]-to-[¬∨] ([⊕]-introᵣ _ np) = [∨]-introₗ np
[⊕]-excluded-middleₗ : (P ⊕ Q) → (P ∨ (¬ P))
[⊕]-excluded-middleₗ ([⊕]-introₗ p nq) = [∨]-introₗ p
[⊕]-excluded-middleₗ ([⊕]-introᵣ q np) = [∨]-introᵣ np
[⊕]-excluded-middleᵣ : (P ⊕ Q) → (Q ∨ (¬ Q))
[⊕]-excluded-middleᵣ ([⊕]-introₗ p nq) = [∨]-introᵣ nq
[⊕]-excluded-middleᵣ ([⊕]-introᵣ q np) = [∨]-introₗ q
[⊕]-or-not-both : (P ∨ Q) → ¬(P ∧ Q) → (P ⊕ Q)
[⊕]-or-not-both or nand with or
... | [∨]-introₗ p = [⊕]-introₗ p (q ↦ nand([↔]-intro p q))
... | [∨]-introᵣ q = [⊕]-introᵣ q (p ↦ nand([↔]-intro p q))
| {
"alphanum_fraction": 0.4258623192,
"avg_line_length": 37.5836363636,
"ext": "agda",
"hexsha": "87cf0c57ccbdac11f56c14856a05204d29334c9e",
"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": "Logic/Propositional/Theorems.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": "Logic/Propositional/Theorems.agda",
"max_line_length": 147,
"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": "Logic/Propositional/Theorems.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": 10574,
"size": 20671
} |
module Two where
open import Relation.Binary.PropositionalEquality
open ≡-Reasoning
import Data.Nat as ℕ
import Data.Nat.Properties as ℕₚ
open ℕ using (ℕ; zero; suc; _+_)
-- Our language consists of constants and addition
data Expr : Set where
const : ℕ → Expr
plus : Expr → Expr → Expr
-- Straightforward semantics
eval-expr : Expr → ℕ
eval-expr (const n) = n
eval-expr (plus e1 e2) = eval-expr e1 + eval-expr e2
-- Tail recursive semantics
eval-expr-tail' : Expr → ℕ → ℕ
eval-expr-tail' (const n) acc = n + acc
eval-expr-tail' (plus e1 e2) acc = eval-expr-tail' e2 (eval-expr-tail' e1 acc)
eval-expr-tail : Expr → ℕ
eval-expr-tail e = eval-expr-tail' e 0
--
-- Task: prove that eval-expr-tail is equivalent to eval-expr.
--
-- The tail recursive evaluation does not depend on its accumulator
eval-expr-tail-correct-lemma : ∀ e acc → eval-expr-tail' e acc ≡ eval-expr-tail' e 0 + acc
eval-expr-tail-correct-lemma e acc = ?
-- The tail recursive evaluation agrees with the straightforward evaluation
eval-expr-tail-correct : ∀ e → eval-expr-tail e ≡ eval-expr e
eval-expr-tail-correct e = ?
| {
"alphanum_fraction": 0.7113122172,
"avg_line_length": 27.625,
"ext": "agda",
"hexsha": "b51a2c434d74358d16362b57835a2b9d2f2e0774",
"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": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "UoG-Agda/Agda101",
"max_forks_repo_path": "Exercises/Two.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff",
"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": "UoG-Agda/Agda101",
"max_issues_repo_path": "Exercises/Two.agda",
"max_line_length": 90,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "d9359c5bfd0eaf69efe1113945d7f3145f6b2dff",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "UoG-Agda/Agda101",
"max_stars_repo_path": "Exercises/Two.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 348,
"size": 1105
} |
-- Opening this module allows lists to be written using "list notation".
-- Examples:
-- [] = ∅
-- [ a ] = a ⊰ ∅
-- [ a , b ] = a ⊰ b ⊰ ∅
-- [ a , b , c ] = a ⊰ b ⊰ c ⊰ ∅
module Syntax.List where
open import Data.List
{-
infixl 1 [_
infixr 1000 _,_
infixl 100000 _]
pattern [] = ∅
pattern [_ l = l
pattern _,_ x l = x ⊰ l
pattern _] x = x ⊰ ∅
-}
pattern [] = ∅
pattern [_] x₁ = x₁ ⊰ ∅
pattern [_,_] x₁ x₂ = x₁ ⊰ x₂ ⊰ ∅
pattern [_,_,_] x₁ x₂ x₃ = x₁ ⊰ x₂ ⊰ x₃ ⊰ ∅
pattern [_,_,_,_] x₁ x₂ x₃ x₄ = x₁ ⊰ x₂ ⊰ x₃ ⊰ x₄ ⊰ ∅
pattern [_,_,_,_,_] x₁ x₂ x₃ x₄ x₅ = x₁ ⊰ x₂ ⊰ x₃ ⊰ x₄ ⊰ x₅ ⊰ ∅
pattern [_,_,_,_,_,_] x₁ x₂ x₃ x₄ x₅ x₆ = x₁ ⊰ x₂ ⊰ x₃ ⊰ x₄ ⊰ x₅ ⊰ x₆ ⊰ ∅
pattern [_,_,_,_,_,_,_] x₁ x₂ x₃ x₄ x₅ x₆ x₇ = x₁ ⊰ x₂ ⊰ x₃ ⊰ x₄ ⊰ x₅ ⊰ x₆ ⊰ x₇ ⊰ ∅
pattern [_,_,_,_,_,_,_,_] x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈ = x₁ ⊰ x₂ ⊰ x₃ ⊰ x₄ ⊰ x₅ ⊰ x₆ ⊰ x₇ ⊰ x₈ ⊰ ∅
pattern [_,_,_,_,_,_,_,_,_] x₁ x₂ x₃ x₄ x₅ x₆ x₇ x₈ x₉ = x₁ ⊰ x₂ ⊰ x₃ ⊰ x₄ ⊰ x₅ ⊰ x₆ ⊰ x₇ ⊰ x₈ ⊰ x₉ ⊰ ∅
| {
"alphanum_fraction": 0.3978583196,
"avg_line_length": 37.9375,
"ext": "agda",
"hexsha": "1c3088415d4db04bb71cccceabd8041240a41015",
"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": "Syntax/List.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": "Syntax/List.agda",
"max_line_length": 103,
"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": "Syntax/List.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": 602,
"size": 1214
} |
{-# OPTIONS --without-K #-}
module sets.int.definition where
open import sum
open import equality
open import function
open import sets.nat.core
open import hott.level
private
data Z : Set where
mk-int : ℕ → ℕ → Z
ℤ : Set
ℤ = Z
_[-]_ : ℕ → ℕ → ℤ
_[-]_ = mk-int
postulate
eq-ℤ : (n m d : ℕ) → n [-] m ≡ (d + n) [-] (d + m)
hℤ : h 2 ℤ
IsAlg-ℤ : ∀ {i} → Set i → Set _
IsAlg-ℤ X = Σ (ℕ → ℕ → X) λ f
→ (∀ n m d → f n m ≡ f (d + n) (d + m))
aℤ : IsAlg-ℤ ℤ
aℤ = _[-]_ , eq-ℤ
map-Alg-ℤ : ∀ {i j}{X : Set i}{Y : Set j}
→ (X → Y) → IsAlg-ℤ X → IsAlg-ℤ Y
map-Alg-ℤ {X = X}{Y} h (f , u) = (g , v)
where
g : ℕ → ℕ → Y
g n m = h (f n m)
v : ∀ n m d → g n m ≡ g (d + n) (d + m)
v n m d = ap h (u n m d)
map-Alg-ℤ-id : ∀ {i}{X : Set i}(aX : IsAlg-ℤ X)
→ map-Alg-ℤ (λ x → x) aX ≡ aX
map-Alg-ℤ-id aX = unapΣ (refl ,
funext λ n → funext λ m → funext λ d → ap-id _)
map-Alg-ℤ-hom : ∀ {i j k}{X : Set i}{Y : Set j}{Z : Set k}
→ (f : Y → Z)(g : X → Y)(aX : IsAlg-ℤ X)
→ map-Alg-ℤ (f ∘' g) aX
≡ map-Alg-ℤ f (map-Alg-ℤ g aX)
map-Alg-ℤ-hom f g aX = unapΣ (refl , funext λ n → funext λ m → funext λ d
→ sym (ap-hom g f _))
Hom-ℤ : ∀ {i j}{X : Set i}{Y : Set j}
→ IsAlg-ℤ X → IsAlg-ℤ Y → Set _
Hom-ℤ {X = X}{Y} aX aY = Σ (X → Y) λ h → map-Alg-ℤ h aX ≡ aY
id-ℤ : ∀ {i}{X : Set i}(aX : IsAlg-ℤ X) → Hom-ℤ aX aX
id-ℤ aX = (λ x → x) , map-Alg-ℤ-id aX
_⋆ℤ_ : ∀ {i j k}{X : Set i}{Y : Set j}{Z : Set k}
→ {aX : IsAlg-ℤ X}{aY : IsAlg-ℤ Y}{aZ : IsAlg-ℤ Z}
→ Hom-ℤ aY aZ → Hom-ℤ aX aY → Hom-ℤ aX aZ
_⋆ℤ_ {aX = aX} (f , u) (g , v) = f ∘' g , map-Alg-ℤ-hom f g aX · ap (map-Alg-ℤ f) v · u
module _ {i}{X : Set i}(hX : h 2 X)(aX : IsAlg-ℤ X) where
elim-ℤ : ℤ → X
elim-ℤ (mk-int n n') = proj₁ aX n n'
postulate elim-β-ℤ : ∀ n m d → ap elim-ℤ (eq-ℤ n m d) ≡ proj₂ aX n m d
elim-Alg-β-ℤ : map-Alg-ℤ elim-ℤ aℤ ≡ aX
elim-Alg-β-ℤ = unapΣ (refl , funext λ n → funext λ m → funext λ d → elim-β-ℤ n m d)
elim-Alg-ℤ : Hom-ℤ aℤ aX
elim-Alg-ℤ = elim-ℤ , elim-Alg-β-ℤ
postulate univ-ℤ : (h : Hom-ℤ aℤ aX) → elim-Alg-ℤ ≡ h
Hom-ℤ-contr : contr (Hom-ℤ aℤ aX)
Hom-ℤ-contr = elim-Alg-ℤ , univ-ℤ
elim-prop-ℤ : ∀ {i}{X : ℤ → Set i} → (∀ n → h 1 (X n))
→ (f : ∀ n m → X (n [-] m))
→ ∀ n → X n
elim-prop-ℤ {X = X} hX f n = subst X (i-β₀ n) (proj₂ (s₀ n))
where
Y : Set _
Y = Σ ℤ X
hY : h 2 Y
hY = Σ-level hℤ λ n → h↑ (hX n)
aY : IsAlg-ℤ Y
aY = (λ n m → (n [-] m , f n m))
, (λ n m d → unapΣ (eq-ℤ n m d , h1⇒prop (hX ((d + n) [-] (d + m))) _ _))
pY : Hom-ℤ aY aℤ
pY = proj₁ , unapΣ (refl , h1⇒prop
(Π-level λ n → Π-level λ m → Π-level λ p → hℤ _ _) _ _)
s : Hom-ℤ aℤ aY
s = elim-Alg-ℤ hY aY
s₀ : ℤ → Y
s₀ = proj₁ s
i-β₀ : ∀ n → proj₁ (s₀ n) ≡ n
i-β₀ n = ap (λ f → proj₁ f n)
(contr⇒prop (Hom-ℤ-contr hℤ aℤ) (pY ⋆ℤ s) (id-ℤ aℤ))
| {
"alphanum_fraction": 0.4723652592,
"avg_line_length": 26.0089285714,
"ext": "agda",
"hexsha": "061b75c72676979b98dd5d943097984987a1546f",
"lang": "Agda",
"max_forks_count": 4,
"max_forks_repo_forks_event_max_datetime": "2019-05-04T19:31:00.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-02-02T12:17:00.000Z",
"max_forks_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "pcapriotti/agda-base",
"max_forks_repo_path": "src/sets/int/definition.agda",
"max_issues_count": 4,
"max_issues_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_issues_repo_issues_event_max_datetime": "2016-10-26T11:57:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-02-02T14:32:16.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "pcapriotti/agda-base",
"max_issues_repo_path": "src/sets/int/definition.agda",
"max_line_length": 87,
"max_stars_count": 20,
"max_stars_repo_head_hexsha": "bbbc3bfb2f80ad08c8e608cccfa14b83ea3d258c",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "pcapriotti/agda-base",
"max_stars_repo_path": "src/sets/int/definition.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-01T11:25:54.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-06-12T12:20:17.000Z",
"num_tokens": 1535,
"size": 2913
} |
module Files where
open import Prelude
open import System.File
open import System.FilePath
open import Prelude.Equality
fileIsEqual : ∀ {k} → Path k → Path k → IO Unit
fileIsEqual a b = _≟_ <$> readBinaryFile a <*> readBinaryFile b >>= λ x →
if x then return unit else exitWith (Failure 1)
where
-- Move this to Prelude.Equality?
_≟_ : ∀ {a} {A : Set a} → {{eq : Eq A}} → A → A → Bool
x ≟ y = isYes (x == y)
main : IO ⊤
main =
readTextFile fIn >>=
writeTextFile fTxtOut >>
readBinaryFile fIn >>=
writeBinaryFile fBinOut >>
fileIsEqual fIn fTxtOut >>
fileIsEqual fIn fBinOut
where
fIn = relative "Files.agda"
fTxtOut = relative "test_files_txt.out"
fBinOut = relative "test_files_bin.out"
| {
"alphanum_fraction": 0.662585034,
"avg_line_length": 24.5,
"ext": "agda",
"hexsha": "928518fbcbc3bfc1b661136b6a221d29ea701a84",
"lang": "Agda",
"max_forks_count": 24,
"max_forks_repo_forks_event_max_datetime": "2021-04-22T06:10:41.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-03-12T18:03:45.000Z",
"max_forks_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "L-TChen/agda-prelude",
"max_forks_repo_path": "test/Files.agda",
"max_issues_count": 59,
"max_issues_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_issues_repo_issues_event_max_datetime": "2022-01-14T07:32:36.000Z",
"max_issues_repo_issues_event_min_datetime": "2016-02-09T05:36:44.000Z",
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "L-TChen/agda-prelude",
"max_issues_repo_path": "test/Files.agda",
"max_line_length": 73,
"max_stars_count": 111,
"max_stars_repo_head_hexsha": "158d299b1b365e186f00d8ef5b8c6844235ee267",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "L-TChen/agda-prelude",
"max_stars_repo_path": "test/Files.agda",
"max_stars_repo_stars_event_max_datetime": "2022-02-12T23:29:26.000Z",
"max_stars_repo_stars_event_min_datetime": "2015-01-05T11:28:15.000Z",
"num_tokens": 237,
"size": 735
} |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.ZCohomology.Properties where
open import Cubical.ZCohomology.Base
open import Cubical.HITs.S1
open import Cubical.HITs.Sn
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.Transport
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Univalence
open import Cubical.Data.Empty
open import Cubical.Data.Sigma hiding (_×_)
open import Cubical.HITs.Susp
open import Cubical.HITs.Wedge
open import Cubical.HITs.SetTruncation renaming (rec to sRec ; elim to sElim ; elim2 to sElim2 ; setTruncIsSet to §)
open import Cubical.HITs.Nullification
open import Cubical.Data.Int renaming (_+_ to _ℤ+_)
open import Cubical.Data.Nat
open import Cubical.HITs.Truncation renaming (elim to trElim ; map to trMap ; rec to trRec ; elim3 to trElim3)
open import Cubical.Homotopy.Loopspace
open import Cubical.Homotopy.Connected
open import Cubical.Homotopy.Freudenthal
open import Cubical.HITs.SmashProduct.Base
open import Cubical.Algebra.Group
open import Cubical.Algebra.Semigroup
open import Cubical.Algebra.Monoid
open import Cubical.Foundations.Equiv.HalfAdjoint
open import Cubical.HITs.Pushout
open import Cubical.Data.Sum.Base
open import Cubical.Data.HomotopyGroup
open import Cubical.ZCohomology.KcompPrelims
private
variable
ℓ ℓ' : Level
A : Type ℓ
B : Type ℓ'
A' : Pointed ℓ
{- Equivalence between cohomology of A and reduced cohomology of (A + 1) -}
coHomRed+1Equiv : (n : ℕ) →
(A : Type ℓ) →
(coHom n A) ≡ (coHomRed n ((A ⊎ Unit , inr (tt))))
coHomRed+1Equiv zero A i = ∥ helpLemma {C = (Int , pos 0)} i ∥₂
module coHomRed+1 where
helpLemma : {C : Pointed ℓ} → ( (A → (typ C)) ≡ ((((A ⊎ Unit) , inr (tt)) →∙ C)))
helpLemma {C = C} = isoToPath (iso map1
map2
(λ b → linvPf b)
(λ _ → refl))
where
map1 : (A → typ C) → ((((A ⊎ Unit) , inr (tt)) →∙ C))
map1 f = map1' , refl
module helpmap where
map1' : A ⊎ Unit → fst C
map1' (inl x) = f x
map1' (inr x) = pt C
map2 : ((((A ⊎ Unit) , inr (tt)) →∙ C)) → (A → typ C)
map2 (g , pf) x = g (inl x)
linvPf : (b :((((A ⊎ Unit) , inr (tt)) →∙ C))) → map1 (map2 b) ≡ b
linvPf (f , snd) i = (λ x → helper x i) , λ j → snd ((~ i) ∨ j)
where
helper : (x : A ⊎ Unit) → ((helpmap.map1') (map2 (f , snd)) x) ≡ f x
helper (inl x) = refl
helper (inr tt) = sym snd
coHomRed+1Equiv (suc n) A i = ∥ coHomRed+1.helpLemma A i {C = ((coHomK (suc n)) , ∣ north ∣)} i ∥₂
-----------
Kn→ΩKn+1 : (n : ℕ) → coHomK n → typ (Ω (coHomK-ptd (suc n)))
Kn→ΩKn+1 n = Iso.fun (Iso3-Kn-ΩKn+1 n)
ΩKn+1→Kn : {n : ℕ} → typ (Ω (coHomK-ptd (suc n))) → coHomK n
ΩKn+1→Kn {n = n} = Iso.inv (Iso3-Kn-ΩKn+1 n)
Kn≃ΩKn+1 : {n : ℕ} → coHomK n ≃ typ (Ω (coHomK-ptd (suc n)))
Kn≃ΩKn+1 {n = n} = isoToEquiv (Iso-Kn-ΩKn+1 n)
---------- Algebra/Group stuff --------
0ₖ : {n : ℕ} → coHomK n
0ₖ {n = zero} = pt (coHomK-ptd 0)
0ₖ {n = suc n} = pt (coHomK-ptd (suc n))
infixr 35 _+ₖ_
_+ₖ_ : {n : ℕ} → coHomK n → coHomK n → coHomK n
_+ₖ_ {n = n} x y = ΩKn+1→Kn (Kn→ΩKn+1 n x ∙ Kn→ΩKn+1 n y)
-ₖ_ : {n : ℕ} → coHomK n → coHomK n
-ₖ_ {n = n} x = ΩKn+1→Kn (sym (Kn→ΩKn+1 n x))
Kn→ΩKn+10ₖ : (n : ℕ) → Kn→ΩKn+1 n 0ₖ ≡ refl
Kn→ΩKn+10ₖ zero = refl
Kn→ΩKn+10ₖ (suc n) = (λ i → cong ∣_∣ (rCancel (merid north) i)) -- could also use refl for n = 1, but for computational reasons I don't want to expand the definition if not necessary.
-0ₖ : {n : ℕ} → -ₖ 0ₖ {n = n} ≡ 0ₖ
-0ₖ {n = n} = (λ i → ΩKn+1→Kn (sym (Kn→ΩKn+10ₖ n i)))
∙∙ (λ i → ΩKn+1→Kn (Kn→ΩKn+10ₖ n (~ i)))
∙∙ Iso.leftInv (Iso3-Kn-ΩKn+1 n) 0ₖ
+ₖ→∙ : (n : ℕ) (a b : coHomK n) → Kn→ΩKn+1 n (a +ₖ b) ≡ Kn→ΩKn+1 n a ∙ Kn→ΩKn+1 n b
+ₖ→∙ n a b = Iso.rightInv (Iso3-Kn-ΩKn+1 n) (Kn→ΩKn+1 n a ∙ Kn→ΩKn+1 n b)
lUnitₖ : {n : ℕ} (x : coHomK n) → 0ₖ +ₖ x ≡ x
lUnitₖ {n = zero} x = cong ΩKn+1→Kn (sym (lUnit (Kn→ΩKn+1 zero x))) ∙
Iso.leftInv (Iso3-Kn-ΩKn+1 zero) x
lUnitₖ {n = suc n} x = (λ i → ΩKn+1→Kn (Kn→ΩKn+10ₖ (suc n) i ∙ Kn→ΩKn+1 (suc n) x)) ∙
(cong ΩKn+1→Kn (sym (lUnit (Kn→ΩKn+1 (suc n) x)))) ∙
Iso.leftInv (Iso3-Kn-ΩKn+1 (suc n)) x
rUnitₖ : {n : ℕ} (x : coHomK n) → x +ₖ 0ₖ ≡ x
rUnitₖ {n = zero} x = cong ΩKn+1→Kn (sym (rUnit (Kn→ΩKn+1 zero x))) ∙
Iso.leftInv (Iso3-Kn-ΩKn+1 zero) x
rUnitₖ {n = suc n} x = (λ i → ΩKn+1→Kn (Kn→ΩKn+1 (suc n) x ∙ Kn→ΩKn+10ₖ (suc n) i)) ∙
(cong ΩKn+1→Kn (sym (rUnit (Kn→ΩKn+1 (suc n) x)))) ∙
Iso.leftInv (Iso3-Kn-ΩKn+1 (suc n)) x
--
rCancelₖ : {n : ℕ} (x : coHomK n) → x +ₖ (-ₖ x) ≡ 0ₖ
rCancelₖ {n = zero} x = (λ i → ΩKn+1→Kn (Kn→ΩKn+1 zero x ∙ Iso.rightInv (Iso3-Kn-ΩKn+1 zero) (sym (Kn→ΩKn+1 zero x)) i)) ∙
cong ΩKn+1→Kn (rCancel (Kn→ΩKn+1 zero x))
rCancelₖ {n = suc n} x = (λ i → ΩKn+1→Kn (Kn→ΩKn+1 (1 + n) x ∙ Iso.rightInv (Iso3-Kn-ΩKn+1 (1 + n)) (sym (Kn→ΩKn+1 (1 + n) x)) i)) ∙
cong ΩKn+1→Kn (rCancel (Kn→ΩKn+1 (1 + n) x)) ∙
(λ i → ΩKn+1→Kn (Kn→ΩKn+10ₖ (suc n) (~ i))) ∙
Iso.leftInv (Iso3-Kn-ΩKn+1 (suc n)) 0ₖ
lCancelₖ : {n : ℕ} (x : coHomK n) → (-ₖ x) +ₖ x ≡ 0ₖ
lCancelₖ {n = zero} x = (λ i → ΩKn+1→Kn (Iso.rightInv (Iso3-Kn-ΩKn+1 zero) (sym (Kn→ΩKn+1 zero x)) i ∙ Kn→ΩKn+1 zero x)) ∙
cong ΩKn+1→Kn (lCancel (Kn→ΩKn+1 zero x))
lCancelₖ {n = suc n} x = (λ i → ΩKn+1→Kn (Iso.rightInv (Iso3-Kn-ΩKn+1 (1 + n)) (sym (Kn→ΩKn+1 (1 + n) x)) i ∙ Kn→ΩKn+1 (1 + n) x)) ∙
cong ΩKn+1→Kn (lCancel (Kn→ΩKn+1 (1 + n) x)) ∙
(λ i → ΩKn+1→Kn (Kn→ΩKn+10ₖ (suc n) (~ i))) ∙
Iso.leftInv (Iso3-Kn-ΩKn+1 (suc n)) 0ₖ
assocₖ : {n : ℕ} (x y z : coHomK n) → ((x +ₖ y) +ₖ z) ≡ (x +ₖ (y +ₖ z))
assocₖ {n = n} x y z = ((λ i → ΩKn+1→Kn (Kn→ΩKn+1 n (ΩKn+1→Kn (Kn→ΩKn+1 n x ∙ Kn→ΩKn+1 n y)) ∙ Kn→ΩKn+1 n z)) ∙∙
(λ i → ΩKn+1→Kn (Iso.rightInv (Iso3-Kn-ΩKn+1 n) (Kn→ΩKn+1 n x ∙ Kn→ΩKn+1 n y) i ∙ Kn→ΩKn+1 n z)) ∙∙
(λ i → ΩKn+1→Kn (assoc (Kn→ΩKn+1 n x) (Kn→ΩKn+1 n y) (Kn→ΩKn+1 n z) (~ i)))) ∙
(λ i → ΩKn+1→Kn ((Kn→ΩKn+1 n x) ∙ Iso.rightInv (Iso3-Kn-ΩKn+1 n) ((Kn→ΩKn+1 n y ∙ Kn→ΩKn+1 n z)) (~ i)))
commₖ : {n : ℕ} (x y : coHomK n) → (x +ₖ y) ≡ (y +ₖ x)
commₖ {n = n} x y i = ΩKn+1→Kn (EH-instance (Kn→ΩKn+1 n x) (Kn→ΩKn+1 n y) i)
where
EH-instance : (p q : typ (Ω ((∥ S₊ (suc n) ∥ (2 + (suc n))) , ∣ north ∣))) → p ∙ q ≡ q ∙ p
EH-instance = transport (λ i → (p q : K-Id n (~ i)) → p ∙ q ≡ q ∙ p)
λ p q → Eckmann-Hilton 0 p q
where
K-Id : (n : HLevel) → typ (Ω (hLevelTrunc (3 + n) (S₊ (1 + n)) , ∣ north ∣)) ≡ typ ((Ω^ 2) (hLevelTrunc (4 + n) (S₊ (2 + n)) , ∣ north ∣ ))
K-Id n = (λ i → typ (Ω (isoToPath (Iso2-Kn-ΩKn+1 (suc n)) i , hcomp (λ k → λ { (i = i0) → ∣ north ∣
; (i = i1) → transportRefl (λ j → ∣ rCancel (merid north) k j ∣) k})
(transp (λ j → isoToPath (Iso2-Kn-ΩKn+1 (suc n)) (i ∧ j)) (~ i) ∣ north ∣))))
rUnitₖ' : {n : ℕ} (x : coHomK n) → x +ₖ 0ₖ ≡ x
rUnitₖ' {n = n} x = commₖ x 0ₖ ∙ lUnitₖ x
-distrₖ : {n : ℕ} → (x y : coHomK n) → -ₖ (x +ₖ y) ≡ (-ₖ x) +ₖ (-ₖ y)
-distrₖ {n = n} x y = ((λ i → ΩKn+1→Kn (sym (Kn→ΩKn+1 n (ΩKn+1→Kn (Kn→ΩKn+1 n x ∙ Kn→ΩKn+1 n y))))) ∙∙
(λ i → ΩKn+1→Kn (sym (Iso.rightInv (Iso3-Kn-ΩKn+1 n) (Kn→ΩKn+1 n x ∙ Kn→ΩKn+1 n y) i))) ∙∙
(λ i → ΩKn+1→Kn (symDistr (Kn→ΩKn+1 n x) (Kn→ΩKn+1 n y) i))) ∙∙
(λ i → ΩKn+1→Kn (Iso.rightInv (Iso3-Kn-ΩKn+1 n) (sym (Kn→ΩKn+1 n y)) (~ i) ∙ (Iso.rightInv (Iso3-Kn-ΩKn+1 n) (sym (Kn→ΩKn+1 n x)) (~ i)))) ∙∙
commₖ (-ₖ y) (-ₖ x)
---- Group structure of cohomology groups ---
_+ₕ_ : {n : ℕ} → coHom n A → coHom n A → coHom n A
_+ₕ_ = sElim2 (λ _ _ → §) λ a b → ∣ (λ x → a x +ₖ b x) ∣₂
-ₕ : {n : ℕ} → coHom n A → coHom n A
-ₕ = sRec § λ a → ∣ (λ x → -ₖ a x) ∣₂
0ₕ : {n : ℕ} → coHom n A
0ₕ = ∣ (λ _ → 0ₖ) ∣₂
rUnitₕ : {n : ℕ} (x : coHom n A) → x +ₕ 0ₕ ≡ x
rUnitₕ = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → rUnitₖ (a x)) i ∣₂
lUnitₕ : {n : ℕ} (x : coHom n A) → 0ₕ +ₕ x ≡ x
lUnitₕ = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → lUnitₖ (a x)) i ∣₂
rCancelₕ : {n : ℕ} (x : coHom n A) → x +ₕ (-ₕ x) ≡ 0ₕ
rCancelₕ = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → rCancelₖ (a x)) i ∣₂
lCancelₕ : {n : ℕ} (x : coHom n A) → (-ₕ x) +ₕ x ≡ 0ₕ
lCancelₕ = sElim (λ _ → isOfHLevelPath 1 (§ _ _))
λ a i → ∣ funExt (λ x → lCancelₖ (a x)) i ∣₂
assocₕ : {n : ℕ} (x y z : coHom n A) → ((x +ₕ y) +ₕ z) ≡ (x +ₕ (y +ₕ z))
assocₕ = elim3 (λ _ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b c i → ∣ funExt (λ x → assocₖ (a x) (b x) (c x)) i ∣₂
commₕ : {n : ℕ} (x y : coHom n A) → (x +ₕ y) ≡ (y +ₕ x)
commₕ {n = n} = sElim2 (λ _ _ → isOfHLevelPath 1 (§ _ _))
λ a b i → ∣ funExt (λ x → commₖ (a x) (b x)) i ∣₂
-- Proof that rUnitₖ and lUnitₖ agree on 0ₖ. Needed for Mayer-Vietoris.
rUnitlUnit0 : {n : ℕ} → rUnitₖ {n = n} 0ₖ ≡ lUnitₖ 0ₖ
rUnitlUnit0 {n = zero} = refl
rUnitlUnit0 {n = suc n} =
(assoc (λ i → ΩKn+1→Kn (Kn→ΩKn+1 (suc n) 0ₖ ∙ Kn→ΩKn+10ₖ (suc n) i))
(cong ΩKn+1→Kn (sym (rUnit (Kn→ΩKn+1 (suc n) 0ₖ))))
(Iso.leftInv (Iso3-Kn-ΩKn+1 (suc n)) 0ₖ))
∙∙ (λ j → helper j
∙ Iso.leftInv (Iso3-Kn-ΩKn+1 (suc n)) 0ₖ)
∙∙ sym (assoc (λ i → ΩKn+1→Kn (Kn→ΩKn+10ₖ (suc n) i ∙ Kn→ΩKn+1 (suc n) 0ₖ))
(cong ΩKn+1→Kn (sym (lUnit (Kn→ΩKn+1 (suc n) 0ₖ))))
(Iso.leftInv (Iso3-Kn-ΩKn+1 (suc n)) 0ₖ))
where
helper : (λ i → ΩKn+1→Kn (Kn→ΩKn+1 (suc n) 0ₖ ∙ Kn→ΩKn+10ₖ (suc n) i))
∙ (cong ΩKn+1→Kn (sym (rUnit (Kn→ΩKn+1 (suc n) 0ₖ))))
≡ (λ i → ΩKn+1→Kn (Kn→ΩKn+10ₖ (suc n) i ∙ Kn→ΩKn+1 (suc n) 0ₖ))
∙ (cong ΩKn+1→Kn (sym (lUnit (Kn→ΩKn+1 (suc n) 0ₖ))))
helper = ((λ j → lUnit (rUnit ((λ i → ΩKn+1→Kn (Kn→ΩKn+1 (suc n) 0ₖ ∙ Kn→ΩKn+10ₖ (suc n) i))) j) j
∙ rUnit (cong ΩKn+1→Kn (sym (rUnit (Kn→ΩKn+1 (suc n) 0ₖ)))) j)
∙∙ (λ j → ((λ z → ΩKn+1→Kn (Kn→ΩKn+1 (suc n) ∣ north ∣ ∙ (λ i → ∣ rCancel (merid north) (z ∧ j) i ∣)))
∙ (λ i → ΩKn+1→Kn (Kn→ΩKn+1 (suc n) 0ₖ ∙ Kn→ΩKn+10ₖ (suc n) (i ∨ j)))
∙ λ z → ΩKn+1→Kn (((λ i → ∣ rCancel (merid north) (z ∧ j) i ∣)) ∙ refl))
∙ cong ΩKn+1→Kn (sym (rUnit (Kn→ΩKn+10ₖ (suc n) j)))
∙ λ z → ΩKn+1→Kn (λ i → ∣ rCancel (merid north) ((~ z) ∧ j) i ∣))
∙∙ (λ j → (((λ z → ΩKn+1→Kn (Kn→ΩKn+1 (suc n) ∣ north ∣ ∙ (λ i → ∣ rCancel (merid north) z i ∣))))
∙ (λ i → ΩKn+1→Kn (Kn→ΩKn+1 (suc n) 0ₖ ∙ refl))
∙ λ z → ΩKn+1→Kn ((λ i → ∣ rCancel (merid north) z i ∣) ∙ λ i → ∣ rCancel (merid north) ((~ z) ∨ (~ j)) i ∣))
∙ cong ΩKn+1→Kn (sym (lUnit (Kn→ΩKn+10ₖ (suc n) (~ j))))
∙ λ z → ΩKn+1→Kn (λ i → ∣ rCancel (merid north) (~ z ∧ (~ j)) i ∣)))
∙∙ (λ j → ((λ z → ΩKn+1→Kn (Kn→ΩKn+1 (suc n) ∣ north ∣ ∙ λ i → ∣ rCancel (merid north) (z ∧ (~ j)) i ∣))
∙ (λ i → ΩKn+1→Kn (Kn→ΩKn+10ₖ (suc n) (i ∧ j) ∙ Kn→ΩKn+10ₖ (suc n) (~ j)))
∙ λ z → ΩKn+1→Kn ((λ i → ∣ rCancel (merid north) (z ∨ j) i ∣) ∙ λ i → ∣ rCancel (merid north) (~ z ∧ ~ j) i ∣))
∙ rUnit (cong ΩKn+1→Kn (sym (lUnit (Kn→ΩKn+1 (suc n) 0ₖ)))) (~ j))
∙∙ (λ j → lUnit (rUnit (λ i → ΩKn+1→Kn (Kn→ΩKn+10ₖ (suc n) i ∙ Kn→ΩKn+1 (suc n) 0ₖ)) (~ j)) (~ j)
∙ cong ΩKn+1→Kn (sym (lUnit (Kn→ΩKn+1 (suc n) 0ₖ))))
---- Group structure of reduced cohomology groups (in progress - might need K to compute properly first) ---
+ₕ∙ : {A : Pointed ℓ} (n : ℕ) → coHomRed n A → coHomRed n A → coHomRed n A
+ₕ∙ zero = sElim2 (λ _ _ → §) λ { (a , pa) (b , pb) → ∣ (λ x → a x +ₖ b x) , (λ i → (pa i +ₖ pb i)) ∣₂ }
+ₕ∙ (suc n) = sElim2 (λ _ _ → §) λ { (a , pa) (b , pb) → ∣ (λ x → a x +ₖ b x) , (λ i → pa i +ₖ pb i) ∙ lUnitₖ 0ₖ ∣₂ }
-ₕ∙ : {A : Pointed ℓ} (n : ℕ) → coHomRed n A → coHomRed n A
-ₕ∙ zero = sRec § λ {(a , pt) → ∣ (λ x → -ₖ a x ) , (λ i → -ₖ (pt i)) ∣₂}
-ₕ∙ (suc n) = sRec § λ {(a , pt) → ∣ (λ x → -ₖ a x ) , (λ i → -ₖ (pt i)) ∙
(λ i → ΩKn+1→Kn (sym (Kn→ΩKn+10ₖ (suc n) i))) ∙
(λ i → ΩKn+1→Kn (Kn→ΩKn+10ₖ (suc n) (~ i))) ∙
Iso.leftInv (Iso3-Kn-ΩKn+1 (suc n)) ∣ north ∣ ∣₂}
0ₕ∙ : {A : Pointed ℓ} (n : ℕ) → coHomRed n A
0ₕ∙ zero = ∣ (λ _ → 0ₖ) , refl ∣₂
0ₕ∙ (suc n) = ∣ (λ _ → 0ₖ) , refl ∣₂
open IsSemigroup
open IsMonoid
open Group
coHomGr : ∀ {ℓ} (n : ℕ) (A : Type ℓ) → Group
Carrier (coHomGr n A) = coHom n A
0g (coHomGr n A) = 0ₕ
Group._+_ (coHomGr n A) = _+ₕ_
Group.- coHomGr n A = -ₕ
is-set (isSemigroup (IsGroup.isMonoid (Group.isGroup (coHomGr n A)))) = §
IsSemigroup.assoc (isSemigroup (IsGroup.isMonoid (Group.isGroup (coHomGr n A)))) x y z = sym (assocₕ x y z)
identity (IsGroup.isMonoid (Group.isGroup (coHomGr n A))) x = (rUnitₕ x) , (lUnitₕ x)
IsGroup.inverse (Group.isGroup (coHomGr n A)) x = (rCancelₕ x) , (lCancelₕ x)
×coHomGr : (n : ℕ) (A : Type ℓ) (B : Type ℓ') → Group
×coHomGr n A B = dirProd (coHomGr n A) (coHomGr n B)
coHomFun : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} (n : ℕ) (f : A → B) → coHom n B → coHom n A
coHomFun n f = sRec § λ β → ∣ β ∘ f ∣₂
--- ΩKₙ is commutative
isCommΩK : (n : ℕ) → (p q : typ (Ω (coHomK n , coHom-pt n))) → p ∙ q ≡ q ∙ p
isCommΩK zero p q = isSetInt _ _ (p ∙ q) (q ∙ p)
isCommΩK (suc n) p q =
cong₂ _∙_ (sym (Iso.rightInv (Iso3-Kn-ΩKn+1 n) p))
(sym (Iso.rightInv (Iso3-Kn-ΩKn+1 n) q))
∙∙ (sym (Iso.rightInv (Iso3-Kn-ΩKn+1 n) (Kn→ΩKn+1 n (ΩKn+1→Kn p) ∙ Kn→ΩKn+1 n (ΩKn+1→Kn q)))
∙∙ cong (Kn→ΩKn+1 n) (commₖ (ΩKn+1→Kn p) (ΩKn+1→Kn q))
∙∙ Iso.rightInv (Iso3-Kn-ΩKn+1 n) (Kn→ΩKn+1 n (ΩKn+1→Kn q) ∙ Kn→ΩKn+1 n (ΩKn+1→Kn p)))
∙∙ sym (cong₂ _∙_ (sym (Iso.rightInv (Iso3-Kn-ΩKn+1 n) q))
(sym (Iso.rightInv (Iso3-Kn-ΩKn+1 n) p)))
--- the loopspace of Kₙ is commutative regardless of base
isCommΩK-based : (n : ℕ) (x : coHomK n) (p q : x ≡ x) → p ∙ q ≡ q ∙ p
isCommΩK-based zero x p q = isSetInt _ _ (p ∙ q) (q ∙ p)
isCommΩK-based (suc n) x p q =
sym (transport⁻Transport (typId x) (p ∙ q))
∙∙ (cong (transport (λ i → typId x (~ i))) (transpTypId p q)
∙∙ (λ i → transport (λ i → typId x (~ i)) (isCommΩK (suc n) (transport (λ i → typId x i) p) (transport (λ i → typId x i) q) i))
∙∙ cong (transport (λ i → typId x (~ i))) (sym (transpTypId q p)))
∙∙ transport⁻Transport (typId x) (q ∙ p)
where
congIsoHelper : (x : coHomK (suc n)) → Iso (coHomK (suc n)) (coHomK (suc n))
Iso.fun (congIsoHelper x) = _+ₖ x
Iso.inv (congIsoHelper x) = _+ₖ (-ₖ x)
Iso.rightInv (congIsoHelper x) a = assocₖ a (-ₖ x) x ∙∙ cong (a +ₖ_) (lCancelₖ x) ∙∙ rUnitₖ a
Iso.leftInv (congIsoHelper x) a = assocₖ a x (-ₖ x) ∙∙ cong (a +ₖ_) (rCancelₖ x) ∙∙ rUnitₖ a
typId : (x : coHomK (suc n)) → (x ≡ x) ≡ Path (coHomK (suc n)) 0ₖ 0ₖ
typId x = isoToPath (congIso (invIso (congIsoHelper x))) ∙ λ i → rCancelₖ x i ≡ rCancelₖ x i
transpTypId : (p q : (x ≡ x)) → transport (λ i → typId x i) (p ∙ q) ≡ transport (λ i → typId x i) p ∙ transport (λ i → typId x i) q
transpTypId p q =
((substComposite (λ x → x) (isoToPath ((congIso (invIso (congIsoHelper x)))))
(λ i → rCancelₖ x i ≡ rCancelₖ x i) (p ∙ q))
∙∙ (λ i → transport (λ i → rCancelₖ x i ≡ rCancelₖ x i) (transportRefl (congFunct (_+ₖ (-ₖ x)) p q i) i))
∙∙ overPathFunct (cong (_+ₖ (-ₖ x)) p) (cong (_+ₖ (-ₖ x)) q) (rCancelₖ x))
∙∙ cong₂ (λ y z → transport (λ i → rCancelₖ x i ≡ rCancelₖ x i) y ∙ transport (λ i → rCancelₖ x i ≡ rCancelₖ x i) z)
(sym (transportRefl (cong (_+ₖ (-ₖ x)) p)))
(sym (transportRefl (cong (_+ₖ (-ₖ x)) q)))
∙∙ cong₂ (_∙_) (sym (substComposite (λ x → x) (isoToPath ((congIso (invIso (congIsoHelper x))))) (λ i → rCancelₖ x i ≡ rCancelₖ x i) p))
(sym (substComposite (λ x → x) (isoToPath ((congIso (invIso (congIsoHelper x))))) (λ i → rCancelₖ x i ≡ rCancelₖ x i) q))
addLemma : (a b : Int) → a +ₖ b ≡ (a ℤ+ b)
addLemma a b = (cong ΩKn+1→Kn (sym (congFunct ∣_∣ (looper a) (looper b)))
∙∙ cong₂ (λ x y → ΩKn+1→Kn (cong ∣_∣ (x ∙ y))) (looper≡looper2 a) (looper≡looper2 b)
∙∙ (λ i → ΩKn+1→Kn (cong ∣_∣ (cong SuspBool→S1 (cong S¹→SuspBool (intLoop a)) ∙ cong SuspBool→S1 (cong S¹→SuspBool (intLoop b))))))
∙∙ (cong (λ x → ΩKn+1→Kn (cong ∣_∣ x)) (sym (congFunct SuspBool→S1 (cong S¹→SuspBool (intLoop a)) (cong S¹→SuspBool (intLoop b))))
∙∙ cong (λ x → ΩKn+1→Kn (cong ∣_∣ (cong SuspBool→S1 x))) (sym (congFunct S¹→SuspBool (intLoop a) (intLoop b)))
∙∙ cong (λ x → ΩKn+1→Kn (cong ∣_∣ (cong SuspBool→S1 (cong S¹→SuspBool x)))) (intLoop-hom a b))
∙∙ (cong (λ x → ΩKn+1→Kn (cong ∣_∣ x)) (sym (looper≡looper2 (a ℤ+ b)))
∙ Iso.leftInv (Iso3-Kn-ΩKn+1 zero) (a ℤ+ b))
| {
"alphanum_fraction": 0.5080413069,
"avg_line_length": 51.2167630058,
"ext": "agda",
"hexsha": "36cccdbda218f72e3974757c2c8ab33dcb71c52e",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "knrafto/cubical",
"max_forks_repo_path": "Cubical/ZCohomology/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "knrafto/cubical",
"max_issues_repo_path": "Cubical/ZCohomology/Properties.agda",
"max_line_length": 183,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "f6771617374bfe65a7043d00731fed5a673aa729",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "knrafto/cubical",
"max_stars_repo_path": "Cubical/ZCohomology/Properties.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 8425,
"size": 17721
} |
{-# OPTIONS --warning=error #-}
-- Useless private
module Issue476a where
A : Set₁
private
A = Set
| {
"alphanum_fraction": 0.6634615385,
"avg_line_length": 10.4,
"ext": "agda",
"hexsha": "9ee9cf422b36624d4935eb1aa07a041e8658f085",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Fail/Issue476a.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Fail/Issue476a.agda",
"max_line_length": 31,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Fail/Issue476a.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": 30,
"size": 104
} |
open import Relation.Binary.Core
module BBHeap.Push {A : Set}
(_≤_ : A → A → Set)
(tot≤ : Total _≤_)
(trans≤ : Transitive _≤_) where
open import BBHeap _≤_
open import BBHeap.Equality _≤_
open import BBHeap.Equality.Properties _≤_
open import Bound.Lower A
open import Bound.Lower.Order _≤_
open import Bound.Lower.Order.Properties _≤_ trans≤
open import Data.Sum renaming (_⊎_ to _∨_)
open import Order.Total _≤_ tot≤
mutual
push⋘ : {b : Bound}{x y : A}{l r : BBHeap (val y)} → LeB b (val x) → LeB b (val y) → l ⋘ r → BBHeap b
push⋘ b≤x _ lf⋘ = left b≤x lf⋘
push⋘ {x = x} b≤x b≤y (ll⋘ {x = y₁} {x' = y₂} y≤y₁ y≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂)
with tot≤ y₁ y₂ | tot≤ x y₁ | tot≤ x y₂
... | inj₁ y₁≤y₂ | inj₁ x≤y₁ | _ = left b≤x (ll⋘ (lexy x≤y₁) (lexy (trans≤ x≤y₁ y₁≤y₂)) l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂)
... | inj₁ y₁≤y₂ | inj₂ y₁≤x | _ =
let pl'≈l' = lemma-push⋘ (lexy y₁≤x) (lexy refl≤) l₁⋘r₁ ;
l'⋘r' = ll⋘ (lexy refl≤) (lexy y₁≤y₂) l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ ;
pl'⋘r' = lemma≈⋘ pl'≈l' l'⋘r'
in left (transLeB b≤y y≤y₁) pl'⋘r'
... | inj₂ y₂≤y₁ | _ | inj₁ x≤y₂ = left b≤x (ll⋘ (lexy (trans≤ x≤y₂ y₂≤y₁)) (lexy x≤y₂) l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂)
... | inj₂ y₂≤y₁ | _ | inj₂ y₂≤x =
let pr'≈r' = lemma-push⋘ (lexy y₂≤x) (lexy refl≤) l₂⋘r₂ ;
r'≈pr' = sym≈ pr'≈r' ;
l'⋘r' = ll⋘ (lexy y₂≤y₁) (lexy refl≤) l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ ;
l'⋘pr' = lemma⋘≈ l'⋘r' r'≈pr'
in left (transLeB b≤y y≤y₂) l'⋘pr'
push⋘ {x = x} b≤x b≤y (lr⋘ {x = y₁} {x' = y₂} y≤y₁ y≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂)
with tot≤ y₁ y₂ | tot≤ x y₁ | tot≤ x y₂
... | inj₁ y₁≤y₂ | inj₁ x≤y₁ | _ = left b≤x (lr⋘ (lexy x≤y₁) (lexy (trans≤ x≤y₁ y₁≤y₂)) l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂)
... | inj₁ y₁≤y₂ | inj₂ y₁≤x | _ =
let pl'≈l' = lemma-push⋙ (lexy y₁≤x) (lexy refl≤) l₁⋙r₁ ;
l'⋘r' = lr⋘ (lexy refl≤) (lexy y₁≤y₂) l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂ ;
pl'⋘r' = lemma≈⋘ pl'≈l' l'⋘r'
in left (transLeB b≤y y≤y₁) pl'⋘r'
... | inj₂ y₂≤y₁ | _ | inj₁ x≤y₂ = left b≤x (lr⋘ (lexy (trans≤ x≤y₂ y₂≤y₁)) (lexy x≤y₂) l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂)
... | inj₂ y₂≤y₁ | _ | inj₂ y₂≤x =
let pr'≈r' = lemma-push⋘ (lexy y₂≤x) (lexy refl≤) l₂⋘r₂ ;
r'≈pr' = sym≈ pr'≈r' ;
l'⋘r' = lr⋘ (lexy y₂≤y₁) (lexy refl≤) l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂ ;
l'⋘pr' = lemma⋘≈ l'⋘r' r'≈pr'
in left (transLeB b≤y y≤y₂) l'⋘pr'
push⋙ : {b : Bound}{x y : A}{l r : BBHeap (val y)} → LeB b (val x) → LeB b (val y) → l ⋙ r → BBHeap b
push⋙ {x = x} b≤x b≤y (⋙lf {x = z} y≤z)
with tot≤ x z
... | inj₁ x≤z = right b≤x (⋙lf (lexy x≤z))
... | inj₂ z≤x = right (transLeB b≤y y≤z) (⋙lf (lexy z≤x))
push⋙ {x = x} b≤x b≤y (⋙rl {x = y₁} {x' = y₂} y≤y₁ y≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂)
with tot≤ y₁ y₂ | tot≤ x y₁ | tot≤ x y₂
... | inj₁ y₁≤y₂ | inj₁ x≤y₁ | _ = right b≤x (⋙rl (lexy x≤y₁) (lexy (trans≤ x≤y₁ y₁≤y₂)) l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂)
... | inj₁ y₁≤y₂ | inj₂ y₁≤x | _ =
let pl'≈l' = lemma-push⋘ (lexy y₁≤x) (lexy refl≤) l₁⋘r₁ ;
l'⋙r' = ⋙rl (lexy refl≤) (lexy y₁≤y₂) l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂ ;
pl'⋙r' = lemma≈⋙ pl'≈l' l'⋙r'
in right (transLeB b≤y y≤y₁) pl'⋙r'
... | inj₂ y₂≤y₁ | _ | inj₁ x≤y₂ = right b≤x (⋙rl (lexy (trans≤ x≤y₂ y₂≤y₁)) (lexy x≤y₂) l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂)
... | inj₂ y₂≤y₁ | _ | inj₂ y₂≤x =
let pr'≈r' = lemma-push⋘ (lexy y₂≤x) (lexy refl≤) l₂⋘r₂ ;
r'≈pr' = sym≈ pr'≈r' ;
l'⋙r' = ⋙rl (lexy y₂≤y₁) (lexy refl≤) l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂ ;
l'⋙pr' = lemma⋙≈ l'⋙r' r'≈pr'
in right (transLeB b≤y y≤y₂) l'⋙pr'
push⋙ {x = x} b≤x b≤y (⋙rr {x = y₁} {x' = y₂} y≤y₁ y≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂)
with tot≤ y₁ y₂ | tot≤ x y₁ | tot≤ x y₂
... | inj₁ y₁≤y₂ | inj₁ x≤y₁ | _ = right b≤x (⋙rr (lexy x≤y₁) (lexy (trans≤ x≤y₁ y₁≤y₂)) l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂)
... | inj₁ y₁≤y₂ | inj₂ y₁≤x | _ =
let pl'≈l' = lemma-push⋘ (lexy y₁≤x) (lexy refl≤) l₁⋘r₁ ;
l'⋙r' = ⋙rr (lexy refl≤) (lexy y₁≤y₂) l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂ ;
pl'⋙r' = lemma≈⋙ pl'≈l' l'⋙r'
in right (transLeB b≤y y≤y₁) pl'⋙r'
... | inj₂ y₂≤y₁ | _ | inj₁ x≤y₂ = right b≤x (⋙rr (lexy (trans≤ x≤y₂ y₂≤y₁)) (lexy x≤y₂) l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂)
... | inj₂ y₂≤y₁ | _ | inj₂ y₂≤x =
let pr'≈r' = lemma-push⋙ (lexy y₂≤x) (lexy refl≤) l₂⋙r₂ ;
r'≈pr' = sym≈ pr'≈r' ;
l'⋙r' = ⋙rr (lexy y₂≤y₁) (lexy refl≤) l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂ ;
l'⋙pr' = lemma⋙≈ l'⋙r' r'≈pr'
in right (transLeB b≤y y≤y₂) l'⋙pr'
lemma-push⋘ : {b : Bound}{x y : A}{l r : BBHeap (val y)}(b≤x : LeB b (val x))(b≤y : LeB b (val y))(l⋘r : l ⋘ r) → push⋘ b≤x b≤y l⋘r ≈ left b≤y l⋘r
lemma-push⋘ b≤x b≤y lf⋘ = ≈left b≤x b≤y lf⋘ lf⋘ ≈leaf ≈leaf
lemma-push⋘ {x = x} b≤x b≤y (ll⋘ {x = y₁} {x' = y₂} y≤y₁ y≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂)
with tot≤ y₁ y₂ | tot≤ x y₁ | tot≤ x y₂
... | inj₁ y₁≤y₂ | inj₁ x≤y₁ | _ =
let l⋘r = ll⋘ y≤y₁ y≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ ;
x≤y₂ = lexy (trans≤ x≤y₁ y₁≤y₂) ;
l'⋘r' = ll⋘ (lexy x≤y₁) x≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ ;
l'≈l = ≈left (lexy x≤y₁) y≤y₁ l₁⋘r₁ l₁⋘r₁ refl≈ refl≈ ;
r'≈r = ≈left x≤y₂ y≤y₂ l₂⋘r₂ l₂⋘r₂ refl≈ refl≈
in ≈left b≤x b≤y l'⋘r' l⋘r l'≈l r'≈r
... | inj₁ y₁≤y₂ | inj₂ y₁≤x | _ =
let l⋘r = ll⋘ y≤y₁ y≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ ;
pl'≈l' = lemma-push⋘ (lexy y₁≤x) (lexy refl≤) l₁⋘r₁ ;
l'⋘r' = ll⋘ (lexy refl≤) (lexy y₁≤y₂) l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ ;
pl'⋘r' = lemma≈⋘ pl'≈l' l'⋘r' ;
l'≈l = ≈left (lexy refl≤) y≤y₁ l₁⋘r₁ l₁⋘r₁ refl≈ refl≈ ;
pl'≈l = trans≈ pl'≈l' l'≈l ;
r'≈r = ≈left (lexy y₁≤y₂) y≤y₂ l₂⋘r₂ l₂⋘r₂ refl≈ refl≈
in ≈left (transLeB b≤y y≤y₁) b≤y pl'⋘r' l⋘r pl'≈l r'≈r
... | inj₂ y₂≤y₁ | _ | inj₁ x≤y₂ =
let l⋘r = ll⋘ y≤y₁ y≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ ;
x≤y₁ = lexy (trans≤ x≤y₂ y₂≤y₁) ;
l'⋘r' = ll⋘ x≤y₁ (lexy x≤y₂) l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ ;
r'≈r = ≈left (lexy x≤y₂) y≤y₂ l₂⋘r₂ l₂⋘r₂ refl≈ refl≈ ;
l'≈l = ≈left x≤y₁ y≤y₁ l₁⋘r₁ l₁⋘r₁ refl≈ refl≈
in ≈left b≤x b≤y l'⋘r' l⋘r l'≈l r'≈r
... | inj₂ y₂≤y₁ | _ | inj₂ y₂≤x =
let l⋘r = ll⋘ y≤y₁ y≤y₂ l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ ;
pr'≈r' = lemma-push⋘ (lexy y₂≤x) (lexy refl≤) l₂⋘r₂ ;
r'≈pr' = sym≈ pr'≈r' ;
l'⋘r' = ll⋘ (lexy y₂≤y₁) (lexy refl≤) l₁⋘r₁ l₂⋘r₂ l₂≃r₂ r₁≃l₂ ;
l'⋘pr' = lemma⋘≈ l'⋘r' r'≈pr' ;
r'≈r = ≈left (lexy refl≤) y≤y₂ l₂⋘r₂ l₂⋘r₂ refl≈ refl≈ ;
pr'≈r = trans≈ pr'≈r' r'≈r ;
l'≈l = ≈left (lexy y₂≤y₁) y≤y₁ l₁⋘r₁ l₁⋘r₁ refl≈ refl≈
in ≈left (transLeB b≤y y≤y₂) b≤y l'⋘pr' l⋘r l'≈l pr'≈r
lemma-push⋘ {x = x} b≤x b≤y (lr⋘ {x = y₁} {x' = y₂} y≤y₁ y≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂)
with tot≤ y₁ y₂ | tot≤ x y₁ | tot≤ x y₂
... | inj₁ y₁≤y₂ | inj₁ x≤y₁ | _ =
let l⋘r = lr⋘ y≤y₁ y≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂ ;
x≤y₂ = lexy (trans≤ x≤y₁ y₁≤y₂) ;
l'⋘r' = lr⋘ (lexy x≤y₁) x≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂ ;
l'≈l = ≈right (lexy x≤y₁) y≤y₁ l₁⋙r₁ l₁⋙r₁ refl≈ refl≈ ;
r'≈r = ≈left x≤y₂ y≤y₂ l₂⋘r₂ l₂⋘r₂ refl≈ refl≈
in ≈left b≤x b≤y l'⋘r' l⋘r l'≈l r'≈r
... | inj₁ y₁≤y₂ | inj₂ y₁≤x | _ =
let l⋘r = lr⋘ y≤y₁ y≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂ ;
pl'≈l' = lemma-push⋙ (lexy y₁≤x) (lexy refl≤) l₁⋙r₁ ;
l'⋘r' = lr⋘ (lexy refl≤) (lexy y₁≤y₂) l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂ ;
pl'⋘r' = lemma≈⋘ pl'≈l' l'⋘r' ;
l'≈l = ≈right (lexy refl≤) y≤y₁ l₁⋙r₁ l₁⋙r₁ refl≈ refl≈ ;
pl'≈l = trans≈ pl'≈l' l'≈l ;
r'≈r = ≈left (lexy y₁≤y₂) y≤y₂ l₂⋘r₂ l₂⋘r₂ refl≈ refl≈
in ≈left (transLeB b≤y y≤y₁) b≤y pl'⋘r' l⋘r pl'≈l r'≈r
... | inj₂ y₂≤y₁ | _ | inj₁ x≤y₂ =
let l⋘r = lr⋘ y≤y₁ y≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂ ;
x≤y₁ = lexy (trans≤ x≤y₂ y₂≤y₁) ;
l'⋘r' = lr⋘ x≤y₁ (lexy x≤y₂) l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂ ;
l'≈l = ≈right x≤y₁ y≤y₁ l₁⋙r₁ l₁⋙r₁ refl≈ refl≈ ;
r'≈r = ≈left (lexy x≤y₂) y≤y₂ l₂⋘r₂ l₂⋘r₂ refl≈ refl≈
in ≈left b≤x b≤y l'⋘r' l⋘r l'≈l r'≈r
... | inj₂ y₂≤y₁ | _ | inj₂ y₂≤x =
let l⋘r = lr⋘ y≤y₁ y≤y₂ l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂ ;
pr'≈r' = lemma-push⋘ (lexy y₂≤x) (lexy refl≤) l₂⋘r₂ ;
r'≈pr' = sym≈ pr'≈r' ;
l'⋘r' = lr⋘ (lexy y₂≤y₁) (lexy refl≤) l₁⋙r₁ l₂⋘r₂ l₂≃r₂ l₁⋗l₂ ;
l'⋘pr' = lemma⋘≈ l'⋘r' r'≈pr' ;
l'≈l = ≈right (lexy y₂≤y₁) y≤y₁ l₁⋙r₁ l₁⋙r₁ refl≈ refl≈ ;
r'≈r = ≈left (lexy refl≤) y≤y₂ l₂⋘r₂ l₂⋘r₂ refl≈ refl≈ ;
pr'≈r = trans≈ pr'≈r' r'≈r
in ≈left (transLeB b≤y y≤y₂) b≤y l'⋘pr' l⋘r l'≈l pr'≈r
lemma-push⋙ : {b : Bound}{x y : A}{l r : BBHeap (val y)}(b≤x : LeB b (val x))(b≤y : LeB b (val y))(l⋙r : l ⋙ r) → push⋙ b≤x b≤y l⋙r ≈ right b≤y l⋙r
lemma-push⋙ {x = x} b≤x b≤y (⋙lf {x = z} y≤z)
with tot≤ x z
... | inj₁ x≤z = ≈right b≤x b≤y (⋙lf (lexy x≤z)) (⋙lf y≤z) (≈left (lexy x≤z) y≤z lf⋘ lf⋘ ≈leaf ≈leaf) ≈leaf
... | inj₂ z≤x = ≈right (transLeB b≤y y≤z) b≤y (⋙lf (lexy z≤x)) (⋙lf y≤z) (≈left (lexy z≤x) y≤z lf⋘ lf⋘ ≈leaf ≈leaf) ≈leaf
lemma-push⋙ {x = x} b≤x b≤y (⋙rl {x = y₁} {x' = y₂} y≤y₁ y≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂)
with tot≤ y₁ y₂ | tot≤ x y₁ | tot≤ x y₂
... | inj₁ y₁≤y₂ | inj₁ x≤y₁ | _ =
let l⋙r = ⋙rl y≤y₁ y≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂ ;
x≤y₂ = lexy (trans≤ x≤y₁ y₁≤y₂) ;
l'⋙r' = ⋙rl (lexy x≤y₁) x≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂ ;
l'≈l = ≈left (lexy x≤y₁) y≤y₁ l₁⋘r₁ l₁⋘r₁ refl≈ refl≈ ;
r'≈r = ≈left x≤y₂ y≤y₂ l₂⋘r₂ l₂⋘r₂ refl≈ refl≈
in ≈right b≤x b≤y l'⋙r' l⋙r l'≈l r'≈r
... | inj₁ y₁≤y₂ | inj₂ y₁≤x | _ =
let l⋙r = ⋙rl y≤y₁ y≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂ ;
pl'≈l' = lemma-push⋘ (lexy y₁≤x) (lexy refl≤) l₁⋘r₁ ;
l'⋙r' = ⋙rl (lexy refl≤) (lexy y₁≤y₂) l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂ ;
pl'⋙r' = lemma≈⋙ pl'≈l' l'⋙r' ;
l'≈l = ≈left (lexy refl≤) y≤y₁ l₁⋘r₁ l₁⋘r₁ refl≈ refl≈ ;
pl'≈l = trans≈ pl'≈l' l'≈l ;
r'≈r = ≈left (lexy y₁≤y₂) y≤y₂ l₂⋘r₂ l₂⋘r₂ refl≈ refl≈
in ≈right (transLeB b≤y y≤y₁) b≤y pl'⋙r' l⋙r pl'≈l r'≈r
... | inj₂ y₂≤y₁ | _ | inj₁ x≤y₂ =
let l⋙r = ⋙rl y≤y₁ y≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂ ;
x≤y₁ = lexy (trans≤ x≤y₂ y₂≤y₁) ;
l'⋙r' = ⋙rl x≤y₁ (lexy x≤y₂) l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂ ;
l'≈l = ≈left x≤y₁ y≤y₁ l₁⋘r₁ l₁⋘r₁ refl≈ refl≈ ;
r'≈r = ≈left (lexy x≤y₂) y≤y₂ l₂⋘r₂ l₂⋘r₂ refl≈ refl≈
in ≈right b≤x b≤y l'⋙r' l⋙r l'≈l r'≈r
... | inj₂ y₂≤y₁ | _ | inj₂ y₂≤x =
let l⋙r = ⋙rl y≤y₁ y≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂ ;
pr'≈r' = lemma-push⋘ (lexy y₂≤x) (lexy refl≤) l₂⋘r₂ ;
r'≈pr' = sym≈ pr'≈r' ;
l'⋙r' = ⋙rl (lexy y₂≤y₁) (lexy refl≤) l₁⋘r₁ l₁≃r₁ l₂⋘r₂ l₁⋗r₂ ;
l'⋙pr' = lemma⋙≈ l'⋙r' r'≈pr' ;
l'≈l = ≈left (lexy y₂≤y₁) y≤y₁ l₁⋘r₁ l₁⋘r₁ refl≈ refl≈ ;
r'≈r = ≈left (lexy refl≤) y≤y₂ l₂⋘r₂ l₂⋘r₂ refl≈ refl≈ ;
pr'≈r = trans≈ pr'≈r' r'≈r
in ≈right (transLeB b≤y y≤y₂) b≤y l'⋙pr' l⋙r l'≈l pr'≈r
lemma-push⋙ {x = x} b≤x b≤y (⋙rr {x = y₁} {x' = y₂} y≤y₁ y≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂)
with tot≤ y₁ y₂ | tot≤ x y₁ | tot≤ x y₂
... | inj₁ y₁≤y₂ | inj₁ x≤y₁ | _ =
let l⋙r = ⋙rr y≤y₁ y≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂ ;
x≤y₂ = lexy (trans≤ x≤y₁ y₁≤y₂) ;
l'⋙r' = ⋙rr (lexy x≤y₁) x≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂ ;
l'≈l = ≈left (lexy x≤y₁) y≤y₁ l₁⋘r₁ l₁⋘r₁ refl≈ refl≈ ;
r'≈r = ≈right x≤y₂ y≤y₂ l₂⋙r₂ l₂⋙r₂ refl≈ refl≈
in ≈right b≤x b≤y l'⋙r' l⋙r l'≈l r'≈r
... | inj₁ y₁≤y₂ | inj₂ y₁≤x | _ =
let l⋙r = ⋙rr y≤y₁ y≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂ ;
pl'≈l' = lemma-push⋘ (lexy y₁≤x) (lexy refl≤) l₁⋘r₁ ;
l'⋙r' = ⋙rr (lexy refl≤) (lexy y₁≤y₂) l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂ ;
pl'⋙r' = lemma≈⋙ pl'≈l' l'⋙r' ;
l'≈l = ≈left (lexy refl≤) y≤y₁ l₁⋘r₁ l₁⋘r₁ refl≈ refl≈ ;
pl'≈l = trans≈ pl'≈l' l'≈l ;
r'≈r = ≈right (lexy y₁≤y₂) y≤y₂ l₂⋙r₂ l₂⋙r₂ refl≈ refl≈
in ≈right (transLeB b≤y y≤y₁) b≤y pl'⋙r' l⋙r pl'≈l r'≈r
... | inj₂ y₂≤y₁ | _ | inj₁ x≤y₂ =
let l⋙r = ⋙rr y≤y₁ y≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂ ;
x≤y₁ = lexy (trans≤ x≤y₂ y₂≤y₁) ;
l'⋙r' = ⋙rr x≤y₁ (lexy x≤y₂) l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂ ;
l'≈l = ≈left x≤y₁ y≤y₁ l₁⋘r₁ l₁⋘r₁ refl≈ refl≈ ;
r'≈r = ≈right (lexy x≤y₂) y≤y₂ l₂⋙r₂ l₂⋙r₂ refl≈ refl≈
in ≈right b≤x b≤y l'⋙r' l⋙r l'≈l r'≈r
... | inj₂ y₂≤y₁ | _ | inj₂ y₂≤x =
let l⋙r = ⋙rr y≤y₁ y≤y₂ l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂ ;
pr'≈r' = lemma-push⋙ (lexy y₂≤x) (lexy refl≤) l₂⋙r₂ ;
r'≈pr' = sym≈ pr'≈r' ;
l'⋙r' = ⋙rr (lexy y₂≤y₁) (lexy refl≤) l₁⋘r₁ l₁≃r₁ l₂⋙r₂ l₁≃l₂ ;
l'⋙pr' = lemma⋙≈ l'⋙r' r'≈pr' ;
l'≈l = ≈left (lexy y₂≤y₁) y≤y₁ l₁⋘r₁ l₁⋘r₁ refl≈ refl≈ ;
r'≈r = ≈right (lexy refl≤) y≤y₂ l₂⋙r₂ l₂⋙r₂ refl≈ refl≈ ;
pr'≈r = trans≈ pr'≈r' r'≈r
in ≈right (transLeB b≤y y≤y₂) b≤y l'⋙pr' l⋙r l'≈l pr'≈r
push : {b : Bound}{x : A} → LeB b (val x) → BBHeap b → BBHeap b
push _ leaf = leaf
push b≤x (left b≤y l⋘r) = push⋘ b≤x b≤y l⋘r
push b≤x (right b≤y l⋙r) = push⋙ b≤x b≤y l⋙r
| {
"alphanum_fraction": 0.415586991,
"avg_line_length": 63.0333333333,
"ext": "agda",
"hexsha": "54e36cfef89235c2980b367681e943dbddef9c94",
"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/BBHeap/Push.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/BBHeap/Push.agda",
"max_line_length": 149,
"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/BBHeap/Push.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": 8925,
"size": 15128
} |
{-# OPTIONS --allow-unsolved-metas #-}
module Problem where
open import OscarPrelude
open import Sequent
infix 13 _¶_
record Problem : Set
where
constructor _¶_
field
inferences : List Sequent
interest : Sequent
open Problem public
instance EqProblem : Eq Problem
EqProblem = {!!}
open import 𝓐ssertion
instance 𝓐ssertionProblem : 𝓐ssertion Problem
𝓐ssertionProblem = record {}
open import HasSatisfaction
instance HasSatisfactionProblem : HasSatisfaction Problem
HasSatisfaction._⊨_ HasSatisfactionProblem I (Φ⁺s ¶ Φ⁻) = I ⊨ Φ⁺s → I ⊨ Φ⁻
open import HasDecidableValidation
instance HasDecidableValidationProblem : HasDecidableValidation Problem
HasDecidableValidationProblem = {!!}
open import HasSubstantiveDischarge
instance HasSubstantiveDischargeProblemProblem : HasSubstantiveDischarge Problem Problem
HasSubstantiveDischarge._≽_ HasSubstantiveDischargeProblemProblem (+s ¶ +) (-s ¶ -) = {!!} -- + ≽ - × +s ≽ -s
open import HasDecidableSubstantiveDischarge
instance HasDecidableSubstantiveDischargeProblemProblem : HasDecidableSubstantiveDischarge Problem Problem
HasDecidableSubstantiveDischarge._≽?_ HasDecidableSubstantiveDischargeProblemProblem = {!!}
| {
"alphanum_fraction": 0.8023549201,
"avg_line_length": 27.0227272727,
"ext": "agda",
"hexsha": "b9045b986309fc9793c2a2aa06d89e38186ea9b9",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-1/Problem.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-1/Problem.agda",
"max_line_length": 109,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-1/Problem.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 333,
"size": 1189
} |
-- Andreas, 2015-06-29 constructors should be covariant.
-- They are already treated as strictly positive in the positivity checker.
-- {-# OPTIONS -v tc.polarity:20 -v tc.proj.like:10 #-}
-- {-# OPTIONS -v tc.conv.elim:25 -v tc.conv.atom:30 -v tc.conv.term:30 --show-implicit #-}
open import Common.Size
open import Common.Product
-- U (i : contravariant)
record U (i : Size) : Set where
coinductive
field out : (j : Size< i) → U j
record Tup (P : Set × Set) : Set where
constructor tup
field
fst : proj₁ P
snd : proj₂ P
Dup : Set → Set
Dup X = Tup (X , X)
-- This is accepted, as constructors are taken as monotone.
data D : Set where
c : Dup D → D
fine : ∀{i} → Dup (U ∞) → Dup (U i)
fine (tup x y) = tup x y
-- This should also be accepted.
-- (Additionally, it is the η-short form of fine.)
cast : ∀{i} → Dup (U ∞) → Dup (U i)
cast x = x
| {
"alphanum_fraction": 0.6352128884,
"avg_line_length": 24.8285714286,
"ext": "agda",
"hexsha": "5d505962f94fec13956783dbdb2ffaa96ba5df8c",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "test/Succeed/CovariantConstructors.agda",
"max_issues_count": 3,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2019-04-01T19:39:26.000Z",
"max_issues_repo_issues_event_min_datetime": "2018-11-14T15:31:44.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "test/Succeed/CovariantConstructors.agda",
"max_line_length": 91,
"max_stars_count": 3,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "test/Succeed/CovariantConstructors.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": 281,
"size": 869
} |
{-# OPTIONS --copatterns #-}
module Copatterns where
open import Common.Equality
record _×_ (A B : Set) : Set where
constructor _,_
field
fst : A
snd : B
open _×_
pair : {A B : Set} → A → B → A × B
fst (pair a b) = a
snd (pair a b) = b
swap : {A B : Set} → A × B → B × A
fst (swap p) = snd p
snd (swap p) = fst p
swap3 : {A B C : Set} → A × (B × C) → C × (B × A)
fst (swap3 t) = snd (snd t)
fst (snd (swap3 t)) = fst (snd t)
snd (snd (swap3 t)) = fst t
-- should also work if we shuffle the clauses
swap4 : {A B C D : Set} → A × (B × (C × D)) → D × (C × (B × A))
fst (snd (swap4 t)) = fst (snd (snd t))
snd (snd (snd (swap4 t))) = fst t
fst (swap4 t) = snd (snd (snd t))
fst (snd (snd (swap4 t))) = fst (snd t)
-- State monad example
record State (S A : Set) : Set where
constructor state
field
runState : S → A × S
open State
record Monad (M : Set → Set) : Set1 where
constructor monad
field
return : {A : Set} → A → M A
_>>=_ : {A B : Set} → M A → (A → M B) → M B
open Monad {{...}}
stateMonad : {S : Set} → Monad (State S)
runState (return {{stateMonad}} a ) s = a , s
runState (_>>=_ {{stateMonad}} m k) s₀ =
let a , s₁ = runState m s₀
in runState (k a) s₁
leftId : {A B S : Set}(a : A)(k : A → State S B) → (return a >>= k) ≡ k a
leftId a k = refl
rightId : {A B S : Set}(m : State S A) → (m >>= return) ≡ m
rightId m = refl
assoc : {A B C S : Set}(m : State S A)(k : A → State S B)(l : B → State S C) →
((m >>= k) >>= l) ≡ (m >>= λ a → k a >>= l)
assoc m k l = refl
-- multiple clauses with abstractions
fswap3 : {A B C X : Set} → (X → A) × ((X → B) × C) → (X → C) × (X → (B × A))
fst (fswap3 t) x = snd (snd t)
fst (snd (fswap3 t) y) = fst (snd t) y
snd (snd (fswap3 t) z) = fst t z
| {
"alphanum_fraction": 0.5173961841,
"avg_line_length": 25.0985915493,
"ext": "agda",
"hexsha": "e135b64a1e96f81583b7e8db60939ce646ce19e1",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "np/agda-git-experiment",
"max_forks_repo_path": "test/succeed/Copatterns.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "np/agda-git-experiment",
"max_issues_repo_path": "test/succeed/Copatterns.agda",
"max_line_length": 78,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "20596e9dd9867166a64470dd24ea68925ff380ce",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "np/agda-git-experiment",
"max_stars_repo_path": "test/succeed/Copatterns.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": 708,
"size": 1782
} |
{-# OPTIONS --universe-polymorphism #-}
module TrustMe where
open import Common.Equality
postulate
A : Set
x y : A
eq : x ≡ y
eq = primTrustMe
does-not-evaluate-to-refl : sym (sym eq) ≡ eq
does-not-evaluate-to-refl = refl
| {
"alphanum_fraction": 0.678111588,
"avg_line_length": 14.5625,
"ext": "agda",
"hexsha": "73388631b38ef84626e47aa947d6ba6d8dde9ff5",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_forks_event_min_datetime": "2019-03-05T20:02:38.000Z",
"max_forks_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/Fail/TrustMe.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "alhassy/agda",
"max_issues_repo_path": "test/Fail/TrustMe.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/Fail/TrustMe.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": 75,
"size": 233
} |
{-# OPTIONS --allow-unsolved-metas #-}
module TermCode where
open import OscarPrelude
open import VariableName
open import FunctionName
open import Arity
open import Term
open import Vector
data TermCode : Set
where
variable : VariableName → TermCode
function : FunctionName → Arity → TermCode
termCode-function-inj₁ : ∀ {𝑓₁ 𝑓₂ arity₁ arity₂} → TermCode.function 𝑓₁ arity₁ ≡ function 𝑓₂ arity₂ → 𝑓₁ ≡ 𝑓₂
termCode-function-inj₁ refl = refl
termCode-function-inj₂ : ∀ {𝑓₁ 𝑓₂ arity₁ arity₂} → TermCode.function 𝑓₁ arity₁ ≡ function 𝑓₂ arity₂ → arity₁ ≡ arity₂
termCode-function-inj₂ refl = refl
instance
EqTermCode : Eq TermCode
Eq._==_ EqTermCode (variable 𝑥₁) (variable 𝑥₂) with 𝑥₁ ≟ 𝑥₂
… | yes 𝑥₁≡𝑥₂ rewrite 𝑥₁≡𝑥₂ = yes refl
… | no 𝑥₁≢𝑥₂ = no (λ { refl → 𝑥₁≢𝑥₂ refl})
Eq._==_ EqTermCode (variable x) (function x₁ x₂) = no (λ ())
Eq._==_ EqTermCode (function x x₁) (variable x₂) = no (λ ())
Eq._==_ EqTermCode (function 𝑓₁ 𝑎₁) (function 𝑓₂ 𝑎₂) = decEq₂ termCode-function-inj₁ termCode-function-inj₂ (𝑓₁ ≟ 𝑓₂) (𝑎₁ ≟ 𝑎₂)
mutual
encodeTerm : Term → List TermCode
encodeTerm (variable 𝑥) = variable 𝑥 ∷ []
encodeTerm (function 𝑓 (⟨_⟩ {arity} τs)) = function 𝑓 arity ∷ encodeTerms τs
encodeTerms : {arity : Arity} → Vector Term arity → List TermCode
encodeTerms ⟨ [] ⟩ = []
encodeTerms ⟨ τ ∷ τs ⟩ = encodeTerm τ ++ encodeTerms ⟨ τs ⟩
mutual
decodeTerm : Nat → StateT (List TermCode) Maybe Term
decodeTerm zero = lift nothing
decodeTerm (suc n) = do
caseM get of λ
{ [] → lift nothing
; (variable 𝑥 ∷ _) →
modify (drop 1) ~|
return (variable 𝑥)
; (function 𝑓 arity ∷ _) →
modify (drop 1) ~|
decodeFunction n 𝑓 arity }
decodeFunction : Nat → FunctionName → Arity → StateT (List TermCode) Maybe Term
decodeFunction n 𝑓 arity = do
τs ← decodeTerms n arity -|
return (function 𝑓 ⟨ τs ⟩)
decodeTerms : Nat → (arity : Arity) → StateT (List TermCode) Maybe (Vector Term arity)
decodeTerms n ⟨ zero ⟩ = return ⟨ [] ⟩
decodeTerms n ⟨ suc arity ⟩ = do
τ ← decodeTerm n -|
τs ← decodeTerms n ⟨ arity ⟩ -|
return ⟨ τ ∷ vector τs ⟩
.decode-is-inverse-of-encode : ∀ τ → runStateT (decodeTerm ∘ length $ encodeTerm τ) (encodeTerm τ) ≡ (just $ τ , [])
decode-is-inverse-of-encode (variable 𝑥) = refl
decode-is-inverse-of-encode (function 𝑓 ⟨ ⟨ [] ⟩ ⟩) = {!!}
decode-is-inverse-of-encode (function 𝑓 ⟨ ⟨ variable 𝑥 ∷ τs ⟩ ⟩) = {!!}
decode-is-inverse-of-encode (function 𝑓 ⟨ ⟨ function 𝑓' τs' ∷ τs ⟩ ⟩) = {!!}
module ExampleEncodeDecode where
example-Term : Term
example-Term =
(function ⟨ 2 ⟩
⟨ ⟨ ( variable ⟨ 0 ⟩ ∷
function ⟨ 3 ⟩ ⟨ ⟨ variable ⟨ 2 ⟩ ∷ [] ⟩ ⟩ ∷
variable ⟨ 5 ⟩ ∷ [] )
⟩ ⟩
)
-- function ⟨ 2 ⟩ ⟨ 3 ⟩ ∷ variable ⟨ 0 ⟩ ∷ function ⟨ 3 ⟩ ⟨ 1 ⟩ ∷ variable ⟨ 2 ⟩ ∷ variable ⟨ 5 ⟩ ∷ []
example-TermCodes : List TermCode
example-TermCodes = encodeTerm example-Term
example-TermDecode : Maybe (Term × List TermCode)
example-TermDecode = runStateT (decodeTerm (length example-TermCodes)) example-TermCodes
example-verified : example-TermDecode ≡ (just $ example-Term , [])
example-verified = refl
example-bad : runStateT (decodeTerm 2) (function ⟨ 2 ⟩ ⟨ 2 ⟩ ∷ variable ⟨ 0 ⟩ ∷ []) ≡ nothing
example-bad = refl
| {
"alphanum_fraction": 0.6382592928,
"avg_line_length": 35.2021276596,
"ext": "agda",
"hexsha": "2948e814c478e47b4d98b27593f53631fe215043",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_forks_repo_licenses": [
"RSA-MD"
],
"max_forks_repo_name": "m0davis/oscar",
"max_forks_repo_path": "archive/agda-1/TermCode.agda",
"max_issues_count": 1,
"max_issues_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_issues_repo_issues_event_max_datetime": "2019-05-11T23:33:04.000Z",
"max_issues_repo_issues_event_min_datetime": "2019-04-29T00:35:04.000Z",
"max_issues_repo_licenses": [
"RSA-MD"
],
"max_issues_repo_name": "m0davis/oscar",
"max_issues_repo_path": "archive/agda-1/TermCode.agda",
"max_line_length": 129,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb",
"max_stars_repo_licenses": [
"RSA-MD"
],
"max_stars_repo_name": "m0davis/oscar",
"max_stars_repo_path": "archive/agda-1/TermCode.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1195,
"size": 3309
} |
{-# OPTIONS --without-K --safe #-}
module Definition.Conversion.Stability where
open import Definition.Untyped
open import Definition.Untyped.Properties
open import Definition.Typed
open import Definition.Typed.Weakening
open import Definition.Conversion
open import Definition.Conversion.Soundness
open import Definition.Typed.Consequences.Syntactic
open import Definition.Typed.Consequences.Substitution
open import Tools.Product
import Tools.PropositionalEquality as PE
-- Equality of contexts.
data ⊢_≡_ : (Γ Δ : Con Term) → Set where
ε : ⊢ ε ≡ ε
_∙_ : ∀ {Γ Δ A B} → ⊢ Γ ≡ Δ → Γ ⊢ A ≡ B → ⊢ Γ ∙ A ≡ Δ ∙ B
mutual
-- Syntactic validity and conversion substitution of a context equality.
contextConvSubst : ∀ {Γ Δ} → ⊢ Γ ≡ Δ → ⊢ Γ × ⊢ Δ × Δ ⊢ˢ idSubst ∷ Γ
contextConvSubst ε = ε , ε , id
contextConvSubst (_∙_ {Γ} {Δ} {A} {B} Γ≡Δ A≡B) =
let ⊢Γ , ⊢Δ , [σ] = contextConvSubst Γ≡Δ
⊢A , ⊢B = syntacticEq A≡B
Δ⊢B = stability Γ≡Δ ⊢B
in ⊢Γ ∙ ⊢A , ⊢Δ ∙ Δ⊢B
, (wk1Subst′ ⊢Γ ⊢Δ Δ⊢B [σ]
, conv (var (⊢Δ ∙ Δ⊢B) here)
(PE.subst (λ x → _ ⊢ _ ≡ x)
(wk1-tailId A)
(wkEq (step id) (⊢Δ ∙ Δ⊢B) (stabilityEq Γ≡Δ (sym A≡B)))))
-- Stability of types under equal contexts.
stability : ∀ {A Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ A → Δ ⊢ A
stability Γ≡Δ A =
let ⊢Γ , ⊢Δ , σ = contextConvSubst Γ≡Δ
q = substitution A σ ⊢Δ
in PE.subst (λ x → _ ⊢ x) (subst-id _) q
-- Stability of type equality.
stabilityEq : ∀ {A B Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ A ≡ B → Δ ⊢ A ≡ B
stabilityEq Γ≡Δ A≡B =
let ⊢Γ , ⊢Δ , σ = contextConvSubst Γ≡Δ
q = substitutionEq A≡B (substRefl σ) ⊢Δ
in PE.subst₂ (λ x y → _ ⊢ x ≡ y) (subst-id _) (subst-id _) q
-- Reflexivity of context equality.
reflConEq : ∀ {Γ} → ⊢ Γ → ⊢ Γ ≡ Γ
reflConEq ε = ε
reflConEq (⊢Γ ∙ ⊢A) = reflConEq ⊢Γ ∙ refl ⊢A
-- Symmetry of context equality.
symConEq : ∀ {Γ Δ} → ⊢ Γ ≡ Δ → ⊢ Δ ≡ Γ
symConEq ε = ε
symConEq (Γ≡Δ ∙ A≡B) = symConEq Γ≡Δ ∙ stabilityEq Γ≡Δ (sym A≡B)
-- Stability of terms.
stabilityTerm : ∀ {t A Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ t ∷ A → Δ ⊢ t ∷ A
stabilityTerm Γ≡Δ t =
let ⊢Γ , ⊢Δ , σ = contextConvSubst Γ≡Δ
q = substitutionTerm t σ ⊢Δ
in PE.subst₂ (λ x y → _ ⊢ x ∷ y) (subst-id _) (subst-id _) q
-- Stability of term reduction.
stabilityRedTerm : ∀ {t u A Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ t ⇒ u ∷ A → Δ ⊢ t ⇒ u ∷ A
stabilityRedTerm Γ≡Δ (conv d x) =
conv (stabilityRedTerm Γ≡Δ d) (stabilityEq Γ≡Δ x)
stabilityRedTerm Γ≡Δ (app-subst d x) =
app-subst (stabilityRedTerm Γ≡Δ d) (stabilityTerm Γ≡Δ x)
stabilityRedTerm Γ≡Δ (fst-subst ⊢F ⊢G t⇒) =
fst-subst (stability Γ≡Δ ⊢F)
(stability (Γ≡Δ ∙ refl ⊢F) ⊢G)
(stabilityRedTerm Γ≡Δ t⇒)
stabilityRedTerm Γ≡Δ (snd-subst ⊢F ⊢G t⇒) =
snd-subst (stability Γ≡Δ ⊢F)
(stability (Γ≡Δ ∙ refl ⊢F) ⊢G)
(stabilityRedTerm Γ≡Δ t⇒)
stabilityRedTerm Γ≡Δ (Σ-β₁ ⊢F ⊢G ⊢t ⊢u) =
Σ-β₁ (stability Γ≡Δ ⊢F)
(stability (Γ≡Δ ∙ refl ⊢F) ⊢G)
(stabilityTerm Γ≡Δ ⊢t)
(stabilityTerm Γ≡Δ ⊢u)
stabilityRedTerm Γ≡Δ (Σ-β₂ ⊢F ⊢G ⊢t ⊢u) =
Σ-β₂ (stability Γ≡Δ ⊢F)
(stability (Γ≡Δ ∙ refl ⊢F) ⊢G)
(stabilityTerm Γ≡Δ ⊢t)
(stabilityTerm Γ≡Δ ⊢u)
stabilityRedTerm Γ≡Δ (β-red x x₁ x₂) =
β-red (stability Γ≡Δ x) (stabilityTerm (Γ≡Δ ∙ refl x) x₁)
(stabilityTerm Γ≡Δ x₂)
stabilityRedTerm Γ≡Δ (natrec-subst x x₁ x₂ d) =
let ⊢Γ , _ , _ = contextConvSubst Γ≡Δ
in natrec-subst (stability (Γ≡Δ ∙ refl (ℕⱼ ⊢Γ)) x) (stabilityTerm Γ≡Δ x₁)
(stabilityTerm Γ≡Δ x₂) (stabilityRedTerm Γ≡Δ d)
stabilityRedTerm Γ≡Δ (natrec-zero x x₁ x₂) =
let ⊢Γ , _ , _ = contextConvSubst Γ≡Δ
in natrec-zero (stability (Γ≡Δ ∙ refl (ℕⱼ ⊢Γ)) x) (stabilityTerm Γ≡Δ x₁)
(stabilityTerm Γ≡Δ x₂)
stabilityRedTerm Γ≡Δ (natrec-suc x x₁ x₂ x₃) =
let ⊢Γ , _ , _ = contextConvSubst Γ≡Δ
in natrec-suc (stabilityTerm Γ≡Δ x) (stability (Γ≡Δ ∙ refl (ℕⱼ ⊢Γ)) x₁)
(stabilityTerm Γ≡Δ x₂) (stabilityTerm Γ≡Δ x₃)
stabilityRedTerm Γ≡Δ (Emptyrec-subst x d) =
Emptyrec-subst (stability Γ≡Δ x) (stabilityRedTerm Γ≡Δ d)
-- Stability of type reductions.
stabilityRed : ∀ {A B Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ A ⇒ B → Δ ⊢ A ⇒ B
stabilityRed Γ≡Δ (univ x) = univ (stabilityRedTerm Γ≡Δ x)
-- Stability of type reduction closures.
stabilityRed* : ∀ {A B Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ A ⇒* B → Δ ⊢ A ⇒* B
stabilityRed* Γ≡Δ (id x) = id (stability Γ≡Δ x)
stabilityRed* Γ≡Δ (x ⇨ D) = stabilityRed Γ≡Δ x ⇨ stabilityRed* Γ≡Δ D
-- Stability of term reduction closures.
stabilityRed*Term : ∀ {t u A Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ t ⇒* u ∷ A → Δ ⊢ t ⇒* u ∷ A
stabilityRed*Term Γ≡Δ (id x) = id (stabilityTerm Γ≡Δ x)
stabilityRed*Term Γ≡Δ (x ⇨ d) = stabilityRedTerm Γ≡Δ x ⇨ stabilityRed*Term Γ≡Δ d
mutual
-- Stability of algorithmic equality of neutrals.
stability~↑ : ∀ {k l A Γ Δ}
→ ⊢ Γ ≡ Δ
→ Γ ⊢ k ~ l ↑ A
→ Δ ⊢ k ~ l ↑ A
stability~↑ Γ≡Δ (var-refl x x≡y) =
var-refl (stabilityTerm Γ≡Δ x) x≡y
stability~↑ Γ≡Δ (app-cong k~l x) =
app-cong (stability~↓ Γ≡Δ k~l) (stabilityConv↑Term Γ≡Δ x)
stability~↑ Γ≡Δ (fst-cong p~r) =
fst-cong (stability~↓ Γ≡Δ p~r)
stability~↑ Γ≡Δ (snd-cong p~r) =
snd-cong (stability~↓ Γ≡Δ p~r)
stability~↑ Γ≡Δ (natrec-cong x₁ x₂ x₃ k~l) =
let ⊢Γ , _ , _ = contextConvSubst Γ≡Δ
in natrec-cong (stabilityConv↑ (Γ≡Δ ∙ (refl (ℕⱼ ⊢Γ))) x₁)
(stabilityConv↑Term Γ≡Δ x₂)
(stabilityConv↑Term Γ≡Δ x₃)
(stability~↓ Γ≡Δ k~l)
stability~↑ Γ≡Δ (Emptyrec-cong x₁ k~l) =
Emptyrec-cong (stabilityConv↑ Γ≡Δ x₁)
(stability~↓ Γ≡Δ k~l)
-- Stability of algorithmic equality of neutrals of types in WHNF.
stability~↓ : ∀ {k l A Γ Δ}
→ ⊢ Γ ≡ Δ
→ Γ ⊢ k ~ l ↓ A
→ Δ ⊢ k ~ l ↓ A
stability~↓ Γ≡Δ ([~] A D whnfA k~l) =
[~] A (stabilityRed* Γ≡Δ D) whnfA (stability~↑ Γ≡Δ k~l)
-- Stability of algorithmic equality of types.
stabilityConv↑ : ∀ {A B Γ Δ}
→ ⊢ Γ ≡ Δ
→ Γ ⊢ A [conv↑] B
→ Δ ⊢ A [conv↑] B
stabilityConv↑ Γ≡Δ ([↑] A′ B′ D D′ whnfA′ whnfB′ A′<>B′) =
[↑] A′ B′ (stabilityRed* Γ≡Δ D) (stabilityRed* Γ≡Δ D′) whnfA′ whnfB′
(stabilityConv↓ Γ≡Δ A′<>B′)
-- Stability of algorithmic equality of types in WHNF.
stabilityConv↓ : ∀ {A B Γ Δ}
→ ⊢ Γ ≡ Δ
→ Γ ⊢ A [conv↓] B
→ Δ ⊢ A [conv↓] B
stabilityConv↓ Γ≡Δ (U-refl x) =
let _ , ⊢Δ , _ = contextConvSubst Γ≡Δ
in U-refl ⊢Δ
stabilityConv↓ Γ≡Δ (ℕ-refl x) =
let _ , ⊢Δ , _ = contextConvSubst Γ≡Δ
in ℕ-refl ⊢Δ
stabilityConv↓ Γ≡Δ (Empty-refl x) =
let _ , ⊢Δ , _ = contextConvSubst Γ≡Δ
in Empty-refl ⊢Δ
stabilityConv↓ Γ≡Δ (Unit-refl x) =
let _ , ⊢Δ , _ = contextConvSubst Γ≡Δ
in Unit-refl ⊢Δ
stabilityConv↓ Γ≡Δ (ne x) =
ne (stability~↓ Γ≡Δ x)
stabilityConv↓ Γ≡Δ (Π-cong F A<>B A<>B₁) =
Π-cong (stability Γ≡Δ F) (stabilityConv↑ Γ≡Δ A<>B)
(stabilityConv↑ (Γ≡Δ ∙ refl F) A<>B₁)
stabilityConv↓ Γ≡Δ (Σ-cong F A<>B A<>B₁) =
Σ-cong (stability Γ≡Δ F) (stabilityConv↑ Γ≡Δ A<>B)
(stabilityConv↑ (Γ≡Δ ∙ refl F) A<>B₁)
-- Stability of algorithmic equality of terms.
stabilityConv↑Term : ∀ {t u A Γ Δ}
→ ⊢ Γ ≡ Δ
→ Γ ⊢ t [conv↑] u ∷ A
→ Δ ⊢ t [conv↑] u ∷ A
stabilityConv↑Term Γ≡Δ ([↑]ₜ B t′ u′ D d d′ whnfB whnft′ whnfu′ t<>u) =
[↑]ₜ B t′ u′ (stabilityRed* Γ≡Δ D) (stabilityRed*Term Γ≡Δ d)
(stabilityRed*Term Γ≡Δ d′) whnfB whnft′ whnfu′
(stabilityConv↓Term Γ≡Δ t<>u)
-- Stability of algorithmic equality of terms in WHNF.
stabilityConv↓Term : ∀ {t u A Γ Δ}
→ ⊢ Γ ≡ Δ
→ Γ ⊢ t [conv↓] u ∷ A
→ Δ ⊢ t [conv↓] u ∷ A
stabilityConv↓Term Γ≡Δ (ℕ-ins x) =
ℕ-ins (stability~↓ Γ≡Δ x)
stabilityConv↓Term Γ≡Δ (Empty-ins x) =
Empty-ins (stability~↓ Γ≡Δ x)
stabilityConv↓Term Γ≡Δ (Unit-ins x) =
Unit-ins (stability~↓ Γ≡Δ x)
stabilityConv↓Term Γ≡Δ (ne-ins t u neN x) =
ne-ins (stabilityTerm Γ≡Δ t) (stabilityTerm Γ≡Δ u) neN (stability~↓ Γ≡Δ x)
stabilityConv↓Term Γ≡Δ (univ x x₁ x₂) =
univ (stabilityTerm Γ≡Δ x) (stabilityTerm Γ≡Δ x₁) (stabilityConv↓ Γ≡Δ x₂)
stabilityConv↓Term Γ≡Δ (zero-refl x) =
let _ , ⊢Δ , _ = contextConvSubst Γ≡Δ
in zero-refl ⊢Δ
stabilityConv↓Term Γ≡Δ (suc-cong t<>u) = suc-cong (stabilityConv↑Term Γ≡Δ t<>u)
stabilityConv↓Term Γ≡Δ (η-eq x x₁ y y₁ t<>u) =
let ⊢F , ⊢G = syntacticΠ (syntacticTerm x)
in η-eq (stabilityTerm Γ≡Δ x) (stabilityTerm Γ≡Δ x₁)
y y₁ (stabilityConv↑Term (Γ≡Δ ∙ refl ⊢F) t<>u)
stabilityConv↓Term Γ≡Δ (Σ-η ⊢p ⊢r pProd rProd fstConv sndConv) =
Σ-η (stabilityTerm Γ≡Δ ⊢p) (stabilityTerm Γ≡Δ ⊢r)
pProd rProd
(stabilityConv↑Term Γ≡Δ fstConv) (stabilityConv↑Term Γ≡Δ sndConv)
stabilityConv↓Term Γ≡Δ (η-unit [t] [u] tUnit uUnit) =
let [t] = stabilityTerm Γ≡Δ [t]
[u] = stabilityTerm Γ≡Δ [u]
in η-unit [t] [u] tUnit uUnit
| {
"alphanum_fraction": 0.5644771529,
"avg_line_length": 39.0729613734,
"ext": "agda",
"hexsha": "1d8080ab44a38bbbfa32aab73e9e2ef4d74d52b0",
"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/Stability.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/Stability.agda",
"max_line_length": 82,
"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/Stability.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 4090,
"size": 9104
} |
------------------------------------------------------------------------
-- Some lemmas used by the other modules in this directory
------------------------------------------------------------------------
module Hinze.Lemmas where
open import Stream.Programs
open import Stream.Equality
open import Codata.Musical.Notation hiding (∞)
open import Relation.Binary.PropositionalEquality
open import Function using (_∘_; flip)
------------------------------------------------------------------------
-- Some lemmas from Section 2.3 of Hinze's paper
-- See also Stream.Equality.≊-η.
⋎-∞ : ∀ {A} (x : A) → x ∞ ⋎ x ∞ ≊ x ∞
⋎-∞ x = refl ≺ ♯ ⋎-∞ x
⋎-map : ∀ {A B} (⊟ : A → B) s t →
⊟ · s ⋎ ⊟ · t ≊ ⊟ · (s ⋎ t)
⋎-map ⊟ s t with whnf s
⋎-map ⊟ s t | x ≺ s′ = refl ≺ ♯ ⋎-map ⊟ t s′
abide-law : ∀ {A B C} (⊞ : A → B → C) s₁ s₂ t₁ t₂ →
s₁ ⟨ ⊞ ⟩ s₂ ⋎ t₁ ⟨ ⊞ ⟩ t₂ ≊ (s₁ ⋎ t₁) ⟨ ⊞ ⟩ (s₂ ⋎ t₂)
abide-law ⊞ s₁ s₂ t₁ t₂ with whnf s₁ | whnf s₂
abide-law ⊞ s₁ s₂ t₁ t₂ | x₁ ≺ s₁′ | x₂ ≺ s₂′ =
refl ≺ ♯ abide-law ⊞ t₁ t₂ s₁′ s₂′
------------------------------------------------------------------------
-- Other lemmas
tailP-cong : ∀ {A} (xs ys : Prog A) →
xs ≊ ys → tailP xs ≊ tailP ys
tailP-cong xs ys xs≈ys with whnf xs | whnf ys | ≅⇒≃ xs≈ys
tailP-cong xs ys xs≈ys | x ≺ xs′ | y ≺ ys′ | x≡y ≺ xs≈ys′ = xs≈ys′
map-fusion : ∀ {A B C} (f : B → C) (g : A → B) xs →
f · g · xs ≊ (f ∘ g) · xs
map-fusion f g xs with whnf xs
map-fusion f g xs | x ≺ xs′ = refl ≺ ♯ map-fusion f g xs′
zip-const-is-map : ∀ {A B C} (_∙_ : A → B → C) xs y →
xs ⟨ _∙_ ⟩ y ∞ ≊ (λ x → x ∙ y) · xs
zip-const-is-map _∙_ xs y with whnf xs
zip-const-is-map _∙_ xs y | x ≺ xs′ =
refl ≺ ♯ zip-const-is-map _∙_ xs′ y
zip-flip : ∀ {A B C} (∙ : A → B → C) s t →
s ⟨ ∙ ⟩ t ≊ t ⟨ flip ∙ ⟩ s
zip-flip ∙ s t with whnf s | whnf t
zip-flip ∙ s t | x ≺ s′ | y ≺ t′ = refl ≺ ♯ zip-flip ∙ s′ t′
zip-⋎-const : ∀ {A B C} (∙ : A → B → C) s t x →
(s ⋎ t) ⟨ ∙ ⟩ x ∞ ≊ s ⟨ ∙ ⟩ x ∞ ⋎ t ⟨ ∙ ⟩ x ∞
zip-⋎-const _∙_ s t x =
(s ⋎ t) ⟨ _∙_ ⟩ x ∞
≊⟨ zip-const-is-map _ (s ⋎ t) _ ⟩
(λ y → y ∙ x) · (s ⋎ t)
≊⟨ ≅-sym (⋎-map (λ y → y ∙ x) s t) ⟩
(λ y → y ∙ x) · s ⋎ (λ y → y ∙ x) · t
≊⟨ ≅-sym (⋎-cong (s ⟨ _∙_ ⟩ x ∞) ((λ y → y ∙ x) · s)
(zip-const-is-map _∙_ s x)
_ _ (zip-const-is-map _∙_ t x)) ⟩
s ⟨ _∙_ ⟩ x ∞ ⋎ t ⟨ _∙_ ⟩ x ∞
∎
zip-const-⋎ : ∀ {A B C} (∙ : A → B → C) x s t →
x ∞ ⟨ ∙ ⟩ (s ⋎ t) ≊ x ∞ ⟨ ∙ ⟩ s ⋎ x ∞ ⟨ ∙ ⟩ t
zip-const-⋎ ∙ x s t =
x ∞ ⟨ ∙ ⟩ (s ⋎ t)
≊⟨ zip-flip ∙ (x ∞) (s ⋎ t) ⟩
(s ⋎ t) ⟨ flip ∙ ⟩ x ∞
≊⟨ zip-⋎-const (flip ∙) s t x ⟩
s ⟨ flip ∙ ⟩ x ∞ ⋎ t ⟨ flip ∙ ⟩ x ∞
≊⟨ ≅-sym (⋎-cong (x ∞ ⟨ ∙ ⟩ s) (s ⟨ flip ∙ ⟩ x ∞)
(zip-flip ∙ (x ∞) s)
_ _ (zip-flip ∙ (x ∞) t)) ⟩
x ∞ ⟨ ∙ ⟩ s ⋎ x ∞ ⟨ ∙ ⟩ t
∎
| {
"alphanum_fraction": 0.3336360884,
"avg_line_length": 39.3214285714,
"ext": "agda",
"hexsha": "b1391c9e94e6367277eeb8e6907dc3d12902e5e1",
"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": "Hinze/Lemmas.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": "Hinze/Lemmas.agda",
"max_line_length": 93,
"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": "Hinze/Lemmas.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": 1383,
"size": 3303
} |
module MultipleIdentifiersOneSignature where
data Bool : Set where
false true : Bool
not : Bool → Bool
not true = false
not false = true
data Suit : Set where
♥ ♢ ♠ ♣ : Suit
record R : Set₁ where
field
A B C : Set
postulate
A : Set
B C : Set
{-# BUILTIN CHAR Char #-}
{-# BUILTIN BOOL Bool #-}
{-# BUILTIN TRUE true #-}
{-# BUILTIN FALSE false #-}
primitive
primIsDigit primIsSpace : Char → Bool
.b : Bool
b = true
f g h : Bool
f = true
g = false
h = true
.i j .k : Bool
i = not b
j = true
k = not (not b)
| {
"alphanum_fraction": 0.6099815157,
"avg_line_length": 13.1951219512,
"ext": "agda",
"hexsha": "b1f98edb3faf34e526c65dedda9c484bc340fe5a",
"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": "6043e77e4a72518711f5f808fb4eb593cbf0bb7c",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "alhassy/agda",
"max_forks_repo_path": "test/Succeed/MultipleIdentifiersOneSignature.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/MultipleIdentifiersOneSignature.agda",
"max_line_length": 44,
"max_stars_count": 1,
"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/MultipleIdentifiersOneSignature.agda",
"max_stars_repo_stars_event_max_datetime": "2021-07-07T10:49:57.000Z",
"max_stars_repo_stars_event_min_datetime": "2021-07-07T10:49:57.000Z",
"num_tokens": 178,
"size": 541
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Examples of pretty printing of rose trees
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe --sized-types #-}
module README.Text.Tree where
open import Data.List.Base
open import Data.String.Base
open import Data.Tree.Rose
open import Function.Base
open import Agda.Builtin.Equality
------------------------------------------------------------------------
-- We import the module defining the pretty printer for rose trees
open import Text.Tree.Linear
------------------------------------------------------------------------
-- Example
_ : unlines (display
$ node [ "one" ]
(node [ "two" ] []
∷ node ("three" ∷ "and" ∷ "four" ∷ [])
(node [ "five" ] []
∷ node [ "six" ] (node [ "seven" ] [] ∷ [])
∷ node [ "eight" ] []
∷ [])
∷ node [ "nine" ]
(node [ "ten" ] []
∷ node [ "eleven" ] [] ∷ [])
∷ []))
≡ "one
\ \ ├ two
\ \ ├ three
\ \ │ and
\ \ │ four
\ \ │ ├ five
\ \ │ ├ six
\ \ │ │ └ seven
\ \ │ └ eight
\ \ └ nine
\ \ ├ ten
\ \ └ eleven"
_ = refl
| {
"alphanum_fraction": 0.383360522,
"avg_line_length": 24.52,
"ext": "agda",
"hexsha": "708a455f737350405f81863abcc205daba92d584",
"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/README/Text/Tree.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/README/Text/Tree.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/README/Text/Tree.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": 314,
"size": 1226
} |
-- The ATP pragma with the role <definition> can be used with functions.
module ATPDefinition where
postulate
D : Set
zero : D
succ : D → D
one : D
one = succ zero
{-# ATP definition one #-}
| {
"alphanum_fraction": 0.6600985222,
"avg_line_length": 15.6153846154,
"ext": "agda",
"hexsha": "f84e194917d3fe88bb2a94489fb0c313309655fc",
"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": "examples/ATPDefinition.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": "examples/ATPDefinition.agda",
"max_line_length": 72,
"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": "examples/ATPDefinition.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": 56,
"size": 203
} |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Base.Types
open import LibraBFT.Concrete.System.Parameters
open import LibraBFT.Impl.Consensus.BlockStorage.SyncManager
open import LibraBFT.Impl.Consensus.ConsensusTypes.Vote as Vote
open import LibraBFT.Impl.OBM.Logging.Logging
open import LibraBFT.Impl.Properties.Util
open import LibraBFT.ImplShared.Base.Types
open import LibraBFT.ImplShared.Consensus.Types
open import LibraBFT.ImplShared.Interface.Output
open import LibraBFT.ImplShared.Util.Crypto
open import LibraBFT.ImplShared.Util.Dijkstra.All
open import LibraBFT.Impl.Consensus.BlockStorage.BlockStore
open import LibraBFT.Impl.Properties.Util
open import Optics.All
open import Util.ByteString
open import Util.Hash
open import Util.PKCS
open import Util.Prelude
open import Yasm.System ℓ-RoundManager ℓ-VSFP ConcSysParms
open Invariants
open RoundManagerTransProps
open OutputProps
module LibraBFT.Impl.Consensus.BlockStorage.Properties.SyncManager where
module insertQuorumCertMSpec
(qc : QuorumCert) (retriever : BlockRetriever) where
open insertQuorumCertM qc retriever
open import LibraBFT.Impl.Consensus.BlockStorage.Properties.BlockStore
module _ (pre : RoundManager) where
record Contract (r : Either ErrLog Unit) (post : RoundManager) (outs : List Output) : Set where
constructor mkContract
field
-- General invariants / properties
rmInv : Preserves RoundManagerInv pre post
noEpochChange : NoEpochChange pre post
noVoteOuts : NoVotes outs
-- Voting
noVote : VoteNotGenerated pre post true
-- Signatures
outQcs∈RM : QCProps.OutputQc∈RoundManager outs post
qcPost : QCProps.∈Post⇒∈PreOr (_≡ qc) pre post
private -- NOTE: need to re-generalize over `pre` because the prestate might differ
module step₁Spec (bs : BlockStore) (pool : SentMessages) (pre : RoundManager) where
postulate -- TODO-2: Prove
contract' : LBFT-weakestPre (step₁ bs) (Contract pre) pre
contract : ∀ Q → RWS-Post-⇒ (Contract pre) Q → LBFT-weakestPre (step₁ bs) Q pre
contract Q pf = LBFT-⇒ (step₁ bs) pre contract' pf
module _ (pool : SentMessages) (pre : RoundManager) where
contract' : LBFT-weakestPre (insertQuorumCertM qc retriever) (Contract pre) pre
proj₁ (contract' bs@._ refl) _ nfIsLeft ._ refl = step₁Spec.contract' bs pool pre
proj₂ (contract' bs@._ refl) NeedFetch nf≡ =
obm-dangerous-magic' "TODO: waiting on contract for `fetchQuorumCertM`"
proj₂ (contract' bs@._ refl) QCBlockExist nf≡ =
insertSingleQuorumCertMSpec.contract qc pre Post₁ contract₁
where
Post₁ : LBFT-Post (Either ErrLog Unit)
Post₁ =
(RWS-weakestPre-∙^∙Post unit (withErrCtx $ "" ∷ [])
(RWS-weakestPre-ebindPost unit (λ _ → use lBlockStore >>= (λ _ → logInfo fakeInfo) >> ok unit)
(RWS-weakestPre-bindPost unit (λ _ → step₁ bs) (Contract pre))))
module _ (r₁ : Either ErrLog Unit) (st₁ : RoundManager) (outs₁ : List Output) (con₁ : insertSingleQuorumCertMSpec.Contract qc pre r₁ st₁ outs₁) where
module ISQC = insertSingleQuorumCertMSpec.Contract con₁
contract₁' : ∀ outs' → NoMsgs outs' → RWS-Post-⇒ (Contract st₁) (RWS-Post++ (Contract pre) outs')
contract₁' outs' noMsgs r₂ st₂ outs₂ con₂ =
mkContract
(transPreservesRoundManagerInv ISQC.rmInv Step₁.rmInv)
(transNoEpochChange{i = pre}{st₁}{st₂} ISQC.noEpochChange Step₁.noEpochChange)
(++-NoVotes outs' outs₂ (NoMsgs⇒NoVotes outs' noMsgs) Step₁.noVoteOuts)
(transVoteNotGenerated ISQC.noVote Step₁.noVote)
(QCProps.++-OutputQc∈RoundManager{st₂}{outs'}{outs₂} (QCProps.NoMsgs⇒OutputQc∈RoundManager outs' st₂ noMsgs) Step₁.outQcs∈RM)
qcPost
where
module Step₁ = Contract con₂
qcPost : QCProps.∈Post⇒∈PreOr (_≡ qc) pre st₂
qcPost qc qc∈st₂
with Step₁.qcPost qc qc∈st₂
...| Right qc≡ = Right qc≡
...| Left qc∈st₁
with ISQC.qcPost qc qc∈st₁
...| Right qc≡ = Right qc≡
...| Left qc∈pre = Left qc∈pre
contract₁ : RWS-Post-⇒ (insertSingleQuorumCertMSpec.Contract qc pre) Post₁
contract₁ (Left _) st₁ outs₁ con₁ ._ refl ._ refl =
step₁Spec.contract bs pool st₁ (RWS-Post++ (Contract pre) (outs₁ ++ []))
(contract₁' _ _ _ con₁ (outs₁ ++ [])
(++-NoMsgs outs₁ [] (insertSingleQuorumCertMSpec.Contract.noMsgOuts con₁) refl))
contract₁ (Right y) st₁ outs₁ con₁ ._ refl ._ refl ._ refl ._ refl ._ refl =
step₁Spec.contract bs pool st₁ (RWS-Post++ (Contract pre) ((outs₁ ++ []) ++ LogInfo fakeInfo ∷ []))
(contract₁' _ _ _ con₁ ((outs₁ ++ []) ++ LogInfo fakeInfo ∷ [])
(++-NoMsgs (outs₁ ++ []) (LogInfo fakeInfo ∷ [])
(++-NoMsgs outs₁ [] (insertSingleQuorumCertMSpec.Contract.noMsgOuts con₁) refl)
refl))
proj₂ (contract' bs@._ refl) QCRoundBeforeRoot _ ._ refl = step₁Spec.contract' bs pool pre
proj₂ (contract' bs@._ refl) QCAlreadyExist _ ._ refl = step₁Spec.contract' bs pool pre
module addCertsMSpec
(syncInfo : SyncInfo) (retriever : BlockRetriever) where
module _ (pre : RoundManager) where
record Contract (r : Either ErrLog Unit) (post : RoundManager) (outs : List Output) : Set where
constructor mkContract
field
-- General invariants / properties
rmInv : Preserves RoundManagerInv pre post
dnmBtIdToBlk : post ≡L pre at (lBlockTree ∙ btIdToBlock)
noEpochChange : NoEpochChange pre post
noVoteOuts : OutputProps.NoVotes outs
-- Voting
noVote : VoteNotGenerated pre post true
-- Signatures
noOutQc : QCProps.¬OutputQc outs
qcPost : QCProps.∈Post⇒∈PreOr (_QC∈SyncInfo syncInfo) pre post
postulate -- TODO-2: prove
contract' : LBFT-weakestPre (addCertsM syncInfo retriever) Contract pre
contract : ∀ Q → RWS-Post-⇒ Contract Q → LBFT-weakestPre (addCertsM syncInfo retriever) Q pre
contract Q pf = LBFT-⇒ (addCertsM syncInfo retriever) pre contract' pf
| {
"alphanum_fraction": 0.6820809249,
"avg_line_length": 45.7214285714,
"ext": "agda",
"hexsha": "b73c1e30e8e22fbd18885cc8c813244ee2793bdc",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_forks_repo_licenses": [
"UPL-1.0"
],
"max_forks_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_forks_repo_path": "src/LibraBFT/Impl/Consensus/BlockStorage/Properties/SyncManager.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"UPL-1.0"
],
"max_issues_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_issues_repo_path": "src/LibraBFT/Impl/Consensus/BlockStorage/Properties/SyncManager.agda",
"max_line_length": 155,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "a4674fc473f2457fd3fe5123af48253cfb2404ef",
"max_stars_repo_licenses": [
"UPL-1.0"
],
"max_stars_repo_name": "LaudateCorpus1/bft-consensus-agda",
"max_stars_repo_path": "src/LibraBFT/Impl/Consensus/BlockStorage/Properties/SyncManager.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 1900,
"size": 6401
} |
module Hello where
data Bool : Set where
true : Bool
false : Bool
data Unit : Set where
one : Unit
unit : Unit
unit = ?
test : Bool → Bool
test x = ?
unicodeTest₁ : Bool → Bool
unicodeTest₁ x = ?
slap : Bool → Bool
slap = λ { x → ? }
module _ where
testIndent : Bool → Bool
testIndent true = ?
testIndent false = ?
| {
"alphanum_fraction": 0.6298507463,
"avg_line_length": 12.4074074074,
"ext": "agda",
"hexsha": "205c9790bc0e58c7e2ea906563a8348ad177b443",
"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": "e7f6eaea4be31748929b49a925a3a9365682e9ec",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "googleson78/cornelis",
"max_forks_repo_path": "test/Hello.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "e7f6eaea4be31748929b49a925a3a9365682e9ec",
"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": "googleson78/cornelis",
"max_issues_repo_path": "test/Hello.agda",
"max_line_length": 26,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "e7f6eaea4be31748929b49a925a3a9365682e9ec",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "googleson78/cornelis",
"max_stars_repo_path": "test/Hello.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 102,
"size": 335
} |
-- Andreas, 2012-01-13
module Issue555b where
data Empty : Set where
record Unit : Set where
constructor tt
-- Do we want to allow this?
data Exp (A : Set) : Set1
data Exp where -- ? needs to report that too few parameters are given
var : Exp Empty
app : {A B : Set} → Exp (A → B) → Exp A → Exp B
-- Basically, A is first declared as a parameter, but later,
-- in the definition, it is turned into an index.
bla : {A : Set} → Exp A → Unit
bla var = tt
bla (app f a) = bla f
| {
"alphanum_fraction": 0.6543209877,
"avg_line_length": 23.1428571429,
"ext": "agda",
"hexsha": "7c825ccbf628fcf7ba7b51eefcb7e506d511ee25",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "masondesu/agda",
"max_forks_repo_path": "test/fail/Issue555b.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "70c8a575c46f6a568c7518150a1a64fcd03aa437",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "masondesu/agda",
"max_issues_repo_path": "test/fail/Issue555b.agda",
"max_line_length": 69,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "aa10ae6a29dc79964fe9dec2de07b9df28b61ed5",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "asr/agda-kanso",
"max_stars_repo_path": "test/fail/Issue555b.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": 150,
"size": 486
} |
{-# OPTIONS --without-K --safe #-}
module Data.Binary.Bits where
open import Data.Bool
as Bool
using (not; _∨_; _∧_; _xor_; T)
renaming (Bool to Bit; true to I; false to O)
public
_xnor_ : Bit → Bit → Bit
O xnor y = not y
I xnor y = y
sumᵇ : Bit → Bit → Bit → Bit
sumᵇ O = _xor_
sumᵇ I = _xnor_
carryᵇ : Bit → Bit → Bit → Bit
carryᵇ O = _∧_
carryᵇ I = _∨_
| {
"alphanum_fraction": 0.620596206,
"avg_line_length": 16.7727272727,
"ext": "agda",
"hexsha": "6eb39ddda7c8489117dd39e54a5ebb2060a04c1c",
"lang": "Agda",
"max_forks_count": null,
"max_forks_repo_forks_event_max_datetime": null,
"max_forks_repo_forks_event_min_datetime": null,
"max_forks_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "oisdk/agda-binary",
"max_forks_repo_path": "Data/Binary/Bits.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "oisdk/agda-binary",
"max_issues_repo_path": "Data/Binary/Bits.agda",
"max_line_length": 47,
"max_stars_count": 1,
"max_stars_repo_head_hexsha": "92af4d620febd47a9791d466d747278dc4a417aa",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/agda-binary",
"max_stars_repo_path": "Data/Binary/Bits.agda",
"max_stars_repo_stars_event_max_datetime": "2019-03-21T21:30:10.000Z",
"max_stars_repo_stars_event_min_datetime": "2019-03-21T21:30:10.000Z",
"num_tokens": 150,
"size": 369
} |
module Span where
open import Prelude
open import Star
open import Modal
data SpanView {A : Set}{R : Rel A}(p : {a b : A} -> R a b -> Bool) :
EdgePred (Star R) where
oneFalse : {a b c d : A}(xs : Star R a b)(pxs : All (\x -> IsTrue (p x)) xs)
(x : R b c)(¬px : IsFalse (p x))(ys : Star R c d) ->
SpanView p (xs ++ x • ys)
allTrue : {a b : A}{xs : Star R a b}(ts : All (\x -> IsTrue (p x)) xs) ->
SpanView p xs
span : {A : Set}{R : Rel A}(p : {a b : A} -> R a b -> Bool){a b : A}
(xs : Star R a b) -> SpanView p xs
span p ε = allTrue ε
span p (x • xs) with inspect (p x)
span p (x • xs) | itsFalse ¬px = oneFalse ε ε x ¬px xs
span p (x • xs) | itsTrue px with span p xs
span p (x • .(xs ++ y • ys)) | itsTrue px
| oneFalse xs pxs y ¬py ys =
oneFalse (x • xs) (check px • pxs) y ¬py ys
span p (x • xs) | itsTrue px | allTrue pxs =
allTrue (check px • pxs)
_│_ : {A : Set}(R : Rel A)(P : EdgePred R) -> Rel A
(R │ P) a b = Σ (R a b) P
forget : {A : Set}{R : Rel A}{P : EdgePred R} -> Star (R │ P) =[ id ]=> Star R
forget = map id fst
data SpanView' {A : Set}{R : Rel A}(p : {a b : A} -> R a b -> Bool) :
EdgePred (Star R) where
oneFalse' : {a b c d : A}(xs : Star (R │ \{a b} x -> IsTrue (p x)) a b)
(x : R b c)(¬px : IsFalse (p x))(ys : Star R c d) ->
SpanView' p (forget xs ++ x • ys)
allTrue' : {a b : A}(xs : Star (R │ \{a b} x -> IsTrue (p x)) a b) ->
SpanView' p (forget xs)
span' : {A : Set}{R : Rel A}(p : {a b : A} -> R a b -> Bool){a b : A}
(xs : Star R a b) -> SpanView' p xs
span' p ε = allTrue' ε
span' p (x • xs) with inspect (p x)
span' p (x • xs) | itsFalse ¬px = oneFalse' ε x ¬px xs
span' p (x • xs) | itsTrue px with span' p xs
span' p (x • .(forget xs ++ y • ys)) | itsTrue px
| oneFalse' xs y ¬py ys = oneFalse' ((x ,, px) • xs) y ¬py ys
span' p (x • .(forget xs)) | itsTrue px
| allTrue' xs = allTrue' ((x ,, px) • xs)
-- Can't seem to define it as 'map Some.a (\x -> (_ ,, uncheck x))'
all│ : {A : Set}{R : Rel A}{P : EdgePred R}{a b : A}{xs : Star R a b} ->
All P xs -> Star (R │ P) a b
all│ (check p • pxs) = (_ ,, p) • all│ pxs
all│ ε = ε
| {
"alphanum_fraction": 0.4867374005,
"avg_line_length": 39,
"ext": "agda",
"hexsha": "dc05e6fd4b05274954c479ced93162f8b2818054",
"lang": "Agda",
"max_forks_count": 371,
"max_forks_repo_forks_event_max_datetime": "2022-03-30T19:00:30.000Z",
"max_forks_repo_forks_event_min_datetime": "2015-01-03T14:04:08.000Z",
"max_forks_repo_head_hexsha": "231d6ad8e77b67ff8c4b1cb35a6c31ccd988c3e9",
"max_forks_repo_licenses": [
"BSD-3-Clause"
],
"max_forks_repo_name": "Agda-zh/agda",
"max_forks_repo_path": "examples/AIM6/Path/Span.agda",
"max_issues_count": 4066,
"max_issues_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_issues_repo_issues_event_max_datetime": "2022-03-31T21:14:49.000Z",
"max_issues_repo_issues_event_min_datetime": "2015-01-10T11:24:51.000Z",
"max_issues_repo_licenses": [
"BSD-3-Clause"
],
"max_issues_repo_name": "shlevy/agda",
"max_issues_repo_path": "examples/AIM6/Path/Span.agda",
"max_line_length": 78,
"max_stars_count": 1989,
"max_stars_repo_head_hexsha": "ed8ac6f4062ea8a20fa0f62d5db82d4e68278338",
"max_stars_repo_licenses": [
"BSD-3-Clause"
],
"max_stars_repo_name": "shlevy/agda",
"max_stars_repo_path": "examples/AIM6/Path/Span.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": 871,
"size": 2262
} |
module Issue396 where
record ⊤ : Set where
constructor tt
foo : (P : ⊤ → Set) →
((x : ⊤) → P x → P x) →
(x y : ⊤) → P x → P y
foo P hyp x y = hyp x
-- Error was:
-- x != y of type ⊤
-- when checking that the expression hyp x has type P x → P y
| {
"alphanum_fraction": 0.5249042146,
"avg_line_length": 18.6428571429,
"ext": "agda",
"hexsha": "258c63b499b90f537a601a66826fa567fcc318ce",
"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/Issue396.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/Issue396.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/Issue396.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": 97,
"size": 261
} |
{-# OPTIONS --universe-polymorphism #-}
module Categories.Bifunctor.NaturalTransformation where
open import Level
open import Categories.Category
open import Categories.Bifunctor
open import Categories.Product
open import Categories.NaturalTransformation public
-- just for completeness ...
BiNaturalTransformation : ∀ {o ℓ e} {o′ ℓ′ e′} {o′′ ℓ′′ e′′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} {E : Category o′′ ℓ′′ e′′} → Bifunctor C D E → Bifunctor C D E → Set (o ⊔ ℓ ⊔ e ⊔ o′ ⊔ ℓ′ ⊔ e′ ⊔ o′′ ⊔ ℓ′′ ⊔ e′′)
BiNaturalTransformation F G = NaturalTransformation F G
reduceN-× : ∀ {o ℓ e} {o′₁ ℓ′₁ e′₁} {o′₂ ℓ′₂ e′₂} {C : Category o ℓ e} {D₁ : Category o′₁ ℓ′₁ e′₁} {D₂ : Category o′₂ ℓ′₂ e′₂} (H : Bifunctor D₁ D₂ C) {o″₁ ℓ″₁ e″₁} {E₁ : Category o″₁ ℓ″₁ e″₁} {F F′ : Functor E₁ D₁} (φ : NaturalTransformation F F′) {o″₂ ℓ″₂ e″₂} {E₂ : Category o″₂ ℓ″₂ e″₂} {G G′ : Functor E₂ D₂} (γ : NaturalTransformation G G′) → NaturalTransformation (reduce-× {D₁ = D₁} {D₂ = D₂} H F G) (reduce-× {D₁ = D₁} {D₂ = D₂} H F′ G′)
reduceN-× H φ γ = H ∘ˡ (φ ⁂ⁿ γ)
overlapN-× : ∀ {o ℓ e} {o′₁ ℓ′₁ e′₁} {o′₂ ℓ′₂ e′₂} {C : Category o ℓ e} {D₁ : Category o′₁ ℓ′₁ e′₁} {D₂ : Category o′₂ ℓ′₂ e′₂} (H : Bifunctor D₁ D₂ C) {o″ ℓ″ e″} {E : Category o″ ℓ″ e″} {F F′ : Functor E D₁} (φ : NaturalTransformation F F′) {G G′ : Functor E D₂} (γ : NaturalTransformation G G′) → NaturalTransformation (overlap-× {D₁ = D₁} {D₂ = D₂} H F G) (overlap-× {D₁ = D₁} {D₂ = D₂} H F′ G′)
overlapN-× H φ γ = H ∘ˡ (φ ※ⁿ γ) | {
"alphanum_fraction": 0.6109238031,
"avg_line_length": 74.15,
"ext": "agda",
"hexsha": "cbab83617dcf951148c2f949263cc1860ba3cecc",
"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/Bifunctor/NaturalTransformation.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/Bifunctor/NaturalTransformation.agda",
"max_line_length": 446,
"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/Bifunctor/NaturalTransformation.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": 665,
"size": 1483
} |
module plfa-code.Connectives where
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl)
open Eq.≡-Reasoning
open import Data.Nat using (ℕ)
open import Function using (_∘_)
open import plfa-code.Isomorphism using (_≃_; _≲_; extensionality)
open plfa-code.Isomorphism.≃-Reasoning
data _×_ (A B : Set) : Set where
⟨_,_⟩ :
A
→ B
-----
→ A × B
proj₁ : ∀ {A B : Set}
→ A × B
-----
→ A
proj₁ ⟨ x , y ⟩ = x
proj₂ : ∀ {A B : Set}
→ A × B
-----
→ B
proj₂ ⟨ x , y ⟩ = y
record _×′_ (A B : Set) : Set where
field
proj₁′ : A
proj₂′ : B
open _×′_
η-× : ∀ {A B : Set} (w : A × B) → ⟨ proj₁ w , proj₂ w ⟩ ≡ w
η-× ⟨ x , y ⟩ = refl
infixr 2 _×_
data Bool : Set where
true : Bool
false : Bool
data Tri : Set where
aa : Tri
bb : Tri
cc : Tri
×-count : Bool × Tri → ℕ
×-count ⟨ true , aa ⟩ = 1
×-count ⟨ true , bb ⟩ = 2
×-count ⟨ true , cc ⟩ = 3
×-count ⟨ false , aa ⟩ = 4
×-count ⟨ false , bb ⟩ = 5
×-count ⟨ false , cc ⟩ = 6
×-comm : ∀ {A B : Set} → A × B ≃ B × A
×-comm =
record
{ to = λ{ ⟨ x , y ⟩ → ⟨ y , x ⟩ }
; from = λ{ ⟨ y , x ⟩ → ⟨ x , y ⟩ }
; from∘to = λ{ ⟨ x , y ⟩ → refl }
; to∘from = λ{ ⟨ y , x ⟩ → refl }
}
×-assoc : ∀ {A B C : Set} → (A × B) × C ≃ A × (B × C)
×-assoc =
record
{ to = λ{ ⟨ ⟨ x , y ⟩ , z ⟩ → ⟨ x , ⟨ y , z ⟩ ⟩ }
; from = λ{ ⟨ x , ⟨ y , z ⟩ ⟩ → ⟨ ⟨ x , y ⟩ , z ⟩ }
; from∘to = λ{ ⟨ ⟨ x , y ⟩ , z ⟩ → refl }
; to∘from = λ{ ⟨ x , ⟨ y , z ⟩ ⟩ → refl }
}
---------- practice ----------
open plfa-code.Isomorphism using (_⇔_)
open _⇔_
⇔-≃-→×→ : ∀ {A B : Set} → A ⇔ B ≃ (A → B) × (B → A)
⇔-≃-→×→ =
record
{ to = λ x → ⟨ to x , from x ⟩
; from = λ{ ⟨ A→B , B→A ⟩ → record { to = A→B ; from = B→A } }
; from∘to = λ x → refl
; to∘from = λ{ ⟨ A→B , B→A ⟩ → refl }
}
------------------------------
data ⊤ : Set where
tt :
--
⊤
η-⊤ : ∀ (w : ⊤) → tt ≡ w
η-⊤ tt = refl
⊤-count : ⊤ → ℕ
⊤-count tt = 1
⊤-identityˡ : ∀ {A : Set} → ⊤ × A ≃ A
⊤-identityˡ =
record
{ to = λ{ ⟨ tt , x ⟩ → x }
; from = λ x → ⟨ tt , x ⟩
; from∘to = λ{ ⟨ tt , x ⟩ → refl }
; to∘from = λ x → refl
}
⊤-identityʳ : ∀ {A : Set} → (A × ⊤) ≃ A
⊤-identityʳ {A} =
≃-begin
(A × ⊤)
≃⟨ ×-comm ⟩
(⊤ × A)
≃⟨ ⊤-identityˡ ⟩
A
≃-∎
data _⊎_ (A B : Set) : Set where
inj₁ :
A
-----
→ A ⊎ B
inj₂ :
B
-----
→ A ⊎ B
case-⊎ : ∀ {A B C : Set}
→ (A → C)
→ (B → C)
→ A ⊎ B
-----------
→ C
case-⊎ f g (inj₁ x) = f x
case-⊎ f g (inj₂ y) = g y
η-⊎ : ∀ {A B : Set} (w : A ⊎ B) → case-⊎ inj₁ inj₂ w ≡ w
η-⊎ (inj₁ x) = refl
η-⊎ (inj₂ y) = refl
uniq-⊎ : ∀ {A B C : Set} (h : A ⊎ B → C) (w : A ⊎ B) →
case-⊎ (h ∘ inj₁) (h ∘ inj₂) w ≡ h w
uniq-⊎ h (inj₁ x) = refl
uniq-⊎ h (inj₂ y) = refl
infix 1 _⊎_
⊎-count : Bool ⊎ Tri → ℕ
⊎-count (inj₁ true) = 1
⊎-count (inj₁ false) = 2
⊎-count (inj₂ aa) = 3
⊎-count (inj₂ bb) = 4
⊎-count (inj₂ cc) = 5
---------- practice ----------
⊎-comm : ∀ {A B : Set} → A ⊎ B ≃ B ⊎ A
⊎-comm =
record
{ to = λ{(inj₁ a) → inj₂ a ; (inj₂ b) → inj₁ b }
; from = λ{(inj₁ b) → inj₂ b ; (inj₂ a) → inj₁ a }
; from∘to = λ{(inj₁ a) → refl ; (inj₂ b) → refl }
; to∘from = λ{(inj₁ b) → refl ; (inj₂ a) → refl }
}
⊎-assoc : ∀ {A B C : Set} → (A ⊎ B) ⊎ C ≃ A ⊎ (B ⊎ C)
⊎-assoc =
record
{ to = to′
; from = from′
; from∘to = from∘to′
; to∘from = to∘from′
}
where
to′ : ∀ {A B C : Set} → (A ⊎ B) ⊎ C → A ⊎ (B ⊎ C)
to′ (inj₁ (inj₁ a)) = inj₁ a
to′ (inj₁ (inj₂ b)) = inj₂ (inj₁ b)
to′ (inj₂ c) = inj₂ (inj₂ c)
from′ : ∀ {A B C : Set} → A ⊎ (B ⊎ C) → (A ⊎ B) ⊎ C
from′ (inj₁ a) = inj₁ (inj₁ a)
from′ (inj₂ (inj₁ b)) = inj₁ (inj₂ b)
from′ (inj₂ (inj₂ c)) = inj₂ c
from∘to′ : ∀ (x) → from′ (to′ x) ≡ x
from∘to′ (inj₁ (inj₁ a)) = refl
from∘to′ (inj₁ (inj₂ b)) = refl
from∘to′ (inj₂ c) = refl
to∘from′ : ∀ (x) → to′ (from′ x) ≡ x
to∘from′ (inj₁ a) = refl
to∘from′ (inj₂ (inj₁ b)) = refl
to∘from′ (inj₂ (inj₂ c)) = refl
------------------------------
data ⊥ : Set where
-- no clauses!
⊥-elim : ∀ {A : Set}
→ ⊥
--
→ A
⊥-elim ()
uniq-⊥ : ∀ {C : Set} (h : ⊥ → C) (w : ⊥) → ⊥-elim w ≡ h w
uniq-⊥ h ()
⊥-count : ⊥ → ℕ
⊥-count ()
---------- practice ----------
⊥-identityˡ : ∀ {A : Set} → ⊥ ⊎ A ≃ A
⊥-identityˡ =
record
{ to = λ{ (inj₂ a) → a }
; from = inj₂
; from∘to = λ{ (inj₂ a) → refl }
; to∘from = λ a → refl
}
⊥-identityʳ : ∀ {A : Set} → A ⊎ ⊥ ≃ A
⊥-identityʳ {A} =
≃-begin
(A ⊎ ⊥)
≃⟨ ⊎-comm ⟩
(⊥ ⊎ A)
≃⟨ ⊥-identityˡ ⟩
A
≃-∎
------------------------------
→-elim : ∀ {A B : Set}
→ (A → B)
→ A
-------
→ B
→-elim L M = L M
η-→ : ∀ {A B : Set} (f : A → B) → (λ (x : A) → f x) ≡ f
η-→ f = refl
→-count : (Bool → Tri) → ℕ
→-count f with f true | f false
... | aa | aa = 1
... | aa | bb = 2
... | aa | cc = 3
... | bb | aa = 4
... | bb | bb = 5
... | bb | cc = 6
... | cc | aa = 7
... | cc | bb = 8
... | cc | cc = 9
currying : ∀ {A B C : Set} → (A → B → C) ≃ (A × B → C)
currying =
record
{ to = λ f → λ{ ⟨ x , y ⟩ → f x y }
; from = λ g x y → g ⟨ x , y ⟩
; from∘to = λ x → refl
; to∘from = λ{ g → extensionality λ{ ⟨ x , y ⟩ → refl } }
}
→-distrib-⊎ : ∀ {A B C : Set} → (A ⊎ B → C) ≃ ((A → C) × (B → C))
→-distrib-⊎ =
record
{ to = λ{ f → ⟨ f ∘ inj₁ , f ∘ inj₂ ⟩ }
; from = λ{ ⟨ g , h ⟩ → λ{ (inj₁ x) → g x ; (inj₂ y) → h y } }
; from∘to = λ{ f → extensionality λ{ (inj₁ x) → refl ; (inj₂ y) → refl } }
; to∘from = λ{ ⟨ g , h ⟩ → refl }
}
→-distrib-× : ∀ {A B C : Set} → (A → B × C) ≃ (A → B) × (A → C)
→-distrib-× =
record
{ to = λ{ f → ⟨ proj₁ ∘ f , proj₂ ∘ f ⟩ }
; from = λ{ ⟨ g , h ⟩ → λ x → ⟨ g x , h x ⟩ }
; from∘to = λ{ f → extensionality λ{ x → η-× (f x) } }
; to∘from = λ{ ⟨ g , h ⟩ → refl }
}
×-distrib-⊎ : ∀ {A B C : Set} → (A ⊎ B) × C ≃ (A × C) ⊎ (B × C)
×-distrib-⊎ =
record
{ to = λ{ ⟨ inj₁ x , z ⟩ → (inj₁ ⟨ x , z ⟩)
; ⟨ inj₂ y , z ⟩ → (inj₂ ⟨ y , z ⟩)
}
; from = λ{ (inj₁ ⟨ x , z ⟩) → ⟨ inj₁ x , z ⟩
; (inj₂ ⟨ y , z ⟩) → ⟨ inj₂ y , z ⟩
}
; from∘to = λ{ ⟨ inj₁ x , z ⟩ → refl
; ⟨ inj₂ y , z ⟩ → refl
}
; to∘from = λ{ (inj₁ ⟨ x , z ⟩) → refl
; (inj₂ ⟨ y , z ⟩) → refl
}
}
⊎-distrib-× : ∀ {A B C : Set} → (A × B) ⊎ C ≲ (A ⊎ C) × (B ⊎ C)
⊎-distrib-× =
record
{ to = λ{ (inj₁ ⟨ x , y ⟩) → ⟨ inj₁ x , inj₁ y ⟩
; (inj₂ z) → ⟨ inj₂ z , inj₂ z ⟩
}
; from = λ{ ⟨ inj₁ x , inj₁ y ⟩ → (inj₁ ⟨ x , y ⟩)
; ⟨ inj₁ x , inj₂ z ⟩ → (inj₂ z)
; ⟨ inj₂ z , _ ⟩ → (inj₂ z)
}
; from∘to = λ{ (inj₁ ⟨ x , y ⟩) → refl
; (inj₂ z) → refl
}
}
---------- practice ----------
⊎-weak-× : ∀ {A B C : Set} → (A ⊎ B) × C → A ⊎ (B × C)
⊎-weak-× ⟨ inj₁ a , c ⟩ = inj₁ a
⊎-weak-× ⟨ inj₂ b , c ⟩ = inj₂ ⟨ b , c ⟩
-- the corresponding distributive law is ×-distrib-⊎, ×-distrib-⊎ is more strong
⊎×-implies-×⊎ : ∀ {A B C D : Set} → (A × B) ⊎ (C × D) → (A ⊎ C) × (B ⊎ D)
⊎×-implies-×⊎ (inj₁ ⟨ a , b ⟩) = ⟨ inj₁ a , inj₁ b ⟩
⊎×-implies-×⊎ (inj₂ ⟨ c , d ⟩) = ⟨ inj₂ c , inj₂ d ⟩
-- the converse doesn't hold. ⟨ inj₁ a , inj₂ d ⟩ could not build a
-- (A × B) ⊎ (C × D) value
------------------------------
| {
"alphanum_fraction": 0.3695287282,
"avg_line_length": 23.3987915408,
"ext": "agda",
"hexsha": "fe30eab68a7e53db44de10dba2fa69085c2762cd",
"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": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "chirsz-ever/plfa-code",
"max_forks_repo_path": "src/plfa-code/Connectives.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3",
"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": "chirsz-ever/plfa-code",
"max_issues_repo_path": "src/plfa-code/Connectives.agda",
"max_line_length": 80,
"max_stars_count": null,
"max_stars_repo_head_hexsha": "ec5b359a8c22bf5268cae3c36a97e6737c75d5f3",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "chirsz-ever/plfa-code",
"max_stars_repo_path": "src/plfa-code/Connectives.agda",
"max_stars_repo_stars_event_max_datetime": null,
"max_stars_repo_stars_event_min_datetime": null,
"num_tokens": 3698,
"size": 7745
} |
-- This file tests that record constructors are used in error
-- messages, if possible.
-- Andreas, 2016-07-20 Repaired this long disfunctional test case.
module RecordConstructorsInErrorMessages where
record R : Set₁ where
constructor con
field
{A} : Set
f : A → A
{B C} D {E} : Set
g : B → C → E
postulate
A : Set
r : R
data _≡_ {A : Set₁} (x : A) : A → Set where
refl : x ≡ x
foo : r ≡ record
{ A = A
; f = λ x → x
; B = A
; C = A
; D = A
; g = λ x _ → x
}
foo = refl
-- EXPECTED ERROR:
-- .R.A r != A of type Set
-- when checking that the expression refl has type
-- r ≡ con (λ x → x) A (λ x _ → x)
| {
"alphanum_fraction": 0.5471976401,
"avg_line_length": 18.3243243243,
"ext": "agda",
"hexsha": "18844cf563d0d89b213cb7833c285e63826dc5ae",
"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/RecordConstructorsInErrorMessages.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/RecordConstructorsInErrorMessages.agda",
"max_line_length": 66,
"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/RecordConstructorsInErrorMessages.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": 242,
"size": 678
} |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of Rational numbers
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Rational.Properties where
open import Algebra.Consequences.Propositional
open import Algebra.Morphism
open import Algebra.Bundles
import Algebra.Morphism.MonoidMonomorphism as MonoidMonomorphisms
import Algebra.Morphism.GroupMonomorphism as GroupMonomorphisms
import Algebra.Morphism.RingMonomorphism as RingMonomorphisms
import Algebra.Properties.CommutativeSemigroup as CommSemigroupProperties
open import Data.Integer.Base as ℤ using (ℤ; ∣_∣; +_; -[1+_]; 0ℤ; _◃_)
open import Data.Integer.Coprimality using (coprime-divisor)
import Data.Integer.Properties as ℤ
open import Data.Integer.GCD using (gcd; gcd[i,j]≡0⇒i≡0; gcd[i,j]≡0⇒j≡0)
open import Data.Nat.Base as ℕ using (ℕ; zero; suc)
import Data.Nat.Properties as ℕ
open import Data.Nat.Coprimality as C using (Coprime; coprime?)
open import Data.Nat.Divisibility hiding (/-cong)
import Data.Nat.GCD as ℕ
import Data.Nat.DivMod as ℕ
open import Data.Product using (_×_; _,_)
open import Data.Rational.Base
open import Data.Rational.Unnormalised as ℚᵘ
using (ℚᵘ; *≡*; *≤*) renaming (↥_ to ↥ᵘ_; ↧_ to ↧ᵘ_; _≃_ to _≃ᵘ_; _≤_ to _≤ᵘ_)
import Data.Rational.Unnormalised.Properties as ℚᵘ
open import Data.Sum.Base
open import Data.Unit using (tt)
import Data.Sign as S
open import Function using (_∘_ ; _$_; Injective)
open import Level using (0ℓ)
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
open import Relation.Binary.Morphism.Structures
import Relation.Binary.Morphism.OrderMonomorphism as OrderMonomorphisms
open import Relation.Nullary using (yes; no; recompute)
open import Relation.Nullary.Decidable as Dec
using (True; False; fromWitness; fromWitnessFalse)
open import Relation.Nullary.Negation using (contradiction)
open import Relation.Nullary.Decidable as Dec using (True; fromWitness; map′)
open import Relation.Nullary.Product using (_×-dec_)
open import Algebra.Definitions {A = ℚ} _≡_
open import Algebra.Structures {A = ℚ} _≡_
private
infix 4 _≢0
_≢0 : ℕ → Set
n ≢0 = False (n ℕ.≟ 0)
recomputeCP : ∀ {n d} → .(Coprime n d) → Coprime n d
recomputeCP {n} {d} c = recompute (coprime? n d) c
------------------------------------------------------------------------
-- Propositional equality
------------------------------------------------------------------------
mkℚ-injective : ∀ {n₁ n₂ d₁ d₂} .{c₁ : Coprime ∣ n₁ ∣ (suc d₁)}
.{c₂ : Coprime ∣ n₂ ∣ (suc d₂)} →
mkℚ n₁ d₁ c₁ ≡ mkℚ n₂ d₂ c₂ → n₁ ≡ n₂ × d₁ ≡ d₂
mkℚ-injective refl = refl , refl
infix 4 _≟_
_≟_ : Decidable {A = ℚ} _≡_
mkℚ n₁ d₁ _ ≟ mkℚ n₂ d₂ _ =
map′ (λ { (refl , refl) → refl }) mkℚ-injective (n₁ ℤ.≟ n₂ ×-dec d₁ ℕ.≟ d₂)
≡-setoid : Setoid 0ℓ 0ℓ
≡-setoid = setoid ℚ
≡-decSetoid : DecSetoid 0ℓ 0ℓ
≡-decSetoid = decSetoid _≟_
------------------------------------------------------------------------
-- mkℚ
------------------------------------------------------------------------
mkℚ-cong : ∀ {n₁ n₂ d₁ d₂}
.{c₁ : Coprime ∣ n₁ ∣ (suc d₁)}
.{c₂ : Coprime ∣ n₂ ∣ (suc d₂)} →
n₁ ≡ n₂ → d₁ ≡ d₂ → mkℚ n₁ d₁ c₁ ≡ mkℚ n₂ d₂ c₂
mkℚ-cong refl refl = refl
------------------------------------------------------------------------
-- mkℚ′
------------------------------------------------------------------------
mkℚ+-cong : ∀ {n₁ n₂ d₁ d₂} d₁≢0 d₂≢0
.{c₁ : Coprime n₁ d₁}
.{c₂ : Coprime n₂ d₂} →
n₁ ≡ n₂ → d₁ ≡ d₂ →
mkℚ+ n₁ d₁ {d₁≢0} c₁ ≡ mkℚ+ n₂ d₂ {d₂≢0} c₂
mkℚ+-cong _ _ refl refl = refl
↥-mkℚ+ : ∀ n d {d≢0} .{c : Coprime n d} → ↥ (mkℚ+ n d {d≢0} c) ≡ + n
↥-mkℚ+ n (suc d) = refl
↧-mkℚ+ : ∀ n d {d≢0} .{c : Coprime n d} → ↧ (mkℚ+ n d {d≢0} c) ≡ + d
↧-mkℚ+ n (suc d) = refl
------------------------------------------------------------------------
-- Numerator and denominator equality
------------------------------------------------------------------------
≡⇒≃ : _≡_ ⇒ _≃_
≡⇒≃ refl = refl
≃⇒≡ : _≃_ ⇒ _≡_
≃⇒≡ {x = mkℚ n₁ d₁ c₁} {y = mkℚ n₂ d₂ c₂} eq = helper
where
open ≡-Reasoning
1+d₁∣1+d₂ : suc d₁ ∣ suc d₂
1+d₁∣1+d₂ = coprime-divisor (+ suc d₁) n₁ (+ suc d₂)
(C.sym (recomputeCP c₁)) $
divides ∣ n₂ ∣ $ begin
∣ n₁ ℤ.* + suc d₂ ∣ ≡⟨ cong ∣_∣ eq ⟩
∣ n₂ ℤ.* + suc d₁ ∣ ≡⟨ ℤ.abs-*-commute n₂ (+ suc d₁) ⟩
∣ n₂ ∣ ℕ.* suc d₁ ∎
1+d₂∣1+d₁ : suc d₂ ∣ suc d₁
1+d₂∣1+d₁ = coprime-divisor (+ suc d₂) n₂ (+ suc d₁)
(C.sym (recomputeCP c₂)) $
divides ∣ n₁ ∣ (begin
∣ n₂ ℤ.* + suc d₁ ∣ ≡⟨ cong ∣_∣ (sym eq) ⟩
∣ n₁ ℤ.* + suc d₂ ∣ ≡⟨ ℤ.abs-*-commute n₁ (+ suc d₂) ⟩
∣ n₁ ∣ ℕ.* suc d₂ ∎)
helper : mkℚ n₁ d₁ c₁ ≡ mkℚ n₂ d₂ c₂
helper with ∣-antisym 1+d₁∣1+d₂ 1+d₂∣1+d₁
... | refl with ℤ.*-cancelʳ-≡ n₁ n₂ (+ suc d₁) (λ ()) eq
... | refl = refl
------------------------------------------------------------------------
-- Properties of -_
------------------------------------------------------------------------
↥-neg : ∀ p → ↥ (- p) ≡ ℤ.- (↥ p)
↥-neg (mkℚ -[1+ _ ] _ _) = refl
↥-neg (mkℚ +0 _ _) = refl
↥-neg (mkℚ +[1+ _ ] _ _) = refl
↧-neg : ∀ p → ↧ (- p) ≡ ↧ p
↧-neg (mkℚ -[1+ _ ] _ _) = refl
↧-neg (mkℚ +0 _ _) = refl
↧-neg (mkℚ +[1+ _ ] _ _) = refl
------------------------------------------------------------------------
-- Properties of normalize
------------------------------------------------------------------------
normalize-coprime : ∀ {n d-1} .(c : Coprime n (suc d-1)) →
normalize n (suc d-1) ≡ mkℚ (+ n) d-1 c
normalize-coprime {n} {d-1} c = begin
normalize n d ≡⟨⟩
mkℚ+ (n ℕ./ g) (d ℕ./ g) _ ≡⟨ mkℚ+-cong n/g≢0 d/1≢0 {c₂ = c₂} (ℕ./-congʳ {n≢0 = g≢0} g≡1) (ℕ./-congʳ {n≢0 = g≢0} g≡1) ⟩
mkℚ+ (n ℕ./ 1) (d ℕ./ 1) _ ≡⟨ mkℚ+-cong d/1≢0 _ {c₂ = c} (ℕ.n/1≡n n) (ℕ.n/1≡n d) ⟩
mkℚ+ n d _ ≡⟨⟩
mkℚ (+ n) d-1 _ ∎
where
open ≡-Reasoning; d = suc d-1; g = ℕ.gcd n d
c′ = recomputeCP c
c₂ : Coprime (n ℕ./ 1) (d ℕ./ 1)
c₂ = subst₂ Coprime (sym (ℕ.n/1≡n n)) (sym (ℕ.n/1≡n d)) c′
g≡1 = C.coprime⇒gcd≡1 c′
g≢0 = fromWitnessFalse (ℕ.gcd[m,n]≢0 n d (inj₂ λ()))
n/g≢0 = fromWitnessFalse (ℕ.n/gcd[m,n]≢0 n d {_} {g≢0})
d/1≢0 = fromWitnessFalse (subst (_≢ 0) (sym (ℕ.n/1≡n d)) λ())
↥-normalize : ∀ i n {n≢0} → ↥ (normalize i n {n≢0}) ℤ.* gcd (+ i) (+ n) ≡ + i
↥-normalize i n@(suc n-1) = begin
↥ (normalize i n) ℤ.* + g ≡⟨ cong (ℤ._* + g) (↥-mkℚ+ _ (n ℕ./ g) {n/g≢0}) ⟩
+ (i ℕ./ g) ℤ.* + g ≡⟨⟩
S.+ ◃ i ℕ./ g ℕ.* g ≡⟨ cong (S.+ ◃_) (ℕ.m/n*n≡m (ℕ.gcd[m,n]∣m i n)) ⟩
S.+ ◃ i ≡⟨ ℤ.+◃n≡+n i ⟩
+ i ∎
where
open ≡-Reasoning; g = ℕ.gcd i n
g≢0 = fromWitnessFalse (ℕ.gcd[m,n]≢0 i n (inj₂ λ()))
n/g≢0 = fromWitnessFalse (ℕ.n/gcd[m,n]≢0 i n {_} {g≢0})
↧-normalize : ∀ i n {n≢0} → ↧ (normalize i n {n≢0}) ℤ.* gcd (+ i) (+ n) ≡ + n
↧-normalize i n@(suc n-1) = begin
↧ (normalize i n) ℤ.* + g ≡⟨ cong (ℤ._* + g) (↧-mkℚ+ _ (n ℕ./ g) {n/g≢0}) ⟩
+ (n ℕ./ g) ℤ.* + g ≡⟨⟩
S.+ ◃ n ℕ./ g ℕ.* g ≡⟨ cong (S.+ ◃_) (ℕ.m/n*n≡m (ℕ.gcd[m,n]∣n i n)) ⟩
S.+ ◃ n ≡⟨ ℤ.+◃n≡+n n ⟩
+ n ∎
where
open ≡-Reasoning; g = ℕ.gcd i n
g≢0 = fromWitnessFalse (ℕ.gcd[m,n]≢0 i n (inj₂ λ()))
n/g≢0 = fromWitnessFalse (ℕ.n/gcd[m,n]≢0 i n {_} {g≢0})
------------------------------------------------------------------------
-- Properties of toℚ/fromℚ
------------------------------------------------------------------------
toℚᵘ-cong : toℚᵘ Preserves _≡_ ⟶ _≃ᵘ_
toℚᵘ-cong refl = *≡* refl
toℚᵘ-injective : Injective _≡_ _≃ᵘ_ toℚᵘ
toℚᵘ-injective (*≡* eq) = ≃⇒≡ eq
toℚᵘ-isRelHomomorphism : IsRelHomomorphism _≡_ _≃ᵘ_ toℚᵘ
toℚᵘ-isRelHomomorphism = record
{ cong = toℚᵘ-cong
}
toℚᵘ-isRelMonomorphism : IsRelMonomorphism _≡_ _≃ᵘ_ toℚᵘ
toℚᵘ-isRelMonomorphism = record
{ isHomomorphism = toℚᵘ-isRelHomomorphism
; injective = toℚᵘ-injective
}
fromℚᵘ-toℚᵘ : ∀ p → fromℚᵘ (toℚᵘ p) ≡ p
fromℚᵘ-toℚᵘ (mkℚ (+ n) d-1 c) = normalize-coprime c
fromℚᵘ-toℚᵘ (mkℚ (-[1+ n ]) d-1 c) = cong (-_) (normalize-coprime c)
------------------------------------------------------------------------
-- Properties of _≤_
------------------------------------------------------------------------
drop-*≤* : ∀ {p q} → p ≤ q → (↥ p ℤ.* ↧ q) ℤ.≤ (↥ q ℤ.* ↧ p)
drop-*≤* (*≤* pq≤qp) = pq≤qp
------------------------------------------------------------------------
-- toℚᵘ is a isomorphism
toℚᵘ-mono-≤ : ∀ {p q} → p ≤ q → toℚᵘ p ≤ᵘ toℚᵘ q
toℚᵘ-mono-≤ (*≤* p≤q) = *≤* p≤q
toℚᵘ-cancel-≤ : ∀ {p q} → toℚᵘ p ≤ᵘ toℚᵘ q → p ≤ q
toℚᵘ-cancel-≤ (*≤* p≤q) = *≤* p≤q
toℚᵘ-isOrderHomomorphism-≤ : IsOrderHomomorphism _≡_ _≃ᵘ_ _≤_ _≤ᵘ_ toℚᵘ
toℚᵘ-isOrderHomomorphism-≤ = record
{ cong = toℚᵘ-cong
; mono = toℚᵘ-mono-≤
}
toℚᵘ-isOrderMonomorphism-≤ : IsOrderMonomorphism _≡_ _≃ᵘ_ _≤_ _≤ᵘ_ toℚᵘ
toℚᵘ-isOrderMonomorphism-≤ = record
{ isOrderHomomorphism = toℚᵘ-isOrderHomomorphism-≤
; injective = toℚᵘ-injective
; cancel = toℚᵘ-cancel-≤
}
------------------------------------------------------------------------
-- Relational properties
private
module ≤-Monomorphism = OrderMonomorphisms toℚᵘ-isOrderMonomorphism-≤
≤-reflexive : _≡_ ⇒ _≤_
≤-reflexive refl = *≤* ℤ.≤-refl
≤-refl : Reflexive _≤_
≤-refl = ≤-reflexive refl
≤-trans : Transitive _≤_
≤-trans = ≤-Monomorphism.trans ℚᵘ.≤-trans
≤-antisym : Antisymmetric _≡_ _≤_
≤-antisym (*≤* le₁) (*≤* le₂) = ≃⇒≡ (ℤ.≤-antisym le₁ le₂)
≤-total : Total _≤_
≤-total p q = [ inj₁ ∘ *≤* , inj₂ ∘ *≤* ]′ (ℤ.≤-total (↥ p ℤ.* ↧ q) (↥ q ℤ.* ↧ p))
infix 4 _≤?_
_≤?_ : Decidable _≤_
p ≤? q = Dec.map′ *≤* drop-*≤* (↥ p ℤ.* ↧ q ℤ.≤? ↥ q ℤ.* ↧ p)
≤-irrelevant : Irrelevant _≤_
≤-irrelevant (*≤* p≤q₁) (*≤* p≤q₂) = cong *≤* (ℤ.≤-irrelevant p≤q₁ p≤q₂)
------------------------------------------------------------------------
-- Structures
≤-isPreorder : IsPreorder _≡_ _≤_
≤-isPreorder = record
{ isEquivalence = isEquivalence
; reflexive = ≤-reflexive
; trans = ≤-trans
}
≤-isPartialOrder : IsPartialOrder _≡_ _≤_
≤-isPartialOrder = record
{ isPreorder = ≤-isPreorder
; antisym = ≤-antisym
}
≤-isTotalOrder : IsTotalOrder _≡_ _≤_
≤-isTotalOrder = record
{ isPartialOrder = ≤-isPartialOrder
; total = ≤-total
}
≤-isDecTotalOrder : IsDecTotalOrder _≡_ _≤_
≤-isDecTotalOrder = record
{ isTotalOrder = ≤-isTotalOrder
; _≟_ = _≟_
; _≤?_ = _≤?_
}
------------------------------------------------------------------------
-- Bundles
≤-decTotalOrder : DecTotalOrder _ _ _
≤-decTotalOrder = record
{ Carrier = ℚ
; _≈_ = _≡_
; _≤_ = _≤_
; isDecTotalOrder = ≤-isDecTotalOrder
}
------------------------------------------------------------------------
-- Properties of _<_
------------------------------------------------------------------------
drop-*<* : ∀ {p q} → p < q → (↥ p ℤ.* ↧ q) ℤ.< (↥ q ℤ.* ↧ p)
drop-*<* (*<* pq<qp) = pq<qp
------------------------------------------------------------------------
-- Relational properties
<⇒≤ : _<_ ⇒ _≤_
<⇒≤ (*<* p<q) = *≤* (ℤ.<⇒≤ p<q)
<-irrefl : Irreflexive _≡_ _<_
<-irrefl refl (*<* p<p) = ℤ.<-irrefl refl p<p
<-asym : Asymmetric _<_
<-asym (*<* p<q) (*<* q<p) = ℤ.<-asym p<q q<p
<-≤-trans : Trans _<_ _≤_ _<_
<-≤-trans {p} {q} {r} (*<* p<q) (*≤* q≤r) = *<*
(ℤ.*-cancelʳ-<-non-neg _ (begin-strict
let n₁ = ↥ p; n₂ = ↥ q; n₃ = ↥ r; sd₁ = ↧ p; sd₂ = ↧ q; sd₃ = ↧ r in
(n₁ ℤ.* sd₃) ℤ.* sd₂ ≡⟨ ℤ.*-assoc n₁ sd₃ sd₂ ⟩
n₁ ℤ.* (sd₃ ℤ.* sd₂) ≡⟨ cong (n₁ ℤ.*_) (ℤ.*-comm sd₃ sd₂) ⟩
n₁ ℤ.* (sd₂ ℤ.* sd₃) ≡⟨ sym (ℤ.*-assoc n₁ sd₂ sd₃) ⟩
(n₁ ℤ.* sd₂) ℤ.* sd₃ <⟨ ℤ.*-monoʳ-<-pos (ℕ.pred (↧ₙ r)) p<q ⟩
(n₂ ℤ.* sd₁) ℤ.* sd₃ ≡⟨ cong (ℤ._* sd₃) (ℤ.*-comm n₂ sd₁) ⟩
(sd₁ ℤ.* n₂) ℤ.* sd₃ ≡⟨ ℤ.*-assoc sd₁ n₂ sd₃ ⟩
sd₁ ℤ.* (n₂ ℤ.* sd₃) ≤⟨ ℤ.*-monoˡ-≤-pos (ℕ.pred (↧ₙ p)) q≤r ⟩
sd₁ ℤ.* (n₃ ℤ.* sd₂) ≡⟨ sym (ℤ.*-assoc sd₁ n₃ sd₂) ⟩
(sd₁ ℤ.* n₃) ℤ.* sd₂ ≡⟨ cong (ℤ._* sd₂) (ℤ.*-comm sd₁ n₃) ⟩
(n₃ ℤ.* sd₁) ℤ.* sd₂ ∎))
where open ℤ.≤-Reasoning
≤-<-trans : Trans _≤_ _<_ _<_
≤-<-trans {p} {q} {r} (*≤* p≤q) (*<* q<r) = *<*
(ℤ.*-cancelʳ-<-non-neg _ (begin-strict
let n₁ = ↥ p; n₂ = ↥ q; n₃ = ↥ r; sd₁ = ↧ p; sd₂ = ↧ q; sd₃ = ↧ r in
(n₁ ℤ.* sd₃) ℤ.* sd₂ ≡⟨ ℤ.*-assoc n₁ sd₃ sd₂ ⟩
n₁ ℤ.* (sd₃ ℤ.* sd₂) ≡⟨ cong (n₁ ℤ.*_) (ℤ.*-comm sd₃ sd₂) ⟩
n₁ ℤ.* (sd₂ ℤ.* sd₃) ≡⟨ sym (ℤ.*-assoc n₁ sd₂ sd₃) ⟩
(n₁ ℤ.* sd₂) ℤ.* sd₃ ≤⟨ ℤ.*-monoʳ-≤-pos (ℕ.pred (↧ₙ r)) p≤q ⟩
(n₂ ℤ.* sd₁) ℤ.* sd₃ ≡⟨ cong (ℤ._* sd₃) (ℤ.*-comm n₂ sd₁) ⟩
(sd₁ ℤ.* n₂) ℤ.* sd₃ ≡⟨ ℤ.*-assoc sd₁ n₂ sd₃ ⟩
sd₁ ℤ.* (n₂ ℤ.* sd₃) <⟨ ℤ.*-monoˡ-<-pos (ℕ.pred (↧ₙ p)) q<r ⟩
sd₁ ℤ.* (n₃ ℤ.* sd₂) ≡⟨ sym (ℤ.*-assoc sd₁ n₃ sd₂) ⟩
(sd₁ ℤ.* n₃) ℤ.* sd₂ ≡⟨ cong (ℤ._* sd₂) (ℤ.*-comm sd₁ n₃) ⟩
(n₃ ℤ.* sd₁) ℤ.* sd₂ ∎))
where open ℤ.≤-Reasoning
<-trans : Transitive _<_
<-trans p<q = ≤-<-trans (<⇒≤ p<q)
infix 4 _<?_
_<?_ : Decidable _<_
p <? q = Dec.map′ *<* drop-*<* ((↥ p ℤ.* ↧ q) ℤ.<? (↥ q ℤ.* ↧ p))
<-cmp : Trichotomous _≡_ _<_
<-cmp p q with ℤ.<-cmp (↥ p ℤ.* ↧ q) (↥ q ℤ.* ↧ p)
... | tri< < ≢ ≯ = tri< (*<* <) (≢ ∘ ≡⇒≃) (≯ ∘ drop-*<*)
... | tri≈ ≮ ≡ ≯ = tri≈ (≮ ∘ drop-*<*) (≃⇒≡ ≡) (≯ ∘ drop-*<*)
... | tri> ≮ ≢ > = tri> (≮ ∘ drop-*<*) (≢ ∘ ≡⇒≃) (*<* >)
<-irrelevant : Irrelevant _<_
<-irrelevant (*<* p<q₁) (*<* p<q₂) = cong *<* (ℤ.<-irrelevant p<q₁ p<q₂)
<-respʳ-≡ : _<_ Respectsʳ _≡_
<-respʳ-≡ = subst (_ <_)
<-respˡ-≡ : _<_ Respectsˡ _≡_
<-respˡ-≡ = subst (_< _)
<-resp-≡ : _<_ Respects₂ _≡_
<-resp-≡ = <-respʳ-≡ , <-respˡ-≡
------------------------------------------------------------------------
-- Structures
<-isStrictPartialOrder : IsStrictPartialOrder _≡_ _<_
<-isStrictPartialOrder = record
{ isEquivalence = isEquivalence
; irrefl = <-irrefl
; trans = <-trans
; <-resp-≈ = <-resp-≡
}
<-isStrictTotalOrder : IsStrictTotalOrder _≡_ _<_
<-isStrictTotalOrder = record
{ isEquivalence = isEquivalence
; trans = <-trans
; compare = <-cmp
}
------------------------------------------------------------------------
-- Bundles
<-strictPartialOrder : StrictPartialOrder 0ℓ 0ℓ 0ℓ
<-strictPartialOrder = record
{ isStrictPartialOrder = <-isStrictPartialOrder
}
<-strictTotalOrder : StrictTotalOrder 0ℓ 0ℓ 0ℓ
<-strictTotalOrder = record
{ isStrictTotalOrder = <-isStrictTotalOrder
}
------------------------------------------------------------------------
-- A specialised module for reasoning about the _≤_ and _<_ relations
------------------------------------------------------------------------
module ≤-Reasoning where
open import Relation.Binary.Reasoning.Base.Triple
≤-isPreorder
<-trans
(resp₂ _<_)
<⇒≤
<-≤-trans
≤-<-trans
public
hiding (step-≈; step-≈˘)
------------------------------------------------------------------------
-- Properties of _/_
------------------------------------------------------------------------
↥-/ : ∀ i n {n≢0} → ↥ (i / n) {n≢0} ℤ.* gcd i (+ n) ≡ i
↥-/ (+ m) (suc n) = ↥-normalize m (suc n)
↥-/ -[1+ m ] (suc n) = begin-equality
↥ (- norm) ℤ.* + g ≡⟨ cong (ℤ._* + g) (↥-neg norm) ⟩
ℤ.- (↥ norm) ℤ.* + g ≡⟨ sym (ℤ.neg-distribˡ-* (↥ norm) (+ g)) ⟩
ℤ.- (↥ norm ℤ.* + g) ≡⟨ cong (ℤ.-_) (↥-normalize (suc m) (suc n)) ⟩
S.- ◃ suc m ≡⟨⟩
-[1+ m ] ∎
where
open ℤ.≤-Reasoning
g = ℕ.gcd (suc m) (suc n)
norm = normalize (suc m) (suc n)
↧-/ : ∀ i n {n≢0} → ↧ (i / n) {n≢0} ℤ.* gcd i (+ n) ≡ + n
↧-/ (+ m) (suc n) = ↧-normalize m (suc n)
↧-/ -[1+ m ] (suc n) = begin-equality
↧ (- norm) ℤ.* + g ≡⟨ cong (ℤ._* + g) (↧-neg norm) ⟩
↧ norm ℤ.* + g ≡⟨ ↧-normalize (suc m) (suc n) ⟩
+ (suc n) ∎
where
open ℤ.≤-Reasoning
g = ℕ.gcd (suc m) (suc n)
norm = normalize (suc m) (suc n)
↥p/↧p≡p : ∀ p → ↥ p / ↧ₙ p ≡ p
↥p/↧p≡p (mkℚ (+ n) d-1 prf) = normalize-coprime prf
↥p/↧p≡p (mkℚ -[1+ n ] d-1 prf) = cong (-_) (normalize-coprime prf)
0/n≡0 : ∀ n {n≢0} → (0ℤ / n) {n≢0} ≡ 0ℚ
0/n≡0 n@(suc n-1) {n≢0} = mkℚ+-cong n/n≢0 _ {c₂ = 0-cop-1} (ℕ.0/n≡0 (ℕ.gcd 0 n)) (ℕ.n/n≡1 n)
where
n/n≢0 = subst _≢0 (sym (ℕ.n/n≡1 n)) _
0-cop-1 = C.sym (C.1-coprimeTo 0)
------------------------------------------------------------------------
-- Properties of _+_
------------------------------------------------------------------------
private
↥+ᵘ : ℚ → ℚ → ℤ
↥+ᵘ p q = ↥ p ℤ.* ↧ q ℤ.+ ↥ q ℤ.* ↧ p
↧+ᵘ : ℚ → ℚ → ℤ
↧+ᵘ p q = ↧ p ℤ.* ↧ q
+-nf : ℚ → ℚ → ℤ
+-nf p q = gcd (↥+ᵘ p q) (↧+ᵘ p q)
↥-+ : ∀ p q → ↥ (p + q) ℤ.* +-nf p q ≡ ↥+ᵘ p q
↥-+ p q = ↥-/ (↥+ᵘ p q) (↧ₙ p ℕ.* ↧ₙ q)
↧-+ : ∀ p q → ↧ (p + q) ℤ.* +-nf p q ≡ ↧+ᵘ p q
↧-+ p q = ↧-/ (↥+ᵘ p q) (↧ₙ p ℕ.* ↧ₙ q)
------------------------------------------------------------------------
-- Raw bundles
+-rawMagma : RawMagma 0ℓ 0ℓ
+-rawMagma = record
{ _≈_ = _≡_
; _∙_ = _+_
}
+-rawMonoid : RawMonoid 0ℓ 0ℓ
+-rawMonoid = record
{ _≈_ = _≡_
; _∙_ = _+_
; ε = 0ℚ
}
+-0-rawGroup : RawGroup 0ℓ 0ℓ
+-0-rawGroup = record
{ _≈_ = _≡_
; _∙_ = _+_
; ε = 0ℚ
; _⁻¹ = -_
}
+-*-rawRing : RawRing 0ℓ 0ℓ
+-*-rawRing = record
{ _≈_ = _≡_
; _+_ = _+_
; _*_ = _*_
; -_ = -_
; 0# = 0ℚ
; 1# = 1ℚ
}
------------------------------------------------------------------------
-- Monomorphic to unnormalised _+_
open Definitions ℚ ℚᵘ ℚᵘ._≃_
toℚᵘ-homo-+ : Homomorphic₂ toℚᵘ _+_ ℚᵘ._+_
toℚᵘ-homo-+ p q with +-nf p q ℤ.≟ 0ℤ
... | yes nf[p,q]≡0 = *≡* (begin
↥ (p + q) ℤ.* ↧+ᵘ p q ≡⟨ cong (ℤ._* ↧+ᵘ p q) eq ⟩
0ℤ ℤ.* ↧+ᵘ p q ≡⟨⟩
0ℤ ℤ.* ↧ (p + q) ≡⟨ cong (ℤ._* ↧ (p + q)) (sym eq2) ⟩
↥+ᵘ p q ℤ.* ↧ (p + q) ∎)
where
open ≡-Reasoning
eq2 : ↥+ᵘ p q ≡ 0ℤ
eq2 = gcd[i,j]≡0⇒i≡0 (↥+ᵘ p q) (↧+ᵘ p q) nf[p,q]≡0
eq : ↥ (p + q) ≡ 0ℤ
eq rewrite eq2 = cong ↥_ (0/n≡0 (↧ₙ p ℕ.* ↧ₙ q))
... | no nf[p,q]≢0 = *≡* (ℤ.*-cancelʳ-≡ _ _ (+-nf p q) nf[p,q]≢0 (begin
↥ (p + q) ℤ.* ↧+ᵘ p q ℤ.* +-nf p q ≡⟨ xy∙z≈xz∙y (↥ (p + q)) _ _ ⟩
↥ (p + q) ℤ.* +-nf p q ℤ.* ↧+ᵘ p q ≡⟨ cong (ℤ._* ↧+ᵘ p q) (↥-+ p q) ⟩
↥+ᵘ p q ℤ.* ↧+ᵘ p q ≡⟨ cong (↥+ᵘ p q ℤ.*_) (sym (↧-+ p q)) ⟩
↥+ᵘ p q ℤ.* (↧ (p + q) ℤ.* +-nf p q) ≡⟨ x∙yz≈xy∙z (↥+ᵘ p q) _ _ ⟩
↥+ᵘ p q ℤ.* ↧ (p + q) ℤ.* +-nf p q ∎))
where open ≡-Reasoning; open CommSemigroupProperties ℤ.*-commutativeSemigroup
toℚᵘ-isMagmaHomomorphism-+ : IsMagmaHomomorphism +-rawMagma ℚᵘ.+-rawMagma toℚᵘ
toℚᵘ-isMagmaHomomorphism-+ = record
{ isRelHomomorphism = toℚᵘ-isRelHomomorphism
; homo = toℚᵘ-homo-+
}
toℚᵘ-isMonoidHomomorphism-+ : IsMonoidHomomorphism +-rawMonoid ℚᵘ.+-rawMonoid toℚᵘ
toℚᵘ-isMonoidHomomorphism-+ = record
{ isMagmaHomomorphism = toℚᵘ-isMagmaHomomorphism-+
; ε-homo = ℚᵘ.≃-refl
}
toℚᵘ-isMonoidMonomorphism-+ : IsMonoidMonomorphism +-rawMonoid ℚᵘ.+-rawMonoid toℚᵘ
toℚᵘ-isMonoidMonomorphism-+ = record
{ isMonoidHomomorphism = toℚᵘ-isMonoidHomomorphism-+
; injective = toℚᵘ-injective
}
------------------------------------------------------------------------
-- Monomorphic to unnormalised -_
toℚᵘ-homo‿- : Homomorphic₁ toℚᵘ (-_) (ℚᵘ.-_)
toℚᵘ-homo‿- (mkℚ +0 _ _) = *≡* refl
toℚᵘ-homo‿- (mkℚ +[1+ _ ] _ _) = *≡* refl
toℚᵘ-homo‿- (mkℚ -[1+ _ ] _ _) = *≡* refl
toℚᵘ-isGroupHomomorphism-+ : IsGroupHomomorphism +-0-rawGroup ℚᵘ.+-0-rawGroup toℚᵘ
toℚᵘ-isGroupHomomorphism-+ = record
{ isMonoidHomomorphism = toℚᵘ-isMonoidHomomorphism-+
; ⁻¹-homo = toℚᵘ-homo‿-
}
toℚᵘ-isGroupMonomorphism-+ : IsGroupMonomorphism +-0-rawGroup ℚᵘ.+-0-rawGroup toℚᵘ
toℚᵘ-isGroupMonomorphism-+ = record
{ isGroupHomomorphism = toℚᵘ-isGroupHomomorphism-+
; injective = toℚᵘ-injective
}
------------------------------------------------------------------------
-- Algebraic properties
private
module +-Monomorphism = GroupMonomorphisms toℚᵘ-isGroupMonomorphism-+
+-assoc : Associative _+_
+-assoc = +-Monomorphism.assoc ℚᵘ.+-isMagma ℚᵘ.+-assoc
+-comm : Commutative _+_
+-comm = +-Monomorphism.comm ℚᵘ.+-isMagma ℚᵘ.+-comm
+-identityˡ : LeftIdentity 0ℚ _+_
+-identityˡ = +-Monomorphism.identityˡ ℚᵘ.+-isMagma ℚᵘ.+-identityˡ
+-identityʳ : RightIdentity 0ℚ _+_
+-identityʳ = +-Monomorphism.identityʳ ℚᵘ.+-isMagma ℚᵘ.+-identityʳ
+-identity : Identity 0ℚ _+_
+-identity = +-identityˡ , +-identityʳ
+-inverseˡ : LeftInverse 0ℚ -_ _+_
+-inverseˡ = +-Monomorphism.inverseˡ ℚᵘ.+-isMagma ℚᵘ.+-inverseˡ
+-inverseʳ : RightInverse 0ℚ -_ _+_
+-inverseʳ = +-Monomorphism.inverseʳ ℚᵘ.+-isMagma ℚᵘ.+-inverseʳ
+-inverse : Inverse 0ℚ -_ _+_
+-inverse = +-Monomorphism.inverse ℚᵘ.+-isMagma ℚᵘ.+-inverse
-‿cong : Congruent₁ (-_)
-‿cong = +-Monomorphism.⁻¹-cong ℚᵘ.+-isMagma ℚᵘ.-‿cong
------------------------------------------------------------------------
-- Structures
+-isMagma : IsMagma _+_
+-isMagma = +-Monomorphism.isMagma ℚᵘ.+-isMagma
+-isSemigroup : IsSemigroup _+_
+-isSemigroup = +-Monomorphism.isSemigroup ℚᵘ.+-isSemigroup
+-0-isMonoid : IsMonoid _+_ 0ℚ
+-0-isMonoid = +-Monomorphism.isMonoid ℚᵘ.+-0-isMonoid
+-0-isCommutativeMonoid : IsCommutativeMonoid _+_ 0ℚ
+-0-isCommutativeMonoid = +-Monomorphism.isCommutativeMonoid ℚᵘ.+-0-isCommutativeMonoid
+-0-isGroup : IsGroup _+_ 0ℚ (-_)
+-0-isGroup = +-Monomorphism.isGroup ℚᵘ.+-0-isGroup
+-0-isAbelianGroup : IsAbelianGroup _+_ 0ℚ (-_)
+-0-isAbelianGroup = +-Monomorphism.isAbelianGroup ℚᵘ.+-0-isAbelianGroup
------------------------------------------------------------------------
-- Packages
+-magma : Magma 0ℓ 0ℓ
+-magma = record
{ isMagma = +-isMagma
}
+-semigroup : Semigroup 0ℓ 0ℓ
+-semigroup = record
{ isSemigroup = +-isSemigroup
}
+-0-monoid : Monoid 0ℓ 0ℓ
+-0-monoid = record
{ isMonoid = +-0-isMonoid
}
+-0-commutativeMonoid : CommutativeMonoid 0ℓ 0ℓ
+-0-commutativeMonoid = record
{ isCommutativeMonoid = +-0-isCommutativeMonoid
}
+-0-group : Group 0ℓ 0ℓ
+-0-group = record
{ isGroup = +-0-isGroup
}
+-0-abelianGroup : AbelianGroup 0ℓ 0ℓ
+-0-abelianGroup = record
{ isAbelianGroup = +-0-isAbelianGroup
}
------------------------------------------------------------------------
-- Properties of _*_
------------------------------------------------------------------------
private
*-nf : ℚ → ℚ → ℤ
*-nf p q = gcd (↥ p ℤ.* ↥ q) (↧ p ℤ.* ↧ q)
↥-* : ∀ p q → ↥ (p * q) ℤ.* *-nf p q ≡ ↥ p ℤ.* ↥ q
↥-* p q = ↥-/ (↥ p ℤ.* ↥ q) (↧ₙ p ℕ.* ↧ₙ q)
↧-* : ∀ p q → ↧ (p * q) ℤ.* *-nf p q ≡ ↧ p ℤ.* ↧ q
↧-* p q = ↧-/ (↥ p ℤ.* ↥ q) (↧ₙ p ℕ.* ↧ₙ q)
------------------------------------------------------------------------
-- Raw bundles
*-rawMagma : RawMagma 0ℓ 0ℓ
*-rawMagma = record
{ _≈_ = _≡_
; _∙_ = _*_
}
*-rawMonoid : RawMonoid 0ℓ 0ℓ
*-rawMonoid = record
{ _≈_ = _≡_
; _∙_ = _*_
; ε = 1ℚ
}
------------------------------------------------------------------------
-- Monomorphic to unnormalised _*_
toℚᵘ-homo-* : Homomorphic₂ toℚᵘ _*_ ℚᵘ._*_
toℚᵘ-homo-* p q with *-nf p q ℤ.≟ 0ℤ
... | yes nf[p,q]≡0 = *≡* (begin
↥ (p * q) ℤ.* (↧ p ℤ.* ↧ q) ≡⟨ cong (ℤ._* (↧ p ℤ.* ↧ q)) eq ⟩
0ℤ ℤ.* (↧ p ℤ.* ↧ q) ≡⟨⟩
0ℤ ℤ.* ↧ (p * q) ≡⟨ cong (ℤ._* ↧ (p * q)) (sym eq2) ⟩
(↥ p ℤ.* ↥ q) ℤ.* ↧ (p * q) ∎)
where
open ≡-Reasoning
eq2 : ↥ p ℤ.* ↥ q ≡ 0ℤ
eq2 = gcd[i,j]≡0⇒i≡0 (↥ p ℤ.* ↥ q) (↧ p ℤ.* ↧ q) nf[p,q]≡0
eq : ↥ (p * q) ≡ 0ℤ
eq rewrite eq2 = cong ↥_ (0/n≡0 (↧ₙ p ℕ.* ↧ₙ q))
... | no nf[p,q]≢0 = *≡* (ℤ.*-cancelʳ-≡ _ _ (*-nf p q) nf[p,q]≢0 (begin
↥ (p * q) ℤ.* (↧ p ℤ.* ↧ q) ℤ.* *-nf p q ≡⟨ xy∙z≈xz∙y (↥ (p * q)) _ _ ⟩
↥ (p * q) ℤ.* *-nf p q ℤ.* (↧ p ℤ.* ↧ q) ≡⟨ cong (ℤ._* (↧ p ℤ.* ↧ q)) (↥-* p q) ⟩
(↥ p ℤ.* ↥ q) ℤ.* (↧ p ℤ.* ↧ q) ≡⟨ cong ((↥ p ℤ.* ↥ q) ℤ.*_) (sym (↧-* p q)) ⟩
(↥ p ℤ.* ↥ q) ℤ.* (↧ (p * q) ℤ.* *-nf p q) ≡⟨ x∙yz≈xy∙z (↥ p ℤ.* ↥ q) _ _ ⟩
(↥ p ℤ.* ↥ q) ℤ.* ↧ (p * q) ℤ.* *-nf p q ∎))
where open ≡-Reasoning; open CommSemigroupProperties ℤ.*-commutativeSemigroup
toℚᵘ-isMagmaHomomorphism-* : IsMagmaHomomorphism *-rawMagma ℚᵘ.*-rawMagma toℚᵘ
toℚᵘ-isMagmaHomomorphism-* = record
{ isRelHomomorphism = toℚᵘ-isRelHomomorphism
; homo = toℚᵘ-homo-*
}
toℚᵘ-isMonoidHomomorphism-* : IsMonoidHomomorphism *-rawMonoid ℚᵘ.*-rawMonoid toℚᵘ
toℚᵘ-isMonoidHomomorphism-* = record
{ isMagmaHomomorphism = toℚᵘ-isMagmaHomomorphism-*
; ε-homo = ℚᵘ.≃-refl
}
toℚᵘ-isMonoidMonomorphism-* : IsMonoidMonomorphism *-rawMonoid ℚᵘ.*-rawMonoid toℚᵘ
toℚᵘ-isMonoidMonomorphism-* = record
{ isMonoidHomomorphism = toℚᵘ-isMonoidHomomorphism-*
; injective = toℚᵘ-injective
}
toℚᵘ-isRingHomomorphism-+-* : IsRingHomomorphism +-*-rawRing ℚᵘ.+-*-rawRing toℚᵘ
toℚᵘ-isRingHomomorphism-+-* = record
{ +-isGroupHomomorphism = toℚᵘ-isGroupHomomorphism-+
; *-isMonoidHomomorphism = toℚᵘ-isMonoidHomomorphism-*
}
toℚᵘ-isRingMonomorphism-+-* : IsRingMonomorphism +-*-rawRing ℚᵘ.+-*-rawRing toℚᵘ
toℚᵘ-isRingMonomorphism-+-* = record
{ isRingHomomorphism = toℚᵘ-isRingHomomorphism-+-*
; injective = toℚᵘ-injective
}
------------------------------------------------------------------------
-- Algebraic properties
private
module *-Monomorphism = RingMonomorphisms toℚᵘ-isRingMonomorphism-+-*
*-assoc : Associative _*_
*-assoc = *-Monomorphism.*-assoc ℚᵘ.*-isMagma ℚᵘ.*-assoc
*-comm : Commutative _*_
*-comm = *-Monomorphism.*-comm ℚᵘ.*-isMagma ℚᵘ.*-comm
*-identityˡ : LeftIdentity 1ℚ _*_
*-identityˡ = *-Monomorphism.*-identityˡ ℚᵘ.*-isMagma ℚᵘ.*-identityˡ
*-identityʳ : RightIdentity 1ℚ _*_
*-identityʳ = *-Monomorphism.*-identityʳ ℚᵘ.*-isMagma ℚᵘ.*-identityʳ
*-identity : Identity 1ℚ _*_
*-identity = *-identityˡ , *-identityʳ
*-distribˡ-+ : _*_ DistributesOverˡ _+_
*-distribˡ-+ = *-Monomorphism.distribˡ ℚᵘ.+-0-isGroup ℚᵘ.*-isMagma ℚᵘ.*-distribˡ-+
*-distribʳ-+ : _*_ DistributesOverʳ _+_
*-distribʳ-+ = *-Monomorphism.distribʳ ℚᵘ.+-0-isGroup ℚᵘ.*-isMagma ℚᵘ.*-distribʳ-+
*-distrib-+ : _*_ DistributesOver _+_
*-distrib-+ = *-distribˡ-+ , *-distribʳ-+
------------------------------------------------------------------------
-- Structures
*-isMagma : IsMagma _*_
*-isMagma = *-Monomorphism.*-isMagma ℚᵘ.*-isMagma
*-isSemigroup : IsSemigroup _*_
*-isSemigroup = *-Monomorphism.*-isSemigroup ℚᵘ.*-isSemigroup
*-1-isMonoid : IsMonoid _*_ 1ℚ
*-1-isMonoid = *-Monomorphism.*-isMonoid ℚᵘ.*-1-isMonoid
*-1-isCommutativeMonoid : IsCommutativeMonoid _*_ 1ℚ
*-1-isCommutativeMonoid = *-Monomorphism.*-isCommutativeMonoid ℚᵘ.*-1-isCommutativeMonoid
+-*-isRing : IsRing _+_ _*_ -_ 0ℚ 1ℚ
+-*-isRing = *-Monomorphism.isRing ℚᵘ.+-*-isRing
------------------------------------------------------------------------
-- Packages
*-magma : Magma 0ℓ 0ℓ
*-magma = record
{ isMagma = *-isMagma
}
*-semigroup : Semigroup 0ℓ 0ℓ
*-semigroup = record
{ isSemigroup = *-isSemigroup
}
*-1-monoid : Monoid 0ℓ 0ℓ
*-1-monoid = record
{ isMonoid = *-1-isMonoid
}
*-1-commutativeMonoid : CommutativeMonoid 0ℓ 0ℓ
*-1-commutativeMonoid = record
{ isCommutativeMonoid = *-1-isCommutativeMonoid
}
+-*-ring : Ring 0ℓ 0ℓ
+-*-ring = record
{ isRing = +-*-isRing
}
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 1.0
≤-irrelevance = ≤-irrelevant
{-# WARNING_ON_USAGE ≤-irrelevance
"Warning: ≤-irrelevance was deprecated in v1.0.
Please use ≤-irrelevant instead."
#-}
| {
"alphanum_fraction": 0.4918068445,
"avg_line_length": 31.889017341,
"ext": "agda",
"hexsha": "6e2946baa525047f75cb30296a989005961d791f",
"lang": "Agda",
"max_forks_count": 1,
"max_forks_repo_forks_event_max_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_forks_event_min_datetime": "2021-11-04T06:54:45.000Z",
"max_forks_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_forks_repo_licenses": [
"MIT"
],
"max_forks_repo_name": "DreamLinuxer/popl21-artifact",
"max_forks_repo_path": "agda-stdlib/src/Data/Rational/Properties.agda",
"max_issues_count": null,
"max_issues_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_issues_repo_issues_event_max_datetime": null,
"max_issues_repo_issues_event_min_datetime": null,
"max_issues_repo_licenses": [
"MIT"
],
"max_issues_repo_name": "DreamLinuxer/popl21-artifact",
"max_issues_repo_path": "agda-stdlib/src/Data/Rational/Properties.agda",
"max_line_length": 121,
"max_stars_count": 5,
"max_stars_repo_head_hexsha": "fb380f2e67dcb4a94f353dbaec91624fcb5b8933",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "DreamLinuxer/popl21-artifact",
"max_stars_repo_path": "agda-stdlib/src/Data/Rational/Properties.agda",
"max_stars_repo_stars_event_max_datetime": "2020-10-10T21:41:32.000Z",
"max_stars_repo_stars_event_min_datetime": "2020-10-07T12:07:53.000Z",
"num_tokens": 12471,
"size": 27584
} |
{-# OPTIONS --cubical --safe #-}
module Algebra.Construct.Free.Semilattice.Relation.Unary.Any.Dec where
open import Prelude hiding (⊥; ⊤)
open import Algebra.Construct.Free.Semilattice.Eliminators
open import Algebra.Construct.Free.Semilattice.Definition
open import Cubical.Foundations.HLevels
open import Data.Empty.UniversePolymorphic
open import HITs.PropositionalTruncation.Sugar
open import HITs.PropositionalTruncation.Properties
open import HITs.PropositionalTruncation
open import Data.Unit.UniversePolymorphic
open import Algebra.Construct.Free.Semilattice.Relation.Unary.Any.Def
open import Relation.Nullary
open import Relation.Nullary.Decidable
open import Relation.Nullary.Decidable.Properties
open import Relation.Nullary.Decidable.Logic
private
variable p : Level
◇? : ∀ {P : A → Type p} → (∀ x → Dec (P x)) → (xs : 𝒦 A) → Dec (◇ P xs)
◇? {A = A} {P = P} P? = 𝒦-elim-prop (λ {xs} → isPropDec (isProp-◇ {P = P} {xs = xs})) (λ x xs → fn x xs (P? x)) (no (Poly⊥⇔Mono⊥ .fun))
where
fn : ∀ x xs → Dec (P x) → Dec (◇ P xs) → Dec (◇ P (x ∷ xs))
fn x xs (yes Px) Pxs = yes ∣ inl Px ∣
fn x xs (no ¬Px) (yes Pxs) = yes ∣ inr Pxs ∣
fn x xs (no ¬Px) (no ¬Pxs) = no (refute-trunc (either′ ¬Px ¬Pxs))
| {
"alphanum_fraction": 0.7054963084,
"avg_line_length": 40.6333333333,
"ext": "agda",
"hexsha": "651a10a5fab9d039afa36f682f8f3ea2d685826c",
"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/Algebra/Construct/Free/Semilattice/Relation/Unary/Any/Dec.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/Algebra/Construct/Free/Semilattice/Relation/Unary/Any/Dec.agda",
"max_line_length": 135,
"max_stars_count": 6,
"max_stars_repo_head_hexsha": "3c176d4690566d81611080e9378f5a178b39b851",
"max_stars_repo_licenses": [
"MIT"
],
"max_stars_repo_name": "oisdk/combinatorics-paper",
"max_stars_repo_path": "agda/Algebra/Construct/Free/Semilattice/Relation/Unary/Any/Dec.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": 417,
"size": 1219
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.