hexsha
stringlengths 40
40
| size
int64 3
1.05M
| ext
stringclasses 163
values | lang
stringclasses 53
values | max_stars_repo_path
stringlengths 3
945
| max_stars_repo_name
stringlengths 4
112
| max_stars_repo_head_hexsha
stringlengths 40
78
| max_stars_repo_licenses
listlengths 1
10
| max_stars_count
float64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 3
945
| max_issues_repo_name
stringlengths 4
113
| max_issues_repo_head_hexsha
stringlengths 40
78
| max_issues_repo_licenses
listlengths 1
10
| max_issues_count
float64 1
116k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 3
945
| max_forks_repo_name
stringlengths 4
113
| max_forks_repo_head_hexsha
stringlengths 40
78
| max_forks_repo_licenses
listlengths 1
10
| max_forks_count
float64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 3
1.05M
| avg_line_length
float64 1
966k
| max_line_length
int64 1
977k
| alphanum_fraction
float64 0
1
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
dc5d9c1bbbe51afcc95e90caffe84119b9b4b2e1
| 1,100
|
agda
|
Agda
|
test/interaction/Issue373.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2019-11-27T04:41:05.000Z
|
2019-11-27T04:41:05.000Z
|
test/interaction/Issue373.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/interaction/Issue373.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
module Issue373 where
data ⊤ : Set where
tt : ⊤
{-# COMPILED_DATA ⊤ () () #-}
data ℕ : Set where
zero : ℕ
suc : (n : ℕ) → ℕ
{-# BUILTIN NATURAL ℕ #-}
{-# BUILTIN ZERO zero #-}
{-# BUILTIN SUC suc #-}
{-# IMPORT Imports.Nat #-}
{-# COMPILED_DATA ℕ Imports.Nat.Nat Imports.Nat.Zero Imports.Nat.Suc #-}
data List (A : Set) : Set where
[] : List A
_∷_ : A → List A → List A
{-# BUILTIN LIST List #-}
{-# BUILTIN NIL [] #-}
{-# BUILTIN CONS _∷_ #-}
{-# COMPILED_DATA List [] [] (:) #-}
postulate
String : Set
{-# BUILTIN STRING String #-}
{-# COMPILED_TYPE String String #-}
postulate
IO : Set → Set
{-# BUILTIN IO IO #-}
{-# COMPILED_TYPE IO IO #-}
infixl 1 _>>=_
postulate
_>>=_ : ∀ {A B} → IO A → (A → IO B) → IO B
{-# COMPILED _>>=_ (\_ _ -> (>>=) :: IO a -> (a -> IO b) -> IO b) #-}
postulate
putStrLn : String → IO ⊤
{-# COMPILED putStrLn putStrLn #-}
f : ℕ → String
f zero = "bad"
f _ = "ok"
-- Works:
-- main = putStrLn (f (suc zero))
-- Compiles, but when the program is run we (used to) get the output
-- "bad":
main = putStrLn (f 1)
| 17.460317
| 72
| 0.543636
|
dfbb13bbd225e822ff6a2a00d9b154b5ac8b3fb2
| 1,641
|
agda
|
Agda
|
Cubical/Data/HomotopyGroup/Base.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
Cubical/Data/HomotopyGroup/Base.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | 1
|
2022-01-27T02:07:48.000Z
|
2022-01-27T02:07:48.000Z
|
Cubical/Data/HomotopyGroup/Base.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Data.HomotopyGroup.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
import Cubical.Foundations.GroupoidLaws as GL
open import Cubical.Foundations.Pointed
open import Cubical.Data.Nat
open import Cubical.Algebra.Group
open import Cubical.Homotopy.Loopspace
open import Cubical.HITs.SetTruncation as SetTrunc
π^_ : ∀ {ℓ} → ℕ → Pointed ℓ → Group
π^_ {ℓ} n p = makeGroup e _⨀_ _⁻¹ setTruncIsSet assoc rUnit lUnit rCancel lCancel
where
n' : ℕ
n' = suc n
A : Type ℓ
A = typ ((Ω^ n') p)
e : ∥ A ∥₂
e = ∣ pt ((Ω^ n') p) ∣₂
_⁻¹ : ∥ A ∥₂ → ∥ A ∥₂
_⁻¹ = SetTrunc.elim {B = λ _ → ∥ A ∥₂} (λ x → squash₂) λ a → ∣ sym a ∣₂
_⨀_ : ∥ A ∥₂ → ∥ A ∥₂ → ∥ A ∥₂
_⨀_ = SetTrunc.elim2 (λ _ _ → squash₂) λ a₀ a₁ → ∣ a₀ ∙ a₁ ∣₂
lUnit : (a : ∥ A ∥₂) → (e ⨀ a) ≡ a
lUnit = SetTrunc.elim (λ _ → isProp→isSet (squash₂ _ _))
(λ a → cong ∣_∣₂ (sym (GL.lUnit a) ))
rUnit : (a : ∥ A ∥₂) → a ⨀ e ≡ a
rUnit = SetTrunc.elim (λ _ → isProp→isSet (squash₂ _ _))
(λ a → cong ∣_∣₂ (sym (GL.rUnit a) ))
assoc : (a b c : ∥ A ∥₂) → a ⨀ (b ⨀ c) ≡ (a ⨀ b) ⨀ c
assoc = SetTrunc.elim3 (λ _ _ _ → isProp→isSet (squash₂ _ _))
(λ a b c → cong ∣_∣₂ (GL.assoc _ _ _))
lCancel : (a : ∥ A ∥₂) → ((a ⁻¹) ⨀ a) ≡ e
lCancel = SetTrunc.elim (λ _ → isProp→isSet (squash₂ _ _))
λ a → cong ∣_∣₂ (GL.lCancel _)
rCancel : (a : ∥ A ∥₂) → (a ⨀ (a ⁻¹)) ≡ e
rCancel = SetTrunc.elim (λ _ → isProp→isSet (squash₂ _ _))
λ a → cong ∣_∣₂ (GL.rCancel _)
| 30.962264
| 81
| 0.551493
|
4158eb7435fa73af60363bf3314cfc238ed15369
| 2,087
|
agda
|
Agda
|
src/Data/QuadTree/FunctorProofs/Valid-QuadTreeFunctor.agda
|
JonathanBrouwer/research-project
|
4959a3c9cd8563a1726e0e968e6a179008cd4d9f
|
[
"Unlicense"
] | 1
|
2021-05-25T09:10:20.000Z
|
2021-05-25T09:10:20.000Z
|
src/Data/QuadTree/FunctorProofs/Valid-QuadTreeFunctor.agda
|
JonathanBrouwer/research-project
|
4959a3c9cd8563a1726e0e968e6a179008cd4d9f
|
[
"Unlicense"
] | null | null | null |
src/Data/QuadTree/FunctorProofs/Valid-QuadTreeFunctor.agda
|
JonathanBrouwer/research-project
|
4959a3c9cd8563a1726e0e968e6a179008cd4d9f
|
[
"Unlicense"
] | null | null | null |
-- {-# OPTIONS --show-implicit --show-irrelevant #-}
module Data.QuadTree.FunctorProofs.Valid-QuadTreeFunctor where
open import Haskell.Prelude renaming (zero to Z; suc to S)
open import Data.Logic
open import Data.QuadTree.InternalAgda
open import Agda.Primitive
open import Data.QuadTree.FunctorProofs.FunctorLaws
open import Data.QuadTree.FunctorProofs.Valid-QuadrantFunctor
open import Data.QuadTree.Implementation.Definition
open import Data.QuadTree.Implementation.ValidTypes
open import Data.QuadTree.Implementation.Functors
open import Data.QuadTree.Implementation.QuadrantLenses
ValidFunctor-QuadTree-IdentityLaw : (dep : Nat) -> IdentityLaw (λ y -> VQuadTree y {dep}) {{quadtreeFunctor dep}}
ValidFunctor-QuadTree-IdentityLaw dep (CVQuadTree (Wrapper (w , h) qd) {p}) =
begin
toQt dep w h _ (fmapₑ (quadrantFunctor dep) id (CVQuadrant qd))
=⟨ cong (toQt dep w h _) (ValidFunctor-Quadrant-IdentityLaw dep (CVQuadrant qd)) ⟩
toQt dep w h _ (CVQuadrant qd)
end
toQt-fmap : {a b : Set} {{eqA : Eq a}} {{eqB : Eq b}} (dep w h : Nat) (g : a -> b) (v : VQuadrant a {dep}) .(q : IsTrue (dep == log2up (if w < h then h else w)))
-> toQt dep w h q (fmapₑ (quadrantFunctor dep) g v)
≡ fmapₑ (quadtreeFunctor dep) g (toQt dep w h q v)
toQt-fmap dep w h g (CVQuadrant (Leaf x)) q = refl
toQt-fmap dep w h g (CVQuadrant (Node qd qd₁ qd₂ qd₃)) q = refl
ValidFunctor-QuadTree-CompositionLaw : (dep : Nat) -> CompositionLaw (λ y -> VQuadTree y {dep}) {{quadtreeFunctor dep}}
ValidFunctor-QuadTree-CompositionLaw dep (CVQuadTree (Wrapper (w , h) qd) {p} {q}) f g =
begin
toQt dep w h _ (fmapₑ (quadrantFunctor dep) (g ∘ f) (CVQuadrant qd))
=⟨ cong (toQt dep w h _) (ValidFunctor-Quadrant-CompositionLaw dep (CVQuadrant qd) f g) ⟩
toQt dep w h _ (fmapₑ (quadrantFunctor dep) g (fmapₑ (quadrantFunctor dep) f (CVQuadrant qd)))
=⟨ toQt-fmap dep w h g (fmapₑ (quadrantFunctor dep) f (CVQuadrant qd)) q ⟩
fmapₑ (quadtreeFunctor dep) g (toQt dep w h _ (fmapₑ (quadrantFunctor dep) f (CVQuadrant qd)))
end where
| 53.512821
| 161
| 0.701485
|
1db86558239b2c150e8a7127d080f1257080f47c
| 547
|
agda
|
Agda
|
src/NTypes/Product.agda
|
vituscze/HoTT-lectures
|
7730385adfdbdda38ee8b124be3cdeebb7312c65
|
[
"BSD-3-Clause"
] | null | null | null |
src/NTypes/Product.agda
|
vituscze/HoTT-lectures
|
7730385adfdbdda38ee8b124be3cdeebb7312c65
|
[
"BSD-3-Clause"
] | null | null | null |
src/NTypes/Product.agda
|
vituscze/HoTT-lectures
|
7730385adfdbdda38ee8b124be3cdeebb7312c65
|
[
"BSD-3-Clause"
] | null | null | null |
{-# OPTIONS --without-K #-}
module NTypes.Product where
open import NTypes
open import PathOperations
open import PathStructure.Product
open import Types
×-isSet : ∀ {a b} {A : Set a} {B : Set b} →
isSet A → isSet B → isSet (A × B)
×-isSet A-set B-set x y p q
= split-eq p ⁻¹
· ap (λ y → ap₂ _,_ y (ap π₂ p))
(A-set _ _ (ap π₁ p) (ap π₁ q))
· ap (λ y → ap₂ _,_ (ap π₁ q) y)
(B-set _ _ (ap π₂ p) (ap π₂ q))
· split-eq q
where
split-eq : (p : x ≡ y) → ap₂ _,_ (ap π₁ p) (ap π₂ p) ≡ p
split-eq = π₂ (π₂ (π₂ split-merge-eq))
| 26.047619
| 58
| 0.570384
|
1a27eab9a6f7f53e2b7239e7f08d8cf14da28b0d
| 3,093
|
agda
|
Agda
|
deBruijn/Context/Extension/Isomorphic.agda
|
nad/dependently-typed-syntax
|
498f8aefc570f7815fd1d6616508eeb92c52abce
|
[
"MIT"
] | 5
|
2020-04-16T12:14:44.000Z
|
2020-07-08T22:51:36.000Z
|
deBruijn/Context/Extension/Isomorphic.agda
|
nad/dependently-typed-syntax
|
498f8aefc570f7815fd1d6616508eeb92c52abce
|
[
"MIT"
] | null | null | null |
deBruijn/Context/Extension/Isomorphic.agda
|
nad/dependently-typed-syntax
|
498f8aefc570f7815fd1d6616508eeb92c52abce
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The two definitions of context extensions are isomorphic
------------------------------------------------------------------------
open import Data.Universe.Indexed
module deBruijn.Context.Extension.Isomorphic
{i u e} (Uni : IndexedUniverse i u e) where
import deBruijn.Context.Basics as Basics
import deBruijn.Context.Extension.Left as Left
import deBruijn.Context.Extension.Right as Right
open import Function.Base
open import Function.Inverse using (_↔_)
import Relation.Binary.PropositionalEquality as P
open Basics Uni
open Left Uni
open Right Uni
open P.≡-Reasoning
-- Ctxt₊-s can be turned into Ctxt⁺-s.
₊-to-⁺ : ∀ {Γ} → Ctxt₊ Γ → Ctxt⁺ Γ
₊-to-⁺ ε = ε
₊-to-⁺ (σ ◅ Γ₊) = ε ▻ σ ⁺++⁺ ₊-to-⁺ Γ₊
abstract
-- The semantics is preserved.
++⁺-₊-to-⁺ : ∀ {Γ} (Γ₊ : Ctxt₊ Γ) → Γ ++₊ Γ₊ ≅-Ctxt Γ ++⁺ ₊-to-⁺ Γ₊
++⁺-₊-to-⁺ ε = P.refl
++⁺-₊-to-⁺ {Γ} (σ ◅ Γ₊) = begin
Γ ▻ σ ++₊ Γ₊ ≡⟨ ++⁺-₊-to-⁺ Γ₊ ⟩
Γ ▻ σ ++⁺ ₊-to-⁺ Γ₊ ≡⟨ ++⁺-++⁺ (ε ▻ σ) (₊-to-⁺ Γ₊) ⟩
Γ ++⁺ (ε ▻ σ ⁺++⁺ ₊-to-⁺ Γ₊) ∎
mutual
-- Ctxt⁺-s can be turned into Ctxt₊-s.
⁺-to-₊ : ∀ {Γ} → Ctxt⁺ Γ → Ctxt₊ Γ
⁺-to-₊ ε = ε
⁺-to-₊ (Γ⁺ ▻ σ) =
⁺-to-₊ Γ⁺ ₊++₊ P.subst Ctxt₊ (++₊-⁺-to-₊ Γ⁺) (σ ◅ ε)
abstract
-- The semantics is preserved.
++₊-⁺-to-₊ : ∀ {Γ} (Γ⁺ : Ctxt⁺ Γ) → Γ ++⁺ Γ⁺ ≅-Ctxt Γ ++₊ ⁺-to-₊ Γ⁺
++₊-⁺-to-₊ ε = P.refl
++₊-⁺-to-₊ {Γ} (Γ⁺ ▻ σ) =
let σ◅ε = P.subst Ctxt₊ (++₊-⁺-to-₊ Γ⁺) (σ ◅ ε)
in begin
Γ ++⁺ Γ⁺ ▻ σ ≡⟨ P.refl ⟩
Γ ++⁺ Γ⁺ ++₊ (σ ◅ ε) ≡⟨ P.sym $ ++₊-cong $ drop-subst-Ctxt₊ id (++₊-⁺-to-₊ Γ⁺) ⟩
Γ ++₊ ⁺-to-₊ Γ⁺ ++₊ σ◅ε ≡⟨ ++₊-++₊ (⁺-to-₊ Γ⁺) σ◅ε ⟩
Γ ++₊ (⁺-to-₊ Γ⁺ ₊++₊ σ◅ε) ∎
-- Some congruence lemmas.
₊-to-⁺-cong : ∀ {Γ₁} {Γ₊₁ : Ctxt₊ Γ₁}
{Γ₂} {Γ₊₂ : Ctxt₊ Γ₂} →
Γ₊₁ ≅-Ctxt₊ Γ₊₂ → ₊-to-⁺ Γ₊₁ ≅-Ctxt⁺ ₊-to-⁺ Γ₊₂
₊-to-⁺-cong P.refl = P.refl
⁺-to-₊-cong : ∀ {Γ₁} {Γ⁺₁ : Ctxt⁺ Γ₁}
{Γ₂} {Γ⁺₂ : Ctxt⁺ Γ₂} →
Γ⁺₁ ≅-Ctxt⁺ Γ⁺₂ → ⁺-to-₊ Γ⁺₁ ≅-Ctxt₊ ⁺-to-₊ Γ⁺₂
⁺-to-₊-cong P.refl = P.refl
-- Ctxt⁺ and Ctxt₊ are isomorphic.
Ctxt⁺↔Ctxt₊ : ∀ Γ → Ctxt⁺ Γ ↔ Ctxt₊ Γ
Ctxt⁺↔Ctxt₊ Γ = record
{ to = P.→-to-⟶ ⁺-to-₊
; from = P.→-to-⟶ ₊-to-⁺
; inverse-of = record
{ left-inverse-of = λ Γ⁺ → ≅-Ctxt⁺-⇒-≡ $ ₊-to-⁺-⁺-to-₊ Γ⁺
; right-inverse-of = λ Γ₊ → ≅-Ctxt₊-⇒-≡ $ ⁺-to-₊-₊-to-⁺ Γ₊
}
}
where
abstract
₊-to-⁺-⁺-to-₊ : (Γ⁺ : Ctxt⁺ Γ) → ₊-to-⁺ (⁺-to-₊ Γ⁺) ≅-Ctxt⁺ Γ⁺
₊-to-⁺-⁺-to-₊ Γ⁺ = cancel-++⁺-left _ _ (begin
Γ ++⁺ ₊-to-⁺ (⁺-to-₊ Γ⁺) ≡⟨ P.sym $ ++⁺-₊-to-⁺ (⁺-to-₊ Γ⁺) ⟩
Γ ++₊ (⁺-to-₊ Γ⁺) ≡⟨ P.sym $ ++₊-⁺-to-₊ Γ⁺ ⟩
Γ ++⁺ Γ⁺ ∎)
⁺-to-₊-₊-to-⁺ : (Γ₊ : Ctxt₊ Γ) → ⁺-to-₊ (₊-to-⁺ Γ₊) ≅-Ctxt₊ Γ₊
⁺-to-₊-₊-to-⁺ Γ₊ = cancel-++₊-left _ _ (begin
Γ ++₊ ⁺-to-₊ (₊-to-⁺ Γ₊) ≡⟨ P.sym $ ++₊-⁺-to-₊ (₊-to-⁺ Γ₊) ⟩
Γ ++⁺ (₊-to-⁺ Γ₊) ≡⟨ P.sym $ ++⁺-₊-to-⁺ Γ₊ ⟩
Γ ++₊ Γ₊ ∎)
| 31.242424
| 93
| 0.388943
|
a1d38ed5eaba6fbfdc5770f9b843ddcaafa424ce
| 968
|
agda
|
Agda
|
test/succeed/Issue458.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
test/succeed/Issue458.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/succeed/Issue458.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
-- The type checker was a little too eager to prune metavariables in
-- order to get the occurs check to pass. In this particular case it
-- got the constraint
-- _41 A B x == B (_42 A B (x , y))
-- and tried to make it work by pruning the third argument to _42. The
-- correct solution _42 A B p := fst p was thus lost.
module Issue458 where
data Σ (A : Set) (B : A -> Set) : Set where
_,_ : (x : A) (y : B x) → Σ A B
uncurry : {A : Set} {B : A → Set} {P : Σ A B → Set} →
((x : A) (y : B x) → P (x , y)) →
(p : Σ A B) → P p
uncurry f (x , y) = f x y
fst : {A : Set} {B : A → Set} → Σ A B → A
fst = uncurry λ x y → x
snd : {A : Set} {B : A → Set} (p : Σ A B) → B (fst p)
snd = uncurry λ x y → y
-- Bug.agda:15,7-24
-- Cannot instantiate the metavariable _50 to .B x since it contains
-- the variable x which is not in scope of the metavariable
-- when checking that the expression uncurry (λ x y → y) has type
-- (p : Σ .A .B) → .B (fst p)
| 35.851852
| 70
| 0.577479
|
13173525c72994e03a8639c37cff471a3a4de5ca
| 1,554
|
agda
|
Agda
|
src/data/lib/prim/Agda/Builtin/String.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2020-04-26T09:35:17.000Z
|
2020-04-26T09:35:17.000Z
|
src/data/lib/prim/Agda/Builtin/String.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2020-05-29T19:45:38.000Z
|
2020-05-29T19:45:38.000Z
|
src/data/lib/prim/Agda/Builtin/String.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2021-06-14T11:07:38.000Z
|
2021-06-14T11:07:38.000Z
|
{-# OPTIONS --without-K --safe --no-sized-types --no-guardedness
--no-subtyping #-}
module Agda.Builtin.String where
open import Agda.Builtin.Bool
open import Agda.Builtin.Char
open import Agda.Builtin.List
open import Agda.Builtin.Maybe
open import Agda.Builtin.Nat using (Nat)
open import Agda.Builtin.Sigma
postulate String : Set
{-# BUILTIN STRING String #-}
primitive
primStringUncons : String → Maybe (Σ Char (λ _ → String))
primStringToList : String → List Char
primStringFromList : List Char → String
primStringAppend : String → String → String
primStringEquality : String → String → Bool
primShowChar : Char → String
primShowString : String → String
primShowNat : Nat → String
{-# COMPILE JS primStringUncons = function(x) {
if (x === "") { return z_jAgda_Agda_Builtin_Maybe["Maybe"]["nothing"]; };
return z_jAgda_Agda_Builtin_Maybe["Maybe"]["just"](z_jAgda_Agda_Builtin_Sigma["_,_"](x.charAt(0))(x.slice(1)));
}
#-}
{-# COMPILE JS primStringToList = function(x) { return x.split(""); } #-}
{-# COMPILE JS primStringFromList = function(x) { return x.join(""); } #-}
{-# COMPILE JS primStringAppend = function(x) { return function(y) { return x+y; }; } #-}
{-# COMPILE JS primStringEquality = function(x) { return function(y) { return x===y; }; } #-}
{-# COMPILE JS primShowChar = function(x) { return JSON.stringify(x); } #-}
{-# COMPILE JS primShowString = function(x) { return JSON.stringify(x); } #-}
{-# COMPILE JS primShowNat = function(x) { return JSON.stringify(x); } #-}
| 40.894737
| 114
| 0.676319
|
597446915666b42c732794813b81f9b77d5b7b2d
| 7,759
|
agda
|
Agda
|
theorems/homotopy/SphereEndomorphism.agda
|
timjb/HoTT-Agda
|
66f800adef943afdf08c17b8ecfba67340fead5e
|
[
"MIT"
] | null | null | null |
theorems/homotopy/SphereEndomorphism.agda
|
timjb/HoTT-Agda
|
66f800adef943afdf08c17b8ecfba67340fead5e
|
[
"MIT"
] | null | null | null |
theorems/homotopy/SphereEndomorphism.agda
|
timjb/HoTT-Agda
|
66f800adef943afdf08c17b8ecfba67340fead5e
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
open import homotopy.LoopSpaceCircle
open import homotopy.PinSn
module homotopy.SphereEndomorphism where
Sphere-endo : ∀ n → Type₀
Sphere-endo n = Sphere n → Sphere n
⊙Sphere-endo : ∀ n → Type₀
⊙Sphere-endo n = ⊙Sphere n ⊙→ ⊙Sphere n
{-
⊙LiftSphere-endo : ∀ {i} n → Type i
⊙LiftSphere-endo {i} n = ⊙Lift {j = i} (⊙Sphere n) ⊙→ ⊙Lift {j = i} (⊙Sphere n)
-}
Trunc-Sphere-endo : ∀ n → Type₀
Trunc-Sphere-endo = Trunc 0 ∘ Sphere-endo
Trunc-⊙Sphere-endo : ∀ n → Type₀
Trunc-⊙Sphere-endo = Trunc 0 ∘ ⊙Sphere-endo
{-
Trunc-⊙LiftSphere-endo : ∀ {i} n → Type i
Trunc-⊙LiftSphere-endo {i} = Trunc 0 ∘ ⊙LiftSphere-endo {i}
-}
{- Part 0: pointedness is free -}
Trunc-⊙Sphere-endo-out : ∀ n
→ Trunc-⊙Sphere-endo n → Trunc-Sphere-endo n
Trunc-⊙Sphere-endo-out n = Trunc-fmap fst
-- For [S¹], the pointedness is free because of the commutativity of its loop space.
-- favonia: maybe one can simplify the proofs through
-- an intermediate type [Σ S¹ (λ x → x == x)]?
private
⊙S¹-endo-in' : (base* : S¹) (loop* : base* == base*) → (⊙S¹ ⊙→ ⊙S¹)
⊙S¹-endo-in' = S¹-elim
(λ loop* → S¹-rec base loop* , idp)
(↓-app→cst-in λ r → ap (λ loop* → (S¹-rec base loop* , idp)) (lemma₀ r)) where
abstract
lemma₀ : ∀ {loop₁ loop₂}
→ loop₁ == loop₂ [ (λ x → x == x) ↓ loop ]
→ loop₁ == loop₂
lemma₀ {loop₁} {loop₂} p = anti-whisker-right loop $
loop₁ ∙ loop
=⟨ ↓-idf=idf-out' p ⟩
loop ∙' loop₂
=⟨ ∙'=∙ loop loop₂ ⟩
loop ∙ loop₂
=⟨ ΩS¹-is-abelian loop loop₂ ⟩
loop₂ ∙ loop
=∎
⊙S¹-endo-in : (S¹ → S¹) → (⊙S¹ ⊙→ ⊙S¹)
⊙S¹-endo-in f = ⊙S¹-endo-in' (f base) (ap f loop)
Trunc-⊙S¹-endo-in : Trunc 0 (S¹ → S¹) → Trunc 0 (⊙S¹ ⊙→ ⊙S¹)
Trunc-⊙S¹-endo-in = Trunc-fmap ⊙S¹-endo-in
abstract
Trunc-⊙S¹-endo-in-η : ∀ f → Trunc-⊙S¹-endo-in (Trunc-⊙Sphere-endo-out 1 f) == f
Trunc-⊙S¹-endo-in-η = Trunc-elim
λ{(f , pt) → ap [_] $
⊙S¹-endo-in'-shifted pt (ap f loop) ∙ ⊙λ= (S¹-rec-η f , idp)}
where
-- free one end to apply identification elimination
⊙S¹-endo-in'-shifted : {base* : S¹}
(shift : base* == base) (loop* : base* == base*)
→ ⊙S¹-endo-in' base* loop* == (S¹-rec base* loop* , shift)
⊙S¹-endo-in'-shifted idp _ = idp
Trunc-⊙S¹-endo-out-β : ∀ f → Trunc-⊙Sphere-endo-out 1 (Trunc-⊙S¹-endo-in f) == f
Trunc-⊙S¹-endo-out-β = Trunc-elim
λ f → ! (ap (λ f → [ fst (⊙S¹-endo-in f) ]) (λ= $ S¹-rec-η f))
∙ ⊙S¹-endo-out-β (f base) (ap f loop)
∙ ap [_] (λ= $ S¹-rec-η f)
where
-- free [base*] to apply circle elimination
⊙S¹-endo-out-β : (base* : S¹) (loop* : base* == base*)
→ [ fst (⊙S¹-endo-in (S¹-rec base* loop*)) ]
== [ S¹-rec base* loop* ] :> Trunc 0 (S¹ → S¹)
⊙S¹-endo-out-β = S¹-elim
(λ loop* → ap (λ loop* → [ S¹-rec base loop* ]) (S¹Rec.loop-β base loop*))
prop-has-all-paths-↓
Trunc-⊙S¹-endo-out-is-equiv : is-equiv (Trunc-⊙Sphere-endo-out 1)
Trunc-⊙S¹-endo-out-is-equiv = is-eq _ Trunc-⊙S¹-endo-in Trunc-⊙S¹-endo-out-β Trunc-⊙S¹-endo-in-η
-- For [Sphere (S (S n))], the pointedness is free because of its connectivity.
private
SphereSS-conn : ∀ n → is-connected 1 (Sphere (S (S n)))
SphereSS-conn n = connected-≤T (≤T-+2+-l 1 (-2≤T ⟨ n ⟩₋₂))
SphereSS-conn-path : ∀ n (x y : Sphere (S (S n))) → is-connected 0 (x == y)
SphereSS-conn-path n x y = path-conn (SphereSS-conn n)
SphereSS-has-all-trunc-paths : ∀ n (x y : Sphere (S (S n))) → Trunc 0 (x == y)
SphereSS-has-all-trunc-paths n x y = –> (Trunc=-equiv [ x ] [ y ])
(contr-has-all-paths {{SphereSS-conn n}} [ x ] [ y ])
Trunc-⊙SphereSS-endo-in : ∀ n
→ Trunc-Sphere-endo (S (S n)) → Trunc-⊙Sphere-endo (S (S n))
Trunc-⊙SphereSS-endo-in n = Trunc-rec λ f →
Trunc-rec (λ pt → [ f , pt ])
(SphereSS-has-all-trunc-paths n (f north) north)
abstract
Trunc-⊙SphereSS-endo-in-η : ∀ n f → Trunc-⊙SphereSS-endo-in n (Trunc-⊙Sphere-endo-out (S (S n)) f) == f
Trunc-⊙SphereSS-endo-in-η n = Trunc-elim
λ{(f , pt) → ap (Trunc-rec (λ pt → [ f , pt ]))
(contr-has-all-paths {{SphereSS-conn-path n (f north) north}}
(SphereSS-has-all-trunc-paths n (f north) north) [ pt ])}
Trunc-⊙SphereSS-endo-out-β : ∀ n f → Trunc-⊙Sphere-endo-out (S (S n)) (Trunc-⊙SphereSS-endo-in n f) == f
Trunc-⊙SphereSS-endo-out-β n = Trunc-elim
λ f → Trunc-elim
{P = λ pt → Trunc-⊙Sphere-endo-out (S (S n)) (Trunc-rec (λ pt → [ f , pt ]) pt) == [ f ]}
(λ pt → idp) (SphereSS-has-all-trunc-paths n (f north) north)
Trunc-⊙SphereSS-endo-out-is-equiv : ∀ n → is-equiv (Trunc-⊙Sphere-endo-out (S (S n)))
Trunc-⊙SphereSS-endo-out-is-equiv n = is-eq
(Trunc-⊙Sphere-endo-out (S (S n))) (Trunc-⊙SphereSS-endo-in n)
(Trunc-⊙SphereSS-endo-out-β n) (Trunc-⊙SphereSS-endo-in-η n)
-- the unified interface
Trunc-⊙SphereS-endo-out-is-equiv : ∀ n → is-equiv (Trunc-⊙Sphere-endo-out (S n))
Trunc-⊙SphereS-endo-out-is-equiv 0 = Trunc-⊙S¹-endo-out-is-equiv
Trunc-⊙SphereS-endo-out-is-equiv (S n) = Trunc-⊙SphereSS-endo-out-is-equiv n
Trunc-⊙SphereS-endo-in : ∀ n
→ Trunc-Sphere-endo (S n) → Trunc-⊙Sphere-endo (S n)
Trunc-⊙SphereS-endo-in n = is-equiv.g (Trunc-⊙SphereS-endo-out-is-equiv n)
{- Part 1: suspension is an isomorphism -}
private
open import homotopy.Freudenthal
SSSSk≤SSk+2+SSk : ∀ k → S (S (S (S k))) ≤T S (S k) +2+ S (S k)
SSSSk≤SSk+2+SSk k = ≤T-+2+-l 0 $ ≤T-+2+-r (S (S k)) $ -2≤T k
SSn≤n+2+n : ∀ n → S (S ⟨ n ⟩) ≤T ⟨ n ⟩ +2+ ⟨ n ⟩
SSn≤n+2+n n = SSSSk≤SSk+2+SSk ⟨ n ⟩₋₂
module F n = FreudenthalEquiv
⟨ n ⟩₋₁ _ (SSn≤n+2+n n) (⊙Sphere (S (S n))) {{Sphere-conn (S (S n))}}
import homotopy.TruncationLoopLadder as TLL
import homotopy.SuspAdjointLoop as SAL
import homotopy.SuspAdjointLoopLadder as SALL
import homotopy.CircleHSpace as CHS
import homotopy.Pi2HSusp as Pi2
⊙up : ∀ n → ⊙Sphere n ⊙→ ⊙Ω (⊙Sphere (S n))
⊙up n = SAL.η (⊙Sphere n)
Ω^'S-Trunc-up-is-equiv : ∀ n → is-equiv (Ω^'-fmap (S n) (⊙Trunc-fmap {n = ⟨ S n ⟩} (⊙up (S n))))
Ω^'S-Trunc-up-is-equiv O = snd (Ω-emap (Pi2.⊙eq⁻¹ CHS.⊙S¹-hSpace))
Ω^'S-Trunc-up-is-equiv (S n) = snd (Ω^'-emap (S (S n)) (F.⊙eq n))
Trunc-Ω^'S-up-is-equiv : ∀ n → is-equiv (Trunc-fmap {n = 0} (Ω^'-fmap (S n) (⊙up (S n))))
Trunc-Ω^'S-up-is-equiv n = ⊙CommSquareEquiv-preserves-equiv (TLL.ladder (S n) (⊙up (S n))) (Ω^'S-Trunc-up-is-equiv n)
Trunc-post⊙∘-Ω^'S-up-is-equiv : ∀ n →
is-equiv (Trunc-fmap {n = 0} ((⊙Ω^'-fmap (S n) (⊙up (S n)) ⊙∘_) :> (_ → ⊙Bool ⊙→ _)))
Trunc-post⊙∘-Ω^'S-up-is-equiv n = CommSquareEquiv-preserves'-equiv
(Trunc-csemap (⊙Bool→-equiv-idf-nat (⊙Ω^'-fmap (S n) (⊙up (S n)))))
(Trunc-Ω^'S-up-is-equiv n)
Trunc-post⊙∘-upS-is-equiv : ∀ n →
is-equiv (Trunc-fmap {n = 0} ((⊙up (S n) ⊙∘_) :> (_ → ⊙Sphere (S n) ⊙→ _)))
Trunc-post⊙∘-upS-is-equiv n = CommSquareEquiv-preserves'-equiv
(Trunc-csemap (SALL.ladder (S n) (⊙up (S n))))
(Trunc-post⊙∘-Ω^'S-up-is-equiv n)
final-fix : ∀ n →
CommSquareEquiv
(⊙Susp-fmap :> (⊙Sphere-endo (S n) → _))
(SAL.η _ ⊙∘_)
(idf _)
(–> (SAL.eq _ _))
final-fix n = comm-sqr (λ f → ! (SAL.η-natural f)) , idf-is-equiv _ , snd (SAL.eq _ _)
Trunc-⊙SphereS-endo-Susp-is-equiv : ∀ n →
is-equiv (Trunc-fmap ⊙Susp-fmap :> (Trunc-⊙Sphere-endo (S n) → _))
Trunc-⊙SphereS-endo-Susp-is-equiv n =
CommSquareEquiv-preserves'-equiv
(Trunc-csemap (final-fix n))
(Trunc-post⊙∘-upS-is-equiv n)
| 38.98995
| 121
| 0.559479
|
1a6ab397a1ed9add09e18c6947fbc8cfe6050ef3
| 905
|
agda
|
Agda
|
Groups/Isomorphisms/Definition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Groups/Isomorphisms/Definition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Groups/Isomorphisms/Definition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 1
|
2021-11-29T13:23:07.000Z
|
2021-11-29T13:23:07.000Z
|
{-# OPTIONS --safe --warning=error --without-K #-}
open import Setoids.Setoids
open import Agda.Primitive using (Level; lzero; lsuc; _⊔_)
open import Groups.Definition
open import Groups.Homomorphisms.Definition
module Groups.Isomorphisms.Definition where
record GroupIso {m n o p : _} {A : Set m} {S : Setoid {m} {o} A} {_·A_ : A → A → A} {B : Set n} {T : Setoid {n} {p} B} {_·B_ : B → B → B} (G : Group S _·A_) (H : Group T _·B_) (f : A → B) : Set (m ⊔ n ⊔ o ⊔ p) where
open Setoid S renaming (_∼_ to _∼G_)
open Setoid T renaming (_∼_ to _∼H_)
field
groupHom : GroupHom G H f
bij : SetoidBijection S T f
record GroupsIsomorphic {m n o p : _} {A : Set m} {S : Setoid {m} {o} A} {_·A_ : A → A → A} {B : Set n} {T : Setoid {n} {p} B} {_·B_ : B → B → B} (G : Group S _·A_) (H : Group T _·B_) : Set (m ⊔ n ⊔ o ⊔ p) where
field
isomorphism : A → B
proof : GroupIso G H isomorphism
| 43.095238
| 215
| 0.59779
|
2e7dd48d2e9d19e27bcd6fa04576f1139bc1e00c
| 1,061
|
agda
|
Agda
|
old/Spaces/WedgeCircles.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
old/Spaces/WedgeCircles.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
old/Spaces/WedgeCircles.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | 50
|
2015-01-10T01:48:08.000Z
|
2022-02-14T03:03:25.000Z
|
{-# OPTIONS --without-K #-}
open import Base
module Spaces.WedgeCircles {i} (A : Set i) where
{-
The idea is
data wedge-circles : Set (suc i) where
base : wedge-circles
loops : A → base ≡ base
-}
private
data #wedge-circles : Set (suc i) where
#base : #wedge-circles
wedge-circles : Set (suc i)
wedge-circles = #wedge-circles
base : wedge-circles
base = #base
postulate -- HIT
loops : A → base ≡ base
wedge-circles-rec : ∀ {i} (P : wedge-circles → Set i) (x : P base)
(p : (t : A) → transport P (loops t) x ≡ x) → ((t : wedge-circles) → P t)
wedge-circles-rec P x p #base = x
postulate -- HIT
β : ∀ {i} (P : wedge-circles → Set i) (x : P base)
(p : (t : A) → transport P (loops t) x ≡ x) (t : A)
→ apd (wedge-circles-rec P x p) (loops t) ≡ p t
wedge-circles-rec-nondep : ∀ {i} (B : Set i) (x : B) (p : A → x ≡ x)
→ (wedge-circles → B)
wedge-circles-rec-nondep B x p #base = x
postulate -- HIT
β-nondep : ∀ {i} (B : Set i) (x : B) (p : A → x ≡ x) (t : A)
→ ap (wedge-circles-rec-nondep B x p) (loops t) ≡ p t
| 24.113636
| 75
| 0.569274
|
0660a8cfdfc52b6dfd4d319ed0887d574624a828
| 16,220
|
agda
|
Agda
|
src/Implicits/Substitutions/Lemmas/MetaType.agda
|
metaborg/ts.agda
|
7fe638b87de26df47b6437f5ab0a8b955384958d
|
[
"MIT"
] | 4
|
2019-04-05T17:57:11.000Z
|
2021-05-07T04:08:41.000Z
|
src/Implicits/Substitutions/Lemmas/MetaType.agda
|
metaborg/ts.agda
|
7fe638b87de26df47b6437f5ab0a8b955384958d
|
[
"MIT"
] | null | null | null |
src/Implicits/Substitutions/Lemmas/MetaType.agda
|
metaborg/ts.agda
|
7fe638b87de26df47b6437f5ab0a8b955384958d
|
[
"MIT"
] | null | null | null |
open import Prelude hiding (subst; module Fin)
module Implicits.Substitutions.Lemmas.MetaType where
open import Implicits.Syntax.Type
open import Implicits.Syntax.Term hiding (var)
open import Implicits.Syntax.Context
open import Implicits.WellTyped
open import Implicits.Substitutions
open import Data.Vec hiding ([_])
open import Data.Fin as Fin using ()
open import Data.Fin.Substitution
open import Data.Fin.Substitution.Lemmas
open import Data.Vec.Properties
open import Data.Nat.Properties.Simple
open import Extensions.Substitution
open import Relation.Binary.HeterogeneousEquality as H using ()
private
module HR = H.≅-Reasoning
module MetaTypeTypeLemmas where
open MetaTypeTypeSubst hiding (_/✶_)
open import Implicits.Syntax.MetaType
open import Data.Star
private module V = VarLemmas
module _ {m : ℕ} where
MT : ℕ → Set
MT = MetaType m
open MetaTypeApp hiding (_/_)
module _ {T₁ T₂} {lift₁ : MetaLift T₁} {lift₂ : MetaLift T₂} where
open Lifted {m} lift₁ using () renaming (_↑✶_ to _↑✶₁_; _/✶_ to _/✶₁_)
open Lifted {m} lift₂ using () renaming (_↑✶_ to _↑✶₂_; _/✶_ to _/✶₂_)
/✶-↑✶ : ∀ {n n'} (ρs₁ : Subs (T₁ m) n n') (ρs₂ : Subs (T₂ m) n n') →
(∀ k x → (simpl (tvar x)) /✶₁ ρs₁ ↑✶₁ k ≡ (simpl (tvar x)) /✶₂ ρs₂ ↑✶₂ k) →
∀ k t → t /✶₁ ρs₁ ↑✶₁ k ≡ t /✶₂ ρs₂ ↑✶₂ k
/✶-↑✶ ρs₁ ρs₂ hyp k (a ⇒ b) = begin
(a ⇒ b) /✶₁ ρs₁ ↑✶₁ k
≡⟨ ⇒-/✶-↑✶ lift₁ 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 (⇒-/✶-↑✶ lift₂ k ρs₂) ⟩
(a ⇒ b) /✶₂ ρs₂ ↑✶₂ k ∎
/✶-↑✶ ρs₁ ρs₂ hyp k (∀' t) = begin
(∀' t) /✶₁ ρs₁ ↑✶₁ k
≡⟨ ∀'-/✶-↑✶ lift₁ k ρs₁ ⟩
∀' (t /✶₁ ρs₁ ↑✶₁ (suc k))
≡⟨ cong ∀' (/✶-↑✶ ρs₁ ρs₂ hyp (suc k) t) ⟩
∀' (t /✶₂ ρs₂ ↑✶₂ (suc k))
≡⟨ sym $ ∀'-/✶-↑✶ lift₂ k ρs₂ ⟩
(∀' t) /✶₂ ρs₂ ↑✶₂ k ∎
/✶-↑✶ ρs₁ ρs₂ hyp k (simpl (tvar c)) = hyp k c
/✶-↑✶ ρs₁ ρs₂ hyp k (simpl (mvar x)) = begin
(simpl (mvar x)) /✶₁ ρs₁ ↑✶₁ k
≡⟨ mvar-/✶-↑✶ lift₁ k ρs₁ ⟩
(simpl (mvar x))
≡⟨ sym $ mvar-/✶-↑✶ lift₂ k ρs₂ ⟩
(simpl (mvar x)) /✶₂ ρs₂ ↑✶₂ k ∎
/✶-↑✶ ρs₁ ρs₂ hyp k (simpl (a →' b)) = begin
(simpl (a →' b)) /✶₁ ρs₁ ↑✶₁ k
≡⟨ →'-/✶-↑✶ lift₁ k ρs₁ ⟩
simpl ((a /✶₁ ρs₁ ↑✶₁ k) →' (b /✶₁ ρs₁ ↑✶₁ k))
≡⟨ cong₂ (λ a b → simpl (a →' b)) (/✶-↑✶ ρs₁ ρs₂ hyp k a) (/✶-↑✶ ρs₁ ρs₂ hyp k b) ⟩
simpl ((a /✶₂ ρs₂ ↑✶₂ k) →' (b /✶₂ ρs₂ ↑✶₂ k))
≡⟨ sym (→'-/✶-↑✶ lift₂ k ρs₂) ⟩
(simpl (a →' b)) /✶₂ ρs₂ ↑✶₂ k ∎
/✶-↑✶ ρs₁ ρs₂ hyp k (simpl (tc c)) = begin
(simpl (tc c)) /✶₁ ρs₁ ↑✶₁ k
≡⟨ tc-/✶-↑✶ lift₁ k ρs₁ ⟩
(simpl (tc c))
≡⟨ sym $ tc-/✶-↑✶ lift₂ k ρs₂ ⟩
(simpl (tc c)) /✶₂ ρs₂ ↑✶₂ k ∎
lemmas₃ : Lemmas₃ (MetaType m)
lemmas₃ = record
{ lemmas₂ = record
{ lemmas₁ = record
{ lemmas₀ = record
{ simple = simple
}
; weaken-var = λ {_ x} → begin
(simpl (tvar x)) /Var V.wk ≡⟨ refl ⟩
(simpl (tvar (lookup x V.wk))) ≡⟨ cong (λ x → simpl (tvar x)) (V.lookup-wk x) ⟩
(simpl (tvar (suc x))) ∎
}
; application = Subst.application subst
; var-/ = refl
}
; /✶-↑✶ = /✶-↑✶
}
private module L₃ = Lemmas₃ lemmas₃
lemmas₅ : Lemmas₅ (MetaType m)
lemmas₅ = record
{ lemmas₄ = record
{ lemmas₃ = lemmas₃
; /-wk = λ {_ t} → begin
t / wk ≡⟨ /✶-↑✶ (ε ▻ wk) (ε ▻ V.wk)
(λ k x → begin
(simpl (tvar x)) / wk ↑⋆ k
≡⟨ L₃.var-/-wk-↑⋆ k x ⟩
(simpl (tvar (Fin.lift k suc x)))
≡⟨ cong (λ x → (simpl (tvar x))) (sym (V.var-/-wk-↑⋆ k x)) ⟩
(simpl (tvar (lookup x (V._↑⋆_ V.wk k))))
≡⟨ refl ⟩
(simpl (tvar x)) /Var V._↑⋆_ V.wk k ∎)
zero t ⟩
t /Var V.wk ≡⟨ refl ⟩
weaken t ∎
}
}
open Lemmas₅ lemmas₅ public hiding (lemmas₃)
module MetaTypeMetaLemmas where
open MetaTypeMetaSubst using (module Lifted; MetaLift)
open import Implicits.Syntax.MetaType
open import Data.Star as Star hiding (map)
open import Data.Star.Properties
private module V = VarLemmas
module MetaTypeAppLemmas {T} (l : MetaLift T) where
open Lifted l
→'-/✶-↑✶ : ∀ k {ν n n' a b} (ρs : Subs (flip T ν) n n') →
(simpl (a →' b)) /✶ ρs ↑✶ k ≡ simpl ((a /✶ ρs ↑✶ k) →' (b /✶ ρs ↑✶ k))
→'-/✶-↑✶ k ε = refl
→'-/✶-↑✶ k (r ◅ ρs) = cong₂ _/_ (→'-/✶-↑✶ k ρs) refl
⇒-/✶-↑✶ : ∀ k {ν n n' a b} (ρs : Subs (flip T ν) n n') →
(a ⇒ b) /✶ ρs ↑✶ k ≡ (a /✶ ρs ↑✶ k) ⇒ (b /✶ ρs ↑✶ k)
⇒-/✶-↑✶ k ε = refl
⇒-/✶-↑✶ k (r ◅ ρs) = cong₂ _/_ (⇒-/✶-↑✶ k ρs) refl
tc-/✶-↑✶ : ∀ k {ν c n n'} (ρs : Subs (flip T ν) n n') →
(simpl (tc c)) /✶ ρs ↑✶ k ≡ simpl (tc c)
tc-/✶-↑✶ k ε = refl
tc-/✶-↑✶ k (r ◅ ρs) = cong₂ _/_ (tc-/✶-↑✶ k ρs) refl
tvar-/✶-↑✶ : ∀ k {ν n n' c} (ρs : Subs (flip T ν) n n') →
(simpl (tvar c)) /✶ ρs ↑✶ k ≡ simpl (tvar c)
tvar-/✶-↑✶ k ε = refl
tvar-/✶-↑✶ k (r ◅ ρs) = cong₂ _/_ (tvar-/✶-↑✶ k ρs) refl
tpweaken-subs : ∀ {ν n n'} (ρs : Subs (flip T ν) n n') → Subs (flip T (suc ν)) n n'
tpweaken-subs ρs = Star.map (λ x → x ↑tp) ρs
comm-↑-↑tp : ∀ {ν n n'} (s : Sub (flip T ν) n n') → (s ↑) ↑tp ≡ (s ↑tp) ↑
comm-↑-↑tp s = begin
(s ↑) ↑tp
≡⟨ refl ⟩
map tpweaken (var zero ∷ map weaken s)
≡⟨ refl ⟩
(tpweaken (var zero)) ∷ (map tpweaken (map weaken s))
≡⟨ cong₂ (λ x xs → x ∷ xs) (tpweaken-var zero) (sym $ map-∘ tpweaken weaken s) ⟩
(var zero) ∷ (map (tpweaken ∘ weaken) s)
≡⟨ cong (λ u → var zero ∷ u) (sym $ map-cong comm-weaken-tpweaken s) ⟩
(var zero) ∷ (map (weaken ∘ tpweaken) s)
≡⟨ cong (λ u → (var zero) ∷ u) (map-∘ weaken tpweaken s) ⟩
(s ↑tp) ↑ ∎
comm-↑⋆-↑tp : ∀ k {ν n n'} (s : Sub (flip T ν) n n') → (s ↑⋆ k) ↑tp ≡ (s ↑tp) ↑⋆ k
comm-↑⋆-↑tp zero s = refl
comm-↑⋆-↑tp (suc k) s = begin
((s ↑⋆ k) ↑) ↑tp
≡⟨ comm-↑-↑tp (s ↑⋆ k) ⟩
((s ↑⋆ k) ↑tp) ↑
≡⟨ cong _↑ (comm-↑⋆-↑tp k s) ⟩
(s ↑tp) ↑⋆ (suc k) ∎
comm-tpweaken-↑✶ : ∀ k {ν n n'} (ρs : Subs (flip T ν) n n') →
(tpweaken-subs ρs) ↑✶ k ≡ tpweaken-subs (ρs ↑✶ k)
comm-tpweaken-↑✶ k ρs = begin
(tpweaken-subs ρs) ↑✶ k
≡⟨ refl ⟩
Star.gmap (_+_ k) (λ ρ → ρ ↑⋆ k) (Star.map _↑tp ρs)
≡⟨ gmap-∘ (_+_ k) (λ ρ₁ → ρ₁ ↑⋆ k) Prelude.id _↑tp ρs ⟩
Star.gmap (_+_ k) (λ ρ → (ρ ↑tp) ↑⋆ k) ρs
≡⟨ gmap-cong (_+_ k) (λ ρ₁ → _↑tp ρ₁ ↑⋆ k) (λ ρ₁ → _↑tp (ρ₁ ↑⋆ k))
(λ s → sym $ comm-↑⋆-↑tp k s) ρs ⟩
Star.gmap (_+_ k) (λ ρ → (ρ ↑⋆ k) ↑tp) ρs
≡⟨ sym $ gmap-∘ Prelude.id _↑tp (_+_ k) (λ ρ₁ → ρ₁ ↑⋆ k) ρs ⟩
Star.map _↑tp (Star.gmap (_+_ k) (λ ρ → ρ ↑⋆ k) ρs)
≡⟨ refl ⟩
tpweaken-subs (ρs ↑✶ k) ∎
∀'-/✶-↑✶ : ∀ k {ν n n' a} (ρs : Subs (flip T ν) n n') →
(∀' a) /✶ ρs ↑✶ k ≡ ∀' (a /✶ (tpweaken-subs ρs) ↑✶ k)
∀'-/✶-↑✶ k {a = a} ε = refl
∀'-/✶-↑✶ k {a = a} (x ◅ ρs) = begin
(∀' a) /✶ (x ◅ ρs) ↑✶ k
≡⟨ cong (flip _/_ (x ↑⋆ k)) (∀'-/✶-↑✶ k ρs) ⟩
(∀' (a /✶ (tpweaken-subs ρs) ↑✶ k)) / (x ↑⋆ k)
≡⟨ cong (λ u → ∀' (a /✶ u / _↑tp (x ↑⋆ k))) (comm-tpweaken-↑✶ k ρs) ⟩
∀' (a /✶ (tpweaken-subs ((x ◅ ρs) ↑✶ k)))
≡⟨ sym $ cong (λ u → ∀' (a /✶ u)) (comm-tpweaken-↑✶ k (x ◅ ρs)) ⟩
∀' (a /✶ (tpweaken-subs (x ◅ ρs)) ↑✶ k) ∎
module _ where
open MetaTypeTypeSubst using () renaming (weaken to mtt-weaken)
private
module MTT = MetaTypeTypeSubst
{-}↑tp-mtt-weaken : ∀ {ν m n} x (s : Sub (flip T ν) m n) →
(mtt-weaken x) / (s ↑tp) ≡ mtt-weaken (x / s)-}
postulate ↑tp-mtt-weaken : ∀ {ν m n } k x (s : Sub (flip T ν) m n) →
(x MTT./Var VarSubst.wk VarSubst.↑⋆ k) /
(Prelude.subst (λ ν → Sub (flip T ν) m n) (sym $ +-suc k ν) (s ↑tp⋆ (suc k))) ≡
(x / (s ↑tp⋆ k)) MTT./Var VarSubst.wk VarSubst.↑⋆ k
{-
↑tp-mtt-weaken k (a ⇒ b) s = cong₂ _⇒_ (↑tp-mtt-weaken k a s) (↑tp-mtt-weaken k b s)
↑tp-mtt-weaken {ν} {m} {n} k (∀' x) s = begin
(∀' (x MTT./Var VarSubst.wk VarSubst.↑⋆ (suc k))) /
(Prelude.subst (λ ν → Sub (flip T ν) m n) (sym $ +-suc k ν) (s ↑tp⋆ (suc k)))
≡⟨ refl ⟩
∀' ((x MTT./Var VarSubst.wk VarSubst.↑⋆ (suc k)) /
(Prelude.subst (λ ν → Sub (flip T ν) m n) (cong suc (sym $ +-suc k ν)) (s ↑tp⋆ (suc (suc k)))))
≡⟨ cong ∀' (↑tp-mtt-weaken (suc k) {!!} {!!}) ⟩
(∀' ((x / (s ↑tp⋆ (suc k))) MTT./Var VarSubst.wk VarSubst.↑⋆ (suc k)))
≡⟨ refl ⟩
(∀' (x / (s ↑tp⋆ (suc k)))) MTT./Var VarSubst.wk VarSubst.↑⋆ k
≡⟨ refl ⟩
(∀' x / s ↑tp⋆ k) MTT./Var VarSubst.wk VarSubst.↑⋆ k ∎
↑tp-mtt-weaken k (simpl (tvar x)) s = refl
↑tp-mtt-weaken k (simpl (mvar x)) s = {!!}
↑tp-mtt-weaken k (simpl (a →' b)) s = cong₂ (λ u v → simpl (u →' v)) (↑tp-mtt-weaken k a s)
(↑tp-mtt-weaken k b s)
↑tp-mtt-weaken k (simpl (tc x)) s = refl
-}
tpweaken-subs-var : ∀ {ν n n'} x (ρs : Subs (flip T ν) n n') →
(simpl (mvar x)) /✶ (tpweaken-subs ρs)
≡ mtt-weaken ((simpl (mvar x)) /✶ ρs)
tpweaken-subs-var x ε = refl
tpweaken-subs-var x (s ◅ ρs) = begin
(simpl (mvar x)) /✶ (Star.map _↑tp (s ◅ ρs))
≡⟨ refl ⟩
(simpl (mvar x)) /✶ (tpweaken-subs ρs) / (s ↑tp)
≡⟨ cong (flip _/_ (_↑tp s)) (tpweaken-subs-var x ρs) ⟩
(mtt-weaken ((simpl (mvar x)) /✶ ρs)) / (s ↑tp)
≡⟨ ↑tp-mtt-weaken zero (simpl (mvar x) /✶ ρs) s ⟩
mtt-weaken ((simpl (mvar x)) /✶ (s ◅ ρs)) ∎
module _ {T₁ T₂} {lift₁ : MetaLift T₁} {lift₂ : MetaLift T₂} where
open MetaTypeTypeSubst using () renaming (weaken to mtt-weaken)
open Lifted lift₁ using () renaming (_↑✶_ to _↑✶₁_; _/✶_ to _/✶₁_; _↑tp to _↑tp₁)
open Lifted lift₂ using () renaming (_↑✶_ to _↑✶₂_; _/✶_ to _/✶₂_; _↑tp to _↑tp₂)
open MetaTypeAppLemmas
weaken-hyp : ∀ {ν n n'} (ρs₁ : Subs (flip T₁ ν) n n') (ρs₂ : Subs (flip T₂ ν) n n') →
(∀ k x → (simpl (mvar x)) /✶₁ ρs₁ ↑✶₁ k ≡ (simpl (mvar x)) /✶₂ ρs₂ ↑✶₂ k) →
(∀ k x → (simpl (mvar x)) /✶₁ (tpweaken-subs lift₁ ρs₁) ↑✶₁ k ≡ (simpl (mvar x)) /✶₂ (tpweaken-subs lift₂ ρs₂) ↑✶₂ k)
weaken-hyp ρs₁ ρs₂ hyp k x = begin
simpl (mvar x) /✶₁ (tpweaken-subs lift₁ ρs₁) ↑✶₁ k
≡⟨ cong (λ u → simpl (mvar x) /✶₁ u) (comm-tpweaken-↑✶ lift₁ k ρs₁) ⟩
simpl (mvar x) /✶₁ tpweaken-subs lift₁ (ρs₁ ↑✶₁ k)
≡⟨ tpweaken-subs-var lift₁ x (ρs₁ ↑✶₁ k) ⟩
mtt-weaken (simpl (mvar x) /✶₁ (ρs₁ ↑✶₁ k))
≡⟨ cong mtt-weaken (hyp k x) ⟩
mtt-weaken (simpl (mvar x) /✶₂ (ρs₂ ↑✶₂ k))
≡⟨ sym $ tpweaken-subs-var lift₂ x (ρs₂ ↑✶₂ k) ⟩
simpl (mvar x) /✶₂ tpweaken-subs lift₂ (ρs₂ ↑✶₂ k)
≡⟨ cong (λ u → simpl (mvar x) /✶₂ u) (sym $ comm-tpweaken-↑✶ lift₂ k ρs₂) ⟩
simpl (mvar x) /✶₂ (tpweaken-subs lift₂ ρs₂) ↑✶₂ k ∎
/✶-↑✶ : ∀ {ν n n'} (ρs₁ : Subs (flip T₁ ν) n n') (ρs₂ : Subs (flip T₂ ν) n n') →
(∀ k x → (simpl (mvar x)) /✶₁ ρs₁ ↑✶₁ k ≡ (simpl (mvar x)) /✶₂ ρs₂ ↑✶₂ k) →
∀ k t → t /✶₁ ρs₁ ↑✶₁ k ≡ t /✶₂ ρs₂ ↑✶₂ k
/✶-↑✶ ρs₁ ρs₂ hyp k (a ⇒ b) = begin
(a ⇒ b) /✶₁ ρs₁ ↑✶₁ k
≡⟨ ⇒-/✶-↑✶ lift₁ 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 (⇒-/✶-↑✶ lift₂ k ρs₂) ⟩
(a ⇒ b) /✶₂ ρs₂ ↑✶₂ k ∎
/✶-↑✶ ρs₁ ρs₂ hyp k (∀' t) = begin
(∀' t) /✶₁ ρs₁ ↑✶₁ k
≡⟨ ∀'-/✶-↑✶ lift₁ k ρs₁ ⟩
(∀' (t /✶₁ (tpweaken-subs lift₁ ρs₁) ↑✶₁ k))
≡⟨ cong ∀' (/✶-↑✶ (tpweaken-subs lift₁ ρs₁) (tpweaken-subs lift₂ ρs₂) (weaken-hyp ρs₁ ρs₂ hyp) k t ) ⟩
(∀' (t /✶₂ (tpweaken-subs lift₂ ρs₂) ↑✶₂ k))
≡⟨ sym $ ∀'-/✶-↑✶ lift₂ k ρs₂ ⟩
(∀' t) /✶₂ ρs₂ ↑✶₂ k ∎
/✶-↑✶ ρs₁ ρs₂ hyp k (simpl (mvar c)) = hyp k c
/✶-↑✶ ρs₁ ρs₂ hyp k (simpl (tvar x)) = begin
(simpl (tvar x)) /✶₁ ρs₁ ↑✶₁ k
≡⟨ tvar-/✶-↑✶ lift₁ k ρs₁ ⟩
(simpl (tvar x))
≡⟨ sym $ tvar-/✶-↑✶ lift₂ k ρs₂ ⟩
(simpl (tvar x)) /✶₂ ρs₂ ↑✶₂ k ∎
/✶-↑✶ ρs₁ ρs₂ hyp k (simpl (a →' b)) = begin
(simpl (a →' b)) /✶₁ ρs₁ ↑✶₁ k
≡⟨ →'-/✶-↑✶ lift₁ k ρs₁ ⟩
simpl ((a /✶₁ ρs₁ ↑✶₁ k) →' (b /✶₁ ρs₁ ↑✶₁ k))
≡⟨ cong₂ (λ a b → simpl (a →' b)) (/✶-↑✶ ρs₁ ρs₂ hyp k a) (/✶-↑✶ ρs₁ ρs₂ hyp k b) ⟩
simpl ((a /✶₂ ρs₂ ↑✶₂ k) →' (b /✶₂ ρs₂ ↑✶₂ k))
≡⟨ sym (→'-/✶-↑✶ lift₂ k ρs₂) ⟩
(simpl (a →' b)) /✶₂ ρs₂ ↑✶₂ k ∎
/✶-↑✶ ρs₁ ρs₂ hyp k (simpl (tc c)) = begin
(simpl (tc c)) /✶₁ ρs₁ ↑✶₁ k
≡⟨ tc-/✶-↑✶ lift₁ k ρs₁ ⟩
(simpl (tc c))
≡⟨ sym $ tc-/✶-↑✶ lift₂ k ρs₂ ⟩
(simpl (tc c)) /✶₂ ρs₂ ↑✶₂ k ∎
module _ {ν : ℕ} where
open MetaTypeMetaSubst
MT : ℕ → Set
MT = flip MetaType ν
lemmas₃ : Lemmas₃ (flip MetaType ν)
lemmas₃ = record
{ lemmas₂ = record
{ lemmas₁ = record
{ lemmas₀ = record
{ simple = simple
}
; weaken-var = λ {_ x} → begin
(simpl (mvar x)) /Var V.wk ≡⟨ refl ⟩
(simpl (mvar (lookup x V.wk))) ≡⟨ cong (λ x → simpl (mvar x)) (V.lookup-wk x) ⟩
(simpl (mvar (suc x))) ∎
}
; application = Subst.application subst
; var-/ = refl
}
; /✶-↑✶ = /✶-↑✶
}
private module L₃ = Lemmas₃ lemmas₃
lemmas₅ : Lemmas₅ (flip MetaType ν)
lemmas₅ = record
{ lemmas₄ = record
{ lemmas₃ = lemmas₃
; /-wk = λ {_ t} → begin
t / wk ≡⟨ /✶-↑✶ (ε ▻ wk) (ε ▻ V.wk)
(λ k x → begin
(simpl (mvar x)) / wk ↑⋆ k
≡⟨ L₃.var-/-wk-↑⋆ k x ⟩
(simpl (mvar (Fin.lift k suc x)))
≡⟨ cong (λ x → (simpl (mvar x))) (sym (V.var-/-wk-↑⋆ k x)) ⟩
(simpl (mvar (lookup x (V._↑⋆_ V.wk k))))
≡⟨ refl ⟩
(simpl (mvar x)) /Var V._↑⋆_ V.wk k ∎)
zero t ⟩
t /Var V.wk ≡⟨ refl ⟩
weaken t ∎
}
}
open Lemmas₅ lemmas₅ public hiding (lemmas₃)
open MetaTypeMetaSubst using (open-meta-k; open-meta; _↑⋆tp_; _↑tp; _◁m; _◁m₁)
us↑-⊙-sub-u≡u∷us : ∀ {ν m} (u : MetaType zero ν) (us : Sub (flip MetaType ν) m zero) →
us ↑ ⊙ sub u ≡ u ∷ us
us↑-⊙-sub-u≡u∷us {ν} {m} u us = cong (λ v → u ∷ v) map-weaken-⊙-sub
open-mvar : ∀ {ν m} (x : Fin m) → open-meta {ν = ν} (simpl (mvar x)) ≡ simpl (mvar (suc x))
open-mvar x = weaken-var
open-tvar-suc : ∀ {ν m} (x : Fin m) → open-meta {ν} (simpl (tvar (suc x))) ≡ simpl (tvar x)
open-tvar-suc x = MetaTypeTypeLemmas.suc-/-sub {t = (simpl (tvar x))}
open import Implicits.Substitutions.Type as TS using ()
open import Implicits.Substitutions.Lemmas.Type as TSLemmas using ()
private
module MTT = MetaTypeTypeSubst
| 42.020725
| 141
| 0.429963
|
41426d835dbf440440070afa652c260a4638edd3
| 2,337
|
agda
|
Agda
|
ground-decidable.agda
|
hazelgrove/hazelnut-agda
|
a3640d7b0f76cdac193afd382694197729ed6d57
|
[
"MIT"
] | null | null | null |
ground-decidable.agda
|
hazelgrove/hazelnut-agda
|
a3640d7b0f76cdac193afd382694197729ed6d57
|
[
"MIT"
] | null | null | null |
ground-decidable.agda
|
hazelgrove/hazelnut-agda
|
a3640d7b0f76cdac193afd382694197729ed6d57
|
[
"MIT"
] | null | null | null |
open import Prelude
open import dynamics-core
module ground-decidable where
ground-decidable : (τ : htyp) → (τ ground) + ((τ ground) → ⊥)
ground-decidable num = Inl GNum
ground-decidable (⦇-⦈ ==> ⦇-⦈) = Inl GArrHole
ground-decidable (⦇-⦈ ⊕ ⦇-⦈) = Inl GSumHole
ground-decidable ⦇-⦈ = Inr (λ ())
ground-decidable (num ==> τ₁) = Inr (λ ())
ground-decidable (⦇-⦈ ==> num) = Inr (λ ())
ground-decidable (⦇-⦈ ==> τ₁ ==> τ₂) = Inr (λ ())
ground-decidable (⦇-⦈ ==> τ₁ ⊕ τ₂) = Inr (λ ())
ground-decidable ((τ ==> τ₂) ==> τ₁) = Inr (λ ())
ground-decidable ((τ ⊕ τ₂) ==> τ₁) = Inr (λ ())
ground-decidable (num ⊕ τ₁) = Inr (λ ())
ground-decidable (⦇-⦈ ⊕ num) = Inr (λ ())
ground-decidable (⦇-⦈ ⊕ τ₁ ==> τ₂) = Inr (λ ())
ground-decidable (⦇-⦈ ⊕ τ₁ ⊕ τ₂) = Inr (λ ())
ground-decidable ((τ ==> τ₂) ⊕ τ₁) = Inr (λ ())
ground-decidable ((τ ⊕ τ₂) ⊕ τ₁) = Inr (λ ())
ground-decidable (⦇-⦈ ==> τ₁ ⊠ τ₂) = Inr (λ ())
ground-decidable ((τ ⊠ τ₂) ==> τ₁) = Inr (λ ())
ground-decidable (⦇-⦈ ⊕ τ₁ ⊠ τ₂) = Inr (λ ())
ground-decidable ((τ ⊠ τ₂) ⊕ τ₁) = Inr (λ ())
ground-decidable (num ⊠ num) = Inr (λ ())
ground-decidable (num ⊠ ⦇-⦈) = Inr (λ ())
ground-decidable (num ⊠ τ₁ ==> τ₂) = Inr (λ ())
ground-decidable (num ⊠ τ₁ ⊕ τ₂) = Inr (λ ())
ground-decidable (num ⊠ τ₁ ⊠ τ₂) = Inr (λ ())
ground-decidable (⦇-⦈ ⊠ num) = Inr (λ ())
ground-decidable (⦇-⦈ ⊠ ⦇-⦈) = Inl GProdHole
ground-decidable (⦇-⦈ ⊠ τ₁ ==> τ₂) = Inr (λ ())
ground-decidable (⦇-⦈ ⊠ τ₁ ⊕ τ₂) = Inr (λ ())
ground-decidable (⦇-⦈ ⊠ τ₁ ⊠ τ₂) = Inr (λ ())
ground-decidable ((τ ==> τ₁) ⊠ num) = Inr (λ ())
ground-decidable ((τ ==> τ₁) ⊠ ⦇-⦈) = Inr (λ ())
ground-decidable ((τ ==> τ₁) ⊠ τ₂ ==> τ₃) = Inr (λ ())
ground-decidable ((τ ==> τ₁) ⊠ τ₂ ⊕ τ₃) = Inr (λ ())
ground-decidable ((τ ==> τ₁) ⊠ τ₂ ⊠ τ₃) = Inr (λ ())
ground-decidable ((τ ⊕ τ₁) ⊠ num) = Inr (λ ())
ground-decidable ((τ ⊕ τ₁) ⊠ ⦇-⦈) = Inr (λ ())
ground-decidable ((τ ⊕ τ₁) ⊠ τ₂ ==> τ₃) = Inr (λ ())
ground-decidable ((τ ⊕ τ₁) ⊠ τ₂ ⊕ τ₃) = Inr (λ ())
ground-decidable ((τ ⊕ τ₁) ⊠ τ₂ ⊠ τ₃) = Inr (λ ())
ground-decidable ((τ ⊠ τ₁) ⊠ num) = Inr (λ ())
ground-decidable ((τ ⊠ τ₁) ⊠ ⦇-⦈) = Inr (λ ())
ground-decidable ((τ ⊠ τ₁) ⊠ τ₂ ==> τ₃) = Inr (λ ())
ground-decidable ((τ ⊠ τ₁) ⊠ τ₂ ⊕ τ₃) = Inr (λ ())
ground-decidable ((τ ⊠ τ₁) ⊠ τ₂ ⊠ τ₃) = Inr (λ ())
| 45.823529
| 63
| 0.507916
|
2ffee2b52d0d068e7b16700c8978caad372bf727
| 14,864
|
agda
|
Agda
|
src/ctxt.agda
|
mb64/cedille
|
d0f69cc6fbfb69d7ef83a436b623d612328eb016
|
[
"MIT"
] | 328
|
2018-09-14T20:06:09.000Z
|
2022-03-26T10:33:07.000Z
|
src/ctxt.agda
|
mb64/cedille
|
d0f69cc6fbfb69d7ef83a436b623d612328eb016
|
[
"MIT"
] | 123
|
2018-09-17T10:53:20.000Z
|
2022-01-12T03:51:28.000Z
|
src/ctxt.agda
|
mb64/cedille
|
d0f69cc6fbfb69d7ef83a436b623d612328eb016
|
[
"MIT"
] | 34
|
2018-09-17T11:51:36.000Z
|
2022-02-20T18:33:16.000Z
|
module ctxt where
open import cedille-types
open import ctxt-types public
open import subst
open import general-util
open import syntax-util
open import type-util
open import free-vars
new-sym-info-trie : trie sym-info
new-sym-info-trie = trie-insert empty-trie compileFail-qual ((term-decl compileFailType) , "missing" , "missing")
new-qualif : qualif
new-qualif = trie-insert empty-trie compileFail (compileFail-qual , [])
qualif-nonempty : qualif → 𝔹
qualif-nonempty q = trie-nonempty (trie-remove q compileFail)
qualif-insert-params : qualif → var → var → params → qualif
qualif-insert-params σ qv v ps = trie-insert σ v (qv , params-to-args ps)
qualif-insert-import : qualif → var → maybe import-as → 𝕃 string → args → qualif
qualif-insert-import σ mn oa [] as = σ
qualif-insert-import σ mn oa (v :: vs) as = qualif-insert-import (trie-insert σ (maybe-else v (λ {(ImportAs _ pfx) → pfx # v}) oa) (mn # v , as)) mn oa vs as
new-ctxt : (filename modname : string) → ctxt
new-ctxt fn mn =
record {
fn = fn;
mn = mn;
ps = [];
qual = new-qualif;
syms = empty-trie;
mod-map = empty-trie;
id-map = empty-trie;
id-current = 0;
id-list = [];
i = empty-trie;
μ = empty-trie;
μ' = empty-trie;
Is/μ = empty-trie;
μ~ = empty-trie;
μᵤ = nothing;
μ̲ = empty-stringset
}
empty-ctxt : ctxt
empty-ctxt = new-ctxt "" ""
ctxt-get-info : var → ctxt → maybe sym-info
ctxt-get-info v Γ = trie-lookup (ctxt.i Γ) v
ctxt-get-qi : ctxt → var → maybe qualif-info
ctxt-get-qi = trie-lookup ∘ ctxt.qual
ctxt-qualif-args-length : ctxt → erased? → var → maybe ℕ
ctxt-qualif-args-length Γ me v =
ctxt-get-qi Γ v >>= λ qv →
just (if me then length (snd qv) else length (erase-args (snd qv)))
qi-var-if : maybe qualif-info → var → var
qi-var-if (just (v , _)) _ = v
qi-var-if nothing v = v
--ctxt-restore-info : ctxt → var → maybe qualif-info → maybe sym-info → ctxt
--ctxt-restore-info (mk-ctxt (fn , mn , ps , q , ) syms i Δ) v qi si =
-- mk-ctxt (fn , mn , ps , f qi v q) syms (f si (qi-var-if qi v) (trie-remove i (qi-var-if (trie-lookup q v) v))) Δ
-- where
-- f : ∀{A : Set} → maybe A → string → trie A → trie A
-- f (just a) s t = trie-insert t s a
-- f nothing s t = trie-remove t s
--ctxt-restore-info* : ctxt → 𝕃 (string × maybe qualif-info × maybe sym-info) → ctxt
--ctxt-restore-info* Γ [] = Γ
--ctxt-restore-info* Γ ((v , qi , m) :: ms) = ctxt-restore-info* (ctxt-restore-info Γ v qi m) ms
def-params : defScope → params → defParams
def-params tt ps = nothing
def-params ff ps = just ps
inst-term : ctxt → params → args → term → term
inst-term Γ ps as t with subst-params-args ps as
...| σ , ps' , as' = lam-expand-term (substs-params Γ σ ps') (substs Γ σ t)
-- TODO add renamectxt to avoid capture bugs?
inst-type : ctxt → params → args → type → type
inst-type Γ ps as T with subst-params-args ps as
...| σ , ps' , as' = abs-expand-type (substs-params Γ σ ps') (substs Γ σ T)
inst-kind : ctxt → params → args → kind → kind
inst-kind Γ ps as k with subst-params-args ps as
...| σ , ps' , as' = abs-expand-kind (substs-params Γ σ ps') (substs Γ σ k)
inst-ctrs : ctxt → params → args → ctrs → ctrs
inst-ctrs Γ ps as c with subst-params-args ps as
...| σ , ps' , as' = flip map c λ where
(Ctr x T) → Ctr x (abs-expand-type (substs-params Γ σ ps') (substs Γ σ T))
maybe-inst-type = maybe-else (λ as T → T) ∘ inst-type
maybe-inst-kind = maybe-else (λ as T → T) ∘ inst-kind
maybe-inst-ctrs = maybe-else (λ as c → c) ∘ inst-ctrs
ctxt-term-decl : posinfo → var → type → ctxt → ctxt
ctxt-term-decl pi v T Γ =
let v' = pi % v in
record Γ {
qual = qualif-insert-params (ctxt.qual Γ) v' v [];
i = trie-insert (ctxt.i Γ) v' (term-decl T , ctxt.fn Γ , pi)
}
ctxt-type-decl : posinfo → var → kind → ctxt → ctxt
ctxt-type-decl pi v k Γ =
let v' = pi % v in
record Γ {
qual = qualif-insert-params (ctxt.qual Γ) v' v [];
i = trie-insert (ctxt.i Γ) v' (type-decl k , ctxt.fn Γ , pi)
}
ctxt-tk-decl : posinfo → var → tpkd → ctxt → ctxt
ctxt-tk-decl p x (Tkt t) Γ = ctxt-term-decl p x t Γ
ctxt-tk-decl p x (Tkk k) Γ = ctxt-type-decl p x k Γ
infix 4 _,_-_:`_
_,_-_:`_ : ctxt → posinfo → var → tpkd → ctxt
Γ , pi - x :` tk = ctxt-tk-decl pi x tk Γ
-- TODO not sure how this and renaming interacts with module scope
ctxt-var-decl-if : var → ctxt → ctxt
ctxt-var-decl-if v Γ with trie-lookup (ctxt.i Γ) v
... | just (rename-def _ , _) = Γ
... | just (var-decl , _) = Γ
... | _ = ctxt-var-decl v Γ
add-indices-to-ctxt : indices → ctxt → ctxt
add-indices-to-ctxt = flip $ foldr λ {(Index x _) → ctxt-var-decl x}
add-params-to-ctxt : params → ctxt → ctxt
add-params-to-ctxt = flip $ foldr λ {(Param me x _) Γ → if ctxt-binds-var Γ (unqual-local x) then Γ else (ctxt-var-decl x ∘ ctxt-var-decl (unqual-local x)) Γ}
add-caseArgs-to-ctxt : case-args → ctxt → ctxt
add-caseArgs-to-ctxt = flip $ foldr λ {(CaseArg me x _) → ctxt-var-decl x}
add-ctrs-to-ctxt : ctrs → ctxt → ctxt
add-ctrs-to-ctxt = flip $ foldr λ {(Ctr x T) → ctxt-var-decl x}
ctxt-rename-rep : ctxt → var → var
ctxt-rename-rep Γ v with trie-lookup (ctxt.i Γ) v
...| just (rename-def v' , _) = v'
...| _ = v
-- we assume that only the left variable might have been renamed
ctxt-eq-rep : ctxt → var → var → 𝔹
ctxt-eq-rep Γ x y = (ctxt-rename-rep Γ x) =string y
{- add a renaming mapping the first variable to the second, unless they are equal.
Notice that adding a renaming for v will overwrite any other declarations for v. -}
ctxt-rename : var → var → ctxt → ctxt
ctxt-rename v v' Γ =
record Γ {
qual = trie-insert (ctxt.qual Γ) v (v' , []);
i = trie-insert (ctxt.i Γ) v (rename-def v' , missing-location)
}
----------------------------------------------------------------------
-- lookup functions
----------------------------------------------------------------------
-- lookup mod params from filename
lookup-mod-params : ctxt → var → maybe params
lookup-mod-params Γ fn =
trie-lookup (ctxt.syms Γ) fn >>=c λ mn _ →
trie-lookup (ctxt.mod-map Γ) mn >>=c λ fn' → just
-- look for a defined kind for the given var, which is assumed to be a type,
-- then instantiate its parameters
qual-lookup : ctxt → var → maybe (var × args × sym-info)
qual-lookup Γ v =
trie-lookup (ctxt.qual Γ) v >>=c λ qv as →
trie-lookup (ctxt.i Γ) qv >>= λ si →
just (qv , as , si)
env-lookup : ctxt → var → maybe sym-info
env-lookup = trie-lookup ∘ ctxt.i
ctxt-lookup-tpkd-var : ctxt → var → maybe (var × args × tpkd)
ctxt-lookup-tpkd-var Γ v with qual-lookup Γ v
... | just (qv , as , term-decl T , _) = just $ qv , as , Tkt T
... | just (qv , as , type-decl k , _) = just $ qv , as , Tkk k
... | just (qv , as , term-def mps _ t T , _) = just $ qv , as , Tkt (maybe-inst-type Γ mps as T)
... | just (qv , as , ctr-def ps T _ _ _ , _) = just $ qv , as , Tkt (inst-type Γ ps as T)
... | just (qv , as , type-def mps _ T k , _) = just $ qv , as , Tkk (maybe-inst-kind Γ mps as k)
... | _ = nothing
ctxt-lookup-type-var : ctxt → var → maybe (var × args × kind)
ctxt-lookup-type-var Γ v = ctxt-lookup-tpkd-var Γ v >>= λ where
(qv , as , Tkt T) → nothing
(qv , as , Tkk k) → just (qv , as , k)
ctxt-lookup-term-var : ctxt → var → maybe (var × args × type)
ctxt-lookup-term-var Γ v = ctxt-lookup-tpkd-var Γ v >>= λ where
(qv , as , Tkt T) → just (qv , as , T)
(qv , as , Tkk k) → nothing
ctxt-lookup-term-var-def : ctxt → var → maybe term
ctxt-lookup-term-var-def Γ v with env-lookup Γ v
... | just (term-def mps opacity-open (just t) _ , _) = just $ maybe-else id lam-expand-term mps t
... | just (term-udef mps opacity-open t , _) = just $ maybe-else id lam-expand-term mps t
... | _ = nothing
ctxt-lookup-type-var-def : ctxt → var → maybe type
ctxt-lookup-type-var-def Γ v with env-lookup Γ v
... | just (type-def mps opacity-open (just T) _ , _) = just $ maybe-else id lam-expand-type mps T
... | _ = nothing
ctxt-lookup-kind-var-def : ctxt → var → maybe (params × kind)
ctxt-lookup-kind-var-def Γ x with qual-lookup Γ x
...| just (_ , as , kind-def ps k , _) = case subst-params-args' Γ ps as k of λ where
(k' , ps' , as') → just (ps' , k')
...| _ = nothing
ctxt-binds-term-var : ctxt → var → maybe (var × args)
ctxt-binds-term-var Γ x with qual-lookup Γ x
...| just (qx , as , term-def _ _ _ _ , _) = just (qx , as)
...| just (qx , as , term-udef _ _ _ , _) = just (qx , as)
...| just (qx , as , term-decl _ , _) = just (qx , as)
...| just (qx , as , ctr-def _ _ _ _ _ , _) = just (qx , as)
--...| just (qx , as , var-decl , _) = just (qx , as)
...| _ = nothing
ctxt-binds-type-var : ctxt → var → maybe (var × args)
ctxt-binds-type-var Γ x with qual-lookup Γ x
...| just (qx , as , type-def _ _ _ _ , _) = just (qx , as)
...| just (qx , as , type-decl _ , _) = just (qx , as)
...| _ = nothing
{-
inst-enc-defs : ctxt → params → args → encoding-defs → encoding-defs
inst-enc-defs Γ ps as (mk-enc-defs ecs gcs Cast cast-in cast-out cast-is Functor functor-in functor-out Fix fix-in fix-out lambek1 lambek2 fix-ind) =
let as = arg-set-erased tt <$> as in
mk-enc-defs ecs gcs
(inst-type Γ ps as Cast)
(inst-term Γ ps as cast-in)
(inst-term Γ ps as cast-out)
(inst-term Γ ps as cast-is)
(inst-type Γ ps as Functor)
(inst-term Γ ps as functor-in)
(inst-term Γ ps as functor-out)
(inst-type Γ ps as Fix)
(inst-term Γ ps as fix-in)
(inst-term Γ ps as fix-out)
(inst-term Γ ps as lambek1)
(inst-term Γ ps as lambek2)
(inst-term Γ ps as fix-ind)
-}
data-lookup' : ctxt → var → var → 𝕃 tmtp → maybe datatype-info
data-lookup' Γ xₒ x as =
(maybe-else'
{B = maybe (var × args × 𝕃 tmtp ×
params × kind × kind × ctrs × encoding-defs × encoded-defs)}
(trie-lookup (ctxt.μ' Γ) x) -- Is x known locally to be a datatype?
(trie-lookup (ctxt.μ Γ) x >>=c λ ps rest → -- No, so is it a global datatype?
let asₚ = tmtps-to-args-for-params nothing ps as
asᵢ = drop (length ps) as in
just (x , asₚ , asᵢ , ps , rest))
λ where
(x' , as') → -- Yes, it is a local datatype of x', and gives as' as parameters to x'
trie-lookup (ctxt.μ Γ) x' >>= λ rest → just (x' , as' , as , rest))
>>= λ where
(x' , asₚ , asᵢ , ps , kᵢ , k , cs , eds , gds) →
just $ mk-data-info x' xₒ asₚ asᵢ ps
(inst-kind Γ ps asₚ kᵢ)
(inst-kind Γ ps asₚ k)
cs
(inst-ctrs Γ ps asₚ (map-snd (subst Γ (params-to-tpapps ps (TpVar x')) x') <$> cs))
eds {-(inst-enc-defs Γ ps asₚ eds)-}
gds
--λ y → inst-ctrs Γ ps asₚ (map-snd (rename-var {TYPE} Γ x' y) <$> cs)
data-lookup : ctxt → var → 𝕃 tmtp → maybe datatype-info
data-lookup Γ x = data-lookup' Γ x x
data-lookup-mu : ctxt → var → var → 𝕃 tmtp → maybe datatype-info
data-lookup-mu Γ xₒ x as =
trie-lookup (ctxt.Is/μ Γ) x >>= λ x' → data-lookup' Γ xₒ x' as
data-highlight : ctxt → var → ctxt
data-highlight Γ x = record Γ { μ̲ = stringset-insert (ctxt.μ̲ Γ) x }
ctxt-lookup-term-loc : ctxt → var → maybe location
ctxt-lookup-term-loc Γ x = qual-lookup Γ x >>= λ where
(_ , _ , term-decl _ , loc) → just loc
(_ , _ , term-def _ _ _ _ , loc) → just loc
(_ , _ , term-udef _ _ _ , loc) → just loc
(_ , _ , ctr-def _ _ _ _ _ , loc) → just loc
(_ , _ , var-decl , loc) → just loc
_ → nothing
ctxt-lookup-type-loc : ctxt → var → maybe location
ctxt-lookup-type-loc Γ x = qual-lookup Γ x >>= λ where
(_ , _ , type-decl _ , loc) → just loc
(_ , _ , type-def _ _ _ _ , loc) → just loc
(_ , _ , var-decl , loc) → just loc
_ → nothing
----------------------------------------------------------------------
ctxt-var-location : ctxt → var → location
ctxt-var-location Γ x with trie-lookup (ctxt.i Γ) x
... | just (_ , l) = l
... | nothing = missing-location
ctxt-clarify-def : ctxt → opacity → var → maybe ctxt
ctxt-clarify-def Γ o x with qual-lookup Γ x
...| just (qx , as , type-def ps o' T? k , loc) =
ifMaybej (o xor o') (record Γ { i = trie-insert (ctxt.i Γ) qx (type-def ps o T? k , loc) })
...| just (qx , as , term-def ps o' t? T , loc) =
ifMaybej (o xor o') (record Γ { i = trie-insert (ctxt.i Γ) qx (term-def ps o t? T , loc) })
...| just (qx , as , term-udef ps o' t , loc) =
ifMaybej (o xor o') (record Γ { i = trie-insert (ctxt.i Γ) qx (term-udef ps o t , loc) })
...| _ = nothing
ctxt-set-current-file : ctxt → string → string → ctxt
ctxt-set-current-file Γ fn mn = record Γ { fn = fn; mn = mn; ps = []; qual = new-qualif }
ctxt-set-current-mod : ctxt → string × string × params × qualif → ctxt
ctxt-set-current-mod Γ (fn , mn , ps , qual) = record Γ { fn = fn; mn = mn; ps = ps; qual = qual }
ctxt-add-current-params : ctxt → ctxt
ctxt-add-current-params Γ =
record Γ {
syms = trie-insert (ctxt.syms Γ) (ctxt.fn Γ) (ctxt.mn Γ , []);
mod-map = trie-insert (ctxt.mod-map Γ) (ctxt.mn Γ) (ctxt.fn Γ , ctxt.ps Γ)
}
ctxt-clear-symbol : ctxt → string → ctxt
ctxt-clear-symbol Γ x =
let qx = qualif-var Γ x in
record Γ {
qual = trie-remove (ctxt.qual Γ) x;
syms = trie-map (λ ss → fst ss , remove _=string_ x (snd ss)) (ctxt.syms Γ);
i = trie-remove (ctxt.i Γ) qx;
μ = trie-remove (ctxt.μ Γ) qx;
Is/μ = trie-remove (ctxt.Is/μ Γ) qx;
μ̲ = trie-remove (ctxt.μ̲ Γ) qx
}
ctxt-clear-symbols : ctxt → 𝕃 string → ctxt
ctxt-clear-symbols Γ [] = Γ
ctxt-clear-symbols Γ (v :: vs) = ctxt-clear-symbols (ctxt-clear-symbol Γ v) vs
ctxt-clear-symbols-of-file : ctxt → (filename : string) → ctxt
ctxt-clear-symbols-of-file Γ fn =
elim-pair (trie-lookup𝕃2 (ctxt.syms Γ) fn) λ mn xs →
let ps = maybe-else' (trie-lookup (ctxt.mod-map Γ) mn) [] snd in
record Γ {
syms = trie-insert (ctxt.syms Γ) fn (mn , []);
mod-map = trie-insert (ctxt.mod-map Γ) mn (fn , ps);
i = hremove (ctxt.i Γ) mn xs;
μ = hremove (ctxt.μ Γ) mn xs;
Is/μ = hremove (ctxt.Is/μ Γ) mn xs;
μ̲ = hremove (ctxt.μ̲ Γ) mn xs
}
where
hremove : ∀ {A : Set} → trie A → var → 𝕃 string → trie A
hremove i mn [] = i
hremove i mn (x :: xs) = hremove (trie-remove i (mn # x)) mn xs
ctxt-add-current-id : ctxt → ctxt
ctxt-add-current-id Γ with trie-contains (ctxt.id-map Γ) (ctxt.fn Γ)
...| tt = Γ
...| ff =
record Γ {
id-map = trie-insert (ctxt.id-map Γ) (ctxt.fn Γ) (suc (ctxt.id-current Γ));
id-current = suc (ctxt.id-current Γ);
id-list = ctxt.fn Γ :: ctxt.id-list Γ
}
ctxt-initiate-file : ctxt → (filename modname : string) → ctxt
ctxt-initiate-file Γ fn mn = ctxt-add-current-id (ctxt-set-current-file (ctxt-clear-symbols-of-file Γ fn) fn mn)
unqual : ctxt → var → string
unqual Γ v =
if qualif-nonempty (ctxt.qual Γ)
then unqual-local (unqual-all (ctxt.qual Γ) v)
else v
qualified-ctxt : ctxt → ctxt
qualified-ctxt Γ = -- use ctxt.i so we bring ALL defs (even from cousin modules, etc...) into scope
record Γ {qual = for trie-strings (ctxt.i Γ) accum empty-trie use λ x q → trie-insert q x (x , [])}
| 37.535354
| 158
| 0.605221
|
a1cde73d57ec71d83b05f86e8794d68ed5be1180
| 651
|
agda
|
Agda
|
agda-stdlib/src/Data/List/Relation/Sublist/Propositional/Properties.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/List/Relation/Sublist/Propositional/Properties.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/List/Relation/Sublist/Propositional/Properties.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- This module is DEPRECATED. Please use
-- Data.List.Relation.Binary.Sublist.Propositional.Properties directly.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.List.Relation.Sublist.Propositional.Properties where
open import Data.List.Relation.Binary.Sublist.Propositional.Properties
public
{-# WARNING_ON_IMPORT
"Data.List.Relation.Sublist.Propositional.Properties was deprecated in v1.0.
Use Data.List.Relation.Binary.Sublist.Propositional.Properties instead."
#-}
| 34.263158
| 76
| 0.614439
|
2e80d65f33c6c750d661045c106e7d802db8892b
| 2,665
|
agda
|
Agda
|
examples/AIM6/HelloAgda/Records.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
examples/AIM6/HelloAgda/Records.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
examples/AIM6/HelloAgda/Records.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-
Agda Implementors' Meeting VI
Göteborg
May 24 - 30, 2007
Hello Agda!
Ulf Norell
-}
-- Records are labeled sigma types.
module Records where
open import Naturals
open import Bool
{-
A very simple record.
-}
record Point : Set where
field x : Nat
y : Nat
-- A record can be seen as a one constructor datatype. In this case:
data Point' : Set where
mkPoint : (x : Nat)(y : Nat) -> Point'
-- There are a few differences, though:
-- To construct a record you use the syntax record { ..; x = e; .. }
origin : Point
origin = record { x = 0; y = 0 }
-- instead of
origin' : Point'
origin' = mkPoint 0 0
-- What's more interesting is that you get projection functions
-- for free when you declare a record. More precisely, you get a module
-- parameterised over a record, containing functions corresponding to the
-- fields. In the Point example you get:
{-
module Point (p : Point) where
x : Nat
y : Nat
-}
-- So Point.x : Point -> Nat is the projection function for the field x.
getX : Point -> Nat
getX = Point.x
-- A nifty thing with having the projection functions in a module is that
-- you can apply the module to a record value, in effect opening the record.
sum : Point -> Nat
sum p = x + y
where
open module Pp = Point p
-- The final difference between records and datatypes is that we have
-- η-equality on records.
data _==_ {A : Set}(x : A) : A -> Set where
refl : x == x
η-Point : (p : Point) -> p == record { x = Point.x p; y = Point.y p }
η-Point p = refl
{-
The empty record
-}
-- One interesting benefit of this is that we get a unit type with
-- η-equality.
record True : Set where
tt : True
tt = record{}
-- Now, since any element of True is equal to tt, metavariables of
-- type True will simply disappear. The following cute example exploits
-- this:
data False : Set where
NonZero : Nat -> Set
NonZero zero = False
NonZero (suc _) = True
-- We make the proof that m is non-zero implicit.
_/_ : (n m : Nat){p : NonZero m} -> Nat
(n / zero) {}
zero / suc m = zero
suc n / suc m = div (suc n) (suc m) m
where
div : Nat -> Nat -> Nat -> Nat
div zero zero c = suc zero
div zero (suc y) c = zero
div (suc x) zero c = suc (div x c c)
div (suc x) (suc y) c = div x y c
-- Now, as long as we're dividing by things which are obviously
-- NonZero we can completely ignore the proof.
five = 17 / 3
{-
A dependent record
-}
-- Of course, records can be dependent, and have parameters.
record ∃ {A : Set}(P : A -> Set) : Set where
field
witness : A
proof : P witness
| 20.820313
| 76
| 0.628893
|
2227733294ba3389a8d0bbf41bc13f475a11f835
| 1,194
|
agda
|
Agda
|
src/Network.agda
|
ilya-fiveisky/agda-network
|
06defd709b073f951723d7e717fcf96ee30567eb
|
[
"Unlicense"
] | null | null | null |
src/Network.agda
|
ilya-fiveisky/agda-network
|
06defd709b073f951723d7e717fcf96ee30567eb
|
[
"Unlicense"
] | null | null | null |
src/Network.agda
|
ilya-fiveisky/agda-network
|
06defd709b073f951723d7e717fcf96ee30567eb
|
[
"Unlicense"
] | null | null | null |
module Network where
open import Data.Fin hiding (lift; _<_)
open import Function
open import Data.Nat
open import Data.Nat.Show
open import Data.String hiding (show)
open import Data.Vec hiding (_++_)
open import Foreign.Haskell
open import IO
import IO.Primitive as IOPrim
import Network.Primitive as NetPrim
withSocketsDo : ∀ {a} {A : Set a} → IO A → IO A
withSocketsDo io = lift (NetPrim.withSocketsDo (run io))
byteSize : ℕ
byteSize = 256
wordSize : ℕ
wordSize = byteSize * byteSize
data IPAddress : Set where
IPv4 : Vec (Fin byteSize) 4 → IPAddress
IPv6 : Vec (Fin wordSize) 8 → IPAddress
{-
private
showIPVec : {m n : ℕ} → Vec (Fin m) n → String
showIPVec ip = foldl₁ (λ x y → x ++ "." ++ y) (map (show ∘ toℕ) ip)
-}
showIP : IPAddress → String
showIP (IPv4 ip) = foldl₁ (λ x y → x ++ "." ++ y) (map (show ∘ toℕ) ip)
showIP (IPv6 ip) = foldl₁ (λ x y → x ++ ":" ++ y) (map ((showInBase 16) ∘ toℕ) ip)
data PortNumber : Set where
portNum : Fin wordSize → PortNumber
showPort : PortNumber → String
showPort (portNum n) = show (toℕ n)
connectTo : IPAddress → PortNumber → IO IOPrim.Handle
connectTo ip (portNum n) = lift (NetPrim.connectTo (showIP ip) (toInteger (toℕ n)))
| 26.533333
| 83
| 0.68258
|
add18cfe528ec1fd05214a1d3afa030a9d4f4ebb
| 1,175
|
agda
|
Agda
|
test/Fail/Issue1427a.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue1427a.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue1427a.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2015-01-19 Forced constructor arguments should not
-- give rise to unification constraints.
-- Andreas, 2015-02-27 Forcing analysis is too fragile to have
-- such a huge impact. The problem has to be addressed by
-- putting heterogeneous unification on a solid foundation.
-- Jesper, 2015-12-18 The new unifier now correctly rejects this example.
-- {-# OPTIONS -v tc.lhs.unify:15 #-}
-- {-# OPTIONS -v tc.force:10 #-}
open import Common.Equality
open import Common.Prelude
data HEq (A : Set) (a : A) : (B : Set) (b : B) → Set1 where
refl : HEq A a A a
data Fin : (n : Nat) → Set where
zero : {n : Nat} → Fin (suc n)
suc : {n : Nat} (i : Fin n) → Fin (suc n)
inj-Fin-≅ : ∀ {n m} {i : Fin n} {j : Fin m} → HEq (Fin n) i (Fin m) j → n ≡ m
inj-Fin-≅ {i = zero} {zero } refl = refl -- Expected to fail, as n /= m
inj-Fin-≅ {i = zero} {suc j} ()
inj-Fin-≅ {i = suc i} {zero } ()
inj-Fin-≅ {i = suc i} {suc .i} refl = refl -- Expected to fail, as n /= m
-- This should not be accepted, as the direct attempt also fails:
-- inj-Fin-≅' : ∀ {n m} {i : Fin n} {j : Fin m} → HEq (Fin n) i (Fin m) j → n ≡ m
-- inj-Fin-≅' refl = refl
| 34.558824
| 81
| 0.593191
|
50b0cc650606f6aee96363f53c15686e056303cd
| 8,424
|
agda
|
Agda
|
src/Erased/With-K.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | 3
|
2020-05-21T22:58:50.000Z
|
2021-09-02T17:18:15.000Z
|
src/Erased/With-K.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | null | null | null |
src/Erased/With-K.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- Some theory of Erased, developed using the K rule and propositional
-- equality
------------------------------------------------------------------------
-- This module instantiates and reexports code from Erased.
{-# OPTIONS --with-K --safe #-}
module Erased.With-K where
open import Equality.Propositional
open import Logical-equivalence using (_⇔_)
open import Prelude
open import Bijection equality-with-J using (_↔_)
open import Embedding equality-with-J as Emb using (Is-embedding)
open import Equivalence equality-with-J as Eq
using (_≃_; Is-equivalence)
import Erased.Basics as EB
import Erased.Level-1 equality-with-J as E
open import H-level equality-with-J
open import Injection equality-with-J using (Injective)
private
variable
a b p : Level
A : Type a
------------------------------------------------------------------------
-- Code related to the module Erased
-- Given an erased proof of equality of x and y one can show that
-- [ x ] is equal to [ y ].
[]-cong : {@0 A : Type a} {@0 x y : A} →
EB.Erased (x ≡ y) → EB.[ x ] ≡ EB.[ y ]
[]-cong EB.[ refl ] = refl
-- []-cong is an equivalence.
[]-cong-equivalence :
{@0 A : Type a} {@0 x y : A} →
Is-equivalence ([]-cong {x = x} {y = y})
[]-cong-equivalence {x = x} {y = y} = _≃_.is-equivalence (Eq.↔⇒≃ (record
{ surjection = record
{ logical-equivalence = record
{ to = []-cong
; from = λ eq → EB.[ cong EB.erased eq ]
}
; right-inverse-of = λ { refl → refl }
}
; left-inverse-of = λ { EB.[ refl ] → refl }
}))
-- []-cong maps [ refl ] to refl (by definition).
[]-cong-[refl] :
{@0 A : Type a} {@0 x : A} →
[]-cong EB.[ refl {x = x} ] ≡ refl {x = EB.[ x ]}
[]-cong-[refl] = refl
-- The []-cong axioms can be instantiated.
instance-of-[]-cong-axiomatisation : E.[]-cong-axiomatisation a
instance-of-[]-cong-axiomatisation = λ where
.E.[]-cong-axiomatisation.[]-cong → []-cong
.E.[]-cong-axiomatisation.[]-cong-equivalence → []-cong-equivalence
.E.[]-cong-axiomatisation.[]-cong-[refl] → []-cong-[refl]
-- Some reexported definitions.
open import Erased equality-with-J instance-of-[]-cong-axiomatisation
public
hiding ([]-cong; []-cong-equivalence; []-cong-[refl]; Injective-[];
Π-Erased≃Π0[]; Π-Erased≃Π0)
------------------------------------------------------------------------
-- Other code
-- [_]→ is injective.
Injective-[] : {@0 A : Type a} → Injective [ A ∣_]→
Injective-[] refl = refl
-- [_]→ is an embedding.
Is-embedding-[] : {@0 A : Type a} → Is-embedding [ A ∣_]→
Is-embedding-[] _ _ =
(λ { refl → refl })
, (λ { refl → refl })
, (λ { refl → refl })
, (λ { refl → refl })
-- If Erased A is a proposition, then A is a proposition.
Is-proposition-Erased→Is-proposition :
{@0 A : Type a} →
Is-proposition (Erased A) → Is-proposition A
Is-proposition-Erased→Is-proposition prop x y =
Injective-[] (prop [ x ] [ y ])
-- A variant of the previous result.
H-level′-1-Erased→H-level′-1 :
{@0 A : Type a} →
H-level′ 1 (Erased A) → H-level′ 1 A
H-level′-1-Erased→H-level′-1 prop x y
with proj₁ (prop [ x ] [ y ])
... | refl = refl , λ { refl → refl }
-- Equality is always very stable.
Very-stable-≡-trivial : Very-stable-≡ A
Very-stable-≡-trivial =
_⇔_.from (Very-stable-≡↔Is-embedding-[] _)
Is-embedding-[]
-- The following four results are inspired by a result in
-- Mishra-Linger's PhD thesis (see Section 5.4.1).
-- There is a bijection between (x : Erased A) → P x and
-- (@0 x : A) → P [ x ].
Π-Erased↔Π0[] :
{@0 A : Type a} {@0 P : Erased A → Type p} →
((x : Erased A) → P x) ↔ ((@0 x : A) → P [ x ])
Π-Erased↔Π0[] = record
{ surjection = record
{ logical-equivalence = Π-Erased⇔Π0
; right-inverse-of = λ _ → refl
}
; left-inverse-of = λ _ → refl
}
-- There is an equivalence between (x : Erased A) → P x and
-- (@0 x : A) → P [ x ].
--
-- This is not proved by converting Π-Erased↔Π0[] to an equivalence,
-- because the type arguments of the conversion function in
-- Equivalence are not erased, and P can only be used in erased
-- contexts.
--
-- This is a strengthening of E.Π-Erased≃Π0[].
Π-Erased≃Π0[] :
{@0 A : Type a} {@0 P : Erased A → Type p} →
((x : Erased A) → P x) ≃ ((@0 x : A) → P [ x ])
Π-Erased≃Π0[] = record
{ to = λ f x → f [ x ]
; is-equivalence =
(λ f ([ x ]) → f x)
, (λ _ → refl)
, (λ _ → refl)
, (λ _ → refl)
}
-- There is a bijection between (x : Erased A) → P (erased x) and
-- (@0 x : A) → P x.
Π-Erased↔Π0 :
{@0 A : Type a} {@0 P : A → Type p} →
((x : Erased A) → P (erased x)) ↔ ((@0 x : A) → P x)
Π-Erased↔Π0 = Π-Erased↔Π0[]
-- There is an equivalence between (x : Erased A) → P (erased x) and
-- (@0 x : A) → P x.
--
-- This is a strengthening of E.Π-Erased≃Π0.
Π-Erased≃Π0 :
{@0 A : Type a} {@0 P : A → Type p} →
((x : Erased A) → P (erased x)) ≃ ((@0 x : A) → P x)
Π-Erased≃Π0 = Π-Erased≃Π0[]
private
-- As an aside it is possible to prove the four previous results
-- without relying on eta-equality for Erased. However, the code
-- makes use of extensionality, and it also makes use of
-- eta-equality for Π. (The use of η-equality for Π could perhaps be
-- avoided, but Agda does not, at the time of writing, provide a
-- simple way to turn off this kind of η-equality.)
data Erased-no-η (@0 A : Type a) : Type a where
[_] : @0 A → Erased-no-η A
@0 erased-no-η : Erased-no-η A → A
erased-no-η [ x ] = x
-- Some lemmas.
Π-Erased-no-η→Π0[] :
{@0 A : Type a} {@0 P : Erased-no-η A → Type p} →
((x : Erased-no-η A) → P x) → (@0 x : A) → P [ x ]
Π-Erased-no-η→Π0[] f x = f [ x ]
Π0[]→Π-Erased-no-η :
{@0 A : Type a} (@0 P : Erased-no-η A → Type p) →
((@0 x : A) → P [ x ]) → (x : Erased-no-η A) → P x
Π0[]→Π-Erased-no-η _ f [ x ] = f x
Π0[]→Π-Erased-no-η-Π-Erased-no-η→Π0[] :
{@0 A : Type a} {@0 P : Erased-no-η A → Type p}
(f : (x : Erased-no-η A) → P x) (x : Erased-no-η A) →
Π0[]→Π-Erased-no-η P (Π-Erased-no-η→Π0[] f) x ≡ f x
Π0[]→Π-Erased-no-η-Π-Erased-no-η→Π0[] f [ x ] = refl
-- There is a bijection between (x : Erased-no-η A) → P x and
-- (@0 x : A) → P [ x ] (assuming extensionality).
Π-Erased-no-η↔Π0[] :
{@0 A : Type a} {@0 P : Erased-no-η A → Type p} →
Extensionality′ (Erased-no-η A) P →
((x : Erased-no-η A) → P x) ↔ ((@0 x : A) → P [ x ])
Π-Erased-no-η↔Π0[] {P = P} ext = record
{ surjection = record
{ logical-equivalence = record
{ to = Π-Erased-no-η→Π0[]
; from = Π0[]→Π-Erased-no-η _
}
; right-inverse-of = λ _ → refl
}
; left-inverse-of = λ f →
ext (Π0[]→Π-Erased-no-η-Π-Erased-no-η→Π0[] f)
}
-- There is an equivalence between (x : Erased-no-η A) → P x and
-- (@0 x : A) → P [ x ] (assuming extensionality).
--
-- This is not proved by converting Π-Erased-no-η↔Π0[] to an
-- equivalence, because the type arguments of the conversion
-- function in Equivalence are not erased, and A and P can only be
-- used in erased contexts.
Π-Erased-no-η≃Π0[] :
{@0 A : Type a} {@0 P : Erased-no-η A → Type p} →
Extensionality′ (Erased-no-η A) P →
((x : Erased-no-η A) → P x) ≃ ((@0 x : A) → P [ x ])
Π-Erased-no-η≃Π0[] {A = A} {P = P} ext = record
{ to = λ f x → f [ x ]
; is-equivalence =
Π0[]→Π-Erased-no-η _
, (λ _ → refl)
, (λ f → ext (Π0[]→Π-Erased-no-η-Π-Erased-no-η→Π0[] f))
, (λ _ → uip _ _)
}
where
uip : {@0 B : Type b} {@0 x y : B} (@0 p q : x ≡ y) → p ≡ q
uip refl refl = refl
-- There is a bijection between
-- (x : Erased-no-η A) → P (erased-no-η x) and (@0 x : A) → P x
-- (assuming extensionality).
Π-Erased-no-η↔Π0 :
{@0 A : Type a} {@0 P : A → Type p} →
Extensionality′ (Erased-no-η A) (P ∘ erased-no-η) →
((x : Erased-no-η A) → P (erased-no-η x)) ↔ ((@0 x : A) → P x)
Π-Erased-no-η↔Π0 = Π-Erased-no-η↔Π0[]
-- There is an equivalence between
-- (x : Erased-no-η A) → P (erased-no-η x) and (@0 x : A) → P x
-- (assuming extensionality).
Π-Erased-no-η≃Π0 :
{@0 A : Type a} {@0 P : A → Type p} →
Extensionality′ (Erased-no-η A) (P ∘ erased-no-η) →
((x : Erased-no-η A) → P (erased-no-η x)) ≃ ((@0 x : A) → P x)
Π-Erased-no-η≃Π0 = Π-Erased-no-η≃Π0[]
| 31.084871
| 72
| 0.540717
|
3d726055f8587bf3862d990841deb3d0a175b90d
| 417
|
agda
|
Agda
|
test/interaction/Issue3316.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 2
|
2019-10-29T09:40:30.000Z
|
2020-09-20T00:28:57.000Z
|
test/interaction/Issue3316.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/interaction/Issue3316.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
module _ where
open import Agda.Builtin.List
open import Agda.Builtin.Reflection
macro
easy : Term → TC _
easy t =
bindTC (freshName "A") λ A →
bindTC (declarePostulate (arg (arg-info visible relevant) A)
(agda-sort (lit 0))) λ _ →
unify (def A []) t
B : Set
B = {!easy!}
-- WAS:
-- Parse error
-- ;<ERROR>
-- Example.A...
-- SHOULD: complain that A is not in scope
| 17.375
| 64
| 0.58753
|
3151b2f5662cd41ce63cc6e493af2e564b826577
| 9,286
|
agda
|
Agda
|
homotopy/LoopSpaceCircle.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | 1
|
2021-06-30T00:17:55.000Z
|
2021-06-30T00:17:55.000Z
|
homotopy/LoopSpaceCircle.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | null | null | null |
homotopy/LoopSpaceCircle.agda
|
danbornside/HoTT-Agda
|
1695a7f3dc60177457855ae846bbd86fcd96983e
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import HoTT
{-
This file contains three proofs of Ω(S¹) = ℤ and the fact that the circle is
a 1-type:
- Something closely related to Mike’s original proof
- Dan’s encode-decode proof
- Guillaume’s proof using the flattening lemma.
This file is divided in a lot of different parts so that common parts can be
factored:
1. Definition of the universal cover and the encoding map (this part is common
to all three proofs)
2. Proof that [encode (loop^ n) == n] (this part is common to Mike’s proof and
the encode-decode proof)
3. Dan’s encode-decode proof that [Ω S¹ ≃ ℤ]
4. Mike’s proof that [Σ S¹ Cover] is contractible
5. Proof with the flattening lemma that [Σ S¹ S¹Cover] is contractible
6. Proof of [Ω S¹ ≃ ℤ] using the fact that [Σ S¹ S¹Cover] is contractible (common
to Mike’s proof and the flattening lemma proof)
7. Encode-decode proof of the whole equivalence
8. Proof that the circle is a 1-type (common to all three proofs)
Keep
- 1, 2, 3 for the encode-decode proof (+ 7, 8 for S¹ is a 1-type)
- 1, 2, 4, 6 for Mike’s proof (+ 8)
- 1, 5, 6 for the flattening lemma proof (+ 8)
-}
module homotopy.LoopSpaceCircle where
{- 1. Universal cover and encoding map (common to all three proofs) -}
module S¹Cover = S¹RecType ℤ succ-equiv
S¹Cover : S¹ → Type₀
S¹Cover = S¹Cover.f
encode : {x : S¹} (p : base == x) → S¹Cover x
encode p = transport S¹Cover p O
{- 2. Encoding [loop^ n] (common to Mike’s proof and the encode-decode proof) -}
-- We define the element of [Ω S¹] which is supposed to correspond to an
-- integer [n], this is the loop winding around the circle [n] times.
-- This is easy by induction on [n]
loop^ : (n : ℤ) → base == base
loop^ O = idp
loop^ (pos O) = loop
loop^ (pos (S n)) = loop^ (pos n) ∙ loop
loop^ (neg O) = ! loop
loop^ (neg (S n)) = loop^ (neg n) ∙ (! loop)
-- Compatibility of [loop^] with the successor function
-- This is again not difficult by induction on [n]
loop^succ : (n : ℤ) → loop^ n ∙ loop == loop^ (succ n)
loop^succ O = idp
loop^succ (pos n) = idp
loop^succ (neg O) = !-inv-l loop
loop^succ (neg (S n)) =
(loop^ (neg n) ∙ ! loop) ∙ loop
=⟨ ∙-assoc (loop^ (neg n)) (! loop) loop ⟩
loop^ (neg n) ∙ (! loop ∙ loop)
=⟨ !-inv-l loop |in-ctx (λ u → loop^ (neg n) ∙ u) ⟩
loop^ (neg n) ∙ idp
=⟨ ∙-unit-r _ ⟩
loop^ (neg n) ∎
-- Now we check that encoding [loop^ n] gives indeed [n], again by induction
-- on [n]
encode-loop^ : (n : ℤ) → encode (loop^ n) == n
encode-loop^ O = idp
encode-loop^ (pos O) = S¹Cover.coe-loop-β O
encode-loop^ (pos (S n)) =
encode (loop^ (pos n) ∙ loop) =⟨ idp ⟩
coe (ap S¹Cover (loop^ (pos n) ∙ loop)) O
=⟨ ap-∙ S¹Cover (loop^ (pos n)) loop |in-ctx (λ u → coe u O) ⟩
coe (ap S¹Cover (loop^ (pos n)) ∙ ap S¹Cover loop) O
=⟨ coe-∙ (ap S¹Cover (loop^ (pos n)))
(ap S¹Cover loop) O ⟩
coe (ap S¹Cover loop) (coe (ap S¹Cover (loop^ (pos n))) O)
=⟨ encode-loop^ (pos n) |in-ctx coe (ap S¹Cover loop) ⟩
coe (ap S¹Cover loop) (pos n)
=⟨ S¹Cover.coe-loop-β (pos n) ⟩
pos (S n) ∎
encode-loop^ (neg O) =
coe (ap S¹Cover (! loop)) O =⟨ coe-ap-! S¹Cover loop O ⟩
coe! (ap S¹Cover loop) O =⟨ S¹Cover.coe!-loop-β O ⟩
neg O ∎
encode-loop^ (neg (S n)) =
encode (loop^ (neg n) ∙ ! loop) =⟨ idp ⟩
coe (ap S¹Cover (loop^ (neg n) ∙ ! loop)) O
=⟨ ap-∙ S¹Cover (loop^ (neg n)) (! loop)
|in-ctx (λ u → coe u O) ⟩
coe (ap S¹Cover (loop^ (neg n)) ∙ ap S¹Cover (! loop)) O
=⟨ coe-∙ (ap S¹Cover (loop^ (neg n)))
(ap S¹Cover (! loop)) O ⟩
coe (ap S¹Cover (! loop)) (coe (ap S¹Cover (loop^ (neg n))) O)
=⟨ encode-loop^ (neg n) |in-ctx coe (ap S¹Cover (! loop)) ⟩
coe (ap S¹Cover (! loop)) (neg n)
=⟨ coe-ap-! S¹Cover loop (neg n) ⟩
coe! (ap S¹Cover loop) (neg n)
=⟨ S¹Cover.coe!-loop-β (neg n) ⟩
neg (S n) ∎
{- 3. Dan’s encode-decode proof -}
-- The decoding function at [base] is [loop^], but we extend it to the whole
-- of [S¹] so that [decode-encode] becomes easier (and we need [loop^succ] to
-- be able to extend it)
decode : (x : S¹) → (S¹Cover x → base == x)
decode =
S¹-elim loop^ (↓-→-in (λ {n} q →
↓-cst=idf-in
(loop^succ n ∙ ap loop^ (S¹Cover.↓-loop-out q))))
decode-encode : (x : S¹) (p : base == x) → decode x (encode p) == p
decode-encode _ p = J (λ x p → decode x (encode p) == p) idp p -- Magic!
-- And we get the theorem
ΩS¹≃ℤ : (base == base) ≃ ℤ
ΩS¹≃ℤ = equiv encode (decode base) encode-loop^ (decode-encode base)
{- 4. Mike’s proof that [Σ S¹ Cover] is contractible -}
-- We want to prove that every point of [Σ S¹ S¹Cover] is equal to [(base , O)]
paths-mike : (xt : Σ S¹ S¹Cover) → (base , O) == xt
paths-mike (x , t) = paths-mike-c x t where
-- We do it by circle-induction on the first component. When it’s [base],
-- we use the [↓-loop^] below (which is essentially [encode-loop^]) and
-- for [loop] we use [loop^succ] and the fact that [ℤ] is a set.
paths-mike-c : (x : S¹) (t : S¹Cover x) → (base , O) == (x , t) :> Σ S¹ S¹Cover
paths-mike-c = S¹-elim
(λ n → pair= (loop^ n) (↓-loop^ n))
(↓-Π-in (λ {n} {n'} q →
↓-cst=idf-in
(pair= (loop^ n) (↓-loop^ n) ∙ pair= loop q
=⟨ Σ-∙ (↓-loop^ n) q ⟩
pair= (loop^ n ∙ loop) (↓-loop^ n ∙ᵈ q)
=⟨ pair== (loop^succ n ∙ ap loop^ (S¹Cover.↓-loop-out q))
(set-↓-has-all-paths-↓ ℤ-is-set) ⟩
pair= (loop^ n') (↓-loop^ n') ∎))) where
↓-loop^ : (n : ℤ) → O == n [ S¹Cover ↓ loop^ n ]
↓-loop^ n = from-transp _ _ (encode-loop^ n)
contr-mike : is-contr (Σ S¹ S¹Cover)
contr-mike = ((base , O) , paths-mike)
{- 5. Flattening lemma proof that [Σ S¹ Cover] is contractible -}
--We import the flattening lemma for the universal cover of the circle
--open FlatteningS¹ ℤ succ-equiv
open S¹Cover using (module Wt; Wt; cct; ppt; flattening-S¹)
-- We prove that the flattened HIT corresponding to the universal cover of the
-- circle (the real line) is contractible
Wt-is-contr : is-contr Wt
Wt-is-contr = (cct tt O , Wt.elim (base* ∘ snd) (loop* ∘ snd)) where
-- This is basically [loop^]
base* : (n : ℤ) → cct tt O == cct tt n
base* O = idp
base* (pos O) = ppt tt O
base* (pos (S n)) = base* (pos n) ∙ ppt tt (pos n)
base* (neg O) = ! (ppt tt (neg O))
base* (neg (S n)) = base* (neg n) ∙ ! (ppt tt (neg (S n)))
loop* : (n : ℤ)
→ base* n == base* (succ n) [ (λ x → cct tt O == x) ↓ ppt tt n ]
loop* n = ↓-cst=idf-in (aux n) where
-- This is basically [loop^succ]
aux : (n : ℤ) → base* n ∙ ppt tt n == base* (succ n)
aux O = idp
aux (pos n) = idp
aux (neg O) = !-inv-l (ppt tt (neg O))
aux (neg (S n)) =
base* (neg (S n)) ∙ ppt tt (neg (S n))
=⟨ idp ⟩
(base* (neg n) ∙ ! (ppt tt (neg (S n)))) ∙ ppt tt (neg (S n))
=⟨ ∙-assoc (base* (neg n)) _ _ ⟩
base* (neg n) ∙ (! (ppt tt (neg (S n))) ∙ ppt tt (neg (S n)))
=⟨ !-inv-l (ppt tt (neg (S n)))
|in-ctx (λ u → base* (neg n) ∙ u) ⟩
base* (neg n) ∙ idp
=⟨ ∙-unit-r _ ⟩
base* (neg n) ∎
-- Then, using the flattening lemma we get that the total space of [Cover] is
-- contractible
contr-flattening : is-contr (Σ S¹ S¹Cover)
contr-flattening = transport! is-contr flattening-S¹ Wt-is-contr
{- 6. Proof that [Ω S¹ ≃ ℤ] using the fact that [Σ S¹ Cover] is contractible -}
tot-encode : Σ S¹ (λ x → base == x) → Σ S¹ S¹Cover
tot-encode (x , y) = (x , encode y)
-- The previous map induces an equivalence on the total spaces, because both
-- total spaces are contractible
total-is-equiv : is-equiv tot-encode
total-is-equiv = contr-to-contr-is-equiv _ (pathfrom-is-contr base) contr-flattening
-- Hence it’s an equivalence fiberwise
postulate -- TODO, will be only one line using the fact that an equivalence on
-- total spaces induces an equivalence fiberwise
encode-is-equiv : (x : S¹) → is-equiv (encode {x})
-- We can then conclude that the loop space of the circle is equivalent to [ℤ]
ΩS¹≃ℤ' : (base == base) ≃ ℤ
ΩS¹≃ℤ' = (encode {base} , encode-is-equiv base)
{- 7. Encode-decode proof of the whole fiberwise equivalence -}
-- This is quite similar to [paths-mike], we’re doing it by circle-induction,
-- the base case is [encode-loop^] and the loop case is using the fact that [ℤ]
-- is a set (and [loop^succ] is already used in [decode])
encode-decode : (x : S¹) (t : S¹Cover x) → encode (decode x t) == t
encode-decode =
S¹-elim {P = λ x → (t : S¹Cover x) → encode (decode x t) == t}
encode-loop^ (↓-Π-in (λ q → prop-has-all-paths-↓ (ℤ-is-set _ _)))
encode-is-equiv' : (x : S¹) → is-equiv (encode {x})
encode-is-equiv' x = is-eq encode (decode x) (encode-decode x) (decode-encode x)
{- 8. Proof that the circle is a 1-type -}
S¹Cover-is-set : (y : S¹) → is-set (S¹Cover y)
S¹Cover-is-set = S¹-elim ℤ-is-set (prop-has-all-paths-↓ is-set-is-prop)
ΩS¹-is-set : (y : S¹) → is-set (base == y)
ΩS¹-is-set y = equiv-preserves-level ((encode {y} , encode-is-equiv y) ⁻¹)
(S¹Cover-is-set y)
S¹-level : has-level ⟨1⟩ S¹
S¹-level =
S¹-elim ΩS¹-is-set (prop-has-all-paths-↓ (Π-level (λ x → is-set-is-prop)))
| 38.371901
| 84
| 0.587982
|
cb947b5fb43e6d1d82997c81da03b7f62cc48860
| 54
|
agda
|
Agda
|
src-cbpv/Everything.agda
|
andreasabel/ipl
|
9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a
|
[
"Unlicense"
] | 19
|
2018-05-16T08:08:51.000Z
|
2021-04-27T19:10:49.000Z
|
src-cbpv/Everything.agda
|
andreasabel/ipl
|
9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a
|
[
"Unlicense"
] | null | null | null |
src-cbpv/Everything.agda
|
andreasabel/ipl
|
9a6151ad1f0977674b8cc9e9cefb49ae83e8a42a
|
[
"Unlicense"
] | 2
|
2018-11-13T16:01:46.000Z
|
2021-02-25T20:39:03.000Z
|
module Everything where
import Library
import NfCBPV
| 10.8
| 23
| 0.851852
|
130c88586c792a20223d1530f41a858361a6801c
| 25,669
|
agda
|
Agda
|
canonical-indeterminate-forms.agda
|
hazelgrove/hazelnut-agda
|
a3640d7b0f76cdac193afd382694197729ed6d57
|
[
"MIT"
] | null | null | null |
canonical-indeterminate-forms.agda
|
hazelgrove/hazelnut-agda
|
a3640d7b0f76cdac193afd382694197729ed6d57
|
[
"MIT"
] | null | null | null |
canonical-indeterminate-forms.agda
|
hazelgrove/hazelnut-agda
|
a3640d7b0f76cdac193afd382694197729ed6d57
|
[
"MIT"
] | null | null | null |
open import Nat
open import Prelude
open import contexts
open import dynamics-core
open import type-assignment-unicity
module canonical-indeterminate-forms where
-- this type gives somewhat nicer syntax for the output of the canonical
-- forms lemma for indeterminates at num type
data cif-num : (Δ : hctx) (d : ihexp) → Set where
CIFNPlus1 : ∀{Δ d} →
Σ[ d1 ∈ ihexp ] Σ[ d2 ∈ ihexp ]
((d == d1 ·+ d2) ×
(Δ , ∅ ⊢ d1 :: num) ×
(Δ , ∅ ⊢ d2 :: num) ×
(d1 indet) ×
(d2 final)
)
→ cif-num Δ d
CIFNPlus2 : ∀{Δ d} →
Σ[ d1 ∈ ihexp ] Σ[ d2 ∈ ihexp ]
((d == d1 ·+ d2) ×
(Δ , ∅ ⊢ d1 :: num) ×
(Δ , ∅ ⊢ d2 :: num) ×
(d1 final) ×
(d2 indet)
)
→ cif-num Δ d
CIFNAp : ∀{Δ d} →
Σ[ d1 ∈ ihexp ] Σ[ d2 ∈ ihexp ] Σ[ τ2 ∈ htyp ]
((d == d1 ∘ d2) ×
(Δ , ∅ ⊢ d1 :: τ2 ==> num) ×
(Δ , ∅ ⊢ d2 :: τ2) ×
(d1 indet) ×
(d2 final) ×
((τ3 τ4 τ3' τ4' : htyp) (d1' : ihexp) → d1 ≠ (d1' ⟨ τ3 ==> τ4 ⇒ τ3' ==> τ4' ⟩))
)
→ cif-num Δ d
CIFNCase : ∀{Δ d} →
Σ[ d1 ∈ ihexp ] Σ[ x ∈ Nat ] Σ[ d2 ∈ ihexp ] Σ[ y ∈ Nat ] Σ[ d3 ∈ ihexp ]
Σ[ τ1 ∈ htyp ] Σ[ τ2 ∈ htyp ]
((d == case d1 x d2 y d3) ×
(Δ , ∅ ⊢ d1 :: τ1 ⊕ τ2) ×
(Δ , ■ (x , τ1) ⊢ d2 :: num) ×
(Δ , ■ (y , τ2) ⊢ d3 :: num) ×
(d1 indet) ×
((τ : htyp) (d' : ihexp) → d1 ≠ inl τ d') ×
((τ : htyp) (d' : ihexp) → d1 ≠ inr τ d') ×
((τ3 τ4 τ3' τ4' : htyp) (d' : ihexp) →
d1 ≠ (d' ⟨(τ3 ⊕ τ4) ⇒ (τ3' ⊕ τ4')⟩))
)
→ cif-num Δ d
CIFNFst : ∀{Δ d} →
Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ]
((d == fst d') ×
(Δ , ∅ ⊢ d' :: num ⊠ τ') ×
(d' indet) ×
((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) ×
((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) →
d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩))
)
→ cif-num Δ d
CIFNSnd : ∀{Δ d} →
Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ]
((d == snd d') ×
(Δ , ∅ ⊢ d' :: τ' ⊠ num) ×
(d' indet) ×
((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) ×
((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) →
d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩))
)
→ cif-num Δ d
CIFNEHole : ∀{Δ d} →
Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ Γ ∈ tctx ]
((d == ⦇-⦈⟨ u , σ ⟩) ×
((u :: num [ Γ ]) ∈ Δ) ×
(Δ , ∅ ⊢ σ :s: Γ)
)
→ cif-num Δ d
CIFNNEHole : ∀{Δ d} →
Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ Γ ∈ tctx ] Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ]
((d == ⦇⌜ d' ⌟⦈⟨ u , σ ⟩) ×
(Δ , ∅ ⊢ d' :: τ') ×
(d' final) ×
((u :: num [ Γ ]) ∈ Δ) ×
(Δ , ∅ ⊢ σ :s: Γ)
)
→ cif-num Δ d
CIFNCast : ∀{Δ d} →
Σ[ d' ∈ ihexp ]
((d == d' ⟨ ⦇-⦈ ⇒ num ⟩) ×
(Δ , ∅ ⊢ d' :: ⦇-⦈) ×
(d' indet) ×
((d'' : ihexp) (τ' : htyp) → d' ≠ (d'' ⟨ τ' ⇒ ⦇-⦈ ⟩))
)
→ cif-num Δ d
CIFNFailedCast : ∀{Δ d} →
Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ]
((d == d' ⟨ τ' ⇒⦇-⦈⇏ num ⟩) ×
(Δ , ∅ ⊢ d' :: τ') ×
(τ' ground) ×
(τ' ≠ num)
)
→ cif-num Δ d
canonical-indeterminate-forms-num : ∀{Δ d} →
Δ , ∅ ⊢ d :: num →
d indet →
cif-num Δ d
canonical-indeterminate-forms-num TANum ()
canonical-indeterminate-forms-num (TAPlus wt wt₁) (IPlus1 x x₁) = CIFNPlus1 (_ , _ , refl , wt , wt₁ , x , x₁)
canonical-indeterminate-forms-num (TAPlus wt wt₁) (IPlus2 x x₁) = CIFNPlus2 (_ , _ , refl , wt , wt₁ , x , x₁)
canonical-indeterminate-forms-num (TAVar x₁) ()
canonical-indeterminate-forms-num (TAAp wt wt₁) (IAp x ind x₁) = CIFNAp (_ , _ , _ , refl , wt , wt₁ , ind , x₁ , x)
canonical-indeterminate-forms-num {Δ = Δ} (TACase {τ1 = τ1} {τ2 = τ2} {x = x} {d1 = d1} {y = y} {d2 = d2} wt _ wt₁ _ wt₂) (ICase ninl ninr ncast ind) = CIFNCase (_ , _ , _ , _ , _ , _ , _ , refl , wt , tr (λ Γ' → Δ , Γ' ⊢ d1 :: num) (extend-empty x τ1) wt₁ , tr (λ Γ' → Δ , Γ' ⊢ d2 :: num) (extend-empty y τ2) wt₂ , ind , ninl , ninr , ncast)
canonical-indeterminate-forms-num (TAFst wt) (IFst x x₁ ind) = CIFNFst (_ , _ , refl , wt , ind , x , x₁)
canonical-indeterminate-forms-num (TASnd wt) (ISnd x x₁ ind) = CIFNSnd (_ , _ , refl , wt , ind , x , x₁)
canonical-indeterminate-forms-num (TAEHole x x₁) IEHole = CIFNEHole (_ , _ , _ , refl , x , x₁)
canonical-indeterminate-forms-num (TANEHole x wt x₁) (INEHole x₂) = CIFNNEHole (_ , _ , _ , _ , _ , refl , wt , x₂ , x , x₁)
canonical-indeterminate-forms-num (TACast wt x) (ICastHoleGround x₁ ind x₂) = CIFNCast (_ , refl , wt , ind , x₁)
canonical-indeterminate-forms-num (TAFailedCast x x₁ x₂ x₃) (IFailedCast x₄ x₅ x₆ x₇) = CIFNFailedCast (_ , _ , refl , x , x₅ , x₇)
-- this type gives somewhat nicer syntax for the output of the canonical
-- forms lemma for indeterminates at arrow type
data cif-arr : (Δ : hctx) (d : ihexp) (τ1 τ2 : htyp) → Set where
CIFAEHole : ∀{d Δ τ1 τ2} →
Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ Γ ∈ tctx ]
((d == ⦇-⦈⟨ u , σ ⟩) ×
((u :: (τ1 ==> τ2) [ Γ ]) ∈ Δ) ×
(Δ , ∅ ⊢ σ :s: Γ)
)
→ cif-arr Δ d τ1 τ2
CIFANEHole : ∀{d Δ τ1 τ2} →
Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] Σ[ Γ ∈ tctx ]
((d == ⦇⌜ d' ⌟⦈⟨ u , σ ⟩) ×
(Δ , ∅ ⊢ d' :: τ') ×
(d' final) ×
((u :: (τ1 ==> τ2) [ Γ ]) ∈ Δ) ×
(Δ , ∅ ⊢ σ :s: Γ)
)
→ cif-arr Δ d τ1 τ2
CIFAAp : ∀{d Δ τ1 τ2} →
Σ[ d1 ∈ ihexp ] Σ[ d2 ∈ ihexp ] Σ[ τ2' ∈ htyp ] Σ[ τ1 ∈ htyp ] Σ[ τ2 ∈ htyp ]
((d == d1 ∘ d2) ×
(Δ , ∅ ⊢ d1 :: τ2' ==> (τ1 ==> τ2)) ×
(Δ , ∅ ⊢ d2 :: τ2') ×
(d1 indet) ×
(d2 final) ×
((τ3 τ4 τ3' τ4' : htyp) (d1' : ihexp) → d1 ≠ (d1' ⟨ τ3 ==> τ4 ⇒ τ3' ==> τ4' ⟩))
)
→ cif-arr Δ d τ1 τ2
CIFACase : ∀{Δ d τ1 τ2} →
Σ[ d1 ∈ ihexp ] Σ[ x ∈ Nat ] Σ[ d2 ∈ ihexp ] Σ[ y ∈ Nat ] Σ[ d3 ∈ ihexp ]
Σ[ τ3 ∈ htyp ] Σ[ τ4 ∈ htyp ]
((d == case d1 x d2 y d3) ×
(Δ , ∅ ⊢ d1 :: τ3 ⊕ τ4) ×
(Δ , ■ (x , τ3) ⊢ d2 :: τ1 ==> τ2) ×
(Δ , ■ (y , τ4) ⊢ d3 :: τ1 ==> τ2) ×
(d1 indet) ×
((τ : htyp) (d' : ihexp) → d1 ≠ inl τ d') ×
((τ : htyp) (d' : ihexp) → d1 ≠ inr τ d') ×
((τ5 τ6 τ5' τ6' : htyp) (d' : ihexp) →
d1 ≠ (d' ⟨(τ5 ⊕ τ6) ⇒ (τ5' ⊕ τ6')⟩))
)
→ cif-arr Δ d τ1 τ2
CIFAFst : ∀{Δ d τ1 τ2} →
Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ]
((d == fst d') ×
(Δ , ∅ ⊢ d' :: (τ1 ==> τ2) ⊠ τ') ×
(d' indet) ×
((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) ×
((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) →
d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩))
)
→ cif-arr Δ d τ1 τ2
CIFASnd : ∀{Δ d τ1 τ2} →
Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ]
((d == snd d') ×
(Δ , ∅ ⊢ d' :: τ' ⊠ (τ1 ==> τ2)) ×
(d' indet) ×
((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) ×
((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) →
d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩))
)
→ cif-arr Δ d τ1 τ2
CIFACast : ∀{d Δ τ1 τ2} →
Σ[ d' ∈ ihexp ] Σ[ τ1 ∈ htyp ] Σ[ τ2 ∈ htyp ] Σ[ τ1' ∈ htyp ] Σ[ τ2' ∈ htyp ]
((d == d' ⟨ (τ1' ==> τ2') ⇒ (τ1 ==> τ2) ⟩) ×
(Δ , ∅ ⊢ d' :: τ1' ==> τ2') ×
(d' indet) ×
((τ1' ==> τ2') ≠ (τ1 ==> τ2))
)
→ cif-arr Δ d τ1 τ2
CIFACastHole : ∀{d Δ τ1 τ2} →
Σ[ d' ∈ ihexp ]
((d == (d' ⟨ ⦇-⦈ ⇒ ⦇-⦈ ==> ⦇-⦈ ⟩)) ×
(τ1 == ⦇-⦈) ×
(τ2 == ⦇-⦈) ×
(Δ , ∅ ⊢ d' :: ⦇-⦈) ×
(d' indet) ×
((d'' : ihexp) (τ' : htyp) → d' ≠ (d'' ⟨ τ' ⇒ ⦇-⦈ ⟩))
)
→ cif-arr Δ d τ1 τ2
CIFAFailedCast : ∀{d Δ τ1 τ2} →
Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ]
((d == (d' ⟨ τ' ⇒⦇-⦈⇏ ⦇-⦈ ==> ⦇-⦈ ⟩) ) ×
(τ1 == ⦇-⦈) ×
(τ2 == ⦇-⦈) ×
(Δ , ∅ ⊢ d' :: τ') ×
(τ' ground) ×
(τ' ≠ (⦇-⦈ ==> ⦇-⦈))
)
→ cif-arr Δ d τ1 τ2
canonical-indeterminate-forms-arr : ∀{Δ d τ1 τ2 } →
Δ , ∅ ⊢ d :: (τ1 ==> τ2) →
d indet →
cif-arr Δ d τ1 τ2
canonical-indeterminate-forms-arr (TAVar x₁) ()
canonical-indeterminate-forms-arr (TALam _ wt) ()
canonical-indeterminate-forms-arr (TAAp wt wt₁) (IAp x ind x₁) = CIFAAp (_ , _ , _ , _ , _ , refl , wt , wt₁ , ind , x₁ , x)
canonical-indeterminate-forms-arr {Δ = Δ} (TACase {τ1 = τ1} {τ2 = τ2} {τ = τ3 ==> τ4} {x = x} {d1 = d1} {y = y} {d2 = d2} wt _ wt₁ _ wt₂) (ICase ninl ninr ncast ind) = CIFACase (_ , _ , _ , _ , _ , _ , _ , refl , wt , tr (λ Γ' → Δ , Γ' ⊢ d1 :: τ3 ==> τ4) (extend-empty x τ1) wt₁ , tr (λ Γ' → Δ , Γ' ⊢ d2 :: τ3 ==> τ4) (extend-empty y τ2) wt₂ , ind , ninl , ninr , ncast)
canonical-indeterminate-forms-arr (TAFst wt) (IFst x x₁ ind) = CIFAFst (_ , _ , refl , wt , ind , x , x₁)
canonical-indeterminate-forms-arr (TASnd wt) (ISnd x x₁ ind) = CIFASnd (_ , _ , refl , wt , ind , x , x₁)
canonical-indeterminate-forms-arr (TAEHole x x₁) IEHole = CIFAEHole (_ , _ , _ , refl , x , x₁)
canonical-indeterminate-forms-arr (TANEHole x wt x₁) (INEHole x₂) = CIFANEHole (_ , _ , _ , _ , _ , refl , wt , x₂ , x , x₁)
canonical-indeterminate-forms-arr (TACast wt x) (ICastArr x₁ ind) = CIFACast (_ , _ , _ , _ , _ , refl , wt , ind , x₁)
canonical-indeterminate-forms-arr (TACast wt TCHole2) (ICastHoleGround x₁ ind GArrHole) = CIFACastHole (_ , refl , refl , refl , wt , ind , x₁)
canonical-indeterminate-forms-arr (TAFailedCast x x₁ GArrHole x₃) (IFailedCast x₄ x₅ GArrHole x₇) = CIFAFailedCast (_ , _ , refl , refl , refl , x , x₅ , x₇)
-- this type gives somewhat nicer syntax for the output of the canonical
-- forms lemma for indeterminates at sum type
data cif-sum : (Δ : hctx) (d : ihexp) (τ1 τ2 : htyp) → Set where
CIFSEHole : ∀{d Δ τ1 τ2} →
Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ Γ ∈ tctx ]
((d == ⦇-⦈⟨ u , σ ⟩) ×
((u :: (τ1 ⊕ τ2) [ Γ ]) ∈ Δ) ×
(Δ , ∅ ⊢ σ :s: Γ)
)
→ cif-sum Δ d τ1 τ2
CIFSNEHole : ∀{d Δ τ1 τ2} →
Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] Σ[ Γ ∈ tctx ]
((d == ⦇⌜ d' ⌟⦈⟨ u , σ ⟩) ×
(Δ , ∅ ⊢ d' :: τ') ×
(d' final) ×
((u :: (τ1 ⊕ τ2) [ Γ ]) ∈ Δ) ×
(Δ , ∅ ⊢ σ :s: Γ)
)
→ cif-sum Δ d τ1 τ2
CIFSAp : ∀{d Δ τ1 τ2} →
Σ[ d1 ∈ ihexp ] Σ[ d2 ∈ ihexp ] Σ[ τ2' ∈ htyp ] Σ[ τ1 ∈ htyp ] Σ[ τ2 ∈ htyp ]
((d == d1 ∘ d2) ×
(Δ , ∅ ⊢ d1 :: τ2' ==> (τ1 ⊕ τ2)) ×
(Δ , ∅ ⊢ d2 :: τ2') ×
(d1 indet) ×
(d2 final) ×
((τ3 τ4 τ3' τ4' : htyp) (d1' : ihexp) → d1 ≠ (d1' ⟨ τ3 ==> τ4 ⇒ τ3' ==> τ4' ⟩))
)
→ cif-sum Δ d τ1 τ2
CIFSInl : ∀{Δ d τ1 τ2} →
Σ[ d' ∈ ihexp ]
((d == inl τ2 d') ×
(Δ , ∅ ⊢ d' :: τ1) ×
(d' indet)
)
→ cif-sum Δ d τ1 τ2
CIFSInr : ∀{Δ d τ1 τ2} →
Σ[ d' ∈ ihexp ]
((d == inr τ1 d') ×
(Δ , ∅ ⊢ d' :: τ2) ×
(d' indet)
)
→ cif-sum Δ d τ1 τ2
CIFSCase : ∀{Δ d τ1 τ2} →
Σ[ d1 ∈ ihexp ] Σ[ x ∈ Nat ] Σ[ d2 ∈ ihexp ] Σ[ y ∈ Nat ] Σ[ d3 ∈ ihexp ]
Σ[ τ3 ∈ htyp ] Σ[ τ4 ∈ htyp ]
((d == case d1 x d2 y d3) ×
(Δ , ∅ ⊢ d1 :: τ3 ⊕ τ4) ×
(Δ , ■ (x , τ3) ⊢ d2 :: τ1 ⊕ τ2) ×
(Δ , ■ (y , τ4) ⊢ d3 :: τ1 ⊕ τ2) ×
(d1 indet) ×
((τ : htyp) (d' : ihexp) → d1 ≠ inl τ d') ×
((τ : htyp) (d' : ihexp) → d1 ≠ inr τ d') ×
((τ5 τ6 τ5' τ6' : htyp) (d' : ihexp) →
d1 ≠ (d' ⟨(τ5 ⊕ τ6) ⇒ (τ5' ⊕ τ6')⟩))
)
→ cif-sum Δ d τ1 τ2
CIFSFst : ∀{Δ d τ1 τ2} →
Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ]
((d == fst d') ×
(Δ , ∅ ⊢ d' :: (τ1 ⊕ τ2) ⊠ τ') ×
(d' indet) ×
((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) ×
((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) →
d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩))
)
→ cif-sum Δ d τ1 τ2
CIFSSnd : ∀{Δ d τ1 τ2} →
Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ]
((d == snd d') ×
(Δ , ∅ ⊢ d' :: τ' ⊠ (τ1 ⊕ τ2)) ×
(d' indet) ×
((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) ×
((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) →
d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩))
)
→ cif-sum Δ d τ1 τ2
CIFSCast : ∀{d Δ τ1 τ2} →
Σ[ d' ∈ ihexp ] Σ[ τ1 ∈ htyp ] Σ[ τ2 ∈ htyp ] Σ[ τ1' ∈ htyp ] Σ[ τ2' ∈ htyp ]
((d == d' ⟨ (τ1' ⊕ τ2') ⇒ (τ1 ⊕ τ2) ⟩) ×
(Δ , ∅ ⊢ d' :: τ1' ⊕ τ2') ×
(d' indet) ×
((τ1' ⊕ τ2') ≠ (τ1 ⊕ τ2))
)
→ cif-sum Δ d τ1 τ2
CIFSCastHole : ∀{d Δ τ1 τ2} →
Σ[ d' ∈ ihexp ]
((d == (d' ⟨ ⦇-⦈ ⇒ ⦇-⦈ ⊕ ⦇-⦈ ⟩)) ×
(τ1 == ⦇-⦈) ×
(τ2 == ⦇-⦈) ×
(Δ , ∅ ⊢ d' :: ⦇-⦈) ×
(d' indet) ×
((d'' : ihexp) (τ' : htyp) → d' ≠ (d'' ⟨ τ' ⇒ ⦇-⦈ ⟩))
)
→ cif-sum Δ d τ1 τ2
CIFSFailedCast : ∀{d Δ τ1 τ2} →
Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ]
((d == (d' ⟨ τ' ⇒⦇-⦈⇏ ⦇-⦈ ⊕ ⦇-⦈ ⟩) ) ×
(τ1 == ⦇-⦈) ×
(τ2 == ⦇-⦈) ×
(Δ , ∅ ⊢ d' :: τ') ×
(τ' ground) ×
(τ' ≠ (⦇-⦈ ⊕ ⦇-⦈))
)
→ cif-sum Δ d τ1 τ2
canonical-indeterminate-forms-sum : ∀{Δ d τ1 τ2 } →
Δ , ∅ ⊢ d :: (τ1 ⊕ τ2) →
d indet →
cif-sum Δ d τ1 τ2
canonical-indeterminate-forms-sum (TAAp wt wt₁) (IAp x ind x₁) = CIFSAp (_ , _ , _ , _ , _ , refl , wt , wt₁ , ind , x₁ , x)
canonical-indeterminate-forms-sum (TAInl wt) (IInl ind) = CIFSInl (_ , refl , wt , ind)
canonical-indeterminate-forms-sum (TAInr wt) (IInr ind) = CIFSInr (_ , refl , wt , ind)
canonical-indeterminate-forms-sum {Δ = Δ} (TACase {τ1 = τ1} {τ2 = τ2} {τ = τ3 ⊕ τ4} {x = x} {d1 = d1} {y = y} {d2 = d2} wt _ wt₁ _ wt₂) (ICase ninl ninr ncast ind) = CIFSCase (_ , _ , _ , _ , _ , _ , _ , refl , wt , tr (λ Γ' → Δ , Γ' ⊢ d1 :: (τ3 ⊕ τ4)) (extend-empty x τ1) wt₁ , tr (λ Γ' → Δ , Γ' ⊢ d2 :: (τ3 ⊕ τ4)) (extend-empty y τ2) wt₂ , ind , ninl , ninr , ncast)
canonical-indeterminate-forms-sum (TAFst wt) (IFst x x₁ ind) = CIFSFst (_ , _ , refl , wt , ind , x , x₁)
canonical-indeterminate-forms-sum (TASnd wt) (ISnd x x₁ ind) = CIFSSnd (_ , _ , refl , wt , ind , x , x₁)
canonical-indeterminate-forms-sum (TAEHole x x₁) IEHole = CIFSEHole (_ , _ , _ , refl , x , x₁)
canonical-indeterminate-forms-sum (TANEHole x wt x₁) (INEHole x₂) = CIFSNEHole (_ , _ , _ , _ , _ , refl , wt , x₂ , x , x₁)
canonical-indeterminate-forms-sum (TACast wt x) (ICastSum x₁ ind) = CIFSCast (_ , _ , _ , _ , _ , refl , wt , ind , x₁)
canonical-indeterminate-forms-sum (TACast wt x) (ICastHoleGround x₁ ind GSumHole) = CIFSCastHole (_ , refl , refl , refl , wt , ind , x₁)
canonical-indeterminate-forms-sum (TAFailedCast wt x x₁ x₂) (IFailedCast x₃ x₄ GSumHole x₆) = CIFSFailedCast (_ , _ , refl , refl , refl , wt , x₄ , x₆)
canonical-indeterminate-forms-sum (TAVar x) ()
-- this type gives somewhat nicer syntax for the output of the canonical
-- forms lemma for indeterminates at product type
data cif-prod : (Δ : hctx) (d : ihexp) (τ1 τ2 : htyp) → Set where
CIFPEHole : ∀{d Δ τ1 τ2} →
Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ Γ ∈ tctx ]
((d == ⦇-⦈⟨ u , σ ⟩) ×
((u :: (τ1 ⊠ τ2) [ Γ ]) ∈ Δ) ×
(Δ , ∅ ⊢ σ :s: Γ)
)
→ cif-prod Δ d τ1 τ2
CIFPNEHole : ∀{d Δ τ1 τ2} →
Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] Σ[ Γ ∈ tctx ]
((d == ⦇⌜ d' ⌟⦈⟨ u , σ ⟩) ×
(Δ , ∅ ⊢ d' :: τ') ×
(d' final) ×
((u :: (τ1 ⊠ τ2) [ Γ ]) ∈ Δ) ×
(Δ , ∅ ⊢ σ :s: Γ)
)
→ cif-prod Δ d τ1 τ2
CIFPAp : ∀{d Δ τ1 τ2} →
Σ[ d1 ∈ ihexp ] Σ[ d2 ∈ ihexp ] Σ[ τ2' ∈ htyp ] Σ[ τ1 ∈ htyp ] Σ[ τ2 ∈ htyp ]
((d == d1 ∘ d2) ×
(Δ , ∅ ⊢ d1 :: τ2' ==> (τ1 ⊠ τ2)) ×
(Δ , ∅ ⊢ d2 :: τ2') ×
(d1 indet) ×
(d2 final) ×
((τ3 τ4 τ3' τ4' : htyp) (d1' : ihexp) → d1 ≠ (d1' ⟨ τ3 ==> τ4 ⇒ τ3' ==> τ4' ⟩))
)
→ cif-prod Δ d τ1 τ2
CIFPCase : ∀{Δ d τ1 τ2} →
Σ[ d1 ∈ ihexp ] Σ[ x ∈ Nat ] Σ[ d2 ∈ ihexp ] Σ[ y ∈ Nat ] Σ[ d3 ∈ ihexp ]
Σ[ τ3 ∈ htyp ] Σ[ τ4 ∈ htyp ]
((d == case d1 x d2 y d3) ×
(Δ , ∅ ⊢ d1 :: τ3 ⊕ τ4) ×
(Δ , ■ (x , τ3) ⊢ d2 :: τ1 ⊠ τ2) ×
(Δ , ■ (y , τ4) ⊢ d3 :: τ1 ⊠ τ2) ×
(d1 indet) ×
((τ : htyp) (d' : ihexp) → d1 ≠ inl τ d') ×
((τ : htyp) (d' : ihexp) → d1 ≠ inr τ d') ×
((τ5 τ6 τ5' τ6' : htyp) (d' : ihexp) →
d1 ≠ (d' ⟨(τ5 ⊕ τ6) ⇒ (τ5' ⊕ τ6')⟩))
)
→ cif-prod Δ d τ1 τ2
CIFPPair1 : ∀{Δ d τ1 τ2} →
Σ[ d1 ∈ ihexp ] Σ[ d2 ∈ ihexp ]
((d == ⟨ d1 , d2 ⟩) ×
(Δ , ∅ ⊢ d1 :: τ1) ×
(Δ , ∅ ⊢ d2 :: τ2) ×
d1 indet ×
d2 final
)
→ cif-prod Δ d τ1 τ2
CIFPPair2 : ∀{Δ d τ1 τ2} →
Σ[ d1 ∈ ihexp ] Σ[ d2 ∈ ihexp ]
((d == ⟨ d1 , d2 ⟩) ×
(Δ , ∅ ⊢ d1 :: τ1) ×
(Δ , ∅ ⊢ d2 :: τ2) ×
d1 final ×
d2 indet
)
→ cif-prod Δ d τ1 τ2
CIFPFst : ∀{Δ d τ1 τ2} →
Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ]
((d == fst d') ×
(Δ , ∅ ⊢ d' :: (τ1 ⊠ τ2) ⊠ τ') ×
(d' indet) ×
((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) ×
((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) →
d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩))
)
→ cif-prod Δ d τ1 τ2
CIFPSnd : ∀{Δ d τ1 τ2} →
Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ]
((d == snd d') ×
(Δ , ∅ ⊢ d' :: τ' ⊠ (τ1 ⊠ τ2)) ×
(d' indet) ×
((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) ×
((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) →
d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩))
)
→ cif-prod Δ d τ1 τ2
CIFPCast : ∀{d Δ τ1 τ2} →
Σ[ d' ∈ ihexp ] Σ[ τ1 ∈ htyp ] Σ[ τ2 ∈ htyp ] Σ[ τ1' ∈ htyp ] Σ[ τ2' ∈ htyp ]
((d == d' ⟨ (τ1' ⊠ τ2') ⇒ (τ1 ⊠ τ2) ⟩) ×
(Δ , ∅ ⊢ d' :: τ1' ⊠ τ2') ×
(d' indet) ×
((τ1' ⊠ τ2') ≠ (τ1 ⊠ τ2))
)
→ cif-prod Δ d τ1 τ2
CIFPCastHole : ∀{d Δ τ1 τ2} →
Σ[ d' ∈ ihexp ]
((d == (d' ⟨ ⦇-⦈ ⇒ ⦇-⦈ ⊠ ⦇-⦈ ⟩)) ×
(τ1 == ⦇-⦈) ×
(τ2 == ⦇-⦈) ×
(Δ , ∅ ⊢ d' :: ⦇-⦈) ×
(d' indet) ×
((d'' : ihexp) (τ' : htyp) → d' ≠ (d'' ⟨ τ' ⇒ ⦇-⦈ ⟩))
)
→ cif-prod Δ d τ1 τ2
CIFPFailedCast : ∀{d Δ τ1 τ2} →
Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ]
((d == (d' ⟨ τ' ⇒⦇-⦈⇏ ⦇-⦈ ⊠ ⦇-⦈ ⟩) ) ×
(τ1 == ⦇-⦈) ×
(τ2 == ⦇-⦈) ×
(Δ , ∅ ⊢ d' :: τ') ×
(τ' ground) ×
(τ' ≠ (⦇-⦈ ⊠ ⦇-⦈))
)
→ cif-prod Δ d τ1 τ2
canonical-indeterminate-forms-prod : ∀{Δ d τ1 τ2} →
Δ , ∅ ⊢ d :: (τ1 ⊠ τ2) →
d indet →
cif-prod Δ d τ1 τ2
canonical-indeterminate-forms-prod (TAVar x) ()
canonical-indeterminate-forms-prod (TAAp wt wt₁) (IAp x ind x₁) = CIFPAp (_ , _ , _ , _ , _ , refl , wt , wt₁ , ind , x₁ , x)
canonical-indeterminate-forms-prod {Δ = Δ} (TACase {τ1 = τ1} {τ2 = τ2} {τ = τ3 ⊠ τ4} {x = x} {d1 = d1} {y = y} {d2 = d2} wt _ wt₁ _ wt₂) (ICase ninl ninr ncast ind) = CIFPCase (_ , _ , _ , _ , _ , _ , _ , refl , wt , tr (λ Γ' → Δ , Γ' ⊢ d1 :: (τ3 ⊠ τ4)) (extend-empty x τ1) wt₁ , tr (λ Γ' → Δ , Γ' ⊢ d2 :: (τ3 ⊠ τ4)) (extend-empty y τ2) wt₂ , ind , ninl , ninr , ncast)
canonical-indeterminate-forms-prod (TAPair wt wt₁) (IPair1 ind x) = CIFPPair1 (_ , _ , refl , wt , wt₁ , ind , x)
canonical-indeterminate-forms-prod (TAPair wt wt₁) (IPair2 x ind) = CIFPPair2 (_ , _ , refl , wt , wt₁ , x , ind)
canonical-indeterminate-forms-prod (TAFst wt) (IFst x x₁ ind) = CIFPFst (_ , _ , refl , wt , ind , x , x₁)
canonical-indeterminate-forms-prod (TASnd wt) (ISnd x x₁ ind) = CIFPSnd (_ , _ , refl , wt , ind , x , x₁)
canonical-indeterminate-forms-prod (TAEHole x x₁) IEHole = CIFPEHole (_ , _ , _ , refl , x , x₁)
canonical-indeterminate-forms-prod (TANEHole x wt x₁) (INEHole x₂) = CIFPNEHole (_ , _ , _ , _ , _ , refl , wt , x₂ , x , x₁)
canonical-indeterminate-forms-prod (TACast wt x) (ICastProd x₁ ind) = CIFPCast (_ , _ , _ , _ , _ , refl , wt , ind , x₁)
canonical-indeterminate-forms-prod (TACast wt x) (ICastHoleGround x₁ ind GProdHole) = CIFPCastHole (_ , refl , refl , refl , wt , ind , x₁)
canonical-indeterminate-forms-prod (TAFailedCast wt x GProdHole x₂) (IFailedCast x₃ x₄ GProdHole x₆) = CIFPFailedCast (_ , _ , refl , refl , refl , wt , x₄ , x₆)
-- this type gives somewhat nicer syntax for the output of the canonical
-- forms lemma for indeterminates at hole type
data cif-hole : (Δ : hctx) (d : ihexp) → Set where
CIFHEHole : ∀{Δ d} →
Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ Γ ∈ tctx ]
((d == ⦇-⦈⟨ u , σ ⟩) ×
((u :: ⦇-⦈ [ Γ ]) ∈ Δ) ×
(Δ , ∅ ⊢ σ :s: Γ)
)
→ cif-hole Δ d
CIFHNEHole : ∀{Δ d} →
Σ[ u ∈ Nat ] Σ[ σ ∈ env ] Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ] Σ[ Γ ∈ tctx ]
((d == ⦇⌜ d' ⌟⦈⟨ u , σ ⟩) ×
(Δ , ∅ ⊢ d' :: τ') ×
(d' final) ×
((u :: ⦇-⦈ [ Γ ]) ∈ Δ) ×
(Δ , ∅ ⊢ σ :s: Γ)
)
→ cif-hole Δ d
CIFHAp : ∀{Δ d} →
Σ[ d1 ∈ ihexp ] Σ[ d2 ∈ ihexp ] Σ[ τ2 ∈ htyp ]
((d == d1 ∘ d2) ×
(Δ , ∅ ⊢ d1 :: (τ2 ==> ⦇-⦈)) ×
(Δ , ∅ ⊢ d2 :: τ2) ×
(d1 indet) ×
(d2 final) ×
((τ3 τ4 τ3' τ4' : htyp) (d1' : ihexp) → d1 ≠ (d1' ⟨ τ3 ==> τ4 ⇒ τ3' ==> τ4' ⟩))
)
→ cif-hole Δ d
CIFHCase : ∀{Δ d} →
Σ[ d1 ∈ ihexp ] Σ[ x ∈ Nat ] Σ[ d2 ∈ ihexp ] Σ[ y ∈ Nat ] Σ[ d3 ∈ ihexp ]
Σ[ τ1 ∈ htyp ] Σ[ τ2 ∈ htyp ]
((d == case d1 x d2 y d3) ×
(Δ , ∅ ⊢ d1 :: τ1 ⊕ τ2) ×
(Δ , ■ (x , τ1) ⊢ d2 :: ⦇-⦈) ×
(Δ , ■ (y , τ2) ⊢ d3 :: ⦇-⦈) ×
(d1 indet) ×
((τ : htyp) (d' : ihexp) → d1 ≠ inl τ d') ×
((τ : htyp) (d' : ihexp) → d1 ≠ inr τ d') ×
((τ3 τ4 τ3' τ4' : htyp) (d' : ihexp) →
d1 ≠ (d' ⟨(τ3 ⊕ τ4) ⇒ (τ3' ⊕ τ4')⟩))
)
→ cif-hole Δ d
CIFHFst : ∀{Δ d} →
Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ]
((d == fst d') ×
(Δ , ∅ ⊢ d' :: ⦇-⦈ ⊠ τ') ×
(d' indet) ×
((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) ×
((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) →
d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩))
)
→ cif-hole Δ d
CIFHSnd : ∀{Δ d} →
Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ]
((d == snd d') ×
(Δ , ∅ ⊢ d' :: τ' ⊠ ⦇-⦈) ×
(d' indet) ×
((d1 d2 : ihexp) → d' ≠ ⟨ d1 , d2 ⟩) ×
((τ3 τ4 τ3' τ4' : htyp) (d'' : ihexp) →
d' ≠ (d'' ⟨(τ3 ⊠ τ4) ⇒ (τ3' ⊠ τ4')⟩))
)
→ cif-hole Δ d
CIFHCast : ∀{Δ d} →
Σ[ d' ∈ ihexp ] Σ[ τ' ∈ htyp ]
((d == d' ⟨ τ' ⇒ ⦇-⦈ ⟩) ×
(Δ , ∅ ⊢ d' :: τ') ×
(τ' ground) ×
(d' indet)
)
→ cif-hole Δ d
canonical-indeterminate-forms-hole : ∀{Δ d} →
Δ , ∅ ⊢ d :: ⦇-⦈ →
d indet →
cif-hole Δ d
canonical-indeterminate-forms-hole (TAVar x₁) ()
canonical-indeterminate-forms-hole (TAAp wt wt₁) (IAp x ind x₁) = CIFHAp (_ , _ , _ , refl , wt , wt₁ , ind , x₁ , x)
canonical-indeterminate-forms-hole {Δ = Δ} (TACase {τ1 = τ1} {τ2 = τ2} {x = x} {d1 = d1} {y = y} {d2 = d2} wt _ wt₁ _ wt₂) (ICase ninl ninr ncast ind) = CIFHCase (_ , _ , _ , _ , _ , _ , _ , refl , wt , tr (λ Γ' → Δ , Γ' ⊢ d1 :: ⦇-⦈) (extend-empty x τ1) wt₁ , tr (λ Γ' → Δ , Γ' ⊢ d2 :: ⦇-⦈) (extend-empty y τ2) wt₂ , ind , ninl , ninr , ncast)
canonical-indeterminate-forms-hole (TAFst wt) (IFst x x₁ ind) = CIFHFst (_ , _ , refl , wt , ind , x , x₁)
canonical-indeterminate-forms-hole (TASnd wt) (ISnd x x₁ ind) = CIFHSnd (_ , _ , refl , wt , ind , x , x₁)
canonical-indeterminate-forms-hole (TAEHole x x₁) IEHole = CIFHEHole (_ , _ , _ , refl , x , x₁)
canonical-indeterminate-forms-hole (TANEHole x wt x₁) (INEHole x₂) = CIFHNEHole (_ , _ , _ , _ , _ , refl , wt , x₂ , x , x₁)
canonical-indeterminate-forms-hole (TACast wt x) (ICastGroundHole x₁ ind) = CIFHCast (_ , _ , refl , wt , x₁ , ind)
canonical-indeterminate-forms-hole (TACast wt x) (ICastHoleGround x₁ ind ())
canonical-indeterminate-forms-hole (TAFailedCast x x₁ () x₃) (IFailedCast x₄ x₅ x₆ x₇)
canonical-indeterminate-forms-coverage : ∀{Δ d τ} →
Δ , ∅ ⊢ d :: τ →
d indet →
τ ≠ num →
((τ1 : htyp) (τ2 : htyp) → τ ≠ (τ1 ==> τ2)) →
((τ1 : htyp) (τ2 : htyp) → τ ≠ (τ1 ⊕ τ2)) →
((τ1 : htyp) (τ2 : htyp) → τ ≠ (τ1 ⊠ τ2)) →
τ ≠ ⦇-⦈ →
⊥
canonical-indeterminate-forms-coverage {τ = num} wt ind nn na ns np nh = nn refl
canonical-indeterminate-forms-coverage {τ = ⦇-⦈} wt ind nn na ns np nh = nh refl
canonical-indeterminate-forms-coverage {τ = τ ==> τ₁} wt ind nn na ns np nh = na τ τ₁ refl
canonical-indeterminate-forms-coverage {τ = τ ⊕ τ₁} wt ind nn na ns np nh = ns τ τ₁ refl
canonical-indeterminate-forms-coverage {τ = τ ⊠ τ₁} wt ind nn na ns np nh = np τ τ₁ refl
| 43.953767
| 372
| 0.404535
|
dce0c11399a42ff5d8e97211d4ebc320a9fff276
| 329
|
agda
|
Agda
|
Cubical/HITs/Sn/Base.agda
|
borsiemir/cubical
|
cefeb3669ffdaea7b88ae0e9dd258378418819ca
|
[
"MIT"
] | 1
|
2020-03-23T23:52:11.000Z
|
2020-03-23T23:52:11.000Z
|
Cubical/HITs/Sn/Base.agda
|
borsiemir/cubical
|
cefeb3669ffdaea7b88ae0e9dd258378418819ca
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Sn/Base.agda
|
borsiemir/cubical
|
cefeb3669ffdaea7b88ae0e9dd258378418819ca
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --safe #-}
module Cubical.HITs.Sn.Base where
open import Cubical.HITs.Susp
open import Cubical.Data.Nat
open import Cubical.Data.NatMinusOne
open import Cubical.Data.Empty
open import Cubical.Foundations.Prelude
S : ℕ₋₁ → Type₀
S neg1 = ⊥
S (ℕ→ℕ₋₁ n) = Susp (S (-1+ n))
S₊ : ℕ → Type₀
S₊ n = S (ℕ→ℕ₋₁ n)
| 20.5625
| 39
| 0.68997
|
c7ea5d60ada8c5d73e9ba684849a5d5f2c1d19c2
| 1,001
|
agda
|
Agda
|
Cubical/Categories/Monoidal/Enriched.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 1
|
2022-03-05T00:29:41.000Z
|
2022-03-05T00:29:41.000Z
|
Cubical/Categories/Monoidal/Enriched.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
Cubical/Categories/Monoidal/Enriched.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
-- Enriched categories
{-# OPTIONS --safe #-}
module Cubical.Categories.Monoidal.Enriched where
open import Cubical.Categories.Monoidal.Base
open import Cubical.Foundations.Prelude
module _ {ℓV ℓV' : Level} (V : MonoidalCategory ℓV ℓV') (ℓE : Level) where
open MonoidalCategory V
renaming (ob to obV; Hom[_,_] to V[_,_]; id to idV; _⋆_ to _⋆V_)
record EnrichedCategory : Type (ℓ-max (ℓ-max ℓV ℓV') (ℓ-suc ℓE)) where
field
ob : Type ℓE
Hom[_,_] : ob → ob → obV
id : ∀ {x} → V[ unit , Hom[ x , x ] ]
seq : ∀ x y z → V[ Hom[ x , y ] ⊗ Hom[ y , z ] , Hom[ x , z ] ]
-- Axioms
⋆IdL : ∀ x y → η⟨ _ ⟩ ≡ (id {x} ⊗ₕ idV) ⋆V (seq x x y)
⋆IdR : ∀ x y → ρ⟨ _ ⟩ ≡ (idV ⊗ₕ id {y}) ⋆V (seq x y y)
⋆Assoc : ∀ x y z w →
α⟨ _ , _ , _ ⟩ ⋆V ((seq x y z) ⊗ₕ idV) ⋆V (seq x z w)
≡ (idV ⊗ₕ (seq y z w)) ⋆V (seq x y w)
-- TODO: define underlying category using Hom[ x , y ] := V[ unit , Hom[ x , y ] ]
| 33.366667
| 82
| 0.508492
|
22382a51ee783fd27c8efcabd325d58d64eb48de
| 331
|
agda
|
Agda
|
src/Data/Natural.agda
|
agda/agda-data-bindings
|
84d51967e20bf248e9f73af37f52972922ffc77c
|
[
"MIT"
] | 2
|
2019-08-02T23:17:59.000Z
|
2019-10-24T13:51:16.000Z
|
src/Data/Natural.agda
|
agda/agda-data-bindings
|
84d51967e20bf248e9f73af37f52972922ffc77c
|
[
"MIT"
] | null | null | null |
src/Data/Natural.agda
|
agda/agda-data-bindings
|
84d51967e20bf248e9f73af37f52972922ffc77c
|
[
"MIT"
] | 1
|
2022-03-12T11:40:14.000Z
|
2022-03-12T11:40:14.000Z
|
-- A binding to a Haskell natural numbers type
open import Data.Nat using ( ℕ ) renaming ( zero to zero' ; suc to suc' )
module Data.Natural where
open import Data.Natural.Primitive public
using ( Natural ; zero ; suc ; _+_ ; toString ; foldl ; foldl' ; foldr )
renaming ( fromℕ to # )
% : Natural → ℕ
% = foldr suc' zero'
| 25.461538
| 74
| 0.670695
|
ad7b4be74ff18140ee77051c13b405ffaa4f7c2d
| 9,603
|
agda
|
Agda
|
src/Categories/Category/Construction/Properties/Presheaves/Complete.agda
|
MirceaS/agda-categories
|
58e5ec015781be5413bdf968f7ec4fdae0ab4b21
|
[
"MIT"
] | null | null | null |
src/Categories/Category/Construction/Properties/Presheaves/Complete.agda
|
MirceaS/agda-categories
|
58e5ec015781be5413bdf968f7ec4fdae0ab4b21
|
[
"MIT"
] | null | null | null |
src/Categories/Category/Construction/Properties/Presheaves/Complete.agda
|
MirceaS/agda-categories
|
58e5ec015781be5413bdf968f7ec4fdae0ab4b21
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
module Categories.Category.Construction.Properties.Presheaves.Complete {o ℓ e} (C : Category o ℓ e) where
open import Data.Product
open import Function.Equality using (Π) renaming (_∘_ to _∙_)
open import Relation.Binary
open import Relation.Binary.Construct.Closure.SymmetricTransitive as ST using (Plus⇔)
open Plus⇔
open import Categories.Category.Complete
open import Categories.Category.Cocomplete
open import Categories.Category.Construction.Presheaves
open import Categories.Category.Instance.Setoids
open import Categories.Category.Instance.Properties.Setoids
open import Categories.Diagram.Limit as Lim
open import Categories.Diagram.Colimit
open import Categories.Functor
open import Categories.NaturalTransformation
import Categories.Category.Construction.Cones as Co
import Categories.Category.Construction.Cocones as Coc
import Relation.Binary.Reasoning.Setoid as SetoidR
private
module C = Category C
open C
open Π using (_⟨$⟩_)
module _ o′ where
private
P = Presheaves′ o′ o′ C
module P = Category P
module _ {J : Category o′ o′ o′} (F : Functor J P) where
module J = Category J
module F = Functor F
open F
module F₀ j = Functor (F₀ j)
module F₁ {a b} (f : a J.⇒ b) = NaturalTransformation (F₁ f)
open Setoid using () renaming (_≈_ to [_]_≈_)
F[-,_] : Obj → Functor J (Setoids o′ o′)
F[-, X ] = record
{ F₀ = λ j → F₀.₀ j X
; F₁ = λ f → F₁.η f X
; identity = identity
; homomorphism = homomorphism
; F-resp-≈ = λ eq → F-resp-≈ eq -- this application cannot be eta reduced
}
-- limit related definitions
module LimFX X = Limit (Setoids-Complete _ _ _ o′ o′ F[-, X ])
module FCone (K : Co.Cone F) where
open Co.Cone F K public
module N = Functor N
module ψ j = NaturalTransformation (ψ j)
module FCone⇒ {K K′ : Co.Cone F} (K⇒K′ : Co.Cone⇒ F K K′) where
open Co.Cone⇒ F K⇒K′ public
module arr = NaturalTransformation arr
FXcone : ∀ X → (K : Co.Cone F) → Co.Cone F[-, X ]
FXcone X K = record
{ N = N.₀ X
; apex = record
{ ψ = λ j → ψ.η j X
; commute = λ f → commute f -- this application cannot be eta reduced
}
}
where open FCone K
⊤ : Co.Cone F
⊤ = record
{ N = record
{ F₀ = λ X → LimFX.apex X
; F₁ = λ {A B} f → record
{ _⟨$⟩_ = λ { (S , eq) → (λ j → F₀.₁ j f ⟨$⟩ S j) , λ {X Y} g →
let open SetoidR (F₀.₀ Y B)
in begin
F₁.η g B ⟨$⟩ (F₀.₁ X f ⟨$⟩ S X) ≈⟨ F₁.commute g f (Setoid.refl (F₀.₀ X A)) ⟩
F₀.₁ Y f ⟨$⟩ (F₁.η g A ⟨$⟩ S X) ≈⟨ Π.cong (F₀.₁ Y f) (eq g) ⟩
F₀.₁ Y f ⟨$⟩ S Y ∎ }
; cong = λ eq j → Π.cong (F₀.₁ j f) (eq j)
}
; identity = λ eq j → F₀.identity j (eq j)
; homomorphism = λ eq j → F₀.homomorphism j (eq j)
; F-resp-≈ = λ eq eq′ j → F₀.F-resp-≈ j eq (eq′ j)
}
; apex = record
{ ψ = λ j → ntHelper record
{ η = λ X → record
{ _⟨$⟩_ = λ { (S , eq) → S j }
; cong = λ eq → eq j
}
; commute = λ f eq → Π.cong (F₀.₁ j f) (eq j)
}
; commute = λ { {Y} {Z} f {W} {S₁ , eq₁} {S₂ , eq₂} eq →
let open SetoidR (F₀.₀ Z W)
in begin
F₁.η f W ⟨$⟩ S₁ Y ≈⟨ eq₁ f ⟩
S₁ Z ≈⟨ eq Z ⟩
S₂ Z ∎ }
}
}
K⇒⊤′ : ∀ X {K} → Co.Cones F [ K , ⊤ ] → Co.Cones F[-, X ] [ FXcone X K , LimFX.limit X ]
K⇒⊤′ X {K} K⇒⊤ = record
{ arr = arr.η X
; commute = comm
}
where open FCone⇒ K⇒⊤ renaming (commute to comm)
complete : Limit F
complete = record
{ terminal = record
{ ⊤ = ⊤
; ! = λ {K} →
let module K = FCone K
in record
{ arr = ntHelper record
{ η = λ X → LimFX.rep X (FXcone X K)
; commute = λ {X Y} f eq j → K.ψ.commute j f eq
}
; commute = λ eq → Π.cong (K.ψ.η _ _) eq
}
; !-unique = λ K⇒⊤ {X} → LimFX.terminal.!-unique X (K⇒⊤′ X K⇒⊤)
}
}
-- colimit related definitions
module ColimFX X = Colimit (Setoids-Cocomplete _ _ _ o′ o′ F[-, X ])
module FCocone (K : Coc.Cocone F) where
open Coc.Cocone F K public
module N = Functor N
module ψ j = NaturalTransformation (ψ j)
module FCocone⇒ {K K′ : Coc.Cocone F} (K⇒K′ : Coc.Cocone⇒ F K K′) where
open Coc.Cocone⇒ F K⇒K′ public
module arr = NaturalTransformation arr
FXcocone : ∀ X → (K : Coc.Cocone F) → Coc.Cocone F[-, X ]
FXcocone X K = record
{ N = N.₀ X
; coapex = record
{ ψ = λ j → ψ.η j X
; commute = λ f → commute f -- this application cannot be eta reduced
}
}
where open FCocone K
⊥ : Coc.Cocone F
⊥ = record
{ N = record
{ F₀ = λ X → ColimFX.coapex X
; F₁ = λ {A B} f → record
{ _⟨$⟩_ = λ { (j , Sj) → j , F₀.₁ j f ⟨$⟩ Sj }
; cong = λ { {a , Sa} {b , Sb} →
ST.map (λ { (j , Sj) → j , F₀.₁ j f ⟨$⟩ Sj }) (helper f) }
}
; identity = λ { {A} {j , _} eq → forth⁺ (J.id , identity (F₀.identity j (Setoid.refl (F₀.₀ j A)))) eq }
; homomorphism = λ {X Y Z} {f g} → λ { {_} {j , Sj} eq →
let open Setoid (F₀.₀ j Z)
in ST.trans (coc o′ o′ F[-, Z ])
(ST.map (hom-map f g) (helper (f ∘ g)) eq)
(forth (J.id , trans (identity refl) (F₀.homomorphism j (Setoid.refl (F₀.₀ j X))))) }
; F-resp-≈ = λ {A B} {f g} eq → λ { {j , Sj} eq′ →
let open Setoid (F₀.₀ j B)
in ST.trans (coc o′ o′ F[-, B ])
(forth (J.id , trans (identity refl) (F₀.F-resp-≈ j eq (Setoid.refl (F₀.₀ j A)))))
(ST.map (λ { (j , Sj) → (j , F₀.₁ j g ⟨$⟩ Sj) }) (helper g) eq′) }
}
; coapex = record
{ ψ = λ j → ntHelper record
{ η = λ X → record
{ _⟨$⟩_ = j ,_
; cong = λ eq → forth (-, identity eq)
}
; commute = λ {X Y} f eq → back (-, identity (Π.cong (F₀.₁ j f) (Setoid.sym (F₀.₀ j X) eq)))
}
; commute = λ {a b} f {X} {x y} eq →
let open ST.Plus⇔Reasoning (coc o′ o′ F[-, X ])
in back (f , Π.cong (F₁.η f X) (Setoid.sym (F₀.₀ a X) eq))
}
}
where helper : ∀ {A B} (f : B C.⇒ A) {a Sa b Sb} →
Σ (a J.⇒ b) (λ g → [ F₀.₀ b A ] F₁.η g A ⟨$⟩ Sa ≈ Sb) →
Σ (a J.⇒ b) λ h → [ F₀.₀ b B ] F₁.η h B ⟨$⟩ (F₀.₁ a f ⟨$⟩ Sa) ≈ F₀.₁ b f ⟨$⟩ Sb
helper {A} {B} f {a} {Sa} {b} {Sb} (g , eq′) =
let open SetoidR (F₀.₀ b B)
in g , (begin
F₁.η g B ⟨$⟩ (F₀.₁ a f ⟨$⟩ Sa) ≈⟨ F₁.commute g f (Setoid.refl (F₀.₀ a A)) ⟩
F₀.₁ b f ⟨$⟩ (F₁.η g A ⟨$⟩ Sa) ≈⟨ Π.cong (F₀.₁ b f) eq′ ⟩
F₀.₁ b f ⟨$⟩ Sb ∎)
hom-map : ∀ {X Y Z} → Y C.⇒ X → Z C.⇒ Y → Σ J.Obj (λ j → Setoid.Carrier (F₀.₀ j X)) → Σ J.Obj (λ j → Setoid.Carrier (F₀.₀ j Z))
hom-map f g (j , Sj) = j , F₀.₁ j (f ∘ g) ⟨$⟩ Sj
⊥⇒K′ : ∀ X {K} → Coc.Cocones F [ ⊥ , K ] → Coc.Cocones F[-, X ] [ ColimFX.colimit X , FXcocone X K ]
⊥⇒K′ X {K} ⊥⇒K = record
{ arr = arr.η X
; commute = comm
}
where open FCocone⇒ ⊥⇒K renaming (commute to comm)
! : {K : Coc.Cocone F} → Coc.Cocone⇒ F ⊥ K
! {K} = record
{ arr = ntHelper record
{ η = λ X → ColimFX.rep X (FXcocone X K)
; commute = λ {X Y} f → λ { {a , Sa} {b , Sb} eq →
let open SetoidR (K.N.F₀ Y)
in begin
K.ψ.η a Y ⟨$⟩ (F₀.₁ a f ⟨$⟩ Sa) ≈⟨ K.ψ.commute a f (Setoid.refl (F₀.₀ a X)) ⟩
K.N.F₁ f ⟨$⟩ (K.ψ.η a X ⟨$⟩ Sa) ≈⟨ Π.cong (K.N.F₁ f) (ST.minimal (coc o′ o′ F[-, X ]) (K.N.₀ X) (Kψ X) (helper X) eq) ⟩
K.N.F₁ f ⟨$⟩ (K.ψ.η b X ⟨$⟩ Sb) ∎ }
}
; commute = λ eq → Π.cong (K.ψ.η _ _) eq
}
where module K = FCocone K
Kψ : ∀ X → Σ J.Obj (λ j → Setoid.Carrier (F₀.₀ j X)) → Setoid.Carrier (K.N.F₀ X)
Kψ X (j , S) = K.ψ.η j X ⟨$⟩ S
helper : ∀ X → coc o′ o′ F[-, X ] =[ Kψ X ]⇒ [ K.N.₀ X ]_≈_
helper X {a , Sa} {b , Sb} (f , eq) = begin
K.ψ.η a X ⟨$⟩ Sa ≈˘⟨ K.commute f (Setoid.refl (F₀.₀ a X)) ⟩
K.ψ.η b X ⟨$⟩ (F₁.η f X ⟨$⟩ Sa) ≈⟨ Π.cong (K.ψ.η b X) eq ⟩
K.ψ.η b X ⟨$⟩ Sb ∎
where open SetoidR (K.N.₀ X)
cocomplete : Colimit F
cocomplete = record
{ initial = record
{ ⊥ = ⊥
; ! = !
; !-unique = λ ⊥⇒K {X} → ColimFX.initial.!-unique X (⊥⇒K′ X ⊥⇒K)
}
}
Presheaves-Complete : Complete o′ o′ o′ P
Presheaves-Complete F = complete F
Presheaves-Cocomplete : Cocomplete o′ o′ o′ P
Presheaves-Cocomplete F = cocomplete F
| 38.412
| 141
| 0.44861
|
1a4e240285207c6c07648fe45d452beb859a1889
| 8,213
|
agda
|
Agda
|
Cubical/HITs/FiniteMultiset/Properties.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 301
|
2018-10-17T18:00:24.000Z
|
2022-03-24T02:10:47.000Z
|
Cubical/HITs/FiniteMultiset/Properties.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 584
|
2018-10-15T09:49:02.000Z
|
2022-03-30T12:09:17.000Z
|
Cubical/HITs/FiniteMultiset/Properties.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 134
|
2018-11-16T06:11:03.000Z
|
2022-03-23T16:22:13.000Z
|
{-# OPTIONS --safe #-}
module Cubical.HITs.FiniteMultiset.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Data.Nat
open import Cubical.Data.Empty as ⊥
open import Cubical.Relation.Nullary
open import Cubical.HITs.FiniteMultiset.Base
open import Cubical.Structures.MultiSet
open import Cubical.Relation.Nullary.DecidableEq
private
variable
ℓ : Level
A : Type ℓ
infixr 30 _++_
_++_ : ∀ (xs ys : FMSet A) → FMSet A
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ xs ++ ys
comm x y xs i ++ ys = comm x y (xs ++ ys) i
trunc xs zs p q i j ++ ys =
trunc (xs ++ ys) (zs ++ ys) (cong (_++ ys) p) (cong (_++ ys) q) i j
unitl-++ : ∀ (xs : FMSet A) → [] ++ xs ≡ xs
unitl-++ xs = refl
unitr-++ : ∀ (xs : FMSet A) → xs ++ [] ≡ xs
unitr-++ = ElimProp.f (trunc _ _) refl (λ x p → cong (_∷_ x) p)
assoc-++ : ∀ (xs ys zs : FMSet A) → xs ++ (ys ++ zs) ≡ (xs ++ ys) ++ zs
assoc-++ = ElimProp.f (isPropΠ2 (λ _ _ → trunc _ _))
(λ ys zs → refl)
(λ x p ys zs → cong (_∷_ x) (p ys zs))
cons-++ : ∀ (x : A) (xs : FMSet A) → x ∷ xs ≡ xs ++ [ x ]
cons-++ x = ElimProp.f (trunc _ _)
refl
(λ y {xs} p → comm x y xs ∙ cong (_∷_ y) p)
comm-++ : ∀ (xs ys : FMSet A) → xs ++ ys ≡ ys ++ xs
comm-++ = ElimProp.f (isPropΠ (λ _ → trunc _ _))
(λ ys → sym (unitr-++ ys))
(λ x {xs} p ys → cong (x ∷_) (p ys)
∙ cong (_++ xs) (cons-++ x ys)
∙ sym (assoc-++ ys [ x ] xs))
module FMSetUniversal {ℓ} {M : Type ℓ} (MSet : isSet M)
(e : M) (_⊗_ : M → M → M)
(comm-⊗ : ∀ x y → x ⊗ y ≡ y ⊗ x) (assoc-⊗ : ∀ x y z → x ⊗ (y ⊗ z) ≡ (x ⊗ y) ⊗ z)
(unit-⊗ : ∀ x → e ⊗ x ≡ x)
(f : A → M) where
f-extend : FMSet A → M
f-extend = Rec.f MSet e (λ x m → f x ⊗ m)
(λ x y m → comm-⊗ (f x) (f y ⊗ m) ∙ sym (assoc-⊗ (f y) m (f x)) ∙ cong (f y ⊗_) (comm-⊗ m (f x)))
f-extend-nil : f-extend [] ≡ e
f-extend-nil = refl
f-extend-cons : ∀ x xs → f-extend (x ∷ xs) ≡ f x ⊗ f-extend xs
f-extend-cons x xs = refl
f-extend-sing : ∀ x → f-extend [ x ] ≡ f x
f-extend-sing x = comm-⊗ (f x) e ∙ unit-⊗ (f x)
f-extend-++ : ∀ xs ys → f-extend (xs ++ ys) ≡ f-extend xs ⊗ f-extend ys
f-extend-++ = ElimProp.f (isPropΠ λ _ → MSet _ _)
(λ ys → sym (unit-⊗ (f-extend ys)))
(λ x {xs} p ys → cong (f x ⊗_) (p ys) ∙ assoc-⊗ (f x) (f-extend xs) (f-extend ys))
module _ (h : FMSet A → M) (h-nil : h [] ≡ e) (h-sing : ∀ x → h [ x ] ≡ f x)
(h-++ : ∀ xs ys → h (xs ++ ys) ≡ h xs ⊗ h ys) where
f-extend-unique : h ≡ f-extend
f-extend-unique = funExt (ElimProp.f (MSet _ _)
h-nil
(λ x {xs} p → (h-++ [ x ] xs) ∙ cong (_⊗ h xs) (h-sing x) ∙ cong (f x ⊗_) p))
-- We want to construct a multiset-structure on FMSet A, the empty set and insertion are given by the constructors,
-- for the count part we use the recursor
-- If A has decidable equality we can define the count-function:
module _(discA : Discrete A) where
FMScount-∷* : A → A → ℕ → ℕ
FMScount-∷* a x n with discA a x
... | yes a≡x = suc n
... | no a≢x = n
FMScount-comm* : (a x y : A) (n : ℕ)
→ FMScount-∷* a x (FMScount-∷* a y n)
≡ FMScount-∷* a y (FMScount-∷* a x n)
FMScount-comm* a x y n with discA a x | discA a y
... | yes a≡x | yes a≡y = refl
... | yes a≡x | no a≢y = refl
... | no a≢x | yes a≡y = refl
... | no a≢x | no a≢y = refl
FMScount : A → FMSet A → ℕ
FMScount a = Rec.f isSetℕ 0 (FMScount-∷* a) (FMScount-comm* a)
FMS-with-str : MultiSet A (Discrete→isSet discA)
FMS-with-str = (FMSet A , [] , _∷_ , FMScount)
-- We prove some useful properties of the FMScount function
FMScount-≡-lemma : ∀ {a} {x} xs → a ≡ x → FMScount a (x ∷ xs) ≡ suc (FMScount a xs)
FMScount-≡-lemma {a} {x} xs a≡x with discA a x
... | yes _ = refl
... | no a≢x = ⊥.rec (a≢x a≡x)
FMScount-≡-lemma-refl : ∀ {x} xs → FMScount x (x ∷ xs) ≡ suc (FMScount x xs)
FMScount-≡-lemma-refl {x} xs = FMScount-≡-lemma xs refl
FMScount-≢-lemma : ∀ {a} {x} xs → ¬ a ≡ x → FMScount a (x ∷ xs) ≡ FMScount a xs
FMScount-≢-lemma {a} {x} xs a≢x with discA a x
... | yes a≡x = ⊥.rec (a≢x a≡x)
... | no _ = refl
FMScount-0-lemma : ∀ xs → (∀ a → FMScount a xs ≡ 0) → xs ≡ []
FMScount-0-lemma = ElimProp.f (isPropΠ λ _ → trunc _ _) (λ _ → refl) θ
where
θ : ∀ x {xs} → ((∀ a → FMScount a xs ≡ 0) → xs ≡ [])
→ ((∀ a → FMScount a (x ∷ xs) ≡ 0) → (x ∷ xs) ≡ [])
θ x {xs} _ p = ⊥.rec (snotz (sym (FMScount-≡-lemma-refl xs) ∙ p x))
-- we define a function that removes an element a from a finite multiset once
-- by simultaneously defining two lemmas about it
remove1 : A → FMSet A → FMSet A
remove1 a [] = []
remove1 a (x ∷ xs) with (discA a x)
... | yes _ = xs
... | no _ = x ∷ remove1 a xs
remove1 a (comm x y xs i) with discA a x with discA a y
... | yes a≡x | yes a≡y = ((sym a≡y ∙ a≡x) i) ∷ xs
... | yes a≡x | no _ = y ∷ (eq i)
where
eq : xs ≡ remove1 a (x ∷ xs)
eq with discA a x
eq | yes _ = refl
eq | no a≢x = ⊥.rec (a≢x a≡x)
remove1 a (comm x y xs i) | no _ | yes a≡y = x ∷ (eq i)
where
eq : remove1 a (y ∷ xs) ≡ xs
eq with discA a y
eq | yes _ = refl
eq | no a≢y = ⊥.rec (a≢y a≡y)
remove1 a (comm x y xs i) | no a≢x | no a≢y = ((λ i → x ∷ (p i)) ∙∙ comm x y (remove1 a xs) ∙∙ (λ i → y ∷ (sym q i))) i
where
p : remove1 a (y ∷ xs) ≡ y ∷ (remove1 a xs)
p with discA a y
p | yes a≡y = ⊥.rec (a≢y a≡y)
p | no _ = refl
q : remove1 a (x ∷ xs) ≡ x ∷ (remove1 a xs)
q with discA a x
q | yes a≡x = ⊥.rec (a≢x a≡x)
q | no _ = refl
remove1 a (trunc xs ys p q i j) = trunc (remove1 a xs) (remove1 a ys) (cong (remove1 a) p) (cong (remove1 a) q) i j
remove1-≡-lemma : ∀ {a} {x} xs → a ≡ x → xs ≡ remove1 a (x ∷ xs)
remove1-≡-lemma {a} {x} xs a≡x with discA a x
... | yes _ = refl
... | no a≢x = ⊥.rec (a≢x a≡x)
remove1-≢-lemma : ∀ {a} {x} xs → ¬ a ≡ x → remove1 a (x ∷ xs) ≡ x ∷ remove1 a xs
remove1-≢-lemma {a} {x} xs a≢x with discA a x
... | yes a≡x = ⊥.rec (a≢x a≡x)
... | no _ = refl
remove1-predℕ-lemma : ∀ a xs → FMScount a (remove1 a xs) ≡ predℕ (FMScount a xs)
remove1-predℕ-lemma a = ElimProp.f (isSetℕ _ _) refl θ
where
θ : ∀ x {xs} → FMScount a (remove1 a xs) ≡ predℕ (FMScount a xs)
→ FMScount a (remove1 a (x ∷ xs)) ≡ predℕ (FMScount a (x ∷ xs))
θ x {xs} p with discA a x
... | yes _ = refl
... | no a≢x = FMScount-≢-lemma (remove1 a xs) a≢x ∙ p
remove1-zero-lemma : ∀ a xs → FMScount a xs ≡ zero → xs ≡ remove1 a xs
remove1-zero-lemma a = ElimProp.f (isPropΠ λ _ → trunc _ _) (λ _ → refl) θ
where
θ : ∀ x {xs} → (FMScount a xs ≡ zero → xs ≡ remove1 a xs)
→ FMScount a (x ∷ xs) ≡ zero → x ∷ xs ≡ remove1 a (x ∷ xs)
θ x {xs} hyp p with discA a x
... | yes _ = ⊥.rec (snotz p)
... | no _ = cong (x ∷_) (hyp p)
remove1-suc-lemma : ∀ a n xs → FMScount a xs ≡ suc n → xs ≡ a ∷ (remove1 a xs)
remove1-suc-lemma a n = ElimProp.f (isPropΠ λ _ → trunc _ _) (λ p → ⊥.rec (znots p)) θ
where
θ : ∀ x {xs} → (FMScount a xs ≡ suc n → xs ≡ a ∷ (remove1 a xs))
→ FMScount a (x ∷ xs) ≡ suc n → x ∷ xs ≡ a ∷ (remove1 a (x ∷ xs))
θ x {xs} hyp p with discA a x
... | yes a≡x = (λ i → (sym a≡x i) ∷ xs)
... | no a≢x = cong (x ∷_) (hyp p) ∙ comm x a (remove1 a xs)
FMScount-remove1-≢-lemma : ∀ {a} {x} xs → ¬ a ≡ x → FMScount a (remove1 x xs) ≡ FMScount a xs
FMScount-remove1-≢-lemma {a} {x} xs a≢x with discreteℕ (FMScount x xs) zero
... | yes p = cong (FMScount a) (sym (remove1-zero-lemma x xs p))
... | no ¬p = sym (FMScount-≢-lemma (remove1 x xs) a≢x) ∙ cong (FMScount a) eq₁
where
eq₁ : (x ∷ remove1 x xs) ≡ xs
eq₁ = sym (remove1-suc-lemma x (predℕ (FMScount x xs)) xs (suc-predℕ (FMScount x xs) ¬p))
| 37.331818
| 127
| 0.499696
|
187755c08b92982944ee494cb9f988213783b559
| 19,488
|
agda
|
Agda
|
Cubical/Experiments/ZCohomologyOld/Groups/Sn.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
Cubical/Experiments/ZCohomologyOld/Groups/Sn.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
Cubical/Experiments/ZCohomologyOld/Groups/Sn.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Experiments.ZCohomologyOld.Groups.Sn where
open import Cubical.ZCohomology.Base
open import Cubical.Experiments.ZCohomologyOld.Properties
open import Cubical.Experiments.ZCohomologyOld.MayerVietorisUnreduced
open import Cubical.Experiments.ZCohomologyOld.Groups.Unit
open import Cubical.Experiments.ZCohomologyOld.Groups.Connected
open import Cubical.Experiments.ZCohomologyOld.KcompPrelims
open import Cubical.Experiments.ZCohomologyOld.Groups.Prelims
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Function
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Structure
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.GroupoidLaws
open import Cubical.HITs.Pushout
open import Cubical.HITs.Sn
open import Cubical.HITs.S1
open import Cubical.HITs.Susp
open import Cubical.HITs.SetTruncation renaming (rec to sRec ; elim to sElim ; elim2 to sElim2 ; map to sMap)
open import Cubical.HITs.PropositionalTruncation renaming (rec to pRec ; elim to pElim ; elim2 to pElim2 ; ∥_∥ to ∥_∥₁ ; ∣_∣ to ∣_∣₁) hiding (map)
open import Cubical.Data.Bool
open import Cubical.Data.Sigma
open import Cubical.Data.Int renaming (_+_ to _+ℤ_; +-comm to +ℤ-comm ; +-assoc to +ℤ-assoc)
open import Cubical.Data.Nat
open import Cubical.HITs.Truncation renaming (elim to trElim ; map to trMap ; rec to trRec)
open import Cubical.Data.Unit
open import Cubical.Homotopy.Connected
open import Cubical.Algebra.Group
infixr 31 _□_
_□_ : _
_□_ = compGroupIso
open GroupEquiv
open vSES
open GroupIso
open GroupHom
open BijectionIso
Sn-connected : (n : ℕ) (x : typ (S₊∙ (suc n))) → ∥ pt (S₊∙ (suc n)) ≡ x ∥₁
Sn-connected zero = toPropElim (λ _ → propTruncIsProp) ∣ refl ∣₁
Sn-connected (suc zero) = suspToPropElim base (λ _ → propTruncIsProp) ∣ refl ∣₁
Sn-connected (suc (suc n)) = suspToPropElim north (λ _ → propTruncIsProp) ∣ refl ∣₁
H⁰-Sⁿ≅ℤ : (n : ℕ) → GroupIso (coHomGr 0 (S₊ (suc n))) intGroup
H⁰-Sⁿ≅ℤ zero = H⁰-connected base (Sn-connected 0)
H⁰-Sⁿ≅ℤ (suc n) = H⁰-connected north (Sn-connected (suc n))
-- -- ----------------------------------------------------------------------
--- We will need to switch between Sⁿ defined using suspensions and using pushouts
--- in order to apply Mayer Vietoris.
S1Iso : Iso S¹ (Pushout {A = Bool} (λ _ → tt) λ _ → tt)
S1Iso = S¹IsoSuspBool ⋄ invIso PushoutSuspIsoSusp
coHomPushout≅coHomSn : (n m : ℕ) → GroupIso (coHomGr m (S₊ (suc n)))
(coHomGr m (Pushout {A = S₊ n} (λ _ → tt) λ _ → tt))
coHomPushout≅coHomSn zero m =
Iso+Hom→GrIso (setTruncIso (domIso S1Iso))
(sElim2 (λ _ _ → isSet→isGroupoid setTruncIsSet _ _) (λ _ _ → refl))
coHomPushout≅coHomSn (suc n) m =
Iso+Hom→GrIso (setTruncIso (domIso (invIso PushoutSuspIsoSusp)))
(sElim2 (λ _ _ → isSet→isGroupoid setTruncIsSet _ _) (λ _ _ → refl))
-------------------------- H⁰(S⁰) -----------------------------
S0→Int : (a : Int × Int) → S₊ 0 → Int
S0→Int a true = fst a
S0→Int a false = snd a
H⁰-S⁰≅ℤ×ℤ : GroupIso (coHomGr 0 (S₊ 0)) (dirProd intGroup intGroup)
fun (map H⁰-S⁰≅ℤ×ℤ) = sRec (isSet× isSetInt isSetInt) λ f → (f true) , (f false)
isHom (map H⁰-S⁰≅ℤ×ℤ) = sElim2 (λ _ _ → isSet→isGroupoid (isSet× isSetInt isSetInt) _ _)
λ a b i → addLemma (a true) (b true) i , addLemma (a false) (b false) i
inv H⁰-S⁰≅ℤ×ℤ a = ∣ S0→Int a ∣₂
rightInv H⁰-S⁰≅ℤ×ℤ _ = refl
leftInv H⁰-S⁰≅ℤ×ℤ = sElim (λ _ → isSet→isGroupoid setTruncIsSet _ _)
λ f → cong ∣_∣₂ (funExt (λ {true → refl ; false → refl}))
------------------------- H¹(S⁰) ≅ 0 -------------------------------
private
Hⁿ-S0≃Kₙ×Kₙ : (n : ℕ) → Iso (S₊ 0 → coHomK (suc n)) (coHomK (suc n) × coHomK (suc n))
Iso.fun (Hⁿ-S0≃Kₙ×Kₙ n) f = (f true) , (f false)
Iso.inv (Hⁿ-S0≃Kₙ×Kₙ n) (a , b) true = a
Iso.inv (Hⁿ-S0≃Kₙ×Kₙ n) (a , b) false = b
Iso.rightInv (Hⁿ-S0≃Kₙ×Kₙ n) a = refl
Iso.leftInv (Hⁿ-S0≃Kₙ×Kₙ n) b = funExt λ {true → refl ; false → refl}
isContrHⁿ-S0 : (n : ℕ) → isContr (coHom (suc n) (S₊ 0))
isContrHⁿ-S0 n = isContrRetract (Iso.fun (setTruncIso (Hⁿ-S0≃Kₙ×Kₙ n)))
(Iso.inv (setTruncIso (Hⁿ-S0≃Kₙ×Kₙ n)))
(Iso.leftInv (setTruncIso (Hⁿ-S0≃Kₙ×Kₙ n)))
(isContrHelper n)
where
isContrHelper : (n : ℕ) → isContr (∥ (coHomK (suc n) × coHomK (suc n)) ∥₂)
fst (isContrHelper zero) = ∣ (0₁ , 0₁) ∣₂
snd (isContrHelper zero) = sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _)
λ y → elim2 {B = λ x y → ∣ (0₁ , 0₁) ∣₂ ≡ ∣(x , y) ∣₂ }
(λ _ _ → isOfHLevelPlus {n = 2} 2 setTruncIsSet _ _)
(toPropElim2 (λ _ _ → setTruncIsSet _ _) refl) (fst y) (snd y)
isContrHelper (suc zero) = ∣ (0₂ , 0₂) ∣₂
, sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _)
λ y → elim2 {B = λ x y → ∣ (0₂ , 0₂) ∣₂ ≡ ∣(x , y) ∣₂ }
(λ _ _ → isOfHLevelPlus {n = 2} 3 setTruncIsSet _ _)
(suspToPropElim2 base (λ _ _ → setTruncIsSet _ _) refl) (fst y) (snd y)
isContrHelper (suc (suc n)) = ∣ (0ₖ (3 + n) , 0ₖ (3 + n)) ∣₂
, sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _)
λ y → elim2 {B = λ x y → ∣ (0ₖ (3 + n) , 0ₖ (3 + n)) ∣₂ ≡ ∣(x , y) ∣₂ }
(λ _ _ → isProp→isOfHLevelSuc (4 + n) (setTruncIsSet _ _))
(suspToPropElim2 north (λ _ _ → setTruncIsSet _ _) refl) (fst y) (snd y)
H¹-S⁰≅0 : (n : ℕ) → GroupIso (coHomGr (suc n) (S₊ 0)) trivialGroup
H¹-S⁰≅0 n = IsoContrGroupTrivialGroup (isContrHⁿ-S0 n)
------------------------- H²(S¹) ≅ 0 -------------------------------
Hⁿ-S¹≅0 : (n : ℕ) → GroupIso (coHomGr (2 + n) (S₊ 1)) trivialGroup
Hⁿ-S¹≅0 n = IsoContrGroupTrivialGroup
(isOfHLevelRetractFromIso 0 helper
(_ , helper2))
where
helper : Iso ⟨ coHomGr (2 + n) (S₊ 1)⟩ ∥ Σ (hLevelTrunc (4 + n) (S₊ (2 + n))) (λ x → ∥ x ≡ x ∥₂) ∥₂
helper = compIso (setTruncIso IsoFunSpaceS¹) IsoSetTruncateSndΣ
helper2 : (x : ∥ Σ (hLevelTrunc (4 + n) (S₊ (2 + n))) (λ x → ∥ x ≡ x ∥₂) ∥₂) → ∣ ∣ north ∣ , ∣ refl ∣₂ ∣₂ ≡ x
helper2 =
sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _)
(uncurry
(trElim (λ _ → isOfHLevelΠ (4 + n) λ _ → isProp→isOfHLevelSuc (3 + n) (setTruncIsSet _ _))
(suspToPropElim (ptSn (suc n)) (λ _ → isPropΠ λ _ → setTruncIsSet _ _)
(sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _)
λ p
→ cong ∣_∣₂ (ΣPathP (refl , isContr→isProp helper3 _ _))))))
where
helper4 : isConnected (n + 3) (hLevelTrunc (4 + n) (S₊ (2 + n)))
helper4 = subst (λ m → isConnected m (hLevelTrunc (4 + n) (S₊ (2 + n)))) (+-comm 3 n)
(isOfHLevelRetractFromIso 0 (invIso (truncOfTruncIso (3 + n) 1)) (sphereConnected (2 + n)))
helper3 : isContr ∥ ∣ north ∣ ≡ ∣ north ∣ ∥₂
helper3 = isOfHLevelRetractFromIso 0 setTruncTrunc2Iso
(isConnectedPath 2 (isConnectedSubtr 3 n helper4) _ _)
-- --------------- H¹(Sⁿ), n ≥ 1 --------------------------------------------
H¹-Sⁿ≅0 : (n : ℕ) → GroupIso (coHomGr 1 (S₊ (2 + n))) trivialGroup
H¹-Sⁿ≅0 zero = IsoContrGroupTrivialGroup isContrH¹S²
where
isContrH¹S² : isContr ⟨ coHomGr 1 (S₊ 2) ⟩
isContrH¹S² = ∣ (λ _ → ∣ base ∣) ∣₂
, coHomPointedElim 0 north (λ _ → setTruncIsSet _ _)
λ f p → cong ∣_∣₂ (funExt λ x → sym p ∙∙ sym (spoke f north) ∙∙ spoke f x)
H¹-Sⁿ≅0 (suc n) = IsoContrGroupTrivialGroup isContrH¹S³⁺ⁿ
where
anIso : Iso ⟨ coHomGr 1 (S₊ (3 + n)) ⟩ ∥ (S₊ (3 + n) → hLevelTrunc (4 + n) (coHomK 1)) ∥₂
anIso =
setTruncIso
(codomainIso
(invIso (truncIdempotentIso (4 + n) (isOfHLevelPlus' {n = 1 + n} 3 (isOfHLevelTrunc 3)))))
isContrH¹S³⁺ⁿ-ish : (f : (S₊ (3 + n) → hLevelTrunc (4 + n) (coHomK 1)))
→ ∣ (λ _ → ∣ ∣ base ∣ ∣) ∣₂ ≡ ∣ f ∣₂
isContrH¹S³⁺ⁿ-ish f = ind (f north) refl
where
ind : (x : hLevelTrunc (4 + n) (coHomK 1))
→ x ≡ f north
→ ∣ (λ _ → ∣ ∣ base ∣ ∣) ∣₂ ≡ ∣ f ∣₂
ind = trElim (λ _ → isOfHLevelΠ (4 + n) λ _ → isOfHLevelPlus' {n = (3 + n)} 1 (setTruncIsSet _ _))
(trElim (λ _ → isOfHLevelΠ 3 λ _ → isOfHLevelPlus {n = 1} 2 (setTruncIsSet _ _))
(toPropElim (λ _ → isPropΠ λ _ → setTruncIsSet _ _)
λ p → cong ∣_∣₂ (funExt λ x → p ∙∙ sym (spoke f north) ∙∙ spoke f x)))
isContrH¹S³⁺ⁿ : isContr ⟨ coHomGr 1 (S₊ (3 + n)) ⟩
isContrH¹S³⁺ⁿ =
isOfHLevelRetractFromIso 0
anIso
(∣ (λ _ → ∣ ∣ base ∣ ∣) ∣₂
, sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _) isContrH¹S³⁺ⁿ-ish)
--------- Direct proof of H¹(S¹) ≅ ℤ without Mayer-Vietoris -------
-- The strategy is to use the proof that ΩS¹ ≃ ℤ. Since we only have this for S¹ with the base/loop definition
-- we begin with some functions translating between H¹(S₊ 1) and ∥ S¹ → S¹ ∥₀. The latter type is easy to characterise,
-- by (S¹ → S¹) ≃ S¹ × ℤ (see Cubical.Experiments.ZCohomologyOld.Groups.Prelims). Truncating this leaves only ℤ, since S¹ is connected.
-- The translation mentioned above uses the basechange function. We use basechange-lemma (Cubical.Experiments.ZCohomologyOld.Groups.Prelims) to prove the basechange2⁻ preserves
-- path composition (in a more general sense than what is proved in basechange2⁻-morph)
-- We can now give the group equivalence. The first bit is just a big composition of our previously defined translations and is pretty uninteresting.
-- The harder step is proving that the equivalence is a morphism. This relies heavily on the fact that addition the cohomology groups essentially is defined using an
-- application of cong₂, which allows us to use basechange-lemma.
coHom1S1≃ℤ : GroupIso (coHomGr 1 (S₊ 1)) intGroup
coHom1S1≃ℤ = theIso
where
F = Iso.fun S¹→S¹≡S¹×Int
F⁻ = Iso.inv S¹→S¹≡S¹×Int
theIso : GroupIso (coHomGr 1 (S₊ 1)) intGroup
fun (map theIso) = sRec isSetInt (λ f → snd (F f))
isHom (map theIso) = sElim2 (λ _ _ → isOfHLevelPath 2 isSetInt _ _)
λ f g → ((λ i → winding (guy (ΩKn+1→Kn 1 (Kn→ΩKn+1 1 (f base) ∙ Kn→ΩKn+1 1 (g base)))
(λ i → S¹map (ΩKn+1→Kn 1 (Kn→ΩKn+1 1 (f (loop i)) ∙ Kn→ΩKn+1 1 (g (loop i))))))))
∙∙ cong winding (helper (f base) (g base) f g refl refl)
∙∙ winding-hom (guy (f base) (λ i → S¹map (f (loop i))))
(guy (g base) (λ i → S¹map (g (loop i))))
where
guy = basechange2⁻ ∘ S¹map
helper : (x y : coHomK 1) (f g : S₊ 1 → coHomK 1)
→ (f base) ≡ x
→ (g base) ≡ y
→ (guy (ΩKn+1→Kn 1 (Kn→ΩKn+1 1 (f base) ∙ Kn→ΩKn+1 1 (g base)))
(λ i → S¹map ((ΩKn+1→Kn 1 (Kn→ΩKn+1 1 (f (loop i)) ∙ Kn→ΩKn+1 1 (g (loop i)))))))
≡ (guy (f base)
(λ i → S¹map (f (loop i))))
∙ (guy (g base)
(λ i → S¹map ((g (loop i)))))
helper =
elim2 (λ _ _ → isGroupoidΠ4 λ _ _ _ _ → isOfHLevelPath 3 (isOfHLevelSuc 3 (isGroupoidS¹) base base) _ _)
(toPropElim2
(λ _ _ → isPropΠ4 λ _ _ _ _ → isGroupoidS¹ _ _ _ _)
λ f g reflf reflg →
basechange-lemma base base
(S¹map ∘ (ΩKn+1→Kn 1))
((Kn→ΩKn+1 1) ∘ f) ((Kn→ΩKn+1 1) ∘ g)
(cong (Kn→ΩKn+1 1) reflf ∙ Kn→ΩKn+10ₖ 1) (cong (Kn→ΩKn+1 1) reflg ∙ Kn→ΩKn+10ₖ 1)
∙ λ j → guy (Iso.leftInv (Iso-Kn-ΩKn+1 1) (f base) j)
(λ i → S¹map (Iso.leftInv (Iso-Kn-ΩKn+1 1) (f (loop i)) j))
∙ guy (Iso.leftInv (Iso-Kn-ΩKn+1 1) (g base) j)
(λ i → S¹map (Iso.leftInv (Iso-Kn-ΩKn+1 1) (g (loop i)) j)))
inv theIso a = ∣ (F⁻ (base , a)) ∣₂
rightInv theIso a = cong snd (Iso.rightInv S¹→S¹≡S¹×Int (base , a))
leftInv theIso = sElim (λ _ → isOfHLevelPath 2 setTruncIsSet _ _)
λ f → cong ((sRec setTruncIsSet ∣_∣₂)
∘ sRec setTruncIsSet λ x → ∣ F⁻ (x , (snd (F f))) ∣₂)
(Iso.inv PathIdTrunc₀Iso (isConnectedS¹ (fst (F f))))
∙ cong ∣_∣₂ (Iso.leftInv S¹→S¹≡S¹×Int f)
---------------------------- Hⁿ(Sⁿ) ≅ ℤ , n ≥ 1 -------------------
Hⁿ-Sⁿ≅ℤ : (n : ℕ) → GroupIso intGroup (coHomGr (suc n) (S₊ (suc n)))
Hⁿ-Sⁿ≅ℤ zero = invGroupIso coHom1S1≃ℤ
Hⁿ-Sⁿ≅ℤ (suc n) =
Hⁿ-Sⁿ≅ℤ n
□ vSES→GroupIso _ _ theIso
□ invGroupIso (coHomPushout≅coHomSn (suc n) (suc (suc n)))
where
module K = MV Unit Unit (S₊ (suc n)) (λ _ → tt) (λ _ → tt)
theIso : vSES (coHomGr (suc n) (S₊ (suc n))) (coHomGr (suc (suc n))
(Pushout {A = S₊ (suc n)} (λ _ → tt) (λ _ → tt)))
_
_
isTrivialLeft theIso p q = ΣPathP (isOfHLevelSuc 0 (isContrHⁿ-Unit n) (fst p) (fst q)
, isOfHLevelSuc 0 (isContrHⁿ-Unit n) (snd p) (snd q))
isTrivialRight theIso p q = ΣPathP (isOfHLevelSuc 0 (isContrHⁿ-Unit (suc n)) (fst p) (fst q)
, isOfHLevelSuc 0 (isContrHⁿ-Unit (suc n)) (snd p) (snd q))
left theIso = K.Δ (suc n)
right theIso = K.i (2 + n)
vSES.ϕ theIso = K.d (suc n)
Ker-ϕ⊂Im-left theIso = K.Ker-d⊂Im-Δ (suc n)
Ker-right⊂Im-ϕ theIso = K.Ker-i⊂Im-d (suc n)
{- More standard proof of H¹(S¹) ≅ ℤ using Mayer-Vietoris.
This is much slower than the direct proof, but let's keep it here for completeness.
-- --------------------------H¹(S¹) -----------------------------------
{-
In order to apply Mayer-Vietoris, we need the following lemma.
Given the following diagram
a ↦ (a , 0) ψ ϕ
A --> A × A -------> B ---> C
If ψ is an isomorphism and ϕ is surjective with ker ϕ ≡ {ψ (a , a) ∣ a ∈ A}, then C ≅ B
-}
diagonalIso : ∀ {ℓ ℓ' ℓ''} {A : Group {ℓ}} (B : Group {ℓ'}) {C : Group {ℓ''}}
(ψ : GroupIso (dirProd A A) B) (ϕ : GroupHom B C)
→ isSurjective _ _ ϕ
→ ((x : ⟨ B ⟩) → isInKer B C ϕ x
→ ∃[ y ∈ ⟨ A ⟩ ] x ≡ (fun (map ψ)) (y , y))
→ ((x : ⟨ B ⟩) → (∃[ y ∈ ⟨ A ⟩ ] x ≡ (fun (map ψ)) (y , y))
→ isInKer B C ϕ x)
→ GroupIso A C
diagonalIso {A = A} B {C = C} ψ ϕ issurj ker→diag diag→ker = BijectionIsoToGroupIso bijIso
where
open GroupStr
module A = GroupStr (snd A)
module B = GroupStr (snd B)
module C = GroupStr (snd C)
module A×A = GroupStr (snd (dirProd A A))
module ψ = GroupIso ψ
module ϕ = GroupHom ϕ
ψ⁻ = inv ψ
fstProj : GroupHom A (dirProd A A)
fun fstProj a = a , GroupStr.0g (snd A)
isHom fstProj g0 g1 i = (g0 A.+ g1) , GroupStr.lid (snd A) (GroupStr.0g (snd A)) (~ i)
bijIso : BijectionIso A C
map' bijIso = compGroupHom fstProj (compGroupHom (map ψ) ϕ)
inj bijIso a inker = pRec (isSetCarrier A _ _)
(λ {(a' , id) → (cong fst (sym (leftInv ψ (a , GroupStr.0g (snd A))) ∙∙ cong ψ⁻ id ∙∙ leftInv ψ (a' , a')))
∙ cong snd (sym (leftInv ψ (a' , a')) ∙∙ cong ψ⁻ (sym id) ∙∙ leftInv ψ (a , GroupStr.0g (snd A)))})
(ker→diag _ inker)
surj bijIso c =
pRec propTruncIsProp
(λ { (b , id) → ∣ (fst (ψ⁻ b) A.+ (A.- snd (ψ⁻ b)))
, ((sym (GroupStr.rid (snd C) _)
∙∙ cong ((fun ϕ) ((fun (map ψ)) (fst (ψ⁻ b) A.+ (A.- snd (ψ⁻ b)) , GroupStr.0g (snd A))) C.+_)
(sym (diag→ker (fun (map ψ) ((snd (ψ⁻ b)) , (snd (ψ⁻ b))))
∣ (snd (ψ⁻ b)) , refl ∣₁))
∙∙ sym ((isHom ϕ) _ _))
∙∙ cong (fun ϕ) (sym ((isHom (map ψ)) _ _)
∙∙ cong (fun (map ψ)) (ΣPathP (sym (GroupStr.assoc (snd A) _ _ _)
∙∙ cong (fst (ψ⁻ b) A.+_) (GroupStr.invl (snd A) _)
∙∙ GroupStr.rid (snd A) _
, (GroupStr.lid (snd A) _)))
∙∙ rightInv ψ b)
∙∙ id) ∣₁ })
(issurj c)
H¹-S¹≅ℤ : GroupIso intGroup (coHomGr 1 (S₊ 1))
H¹-S¹≅ℤ =
diagonalIso (coHomGr 0 (S₊ 0))
(invGroupIso H⁰-S⁰≅ℤ×ℤ)
(K.d 0)
(λ x → K.Ker-i⊂Im-d 0 x
(ΣPathP (isOfHLevelSuc 0 (isContrHⁿ-Unit 0) _ _
, isOfHLevelSuc 0 (isContrHⁿ-Unit 0) _ _)))
((sElim (λ _ → isOfHLevelΠ 2 λ _ → isOfHLevelSuc 1 propTruncIsProp)
(λ x inker
→ pRec propTruncIsProp
(λ {((f , g) , id') → helper x f g id' inker})
((K.Ker-d⊂Im-Δ 0 ∣ x ∣₂ inker)))))
((sElim (λ _ → isOfHLevelΠ 2 λ _ → isOfHLevelPath 2 setTruncIsSet _ _)
λ F surj
→ pRec (setTruncIsSet _ _)
(λ { (x , id) → K.Im-Δ⊂Ker-d 0 ∣ F ∣₂
∣ (∣ (λ _ → x) ∣₂ , ∣ (λ _ → 0) ∣₂) ,
(cong ∣_∣₂ (funExt (surjHelper x))) ∙ sym id ∣₁ })
surj) )
□ invGroupIso (coHomPushout≅coHomSn 0 1)
where
module K = MV Unit Unit (S₊ 0) (λ _ → tt) (λ _ → tt)
surjHelper : (x : Int) (x₁ : S₊ 0) → x -[ 0 ]ₖ 0 ≡ S0→Int (x , x) x₁
surjHelper x true = Iso.leftInv (Iso-Kn-ΩKn+1 0) x
surjHelper x false = Iso.leftInv (Iso-Kn-ΩKn+1 0) x
helper : (F : S₊ 0 → Int) (f g : ∥ (Unit → Int) ∥₂)
(id : GroupHom.fun (K.Δ 0) (f , g) ≡ ∣ F ∣₂)
→ isInKer (coHomGr 0 (S₊ 0))
(coHomGr 1 (Pushout (λ _ → tt) (λ _ → tt)))
(K.d 0)
∣ F ∣₂
→ ∃[ x ∈ Int ] ∣ F ∣₂ ≡ inv H⁰-S⁰≅ℤ×ℤ (x , x)
helper F =
sElim2 (λ _ _ → isOfHLevelΠ 2 λ _ → isOfHLevelΠ 2 λ _ → isOfHLevelSuc 1 propTruncIsProp)
λ f g id inker
→ pRec propTruncIsProp
(λ ((a , b) , id2)
→ sElim2 {C = λ f g → GroupHom.fun (K.Δ 0) (f , g) ≡ ∣ F ∣₂ → _ }
(λ _ _ → isOfHLevelΠ 2 λ _ → isOfHLevelSuc 1 propTruncIsProp)
(λ f g id → ∣ (helper2 f g .fst) , (sym id ∙ sym (helper2 f g .snd)) ∣₁)
a b id2)
(MV.Ker-d⊂Im-Δ _ _ (S₊ 0) (λ _ → tt) (λ _ → tt) 0 ∣ F ∣₂ inker)
where
helper2 : (f g : Unit → Int)
→ Σ[ x ∈ Int ] (inv H⁰-S⁰≅ℤ×ℤ (x , x))
≡ GroupHom.fun (K.Δ 0) (∣ f ∣₂ , ∣ g ∣₂)
helper2 f g = (f _ -[ 0 ]ₖ g _) , cong ∣_∣₂ (funExt λ {true → refl ; false → refl})
-}
| 50.097686
| 176
| 0.509904
|
2fdaf2d2bd74e412cd5dbfaa668ea8607101438f
| 6,893
|
agda
|
Agda
|
agda-stdlib/src/Relation/Binary/Construct/Add/Supremum/Strict.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Relation/Binary/Construct/Add/Supremum/Strict.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Relation/Binary/Construct/Add/Supremum/Strict.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- The lifting of a strict order to incorporate a new supremum
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
-- This module is designed to be used with
-- Relation.Nullary.Construct.Add.Supremum
open import Relation.Binary
module Relation.Binary.Construct.Add.Supremum.Strict
{a r} {A : Set a} (_<_ : Rel A r) where
open import Level using (_⊔_)
open import Data.Product
open import Function
open import Relation.Nullary hiding (Irrelevant)
import Relation.Nullary.Decidable as Dec
open import Relation.Binary.PropositionalEquality as P
using (_≡_; refl)
open import Relation.Nullary.Construct.Add.Supremum
import Relation.Binary.Construct.Add.Supremum.Equality as Equality
import Relation.Binary.Construct.Add.Supremum.NonStrict as NonStrict
------------------------------------------------------------------------
-- Definition
infix 4 _<⁺_
data _<⁺_ : Rel (A ⁺) (a ⊔ r) where
[_] : {k l : A} → k < l → [ k ] <⁺ [ l ]
[_]<⊤⁺ : (k : A) → [ k ] <⁺ ⊤⁺
------------------------------------------------------------------------
-- Relational properties
[<]-injective : ∀ {k l} → [ k ] <⁺ [ l ] → k < l
[<]-injective [ p ] = p
<⁺-asym : Asymmetric _<_ → Asymmetric _<⁺_
<⁺-asym <-asym [ p ] [ q ] = <-asym p q
<⁺-trans : Transitive _<_ → Transitive _<⁺_
<⁺-trans <-trans [ p ] [ q ] = [ <-trans p q ]
<⁺-trans <-trans [ p ] [ k ]<⊤⁺ = [ _ ]<⊤⁺
<⁺-dec : Decidable _<_ → Decidable _<⁺_
<⁺-dec _<?_ [ k ] [ l ] = Dec.map′ [_] [<]-injective (k <? l)
<⁺-dec _<?_ [ k ] ⊤⁺ = yes [ k ]<⊤⁺
<⁺-dec _<?_ ⊤⁺ [ l ] = no (λ ())
<⁺-dec _<?_ ⊤⁺ ⊤⁺ = no (λ ())
<⁺-irrelevant : Irrelevant _<_ → Irrelevant _<⁺_
<⁺-irrelevant <-irr [ p ] [ q ] = P.cong _ (<-irr p q)
<⁺-irrelevant <-irr [ k ]<⊤⁺ [ k ]<⊤⁺ = P.refl
module _ {r} {_≤_ : Rel A r} where
open NonStrict _≤_
<⁺-transʳ : Trans _≤_ _<_ _<_ → Trans _≤⁺_ _<⁺_ _<⁺_
<⁺-transʳ <-transʳ [ p ] [ q ] = [ <-transʳ p q ]
<⁺-transʳ <-transʳ [ p ] [ k ]<⊤⁺ = [ _ ]<⊤⁺
<⁺-transˡ : Trans _<_ _≤_ _<_ → Trans _<⁺_ _≤⁺_ _<⁺_
<⁺-transˡ <-transˡ [ p ] [ q ] = [ <-transˡ p q ]
<⁺-transˡ <-transˡ [ p ] ([ _ ] ≤⊤⁺) = [ _ ]<⊤⁺
<⁺-transˡ <-transˡ [ k ]<⊤⁺ (⊤⁺ ≤⊤⁺) = [ k ]<⊤⁺
------------------------------------------------------------------------
-- Relational properties + propositional equality
<⁺-cmp-≡ : Trichotomous _≡_ _<_ → Trichotomous _≡_ _<⁺_
<⁺-cmp-≡ <-cmp ⊤⁺ ⊤⁺ = tri≈ (λ ()) refl (λ ())
<⁺-cmp-≡ <-cmp ⊤⁺ [ l ] = tri> (λ ()) (λ ()) [ l ]<⊤⁺
<⁺-cmp-≡ <-cmp [ k ] ⊤⁺ = tri< [ k ]<⊤⁺ (λ ()) (λ ())
<⁺-cmp-≡ <-cmp [ k ] [ l ] with <-cmp k l
... | tri< a ¬b ¬c = tri< [ a ] (¬b ∘ []-injective) (¬c ∘ [<]-injective)
... | tri≈ ¬a refl ¬c = tri≈ (¬a ∘ [<]-injective) refl (¬c ∘ [<]-injective)
... | tri> ¬a ¬b c = tri> (¬a ∘ [<]-injective) (¬b ∘ []-injective) [ c ]
<⁺-irrefl-≡ : Irreflexive _≡_ _<_ → Irreflexive _≡_ _<⁺_
<⁺-irrefl-≡ <-irrefl refl [ x ] = <-irrefl refl x
<⁺-respˡ-≡ : _<⁺_ Respectsˡ _≡_
<⁺-respˡ-≡ = P.subst (_<⁺ _)
<⁺-respʳ-≡ : _<⁺_ Respectsʳ _≡_
<⁺-respʳ-≡ = P.subst (_ <⁺_)
<⁺-resp-≡ : _<⁺_ Respects₂ _≡_
<⁺-resp-≡ = <⁺-respʳ-≡ , <⁺-respˡ-≡
------------------------------------------------------------------------
-- Relational properties + setoid equality
module _ {e} {_≈_ : Rel A e} where
open Equality _≈_
<⁺-cmp : Trichotomous _≈_ _<_ → Trichotomous _≈⁺_ _<⁺_
<⁺-cmp <-cmp ⊤⁺ ⊤⁺ = tri≈ (λ ()) ⊤⁺≈⊤⁺ (λ ())
<⁺-cmp <-cmp ⊤⁺ [ l ] = tri> (λ ()) (λ ()) [ l ]<⊤⁺
<⁺-cmp <-cmp [ k ] ⊤⁺ = tri< [ k ]<⊤⁺ (λ ()) (λ ())
<⁺-cmp <-cmp [ k ] [ l ] with <-cmp k l
... | tri< a ¬b ¬c = tri< [ a ] (¬b ∘ [≈]-injective) (¬c ∘ [<]-injective)
... | tri≈ ¬a b ¬c = tri≈ (¬a ∘ [<]-injective) [ b ] (¬c ∘ [<]-injective)
... | tri> ¬a ¬b c = tri> (¬a ∘ [<]-injective) (¬b ∘ [≈]-injective) [ c ]
<⁺-irrefl : Irreflexive _≈_ _<_ → Irreflexive _≈⁺_ _<⁺_
<⁺-irrefl <-irrefl [ p ] [ q ] = <-irrefl p q
<⁺-respˡ-≈⁺ : _<_ Respectsˡ _≈_ → _<⁺_ Respectsˡ _≈⁺_
<⁺-respˡ-≈⁺ <-respˡ-≈ [ p ] [ q ] = [ <-respˡ-≈ p q ]
<⁺-respˡ-≈⁺ <-respˡ-≈ [ p ] ([ l ]<⊤⁺) = [ _ ]<⊤⁺
<⁺-respˡ-≈⁺ <-respˡ-≈ ⊤⁺≈⊤⁺ q = q
<⁺-respʳ-≈⁺ : _<_ Respectsʳ _≈_ → _<⁺_ Respectsʳ _≈⁺_
<⁺-respʳ-≈⁺ <-respʳ-≈ [ p ] [ q ] = [ <-respʳ-≈ p q ]
<⁺-respʳ-≈⁺ <-respʳ-≈ ⊤⁺≈⊤⁺ q = q
<⁺-resp-≈⁺ : _<_ Respects₂ _≈_ → _<⁺_ Respects₂ _≈⁺_
<⁺-resp-≈⁺ = map <⁺-respʳ-≈⁺ <⁺-respˡ-≈⁺
------------------------------------------------------------------------
-- Structures + propositional equality
<⁺-isStrictPartialOrder-≡ : IsStrictPartialOrder _≡_ _<_ →
IsStrictPartialOrder _≡_ _<⁺_
<⁺-isStrictPartialOrder-≡ strict = record
{ isEquivalence = P.isEquivalence
; irrefl = <⁺-irrefl-≡ irrefl
; trans = <⁺-trans trans
; <-resp-≈ = <⁺-resp-≡
} where open IsStrictPartialOrder strict
<⁺-isDecStrictPartialOrder-≡ : IsDecStrictPartialOrder _≡_ _<_ →
IsDecStrictPartialOrder _≡_ _<⁺_
<⁺-isDecStrictPartialOrder-≡ dectot = record
{ isStrictPartialOrder = <⁺-isStrictPartialOrder-≡ isStrictPartialOrder
; _≟_ = ≡-dec _≟_
; _<?_ = <⁺-dec _<?_
} where open IsDecStrictPartialOrder dectot
<⁺-isStrictTotalOrder-≡ : IsStrictTotalOrder _≡_ _<_ →
IsStrictTotalOrder _≡_ _<⁺_
<⁺-isStrictTotalOrder-≡ strictot = record
{ isEquivalence = P.isEquivalence
; trans = <⁺-trans trans
; compare = <⁺-cmp-≡ compare
} where open IsStrictTotalOrder strictot
------------------------------------------------------------------------
-- Structures + setoid equality
module _ {e} {_≈_ : Rel A e} where
open Equality _≈_
<⁺-isStrictPartialOrder : IsStrictPartialOrder _≈_ _<_ →
IsStrictPartialOrder _≈⁺_ _<⁺_
<⁺-isStrictPartialOrder strict = record
{ isEquivalence = ≈⁺-isEquivalence isEquivalence
; irrefl = <⁺-irrefl irrefl
; trans = <⁺-trans trans
; <-resp-≈ = <⁺-resp-≈⁺ <-resp-≈
} where open IsStrictPartialOrder strict
<⁺-isDecStrictPartialOrder : IsDecStrictPartialOrder _≈_ _<_ →
IsDecStrictPartialOrder _≈⁺_ _<⁺_
<⁺-isDecStrictPartialOrder dectot = record
{ isStrictPartialOrder = <⁺-isStrictPartialOrder isStrictPartialOrder
; _≟_ = ≈⁺-dec _≟_
; _<?_ = <⁺-dec _<?_
} where open IsDecStrictPartialOrder dectot
<⁺-isStrictTotalOrder : IsStrictTotalOrder _≈_ _<_ →
IsStrictTotalOrder _≈⁺_ _<⁺_
<⁺-isStrictTotalOrder strictot = record
{ isEquivalence = ≈⁺-isEquivalence isEquivalence
; trans = <⁺-trans trans
; compare = <⁺-cmp compare
} where open IsStrictTotalOrder strictot
| 36.664894
| 75
| 0.487741
|
d0697094c3788eb2e791d40e7890efd8442ad9e8
| 22
|
agda
|
Agda
|
silly1.agda
|
alhassy/agda
|
6043e77e4a72518711f5f808fb4eb593cbf0bb7c
|
[
"BSD-3-Clause"
] | null | null | null |
silly1.agda
|
alhassy/agda
|
6043e77e4a72518711f5f808fb4eb593cbf0bb7c
|
[
"BSD-3-Clause"
] | null | null | null |
silly1.agda
|
alhassy/agda
|
6043e77e4a72518711f5f808fb4eb593cbf0bb7c
|
[
"BSD-3-Clause"
] | null | null | null |
mmodule silly1 where
| 7.333333
| 20
| 0.818182
|
294ff4ff76ea1f9f01c2339399de59d3177bd729
| 190
|
agda
|
Agda
|
test/Fail/ParseForallAbsurd.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/ParseForallAbsurd.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/ParseForallAbsurd.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2010-09-24
module ParseForallAbsurd where
parseFails : forall () -> Set1
parseFails x = Set
-- this does no longer give the error message
-- "absurd lambda cannot have a body"
| 21.111111
| 45
| 0.731579
|
1a8fed138a280298744ded9cda8f94ad1934a489
| 1,108
|
agda
|
Agda
|
vendor/stdlib/src/Data/Char.agda
|
isabella232/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 56
|
2015-01-20T02:11:42.000Z
|
2021-12-21T17:02:19.000Z
|
vendor/stdlib/src/Data/Char.agda
|
larrytheliquid/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 1
|
2022-03-12T12:17:51.000Z
|
2022-03-12T12:17:51.000Z
|
vendor/stdlib/src/Data/Char.agda
|
isabella232/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 3
|
2015-07-21T16:37:58.000Z
|
2022-03-12T11:54:10.000Z
|
------------------------------------------------------------------------
-- Characters
------------------------------------------------------------------------
module Data.Char where
open import Data.Nat using (ℕ)
open import Data.Bool using (Bool; true; false)
open import Relation.Nullary
open import Relation.Binary
open import Relation.Binary.PropositionalEquality as PropEq using (_≡_)
------------------------------------------------------------------------
-- The type
postulate
Char : Set
{-# BUILTIN CHAR Char #-}
{-# COMPILED_TYPE Char Char #-}
------------------------------------------------------------------------
-- Operations
private
primitive
primCharToNat : Char → ℕ
primCharEquality : Char → Char → Bool
toNat : Char → ℕ
toNat = primCharToNat
infix 4 _==_
_==_ : Char → Char → Bool
_==_ = primCharEquality
_≟_ : Decidable {Char} _≡_
s₁ ≟ s₂ with s₁ == s₂
... | true = yes trustMe
where postulate trustMe : _
... | false = no trustMe
where postulate trustMe : _
setoid : Setoid
setoid = PropEq.setoid Char
decSetoid : DecSetoid
decSetoid = PropEq.decSetoid _≟_
| 22.16
| 72
| 0.518953
|
2e5cdb30e95f4d195ea3988f21e74ad8e29fb9f5
| 1,413
|
agda
|
Agda
|
src/Yasm/Types.agda
|
LaudateCorpus1/bft-consensus-agda
|
a4674fc473f2457fd3fe5123af48253cfb2404ef
|
[
"UPL-1.0"
] | null | null | null |
src/Yasm/Types.agda
|
LaudateCorpus1/bft-consensus-agda
|
a4674fc473f2457fd3fe5123af48253cfb2404ef
|
[
"UPL-1.0"
] | null | null | null |
src/Yasm/Types.agda
|
LaudateCorpus1/bft-consensus-agda
|
a4674fc473f2457fd3fe5123af48253cfb2404ef
|
[
"UPL-1.0"
] | null | null | null |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import Util.Prelude
-- This module defines types used in the specification of a SystemModel.
module Yasm.Types where
-- Actions that can be performed by peers.
--
-- For now, the SystemModel supports only one kind of action: to send a
-- message. Later it might include things like logging, crashes, assertion
-- failures, etc. For example, if an assertion fires, this
-- could "kill the process" and make it not send any messages in the future.
-- We could also then prove that the handlers do not crash, certain
-- messages are logged under certain circumstances, etc.
--
-- Alternatively, certain actions can be kept outside the system model by
-- defining an application-specific PeerState type (see `Yasm.Base`).
-- For example:
--
-- > libraHandle : Msg → Status × Log × LState → Status × LState × List Action
-- > libraHandle _ (Crashed , l , s) = Crashed , s , [] -- i.e., crashed peers never send messages
-- >
-- > handle = filter isSend ∘ libraHandle
data Action (Msg : Set) : Set where
send : (m : Msg) → Action Msg
-- Injectivity of `send`.
action-send-injective : ∀ {Msg}{m m' : Msg} → send m ≡ send m' → m ≡ m'
action-send-injective refl = refl
| 40.371429
| 111
| 0.716207
|
c5196cf0abe5ed14028d89c715014059ac863565
| 5,552
|
agda
|
Agda
|
Cubical/Data/Nat/GCD.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
Cubical/Data/Nat/GCD.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | 1
|
2022-01-27T02:07:48.000Z
|
2022-01-27T02:07:48.000Z
|
Cubical/Data/Nat/GCD.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Data.Nat.GCD where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Induction.WellFounded
open import Cubical.Data.Fin
open import Cubical.Data.Sigma as Σ
open import Cubical.Data.NatPlusOne
open import Cubical.HITs.PropositionalTruncation as PropTrunc
open import Cubical.Data.Nat.Base
open import Cubical.Data.Nat.Properties
open import Cubical.Data.Nat.Order
open import Cubical.Data.Nat.Divisibility
private
variable
m n d : ℕ
-- common divisors
isCD : ℕ → ℕ → ℕ → Type₀
isCD m n d = (d ∣ m) × (d ∣ n)
isPropIsCD : isProp (isCD m n d)
isPropIsCD = isProp× isProp∣ isProp∣
symCD : isCD m n d → isCD n m d
symCD (d∣m , d∣n) = (d∣n , d∣m)
-- greatest common divisors
isGCD : ℕ → ℕ → ℕ → Type₀
isGCD m n d = (isCD m n d) × (∀ d' → isCD m n d' → d' ∣ d)
GCD : ℕ → ℕ → Type₀
GCD m n = Σ ℕ (isGCD m n)
isPropIsGCD : isProp (isGCD m n d)
isPropIsGCD = isProp× isPropIsCD (isPropΠ2 (λ _ _ → isProp∣))
isPropGCD : isProp (GCD m n)
isPropGCD (d , dCD , gr) (d' , d'CD , gr') =
Σ≡Prop (λ _ → isPropIsGCD) (antisym∣ (gr' d dCD) (gr d' d'CD))
symGCD : isGCD m n d → isGCD n m d
symGCD (dCD , gr) = symCD dCD , λ { d' d'CD → gr d' (symCD d'CD) }
divsGCD : m ∣ n → isGCD m n m
divsGCD p = (∣-refl refl , p) , λ { d (d∣m , _) → d∣m }
oneGCD : ∀ m → isGCD m 1 1
oneGCD m = symGCD (divsGCD (∣-oneˡ m))
-- The base case of the Euclidean algorithm
zeroGCD : ∀ m → isGCD m 0 m
zeroGCD m = divsGCD (∣-zeroʳ m)
private
lem₁ : prediv d (suc n) → prediv d (m % suc n) → prediv d m
lem₁ {d} {n} {m} (c₁ , p₁) (c₂ , p₂) = (q · c₁ + c₂) , p
where r = m % suc n; q = n%k≡n[modk] m (suc n) .fst
p = (q · c₁ + c₂) · d ≡⟨ sym (·-distribʳ (q · c₁) c₂ d) ⟩
(q · c₁) · d + c₂ · d ≡⟨ cong (_+ c₂ · d) (sym (·-assoc q c₁ d)) ⟩
q · (c₁ · d) + c₂ · d ≡[ i ]⟨ q · (p₁ i) + (p₂ i) ⟩
q · (suc n) + r ≡⟨ n%k≡n[modk] m (suc n) .snd ⟩
m ∎
lem₂ : prediv d (suc n) → prediv d m → prediv d (m % suc n)
lem₂ {d} {n} {m} (c₁ , p₁) (c₂ , p₂) = c₂ ∸ q · c₁ , p
where r = m % suc n; q = n%k≡n[modk] m (suc n) .fst
p = (c₂ ∸ q · c₁) · d ≡⟨ ∸-distribʳ c₂ (q · c₁) d ⟩
c₂ · d ∸ (q · c₁) · d ≡⟨ cong (c₂ · d ∸_) (sym (·-assoc q c₁ d)) ⟩
c₂ · d ∸ q · (c₁ · d) ≡[ i ]⟨ p₂ i ∸ q · (p₁ i) ⟩
m ∸ q · (suc n) ≡⟨ cong (_∸ q · (suc n)) (sym (n%k≡n[modk] m (suc n) .snd)) ⟩
(q · (suc n) + r) ∸ q · (suc n) ≡⟨ cong (_∸ q · (suc n)) (+-comm (q · (suc n)) r) ⟩
(r + q · (suc n)) ∸ q · (suc n) ≡⟨ ∸-cancelʳ r zero (q · (suc n)) ⟩
r ∎
-- The inductive step of the Euclidean algorithm
stepGCD : isGCD (suc n) (m % suc n) d
→ isGCD m (suc n) d
fst (stepGCD ((d∣n , d∣m%n) , gr)) = PropTrunc.map2 lem₁ d∣n d∣m%n , d∣n
snd (stepGCD ((d∣n , d∣m%n) , gr)) d' (d'∣m , d'∣n) = gr d' (d'∣n , PropTrunc.map2 lem₂ d'∣n d'∣m)
-- putting it all together using well-founded induction
euclid< : ∀ m n → n < m → GCD m n
euclid< = WFI.induction <-wellfounded λ {
m rec zero p → m , zeroGCD m ;
m rec (suc n) p → let d , dGCD = rec (suc n) p (m % suc n) (n%sk<sk m n)
in d , stepGCD dGCD }
euclid : ∀ m n → GCD m n
euclid m n with n ≟ m
... | lt p = euclid< m n p
... | gt p = Σ.map-snd symGCD (euclid< n m p)
... | eq p = m , divsGCD (∣-refl (sym p))
isContrGCD : ∀ m n → isContr (GCD m n)
isContrGCD m n = euclid m n , isPropGCD _
-- the gcd operator on ℕ
gcd : ℕ → ℕ → ℕ
gcd m n = euclid m n .fst
gcdIsGCD : ∀ m n → isGCD m n (gcd m n)
gcdIsGCD m n = euclid m n .snd
isGCD→gcd≡ : isGCD m n d → gcd m n ≡ d
isGCD→gcd≡ dGCD = cong fst (isContrGCD _ _ .snd (_ , dGCD))
gcd≡→isGCD : gcd m n ≡ d → isGCD m n d
gcd≡→isGCD p = subst (isGCD _ _) p (gcdIsGCD _ _)
-- multiplicative properties of the gcd
isCD-cancelʳ : ∀ k → isCD (m · suc k) (n · suc k) (d · suc k)
→ isCD m n d
isCD-cancelʳ k (dk∣mk , dk∣nk) = (∣-cancelʳ k dk∣mk , ∣-cancelʳ k dk∣nk)
isCD-multʳ : ∀ k → isCD m n d
→ isCD (m · k) (n · k) (d · k)
isCD-multʳ k (d∣m , d∣n) = (∣-multʳ k d∣m , ∣-multʳ k d∣n)
isGCD-cancelʳ : ∀ k → isGCD (m · suc k) (n · suc k) (d · suc k)
→ isGCD m n d
isGCD-cancelʳ {m} {n} {d} k (dCD , gr) =
isCD-cancelʳ k dCD , λ d' d'CD → ∣-cancelʳ k (gr (d' · suc k) (isCD-multʳ (suc k) d'CD))
gcd-factorʳ : ∀ m n k → gcd (m · k) (n · k) ≡ gcd m n · k
gcd-factorʳ m n zero = (λ i → gcd (0≡m·0 m (~ i)) (0≡m·0 n (~ i))) ∙ 0≡m·0 (gcd m n)
gcd-factorʳ m n (suc k) = sym p ∙ cong (_· suc k) (sym q)
where k∣gcd : suc k ∣ gcd (m · suc k) (n · suc k)
k∣gcd = gcdIsGCD (m · suc k) (n · suc k) .snd (suc k) (∣-right m , ∣-right n)
d' = ∣-untrunc k∣gcd .fst
p : d' · suc k ≡ gcd (m · suc k) (n · suc k)
p = ∣-untrunc k∣gcd .snd
d'GCD : isGCD m n d'
d'GCD = isGCD-cancelʳ _ (subst (isGCD _ _) (sym p) (gcdIsGCD (m · suc k) (n · suc k)))
q : gcd m n ≡ d'
q = isGCD→gcd≡ d'GCD
-- Q: Can this be proved directly? (i.e. without a transport)
isGCD-multʳ : ∀ k → isGCD m n d
→ isGCD (m · k) (n · k) (d · k)
isGCD-multʳ {m} {n} {d} k dGCD = gcd≡→isGCD (gcd-factorʳ m n k ∙ cong (_· k) r)
where r : gcd m n ≡ d
r = isGCD→gcd≡ dGCD
| 34.271605
| 107
| 0.525216
|
1d3f9c06705a8cdfcd32c04fe78d0186e20c4f79
| 1,608
|
agda
|
Agda
|
TypeTheory/Nat/AnotherMono/Structure.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | 3
|
2020-04-07T17:49:42.000Z
|
2020-04-21T00:03:43.000Z
|
TypeTheory/Nat/AnotherMono/Structure.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | null | null | null |
TypeTheory/Nat/AnotherMono/Structure.agda
|
rei1024/agda-misc
|
37200ea91d34a6603d395d8ac81294068303f577
|
[
"MIT"
] | null | null | null |
module TypeTheory.Nat.AnotherMono.Structure where
open import Level renaming (zero to lzero; suc to lsuc)
open import Data.Empty using (⊥)
open import Data.Product using (Σ; _×_; _,_)
open import Relation.Binary using (Rel)
open import Relation.Binary.PropositionalEquality
open import Relation.Nullary using (¬_)
record Nat : Set₁ where
field
N : Set
zero : N
suc : N → N
ind : (P : N → Set) → P zero → (∀ k → P k → P (suc k)) → ∀ n → P n
ind-zero : ∀ P P-zero P-suc → ind P P-zero P-suc zero ≡ P-zero
ind-suc : ∀ P P-zero P-suc n → ind P P-zero P-suc (suc n) ≡
P-suc n (ind P P-zero P-suc n)
s≢z : ∀ {n} → suc n ≢ zero
0N : N
0N = zero
1N : N
1N = suc zero
z≢s : ∀ {n} → zero ≢ suc n
z≢s = ≢-sym s≢z
rec : {A : Set} → A → (A → A) → N → A
rec {A} z s = ind (λ _ → A) z (λ _ → s)
rec-zero : ∀ {A} (z : A) s → rec z s zero ≡ z
rec-zero z s = ind-zero _ _ _
rec-suc : ∀ {A} (z : A) s n → rec z s (suc n) ≡ s (rec z s n)
rec-suc z s n = ind-suc _ _ _ _
infixl 6 _+_
infixl 7 _*_
infix 4 _≤_ _<_ _≥_ _>_ _≰_
-- Arithematic
-- Addition
_+_ : N → N → N
m + n = rec n suc m
-- Multiplication
_*_ : N → N → N
m * n = rec zero (n +_) m
-- Order
_≤_ : Rel N lzero
m ≤ n = Σ N λ o → o + m ≡ n
_<_ : Rel N lzero
m < n = suc m ≤ n
_≥_ : Rel N lzero
m ≥ n = n ≤ m
_>_ : Rel N lzero
m > n = n < m
_≰_ : Rel N lzero
m ≰ n = ¬ m ≤ n
_≮_ : Rel N lzero
m ≮ n = ¬ m < n
_≱_ : Rel N lzero
m ≱ n = ¬ m ≥ n
_≯_ : Rel N lzero
m ≯ n = ¬ m > n
| 21.157895
| 75
| 0.496891
|
c54303d2e37d17a015ffefac355cce82980c2694
| 5,610
|
agda
|
Agda
|
src/chap0.agda
|
shinji-kono/automaton-in-agda
|
eba0538f088f3d0c0fedb19c47c081954fbc69cb
|
[
"MIT"
] | null | null | null |
src/chap0.agda
|
shinji-kono/automaton-in-agda
|
eba0538f088f3d0c0fedb19c47c081954fbc69cb
|
[
"MIT"
] | null | null | null |
src/chap0.agda
|
shinji-kono/automaton-in-agda
|
eba0538f088f3d0c0fedb19c47c081954fbc69cb
|
[
"MIT"
] | null | null | null |
module chap0 where
open import Data.List
open import Data.Nat hiding (_⊔_)
-- open import Data.Integer hiding (_⊔_ ; _≟_ ; _+_ )
open import Data.Product
A : List ℕ
A = 1 ∷ 2 ∷ []
data Literal : Set where
x : Literal
y : Literal
z : Literal
B : List Literal
B = x ∷ y ∷ z ∷ []
ListProduct : {A B : Set } → List A → List B → List ( A × B )
ListProduct = {!!}
ex05 : List ( ℕ × Literal )
ex05 = ListProduct A B -- (1 , x) ∷ (1 , y) ∷ (1 , z) ∷ (2 , x) ∷ (2 , y) ∷ (2 , z) ∷ []
ex06 : List ( ℕ × Literal × ℕ )
ex06 = ListProduct A (ListProduct B A)
ex07 : Set
ex07 = ℕ × ℕ
data ex08-f : ℕ → ℕ → Set where
ex08f0 : ex08-f 0 1
ex08f1 : ex08-f 1 2
ex08f2 : ex08-f 2 3
ex08f3 : ex08-f 3 4
ex08f4 : ex08-f 4 0
data ex09-g : ℕ → ℕ → ℕ → ℕ → Set where
ex09g0 : ex09-g 0 1 2 3
ex09g1 : ex09-g 1 2 3 0
ex09g2 : ex09-g 2 3 0 1
ex09g3 : ex09-g 3 0 1 2
open import Data.Nat.DivMod
open import Relation.Binary.PropositionalEquality
open import Relation.Binary.Core
open import Data.Nat.Properties
-- _%_ : ℕ → ℕ → ℕ
-- _%_ a b with <-cmp a b
-- _%_ a b | tri< a₁ ¬b ¬c = a
-- _%_ a b | tri≈ ¬a b₁ ¬c = 0
-- _%_ a b | tri> ¬a ¬b c = _%_ (a - b) b
_≡7_ : ℕ → ℕ → Set
n ≡7 m = (n % 7) ≡ (m % 7 )
refl7 : { n : ℕ} → n ≡7 n
refl7 = {!!}
sym7 : { n m : ℕ} → n ≡7 m → m ≡7 n
sym7 = {!!}
trans7 : { n m o : ℕ} → n ≡7 m → m ≡7 o → n ≡7 o
trans7 = {!!}
open import Level renaming ( zero to Zero ; suc to Suc )
record Graph { v v' : Level } : Set (Suc v ⊔ Suc v' ) where
field
vertex : Set v
edge : vertex → vertex → Set v'
open Graph
-- open import Data.Fin hiding ( _≟_ )
open import Data.Empty
open import Relation.Nullary
open import Data.Unit hiding ( _≟_ )
-- data Dec (P : Set) : Set where
-- yes : P → Dec P
-- no : ¬ P → Dec P
--
-- _≟_ : (s t : ℕ ) → Dec ( s ≡ t )
-- ¬ A = A → ⊥
_n≟_ : (s t : ℕ ) → Dec ( s ≡ t )
zero n≟ zero = yes refl
zero n≟ suc t = no (λ ())
suc s n≟ zero = no (λ ())
suc s n≟ suc t with s n≟ t
... | yes refl = yes refl
... | no n = no (λ k → n (tt1 k) ) where
tt1 : suc s ≡ suc t → s ≡ t
tt1 refl = refl
open import Data.Bool hiding ( _≟_ )
conn : List ( ℕ × ℕ ) → ℕ → ℕ → Bool
conn [] _ _ = false
conn ((n1 , m1 ) ∷ t ) n m with n ≟ n1 | m ≟ m1
conn ((n1 , m1) ∷ t) n m | yes refl | yes refl = true
conn ((n1 , m1) ∷ t) n m | _ | _ = conn t n m
list012a : List ( ℕ × ℕ )
list012a = (1 , 2) ∷ (2 , 3) ∷ (3 , 4) ∷ (4 , 5) ∷ (5 , 1) ∷ []
graph012a : Graph {Zero} {Zero}
graph012a = record { vertex = ℕ ; edge = λ s t → (conn list012a s t) ≡ true }
data edge012b : ℕ → ℕ → Set where
e012b-1 : edge012b 1 2
e012b-2 : edge012b 1 3
e012b-3 : edge012b 1 4
e012b-4 : edge012b 2 3
e012b-5 : edge012b 2 4
e012b-6 : edge012b 3 4
edge? : (E : ℕ → ℕ → Set) → ( a b : ℕ ) → Set
edge? E a b = Dec ( E a b )
lemma3 : ( a b : ℕ ) → edge? edge012b a b
lemma3 1 2 = yes e012b-1
lemma3 1 3 = yes e012b-2
lemma3 1 4 = yes e012b-3
lemma3 2 3 = yes e012b-4
lemma3 2 4 = yes e012b-5
lemma3 3 4 = yes e012b-6
lemma3 1 1 = no ( λ () )
lemma3 2 1 = no ( λ () )
lemma3 2 2 = no ( λ () )
lemma3 3 1 = no ( λ () )
lemma3 3 2 = no ( λ () )
lemma3 3 3 = no ( λ () )
lemma3 0 _ = no ( λ () )
lemma3 _ 0 = no ( λ () )
lemma3 _ (suc (suc (suc (suc (suc _))))) = no ( λ () )
lemma3 (suc (suc (suc (suc _)))) _ = no ( λ () )
graph012b : Graph {Zero} {Zero}
graph012b = record { vertex = ℕ ; edge = edge012b }
data connected { V : Set } ( E : V -> V -> Set ) ( x y : V ) : Set where
direct : E x y → connected E x y
indirect : ( z : V ) -> E x z → connected {V} E z y → connected E x y
lemma1 : connected ( edge graph012a ) 1 2
lemma1 = direct refl where
lemma1-2 : connected ( edge graph012a ) 1 3
lemma1-2 = indirect 2 refl (direct refl )
lemma2 : connected ( edge graph012b ) 1 2
lemma2 = direct e012b-1
reachable : { V : Set } ( E : V -> V -> Set ) ( x y : V ) -> Set
reachable {V} E X Y = Dec ( connected {V} E X Y )
dag : { V : Set } ( E : V -> V -> Set ) -> Set
dag {V} E = ∀ (n : V) → ¬ ( connected E n n )
open import Function
lemma4 : ¬ ( dag ( edge graph012a) )
lemma4 neg = neg 1 $ indirect 2 refl $ indirect 3 refl $ indirect 4 refl $ indirect 5 refl $ direct refl
dgree : List ( ℕ × ℕ ) → ℕ → ℕ
dgree [] _ = 0
dgree ((e , e1) ∷ t) e0 with e0 ≟ e | e0 ≟ e1
dgree ((e , e1) ∷ t) e0 | yes _ | _ = 1 + (dgree t e0)
dgree ((e , e1) ∷ t) e0 | _ | yes p = 1 + (dgree t e0)
dgree ((e , e1) ∷ t) e0 | no _ | no _ = dgree t e0
dgree-c : {t : Set} → List ( ℕ × ℕ ) → ℕ → (ℕ → t) → t
dgree-c {t} [] e0 next = next 0
dgree-c {t} ((e , e1) ∷ tail ) e0 next with e0 ≟ e | e0 ≟ e1
... | yes _ | _ = dgree-c tail e0 ( λ n → next (n + 1 ))
... | _ | yes _ = dgree-c tail e0 ( λ n → next (n + 1 ))
... | no _ | no _ = dgree-c tail e0 next
lemma6 = dgree list012a 2
lemma7 = dgree-c list012a 2 ( λ n → n )
even2 : (n : ℕ ) → n % 2 ≡ 0 → (n + 2) % 2 ≡ 0
even2 0 refl = refl
even2 1 ()
even2 (suc (suc n)) eq = trans ([a+n]%n≡a%n n _) eq -- [a+n]%n≡a%n : ∀ a n → (a + suc n) % suc n ≡ a % suc n
sum-of-dgree : ( g : List ( ℕ × ℕ )) → ℕ
sum-of-dgree [] = 0
sum-of-dgree ((e , e1) ∷ t) = 2 + sum-of-dgree t
dgree-even : ( g : List ( ℕ × ℕ )) → sum-of-dgree g % 2 ≡ 0
dgree-even [] = refl
dgree-even ((e , e1) ∷ t) = begin
sum-of-dgree ((e , e1) ∷ t) % 2
≡⟨⟩
(2 + sum-of-dgree t ) % 2
≡⟨ cong ( λ k → k % 2 ) ( +-comm 2 (sum-of-dgree t) ) ⟩
(sum-of-dgree t + 2) % 2
≡⟨ [a+n]%n≡a%n (sum-of-dgree t) _ ⟩
sum-of-dgree t % 2
≡⟨ dgree-even t ⟩
0
∎ where open ≡-Reasoning
| 26.587678
| 108
| 0.516221
|
2efc0c7cc5bc8e9e6c621ef521ab2e5a24bdad7e
| 594
|
agda
|
Agda
|
test/Fail/Issue2985-2.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 2
|
2019-10-29T09:40:30.000Z
|
2020-09-20T00:28:57.000Z
|
test/Fail/Issue2985-2.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Fail/Issue2985-2.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
-- This variant of the code is due to Ulf Norell.
open import Agda.Builtin.Size
data ⊥ : Set where
mutual
data Unit (i : Size) : Set where
c : Unit′ i → Unit i
data Unit₁ (i : Size) : Set where
c₁ : ⊥ → Unit i → Unit₁ i
record Unit′ (i : Size) : Set where
coinductive
field
force : {j : Size< i} → Unit₁ j
open Unit′ public
tail : Unit ∞ → Unit₁ ∞
tail (c x) = force x
u : (∀ {i} → Unit′ i → Unit i) →
∀ {i} → Unit₁ i
u cons = tail (cons λ { .force → u cons })
bad : Unit₁ ∞
bad = u c
refute : Unit₁ ∞ → ⊥
refute (c₁ () _)
loop : ⊥
loop = refute bad
| 16.054054
| 49
| 0.56229
|
1acd579550160c86f06ac660fe1efbaca64afcc7
| 7,679
|
agda
|
Agda
|
LibraBFT/Base/KVMap.agda
|
oracle/bft-consensus-agda
|
49f8b1b70823be805d84ffc3157c3b880edb1e92
|
[
"UPL-1.0"
] | 4
|
2020-12-16T19:43:41.000Z
|
2021-12-18T19:24:05.000Z
|
LibraBFT/Base/KVMap.agda
|
oracle/bft-consensus-agda
|
49f8b1b70823be805d84ffc3157c3b880edb1e92
|
[
"UPL-1.0"
] | 72
|
2021-02-04T05:04:33.000Z
|
2022-03-25T05:36:11.000Z
|
LibraBFT/Base/KVMap.agda
|
oracle/bft-consensus-agda
|
49f8b1b70823be805d84ffc3157c3b880edb1e92
|
[
"UPL-1.0"
] | 6
|
2020-12-16T19:43:52.000Z
|
2022-02-18T01:04:32.000Z
|
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020 Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Prelude
open import LibraBFT.Lemmas
-- This module contains a model of a key-value store, along with its
-- functionality and various properties about it. Most of the properties
-- are not currently used, but they are included here based on our
-- experience in other work, as we think many of them will be needed when
-- reasoning about an actual LibraBFT implementation.
-- Although we believe the assumptions here are reasonable, it is always
-- possible that we made a mistake in postulating one of the properties,
-- making it impossible to implement. Thus, it would a useful contribution
-- to:
--
-- TODO-1: construct an actual implementation and provide and prove the
-- necessary properties to satisfy the requirements of this module
--
-- Note that this would require some work, but should be relatively
-- straightforward and requires only "local" changes.
module LibraBFT.Base.KVMap where
private
variable
Key : Set
Val : Set
k k' : Key
v v' : Val
postulate -- valid assumptions, but would be good to eliminate with a reference implementation (above)
_≟Key_ : ∀ (k1 k2 : Key) → Dec (k1 ≡ k2)
KVMap : Set → Set → Set
_∈KV_ : Key → KVMap Key Val → Set
_∈KV?_ : (k : Key) (kvm : KVMap Key Val) → Dec (k ∈KV kvm)
∈KV-irrelevant : (k : Key) (kvm : KVMap Key Val)
→ (r s : k ∈KV kvm)
→ r ≡ s
-- functionality
empty : KVMap Key Val
∈KV-empty-⊥ : k ∈KV (empty {Val = Val}) → ⊥
lookup : Key → KVMap Key Val → Maybe Val
insert : (k : Key)(v : Val)(kvm : KVMap Key Val)
→ KVMap Key Val
kvm-insert : (k : Key)(v : Val)(kvm : KVMap Key Val)
→ lookup k kvm ≡ nothing
→ KVMap Key Val
elems : KVMap Key Val → List Val
delete : Key → KVMap Key Val → KVMap Key Val
singleton : Key → Val → KVMap Key Val
fromList : List (Key × Val) → KVMap Key Val
toList : KVMap Key Val → List (Key × Val)
-- TODO-3: update properties to reflect kvm-update, consider combining insert/update
kvm-update : (k : Key)(v : Val)(kvm : KVMap Key Val)
→ lookup k kvm ≢ nothing
→ KVMap Key Val
kvm-insert-Haskell
: (k : Key)(v : Val)(kvm : KVMap Key Val)
→ KVMap Key Val
kvm-member : (k : Key) (kvm : KVMap Key Val)
→ Bool
kvm-size : KVMap Key Val → ℕ
-- TODO-1: add properties relating kvm-toList to empty, kvm-insert and kvm-update
kvm-keys : KVMap Key Val → List Key
kvm-toList : KVMap Key Val → List (Key × Val)
kvm-toList-length : (kvm : KVMap Key Val)
→ length (kvm-toList kvm) ≡ kvm-size kvm
kvm-keys-All≢ : ∀ (kvm : KVMap Key Val) → allDistinct (List-map proj₁ (kvm-toList kvm))
kvm-toList-lookup : ∀ (kvm : KVMap Key Val)
→ let kvmL = kvm-toList kvm
key = proj₁ ∘ List-lookup kvmL
value = proj₂ ∘ List-lookup kvmL
in ∀ {α} → lookup (key α) kvm ≡ just (value α)
-- TODO-1: need properties showing that the resulting map contains (k , v) for
-- each pair in the list, provided there is no pair (k , v') in the list
-- after (k , v). This is consistent with Haskell's Data.Map.fromList
kvm-fromList : List (Key × Val) → KVMap Key Val
-- properties
lookup-correct : {kvm : KVMap Key Val}
→ (prf : lookup k kvm ≡ nothing)
→ lookup k (kvm-insert k v kvm prf) ≡ just v
-- Haskell's insert updates the value even if the key is already in the map
lookup-correct-haskell
: {kvm : KVMap Key Val}
→ lookup k (kvm-insert-Haskell k v kvm) ≡ just v
lookup-correct-update
: {kvm : KVMap Key Val}
→ (prf : lookup k kvm ≢ nothing)
→ lookup k (kvm-update k v kvm prf) ≡ just v
lookup-stable : {kvm : KVMap Key Val}{k k' : Key}{v' : Val}
→ (prf : lookup k kvm ≡ nothing)
→ lookup k' kvm ≡ just v
→ lookup k' (kvm-insert k v' kvm prf) ≡ just v
insert-target : {kvm : KVMap Key Val}
→ (prf : lookup k kvm ≡ nothing)
→ lookup k' kvm ≢ just v
→ lookup k' (kvm-insert k v' kvm prf) ≡ just v
→ k' ≡ k × v ≡ v'
insert-target-≢ : {kvm : KVMap Key Val}{k k' : Key}
→ (prf : lookup k kvm ≡ nothing)
→ k' ≢ k
→ lookup k' kvm ≡ lookup k' (kvm-insert k v kvm prf)
update-target-≢ : {kvm : KVMap Key Val}
→ ∀ {k1 k2 x}
→ k2 ≢ k1
→ lookup k1 kvm ≡ lookup k1 (kvm-update k2 v kvm x)
kvm-empty : lookup {Val = Val} k empty ≡ nothing
kvm-empty-⊥ : {k : Key} {v : Val} → lookup k empty ≡ just v → ⊥
KVM-extensionality : ∀ {kvm1 kvm2 : KVMap Key Val}
→ (∀ (x : Key) → lookup x kvm1 ≡ lookup x kvm2)
→ kvm1 ≡ kvm2
-- Corollaries
lookup-stable-1 : {kvm : KVMap Key Val}{k k' : Key}{v' : Val}
→ (prf : lookup k kvm ≡ nothing)
→ lookup k' kvm ≡ just v'
→ lookup k' (kvm-insert k v kvm prf) ≡ lookup k' kvm
lookup-stable-1 prf hyp = trans (lookup-stable prf hyp) (sym hyp)
lookup-correct-update-2
: {kvm : KVMap Key Val}
→ (prf : lookup k kvm ≢ nothing)
→ lookup k (kvm-update k v kvm prf) ≡ just v'
→ v ≡ v'
lookup-correct-update-2 {kvm} prf lkup =
just-injective
(trans (sym (lookup-correct-update prf)) lkup)
update-target : {kvm : KVMap Key Val}
→ ∀ {k1 k2 x}
→ lookup k1 kvm ≢ lookup k1 (kvm-update k2 v kvm x)
→ k2 ≡ k1
update-target {kvm = kvm}{k1 = k1}{k2 = k2}{x} vneq
with k1 ≟Key k2
...| yes refl = refl
...| no neq = ⊥-elim (vneq (update-target-≢ {k1 = k1} {k2 = k2} (neq ∘ sym)))
lookup-correct-update-3 : ∀ {kvm : KVMap Key Val}{k1 k2 v2}
→ (prf : lookup k2 kvm ≢ nothing)
→ lookup k2 kvm ≡ just v2
→ lookup k1 (kvm-update k2 v2 kvm prf) ≡ lookup k1 kvm
lookup-correct-update-3 {kvm = kvm} {k1 = k1} {k2 = k2} {v2 = v2} prf with k1 ≟Key k2
...| yes refl = λ pr → trans (lookup-correct-update {v = v2} prf) (sym pr)
...| no neq = λ pr → sym (update-target-≢ {k1 = k1} {k2 = k2} {prf} λ k2≢k1 → ⊥-elim (neq (sym k2≢k1)))
lookup-correct-update-4
: ∀ {orig : KVMap Key Val}{k1}{v1}
{rdy : lookup k1 orig ≢ nothing}
→ lookup k1 orig ≡ just v1
→ kvm-update k1 v1 orig rdy ≡ orig
lookup-correct-update-4 {orig = orig} {k1 = k1} {v1 = v1} {rdy = rdy} hyp =
KVM-extensionality {kvm1 = kvm-update k1 v1 orig rdy} {kvm2 = orig}
λ x → lookup-correct-update-3 rdy hyp
insert-target-0 : {kvm : KVMap Key Val}
→ (prf : lookup k kvm ≡ nothing)
→ lookup k' kvm ≢ lookup k' (kvm-insert k v kvm prf)
→ k ≡ k'
insert-target-0 {k = k} {k' = k'} prf lookups≢
with k' ≟Key k
...| yes refl = refl
...| no neq = ⊥-elim (lookups≢ (insert-target-≢ prf neq))
| 39.994792
| 111
| 0.541086
|
134173843db3e47e142372e1bf1149abcfdf9fec
| 90
|
agda
|
Agda
|
tests/ModusPonens-solution.agda
|
danr/agder
|
ece25bed081a24f02e9f85056d05933eae2afabf
|
[
"BSD-3-Clause"
] | 1
|
2021-05-17T12:07:03.000Z
|
2021-05-17T12:07:03.000Z
|
tests/ModusPonens-solution.agda
|
danr/agder
|
ece25bed081a24f02e9f85056d05933eae2afabf
|
[
"BSD-3-Clause"
] | null | null | null |
tests/ModusPonens-solution.agda
|
danr/agder
|
ece25bed081a24f02e9f85056d05933eae2afabf
|
[
"BSD-3-Clause"
] | null | null | null |
module ModusPonens where
modusPonens : ∀ {P Q : Set} → (P → Q) → P → Q
modusPonens x = x
| 18
| 45
| 0.611111
|
590b444ab136537b99e796ba9ba7a8d09dc68266
| 5,283
|
agda
|
Agda
|
Categories/Functor/Properties.agda
|
rei1024/agda-categories
|
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
|
[
"MIT"
] | null | null | null |
Categories/Functor/Properties.agda
|
rei1024/agda-categories
|
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
|
[
"MIT"
] | null | null | null |
Categories/Functor/Properties.agda
|
rei1024/agda-categories
|
89d163f72caa7deeac9413f27bc1b4ed7f9e025b
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
module Categories.Functor.Properties where
-- Properties valid of all Functors
open import Level
open import Data.Product using (proj₁; proj₂; _,_)
open import Function.Surjection using (Surjective)
open import Function.Equivalence using (Equivalence)
open import Function.Equality hiding (_∘_)
open import Categories.Category
open import Categories.Functor.Core
open import Categories.Functor
open import Categories.Morphism as Morphism
import Categories.Morphism.Reasoning as Reas
open import Categories.Morphism.IsoEquiv as IsoEquiv
open import Categories.Morphism.Isomorphism
open import Relation.Binary using (_Preserves_⟶_)
private
variable
o ℓ e : Level
C D : Category o ℓ e
-- a series of [ Functor ]-respects-Thing combinators (with respects -> resp)
module _ (F : Functor C D) where
private
module C = Category C
module D = Category D
module IsoC = IsoEquiv C
module IsoD = IsoEquiv D
open C hiding (_∘_)
open Functor F
private
variable
A B E : Obj
f g h i : A ⇒ B
[_]-resp-∘ : C [ C [ f ∘ g ] ≈ h ] → D [ D [ F₁ f ∘ F₁ g ] ≈ F₁ h ]
[_]-resp-∘ {f = f} {g = g} {h = h} eq = begin
F₁ f ∘ F₁ g ≈˘⟨ homomorphism ⟩
F₁ (C [ f ∘ g ]) ≈⟨ F-resp-≈ eq ⟩
F₁ h ∎
where open D
open D.HomReasoning
[_]-resp-square : C.CommutativeSquare f g h i →
D.CommutativeSquare (F₁ f) (F₁ g) (F₁ h) (F₁ i)
[_]-resp-square {f = f} {g = g} {h = h} {i = i} sq = begin
F₁ h ∘ F₁ f ≈˘⟨ homomorphism ⟩
F₁ (C [ h ∘ f ]) ≈⟨ F-resp-≈ sq ⟩
F₁ (C [ i ∘ g ]) ≈⟨ homomorphism ⟩
F₁ i ∘ F₁ g ∎
where open D
open D.HomReasoning
[_]-resp-Iso : Iso C f g → Iso D (F₁ f) (F₁ g)
[_]-resp-Iso {f = f} {g = g} iso = record
{ isoˡ = begin
F₁ g ∘ F₁ f ≈⟨ [ isoˡ ]-resp-∘ ⟩
F₁ C.id ≈⟨ identity ⟩
D.id ∎
; isoʳ = begin
F₁ f ∘ F₁ g ≈⟨ [ isoʳ ]-resp-∘ ⟩
F₁ C.id ≈⟨ identity ⟩
D.id ∎
}
where open Iso iso
open D
open D.HomReasoning
[_]-resp-≅ : F₀ Preserves _≅_ C ⟶ _≅_ D
[_]-resp-≅ i≅j = record
{ from = F₁ from
; to = F₁ to
; iso = [ iso ]-resp-Iso
}
where open _≅_ i≅j
[_]-resp-≃ : ∀ {f g : _≅_ C A B} → f IsoC.≃ g → [ f ]-resp-≅ IsoD.≃ [ g ]-resp-≅
[_]-resp-≃ ⌞ eq ⌟ = ⌞ F-resp-≈ eq ⌟
homomorphismᵢ : ∀ {f : _≅_ C B E} {g : _≅_ C A B} → [ _∘ᵢ_ C f g ]-resp-≅ IsoD.≃ (_∘ᵢ_ D [ f ]-resp-≅ [ g ]-resp-≅ )
homomorphismᵢ = ⌞ homomorphism ⌟
-- Uses a strong version of Essential Surjectivity.
EssSurj×Full×Faithful⇒Invertible : EssentiallySurjective F → Full F → Faithful F → Functor D C
EssSurj×Full×Faithful⇒Invertible surj full faith = record
{ F₀ = λ d → proj₁ (surj d)
; F₁ = λ {A} {B} f →
let (a , sa) = surj A in
let (b , sb) = surj B in
let module S = Surjective (full {a} {b}) in
S.from ⟨$⟩ (_≅_.to sb) ∘ f ∘ (_≅_.from sa)
; identity = λ {A} →
let (a , sa) = surj A in begin
from full ⟨$⟩ _≅_.to sa ∘ D.id ∘ _≅_.from sa ≈⟨ cong (from full) (D.∘-resp-≈ʳ D.identityˡ D.HomReasoning.○ _≅_.isoˡ sa) ⟩
from full ⟨$⟩ D.id ≈˘⟨ cong (from full) identity ⟩
from full ⟨$⟩ F₁ C.id ≈⟨ faith _ _ (right-inverse-of full (F₁ C.id)) ⟩
C.id ∎
; homomorphism = λ {X} {Y} {Z} {f} {g} →
let (x , sx) = surj X in
let (y , sy) = surj Y in
let (z , sz) = surj Z in
let open Morphism._≅_ in faith _ _ (E.begin
F₁ (from full ⟨$⟩ to sz ∘ (g ∘ f) ∘ from sx) E.≈⟨ right-inverse-of full _ ⟩
(to sz ∘ (g ∘ f) ∘ from sx) E.≈⟨ D.∘-resp-≈ʳ (D.∘-resp-≈ˡ (D.∘-resp-≈ʳ (introˡ (isoʳ sy)))) ⟩
(to sz ∘ (g ∘ (from sy ∘ to sy) ∘ f) ∘ from sx) E.≈˘⟨ D.assoc ⟩
(to sz ∘ g ∘ ((from sy ∘ to sy) ∘ f)) ∘ from sx E.≈⟨ D.∘-resp-≈ˡ (D.∘-resp-≈ʳ (D.∘-resp-≈ʳ D.assoc)) ⟩
(to sz ∘ g ∘ (from sy ∘ (to sy ∘ f))) ∘ from sx E.≈˘⟨ D.∘-resp-≈ˡ D.assoc ⟩
((to sz ∘ g) ∘ (from sy ∘ (to sy ∘ f))) ∘ from sx E.≈˘⟨ D.∘-resp-≈ˡ D.assoc ⟩
(((to sz ∘ g) ∘ from sy) ∘ (to sy ∘ f)) ∘ from sx E.≈⟨ D.assoc ⟩
((to sz ∘ g) ∘ from sy) ∘ ((to sy ∘ f) ∘ from sx) E.≈⟨ D.∘-resp-≈ D.assoc D.assoc ⟩
(to sz ∘ g ∘ from sy) ∘ (to sy ∘ f ∘ from sx) E.≈˘⟨ D.∘-resp-≈ (right-inverse-of full _) (right-inverse-of full _) ⟩
F₁ (from full ⟨$⟩ to sz ∘ g ∘ from sy) ∘ F₁ (from full ⟨$⟩ to sy ∘ f ∘ from sx) E.≈˘⟨ homomorphism ⟩
F₁ ((from full ⟨$⟩ to sz ∘ g ∘ from sy) C.∘ (from full ⟨$⟩ to sy ∘ f ∘ from sx)) E.∎)
; F-resp-≈ = λ f≈g → cong (from full) (D.∘-resp-≈ʳ (D.∘-resp-≈ˡ f≈g))
}
where
open Morphism D
open Reas D
open Category D
open Surjective
open C.HomReasoning
module E = D.HomReasoning
-- Functor Composition is Associative and the unit laws are found in
-- NaturalTransformation.NaturalIsomorphism, reified as associator, unitorˡ and unitorʳ.
| 40.022727
| 155
| 0.504259
|
208559bf1a06527e041f035161d9fc69385358c9
| 3,000
|
agda
|
Agda
|
day-2/Day2.agda
|
Zalastax/adventofcode2017
|
37956e581dc51bf78008d7dd902bb18d2ee481f6
|
[
"MIT"
] | null | null | null |
day-2/Day2.agda
|
Zalastax/adventofcode2017
|
37956e581dc51bf78008d7dd902bb18d2ee481f6
|
[
"MIT"
] | null | null | null |
day-2/Day2.agda
|
Zalastax/adventofcode2017
|
37956e581dc51bf78008d7dd902bb18d2ee481f6
|
[
"MIT"
] | null | null | null |
module Day2 where
open import Data.String as String
open import Data.Maybe
open import Foreign.Haskell using (Unit)
open import Data.List as List hiding (fromMaybe)
open import Data.Nat
open import Data.Nat.DivMod
import Data.Nat.Show as ℕs
open import Data.Char
open import Data.Vec as Vec renaming (_>>=_ to _VV=_ ; toList to VecToList)
open import Data.Product
open import Relation.Nullary
open import Data.Nat.Properties
open import Data.Bool.Base
open import AocIO
open import AocUtil
open import AocVec
import Data.Fin as Fin
natDiff : ℕ → ℕ → ℕ
natDiff zero y = y
natDiff x zero = x
natDiff (suc x) (suc y) = natDiff x y
fromMaybe : ∀ {a} {A : Set a} → A → Maybe A → A
fromMaybe v (just x) = x
fromMaybe v nothing = v
find : ∀ {a} {A : Set a} → (A → Bool) → List A → Maybe A
find pred [] = nothing
find pred (x ∷ ls) with (pred x)
... | false = find pred ls
... | true = just x
dividesEvenly : ℕ → ℕ → Bool
dividesEvenly zero zero = true
dividesEvenly zero dividend = false
dividesEvenly (suc divisor) dividend with (dividend mod (suc divisor))
... | Fin.Fin.zero = true
... | Fin.Fin.suc p = false
oneDividesTheOther : ℕ → ℕ → Bool
oneDividesTheOther x y = dividesEvenly x y ∨ dividesEvenly y x
main2 : IO Unit
main2 = mainBuilder (readFileMain processFile)
where
parseLine : List Char → List ℕ
parseLine ls with (words ls)
... | line-words = List.map unsafeParseNat line-words
minMax : {n : ℕ} → Vec ℕ (suc n) → (ℕ × ℕ)
minMax {0} (x ∷ []) = x , x
minMax {suc _} (x ∷ ls) with (minMax ls)
... | min , max = (min ⊓ x) , (max ⊔ x)
minMaxDiff : List ℕ → ℕ
minMaxDiff ls = helper (Vec.fromList ls)
where
helper : {n : ℕ} → Vec ℕ n → ℕ
helper [] = 0
helper (x ∷ vec) with (minMax (x ∷ vec))
... | min , max = natDiff min max
lineDiff : List Char → ℕ
lineDiff s = minMaxDiff (parseLine s)
processFile : String → IO Unit
processFile file-content with (lines (String.toList file-content))
... | file-lines with (List.map lineDiff file-lines)
... | line-diffs = printString (ℕs.show (List.sum line-diffs))
main : IO Unit
main = mainBuilder (readFileMain processFile)
where
parseLine : List Char → List ℕ
parseLine ls with (words ls)
... | line-words = List.map unsafeParseNat line-words
pierreDiv : ℕ → ℕ → ℕ
pierreDiv x y with (x ⊓ y) | (x ⊔ y)
... | 0 | _ = 0
... | _ | 0 = 0
... | (suc min) | (suc max) = (suc max) div (suc min)
lineDivider : List ℕ → Maybe ℕ
lineDivider [] = nothing
lineDivider (x ∷ ln) with (find (oneDividesTheOther x) ln)
... | nothing = lineDivider ln
... | just y = just (pierreDiv x y)
lineScore : List Char → ℕ
lineScore s = fromMaybe 0 (lineDivider (parseLine s))
processFile : String → IO Unit
processFile file-content with (lines (String.toList file-content))
... | file-lines with (List.map lineScore file-lines)
... | line-scores = printString (ℕs.show (List.sum line-scores))
| 31.914894
| 75
| 0.642667
|
fbb818299e981749aaaf394300a7e19a216d6686
| 3,288
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Data/Maybe/Relation/Binary/Pointwise.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
test/asset/agda-stdlib-1.0/Data/Maybe/Relation/Binary/Pointwise.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Maybe/Relation/Binary/Pointwise.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Pointwise lifting of relations to maybes
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Maybe.Relation.Binary.Pointwise where
open import Level
open import Data.Maybe.Base using (Maybe; just; nothing)
open import Function.Equivalence using (_⇔_; equivalence)
open import Relation.Binary
open import Relation.Binary.PropositionalEquality as P using (_≡_)
open import Relation.Nullary
import Relation.Nullary.Decidable as Dec
------------------------------------------------------------------------
-- Definition
data Pointwise
{a b ℓ} {A : Set a} {B : Set b}
(R : REL A B ℓ) : REL (Maybe A) (Maybe B) (a ⊔ b ⊔ ℓ) where
just : ∀ {x y} → R x y → Pointwise R (just x) (just y)
nothing : Pointwise R nothing nothing
------------------------------------------------------------------------
-- Properties
module _ {a b ℓ} {A : Set a} {B : Set b} {R : REL A B ℓ} where
drop-just : ∀ {x y} → Pointwise R (just x) (just y) → R x y
drop-just (just p) = p
just-equivalence : ∀ {x y} → R x y ⇔ Pointwise R (just x) (just y)
just-equivalence = equivalence just drop-just
------------------------------------------------------------------------
-- Relational properties
module _ {a r} {A : Set a} {R : Rel A r} where
refl : Reflexive R → Reflexive (Pointwise R)
refl R-refl {just _} = just R-refl
refl R-refl {nothing} = nothing
reflexive : _≡_ ⇒ R → _≡_ ⇒ Pointwise R
reflexive reflexive P.refl = refl (reflexive P.refl)
module _ {a b r₁ r₂} {A : Set a} {B : Set b}
{R : REL A B r₁} {S : REL B A r₂} where
sym : Sym R S → Sym (Pointwise R) (Pointwise S)
sym R-sym (just p) = just (R-sym p)
sym R-sym nothing = nothing
module _ {a b c r₁ r₂ r₃} {A : Set a} {B : Set b} {C : Set c}
{R : REL A B r₁} {S : REL B C r₂} {T : REL A C r₃} where
trans : Trans R S T → Trans (Pointwise R) (Pointwise S) (Pointwise T)
trans R-trans (just p) (just q) = just (R-trans p q)
trans R-trans nothing nothing = nothing
module _ {a r} {A : Set a} {R : Rel A r} where
dec : Decidable R → Decidable (Pointwise R)
dec R-dec (just x) (just y) = Dec.map just-equivalence (R-dec x y)
dec R-dec (just x) nothing = no (λ ())
dec R-dec nothing (just y) = no (λ ())
dec R-dec nothing nothing = yes nothing
isEquivalence : IsEquivalence R → IsEquivalence (Pointwise R)
isEquivalence R-isEquivalence = record
{ refl = refl R.refl
; sym = sym R.sym
; trans = trans R.trans
} where module R = IsEquivalence R-isEquivalence
isDecEquivalence : IsDecEquivalence R → IsDecEquivalence (Pointwise R)
isDecEquivalence R-isDecEquivalence = record
{ isEquivalence = isEquivalence R.isEquivalence
; _≟_ = dec R._≟_
} where module R = IsDecEquivalence R-isDecEquivalence
module _ {c ℓ} where
setoid : Setoid c ℓ → Setoid c (c ⊔ ℓ)
setoid S = record
{ isEquivalence = isEquivalence S.isEquivalence
} where module S = Setoid S
decSetoid : DecSetoid c ℓ → DecSetoid c (c ⊔ ℓ)
decSetoid S = record
{ isDecEquivalence = isDecEquivalence S.isDecEquivalence
} where module S = DecSetoid S
| 33.896907
| 72
| 0.575426
|
2e18f0558e6adf9228e365a51e0ca5c431227eb7
| 1,755
|
agda
|
Agda
|
test/Succeed/Issue1099.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Succeed/Issue1099.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/Issue1099.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
-- Andreas, 2014-04-11, issue reported by James Chapman
-- {-# OPTIONS -v tc.decl.ax:100 #-}
-- {-# OPTIONS -v tc.polarity:100 #-}
{-# OPTIONS --copatterns --sized-types #-}
module _ where
open import Common.Size
module Works where
mutual
data Delay i (A : Set) : Set where
now : A → Delay i A
later : ∞Delay i A → Delay i A
record ∞Delay i A : Set where
coinductive
field force : {j : Size< i} → Delay j A
open ∞Delay
mutual
_=<<_ : ∀{i A B} → Delay i A → (A → Delay i B) → Delay i B
now x =<< f = f x
later x =<< f = later (x ∞=<< f)
_∞=<<_ : ∀{i A B} → ∞Delay i A → (A → Delay i B) → ∞Delay i B
force (c ∞=<< f) = force c =<< f
-- Polarity of Issue1099.Delay from positivity: [Contravariant,Covariant]
-- Refining polarity with type Size → Set → Set
-- Polarity of Issue1099.Delay: [Contravariant,Covariant]
module Fails where
mutual
data Delay i A : Set where
now : A → Delay i A
later : ∞Delay i A → Delay i A
record ∞Delay i A : Set where
coinductive
field force : {j : Size< i} → Delay j A
open ∞Delay
mutual
_=<<_ : ∀{i A B} → Delay i A → (A → Delay i B) → Delay i B
now x =<< f = f x
later x =<< f = later (x ∞=<< f)
_∞=<<_ : ∀{i A B} → ∞Delay i A → (A → Delay i B) → ∞Delay i B
force (c ∞=<< f) = force c =<< f
-- Polarity of Issue1099.Delay from positivity: [Contravariant,Covariant]
-- Refining polarity with type (i₁ : Size) → Set → Set
-- WAS: Polarity of Issue1099.Delay: [Invariant,Covariant]
-- NOW: Polarity of Issue1099.Delay: [Contravariant,Covariant]
-- Polarity refinement calls free variable analysis, which is not in the
-- monad. Thus, need to instantiate metas before polarity refinement.
| 29.745763
| 73
| 0.596581
|
0bd3a764ecd5dfdaf5d268cf5cdaa6bffbbb5b3f
| 1,058
|
agda
|
Agda
|
src/Categories/Functor/Fibration.agda
|
jaykru/agda-categories
|
a4053cf700bcefdf73b857c3352f1eae29382a60
|
[
"MIT"
] | 279
|
2019-06-01T14:36:40.000Z
|
2022-03-22T00:40:14.000Z
|
src/Categories/Functor/Fibration.agda
|
jaykru/agda-categories
|
a4053cf700bcefdf73b857c3352f1eae29382a60
|
[
"MIT"
] | 236
|
2019-06-01T14:53:54.000Z
|
2022-03-28T14:31:43.000Z
|
src/Categories/Functor/Fibration.agda
|
jaykru/agda-categories
|
a4053cf700bcefdf73b857c3352f1eae29382a60
|
[
"MIT"
] | 64
|
2019-06-02T16:58:15.000Z
|
2022-03-14T02:00:59.000Z
|
{-# OPTIONS --without-K --safe #-}
open import Categories.Category
open import Categories.Functor
-- Cartesian fibration, also known as Grothendieck Fibration, see
-- https://ncatlab.org/nlab/show/Grothendieck+fibration
module Categories.Functor.Fibration {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (F : Functor C D) where
open import Level
open import Categories.Morphism D using (_≅_)
open import Categories.Morphism.Cartesian using (Cartesian)
private
module C = Category C
module D = Category D
open Functor F
record Fibration : Set (levelOfTerm F) where
field
universal₀ : ∀ {A B} (f : A D.⇒ F₀ B) → C.Obj
universal₁ : ∀ {A B} (f : A D.⇒ F₀ B) → universal₀ f C.⇒ B
iso : ∀ {A B} (f : A D.⇒ F₀ B) → F₀ (universal₀ f) ≅ A
module iso {A B} (f : A D.⇒ F₀ B) = _≅_ (iso f)
field
commute : ∀ {A B} (f : A D.⇒ F₀ B) → f D.∘ iso.from f D.≈ F₁ (universal₁ f)
cartesian : ∀ {A B} (f : A D.⇒ F₀ B) → Cartesian F (universal₁ f)
module cartesian {A B} (f : A D.⇒ F₀ B) = Cartesian (cartesian f)
| 32.060606
| 121
| 0.62949
|
2f663c603417176a20ab8209b8f47913fbe88baf
| 2,139
|
agda
|
Agda
|
Definition/Typed/Consequences/Canonicity.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
Definition/Typed/Consequences/Canonicity.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
Definition/Typed/Consequences/Canonicity.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
module Definition.Typed.Consequences.Canonicity where
open import Definition.Untyped
open import Definition.Typed
open import Definition.Typed.Weakening
open import Definition.Typed.Properties
open import Definition.Typed.EqRelInstance
open import Definition.LogicalRelation
open import Definition.LogicalRelation.Irrelevance
open import Definition.LogicalRelation.ShapeView
open import Definition.LogicalRelation.Fundamental.Reducibility
open import Definition.Typed.Consequences.Inversion
open import Definition.Typed.Consequences.Inequality
open import Tools.Empty
open import Tools.Nat
open import Tools.Product
-- Turns a natural number into its term representation
sucᵏ : Nat → Term
sucᵏ 0 = zero
sucᵏ (1+ n) = suc (sucᵏ n)
-- Helper function for canonicity for reducible natural properties
canonicity″ : ∀ {t}
→ Natural-prop ε t
→ ∃ λ k → ε ⊢ t ≡ sucᵏ k ∷ ℕ
canonicity″ (sucᵣ (ℕₜ n₁ d n≡n prop)) =
let a , b = canonicity″ prop
in 1+ a , suc-cong (trans (subset*Term (redₜ d)) b)
canonicity″ zeroᵣ = 0 , refl (zeroⱼ ε)
canonicity″ (ne (neNfₜ neK ⊢k k≡k)) = ⊥-elim (noNe ⊢k neK)
-- Helper function for canonicity for specific reducible natural numbers
canonicity′ : ∀ {t l}
→ ([ℕ] : ε ⊩⟨ l ⟩ℕ ℕ)
→ ε ⊩⟨ l ⟩ t ∷ ℕ / ℕ-intr [ℕ]
→ ∃ λ k → ε ⊢ t ≡ sucᵏ k ∷ ℕ
canonicity′ (noemb [ℕ]) (ℕₜ n d n≡n prop) =
let a , b = canonicity″ prop
in a , trans (subset*Term (redₜ d)) b
canonicity′ (emb 0<1 [ℕ]) [t] = canonicity′ [ℕ] [t]
-- Canonicity of natural numbers
canonicity : ∀ {t} → ε ⊢ t ∷ ℕ → ∃ λ k → ε ⊢ t ≡ sucᵏ k ∷ ℕ
canonicity ⊢t with reducibleTerm ⊢t
canonicity ⊢t | [ℕ] , [t] =
canonicity′ (ℕ-elim [ℕ]) (irrelevanceTerm [ℕ] (ℕ-intr (ℕ-elim [ℕ])) [t])
-- Canonicity for Empty
¬Empty′ : ∀ {n} → ε ⊩Empty n ∷Empty → ⊥
¬Empty′ (Emptyₜ n _ n≡n (ne (neNfₜ neN ⊢n _))) =
noNe ⊢n neN
¬Empty : ∀ {n} → ε ⊢ n ∷ Empty → ⊥
¬Empty {n} ⊢n =
let [Empty] , [n] = reducibleTerm ⊢n
[Empty]′ = Emptyᵣ {l = ¹} ([ Emptyⱼ ε , Emptyⱼ ε , id (Emptyⱼ ε) ])
[n]′ = irrelevanceTerm [Empty] [Empty]′ [n]
in ¬Empty′ [n]′
| 31.925373
| 74
| 0.647031
|
18c9fe0ec542765f393e1206215ad5e1d421bc29
| 625
|
agda
|
Agda
|
test/succeed/InferRecordTypes.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
test/succeed/InferRecordTypes.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/succeed/InferRecordTypes.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
-- We can infer the type of a record by comparing the given
-- fields against the fields of the currently known records.
module InferRecordTypes where
data Nat : Set where
zero : Nat
suc : Nat → Nat
record _×_ (A B : Set) : Set where
field
fst : A
snd : B
pair = record { fst = zero; snd = zero }
record R₁ : Set where
field
x₁ : Nat
r₁ = record { x₁ = zero }
data T {A : Set} : A → Set where
mkT : ∀ n → T n
record R₂ A : Set where
field
{x₁} : A
x₂ : T x₁
r₂ = record { x₂ = mkT (suc zero) }
record R₃ : Set where
field
x₁ x₃ : Nat
r₃ = record { x₁ = zero; x₃ = suc zero }
| 17.361111
| 60
| 0.5984
|
571caa7161650a986a3963a4c173ee3c389d5112
| 1,440
|
agda
|
Agda
|
agda-stdlib/src/Function/Related/TypeIsomorphisms/Solver.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Function/Related/TypeIsomorphisms/Solver.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Function/Related/TypeIsomorphisms/Solver.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Automatic solver for equations over product and sum types
--
-- See examples at the bottom of the file for how to use this solver
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Function.Related.TypeIsomorphisms.Solver where
open import Algebra using (CommutativeSemiring)
import Algebra.Solver.Ring.NaturalCoefficients.Default
open import Data.Empty using (⊥)
open import Data.Product using (_×_)
open import Data.Sum.Base using (_⊎_)
open import Data.Unit using (⊤)
open import Level using (Level; Lift)
open import Function.Inverse as Inv using (_↔_)
open import Function.Related as Related
open import Function.Related.TypeIsomorphisms
------------------------------------------------------------------------
-- The solver
module ×-⊎-Solver (k : Symmetric-kind) {ℓ} =
Algebra.Solver.Ring.NaturalCoefficients.Default
(×-⊎-commutativeSemiring k ℓ)
------------------------------------------------------------------------
-- Tests
private
-- A test of the solver above.
test : {ℓ : Level} (A B C : Set ℓ) →
(Lift ℓ ⊤ × A × (B ⊎ C)) ↔ (A × B ⊎ C × (Lift ℓ ⊥ ⊎ A))
test = solve 3 (λ A B C → con 1 :* (A :* (B :+ C)) :=
A :* B :+ C :* (con 0 :+ A))
Inv.id
where open ×-⊎-Solver bijection
| 32.727273
| 72
| 0.520139
|
ad64a6a6a353acfa068c507b71c898e9e0326d66
| 1,821
|
agda
|
Agda
|
Cubical/HITs/Rationals/SigmaQ/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Rationals/SigmaQ/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Rationals/SigmaQ/Base.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2021-11-22T02:02:01.000Z
|
2021-11-22T02:02:01.000Z
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.Rationals.SigmaQ.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.HITs.Ints.QuoInt
open import Cubical.Data.Nat as ℕ hiding (_*_)
open import Cubical.Data.NatPlusOne
open import Cubical.Data.Sigma
open import Cubical.Data.Nat.GCD
open import Cubical.Data.Nat.Coprime
-- ℚ as the set of coprime pairs in ℤ × ℕ₊₁
ℚ : Type₀
ℚ = Σ[ (a , b) ∈ ℤ × ℕ₊₁ ] areCoprime (abs a , ℕ₊₁→ℕ b)
isSetℚ : isSet ℚ
isSetℚ = isSetΣ (isSet× isSetℤ (subst isSet 1+Path isSetℕ)) (λ _ → isProp→isSet isPropIsGCD)
signedPair : Sign → ℕ × ℕ₊₁ → ℤ × ℕ₊₁
signedPair s (a , b) = (signed s a , b)
[_] : ℤ × ℕ₊₁ → ℚ
[ signed s a , b ] = signedPair s (toCoprime (a , b)) , toCoprimeAreCoprime (a , b)
[ posneg i , b ] = (posneg i , 1) , toCoprimeAreCoprime (0 , b)
[]-cancelʳ : ∀ ((a , b) : ℤ × ℕ₊₁) k → [ a * pos (ℕ₊₁→ℕ k) , b *₊₁ k ] ≡ [ a , b ]
[]-cancelʳ (signed s zero , b) k =
Σ≡Prop (λ _ → isPropIsGCD) (λ i → signed-zero spos s i , 1)
[]-cancelʳ (signed s (suc a) , b) k =
Σ≡Prop (λ _ → isPropIsGCD) (λ i → signedPair (*S-comm s spos i)
(toCoprime-cancelʳ (suc a , b) k i))
[]-cancelʳ (posneg i , b) k j =
isSet→isSet' isSetℚ ([]-cancelʳ (pos zero , b) k) ([]-cancelʳ (neg zero , b) k)
(λ i → [ posneg i * pos (ℕ₊₁→ℕ k) , b *₊₁ k ]) (λ i → [ posneg i , b ]) i j
-- Natural number and negative integer literals for ℚ
open import Cubical.Data.Nat.Literals public
instance
fromNatℚ : HasFromNat ℚ
fromNatℚ = record { Constraint = λ _ → Unit ; fromNat = λ n → (pos n , 1) , oneGCD n }
instance
fromNegℚ : HasFromNeg ℚ
fromNegℚ = record { Constraint = λ _ → Unit ; fromNeg = λ n → (neg n , 1) , oneGCD n }
| 33.109091
| 97
| 0.602965
|
0684d8389484929a7e3124ff6b7bf90e0a799311
| 8,624
|
agda
|
Agda
|
Definition/LogicalRelation/Substitution/Introductions/Emptyrec.agda
|
CoqHott/logrel-mltt
|
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
|
[
"MIT"
] | 2
|
2018-06-21T08:39:01.000Z
|
2022-01-17T16:13:53.000Z
|
Definition/LogicalRelation/Substitution/Introductions/Emptyrec.agda
|
CoqHott/logrel-mltt
|
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
|
[
"MIT"
] | null | null | null |
Definition/LogicalRelation/Substitution/Introductions/Emptyrec.agda
|
CoqHott/logrel-mltt
|
e0eeebc4aa5ed791ce3e7c0dc9531bd113dfcc04
|
[
"MIT"
] | 2
|
2022-01-26T14:55:51.000Z
|
2022-02-15T19:42:19.000Z
|
{-# OPTIONS --safe #-}
open import Definition.Typed.EqualityRelation
module Definition.LogicalRelation.Substitution.Introductions.Emptyrec {{eqrel : EqRelSet}} where
open EqRelSet {{...}}
open import Definition.Untyped as U hiding (wk)
open import Definition.Untyped.Properties
open import Definition.Typed
import Definition.Typed.Weakening as T
open import Definition.Typed.Properties
open import Definition.Typed.RedSteps
open import Definition.LogicalRelation
open import Definition.LogicalRelation.ShapeView
open import Definition.LogicalRelation.Irrelevance
open import Definition.LogicalRelation.Properties
open import Definition.LogicalRelation.Application
open import Definition.LogicalRelation.Substitution
open import Definition.LogicalRelation.Substitution.Properties
import Definition.LogicalRelation.Substitution.Irrelevance as S
open import Definition.LogicalRelation.Substitution.Reflexivity
open import Definition.LogicalRelation.Substitution.Weakening
open import Definition.LogicalRelation.Substitution.Introductions.Empty
open import Definition.LogicalRelation.Substitution.Introductions.Pi
open import Definition.LogicalRelation.Substitution.Introductions.SingleSubst
open import Tools.Product
open import Tools.Unit
open import Tools.Empty
open import Tools.Nat
import Tools.PropositionalEquality as PE
-- Reducibility of natural recursion under a valid substitution.
EmptyrecTerm : ∀ {F rF lF lEmpty n Γ Δ σ l}
([Γ] : ⊩ᵛ Γ)
([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ rF , ι lF ] / [Γ])
(⊢Δ : ⊢ Δ)
([σ] : Δ ⊩ˢ σ ∷ Γ / [Γ] / ⊢Δ)
([σn] : Δ ⊩⟨ l ⟩ n ∷ Empty lEmpty ^ [ % , ι lEmpty ] / Emptyᵣ (idRed:*: (univ (Emptyⱼ ⊢Δ))))
→ Δ ⊩⟨ l ⟩ Emptyrec lF lEmpty (subst σ F) n
∷ subst σ F ^ [ rF , ι lF ]
/ proj₁ ([F] ⊢Δ [σ])
EmptyrecTerm {F} {rF = !} {lF} {lEmpty} {n} {Γ} {Δ} {σ} {l} [Γ] [F] ⊢Δ [σ]
(Emptyₜ (ne d)) =
let [Empty] = Emptyᵛ {ll = lEmpty} {l = l} [Γ]
[σEmpty] = proj₁ ([Empty] ⊢Δ [σ])
[σF] = proj₁ ([F] ⊢Δ [σ])
⊢F = escape [σF]
⊢F≡F = escapeEq [σF] (reflEq [σF])
in neuTerm [σF] (Emptyrecₙ) (Emptyrecⱼ ⊢F d)
(~-Emptyrec ⊢F≡F d d)
EmptyrecTerm {F} {rF = %} {lF} {lEmpty} {n} {Γ} {Δ} {σ} {l} [Γ] [F] ⊢Δ [σ]
(Emptyₜ (ne d)) =
let [Empty] = Emptyᵛ {ll = lEmpty} {l = l} [Γ]
[σEmpty] = proj₁ ([Empty] ⊢Δ [σ])
[σF] = proj₁ ([F] ⊢Δ [σ])
⊢F = escape [σF]
⊢F≡F = escapeEq [σF] (reflEq [σF])
in logRelIrr [σF] (Emptyrecⱼ ⊢F d)
-- Reducibility of natural recursion congurence under a valid substitution equality.
Emptyrec-congTerm : ∀ {F F′ rF lF lEmpty n m Γ Δ σ σ′ l}
([Γ] : ⊩ᵛ Γ)
([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ rF , ι lF ] / [Γ])
([F′] : Γ ⊩ᵛ⟨ l ⟩ F′ ^ [ rF , ι lF ] / [Γ])
([F≡F′] : Γ ⊩ᵛ⟨ l ⟩ F ≡ F′ ^ [ rF , ι lF ] / [Γ] / [F])
(⊢Δ : ⊢ Δ)
([σ] : Δ ⊩ˢ σ ∷ Γ / [Γ] / ⊢Δ)
([σ′] : Δ ⊩ˢ σ′ ∷ Γ / [Γ] / ⊢Δ)
([σ≡σ′] : Δ ⊩ˢ σ ≡ σ′ ∷ Γ / [Γ] / ⊢Δ / [σ])
([σn] : Δ ⊩⟨ l ⟩ n ∷ Empty lEmpty ^ [ % , ι lEmpty ] / Emptyᵣ (idRed:*: (univ (Emptyⱼ ⊢Δ))))
([σm] : Δ ⊩⟨ l ⟩ m ∷ Empty lEmpty ^ [ % , ι lEmpty ] / Emptyᵣ (idRed:*: (univ (Emptyⱼ ⊢Δ))))
→ Δ ⊩⟨ l ⟩ Emptyrec lF lEmpty (subst σ F) n
≡ Emptyrec lF lEmpty (subst σ′ F′) m
∷ subst σ F ^ [ rF , ι lF ]
/ proj₁ ([F] ⊢Δ [σ])
Emptyrec-congTerm {F} {F′} {rF = !} {lF} {lEmpty} {n} {m} {Γ} {Δ} {σ} {σ′} {l}
[Γ] [F] [F′] [F≡F′]
⊢Δ [σ] [σ′] [σ≡σ′]
(Emptyₜ (ne ⊢n′))
(Emptyₜ (ne ⊢m′)) =
let [Empty] = Emptyᵛ {ll = lEmpty} {l = l} [Γ]
[σEmpty] = proj₁ ([Empty] ⊢Δ [σ])
[σ′Empty] = proj₁ ([Empty] ⊢Δ [σ′])
[σF] = proj₁ ([F] ⊢Δ [σ])
[σ′F] = proj₁ ([F] ⊢Δ [σ′])
[σ′F′] = proj₁ ([F′] ⊢Δ [σ′])
⊢F = escape [σF]
⊢F≡F = escapeEq [σF] (reflEq [σF])
⊢F′ = escape [σ′F′]
⊢F′≡F′ = escapeEq [σ′F′] (reflEq [σ′F′])
⊢σF≡σ′F = escapeEq [σF] (proj₂ ([F] ⊢Δ [σ]) [σ′] [σ≡σ′])
⊢σ′F≡σ′F′ = escapeEq [σ′F] ([F≡F′] ⊢Δ [σ′])
⊢F≡F′ = ≅-trans ⊢σF≡σ′F ⊢σ′F≡σ′F′
[σF≡σ′F] = proj₂ ([F] ⊢Δ [σ]) [σ′] [σ≡σ′]
[σ′F≡σ′F′] = [F≡F′] ⊢Δ [σ′]
[σF≡σ′F′] = transEq [σF] [σ′F] [σ′F′] [σF≡σ′F] [σ′F≡σ′F′]
EmptyrecN = neuTerm [σF] (Emptyrecₙ) (Emptyrecⱼ ⊢F ⊢n′)
(~-Emptyrec ⊢F≡F ⊢n′ ⊢n′)
EmptyrecM = neuTerm [σ′F′] (Emptyrecₙ) (Emptyrecⱼ ⊢F′ ⊢m′)
(~-Emptyrec ⊢F′≡F′ ⊢m′ ⊢m′)
EmptyrecN≡M =
neuEqTerm [σF] Emptyrecₙ Emptyrecₙ
(Emptyrecⱼ ⊢F ⊢n′)
(conv (Emptyrecⱼ ⊢F′ ⊢m′)
(sym (≅-eq (escapeEq [σF]
(transEq [σF] [σ′F] [σ′F′] [σF≡σ′F] [σ′F≡σ′F′])))))
(~-Emptyrec ⊢F≡F′ ⊢n′ ⊢m′)
in EmptyrecN≡M
Emptyrec-congTerm {F} {F′} {rF = %} {lF} {lEmpty} {n} {m} {Γ} {Δ} {σ} {σ′} {l}
[Γ] [F] [F′] [F≡F′]
⊢Δ [σ] [σ′] [σ≡σ′]
(Emptyₜ (ne ⊢n′))
(Emptyₜ (ne ⊢m′)) =
let [Empty] = Emptyᵛ {ll = lEmpty} {l = l} [Γ]
[σEmpty] = proj₁ ([Empty] ⊢Δ [σ])
[σ′Empty] = proj₁ ([Empty] ⊢Δ [σ′])
[σF] = proj₁ ([F] ⊢Δ [σ])
[σ′F] = proj₁ ([F] ⊢Δ [σ′])
[σ′F′] = proj₁ ([F′] ⊢Δ [σ′])
⊢F = escape [σF]
⊢F≡F = escapeEq [σF] (reflEq [σF])
⊢F′ = escape [σ′F′]
⊢F′≡F′ = escapeEq [σ′F′] (reflEq [σ′F′])
⊢σF≡σ′F = escapeEq [σF] (proj₂ ([F] ⊢Δ [σ]) [σ′] [σ≡σ′])
⊢σ′F≡σ′F′ = escapeEq [σ′F] ([F≡F′] ⊢Δ [σ′])
⊢F≡F′ = ≅-trans ⊢σF≡σ′F ⊢σ′F≡σ′F′
[σF≡σ′F] = proj₂ ([F] ⊢Δ [σ]) [σ′] [σ≡σ′]
[σ′F≡σ′F′] = [F≡F′] ⊢Δ [σ′]
[σF≡σ′F′] = transEq [σF] [σ′F] [σ′F′] [σF≡σ′F] [σ′F≡σ′F′]
in logRelIrrEq [σF] (Emptyrecⱼ ⊢F ⊢n′) (conv (Emptyrecⱼ ⊢F′ ⊢m′)
(sym (≅-eq (escapeEq [σF]
(transEq [σF] [σ′F] [σ′F′] [σF≡σ′F] [σ′F≡σ′F′])))))
-- Validity of empty recursion.
Emptyrecᵛ : ∀ {F rF lF lEmpty n Γ l} ([Γ] : ⊩ᵛ Γ)
([Empty] : Γ ⊩ᵛ⟨ l ⟩ Empty lEmpty ^ [ % , ι lEmpty ] / [Γ])
([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ rF , ι lF ] / [Γ])
→ ([n] : Γ ⊩ᵛ⟨ l ⟩ n ∷ Empty lEmpty ^ [ % , ι lEmpty ] / [Γ] / [Empty])
→ Γ ⊩ᵛ⟨ l ⟩ Emptyrec lF lEmpty F n ∷ F ^ [ rF , ι lF ] / [Γ] / [F]
Emptyrecᵛ {F} {rF} {lF} {lEmpty} {n} {l = l} [Γ] [Empty] [F] [n]
{Δ = Δ} {σ = σ} ⊢Δ [σ] =
let [σn] = irrelevanceTerm {l′ = l} (proj₁ ([Empty] ⊢Δ [σ]))
(Emptyᵣ (idRed:*: (univ (Emptyⱼ ⊢Δ)))) (proj₁ ([n] ⊢Δ [σ]))
in EmptyrecTerm {F = F} [Γ] [F] ⊢Δ [σ] [σn]
, λ {σ'} [σ′] [σ≡σ′] →
let [σ′n] = irrelevanceTerm {l′ = l} (proj₁ ([Empty] ⊢Δ [σ′]))
(Emptyᵣ (idRed:*: (univ (Emptyⱼ ⊢Δ)))) (proj₁ ([n] ⊢Δ [σ′]))
[σn≡σ′n] = irrelevanceEqTerm {l′ = l} (proj₁ ([Empty] ⊢Δ [σ]))
(Emptyᵣ (idRed:*: (univ (Emptyⱼ ⊢Δ))))
(proj₂ ([n] ⊢Δ [σ]) [σ′] [σ≡σ′])
congTerm = Emptyrec-congTerm {F = F} {F′ = F} [Γ] [F] [F] (reflᵛ {F} {l = l} [Γ] [F])
⊢Δ [σ] [σ′] [σ≡σ′] [σn] [σ′n]
in congTerm
-- Validity of natural recursion congurence.
Emptyrec-congᵛ : ∀ {F F′ rF lF lEmpty n n′ Γ l} ([Γ] : ⊩ᵛ Γ)
([Empty] : Γ ⊩ᵛ⟨ l ⟩ Empty lEmpty ^ [ % , ι lEmpty ] / [Γ])
([F] : Γ ⊩ᵛ⟨ l ⟩ F ^ [ rF , ι lF ] / [Γ])
([F′] : Γ ⊩ᵛ⟨ l ⟩ F′ ^ [ rF , ι lF ] / [Γ])
([F≡F′] : Γ ⊩ᵛ⟨ l ⟩ F ≡ F′ ^ [ rF , ι lF ] / [Γ] / [F])
([n] : Γ ⊩ᵛ⟨ l ⟩ n ∷ Empty lEmpty ^ [ % , ι lEmpty ] / [Γ] / [Empty])
([n′] : Γ ⊩ᵛ⟨ l ⟩ n′ ∷ Empty lEmpty ^ [ % , ι lEmpty ] / [Γ] / [Empty])
→ Γ ⊩ᵛ⟨ l ⟩ Emptyrec lF lEmpty F n ≡ Emptyrec lF lEmpty F′ n′ ∷ F ^ [ rF , ι lF ] / [Γ] / [F]
Emptyrec-congᵛ {F} {F′} {rF} {lF} {lEmpty} {n} {n′} {l = l}
[Γ] [Empty] [F] [F′] [F≡F′]
[n] [n′] {Δ = Δ} {σ = σ} ⊢Δ [σ] =
let [σn] = irrelevanceTerm {l′ = l} (proj₁ ([Empty] ⊢Δ [σ]))
(Emptyᵣ (idRed:*: (univ (Emptyⱼ ⊢Δ)))) (proj₁ ([n] ⊢Δ [σ]))
[σn′] = irrelevanceTerm {l′ = l} (proj₁ ([Empty] ⊢Δ [σ]))
(Emptyᵣ (idRed:*: (univ (Emptyⱼ ⊢Δ)))) (proj₁ ([n′] ⊢Δ [σ]))
congTerm = Emptyrec-congTerm {F} {F′} [Γ] [F] [F′] [F≡F′]
⊢Δ [σ] [σ] (reflSubst [Γ] ⊢Δ [σ]) [σn] [σn′]
in congTerm
| 47.646409
| 115
| 0.44782
|
10d45dbd29e809016392cda861751d755c19a315
| 2,031
|
agda
|
Agda
|
papers/unraveling-recursion/code/src/Compilation/Term.agda
|
imikushin/plutus
|
2c5bda20fb94b0f3737ba1a236ef5d7a7fd9f631
|
[
"Apache-2.0"
] | 1,299
|
2018-10-02T13:41:39.000Z
|
2022-03-28T01:10:02.000Z
|
papers/unraveling-recursion/code/src/Compilation/Term.agda
|
imikushin/plutus
|
2c5bda20fb94b0f3737ba1a236ef5d7a7fd9f631
|
[
"Apache-2.0"
] | 2,493
|
2018-09-28T19:28:17.000Z
|
2022-03-31T15:31:31.000Z
|
papers/unraveling-recursion/code/src/Compilation/Term.agda
|
imikushin/plutus
|
2c5bda20fb94b0f3737ba1a236ef5d7a7fd9f631
|
[
"Apache-2.0"
] | 399
|
2018-10-05T09:36:10.000Z
|
2022-03-31T11:18:25.000Z
|
module Compilation.Term where
open import Context
open import Type.Core
open import Type.NbE
import Term.Core as Core
open import Compilation.Data
open import Compilation.Encode.Core
open import Function
open import Data.Empty
open import Data.Sum.Base
open import Data.List.Base as List
infix 3 _⊢_
data Recursivity : Set where
NonRec Rec : Recursivity
caseRec : ∀ {ρ} {R : Set ρ} -> Recursivity -> R -> R -> R
caseRec NonRec x y = x
caseRec Rec x y = y
data _⊢_ {Θ} Γ : Star Θ -> Set where
letType : ∀ {σ β} -> (α : Θ ⊢ᵗ σ) -> shiftᶜ Γ ⊢ β -> Γ ⊢ β [ α ]ᵗ
letTerm : ∀ {α} Δ rec -> Seq (caseRec rec Γ (Γ ▻▻ Δ) ⊢_) Δ -> Γ ▻▻ Δ ⊢ α -> Γ ⊢ α
var : ∀ {α} -> α ∈ Γ -> Γ ⊢ α
Λ_ : ∀ {σ α} -> shiftᶜ Γ ⊢ α -> Γ ⊢ π σ α
_[_] : ∀ {σ β} -> Γ ⊢ π σ β -> (α : Θ ⊢ᵗ σ) -> Γ ⊢ β [ α ]ᵗ
ƛ_ : ∀ {α β} -> Γ ▻ α ⊢ β -> Γ ⊢ α ⇒ β
_·_ : ∀ {α β} -> Γ ⊢ α ⇒ β -> Γ ⊢ α -> Γ ⊢ β
iwrap : ∀ {κ ψ} {α : Θ ⊢ᵗ κ} -> Γ ⊢ Core.unfold ψ α -> Γ ⊢ μ ψ α
unwrap : ∀ {κ ψ} {α : Θ ⊢ᵗ κ} -> Γ ⊢ μ ψ α -> Γ ⊢ Core.unfold ψ α
mutual
compile : ∀ {Θ} {Γ : Con (Star Θ)} {α} -> Γ ⊢ α -> Γ Core.⊢ α
compile (letType α term) = (Core.Λ (compile term)) Core.[ α ]
compile (letTerm Δ rec env term) with rec
... | NonRec = Core.instNonRec (map-compile env) (compile term)
... | Rec = Core.instRec (map-compile env) (compile term)
compile (var v) = Core.var v
compile (Λ body) = Core.Λ (compile body)
compile (fun [ α ]) = compile fun Core.[ α ]
compile (ƛ body) = Core.ƛ (compile body)
compile (fun · arg) = compile fun Core.· compile arg
compile (iwrap term) = Core.iwrap (compile term)
compile (unwrap term) = Core.unwrap (compile term)
-- This is just `mapˢ compile` inlined to convince Agda there are no termination problems.
map-compile : ∀ {Θ} {Γ Δ : Con (Star Θ)} -> Seq (Γ ⊢_) Δ -> Seq (Γ Core.⊢_) Δ
map-compile ø = ø
map-compile (seq ▶ term) = map-compile seq ▶ compile term
| 38.320755
| 92
| 0.544067
|
2e258e4904583087ad01650a12c3bdc30b499544
| 1,374
|
agda
|
Agda
|
test/succeed/TerminationListInsertionNaive.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
test/succeed/TerminationListInsertionNaive.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/succeed/TerminationListInsertionNaive.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
module TerminationListInsertionNaive where
data List (A : Set) : Set where
[] : List A
_::_ : A -> List A -> List A
infixr 50 _::_
-- non-deterministic choice
postulate
_⊕_ : {A : Set} -> A -> A -> A
infixl 10 _⊕_
-- a funny formulation of insert
-- insert (a :: l) inserts a into l
--
-- this example cannot be handled with subpatterns
-- it is done with structured orders
-- could also be done with sized types
insert : {A : Set} -> List A -> List A
insert [] = []
insert (a :: []) = a :: []
insert (a :: b :: bs) = a :: b :: bs ⊕ -- case a <= b
b :: insert (a :: bs) -- case a > b
-- list flattening
-- termination using structured orders
flat : {A : Set} -> List (List A) -> List A
flat [] = []
flat ([] :: ll) = flat ll
flat ((x :: l) :: ll) = x :: flat (l :: ll)
{- generates two recursive calls with the following call matrices
[] :: ll (x :: l) ll
ll < l < .
ll . =
during composition, the second is collapsed to =, so the call graph is
already complete. Both matrices are idempotent and contain a strictly
decreasing argument.
It could also be done with sized types; lexicographic in (i,j)
with type
flat : {A : Set} -> (1 + Listʲ A × List^i (List^∞ A)) -> List^∞ A
-}
| 25.444444
| 70
| 0.534934
|
13442126c5c4432ae5a0ffc693aea063d10d5be4
| 6,326
|
agda
|
Agda
|
Cubical/Algebra/RingSolver/Solver.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 1
|
2022-03-05T00:29:41.000Z
|
2022-03-05T00:29:41.000Z
|
Cubical/Algebra/RingSolver/Solver.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/RingSolver/Solver.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe #-}
module Cubical.Algebra.RingSolver.Solver where
open import Cubical.Foundations.Prelude
open import Cubical.Data.FinData
open import Cubical.Data.Nat using (ℕ)
open import Cubical.Data.Nat.Order using (zero-≤)
open import Cubical.Data.Vec.Base
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.Ring
open import Cubical.Algebra.RingSolver.RawAlgebra renaming (⟨_⟩ to ⟨_⟩ᵣ)
open import Cubical.Algebra.RingSolver.AlgebraExpression
open import Cubical.Algebra.RingSolver.IntAsRawRing
open import Cubical.Algebra.RingSolver.HornerForms
open import Cubical.Algebra.RingSolver.EvalHom
open import Cubical.Algebra.RingSolver.HornerEval
private
variable
ℓ : Level
module EqualityToNormalform (R : CommRing ℓ) where
νR = CommRing→RawℤAlgebra R
open CommRingStr (snd R)
open RingTheory (CommRing→Ring R)
open Eval ℤAsRawRing νR
open IteratedHornerOperations νR
open HomomorphismProperties R
ℤExpr : (n : ℕ) → Type _
ℤExpr = Expr ℤAsRawRing (fst R)
normalize : {n : ℕ} → ℤExpr n → IteratedHornerForms νR n
normalize {n = n} (K r) = Constant n νR r
normalize {n = n} (∣ k) = Variable n νR k
normalize (x +' y) =
(normalize x) +ₕ (normalize y)
normalize (x ·' y) =
(normalize x) ·ₕ (normalize y)
normalize (-' x) = -ₕ (normalize x)
isEqualToNormalform :
{n : ℕ} (e : ℤExpr n) (xs : Vec (fst R) n)
→ eval (normalize e) xs ≡ ⟦ e ⟧ xs
isEqualToNormalform (K r) [] = refl
isEqualToNormalform {n = ℕ.suc n} (K r) (x ∷ xs) =
eval (Constant (ℕ.suc n) νR r) (x ∷ xs) ≡⟨ refl ⟩
eval (0ₕ ·X+ Constant n νR r) (x ∷ xs) ≡⟨ combineCasesEval R 0ₕ (Constant n νR r) x xs ⟩
eval 0ₕ (x ∷ xs) · x + eval (Constant n νR r) xs ≡⟨ cong (λ u → u · x + eval (Constant n νR r) xs)
(Eval0H (x ∷ xs)) ⟩
0r · x + eval (Constant n νR r) xs ≡⟨ cong
(λ u → u + eval (Constant n νR r) xs)
(0LeftAnnihilates _) ⟩
0r + eval (Constant n νR r) xs ≡⟨ +Lid _ ⟩
eval (Constant n νR r) xs ≡⟨ isEqualToNormalform (K r) xs ⟩
_ ∎
isEqualToNormalform (∣ zero) (x ∷ xs) =
eval (1ₕ ·X+ 0ₕ) (x ∷ xs) ≡⟨ combineCasesEval R 1ₕ 0ₕ x xs ⟩
eval 1ₕ (x ∷ xs) · x + eval 0ₕ xs ≡⟨ cong (λ u → u · x + eval 0ₕ xs)
(Eval1ₕ (x ∷ xs)) ⟩
1r · x + eval 0ₕ xs ≡⟨ cong (λ u → 1r · x + u ) (Eval0H xs) ⟩
1r · x + 0r ≡⟨ +Rid _ ⟩
1r · x ≡⟨ ·Lid _ ⟩
x ∎
isEqualToNormalform {n = ℕ.suc n} (∣ (suc k)) (x ∷ xs) =
eval (0ₕ ·X+ Variable n νR k) (x ∷ xs) ≡⟨ combineCasesEval R 0ₕ (Variable n νR k) x xs ⟩
eval 0ₕ (x ∷ xs) · x + eval (Variable n νR k) xs ≡⟨ cong (λ u → u · x + eval (Variable n νR k) xs)
(Eval0H (x ∷ xs)) ⟩
0r · x + eval (Variable n νR k) xs ≡⟨ cong (λ u → u + eval (Variable n νR k) xs)
(0LeftAnnihilates _) ⟩
0r + eval (Variable n νR k) xs ≡⟨ +Lid _ ⟩
eval (Variable n νR k) xs ≡⟨ isEqualToNormalform (∣ k) xs ⟩
⟦ ∣ (suc k) ⟧ (x ∷ xs) ∎
isEqualToNormalform (-' e) [] =
eval (-ₕ (normalize e)) [] ≡⟨ -EvalDist (normalize e) [] ⟩
- eval (normalize e) [] ≡⟨ cong -_ (isEqualToNormalform e [] ) ⟩
- ⟦ e ⟧ [] ∎
isEqualToNormalform (-' e) (x ∷ xs) =
eval (-ₕ (normalize e)) (x ∷ xs) ≡⟨ -EvalDist (normalize e) (x ∷ xs) ⟩
- eval (normalize e) (x ∷ xs) ≡⟨ cong -_ (isEqualToNormalform e (x ∷ xs) ) ⟩
- ⟦ e ⟧ (x ∷ xs) ∎
isEqualToNormalform (e +' e₁) [] =
eval (normalize e +ₕ normalize e₁) []
≡⟨ +Homeval (normalize e) _ [] ⟩
eval (normalize e) []
+ eval (normalize e₁) []
≡⟨ cong (λ u → u + eval (normalize e₁) [])
(isEqualToNormalform e []) ⟩
⟦ e ⟧ []
+ eval (normalize e₁) []
≡⟨ cong (λ u → ⟦ e ⟧ [] + u) (isEqualToNormalform e₁ []) ⟩
⟦ e ⟧ [] + ⟦ e₁ ⟧ [] ∎
isEqualToNormalform (e +' e₁) (x ∷ xs) =
eval (normalize e +ₕ normalize e₁) (x ∷ xs)
≡⟨ +Homeval (normalize e) _ (x ∷ xs) ⟩
eval (normalize e) (x ∷ xs) + eval (normalize e₁) (x ∷ xs)
≡⟨ cong (λ u → u + eval (normalize e₁) (x ∷ xs))
(isEqualToNormalform e (x ∷ xs)) ⟩
⟦ e ⟧ (x ∷ xs) + eval (normalize e₁) (x ∷ xs)
≡⟨ cong (λ u → ⟦ e ⟧ (x ∷ xs) + u) (isEqualToNormalform e₁ (x ∷ xs)) ⟩
⟦ e ⟧ (x ∷ xs) + ⟦ e₁ ⟧ (x ∷ xs) ∎
isEqualToNormalform (e ·' e₁) [] =
eval (normalize e ·ₕ normalize e₁) []
≡⟨ ·Homeval (normalize e) _ [] ⟩
eval (normalize e) [] · eval (normalize e₁) []
≡⟨ cong (λ u → u · eval (normalize e₁) [])
(isEqualToNormalform e []) ⟩
⟦ e ⟧ [] · eval (normalize e₁) []
≡⟨ cong (λ u → ⟦ e ⟧ [] · u) (isEqualToNormalform e₁ []) ⟩
⟦ e ⟧ [] · ⟦ e₁ ⟧ [] ∎
isEqualToNormalform (e ·' e₁) (x ∷ xs) =
eval (normalize e ·ₕ normalize e₁) (x ∷ xs)
≡⟨ ·Homeval (normalize e) _ (x ∷ xs) ⟩
eval (normalize e) (x ∷ xs) · eval (normalize e₁) (x ∷ xs)
≡⟨ cong (λ u → u · eval (normalize e₁) (x ∷ xs))
(isEqualToNormalform e (x ∷ xs)) ⟩
⟦ e ⟧ (x ∷ xs) · eval (normalize e₁) (x ∷ xs)
≡⟨ cong (λ u → ⟦ e ⟧ (x ∷ xs) · u) (isEqualToNormalform e₁ (x ∷ xs)) ⟩
⟦ e ⟧ (x ∷ xs) · ⟦ e₁ ⟧ (x ∷ xs) ∎
solve :
{n : ℕ} (e₁ e₂ : ℤExpr n) (xs : Vec (fst R) n)
(p : eval (normalize e₁) xs ≡ eval (normalize e₂) xs)
→ ⟦ e₁ ⟧ xs ≡ ⟦ e₂ ⟧ xs
solve e₁ e₂ xs p =
⟦ e₁ ⟧ xs ≡⟨ sym (isEqualToNormalform e₁ xs) ⟩
eval (normalize e₁) xs ≡⟨ p ⟩
eval (normalize e₂) xs ≡⟨ isEqualToNormalform e₂ xs ⟩
⟦ e₂ ⟧ xs ∎
ℤExpr : (R : CommRing ℓ) (n : ℕ)
→ _
ℤExpr R n = EqualityToNormalform.ℤExpr R n
solve : (R : CommRing ℓ)
{n : ℕ} (e₁ e₂ : ℤExpr R n) (xs : Vec (fst R) n)
(p : eval (EqualityToNormalform.normalize R e₁) xs ≡ eval (EqualityToNormalform.normalize R e₂) xs)
→ _
solve R = EqualityToNormalform.solve R
| 43.328767
| 107
| 0.50411
|
2eed2f1c63c95b0831b33681bb0f373447d9f4e7
| 8,646
|
agda
|
Agda
|
test/Succeed/Inlining-Builtin-Reflection-did-not-work.agda
|
isovector/agda
|
9a29f3a1f5e24c818bdabbf2c17d0f79887aa8b4
|
[
"BSD-2-Clause"
] | null | null | null |
test/Succeed/Inlining-Builtin-Reflection-did-not-work.agda
|
isovector/agda
|
9a29f3a1f5e24c818bdabbf2c17d0f79887aa8b4
|
[
"BSD-2-Clause"
] | null | null | null |
test/Succeed/Inlining-Builtin-Reflection-did-not-work.agda
|
isovector/agda
|
9a29f3a1f5e24c818bdabbf2c17d0f79887aa8b4
|
[
"BSD-2-Clause"
] | null | null | null |
module _ where
open import Agda.Builtin.Unit
open import Agda.Builtin.Bool
open import Agda.Builtin.Nat
open import Agda.Builtin.Word
open import Agda.Builtin.List
open import Agda.Builtin.String
open import Agda.Builtin.Char
open import Agda.Builtin.Float
open import Agda.Builtin.Sigma
-- Names --
postulate Name : Set
{-# BUILTIN QNAME Name #-}
primitive
primQNameEquality : Name → Name → Bool
primQNameLess : Name → Name → Bool
primShowQName : Name → String
-- Metavariables --
postulate Meta : Set
{-# BUILTIN AGDAMETA Meta #-}
primitive
primMetaEquality : Meta → Meta → Bool
primMetaLess : Meta → Meta → Bool
primShowMeta : Meta → String
-- Arguments --
-- Arguments can be (visible), {hidden}, or {{instance}}.
data Visibility : Set where
visible hidden instance′ : Visibility
{-# BUILTIN HIDING Visibility #-}
{-# BUILTIN VISIBLE visible #-}
{-# BUILTIN HIDDEN hidden #-}
{-# BUILTIN INSTANCE instance′ #-}
-- Arguments can be relevant or irrelevant.
data Relevance : Set where
relevant irrelevant : Relevance
{-# BUILTIN RELEVANCE Relevance #-}
{-# BUILTIN RELEVANT relevant #-}
{-# BUILTIN IRRELEVANT irrelevant #-}
-- Arguments also have a quantity.
data Quantity : Set where
quantity-0 quantity-ω : Quantity
{-# BUILTIN QUANTITY Quantity #-}
{-# BUILTIN QUANTITY-0 quantity-0 #-}
{-# BUILTIN QUANTITY-ω quantity-ω #-}
-- Relevance and quantity are combined into a modality.
data Modality : Set where
modality : (r : Relevance) (q : Quantity) → Modality
{-# BUILTIN MODALITY Modality #-}
{-# BUILTIN MODALITY-CONSTRUCTOR modality #-}
data ArgInfo : Set where
arg-info : (v : Visibility) (m : Modality) → ArgInfo
data Arg (A : Set) : Set where
arg : (i : ArgInfo) (x : A) → Arg A
{-# BUILTIN ARGINFO ArgInfo #-}
{-# BUILTIN ARGARGINFO arg-info #-}
{-# BUILTIN ARG Arg #-}
{-# BUILTIN ARGARG arg #-}
-- Name abstraction --
data Abs (A : Set) : Set where
abs : (s : String) (x : A) → Abs A
{-# BUILTIN ABS Abs #-}
{-# BUILTIN ABSABS abs #-}
-- Literals --
data Literal : Set where
nat : (n : Nat) → Literal
word64 : (n : Word64) → Literal
float : (x : Float) → Literal
char : (c : Char) → Literal
string : (s : String) → Literal
name : (x : Name) → Literal
meta : (x : Meta) → Literal
{-# BUILTIN AGDALITERAL Literal #-}
{-# BUILTIN AGDALITNAT nat #-}
{-# BUILTIN AGDALITWORD64 word64 #-}
{-# BUILTIN AGDALITFLOAT float #-}
{-# BUILTIN AGDALITCHAR char #-}
{-# BUILTIN AGDALITSTRING string #-}
{-# BUILTIN AGDALITQNAME name #-}
{-# BUILTIN AGDALITMETA meta #-}
-- Patterns --
-- Terms --
data Sort : Set
data Clause : Set
data Term : Set
Type = Term
Telescope = List (Σ String λ _ → Arg Type)
data Term where
var : (x : Nat) (args : List (Arg Term)) → Term
con : (c : Name) (args : List (Arg Term)) → Term
def : (f : Name) (args : List (Arg Term)) → Term
lam : (v : Visibility) (t : Abs Term) → Term
pat-lam : (cs : List Clause) (args : List (Arg Term)) → Term
pi : (a : Arg Type) (b : Abs Type) → Term
agda-sort : (s : Sort) → Term
lit : (l : Literal) → Term
meta : (x : Meta) → List (Arg Term) → Term
unknown : Term
data Sort where
set : (t : Term) → Sort
lit : (n : Nat) → Sort
prop : (t : Term) → Sort
propLit : (n : Nat) → Sort
inf : (n : Nat) → Sort
unknown : Sort
data Pattern : Set where
con : (c : Name) (ps : List (Arg Pattern)) → Pattern
dot : (t : Term) → Pattern
var : (x : Nat) → Pattern
lit : (l : Literal) → Pattern
proj : (f : Name) → Pattern
absurd : (x : Nat) → Pattern
data Clause where
clause : (tel : Telescope) (ps : List (Arg Pattern)) (t : Term) → Clause
absurd-clause : (tel : Telescope) (ps : List (Arg Pattern)) → Clause
{-# BUILTIN AGDATERM Term #-}
{-# BUILTIN AGDASORT Sort #-}
{-# BUILTIN AGDAPATTERN Pattern #-}
{-# BUILTIN AGDACLAUSE Clause #-}
{-# BUILTIN AGDATERMVAR var #-}
{-# BUILTIN AGDATERMCON con #-}
{-# BUILTIN AGDATERMDEF def #-}
{-# BUILTIN AGDATERMMETA meta #-}
{-# BUILTIN AGDATERMLAM lam #-}
{-# BUILTIN AGDATERMEXTLAM pat-lam #-}
{-# BUILTIN AGDATERMPI pi #-}
{-# BUILTIN AGDATERMSORT agda-sort #-}
{-# BUILTIN AGDATERMLIT lit #-}
{-# BUILTIN AGDATERMUNSUPPORTED unknown #-}
{-# BUILTIN AGDASORTSET set #-}
{-# BUILTIN AGDASORTLIT lit #-}
{-# BUILTIN AGDASORTPROP prop #-}
{-# BUILTIN AGDASORTPROPLIT propLit #-}
{-# BUILTIN AGDASORTINF inf #-}
{-# BUILTIN AGDASORTUNSUPPORTED unknown #-}
{-# BUILTIN AGDAPATCON con #-}
{-# BUILTIN AGDAPATDOT dot #-}
{-# BUILTIN AGDAPATVAR var #-}
{-# BUILTIN AGDAPATLIT lit #-}
{-# BUILTIN AGDAPATPROJ proj #-}
{-# BUILTIN AGDAPATABSURD absurd #-}
{-# BUILTIN AGDACLAUSECLAUSE clause #-}
{-# BUILTIN AGDACLAUSEABSURD absurd-clause #-}
-- Definitions --
data Definition : Set where
function : (cs : List Clause) → Definition
data-type : (pars : Nat) (cs : List Name) → Definition
record-type : (c : Name) (fs : List (Arg Name)) → Definition
data-cons : (d : Name) → Definition
axiom : Definition
prim-fun : Definition
{-# BUILTIN AGDADEFINITION Definition #-}
{-# BUILTIN AGDADEFINITIONFUNDEF function #-}
{-# BUILTIN AGDADEFINITIONDATADEF data-type #-}
{-# BUILTIN AGDADEFINITIONRECORDDEF record-type #-}
{-# BUILTIN AGDADEFINITIONDATACONSTRUCTOR data-cons #-}
{-# BUILTIN AGDADEFINITIONPOSTULATE axiom #-}
{-# BUILTIN AGDADEFINITIONPRIMITIVE prim-fun #-}
-- Errors --
data ErrorPart : Set where
strErr : String → ErrorPart
termErr : Term → ErrorPart
nameErr : Name → ErrorPart
{-# BUILTIN AGDAERRORPART ErrorPart #-}
{-# BUILTIN AGDAERRORPARTSTRING strErr #-}
{-# BUILTIN AGDAERRORPARTTERM termErr #-}
{-# BUILTIN AGDAERRORPARTNAME nameErr #-}
-- TC monad --
postulate
TC : ∀ {a} → Set a → Set a
returnTC : ∀ {a} {A : Set a} → A → TC A
bindTC : ∀ {a b} {A : Set a} {B : Set b} → TC A → (A → TC B) → TC B
unify : Term → Term → TC ⊤
typeError : ∀ {a} {A : Set a} → List ErrorPart → TC A
inferType : Term → TC Type
checkType : Term → Type → TC Term
normalise : Term → TC Term
catchTC : ∀ {a} {A : Set a} → TC A → TC A → TC A
quoteTC : ∀ {a} {A : Set a} → A → TC Term
unquoteTC : ∀ {a} {A : Set a} → Term → TC A
getContext : TC Telescope
extendContext : ∀ {a} {A : Set a} → String → Arg Type → TC A → TC A
inContext : ∀ {a} {A : Set a} → Telescope → TC A → TC A
freshName : String → TC Name
declareDef : Arg Name → Type → TC ⊤
defineFun : Name → List Clause → TC ⊤
getType : Name → TC Type
getDefinition : Name → TC Definition
blockOnMeta : ∀ {a} {A : Set a} → Meta → TC A
commitTC : TC ⊤
{-# BUILTIN AGDATCM TC #-}
{-# BUILTIN AGDATCMRETURN returnTC #-}
{-# BUILTIN AGDATCMBIND bindTC #-}
{-# BUILTIN AGDATCMUNIFY unify #-}
{-# BUILTIN AGDATCMTYPEERROR typeError #-}
{-# BUILTIN AGDATCMINFERTYPE inferType #-}
{-# BUILTIN AGDATCMCHECKTYPE checkType #-}
{-# BUILTIN AGDATCMNORMALISE normalise #-}
{-# BUILTIN AGDATCMCATCHERROR catchTC #-}
{-# BUILTIN AGDATCMQUOTETERM quoteTC #-}
{-# BUILTIN AGDATCMUNQUOTETERM unquoteTC #-}
{-# BUILTIN AGDATCMGETCONTEXT getContext #-}
{-# BUILTIN AGDATCMEXTENDCONTEXT extendContext #-}
{-# BUILTIN AGDATCMINCONTEXT inContext #-}
{-# BUILTIN AGDATCMFRESHNAME freshName #-}
{-# BUILTIN AGDATCMDECLAREDEF declareDef #-}
{-# BUILTIN AGDATCMDEFINEFUN defineFun #-}
{-# BUILTIN AGDATCMGETTYPE getType #-}
{-# BUILTIN AGDATCMGETDEFINITION getDefinition #-}
{-# BUILTIN AGDATCMBLOCKONMETA blockOnMeta #-}
{-# BUILTIN AGDATCMCOMMIT commitTC #-}
-- The code below used to be rejected, but it was accepted if the code
-- above was placed in a separate module.
postulate
A : Set
a : A
done : {A : Set} → A
helper : Term → Term → TC ⊤
helper hole (meta m args) =
bindTC (unify hole (lit (meta m))) λ _ →
unify (meta m args) (def (quote a) [])
helper _ _ = done
macro
metaLit : Term → TC ⊤
metaLit hole =
bindTC (checkType unknown (def (quote A) [])) (helper hole)
m : Meta
m = metaLit
| 30.768683
| 81
| 0.590446
|
57ca7f7109b1d2411138d747f8a3ac59971a7fce
| 1,691
|
agda
|
Agda
|
agda-stdlib/src/Relation/Binary/Core.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Relation/Binary/Core.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Relation/Binary/Core.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Properties of binary relations
------------------------------------------------------------------------
-- The contents of this module should be accessed via `Relation.Binary`.
{-# OPTIONS --without-K --safe #-}
module Relation.Binary.Core where
open import Function.Base using (_on_)
open import Level using (Level; _⊔_; suc)
private
variable
a b c ℓ ℓ₁ ℓ₂ ℓ₃ : Level
A : Set a
B : Set b
C : Set c
------------------------------------------------------------------------
-- Definitions
------------------------------------------------------------------------
-- Heterogeneous binary relations
REL : Set a → Set b → (ℓ : Level) → Set (a ⊔ b ⊔ suc ℓ)
REL A B ℓ = A → B → Set ℓ
-- Homogeneous binary relations
Rel : Set a → (ℓ : Level) → Set (a ⊔ suc ℓ)
Rel A ℓ = REL A A ℓ
------------------------------------------------------------------------
-- Relationships between relations
------------------------------------------------------------------------
infixr 4 _⇒_ _=[_]⇒_
-- Implication/containment - could also be written _⊆_.
_⇒_ : REL A B ℓ₁ → REL A B ℓ₂ → Set _
P ⇒ Q = ∀ {x y} → P x y → Q x y
-- Generalised implication - if P ≡ Q it can be read as "f preserves P".
_=[_]⇒_ : Rel A ℓ₁ → (A → B) → Rel B ℓ₂ → Set _
P =[ f ]⇒ Q = P ⇒ (Q on f)
-- A synonym for _=[_]⇒_.
_Preserves_⟶_ : (A → B) → Rel A ℓ₁ → Rel B ℓ₂ → Set _
f Preserves P ⟶ Q = P =[ f ]⇒ Q
-- A binary variant of _Preserves_⟶_.
_Preserves₂_⟶_⟶_ : (A → B → C) → Rel A ℓ₁ → Rel B ℓ₂ → Rel C ℓ₃ → Set _
_∙_ Preserves₂ P ⟶ Q ⟶ R = ∀ {x y u v} → P x y → Q u v → R (x ∙ u) (y ∙ v)
| 27.274194
| 74
| 0.438794
|
2e02458b640d4165598dfe281f81441155810500
| 475
|
agda
|
Agda
|
examples/SizedPoly/Console.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | 23
|
2016-06-19T12:57:55.000Z
|
2020-10-12T23:15:25.000Z
|
examples/SizedPoly/Console.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | null | null | null |
examples/SizedPoly/Console.agda
|
agda/ooAgda
|
7cc45e0148a4a508d20ed67e791544c30fecd795
|
[
"MIT"
] | 2
|
2018-09-01T15:02:37.000Z
|
2022-03-12T11:41:00.000Z
|
module SizedPoly.Console where
open import SizedPolyIO.Base
open import SizedPolyIO.Console hiding (main)
open import NativePolyIO
open import Level using () renaming (zero to lzero)
{-# TERMINATING #-}
myProgram : ∀{i} → IOConsole i (Unit {lzero})
myProgram = exec getLine λ line →
exec (putStrLn line) λ _ →
exec (putStrLn line) λ _ →
myProgram
main : NativeIO Unit
main = translateIOConsole myProgram
| 22.619048
| 51
| 0.648421
|
22b04c7254bdebee8979ffeef71878248687866c
| 2,652
|
agda
|
Agda
|
src/STLC/Syntax.agda
|
mietek/coquand-kovacs
|
bd626509948fbf8503ec2e31c1852e1ac6edcc79
|
[
"X11"
] | null | null | null |
src/STLC/Syntax.agda
|
mietek/coquand-kovacs
|
bd626509948fbf8503ec2e31c1852e1ac6edcc79
|
[
"X11"
] | null | null | null |
src/STLC/Syntax.agda
|
mietek/coquand-kovacs
|
bd626509948fbf8503ec2e31c1852e1ac6edcc79
|
[
"X11"
] | null | null | null |
module STLC.Syntax where
open import Prelude public
--------------------------------------------------------------------------------
-- Types
infixr 7 _⇒_
data 𝒯 : Set
where
⎵ : 𝒯
_⇒_ : (A B : 𝒯) → 𝒯
--------------------------------------------------------------------------------
-- Contexts
data 𝒞 : Set
where
∅ : 𝒞
_,_ : (Γ : 𝒞) (A : 𝒯) → 𝒞
length : 𝒞 → Nat
length ∅ = zero
length (Γ , x) = suc (length Γ)
lookup : (Γ : 𝒞) (i : Nat) {{_ : True (length Γ >? i)}} → 𝒯
lookup ∅ i {{()}}
lookup (Γ , A) zero {{yes}} = A
lookup (Γ , B) (suc i) {{p}} = lookup Γ i
-- Variables
infix 4 _∋_
data _∋_ : 𝒞 → 𝒯 → Set
where
zero : ∀ {Γ A} → Γ , A ∋ A
suc : ∀ {Γ A B} → (i : Γ ∋ A)
→ Γ , B ∋ A
Nat→∋ : ∀ {Γ} → (i : Nat) {{_ : True (length Γ >? i)}}
→ Γ ∋ lookup Γ i
Nat→∋ {Γ = ∅} i {{()}}
Nat→∋ {Γ = Γ , A} zero {{yes}} = zero
Nat→∋ {Γ = Γ , B} (suc i) {{p}} = suc (Nat→∋ i)
instance
num∋ : ∀ {Γ A} → Number (Γ ∋ A)
num∋ {Γ} {A} =
record
{ Constraint = λ i → Σ (True (length Γ >? i))
(λ p → lookup Γ i {{p}} ≡ A)
; fromNat = λ { i {{p , refl}} → Nat→∋ i }
}
--------------------------------------------------------------------------------
-- Terms
infix 3 _⊢_
data _⊢_ : 𝒞 → 𝒯 → Set
where
𝓋 : ∀ {Γ A} → (i : Γ ∋ A)
→ Γ ⊢ A
ƛ : ∀ {Γ A B} → (M : Γ , A ⊢ B)
→ Γ ⊢ A ⇒ B
_∙_ : ∀ {Γ A B} → (M : Γ ⊢ A ⇒ B) (N : Γ ⊢ A)
→ Γ ⊢ B
instance
num⊢ : ∀ {Γ A} → Number (Γ ⊢ A)
num⊢ {Γ} {A} =
record
{ Constraint = λ i → Σ (True (length Γ >? i))
(λ p → lookup Γ i {{p}} ≡ A)
; fromNat = λ { i {{p , refl}} → 𝓋 (Nat→∋ i) }
}
--------------------------------------------------------------------------------
-- Normal forms
mutual
infix 3 _⊢ⁿᶠ_
data _⊢ⁿᶠ_ : 𝒞 → 𝒯 → Set where
ƛ : ∀ {Γ A B} → (M : Γ , A ⊢ⁿᶠ B)
→ Γ ⊢ⁿᶠ A ⇒ B
ne : ∀ {Γ} → (M : Γ ⊢ⁿᵉ ⎵)
→ Γ ⊢ⁿᶠ ⎵
infix 3 _⊢ⁿᵉ_
data _⊢ⁿᵉ_ : 𝒞 → 𝒯 → Set where
𝓋 : ∀ {Γ A} → (i : Γ ∋ A)
→ Γ ⊢ⁿᵉ A
_∙_ : ∀ {Γ A B} → (M : Γ ⊢ⁿᵉ A ⇒ B) (N : Γ ⊢ⁿᶠ A)
→ Γ ⊢ⁿᵉ B
instance
num⊢ⁿᵉ : ∀ {Γ A} → Number (Γ ⊢ⁿᵉ A)
num⊢ⁿᵉ {Γ} {A} =
record
{ Constraint = λ i → Σ (True (length Γ >? i))
(λ p → lookup Γ i {{p}} ≡ A)
; fromNat = λ { i {{p , refl}} → 𝓋 (Nat→∋ i) }
}
--------------------------------------------------------------------------------
| 21.216
| 80
| 0.300905
|
587d1e5f9a79cfa46e348f9a60922f8a5e819990
| 22,123
|
agda
|
Agda
|
Cubical/Homotopy/HopfInvariant/HopfMap.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 1
|
2022-03-05T00:29:00.000Z
|
2022-03-05T00:29:00.000Z
|
Cubical/Homotopy/HopfInvariant/HopfMap.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
Cubical/Homotopy/HopfInvariant/HopfMap.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe --experimental-lossy-unification #-}
{-
This file contains a proof that the generator of Π₃S² has
hopf invariant ±1.
-}
module Cubical.Homotopy.HopfInvariant.HopfMap where
open import Cubical.Homotopy.HopfInvariant.Base
open import Cubical.Homotopy.Hopf
open S¹Hopf
open import Cubical.Homotopy.Connected
open import Cubical.Homotopy.HSpace
open import Cubical.ZCohomology.Base
open import Cubical.ZCohomology.GroupStructure
open import Cubical.ZCohomology.Properties
open import Cubical.ZCohomology.Groups.Sn
open import Cubical.ZCohomology.RingStructure.CupProduct
open import Cubical.ZCohomology.RingStructure.RingLaws
open import Cubical.ZCohomology.Gysin
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Path
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Function
open import Cubical.Foundations.Pointed
open import Cubical.Foundations.Pointed.Homogeneous
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Univalence
open import Cubical.Data.Sum
open import Cubical.Data.Sigma
open import Cubical.Data.Int hiding (_+'_)
open import Cubical.Data.Nat renaming (_+_ to _+ℕ_ ; _·_ to _·ℕ_)
open import Cubical.Data.Unit
open import Cubical.Algebra.Group
renaming (ℤ to ℤGroup ; Unit to UnitGroup)
open import Cubical.Algebra.Group.ZAction
open import Cubical.Algebra.Group.Exact
open import Cubical.HITs.Pushout
open import Cubical.HITs.Join
open import Cubical.HITs.S1 renaming (_·_ to _*_)
open import Cubical.HITs.Sn
open import Cubical.HITs.Susp
open import Cubical.HITs.Truncation
renaming (rec to trRec ; elim to trElim)
open import Cubical.HITs.SetTruncation
renaming (rec to sRec ; rec2 to sRec2
; elim to sElim ; elim2 to sElim2 ; map to sMap)
open import Cubical.HITs.PropositionalTruncation
renaming (rec to pRec)
HopfMap : S₊∙ 3 →∙ S₊∙ 2
fst HopfMap x = JoinS¹S¹→TotalHopf (Iso.inv (IsoSphereJoin 1 1) x) .fst
snd HopfMap = refl
-- We use the Hopf fibration in order to connect it to the Gysin Sequence
module hopfS¹ =
Hopf S1-AssocHSpace (sphereElim2 _ (λ _ _ → squash) ∣ refl ∣)
S¹Hopf = hopfS¹.Hopf
E* = hopfS¹.TotalSpacePush²'
IsoE*join = hopfS¹.joinIso₂
IsoTotalHopf' = hopfS¹.joinIso₁
CP² = hopfS¹.TotalSpaceHopfPush²
fibr = hopfS¹.P
TotalHopf' : Type _
TotalHopf' = Σ (S₊ 2) S¹Hopf
IsoJoins : (join S¹ (join S¹ S¹)) ≡ join S¹ (S₊ 3)
IsoJoins = cong (join S¹) (isoToPath (IsoSphereJoin 1 1))
-- CP² is 1-connected
conCP² : (x y : CP²) → ∥ x ≡ y ∥₂
conCP² x y = sRec2 squash₂ (λ p q → ∣ p ∙ sym q ∣₂) (conCP²' x) (conCP²' y)
where
conCP²' : (x : CP²) → ∥ x ≡ inl tt ∥₂
conCP²' (inl x) = ∣ refl ∣₂
conCP²' (inr x) = sphereElim 1 {A = λ x → ∥ inr x ≡ inl tt ∥₂}
(λ _ → squash₂) ∣ sym (push (inl base)) ∣₂ x
conCP²' (push a i) = main a i
where
indLem : ∀ {ℓ} {A : hopfS¹.TotalSpaceHopfPush → Type ℓ}
→ ((a : _) → isProp (A a))
→ A (inl base)
→ ((a : hopfS¹.TotalSpaceHopfPush) → A a)
indLem {A = A} p b =
PushoutToProp p
(sphereElim 0 (λ _ → p _) b)
(sphereElim 0 (λ _ → p _) (subst A (push (base , base)) b))
main : (a : hopfS¹.TotalSpaceHopfPush)
→ PathP (λ i → ∥ Path CP² (push a i) (inl tt) ∥₂)
(conCP²' (inl tt)) (conCP²' (inr (hopfS¹.induced a)))
main = indLem (λ _ → isOfHLevelPathP' 1 squash₂ _ _)
λ j → ∣ (λ i → push (inl base) (~ i ∧ j)) ∣₂
module GysinS² = Gysin (CP² , inl tt) fibr conCP² 2 idIso refl
E'S⁴Iso : Iso GysinS².E' (S₊ 5)
E'S⁴Iso =
compIso IsoE*join
(compIso (Iso→joinIso idIso (IsoSphereJoin 1 1))
(IsoSphereJoin 1 3))
isContrH³E : isContr (coHom 3 (GysinS².E'))
isContrH³E =
subst isContr (sym (isoToPath
(fst (Hⁿ-Sᵐ≅0 2 4
λ p → snotz (sym (cong (predℕ ∘ predℕ) p)))))
∙ cong (coHom 3) (sym (isoToPath E'S⁴Iso)))
isContrUnit
isContrH⁴E : isContr (coHom 4 (GysinS².E'))
isContrH⁴E =
subst isContr (sym (isoToPath
(fst (Hⁿ-Sᵐ≅0 3 4
λ p → snotz (sym (cong (predℕ ∘ predℕ ∘ predℕ) p)))))
∙ cong (coHom 4) (sym (isoToPath E'S⁴Iso)))
isContrUnit
-- We will need a bunch of elimination principles
joinS¹S¹→Groupoid : ∀ {ℓ} (P : join S¹ S¹ → Type ℓ)
→ ((x : _) → isGroupoid (P x))
→ P (inl base)
→ (x : _) → P x
joinS¹S¹→Groupoid P grp b =
transport (λ i → (x : (isoToPath (invIso (IsoSphereJoin 1 1))) i)
→ P (transp (λ j → isoToPath (invIso (IsoSphereJoin 1 1)) (i ∨ j)) i x))
(sphereElim _ (λ _ → grp _) b)
TotalHopf→Gpd : ∀ {ℓ} (P : hopfS¹.TotalSpaceHopfPush → Type ℓ)
→ ((x : _) → isGroupoid (P x))
→ P (inl base)
→ (x : _) → P x
TotalHopf→Gpd P grp b =
transport (λ i → (x : sym (isoToPath IsoTotalHopf') i)
→ P (transp (λ j → isoToPath IsoTotalHopf' (~ i ∧ ~ j)) i x))
(joinS¹S¹→Groupoid _ (λ _ → grp _) b)
TotalHopf→Gpd' : ∀ {ℓ} (P : Σ (S₊ 2) hopfS¹.Hopf → Type ℓ)
→ ((x : _) → isGroupoid (P x))
→ P (north , base)
→ (x : _) → P x
TotalHopf→Gpd' P grp b =
transport (λ i → (x : ua (_ , hopfS¹.isEquivTotalSpaceHopfPush→TotalSpace) i)
→ P (transp (λ j → ua (_ , hopfS¹.isEquivTotalSpaceHopfPush→TotalSpace)
(i ∨ j)) i x))
(TotalHopf→Gpd _ (λ _ → grp _) b)
CP²→Groupoid : ∀ {ℓ} {P : CP² → Type ℓ}
→ ((x : _) → is2Groupoid (P x))
→ (b : P (inl tt))
→ (s2 : ((x : _) → P (inr x)))
→ PathP (λ i → P (push (inl base) i)) b (s2 north)
→ (x : _) → P x
CP²→Groupoid {P = P} grp b s2 pp (inl x) = b
CP²→Groupoid {P = P} grp b s2 pp (inr x) = s2 x
CP²→Groupoid {P = P} grp b s2 pp (push a i₁) = lem a i₁
where
lem : (a : hopfS¹.TotalSpaceHopfPush) → PathP (λ i → P (push a i)) b (s2 _)
lem = TotalHopf→Gpd _ (λ _ → isOfHLevelPathP' 3 (grp _) _ _) pp
-- The function inducing the iso H²(S²) ≅ H²(CP²)
H²S²→H²CP²-raw : (S₊ 2 → coHomK 2) → (CP² → coHomK 2)
H²S²→H²CP²-raw f (inl x) = 0ₖ _
H²S²→H²CP²-raw f (inr x) = f x -ₖ f north
H²S²→H²CP²-raw f (push a i) =
TotalHopf→Gpd (λ x → 0ₖ 2
≡ f (hopfS¹.TotalSpaceHopfPush→TotalSpace x .fst) -ₖ f north)
(λ _ → isOfHLevelTrunc 4 _ _)
(sym (rCancelₖ 2 (f north)))
a i
H²S²→H²CP² : coHomGr 2 (S₊ 2) .fst → coHomGr 2 CP² .fst
H²S²→H²CP² = sMap H²S²→H²CP²-raw
cancel-H²S²→H²CP² : (f : CP² → coHomK 2)
→ ∥ H²S²→H²CP²-raw (f ∘ inr) ≡ f ∥
cancel-H²S²→H²CP² f =
pRec squash
(λ p → pRec squash
(λ f → ∣ funExt f ∣)
(cancelLem p))
(connLem (f (inl tt)))
where
connLem : (x : coHomK 2) → ∥ x ≡ 0ₖ 2 ∥
connLem = coHomK-elim _ (λ _ → isOfHLevelSuc 1 squash) ∣ refl ∣
cancelLem : (p : f (inl tt) ≡ 0ₖ 2)
→ ∥ ((x : CP²) → H²S²→H²CP²-raw (f ∘ inr) x ≡ f x) ∥
cancelLem p = trRec squash (λ pp →
∣ CP²→Groupoid (λ _ → isOfHLevelPath 4 (isOfHLevelTrunc 4) _ _)
(sym p)
(λ x → (λ i → f (inr x) -ₖ f (push (inl base) (~ i)))
∙∙ (λ i → f (inr x) -ₖ p i)
∙∙ rUnitₖ 2 (f (inr x))) pp ∣)
help
where
help :
hLevelTrunc 1
(PathP (λ i₁ → H²S²→H²CP²-raw (f ∘ inr) (push (inl base) i₁)
≡ f (push (inl base) i₁))
(sym p)
(((λ i₁ → f (inr north) -ₖ f (push (inl base) (~ i₁))) ∙∙
(λ i₁ → f (inr north) -ₖ p i₁) ∙∙ rUnitₖ 2 (f (inr north)))))
help = isConnectedPathP 1 (isConnectedPath 2 (isConnectedKn 1) _ _) _ _ .fst
H²CP²≅H²S² : GroupIso (coHomGr 2 CP²) (coHomGr 2 (S₊ 2))
Iso.fun (fst H²CP²≅H²S²) = sMap (_∘ inr)
Iso.inv (fst H²CP²≅H²S²) = H²S²→H²CP²
Iso.rightInv (fst H²CP²≅H²S²) =
sElim (λ _ → isOfHLevelPath 2 squash₂ _ _)
λ f → trRec {B = Iso.fun (fst H²CP²≅H²S²) (Iso.inv (fst H²CP²≅H²S²) ∣ f ∣₂)
≡ ∣ f ∣₂}
(isOfHLevelPath 2 squash₂ _ _)
(λ p → cong ∣_∣₂ (funExt λ x → cong (λ y → (f x) -ₖ y) p ∙ rUnitₖ 2 (f x)))
(Iso.fun (PathIdTruncIso _)
(isContr→isProp (isConnectedKn 1) ∣ f north ∣ ∣ 0ₖ 2 ∣))
Iso.leftInv (fst H²CP²≅H²S²) =
sElim (λ _ → isOfHLevelPath 2 squash₂ _ _)
λ f → pRec (squash₂ _ _) (cong ∣_∣₂) (cancel-H²S²→H²CP² f)
snd H²CP²≅H²S² =
makeIsGroupHom
(sElim2 (λ _ _ → isOfHLevelPath 2 squash₂ _ _) λ f g → refl)
H²CP²≅ℤ : GroupIso (coHomGr 2 CP²) ℤGroup
H²CP²≅ℤ = compGroupIso H²CP²≅H²S² (Hⁿ-Sⁿ≅ℤ 1)
-- ⌣ gives a groupEquiv H²(CP²) ≃ H⁴(CP²)
⌣Equiv : GroupEquiv (coHomGr 2 CP²) (coHomGr 4 CP²)
fst (fst ⌣Equiv) = GysinS².⌣-hom 2 .fst
snd (fst ⌣Equiv) = isEq⌣
where
isEq⌣ : isEquiv (GysinS².⌣-hom 2 .fst)
isEq⌣ =
SES→isEquiv
(GroupPath _ _ .fst (invGroupEquiv
(isContr→≃Unit isContrH³E
, makeIsGroupHom λ _ _ → refl)))
(GroupPath _ _ .fst (invGroupEquiv
(isContr→≃Unit isContrH⁴E
, makeIsGroupHom λ _ _ → refl)))
(GysinS².susp∘ϕ 1)
(GysinS².⌣-hom 2)
(GysinS².p-hom 4)
(GysinS².Ker-⌣e⊂Im-Susp∘ϕ _)
(GysinS².Ker-p⊂Im-⌣e _)
snd ⌣Equiv = GysinS².⌣-hom 2 .snd
-- The generator of H²(CP²)
genCP² : coHom 2 CP²
genCP² = ∣ CP²→Groupoid (λ _ → isOfHLevelTrunc 4)
(0ₖ _)
∣_∣
refl ∣₂
inrInjective : (f g : CP² → coHomK 2) → ∥ f ∘ inr ≡ g ∘ inr ∥
→ Path (coHom 2 CP²) ∣ f ∣₂ ∣ g ∣₂
inrInjective f g = pRec (squash₂ _ _)
(λ p → pRec (squash₂ _ _) (λ id → trRec (squash₂ _ _)
(λ pp → cong ∣_∣₂
(funExt (CP²→Groupoid
(λ _ → isOfHLevelPath 4 (isOfHLevelTrunc 4) _ _)
id
(funExt⁻ p)
(compPathR→PathP pp))))
(conn2 (f (inl tt)) (g (inl tt)) id
(cong f (push (inl base))
∙ (funExt⁻ p north) ∙ cong g (sym (push (inl base))))))
(conn (f (inl tt)) (g (inl tt))))
where
conn : (x y : coHomK 2) → ∥ x ≡ y ∥
conn = coHomK-elim _ (λ _ → isSetΠ λ _ → isOfHLevelSuc 1 squash)
(coHomK-elim _ (λ _ → isOfHLevelSuc 1 squash) ∣ refl ∣)
conn2 : (x y : coHomK 2) (p q : x ≡ y) → hLevelTrunc 1 (p ≡ q)
conn2 x y p q =
Iso.fun (PathIdTruncIso _)
(isContr→isProp (isConnectedPath _ (isConnectedKn 1) x y) ∣ p ∣ ∣ q ∣)
-- A couple of basic lemma concerning the hSpace structure on S¹
private
invLooperLem₁ : (a x : S¹)
→ (invEq (hopfS¹.μ-eq a) x) * a ≡ (invLooper a * x) * a
invLooperLem₁ a x =
secEq (hopfS¹.μ-eq a) x
∙∙ cong (_* x) (rCancelS¹ a)
∙∙ AssocHSpace.μ-assoc S1-AssocHSpace a (invLooper a) x
∙ commS¹ _ _
invLooperLem₂ : (a x : S¹) → invEq (hopfS¹.μ-eq a) x ≡ invLooper a * x
invLooperLem₂ a x = sym (retEq (hopfS¹.μ-eq a) (invEq (hopfS¹.μ-eq a) x))
∙∙ cong (invEq (hopfS¹.μ-eq a)) (invLooperLem₁ a x)
∙∙ retEq (hopfS¹.μ-eq a) (invLooper a * x)
rotLoop² : (a : S¹) → Path (a ≡ a) (λ i → rotLoop (rotLoop a i) (~ i)) refl
rotLoop² =
sphereElim 0 (λ _ → isGroupoidS¹ _ _ _ _)
λ i j → hcomp (λ {k → λ { (i = i1) → base
; (j = i0) → base
; (j = i1) → base}})
base
-- We prove that the generator of CP² given by Gysin is the same one
-- as genCP², which is much easier to work with
Gysin-e≡genCP² : GysinS².e ≡ genCP²
Gysin-e≡genCP² =
inrInjective _ _ ∣ funExt (λ x → funExt⁻ (cong fst (main x)) south) ∣
where
mainId : (x : Σ (S₊ 2) hopfS¹.Hopf)
→ Path (hLevelTrunc 4 _) ∣ fst x ∣ ∣ north ∣
mainId = uncurry λ { north → λ y → cong ∣_∣ₕ (merid base ∙ sym (merid y))
; south → λ y → cong ∣_∣ₕ (sym (merid y))
; (merid a i) → main a i}
where
main : (a : S¹) → PathP (λ i → (y : hopfS¹.Hopf (merid a i))
→ Path (HubAndSpoke (Susp S¹) 3) ∣ merid a i ∣ ∣ north ∣)
(λ y → cong ∣_∣ₕ (merid base ∙ sym (merid y)))
λ y → cong ∣_∣ₕ (sym (merid y))
main a =
toPathP
(funExt λ x →
cong (transport (λ i₁
→ Path (HubAndSpoke (Susp S¹) 3) ∣ merid a i₁ ∣ ∣ north ∣))
((λ i → (λ z → cong ∣_∣ₕ
(merid base
∙ sym (merid (transport
(λ j → uaInvEquiv (hopfS¹.μ-eq a) (~ i) j) x))) z))
∙ λ i → cong ∣_∣ₕ (merid base
∙ sym (merid (transportRefl (invEq (hopfS¹.μ-eq a) x) i))))
∙∙ (λ i → transp (λ i₁ → Path (HubAndSpoke (Susp S¹) 3)
∣ merid a (i₁ ∨ i) ∣ ∣ north ∣) i
(compPath-filler' (cong ∣_∣ₕ (sym (merid a)))
(cong ∣_∣ₕ (merid base
∙ sym (merid (invLooperLem₂ a x i)))) i))
∙∙ cong ((cong ∣_∣ₕ) (sym (merid a)) ∙_)
(cong (cong ∣_∣ₕ) (cong sym (symDistr (merid base)
(sym (merid (invLooper a * x)))))
∙ cong sym (SuspS¹-hom (invLooper a) x)
∙ symDistr ((cong ∣_∣ₕ) (merid (invLooper a) ∙ sym (merid base)))
((cong ∣_∣ₕ) (merid x ∙ sym (merid base)))
∙ isCommΩK 2 (sym (λ i₁ → ∣ (merid x
∙ (λ i₂ → merid base (~ i₂))) i₁ ∣))
(sym (λ i₁ → ∣ (merid (invLooper a)
∙ (λ i₂ → merid base (~ i₂))) i₁ ∣))
∙ cong₂ _∙_ (cong sym (SuspS¹-inv a)
∙ cong-∙ ∣_∣ₕ (merid a) (sym (merid base)))
(cong (cong ∣_∣ₕ) (symDistr (merid x) (sym (merid base)))
∙ cong-∙ ∣_∣ₕ (merid base) (sym (merid x))))
∙∙ (λ j → (λ i₁ → ∣ merid a (~ i₁ ∨ j) ∣) ∙ ((λ i₁ → ∣ merid a (i₁ ∨ j) ∣)
∙ (λ i₁ → ∣ merid base (~ i₁ ∨ j) ∣))
∙ (λ i₁ → ∣ merid base (i₁ ∨ j) ∣)
∙ (λ i₁ → ∣ merid x (~ i₁) ∣ₕ))
∙∙ sym (lUnit _)
∙∙ sym (assoc _ _ _)
∙∙ (sym (lUnit _) ∙ sym (lUnit _) ∙ sym (lUnit _)))
gen' : (x : S₊ 2) → preThom.Q (CP² , inl tt) fibr (inr x) →∙ coHomK-ptd 2
fst (gen' x) north = ∣ north ∣
fst (gen' x) south = ∣ x ∣
fst (gen' x) (merid a i₁) = mainId (x , a) (~ i₁)
snd (gen' x) = refl
gen'Id : GysinS².c (inr north) .fst ≡ gen' north .fst
gen'Id = cong fst (GysinS².cEq (inr north) ∣ push (inl base) ∣₂)
∙ (funExt lem)
where
lem : (qb : _) →
∣ (subst (fst ∘ preThom.Q (CP² , inl tt) fibr)
(sym (push (inl base))) qb) ∣
≡ gen' north .fst qb
lem north = refl
lem south = cong ∣_∣ₕ (sym (merid base))
lem (merid a i) j =
hcomp (λ k →
λ { (i = i0) → ∣ merid a (~ k ∧ j) ∣
; (i = i1) → ∣ merid base (~ j) ∣
; (j = i0) → ∣ transportRefl (merid a i) (~ k) ∣
; (j = i1) → ∣ compPath-filler
(merid base) (sym (merid a)) k (~ i) ∣ₕ})
(hcomp (λ k →
λ { (i = i0) → ∣ merid a (j ∨ ~ k) ∣
; (i = i1) → ∣ merid base (~ j ∨ ~ k) ∣
; (j = i0) → ∣ merid a (~ k ∨ i) ∣
; (j = i1) → ∣ merid base (~ i ∨ ~ k) ∣ₕ})
∣ south ∣)
setHelp : (x : S₊ 2)
→ isSet (preThom.Q (CP² , inl tt) fibr (inr x) →∙ coHomK-ptd 2)
setHelp = sphereElim _ (λ _ → isProp→isOfHLevelSuc 1 (isPropIsOfHLevel 2))
(isOfHLevel↑∙' 0 1)
main : (x : S₊ 2) → (GysinS².c (inr x) ≡ gen' x)
main = sphereElim _ (λ x → isOfHLevelPath 2 (setHelp x) _ _)
(→∙Homogeneous≡ (isHomogeneousKn _) gen'Id)
isGenerator≃ℤ : ∀ {ℓ} (G : Group ℓ) (g : fst G) → Type ℓ
isGenerator≃ℤ G g =
Σ[ e ∈ GroupIso G ℤGroup ] abs (Iso.fun (fst e) g) ≡ 1
isGenerator≃ℤ-e : isGenerator≃ℤ (coHomGr 2 CP²) GysinS².e
isGenerator≃ℤ-e =
subst (isGenerator≃ℤ (coHomGr 2 CP²)) (sym Gysin-e≡genCP²)
(H²CP²≅ℤ , refl)
-- Alternative definition of the hopfMap
HopfMap' : S₊ 3 → S₊ 2
HopfMap' x =
hopfS¹.TotalSpaceHopfPush→TotalSpace
(Iso.inv IsoTotalHopf'
(Iso.inv (IsoSphereJoin 1 1) x)) .fst
hopfMap≡HopfMap' : HopfMap ≡ (HopfMap' , refl)
hopfMap≡HopfMap' =
ΣPathP ((funExt (λ x →
cong (λ x → JoinS¹S¹→TotalHopf x .fst)
(sym (Iso.rightInv IsoTotalHopf'
(Iso.inv (IsoSphereJoin 1 1) x)))
∙ sym (lem (Iso.inv IsoTotalHopf'
(Iso.inv (IsoSphereJoin 1 1) x)))))
, flipSquare (sym (rUnit refl) ◁ λ _ _ → north))
where
lem : (x : _) → hopfS¹.TotalSpaceHopfPush→TotalSpace x .fst
≡ JoinS¹S¹→TotalHopf (Iso.fun IsoTotalHopf' x) .fst
lem (inl x) = refl
lem (inr x) = refl
lem (push (base , snd₁) i) = refl
lem (push (loop i₁ , a) i) k = merid (rotLoop² a (~ k) i₁) i
CP²' : Type _
CP²' = Pushout {A = S₊ 3} (λ _ → tt) HopfMap'
PushoutReplaceBase : ∀ {ℓ ℓ' ℓ''} {A B : Type ℓ} {C : Type ℓ'} {D : Type ℓ''}
{f : A → C} {g : A → D} (e : B ≃ A)
→ Pushout (f ∘ fst e) (g ∘ fst e) ≡ Pushout f g
PushoutReplaceBase {f = f} {g = g} =
EquivJ (λ _ e → Pushout (f ∘ fst e) (g ∘ fst e) ≡ Pushout f g) refl
CP2≡CP²' : CP²' ≡ CP²
CP2≡CP²' =
PushoutReplaceBase
(isoToEquiv (compIso (invIso (IsoSphereJoin 1 1)) (invIso IsoTotalHopf')))
-- packaging everything up:
⌣equiv→pres1 : ∀ {ℓ} {G H : Type ℓ} → (G ≡ H)
→ (g₁ : coHom 2 G) (h₁ : coHom 2 H)
→ (fstEq : (Σ[ ϕ ∈ GroupEquiv (coHomGr 2 G) ℤGroup ]
abs (fst (fst ϕ) g₁) ≡ 1))
→ (sndEq : ((Σ[ ϕ ∈ GroupEquiv (coHomGr 2 H) ℤGroup ]
abs (fst (fst ϕ) h₁) ≡ 1)))
→ isEquiv {A = coHom 2 G} {B = coHom 4 G} (_⌣ g₁)
→ (3rdEq : GroupEquiv (coHomGr 4 H) ℤGroup)
→ abs (fst (fst 3rdEq) (h₁ ⌣ h₁)) ≡ 1
⌣equiv→pres1 {G = G} = J (λ H _ → (g₁ : coHom 2 G) (h₁ : coHom 2 H)
→ (fstEq : (Σ[ ϕ ∈ GroupEquiv (coHomGr 2 G) ℤGroup ]
abs (fst (fst ϕ) g₁) ≡ 1))
→ (sndEq : ((Σ[ ϕ ∈ GroupEquiv (coHomGr 2 H) ℤGroup ]
abs (fst (fst ϕ) h₁) ≡ 1)))
→ isEquiv {A = coHom 2 G} {B = coHom 4 G} (_⌣ g₁)
→ (3rdEq : GroupEquiv (coHomGr 4 H) ℤGroup)
→ abs (fst (fst 3rdEq) (h₁ ⌣ h₁)) ≡ 1)
help
where
help : (g₁ h₁ : coHom 2 G)
→ (fstEq : (Σ[ ϕ ∈ GroupEquiv (coHomGr 2 G) ℤGroup ]
abs (fst (fst ϕ) g₁) ≡ 1))
→ (sndEq : ((Σ[ ϕ ∈ GroupEquiv (coHomGr 2 G) ℤGroup ]
abs (fst (fst ϕ) h₁) ≡ 1)))
→ isEquiv {A = coHom 2 G} {B = coHom 4 G} (_⌣ g₁)
→ (3rdEq : GroupEquiv (coHomGr 4 G) ℤGroup)
→ abs (fst (fst 3rdEq) (h₁ ⌣ h₁)) ≡ 1
help g h (ϕ , idg) (ψ , idh) ⌣eq ξ =
⊎→abs _ _
(groupEquivPresGen _
(compGroupEquiv main (compGroupEquiv (invGroupEquiv main) ψ))
h (abs→⊎ _ _ (cong abs (cong (fst (fst ψ)) (retEq (fst main) h))
∙ idh)) (compGroupEquiv main ξ))
where
lem₁ : ((fst (fst ψ) h) ≡ 1) ⊎ (fst (fst ψ) h ≡ -1)
→ abs (fst (fst ϕ) h) ≡ 1
lem₁ p = ⊎→abs _ _ (groupEquivPresGen _ ψ h p ϕ)
lem₂ : ((fst (fst ϕ) h) ≡ 1) ⊎ (fst (fst ϕ) h ≡ -1)
→ ((fst (fst ϕ) g) ≡ 1) ⊎ (fst (fst ϕ) g ≡ -1)
→ (h ≡ g) ⊎ (h ≡ (-ₕ g))
lem₂ (inl x) (inl x₁) =
inl (sym (retEq (fst ϕ) h)
∙∙ cong (invEq (fst ϕ)) (x ∙ sym x₁)
∙∙ retEq (fst ϕ) g)
lem₂ (inl x) (inr x₁) =
inr (sym (retEq (fst ϕ) h)
∙∙ cong (invEq (fst ϕ)) x
∙ IsGroupHom.presinv (snd (invGroupEquiv ϕ)) (negsuc zero)
∙∙ cong (-ₕ_) (cong (invEq (fst ϕ)) (sym x₁) ∙ (retEq (fst ϕ) g)))
lem₂ (inr x) (inl x₁) =
inr (sym (retEq (fst ϕ) h)
∙∙ cong (invEq (fst ϕ)) x
∙∙ (IsGroupHom.presinv (snd (invGroupEquiv ϕ)) 1
∙ cong (-ₕ_) (cong (invEq (fst ϕ)) (sym x₁) ∙ (retEq (fst ϕ) g))))
lem₂ (inr x) (inr x₁) =
inl (sym (retEq (fst ϕ) h)
∙∙ cong (invEq (fst ϕ)) (x ∙ sym x₁)
∙∙ retEq (fst ϕ) g)
-ₕeq : ∀ {ℓ} {A : Type ℓ} (n : ℕ) → Iso (coHom n A) (coHom n A)
Iso.fun (-ₕeq n) = -ₕ_
Iso.inv (-ₕeq n) = -ₕ_
Iso.rightInv (-ₕeq n) =
sElim (λ _ → isOfHLevelPath 2 squash₂ _ _)
λ f → cong ∣_∣₂ (funExt λ x → -ₖ^2 (f x))
Iso.leftInv (-ₕeq n) =
sElim (λ _ → isOfHLevelPath 2 squash₂ _ _)
λ f → cong ∣_∣₂ (funExt λ x → -ₖ^2 (f x))
theEq : coHom 2 G ≃ coHom 4 G
theEq = compEquiv (_ , ⌣eq) (isoToEquiv (-ₕeq 4))
lem₃ : (h ≡ g) ⊎ (h ≡ (-ₕ g)) → isEquiv {A = coHom 2 G} (_⌣ h)
lem₃ (inl x) = subst isEquiv (λ i → _⌣ (x (~ i))) ⌣eq
lem₃ (inr x) =
subst isEquiv (funExt (λ x → -ₕDistᵣ 2 2 x g) ∙ (λ i → _⌣ (x (~ i))))
(theEq .snd)
main : GroupEquiv (coHomGr 2 G) (coHomGr 4 G)
fst main = _ ,
(lem₃ (lem₂ (abs→⊎ _ _ (lem₁ (abs→⊎ _ _ idh))) (abs→⊎ _ _ idg)))
snd main =
makeIsGroupHom λ g1 g2 → rightDistr-⌣ _ _ g1 g2 h
-- The hopf invariant is ±1 for both definitions of the hopf map
HopfInvariant-HopfMap' :
abs (HopfInvariant zero (HopfMap' , λ _ → HopfMap' (snd (S₊∙ 3)))) ≡ 1
HopfInvariant-HopfMap' =
cong abs (cong (Iso.fun (fst (Hopfβ-Iso zero (HopfMap' , refl))))
(transportRefl (⌣-α 0 (HopfMap' , refl))))
∙ ⌣equiv→pres1 (sym CP2≡CP²')
GysinS².e (Hopfα zero (HopfMap' , refl))
(l isGenerator≃ℤ-e)
(GroupIso→GroupEquiv (Hopfα-Iso 0 (HopfMap' , refl)) , refl)
(snd (fst ⌣Equiv))
(GroupIso→GroupEquiv (Hopfβ-Iso zero (HopfMap' , refl)))
where
l : Σ[ ϕ ∈ GroupIso (coHomGr 2 CP²) ℤGroup ]
(abs (Iso.fun (fst ϕ) GysinS².e) ≡ 1)
→ Σ[ ϕ ∈ GroupEquiv (coHomGr 2 CP²) ℤGroup ]
(abs (fst (fst ϕ) GysinS².e) ≡ 1)
l p = (GroupIso→GroupEquiv (fst p)) , (snd p)
HopfInvariant-HopfMap : abs (HopfInvariant zero HopfMap) ≡ 1
HopfInvariant-HopfMap = cong abs (cong (HopfInvariant zero) hopfMap≡HopfMap')
∙ HopfInvariant-HopfMap'
| 39.505357
| 81
| 0.527596
|
2f4128c059f745d163a9439810b4ba6c9fa46e3d
| 499
|
agda
|
Agda
|
Data/Collection/Core/Properties.agda
|
banacorn/lambda-calculus
|
f81b116473582ab7956adc4bf1d7ebf1ae2a213a
|
[
"MIT"
] | null | null | null |
Data/Collection/Core/Properties.agda
|
banacorn/lambda-calculus
|
f81b116473582ab7956adc4bf1d7ebf1ae2a213a
|
[
"MIT"
] | null | null | null |
Data/Collection/Core/Properties.agda
|
banacorn/lambda-calculus
|
f81b116473582ab7956adc4bf1d7ebf1ae2a213a
|
[
"MIT"
] | null | null | null |
module Data.Collection.Core.Properties where
-- open import Data.List public using (List; []; _∷_)
-- open import Data.String public using (String; _≟_)
-- open import Level using (zero)
--
-- open import Function using (flip)
-- open import Relation.Nullary
-- open import Relation.Nullary.Negation
-- open import Relation.Nullary.Decidable renaming (map to mapDec; map′ to mapDec′)
-- open import Relation.Unary
-- open import Relation.Binary
-- open import Relation.Binary.PropositionalEquality
| 35.642857
| 83
| 0.757515
|
dc3f6dce94cefdfc7062b20d27295672b88e575a
| 1,929
|
agda
|
Agda
|
src/Logic.agda
|
acallesalda/setform
|
4ab3c1a8bfd679cb3ced25500aa8103cb6c4b1f4
|
[
"MIT"
] | 3
|
2019-08-02T23:13:13.000Z
|
2022-01-06T20:04:13.000Z
|
src/Logic.agda
|
acallesalda/setform
|
4ab3c1a8bfd679cb3ced25500aa8103cb6c4b1f4
|
[
"MIT"
] | null | null | null |
src/Logic.agda
|
acallesalda/setform
|
4ab3c1a8bfd679cb3ced25500aa8103cb6c4b1f4
|
[
"MIT"
] | null | null | null |
-----------------------------------
-- First order logic
-----------------------------------
module Logic where
infix 4 _,_
infix 3 ¬_
infix 1 _∧_
infix 1 _∨_
infix 0 _⇔_
-- Some First order logic I need.
-- ∧ data type (conjunction).
data _∧_ (A B : Set) : Set where
_,_ : A → B → A ∧ B
∧-proj₁ : ∀ {A B} → A ∧ B → A
∧-proj₁ (a , _) = a
∧-proj₂ : ∀ {A B} → A ∧ B → B
∧-proj₂ (_ , b) = b
-- ∨ data type (disjunction), with many useful properties.
data _∨_ (A B : Set) : Set where
inj₁ : A → A ∨ B
inj₂ : B → A ∨ B
∨-e : (A B C : Set) → A ∨ B → (A → C) → (B → C) → C
∨-e A B C (inj₁ a) i₁ i₂ = i₁ a
∨-e A B C (inj₂ b) i₁ i₂ = i₂ b
∨-sym : (A B : Set) → A ∨ B → B ∨ A
∨-sym A B (inj₁ a) = inj₂ a
∨-sym A B (inj₂ b) = inj₁ b
trivial : (A : Set) → A → A
trivial _ A = A
∨-idem : (A : Set) → A ∨ A → A
∨-idem A (inj₁ a) = a
∨-idem A (inj₂ a) = a
∨-prop₁ : {A B C : Set} → (A ∨ B → C) → A → C
∨-prop₁ i a = i (inj₁ a)
∨-prop₂ : {A B C : Set} → (A ∨ B → C) → B → C
∨-prop₂ i b = i (inj₂ b)
∨-prop₃ : {A B C : Set} → A ∨ B → (A → C) → C ∨ B
∨-prop₃ (inj₁ x) i = inj₁ (i x)
∨-prop₃ (inj₂ x) i = inj₂ x
∨-prop₄ : {A B C : Set} → A ∨ B → (B → C) → A ∨ C
∨-prop₄ (inj₁ x) x₁ = inj₁ x
∨-prop₄ (inj₂ x) x₁ = inj₂ (x₁ x)
∨-prop₅ : {A B C D : Set} → A ∨ B → (A → C) → (B → D) → C ∨ D
∨-prop₅ (inj₁ a) a→c b→d = inj₁ (a→c a)
∨-prop₅ (inj₂ b) a→c b→d = inj₂ (b→d b)
∨-∧ : {A B : Set} → (A ∧ B) ∨ (B ∧ A) → A ∧ B
∨-∧ (inj₁ (a , b)) = a , b
∨-∧ (inj₂ (b , a)) = a , b
-- Bi-implication.
_⇔_ : Set → Set → Set
A ⇔ B = (A → B) ∧ (B → A)
⇔-p : (A B C : Set) → A ⇔ (B ∧ C) → (C → B) → A ⇔ C
⇔-p A B C (h₁ , h₂) h₃ = prf₁ , prf₂
where
prf₁ : A → C
prf₁ A = ∧-proj₂ (h₁ A)
prf₂ : C → A
prf₂ C = h₂ ((h₃ C) , C)
-- Empty data type.
data ⊥ : Set where
⊥-elim : {A : Set} → ⊥ → A
⊥-elim ()
data ⊤ : Set where
<> : ⊤
-- Negation
¬_ : Set → Set
¬ A = A → ⊥
cont : (A : Set) → A ∧ ¬ A → ⊥
cont _ (x , ¬x) = ¬x x
| 19.29
| 61
| 0.43183
|
13671053f87694bb9e1eacd14669f651cc2492aa
| 2,814
|
agda
|
Agda
|
Categories/FunctorCategory.agda
|
copumpkin/categories
|
36f4181d751e2ecb54db219911d8c69afe8ba892
|
[
"BSD-3-Clause"
] | 98
|
2015-04-15T14:57:33.000Z
|
2022-03-08T05:20:36.000Z
|
Categories/FunctorCategory.agda
|
p-pavel/categories
|
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
|
[
"BSD-3-Clause"
] | 19
|
2015-05-23T06:47:10.000Z
|
2019-08-09T16:31:40.000Z
|
Categories/FunctorCategory.agda
|
p-pavel/categories
|
e41aef56324a9f1f8cf3cd30b2db2f73e01066f2
|
[
"BSD-3-Clause"
] | 23
|
2015-02-05T13:03:09.000Z
|
2021-11-11T13:50:56.000Z
|
{-# OPTIONS --universe-polymorphism #-}
module Categories.FunctorCategory where
open import Data.Product
open import Categories.Category
import Categories.Functor as Cat
open import Categories.Functor hiding (equiv; id; _∘_; _≡_)
open import Categories.NaturalTransformation
open import Categories.Product
open import Categories.Square
Functors : ∀ {o ℓ e} {o′ ℓ′ e′} → Category o ℓ e → Category o′ ℓ′ e′ → Category _ _ _
Functors C D = record
{ Obj = Functor C D
; _⇒_ = NaturalTransformation
; _≡_ = _≡_
; _∘_ = _∘₁_
; id = id
; assoc = λ {_} {_} {_} {_} {f} {g} {h} → assoc₁ {X = f} {g} {h}
; identityˡ = λ {_} {_} {f} → identity₁ˡ {X = f}
; identityʳ = λ {_} {_} {f} → identity₁ʳ {X = f}
; equiv = λ {F} {G} → equiv {F = F} {G = G}
; ∘-resp-≡ = λ {_} {_} {_} {f} {h} {g} {i} → ∘₁-resp-≡ {f = f} {h} {g} {i}
}
eval : ∀ {o ℓ e} {o′ ℓ′ e′} {C : Category o ℓ e}{D : Category o′ ℓ′ e′} → Functor (Product (Functors C D) C) D
eval {C = C} {D = D} =
record {
F₀ = λ x → let F , c = x in F₀ F c;
F₁ = λ { {F , c₁} {G , c₂} (ε , f) → F₁ G f D.∘ η ε _};
identity = λ { {F , c} → begin
F₁ F C.id D.∘ D.id ↓⟨ D.identityʳ ⟩
F₁ F C.id ↓⟨ identity F ⟩
D.id ∎};
homomorphism = λ { {F , c₁} {G , c₂} {H , c₃} {ε₁ , f₁} {ε₂ , f₂} →
begin
F₁ H (f₂ C.∘ f₁) D.∘ η ε₂ c₁ D.∘ η ε₁ c₁ ↑⟨ D.assoc ⟩
(F₁ H (f₂ C.∘ f₁) D.∘ η ε₂ c₁) D.∘ η ε₁ c₁
↓⟨ D.∘-resp-≡ˡ (begin
F₁ H (C [ f₂ ∘ f₁ ]) D.∘ η ε₂ c₁ ↓⟨ D.∘-resp-≡ˡ (homomorphism H) ⟩
(F₁ H f₂ D.∘ F₁ H f₁) D.∘ η ε₂ c₁ ↓⟨ D.assoc ⟩
F₁ H f₂ D.∘ F₁ H f₁ D.∘ η ε₂ c₁ ↑⟨ D.∘-resp-≡ʳ (commute ε₂ f₁) ⟩
F₁ H f₂ D.∘ η ε₂ c₂ D.∘ F₁ G f₁ ↑⟨ D.assoc ⟩
(F₁ H f₂ D.∘ η ε₂ c₂) D.∘ F₁ G f₁ ∎)
⟩
((F₁ H f₂ D.∘ η ε₂ c₂) D.∘ F₁ G f₁) D.∘ η ε₁ c₁ ↓⟨ D.assoc ⟩
(F₁ H f₂ D.∘ η ε₂ c₂) D.∘ F₁ G f₁ D.∘ η ε₁ c₁ ∎ };
F-resp-≡ = λ { {F , c₁} {G , c₂} {ε₁ , f₁} {ε₂ , f₂} (ε₁≡ε₂ , f₁≡f₂)
→ D.∘-resp-≡ (F-resp-≡ G f₁≡f₂) ε₁≡ε₂} }
where
module C = Category C
module D = Category D
open Functor
open NaturalTransformation
open D.HomReasoning
Cat[-∘_] : ∀ {o₁ ℓ₁ e₁ o₂ ℓ₂ e₂ o₃ ℓ₃ e₃} {A : Category o₁ ℓ₁ e₁} {B : Category o₂ ℓ₂ e₂}
{C : Category o₃ ℓ₃ e₃} -> Functor A B -> Functor (Functors B C) (Functors A C)
Cat[-∘_] {C = C} r = record
{ F₀ = λ X → X Cat.∘ r
; F₁ = λ η → η ∘ʳ r
; identity = C.Equiv.refl
; homomorphism = C.Equiv.refl
; F-resp-≡ = λ x → x
}
where
module C = Category C
| 39.633803
| 110
| 0.453447
|
41b9608e6073594dcecf83d333dbdf60618583f4
| 1,052
|
agda
|
Agda
|
theorems/homotopy/RelativelyConstantToSetExtendsViaSurjection.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
theorems/homotopy/RelativelyConstantToSetExtendsViaSurjection.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
theorems/homotopy/RelativelyConstantToSetExtendsViaSurjection.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 50
|
2015-01-10T01:48:08.000Z
|
2022-02-14T03:03:25.000Z
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
import homotopy.ConstantToSetExtendsToProp as ConstExt
module homotopy.RelativelyConstantToSetExtendsViaSurjection
{i j k} {A : Type i} {B : Type j} {C : B → Type k}
{{_ : ∀ {b} → is-set (C b)}}
(f : A → B) (f-is-surj : is-surj f)
(g : (a : A) → C (f a))
(g-is-const : ∀ a₁ a₂ → (p : f a₁ == f a₂) → g a₁ == g a₂ [ C ↓ p ])
where
{-
(b : A) ----> [ hfiber f b ] ----?----> C ?
^
|
hfiber f b
-}
private
lemma : ∀ b → hfiber f b → C b
lemma b (a , fa=b) = transport C fa=b (g a)
lemma-const : ∀ b → (h₁ h₂ : hfiber f b) → lemma b h₁ == lemma b h₂
lemma-const ._ (a₁ , fa₁=fa₂) (a₂ , idp) =
to-transp (g-is-const a₁ a₂ fa₁=fa₂)
module CE (b : B) =
ConstExt {A = hfiber f b} {B = C b}
(lemma b) (lemma-const b)
ext : Π B C
ext b = CE.ext b (f-is-surj b)
β : (a : A) → ext (f a) == g a
β a = ap (CE.ext (f a))
(prop-has-all-paths (f-is-surj (f a)) [ a , idp ])
| 26.974359
| 71
| 0.481939
|
136980fe558d0dc65061016063fc98aee879ece2
| 7,066
|
agda
|
Agda
|
agda-stdlib/src/Relation/Binary/Bundles.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Relation/Binary/Bundles.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Relation/Binary/Bundles.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Bundles for homogeneous binary relations
------------------------------------------------------------------------
-- The contents of this module should be accessed via `Relation.Binary`.
{-# OPTIONS --without-K --safe #-}
module Relation.Binary.Bundles where
open import Level
open import Relation.Nullary using (¬_)
open import Relation.Binary.Core
open import Relation.Binary.Definitions
open import Relation.Binary.Structures
------------------------------------------------------------------------
-- Setoids
------------------------------------------------------------------------
record PartialSetoid a ℓ : Set (suc (a ⊔ ℓ)) where
field
Carrier : Set a
_≈_ : Rel Carrier ℓ
isPartialEquivalence : IsPartialEquivalence _≈_
open IsPartialEquivalence isPartialEquivalence public
_≉_ : Rel Carrier _
x ≉ y = ¬ (x ≈ y)
record Setoid c ℓ : Set (suc (c ⊔ ℓ)) where
infix 4 _≈_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ
isEquivalence : IsEquivalence _≈_
open IsEquivalence isEquivalence public
partialSetoid : PartialSetoid c ℓ
partialSetoid = record
{ isPartialEquivalence = isPartialEquivalence
}
open PartialSetoid partialSetoid public using (_≉_)
record DecSetoid c ℓ : Set (suc (c ⊔ ℓ)) where
infix 4 _≈_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ
isDecEquivalence : IsDecEquivalence _≈_
open IsDecEquivalence isDecEquivalence public
setoid : Setoid c ℓ
setoid = record
{ isEquivalence = isEquivalence
}
open Setoid setoid public using (partialSetoid; _≉_)
------------------------------------------------------------------------
-- Preorders
------------------------------------------------------------------------
record Preorder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _∼_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ₁ -- The underlying equality.
_∼_ : Rel Carrier ℓ₂ -- The relation.
isPreorder : IsPreorder _≈_ _∼_
open IsPreorder isPreorder public
hiding (module Eq)
module Eq where
setoid : Setoid c ℓ₁
setoid = record
{ isEquivalence = isEquivalence
}
open Setoid setoid public
------------------------------------------------------------------------
-- Partial orders
------------------------------------------------------------------------
record Poset c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _≤_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ₁
_≤_ : Rel Carrier ℓ₂
isPartialOrder : IsPartialOrder _≈_ _≤_
open IsPartialOrder isPartialOrder public
hiding (module Eq)
preorder : Preorder c ℓ₁ ℓ₂
preorder = record
{ isPreorder = isPreorder
}
open Preorder preorder public
using (module Eq)
record DecPoset c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _≤_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ₁
_≤_ : Rel Carrier ℓ₂
isDecPartialOrder : IsDecPartialOrder _≈_ _≤_
private
module DPO = IsDecPartialOrder isDecPartialOrder
open DPO public hiding (module Eq)
poset : Poset c ℓ₁ ℓ₂
poset = record
{ isPartialOrder = isPartialOrder
}
open Poset poset public
using (preorder)
module Eq where
decSetoid : DecSetoid c ℓ₁
decSetoid = record
{ isDecEquivalence = DPO.Eq.isDecEquivalence
}
open DecSetoid decSetoid public
record StrictPartialOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _<_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ₁
_<_ : Rel Carrier ℓ₂
isStrictPartialOrder : IsStrictPartialOrder _≈_ _<_
open IsStrictPartialOrder isStrictPartialOrder public
hiding (module Eq)
module Eq where
setoid : Setoid c ℓ₁
setoid = record
{ isEquivalence = isEquivalence
}
open Setoid setoid public
record DecStrictPartialOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _<_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ₁
_<_ : Rel Carrier ℓ₂
isDecStrictPartialOrder : IsDecStrictPartialOrder _≈_ _<_
private
module DSPO = IsDecStrictPartialOrder isDecStrictPartialOrder
open DSPO public hiding (module Eq)
strictPartialOrder : StrictPartialOrder c ℓ₁ ℓ₂
strictPartialOrder = record
{ isStrictPartialOrder = isStrictPartialOrder
}
module Eq where
decSetoid : DecSetoid c ℓ₁
decSetoid = record
{ isDecEquivalence = DSPO.Eq.isDecEquivalence
}
open DecSetoid decSetoid public
------------------------------------------------------------------------
-- Total orders
------------------------------------------------------------------------
record TotalOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _≤_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ₁
_≤_ : Rel Carrier ℓ₂
isTotalOrder : IsTotalOrder _≈_ _≤_
open IsTotalOrder isTotalOrder public
hiding (module Eq)
poset : Poset c ℓ₁ ℓ₂
poset = record
{ isPartialOrder = isPartialOrder
}
open Poset poset public
using (module Eq; preorder)
record DecTotalOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _≤_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ₁
_≤_ : Rel Carrier ℓ₂
isDecTotalOrder : IsDecTotalOrder _≈_ _≤_
private
module DTO = IsDecTotalOrder isDecTotalOrder
open DTO public hiding (module Eq)
totalOrder : TotalOrder c ℓ₁ ℓ₂
totalOrder = record
{ isTotalOrder = isTotalOrder
}
open TotalOrder totalOrder public using (poset; preorder)
decPoset : DecPoset c ℓ₁ ℓ₂
decPoset = record
{ isDecPartialOrder = isDecPartialOrder
}
open DecPoset decPoset public using (module Eq)
-- Note that these orders are decidable. The current implementation
-- of `Trichotomous` subsumes irreflexivity and asymmetry. Any reasonable
-- definition capturing these three properties implies decidability
-- as `Trichotomous` necessarily separates out the equality case.
record StrictTotalOrder c ℓ₁ ℓ₂ : Set (suc (c ⊔ ℓ₁ ⊔ ℓ₂)) where
infix 4 _≈_ _<_
field
Carrier : Set c
_≈_ : Rel Carrier ℓ₁
_<_ : Rel Carrier ℓ₂
isStrictTotalOrder : IsStrictTotalOrder _≈_ _<_
open IsStrictTotalOrder isStrictTotalOrder public
hiding (module Eq)
strictPartialOrder : StrictPartialOrder c ℓ₁ ℓ₂
strictPartialOrder = record
{ isStrictPartialOrder = isStrictPartialOrder
}
open StrictPartialOrder strictPartialOrder public
using (module Eq)
decSetoid : DecSetoid c ℓ₁
decSetoid = record
{ isDecEquivalence = isDecEquivalence
}
{-# WARNING_ON_USAGE decSetoid
"Warning: decSetoid was deprecated in v1.3.
Please use Eq.decSetoid instead."
#-}
| 25.694545
| 73
| 0.586329
|
1a24c51dccfa2425389ea2040d1f65544564f6fd
| 683
|
agda
|
Agda
|
test/Succeed/Issue1595.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Succeed/Issue1595.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/Issue1595.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | null | null | null |
-- Andreas, 2015-06-28, issue reported by Nisse
{-# OPTIONS -vtc.pos.occ:20 #-} -- KEEP!, this triggered the __IMPOSSIBLE__
-- {-# OPTIONS -vtc.pos.occ:70 -v tc.rec:80 --show-implicit #-}
data ⊥ : Set where
F : ⊥ → Set
F ()
record R (i : ⊥) : Set₁ where
constructor c
field
P Q : F i → Set
-- An internal error has occurred. Please report this as a bug.
-- Location of the error: src/full/Agda/Syntax/Translation/InternalToAbstract.hs:874
-- The error is triggered by the use of prettyTCM in
-- Agda.TypeChecking.Positivity.getOccurrences.
-- tel = (_ : Prop) (_ : Prop) -- WRONG
-- perm = id
-- ps = (c x x : R @0) _
-- body = λ x _y _z -> x _z
-- type = F @1 → Set
| 24.392857
| 84
| 0.635432
|
59ae61b3338e1a5cac3db115c61d21d04ea990e7
| 34
|
agda
|
Agda
|
test/Fail/Imports/WronglyNamedModule.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Imports/WronglyNamedModule.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Imports/WronglyNamedModule.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Imports.TheWrongName where
| 17
| 33
| 0.882353
|
dc86af51e544944ab4d276babe9df100f95d64ae
| 9,725
|
agda
|
Agda
|
Cubical/Algebra/IntegerMatrix/Elementaries.agda
|
howsiyu/cubical
|
1b9c97a2140fe96fe636f4c66beedfd7b8096e8f
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/IntegerMatrix/Elementaries.agda
|
howsiyu/cubical
|
1b9c97a2140fe96fe636f4c66beedfd7b8096e8f
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/IntegerMatrix/Elementaries.agda
|
howsiyu/cubical
|
1b9c97a2140fe96fe636f4c66beedfd7b8096e8f
|
[
"MIT"
] | null | null | null |
{-
Elementary transformation specific to coefficient ℤ
-}
{-# OPTIONS --safe #-}
module Cubical.Algebra.IntegerMatrix.Elementaries where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Data.Nat hiding (_+_ ; _·_)
open import Cubical.Data.FinData
open import Cubical.Relation.Nullary
open import Cubical.Algebra.RingSolver.Reflection
open import Cubical.Algebra.Ring.BigOps
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.CommRing.Instances.Int renaming (ℤ to Ringℤ)
open import Cubical.Algebra.Matrix
open import Cubical.Algebra.Matrix.CommRingCoefficient
open import Cubical.Algebra.Matrix.RowTransformation
private
variable
ℓ : Level
m n : ℕ
-- It seems there are bugs when applying ring solver to integers.
-- The following is a work-around.
private
module Helper {ℓ : Level}(𝓡 : CommRing ℓ) where
open CommRingStr (𝓡 .snd)
helper1 : (a b x y g : 𝓡 .fst) → (a · x - b · - y) · g ≡ a · (x · g) + b · (y · g)
helper1 = solve 𝓡
helper2 : (a b : 𝓡 .fst) → a ≡ 1r · a + 0r · b
helper2 = solve 𝓡
open Helper Ringℤ
module ElemTransformationℤ where
open import Cubical.Foundations.Powerset
open import Cubical.Data.Int using (·rCancel)
open import Cubical.Data.Int.Divisibility
private
ℤ = Ringℤ .fst
open CommRingStr (Ringℤ .snd)
open Sum (CommRing→Ring Ringℤ)
open Coefficient Ringℤ
open LinearTransformation Ringℤ
open Bézout
open SimRel
open Sim
open isLinear
open isLinear2×2
-- The Bézout step to simplify one row
module _
(x y : ℤ)(b : Bézout x y) where
bézout2Mat : Mat 2 2
bézout2Mat zero zero = b .coef₁
bézout2Mat zero one = b .coef₂
bézout2Mat one zero = - (div₂ b)
bézout2Mat one one = div₁ b
module _
(p : ¬ x ≡ 0) where
open Units Ringℤ
private
detEq : det2×2 bézout2Mat · b .gcd ≡ b .gcd
detEq =
helper1 (b .coef₁) (b .coef₂) _ _ _
∙ (λ t → b .coef₁ · divideEq (b .isCD .fst) t + b .coef₂ · divideEq (b .isCD .snd) t)
∙ b .identity
det≡1 : det2×2 bézout2Mat ≡ 1
det≡1 = ·rCancel _ _ _ (detEq ∙ sym (·Lid _)) (¬m≡0→¬gcd≡0 b p)
isInvBézout2Mat : isInv bézout2Mat
isInvBézout2Mat = isInvMat2x2 bézout2Mat (subst (λ r → r ∈ Rˣ) (sym det≡1) RˣContainsOne)
module _
(M : Mat 2 (suc n)) where
private
b = bézout (M zero zero) (M one zero)
bézout2Rows : Mat 2 (suc n)
bézout2Rows zero i = b .coef₁ · M zero i + b .coef₂ · M one i
bézout2Rows one i = - (div₂ b) · M zero i + div₁ b · M one i
bézout2Rows-vanish : bézout2Rows one zero ≡ 0
bézout2Rows-vanish = div·- b
bézout2Rows-div₁ : (n : ℤ) → M zero zero ∣ n → bézout2Rows zero zero ∣ n
bézout2Rows-div₁ n p = subst (λ a → a ∣ n) (sym (b .identity)) (∣-trans (b .isCD .fst) p)
bézout2Rows-div₂ : (n : ℤ) → M one zero ∣ n → bézout2Rows zero zero ∣ n
bézout2Rows-div₂ n p = subst (λ a → a ∣ n) (sym (b .identity)) (∣-trans (b .isCD .snd) p)
bézout2Rows-nonZero : ¬ M zero zero ≡ 0 → ¬ bézout2Rows zero zero ≡ 0
bézout2Rows-nonZero p r =
p (sym (∣-zeroˡ (subst (λ a → a ∣ M zero zero) r (bézout2Rows-div₁ (M zero zero) (∣-refl refl)))))
bézout2Rows-inv : ¬ M zero zero ≡ 0 → M zero zero ∣ M one zero → M zero ≡ bézout2Rows zero
bézout2Rows-inv p q t j =
let (c₁≡1 , c₂≡0) = bézout∣ _ _ p q in
(helper2 (M zero j) (M one j) ∙ (λ t → c₁≡1 (~ t) · M zero j + c₂≡0 (~ t) · M one j)) t
bézout2Rows-commonDiv : (a : ℤ)
→ ((j : Fin (suc n)) → a ∣ M zero j)
→ ((j : Fin (suc n)) → a ∣ M one j)
→ (i : Fin 2)(j : Fin (suc n)) → a ∣ bézout2Rows i j
bézout2Rows-commonDiv a p q zero j = ∣-+ (∣-right· {n = b .coef₁} (p j)) (∣-right· {n = b .coef₂} (q j))
bézout2Rows-commonDiv a p q one j = ∣-+ (∣-right· {n = - (div₂ b)} (p j)) (∣-right· {n = div₁ b} (q j))
module _
(M : Mat (suc m) (suc n)) where
bézoutRows : Mat (suc m) (suc n)
bézoutRows = transRows bézout2Rows M
bézoutRows-vanish : (i : Fin m) → bézoutRows (suc i) zero ≡ 0
bézoutRows-vanish = transRowsIndP' _ (λ v → v zero ≡ 0) bézout2Rows-vanish M
bézoutRows-div₁-helper : (n : ℤ) → M zero zero ∣ n → bézoutRows zero zero ∣ n
bézoutRows-div₁-helper n = transRowsIndP _ (λ v → v zero ∣ n) (λ M → bézout2Rows-div₁ M n) M
bézoutRows-div₂-helper : (n : ℤ) → (i : Fin m) → M (suc i) zero ∣ n → bézoutRows zero zero ∣ n
bézoutRows-div₂-helper n =
transRowsIndPQ' _ (λ v → v zero ∣ n) (λ v → v zero ∣ n)
(λ M → bézout2Rows-div₁ M n) (λ M → bézout2Rows-div₂ M n) M
bézoutRows-div : (i : Fin (suc m)) → bézoutRows zero zero ∣ M i zero
bézoutRows-div zero = bézoutRows-div₁-helper _ (∣-refl refl)
bézoutRows-div (suc i) = bézoutRows-div₂-helper _ i (∣-refl refl)
bézoutRows-nonZero : ¬ M zero zero ≡ 0 → ¬ bézoutRows zero zero ≡ 0
bézoutRows-nonZero p r = p (sym (∣-zeroˡ (subst (λ a → a ∣ M zero zero) r (bézoutRows-div zero))))
bézoutRows-inv : ¬ M zero zero ≡ 0 → ((i : Fin m) → M zero zero ∣ M (suc i) zero) → M zero ≡ bézoutRows zero
bézoutRows-inv = transRowsIndPRelInv _ (λ V → ¬ V zero ≡ 0) (λ U V → U zero ∣ V zero) bézout2Rows-inv M
bézoutRows-commonDiv₀ : (a : ℤ)
→ ((j : Fin (suc n)) → a ∣ M zero j)
→ ((i : Fin m)(j : Fin (suc n)) → a ∣ M (suc i) j)
→ (j : Fin (suc n)) → a ∣ bézoutRows zero j
bézoutRows-commonDiv₀ a =
transRowsIndP₀ _ (λ V → ((j : Fin (suc n)) → a ∣ V j))
(λ N s s' → bézout2Rows-commonDiv N a s s' zero)
(λ N s s' → bézout2Rows-commonDiv N a s s' one) _
bézoutRows-commonDiv₁ : (a : ℤ)
→ ((j : Fin (suc n)) → a ∣ M zero j)
→ ((i : Fin m)(j : Fin (suc n)) → a ∣ M (suc i) j)
→ (i : Fin m)(j : Fin (suc n)) → a ∣ bézoutRows (suc i) j
bézoutRows-commonDiv₁ a =
transRowsIndP₁ _ (λ V → ((j : Fin (suc n)) → a ∣ V j))
(λ N s s' → bézout2Rows-commonDiv N a s s' zero)
(λ N s s' → bézout2Rows-commonDiv N a s s' one) _
bézoutRows-commonDiv :
((i : Fin (suc m))(j : Fin (suc n)) → M zero zero ∣ M i j)
→ (i : Fin (suc m))(j : Fin (suc n)) → M zero zero ∣ bézoutRows i j
bézoutRows-commonDiv p zero = bézoutRows-commonDiv₀ _ (p zero) (p ∘ suc)
bézoutRows-commonDiv p (suc i) = bézoutRows-commonDiv₁ _ (p zero) (p ∘ suc) i
bézoutRows-commonDivInv :
¬ M zero zero ≡ 0
→ ((i : Fin (suc m))(j : Fin (suc n)) → M zero zero ∣ M i j)
→ (i : Fin (suc m))(j : Fin (suc n)) → bézoutRows zero zero ∣ bézoutRows i j
bézoutRows-commonDivInv h p i j =
let inv = (λ t → bézoutRows-inv h (λ i → p (suc i) zero) t zero) in
subst (_∣ bézoutRows i j) inv (bézoutRows-commonDiv p i j)
isLinear2Bézout2Rows : isLinear2×2 (bézout2Rows {n = n})
isLinear2Bézout2Rows .transMat M = bézout2Mat _ _ (bézout (M zero zero) (M one zero))
isLinear2Bézout2Rows .transEq M t zero j = mul2 (isLinear2Bézout2Rows .transMat M) M zero j (~ t)
isLinear2Bézout2Rows .transEq M t one j = mul2 (isLinear2Bézout2Rows .transMat M) M one j (~ t)
isLinearBézoutRows : isLinear (bézoutRows {m = m} {n = n})
isLinearBézoutRows = isLinearTransRows _ isLinear2Bézout2Rows _
isInv2Bézout2Rows : (M : Mat 2 (suc n))(p : ¬ M zero zero ≡ 0) → isInv (isLinear2Bézout2Rows .transMat M)
isInv2Bézout2Rows _ p = isInvBézout2Mat _ _ _ p
isInvBézout2Rows : (M : Mat (suc m) (suc n))(p : ¬ M zero zero ≡ 0) → isInv (isLinearBézoutRows .transMat M)
isInvBézout2Rows = isInvTransRowsInd _ _ (λ V → ¬ V zero ≡ 0) bézout2Rows-nonZero isInv2Bézout2Rows
-- Using Bézout identity to eliminate the first column/row
record RowsImproved (M : Mat (suc m) (suc n)) : Type where
field
sim : Sim M
div : (i : Fin (suc m)) → sim .result zero zero ∣ M i zero
vanish : (i : Fin m) → sim .result (suc i) zero ≡ 0
nonZero : ¬ sim .result zero zero ≡ 0
record ColsImproved (M : Mat (suc m) (suc n)) : Type where
field
sim : Sim M
div : (j : Fin (suc n)) → sim .result zero zero ∣ M zero j
vanish : (j : Fin n) → sim .result zero (suc j) ≡ 0
nonZero : ¬ sim .result zero zero ≡ 0
open RowsImproved
open ColsImproved
improveRows : (M : Mat (suc m) (suc n))(p : ¬ M zero zero ≡ 0) → RowsImproved M
improveRows M _ .sim .result = bézoutRows M
improveRows M _ .sim .simrel .transMatL = isLinearBézoutRows .transMat M
improveRows _ _ .sim .simrel .transMatR = 𝟙
improveRows _ _ .sim .simrel .transEq = isLinearBézoutRows .transEq _ ∙ sym (⋆rUnit _)
improveRows _ p .sim .simrel .isInvTransL = isInvBézout2Rows _ p
improveRows _ p .sim .simrel .isInvTransR = isInv𝟙
improveRows _ _ .div = bézoutRows-div _
improveRows _ _ .vanish = bézoutRows-vanish _
improveRows M p .nonZero = bézoutRows-nonZero M p
improveCols : (M : Mat (suc m) (suc n))(p : ¬ M zero zero ≡ 0) → ColsImproved M
improveCols M _ .sim .result = (bézoutRows (M ᵗ))ᵗ
improveCols _ _ .sim .simrel .transMatL = 𝟙
improveCols M _ .sim .simrel .transMatR = (isLinearBézoutRows .transMat (M ᵗ))ᵗ
improveCols M _ .sim .simrel .transEq =
let P = isLinearBézoutRows .transMat (M ᵗ) in
(λ t → (isLinearBézoutRows .transEq (M ᵗ) t)ᵗ)
∙ compᵗ P (M ᵗ)
∙ (λ t → idemᵗ M t ⋆ P ᵗ)
∙ (λ t → ⋆lUnit M (~ t) ⋆ P ᵗ)
improveCols _ _ .sim .simrel .isInvTransL = isInv𝟙
improveCols M p .sim .simrel .isInvTransR =
isInvᵗ {M = isLinearBézoutRows .transMat (M ᵗ)} (isInvBézout2Rows (M ᵗ) p)
improveCols _ _ .div = bézoutRows-div _
improveCols _ _ .vanish = bézoutRows-vanish _
improveCols M p .nonZero = bézoutRows-nonZero (M ᵗ) p
| 38.438735
| 112
| 0.613573
|
138593e91b1626bdc30726bbca96d1622785ac40
| 916
|
agda
|
Agda
|
src/fot/PA/Inductive/README.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
src/fot/PA/Inductive/README.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
src/fot/PA/Inductive/README.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
------------------------------------------------------------------------------
-- First-order Peano arithmetic
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module PA.Inductive.README where
-- Formalization of first-order Peano arithmetic using Agda data types
-- and primitive recursive functions for addition and multiplication.
------------------------------------------------------------------------------
-- Inductive definitions
open import PA.Inductive.Base
-- Some properties
open import PA.Inductive.PropertiesATP
open import PA.Inductive.PropertiesI
open import PA.Inductive.PropertiesByInduction
open import PA.Inductive.PropertiesByInductionATP
open import PA.Inductive.PropertiesByInductionI
| 35.230769
| 78
| 0.550218
|
2e07aa388942b496fb4f19d56850f4e3228f1c7c
| 260
|
agda
|
Agda
|
src/FRP/LTL/RSet/Until.agda
|
agda/agda-frp-ltl
|
e88107d7d192cbfefd0a94505e6a5793afe1a7a5
|
[
"MIT"
] | 21
|
2015-07-02T20:25:05.000Z
|
2020-06-15T02:51:13.000Z
|
src/FRP/LTL/RSet/Until.agda
|
agda/agda-frp-ltl
|
e88107d7d192cbfefd0a94505e6a5793afe1a7a5
|
[
"MIT"
] | 2
|
2015-03-01T07:01:31.000Z
|
2015-03-02T15:23:53.000Z
|
src/FRP/LTL/RSet/Until.agda
|
agda/agda-frp-ltl
|
e88107d7d192cbfefd0a94505e6a5793afe1a7a5
|
[
"MIT"
] | 3
|
2015-03-01T07:33:00.000Z
|
2022-03-12T11:39:04.000Z
|
open import Data.Product using ( ∃ ; _×_ )
open import FRP.LTL.RSet.Core using ( RSet ; _[_,_⟩ )
open import FRP.LTL.Time using ( _≤_ )
module FRP.LTL.RSet.Until where
infixr 2 _U_
_U_ : RSet → RSet → RSet
(A U B) t = ∃ λ u → (t ≤ u) × (A [ t , u ⟩) × B u
| 21.666667
| 53
| 0.596154
|
c7a224a3104071541ef4af5007e61e869bf26946
| 2,673
|
agda
|
Agda
|
vendor/stdlib/src/Data/Sets.agda
|
isabella232/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 56
|
2015-01-20T02:11:42.000Z
|
2021-12-21T17:02:19.000Z
|
vendor/stdlib/src/Data/Sets.agda
|
larrytheliquid/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 1
|
2022-03-12T12:17:51.000Z
|
2022-03-12T12:17:51.000Z
|
vendor/stdlib/src/Data/Sets.agda
|
isabella232/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 3
|
2015-07-21T16:37:58.000Z
|
2022-03-12T11:54:10.000Z
|
------------------------------------------------------------------------
-- Finite sets (currently only some type signatures)
------------------------------------------------------------------------
module Data.Sets where
open import Relation.Nullary
open import Relation.Binary
open import Relation.Binary.OrderMorphism
open import Data.Function
open import Data.List as L using (List)
open import Data.Product using (∃; _×_)
module Sets₁ (dto : DecTotalOrder) where
open DecTotalOrder dto public using (_≈_)
open DecTotalOrder dto hiding (_≈_)
infixr 6 _∪_
infix 5 _∈?_
infix 4 _∈_ _|≈|_
abstract postulate decSetoid : DecSetoid
<Set> : Set
<Set> = DecSetoid.carrier decSetoid
_|≈|_ : Rel <Set>
_|≈|_ = DecSetoid._≈_ decSetoid
abstract
postulate
empty : <Set>
insert : carrier → <Set> → <Set>
_∪_ : <Set> → <Set> → <Set>
_∈_ : carrier → <Set> → Set
_∈?_ : (x : carrier) → (s : <Set>) → Dec (x ∈ s)
toList : <Set> → List carrier
postulate
prop-∈-insert₁ : ∀ {x y s} → x ≈ y → x ∈ insert y s
prop-∈-insert₂ : ∀ {x y s} → x ∈ s → x ∈ insert y s
prop-∈-insert₃ : ∀ {x y s} → ¬ x ≈ y → x ∈ insert y s → x ∈ s
prop-∈-empty : ∀ {x} → ¬ x ∈ empty
prop-∈-∪ : ∀ {x s₁ s₂} → x ∈ s₁ → x ∈ s₁ ∪ s₂
prop-∪₁ : ∀ {s₁ s₂} → s₁ ∪ s₂ |≈| s₂ ∪ s₁
prop-∪₂ : ∀ {s₁ s₂ s₃} → s₁ ∪ (s₂ ∪ s₃) |≈| (s₁ ∪ s₂) ∪ s₃
prop-∈-|≈| : ∀ {x} → (λ s → x ∈ s) Respects _|≈|_
prop-∈-≈ : ∀ {s} → (λ x → x ∈ s) Respects _≈_
-- TODO: Postulates for toList.
singleton : carrier → <Set>
singleton x = insert x empty
⋃_ : List <Set> → <Set>
⋃_ = L.foldr _∪_ empty
fromList : List carrier → <Set>
fromList = L.foldr insert empty
_⊆_ : <Set> → <Set> → Set
s₁ ⊆ s₂ = ∀ x → x ∈ s₁ → x ∈ s₂
open Sets₁ public
open DecTotalOrder hiding (_≈_)
open _⇒-Poset_
abstract
postulate
map : ∀ {do₁ do₂} → do₁ ⇒-DTO do₂ → <Set> do₁ → <Set> do₂
mapToSet : ∀ {do₁ do₂} →
(carrier do₁ → <Set> do₂) →
<Set> do₁ → <Set> do₂
prop-map-∈₁ : ∀ {do₁ do₂ f x s} →
x ⟨ _∈_ do₁ ⟩₁ s →
fun f x ⟨ _∈_ do₂ ⟩₁ map f s
prop-map-∈₂ : ∀ {do₁ do₂ f y s} →
y ⟨ _∈_ do₂ ⟩₁ map f s →
∃ λ x → (fun f x ⟨ _≈_ do₂ ⟩₁ y) ×
( x ⟨ _∈_ do₁ ⟩₁ s)
prop-mapToSet₁ : ∀ {do₁ do₂ f x s} →
x ⟨ _∈_ do₁ ⟩₁ s →
f x ⟨ _⊆_ do₂ ⟩₁ mapToSet f s
prop-mapToSet₂ : ∀ {do₁ do₂ f y s} →
y ⟨ _∈_ do₂ ⟩₁ mapToSet f s →
∃ λ x → (y ⟨ _∈_ do₂ ⟩₁ f x) ×
(x ⟨ _∈_ do₁ ⟩₁ s)
| 28.136842
| 72
| 0.466517
|
1da4e513700eb391f18d74a4057369244660256d
| 275
|
agda
|
Agda
|
test/Fail/WithoutK2.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/WithoutK2.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/WithoutK2.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --without-K #-}
module WithoutK2 where
-- Equality defined with two indices.
data _≡_ {A : Set} : A → A → Set where
refl : ∀ x → x ≡ x
K : {A : Set} (P : {x : A} → x ≡ x → Set) →
(∀ x → P (refl x)) →
∀ {x} (x≡x : x ≡ x) → P x≡x
K P p (refl x) = p x
| 19.642857
| 43
| 0.469091
|
1307a9e10566c953807a335516ad9adb4e259668
| 487
|
agda
|
Agda
|
Logic/Propositional/Xor.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Logic/Propositional/Xor.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Logic/Propositional/Xor.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
module Logic.Propositional.Xor where
open import Logic.Propositional
open import Logic
import Lvl
-- TODO: Is it possible write a general construction for arbitrary number of xors? Probably by using rotate₃Fn₃Op₂?
data _⊕₃_⊕₃_ {ℓ₁ ℓ₂ ℓ₃} (P : Stmt{ℓ₁}) (Q : Stmt{ℓ₂}) (R : Stmt{ℓ₃}) : Stmt{ℓ₁ Lvl.⊔ ℓ₂ Lvl.⊔ ℓ₃} where
[⊕₃]-intro₁ : P → (¬ Q) → (¬ R) → (P ⊕₃ Q ⊕₃ R)
[⊕₃]-intro₂ : (¬ P) → Q → (¬ R) → (P ⊕₃ Q ⊕₃ R)
[⊕₃]-intro₃ : (¬ P) → (¬ Q) → R → (P ⊕₃ Q ⊕₃ R)
| 40.583333
| 115
| 0.572895
|
2f41756f64def9e877e832f70b543ecc8bfb5b8a
| 2,115
|
agda
|
Agda
|
examples/outdated-and-incorrect/tactics/bool/Bool.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
examples/outdated-and-incorrect/tactics/bool/Bool.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
examples/outdated-and-incorrect/tactics/bool/Bool.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Bool where
data Bool : Set where
false : Bool
true : Bool
data IsTrue : Bool -> Set where
isTrue : IsTrue true
open import Vec
open import All
allEnvs : {n : Nat} -> List (Vec Bool n)
allEnvs {zero } = ε :: []
allEnvs {suc n} = map (_►_ false) allEnvs ++ map (_►_ true) allEnvs
∈++left : {A : Set}{x : A}{xs ys : List A} -> x ∈ xs -> x ∈ (xs ++ ys)
∈++left (hd p) = hd p
∈++left (tl q) = tl (∈++left q)
∈++right : {A : Set}{x : A}{xs ys : List A} -> x ∈ ys -> x ∈ (xs ++ ys)
∈++right {xs = []} p = p
∈++right {xs = x :: xs} p = tl (∈++right {xs = xs} p)
∈map : {A B : Set}{f : A -> B}{x : A}{xs : List A} -> x ∈ xs -> f x ∈ map f xs
∈map (hd refl) = hd refl
∈map (tl q) = tl (∈map q)
covered : {n : Nat} -> (xs : Vec Bool n) -> xs ∈ allEnvs
covered ε = hd refl
covered (false ► xs) = ∈++left (∈map (covered xs))
covered (true ► xs) = ∈++right {xs = map (_►_ false) allEnvs}
(∈map (covered xs))
Sat : {A : Set} -> (A -> Bool) -> A -> Set
Sat f x = IsTrue (f x)
lem₁ : {n : Nat}(f : Vec Bool n -> Bool) ->
All (Sat f) allEnvs -> (xs : Vec Bool n) -> Sat f xs
lem₁ f p xs with p ! covered xs
... | (.xs , p , refl) = p
data False : Set where
¬_ : Set -> Set
¬ P = P -> False
data _∨_ (A B : Set) : Set where
inl : A -> A ∨ B
inr : B -> A ∨ B
¬IsTrue-false : ¬ IsTrue false
¬IsTrue-false ()
decide : {A : Set}(p : A -> Bool)(x : A) ->
Sat p x ∨ ¬ Sat p x
decide p x with p x
... | true = inl isTrue
... | false = inr ¬IsTrue-false
all : {A : Set}(p : A -> Bool)(xs : List A) ->
All (Sat p) xs ∨ Some (\x -> ¬ Sat p x) xs
all p [] = inl ∅
all p (x :: xs) with decide p x
... | inr ¬px = inr (hd ¬px)
... | inl px with all p xs
... | inl ps = inl (px ▹ ps)
... | inr q = inr (tl q)
data NoProof : Set where
no-proof : NoProof
Proof : {n : Nat} -> (Vec Bool n -> Bool) -> Set
Proof {n} f with all f allEnvs
... | inl _ = (xs : Vec Bool n) -> Sat f xs
... | inr _ = NoProof
prove : {n : Nat}(f : Vec Bool n -> Bool) -> Proof f
prove f with all f allEnvs
... | inl ps = lem₁ f ps
... | inr _ = no-proof
| 25.481928
| 78
| 0.501182
|
ad39466859c6bbd0a981bea24277a8aabd266466
| 10,900
|
agda
|
Agda
|
Cubical/HITs/PropositionalTruncation/Properties.agda
|
RobertHarper/cubical
|
d13941587a58895b65f714f1ccc9c1f5986b109c
|
[
"MIT"
] | null | null | null |
Cubical/HITs/PropositionalTruncation/Properties.agda
|
RobertHarper/cubical
|
d13941587a58895b65f714f1ccc9c1f5986b109c
|
[
"MIT"
] | null | null | null |
Cubical/HITs/PropositionalTruncation/Properties.agda
|
RobertHarper/cubical
|
d13941587a58895b65f714f1ccc9c1f5986b109c
|
[
"MIT"
] | 1
|
2021-11-22T02:02:01.000Z
|
2021-11-22T02:02:01.000Z
|
{-
This file contains:
- Eliminator for propositional truncation
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.PropositionalTruncation.Properties where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Function
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Data.Sigma
open import Cubical.HITs.PropositionalTruncation.Base
private
variable
ℓ : Level
A B C : Type ℓ
rec : ∀ {P : Type ℓ} → isProp P → (A → P) → ∥ A ∥ → P
rec Pprop f ∣ x ∣ = f x
rec Pprop f (squash x y i) = Pprop (rec Pprop f x) (rec Pprop f y) i
rec2 : ∀ {P : Type ℓ} → isProp P → (A → A → P) → ∥ A ∥ → ∥ A ∥ → P
rec2 Pprop f = rec (isPropΠ (λ _ → Pprop))
(λ a → rec Pprop (f a))
elim : ∀ {P : ∥ A ∥ → Type ℓ} → ((a : ∥ A ∥) → isProp (P a))
→ ((x : A) → P ∣ x ∣) → (a : ∥ A ∥) → P a
elim Pprop f ∣ x ∣ = f x
elim Pprop f (squash x y i) =
isOfHLevel→isOfHLevelDep 1 Pprop
(elim Pprop f x) (elim Pprop f y) (squash x y) i
elim2 : {P : ∥ A ∥ → ∥ A ∥ → Type ℓ}
(Bset : ((x y : ∥ A ∥) → isProp (P x y)))
(g : (a b : A) → P ∣ a ∣ ∣ b ∣)
(x y : ∥ A ∥) → P x y
elim2 Pprop g = elim (λ _ → isPropΠ (λ _ → Pprop _ _))
(λ a → elim (λ _ → Pprop _ _) (g a))
elim3 : {P : ∥ A ∥ → ∥ A ∥ → ∥ A ∥ → Type ℓ}
(Bset : ((x y z : ∥ A ∥) → isProp (P x y z)))
(g : (a b c : A) → P (∣ a ∣) ∣ b ∣ ∣ c ∣)
(x y z : ∥ A ∥) → P x y z
elim3 Pprop g = elim2 (λ _ _ → isPropΠ (λ _ → Pprop _ _ _))
(λ a b → elim (λ _ → Pprop _ _ _) (g a b))
propTruncIsProp : isProp ∥ A ∥
propTruncIsProp x y = squash x y
propTruncIdempotent≃ : isProp A → ∥ A ∥ ≃ A
propTruncIdempotent≃ {A = A} hA = isoToEquiv f
where
f : Iso ∥ A ∥ A
Iso.fun f = rec hA (idfun A)
Iso.inv f x = ∣ x ∣
Iso.rightInv f _ = refl
Iso.leftInv f = elim (λ _ → isProp→isSet propTruncIsProp _ _) (λ _ → refl)
propTruncIdempotent : isProp A → ∥ A ∥ ≡ A
propTruncIdempotent hA = ua (propTruncIdempotent≃ hA)
-- We could also define the eliminator using the recursor
elim' : ∀ {P : ∥ A ∥ → Type ℓ} → ((a : ∥ A ∥) → isProp (P a)) →
((x : A) → P ∣ x ∣) → (a : ∥ A ∥) → P a
elim' {P = P} Pprop f a =
rec (Pprop a) (λ x → transp (λ i → P (squash ∣ x ∣ a i)) i0 (f x)) a
map : (A → B) → (∥ A ∥ → ∥ B ∥)
map f = rec squash (∣_∣ ∘ f)
map2 : (A → B → C) → (∥ A ∥ → ∥ B ∥ → ∥ C ∥)
map2 f = rec (isPropΠ λ _ → squash) (map ∘ f)
-- The propositional truncation can be eliminated into non-propositional
-- types as long as the function used in the eliminator is 'coherently
-- constant.' The details of this can be found in the following paper:
--
-- https://arxiv.org/pdf/1411.2682.pdf
module SetElim (Bset : isSet B) where
Bset' : isSet' B
Bset' = isSet→isSet' Bset
rec→Set : (f : A → B) (kf : 2-Constant f) → ∥ A ∥ → B
helper : (f : A → B) (kf : 2-Constant f) → (t u : ∥ A ∥)
→ rec→Set f kf t ≡ rec→Set f kf u
rec→Set f kf ∣ x ∣ = f x
rec→Set f kf (squash t u i) = helper f kf t u i
helper f kf ∣ x ∣ ∣ y ∣ = kf x y
helper f kf (squash t u i) v
= Bset' (helper f kf t v) (helper f kf u v) (helper f kf t u) refl i
helper f kf t (squash u v i)
= Bset' (helper f kf t u) (helper f kf t v) refl (helper f kf u v) i
kcomp : ∀(f : ∥ A ∥ → B) → 2-Constant (f ∘ ∣_∣)
kcomp f x y = cong f (squash ∣ x ∣ ∣ y ∣)
Fset : isSet (A → B)
Fset = isSetΠ (const Bset)
Kset : (f : A → B) → isSet (2-Constant f)
Kset f = isSetΠ (λ _ → isSetΠ (λ _ → isProp→isSet (Bset _ _)))
setRecLemma
: (f : ∥ A ∥ → B)
→ rec→Set (f ∘ ∣_∣) (kcomp f) ≡ f
setRecLemma f i t
= elim {P = λ t → rec→Set (f ∘ ∣_∣) (kcomp f) t ≡ f t}
(λ t → Bset _ _) (λ x → refl) t i
mkKmap : (∥ A ∥ → B) → Σ (A → B) 2-Constant
mkKmap f = f ∘ ∣_∣ , kcomp f
fib : (g : Σ (A → B) 2-Constant) → fiber mkKmap g
fib (g , kg) = rec→Set g kg , refl
eqv : (g : Σ (A → B) 2-Constant)
→ ∀ fi → fib g ≡ fi
eqv g (f , p) =
Σ≡Prop (λ f → isOfHLevelΣ 2 Fset Kset _ _)
(cong (uncurry rec→Set) (sym p) ∙ setRecLemma f)
trunc→Set≃ : (∥ A ∥ → B) ≃ (Σ (A → B) 2-Constant)
trunc→Set≃ .fst = mkKmap
trunc→Set≃ .snd .equiv-proof g = fib g , eqv g
-- The strategy of this equivalence proof follows the paper more closely.
-- It is used further down for the groupoid version, because the above
-- strategy does not generalize so easily.
e : B → Σ (A → B) 2-Constant
e b = const b , λ _ _ → refl
eval : A → (γ : Σ (A → B) 2-Constant) → B
eval a₀ (g , _) = g a₀
e-eval : ∀ (a₀ : A) γ → e (eval a₀ γ) ≡ γ
e-eval a₀ (g , kg) i .fst a₁ = kg a₀ a₁ i
e-eval a₀ (g , kg) i .snd a₁ a₂ = Bset' refl (kg a₁ a₂) (kg a₀ a₁) (kg a₀ a₂) i
e-isEquiv : A → isEquiv (e {A = A})
e-isEquiv a₀ = isoToIsEquiv (iso e (eval a₀) (e-eval a₀) λ _ → refl)
preEquiv₁ : ∥ A ∥ → B ≃ Σ (A → B) 2-Constant
preEquiv₁ t = e , rec (isPropIsEquiv e) e-isEquiv t
preEquiv₂ : (∥ A ∥ → Σ (A → B) 2-Constant) ≃ Σ (A → B) 2-Constant
preEquiv₂ = isoToEquiv (iso to const (λ _ → refl) retr)
where
to : (∥ A ∥ → Σ (A → B) 2-Constant) → Σ (A → B) 2-Constant
to f .fst x = f ∣ x ∣ .fst x
to f .snd x y i = f (squash ∣ x ∣ ∣ y ∣ i) .snd x y i
retr : retract to const
retr f i t .fst x = f (squash ∣ x ∣ t i) .fst x
retr f i t .snd x y
= Bset'
(λ j → f (squash ∣ x ∣ ∣ y ∣ j) .snd x y j)
(f t .snd x y)
(λ j → f (squash ∣ x ∣ t j) .fst x)
(λ j → f (squash ∣ y ∣ t j) .fst y)
i
trunc→Set≃₂ : (∥ A ∥ → B) ≃ Σ (A → B) 2-Constant
trunc→Set≃₂ = compEquiv (equivPi preEquiv₁) preEquiv₂
open SetElim public using (rec→Set; trunc→Set≃)
elim→Set
: {P : ∥ A ∥ → Type ℓ}
→ (∀ t → isSet (P t))
→ (f : (x : A) → P ∣ x ∣)
→ (kf : ∀ x y → PathP (λ i → P (squash ∣ x ∣ ∣ y ∣ i)) (f x) (f y))
→ (t : ∥ A ∥) → P t
elim→Set {A = A} {P = P} Pset f kf t
= rec→Set (Pset t) g gk t
where
g : A → P t
g x = transp (λ i → P (squash ∣ x ∣ t i)) i0 (f x)
gk : 2-Constant g
gk x y i = transp (λ j → P (squash (squash ∣ x ∣ ∣ y ∣ i) t j)) i0 (kf x y i)
RecHProp : (P : A → hProp ℓ) (kP : ∀ x y → P x ≡ P y) → ∥ A ∥ → hProp ℓ
RecHProp P kP = rec→Set isSetHProp P kP
module GpdElim (Bgpd : isGroupoid B) where
Bgpd' : isGroupoid' B
Bgpd' = isGroupoid→isGroupoid' Bgpd
module _ (f : A → B) (3kf : 3-Constant f) where
open 3-Constant 3kf
rec→Gpd : ∥ A ∥ → B
pathHelper : (t u : ∥ A ∥) → rec→Gpd t ≡ rec→Gpd u
triHelper₁
: (t u v : ∥ A ∥)
→ Square (pathHelper t u) (pathHelper t v) refl (pathHelper u v)
triHelper₂
: (t u v : ∥ A ∥)
→ Square (pathHelper t v) (pathHelper u v) (pathHelper t u) refl
rec→Gpd ∣ x ∣ = f x
rec→Gpd (squash t u i) = pathHelper t u i
pathHelper ∣ x ∣ ∣ y ∣ = link x y
pathHelper (squash t u j) v = triHelper₂ t u v j
pathHelper ∣ x ∣ (squash u v j) = triHelper₁ ∣ x ∣ u v j
triHelper₁ ∣ x ∣ ∣ y ∣ ∣ z ∣ = coh₁ x y z
triHelper₁ (squash s t i) u v
= Bgpd'
(triHelper₁ s u v)
(triHelper₁ t u v)
(triHelper₂ s t u)
(triHelper₂ s t v)
(λ i → refl)
(λ i → pathHelper u v)
i
triHelper₁ ∣ x ∣ (squash t u i) v
= Bgpd'
(triHelper₁ ∣ x ∣ t v)
(triHelper₁ ∣ x ∣ u v)
(triHelper₁ ∣ x ∣ t u)
(λ i → pathHelper ∣ x ∣ v)
(λ i → refl)
(triHelper₂ t u v)
i
triHelper₁ ∣ x ∣ ∣ y ∣ (squash u v i)
= Bgpd'
(triHelper₁ ∣ x ∣ ∣ y ∣ u)
(triHelper₁ ∣ x ∣ ∣ y ∣ v)
(λ i → link x y)
(triHelper₁ ∣ x ∣ u v)
(λ i → refl)
(triHelper₁ ∣ y ∣ u v)
i
triHelper₂ ∣ x ∣ ∣ y ∣ ∣ z ∣ = coh₂ x y z
triHelper₂ (squash s t i) u v
= Bgpd'
(triHelper₂ s u v)
(triHelper₂ t u v)
(triHelper₂ s t v)
(λ i → pathHelper u v)
(triHelper₂ s t u)
(λ i → refl)
i
triHelper₂ ∣ x ∣ (squash t u i) v
= Bgpd'
(triHelper₂ ∣ x ∣ t v)
(triHelper₂ ∣ x ∣ u v)
(λ i → pathHelper ∣ x ∣ v)
(triHelper₂ t u v)
(triHelper₁ ∣ x ∣ t u)
(λ i → refl)
i
triHelper₂ ∣ x ∣ ∣ y ∣ (squash u v i)
= Bgpd'
(triHelper₂ ∣ x ∣ ∣ y ∣ u)
(triHelper₂ ∣ x ∣ ∣ y ∣ v)
(triHelper₁ ∣ x ∣ u v)
(triHelper₁ ∣ y ∣ u v)
(λ i → link x y)
(λ i → refl)
i
preEquiv₁ : (∥ A ∥ → Σ (A → B) 3-Constant) ≃ Σ (A → B) 3-Constant
preEquiv₁ = isoToEquiv (iso fn const (λ _ → refl) retr)
where
open 3-Constant
fn : (∥ A ∥ → Σ (A → B) 3-Constant) → Σ (A → B) 3-Constant
fn f .fst x = f ∣ x ∣ .fst x
fn f .snd .link x y i = f (squash ∣ x ∣ ∣ y ∣ i) .snd .link x y i
fn f .snd .coh₁ x y z i j
= f (squash ∣ x ∣ (squash ∣ y ∣ ∣ z ∣ i) j) .snd .coh₁ x y z i j
retr : retract fn const
retr f i t .fst x = f (squash ∣ x ∣ t i) .fst x
retr f i t .snd .link x y j
= f (squash (squash ∣ x ∣ ∣ y ∣ j) t i) .snd .link x y j
retr f i t .snd .coh₁ x y z
= Bgpd'
(λ k j → f (cb k j i0) .snd .coh₁ x y z k j )
(λ k j → f (cb k j i1) .snd .coh₁ x y z k j)
(λ k j → f (cb i0 j k) .snd .link x y j)
(λ k j → f (cb i1 j k) .snd .link x z j)
(λ _ → refl)
(λ k j → f (cb j i1 k) .snd .link y z j)
i
where
cb : I → I → I → ∥ _ ∥
cb i j k = squash (squash ∣ x ∣ (squash ∣ y ∣ ∣ z ∣ i) j) t k
e : B → Σ (A → B) 3-Constant
e b .fst _ = b
e b .snd = record
{ link = λ _ _ _ → b
; coh₁ = λ _ _ _ _ _ → b
}
eval : A → Σ (A → B) 3-Constant → B
eval a₀ (g , _) = g a₀
module _ where
open 3-Constant
e-eval : ∀(a₀ : A) γ → e (eval a₀ γ) ≡ γ
e-eval a₀ (g , 3kg) i .fst x = 3kg .link a₀ x i
e-eval a₀ (g , 3kg) i .snd .link x y = λ j → 3kg .coh₁ a₀ x y j i
e-eval a₀ (g , 3kg) i .snd .coh₁ x y z
= Bgpd'
(λ _ _ → g a₀)
(3kg .coh₁ x y z)
(λ k j → 3kg .coh₁ a₀ x y j k)
(λ k j → 3kg .coh₁ a₀ x z j k)
(λ _ → refl)
(λ k j → 3kg .coh₁ a₀ y z j k)
i
e-isEquiv : A → isEquiv (e {A = A})
e-isEquiv a₀ = isoToIsEquiv (iso e (eval a₀) (e-eval a₀) λ _ → refl)
preEquiv₂ : ∥ A ∥ → B ≃ Σ (A → B) 3-Constant
preEquiv₂ t = e , rec (isPropIsEquiv e) e-isEquiv t
trunc→Gpd≃ : (∥ A ∥ → B) ≃ Σ (A → B) 3-Constant
trunc→Gpd≃ = compEquiv (equivPi preEquiv₂) preEquiv₁
open GpdElim using (rec→Gpd; trunc→Gpd≃) public
RecHSet : (P : A → TypeOfHLevel ℓ 2) → 3-Constant P → ∥ A ∥ → TypeOfHLevel ℓ 2
RecHSet P 3kP = rec→Gpd (isOfHLevelTypeOfHLevel 2) P 3kP
| 31.594203
| 81
| 0.501101
|
0e952dc79b8e163f2c2ab3e79943edfe3f6c7c9e
| 773
|
agda
|
Agda
|
agda/BTree/Complete/Alternative/Properties.agda
|
bgbianchi/sorting
|
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
|
[
"MIT"
] | 6
|
2015-05-21T12:50:35.000Z
|
2021-08-24T22:11:15.000Z
|
agda/BTree/Complete/Alternative/Properties.agda
|
bgbianchi/sorting
|
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
|
[
"MIT"
] | null | null | null |
agda/BTree/Complete/Alternative/Properties.agda
|
bgbianchi/sorting
|
b8d428bccbdd1b13613e8f6ead6c81a8f9298399
|
[
"MIT"
] | null | null | null |
module BTree.Complete.Alternative.Properties {A : Set} where
open import BTree {A}
open import BTree.Equality {A}
open import BTree.Equality.Properties {A}
open import BTree.Complete.Alternative {A}
open import Data.Sum renaming (_⊎_ to _∨_)
lemma-⋗-≃ : {t t' t'' : BTree} → t ⋗ t' → t' ≃ t'' → t ⋗ t''
lemma-⋗-≃ (⋗lf x) ≃lf = ⋗lf x
lemma-⋗-≃ (⋗nd x x' l≃r l'≃r' l⋗l') (≃nd .x' x'' _ l''≃r'' l'≃l'') = ⋗nd x x'' l≃r l'≃l'' (lemma-⋗-≃ l⋗l' l''≃r'')
lemma-≃-⋘ : {l r : BTree} → l ≃ r → l ⋘ r
lemma-≃-⋘ ≃lf = lf⋘
lemma-≃-⋘ (≃nd x x' l≃r l≃l' l'≃r') = ll⋘ x x' (lemma-≃-⋘ l≃r) l'≃r' (trans≃ (symm≃ l≃r) l≃l')
lemma-⋗-⋙ : {l r : BTree} → l ⋗ r → l ⋙ r
lemma-⋗-⋙ (⋗lf x) = ⋙lf x
lemma-⋗-⋙ (⋗nd x x' l≃r l'≃r' l⋗l') = ⋙rl x x' l≃r (lemma-≃-⋘ l'≃r') (lemma-⋗-≃ l⋗l' l'≃r')
| 36.809524
| 114
| 0.507115
|
1331be2d113fc8d95ee85205b6575fe19a92d783
| 4,394
|
agda
|
Agda
|
src/Calf/CostMonoids.agda
|
jonsterling/agda-calf
|
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
|
[
"Apache-2.0"
] | 29
|
2021-07-14T03:18:28.000Z
|
2022-03-22T20:35:11.000Z
|
src/Calf/CostMonoids.agda
|
jonsterling/agda-calf
|
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
|
[
"Apache-2.0"
] | null | null | null |
src/Calf/CostMonoids.agda
|
jonsterling/agda-calf
|
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
|
[
"Apache-2.0"
] | 2
|
2021-10-06T10:28:24.000Z
|
2022-01-29T08:12:01.000Z
|
{-# OPTIONS --prop --without-K --rewriting #-}
-- Common cost monoids.
module Calf.CostMonoids where
open import Calf.CostMonoid
open import Data.Product
open import Relation.Binary.PropositionalEquality
ℕ-CostMonoid : CostMonoid
ℕ-CostMonoid = record
{ ℂ = ℕ
; _+_ = _+_
; zero = zero
; _≤_ = _≤_
; isCostMonoid = record
{ isMonoid = +-0-isMonoid
; isCancellative = record { ∙-cancel-≡ = +-cancel-≡ }
; isPreorder = ≤-isPreorder
; isMonotone = record { ∙-mono-≤ = +-mono-≤ }
}
}
where
open import Data.Nat
open import Data.Nat.Properties
ℕ-Work-ParCostMonoid : ParCostMonoid
ℕ-Work-ParCostMonoid = record
{ ℂ = ℕ
; _⊕_ = _+_
; 𝟘 = 0
; _⊗_ = _+_
; 𝟙 = 0
; _≤_ = _≤_
; isParCostMonoid = record
{ isMonoid = +-0-isMonoid
; isCommutativeMonoid = +-0-isCommutativeMonoid
; isCancellative = record { ∙-cancel-≡ = +-cancel-≡ }
; isPreorder = ≤-isPreorder
; isMonotone-⊕ = record { ∙-mono-≤ = +-mono-≤ }
; isMonotone-⊗ = record { ∙-mono-≤ = +-mono-≤ }
}
}
where
open import Data.Nat
open import Data.Nat.Properties
ℕ-Span-ParCostMonoid : ParCostMonoid
ℕ-Span-ParCostMonoid = record
{ ℂ = ℕ
; _⊕_ = _+_
; 𝟘 = 0
; _⊗_ = _⊔_
; 𝟙 = 0
; _≤_ = _≤_
; isParCostMonoid = record
{ isMonoid = +-0-isMonoid
; isCommutativeMonoid = ⊔-0-isCommutativeMonoid
; isPreorder = ≤-isPreorder
; isCancellative = record { ∙-cancel-≡ = +-cancel-≡ }
; isMonotone-⊕ = record { ∙-mono-≤ = +-mono-≤ }
; isMonotone-⊗ = record { ∙-mono-≤ = ⊔-mono-≤ }
}
}
where
open import Data.Nat
open import Data.Nat.Properties
combineParCostMonoids : ParCostMonoid → ParCostMonoid → ParCostMonoid
combineParCostMonoids pcm₁ pcm₂ = record
{ ℂ = ℂ pcm₁ × ℂ pcm₂
; _⊕_ = λ (a₁ , a₂) (b₁ , b₂) → _⊕_ pcm₁ a₁ b₁ , _⊕_ pcm₂ a₂ b₂
; 𝟘 = 𝟘 pcm₁ , 𝟘 pcm₂
; _⊗_ = λ (a₁ , a₂) (b₁ , b₂) → _⊗_ pcm₁ a₁ b₁ , _⊗_ pcm₂ a₂ b₂
; 𝟙 = 𝟙 pcm₁ , 𝟙 pcm₂
; _≤_ = λ (a₁ , a₂) (b₁ , b₂) → _≤_ pcm₁ a₁ b₁ × _≤_ pcm₂ a₂ b₂
; isParCostMonoid = record
{ isMonoid = record
{ isSemigroup = record
{ isMagma = record
{ isEquivalence = isEquivalence
; ∙-cong = λ h₁ h₂ →
cong₂ _,_
(cong₂ (_⊕_ pcm₁) (cong proj₁ h₁) (cong proj₁ h₂))
(cong₂ (_⊕_ pcm₂) (cong proj₂ h₁) (cong proj₂ h₂))
}
; assoc = λ (a₁ , a₂) (b₁ , b₂) (c₁ , c₂) → cong₂ _,_ (⊕-assoc pcm₁ a₁ b₁ c₁) (⊕-assoc pcm₂ a₂ b₂ c₂)
}
; identity =
(λ (a₁ , a₂) → cong₂ _,_ (⊕-identityˡ pcm₁ a₁) (⊕-identityˡ pcm₂ a₂)) ,
(λ (a₁ , a₂) → cong₂ _,_ (⊕-identityʳ pcm₁ a₁) (⊕-identityʳ pcm₂ a₂))
}
; isCommutativeMonoid = record
{ isMonoid = record
{ isSemigroup = record
{ isMagma = record
{ isEquivalence = isEquivalence
; ∙-cong = λ h₁ h₂ →
cong₂ _,_
(cong₂ (_⊗_ pcm₁) (cong proj₁ h₁) (cong proj₁ h₂))
(cong₂ (_⊗_ pcm₂) (cong proj₂ h₁) (cong proj₂ h₂))
}
; assoc = λ (a₁ , a₂) (b₁ , b₂) (c₁ , c₂) → cong₂ _,_ (⊗-assoc pcm₁ a₁ b₁ c₁) (⊗-assoc pcm₂ a₂ b₂ c₂)
}
; identity =
(λ (a₁ , a₂) → cong₂ _,_ (⊗-identityˡ pcm₁ a₁) (⊗-identityˡ pcm₂ a₂)) ,
(λ (a₁ , a₂) → cong₂ _,_ (⊗-identityʳ pcm₁ a₁) (⊗-identityʳ pcm₂ a₂))
}
; comm = λ (a₁ , a₂) (b₁ , b₂) → cong₂ _,_ (⊗-comm pcm₁ a₁ b₁) (⊗-comm pcm₂ a₂ b₂)
}
; isCancellative = record
{ ∙-cancel-≡ =
(λ (x₁ , x₂) h → cong₂ _,_ (⊕-cancelˡ-≡ pcm₁ x₁ (cong proj₁ h)) (⊕-cancelˡ-≡ pcm₂ x₂ (cong proj₂ h))) ,
(λ (y₁ , y₂) (z₁ , z₂) h → cong₂ _,_ (⊕-cancelʳ-≡ pcm₁ y₁ z₁ (cong proj₁ h)) (⊕-cancelʳ-≡ pcm₂ y₂ z₂ (cong proj₂ h)))
}
; isPreorder = record
{ isEquivalence = isEquivalence
; reflexive = λ { refl → ≤-refl pcm₁ , ≤-refl pcm₂ }
; trans = λ (h₁ , h₂) (h₁' , h₂') → ≤-trans pcm₁ h₁ h₁' , ≤-trans pcm₂ h₂ h₂'
}
; isMonotone-⊕ = record
{ ∙-mono-≤ = λ (h₁ , h₂) (h₁' , h₂') → ⊕-mono-≤ pcm₁ h₁ h₁' , ⊕-mono-≤ pcm₂ h₂ h₂'
}
; isMonotone-⊗ = record
{ ∙-mono-≤ = λ (h₁ , h₂) (h₁' , h₂') → ⊗-mono-≤ pcm₁ h₁ h₁' , ⊗-mono-≤ pcm₂ h₂ h₂'
}
}
}
where open ParCostMonoid
ℕ²-ParCostMonoid : ParCostMonoid
ℕ²-ParCostMonoid = combineParCostMonoids ℕ-Work-ParCostMonoid ℕ-Span-ParCostMonoid
| 32.791045
| 127
| 0.540737
|
13a00528974561d24fb8d3fbc5dbd45653d00575
| 3,166
|
agda
|
Agda
|
misc/RecursiveDescent/InductiveWithFix/PBM.agda
|
yurrriq/parser-combinators
|
b396d35cc2cb7e8aea50b982429ee385f001aa88
|
[
"MIT"
] | 7
|
2016-12-13T05:23:14.000Z
|
2021-06-22T05:35:31.000Z
|
misc/RecursiveDescent/InductiveWithFix/PBM.agda
|
nad/parser-combinators
|
76774f54f466cfe943debf2da731074fe0c33644
|
[
"MIT"
] | 1
|
2018-01-22T22:21:41.000Z
|
2018-01-24T16:39:37.000Z
|
misc/RecursiveDescent/InductiveWithFix/PBM.agda
|
nad/parser-combinators
|
76774f54f466cfe943debf2da731074fe0c33644
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- A parser for PBM images; illustrates essential use of bind
------------------------------------------------------------------------
-- Note that I am using the simple "Plain PBM" format, and I try to
-- adhere to the following statement from the pbm man page:
--
-- "Programs that read this format should be as lenient as possible,
-- accepting anything that looks remotely like a bitmap."
-- The idea to write this particular parser was taken from "The Power
-- of Pi" by Oury and Swierstra.
module RecursiveDescent.InductiveWithFix.PBM where
import Data.Vec as Vec
open Vec using (Vec; _++_; [_])
import Data.List as List
open import Data.Nat
import Data.String as String
open String using (String) renaming (_++_ to _<+>_)
import Data.Char as Char
open Char using (Char; _==_)
open import Data.Product.Record
open import Data.Function
open import Data.Bool
open import Data.Unit
open import Data.Maybe
import Data.Nat.Show as N
open import Relation.Nullary
open import Relation.Binary.PropositionalEquality using (_≡_; refl)
open import RecursiveDescent.Index
open import RecursiveDescent.InductiveWithFix
open import RecursiveDescent.InductiveWithFix.Lib
open Token Char.decSetoid
------------------------------------------------------------------------
-- The PBM type
data Colour : Set where
white : Colour
black : Colour
Matrix : Set -> ℕ -> ℕ -> Set
Matrix a rows cols = Vec (Vec a cols) rows
record PBM : Set where
field
rows : ℕ
cols : ℕ
matrix : Matrix Colour rows cols
open PBM
makePBM : forall {rows cols} -> Matrix Colour rows cols -> PBM
makePBM m = record { rows = _; cols = _; matrix = m }
------------------------------------------------------------------------
-- Showing PBM images
showColour : Colour -> Char
showColour white = '0'
showColour black = '1'
show : PBM -> String
show i = "P1 # Generated using Agda.\n" <+>
N.show (cols i) <+> " " <+> N.show (rows i) <+> "\n" <+>
showMatrix (matrix i)
where
showMatrix = String.fromList ∘
Vec.toList ∘
Vec.concat ∘
Vec.map ((\xs -> xs ++ [ '\n' ]) ∘ Vec.map showColour)
------------------------------------------------------------------------
-- Parsing PBM images
data NT : ParserType₁ where
comment : NT _ ⊤
colour : NT _ Colour
pbm : NT _ PBM
grammar : Grammar Char NT
grammar comment = tt <$ sym '#' <⊛ sat' (not ∘ _==_ '\n') ⋆ <⊛ sym '\n'
grammar colour = white <$ sym '0'
∣ black <$ sym '1'
grammar pbm =
w∣c ⋆ ⊛>
string (String.toVec "P1") ⊛>
w∣c ⋆ ⊛>
number !>>= \cols -> -- _>>=_ works just as well.
w∣c + ⊛>
number >>= \rows -> -- _!>>=_ works just as well.
w∣c ⊛>
(makePBM <$> exactly rows (exactly cols (w∣c ⋆ ⊛> ! colour))) <⊛
any ⋆
where w∣c = whitespace ∣ ! comment
module Example where
open Vec
image = makePBM ((white ∷ black ∷ []) ∷
(black ∷ white ∷ []) ∷
(black ∷ black ∷ []) ∷ [])
ex₁ : parse-complete (! pbm) grammar (String.toList (show image)) ≡
List.[_] image
ex₁ = refl
| 28.522523
| 72
| 0.559697
|
41b34ddffd9f4acb7c6215f0d2752e44803d2d0d
| 5,003
|
agda
|
Agda
|
src/Data/PropFormula/Properties.agda
|
jonaprieto/agda-prop
|
a1730062a6aaced2bb74878c1071db06477044ae
|
[
"MIT"
] | 13
|
2017-05-01T16:45:41.000Z
|
2022-01-17T03:33:12.000Z
|
src/Data/PropFormula/Properties.agda
|
jonaprieto/agda-prop
|
a1730062a6aaced2bb74878c1071db06477044ae
|
[
"MIT"
] | 18
|
2017-03-08T14:33:10.000Z
|
2017-12-18T16:34:21.000Z
|
src/Data/PropFormula/Properties.agda
|
jonaprieto/agda-prop
|
a1730062a6aaced2bb74878c1071db06477044ae
|
[
"MIT"
] | 2
|
2017-03-30T16:41:56.000Z
|
2017-12-01T17:01:25.000Z
|
------------------------------------------------------------------------------
-- Agda-Prop Library.
-- Properties.
------------------------------------------------------------------------------
open import Data.Nat using ( ℕ )
module Data.PropFormula.Properties ( n : ℕ ) where
------------------------------------------------------------------------------
open import Data.Bool.Base using ( Bool; false; true; not; T )
open import Data.Fin using ( Fin ; suc; zero )
open import Data.PropFormula.Syntax n
open import Data.PropFormula.Dec n
open import Relation.Binary.PropositionalEquality using ( _≡_ ; refl ; cong )
------------------------------------------------------------------------------
suc-injective : ∀ {o} {m n : Fin o} → Fin.suc m ≡ Fin.suc n → m ≡ n
suc-injective refl = refl
var-injective : ∀ {x x₁} → Var x ≡ Var x₁ → x ≡ x₁
var-injective refl = refl
∧-injective₁ : ∀ {φ φ₁ ψ ψ₁} → (φ ∧ φ₁) ≡ (ψ ∧ ψ₁) → φ ≡ ψ
∧-injective₁ refl = refl
∧-injective₂ : ∀ {φ φ₁ ψ ψ₁} → (φ ∧ φ₁) ≡ (ψ ∧ ψ₁) → φ₁ ≡ ψ₁
∧-injective₂ refl = refl
∨-injective₁ : ∀ {φ φ₁ ψ ψ₁} → (φ ∨ φ₁) ≡ (ψ ∨ ψ₁) → φ ≡ ψ
∨-injective₁ refl = refl
∨-injective₂ : ∀ {φ φ₁ ψ ψ₁} → (φ ∨ φ₁) ≡ (ψ ∨ ψ₁) → φ₁ ≡ ψ₁
∨-injective₂ refl = refl
⊃-injective₁ : ∀ {φ φ₁ ψ ψ₁} → (φ ⊃ φ₁) ≡ (ψ ⊃ ψ₁) → φ ≡ ψ
⊃-injective₁ refl = refl
⊃-injective₂ : ∀ {φ φ₁ ψ ψ₁} → (φ ⊃ φ₁) ≡ (ψ ⊃ ψ₁) → φ₁ ≡ ψ₁
⊃-injective₂ refl = refl
⇔-injective₁ : ∀ {φ φ₁ ψ ψ₁} → (φ ⇔ φ₁) ≡ (ψ ⇔ ψ₁) → φ ≡ ψ
⇔-injective₁ refl = refl
⇔-injective₂ : ∀ {φ φ₁ ψ ψ₁} → (φ ⇔ φ₁) ≡ (ψ ⇔ ψ₁) → φ₁ ≡ ψ₁
⇔-injective₂ refl = refl
¬-injective : ∀ {φ ψ} → ¬ φ ≡ ¬ ψ → φ ≡ ψ
¬-injective refl = refl
-- Def.
_≟_ : {n : ℕ} → Decidable {A = Fin n} _≡_
zero ≟ zero = yes refl
zero ≟ suc y = no λ()
suc x ≟ zero = no λ()
suc x ≟ suc y with x ≟ y
... | yes x≡y = yes (cong Fin.suc x≡y)
... | no x≢y = no (λ r → x≢y (suc-injective r))
-- Def.
eq : (φ ψ : PropFormula) → Dec (φ ≡ ψ)
-- Equality with Var.
eq (Var x) ⊤ = no λ()
eq (Var x) ⊥ = no λ()
eq (Var x) (ψ ∧ ψ₁) = no λ()
eq (Var x) (ψ ∨ ψ₁) = no λ()
eq (Var x) (ψ ⊃ ψ₁) = no λ()
eq (Var x) (ψ ⇔ ψ₁) = no λ()
eq (Var x) (¬ ψ) = no λ()
eq (Var x) (Var x₁) with x ≟ x₁
... | yes refl = yes refl
... | no x≢x₁ = no (λ r → x≢x₁ (var-injective r))
-- Equality with ⊤.
eq ⊤ (Var x) = no λ()
eq ⊤ ⊥ = no λ()
eq ⊤ (ψ ∧ ψ₁) = no λ()
eq ⊤ (ψ ∨ ψ₁) = no λ()
eq ⊤ (ψ ⊃ ψ₁) = no λ()
eq ⊤ (ψ ⇔ ψ₁) = no λ()
eq ⊤ (¬ ψ) = no λ()
eq ⊤ ⊤ = yes refl
-- Equality with ⊥.
eq ⊥ (Var x) = no λ()
eq ⊥ ⊤ = no λ()
eq ⊥ (ψ ∧ ψ₁) = no λ()
eq ⊥ (ψ ∨ ψ₁) = no λ()
eq ⊥ (ψ ⊃ ψ₁) = no λ()
eq ⊥ (ψ ⇔ ψ₁) = no λ()
eq ⊥ (¬ ψ) = no λ()
eq ⊥ ⊥ = yes refl
-- Equality with ∧.
eq (φ ∧ φ₁) (Var x) = no λ()
eq (φ ∧ φ₁) ⊤ = no λ()
eq (φ ∧ φ₁) ⊥ = no λ()
eq (φ ∧ φ₁) (ψ ∨ ψ₁) = no λ()
eq (φ ∧ φ₁) (ψ ⊃ ψ₁) = no λ()
eq (φ ∧ φ₁) (ψ ⇔ ψ₁) = no λ()
eq (φ ∧ φ₁) (¬ ψ) = no λ()
eq (φ ∧ φ₁) (ψ ∧ ψ₁) with eq φ ψ | eq φ₁ ψ₁
... | yes refl | yes refl = yes refl
... | yes _ | no φ₁≢ψ₁ = no (λ r → φ₁≢ψ₁ (∧-injective₂ r))
... | no φ≢ψ | _ = no (λ r → φ≢ψ (∧-injective₁ r))
-- Equality with ∨.
eq (φ ∨ φ₁) (Var x) = no λ()
eq (φ ∨ φ₁) ⊤ = no λ()
eq (φ ∨ φ₁) ⊥ = no λ()
eq (φ ∨ φ₁) (ψ ∧ ψ₁) = no λ()
eq (φ ∨ φ₁) (ψ ⊃ ψ₁) = no λ()
eq (φ ∨ φ₁) (ψ ⇔ ψ₁) = no λ()
eq (φ ∨ φ₁) (¬ ψ) = no λ()
eq (φ ∨ φ₁) (ψ ∨ ψ₁) with eq φ ψ | eq φ₁ ψ₁
... | yes refl | yes refl = yes refl
... | yes _ | no φ₁≢ψ₁ = no (λ r → φ₁≢ψ₁ (∨-injective₂ r))
... | no φ≢ψ | _ = no (λ r → φ≢ψ (∨-injective₁ r))
-- Equality with ⊃.
eq (φ ⊃ φ₁) (Var x) = no λ()
eq (φ ⊃ φ₁) ⊤ = no λ()
eq (φ ⊃ φ₁) ⊥ = no λ()
eq (φ ⊃ φ₁) (ψ ∧ ψ₁) = no λ()
eq (φ ⊃ φ₁) (ψ ∨ ψ₁) = no λ()
eq (φ ⊃ φ₁) (ψ ⇔ ψ₁) = no λ()
eq (φ ⊃ φ₁) (¬ ψ) = no λ()
eq (φ ⊃ φ₁) (ψ ⊃ ψ₁) with eq φ ψ | eq φ₁ ψ₁
... | yes refl | yes refl = yes refl
... | yes _ | no φ₁≢ψ₁ = no (λ r → φ₁≢ψ₁ (⊃-injective₂ r))
... | no φ≢ψ | _ = no (λ r → φ≢ψ (⊃-injective₁ r))
-- Equality with ⇔.
eq (φ ⇔ φ₁) (Var x) = no λ()
eq (φ ⇔ φ₁) ⊤ = no λ()
eq (φ ⇔ φ₁) ⊥ = no λ()
eq (φ ⇔ φ₁) (ψ ∧ ψ₁) = no λ()
eq (φ ⇔ φ₁) (ψ ∨ ψ₁) = no λ()
eq (φ ⇔ φ₁) (ψ ⊃ ψ₁) = no λ()
eq (φ ⇔ φ₁) (¬ ψ) = no λ()
eq (φ ⇔ φ₁) (ψ ⇔ ψ₁) with eq φ ψ | eq φ₁ ψ₁
... | yes refl | yes refl = yes refl
... | yes _ | no φ₁≢ψ₁ = no (λ r → φ₁≢ψ₁ (⇔-injective₂ r))
... | no φ≢ψ | _ = no (λ r → φ≢ψ (⇔-injective₁ r))
-- Equality with ¬.
eq (¬ φ) (Var x) = no λ()
eq (¬ φ) ⊤ = no λ()
eq (¬ φ) ⊥ = no λ()
eq (¬ φ) (ψ ∧ ψ₁) = no λ()
eq (¬ φ) (ψ ∨ ψ₁) = no λ()
eq (¬ φ) (ψ ⊃ ψ₁) = no λ()
eq (¬ φ) (ψ ⇔ ψ₁) = no λ()
eq (¬ φ) (¬ ψ) with eq φ ψ
... | yes refl = yes refl
... | no φ≢ψ = no (λ r → φ≢ψ (¬-injective r))
-- Theorem.
subst
: ∀ {Γ} {φ ψ}
→ φ ≡ ψ
→ Γ ⊢ φ
→ Γ ⊢ ψ
subst refl o = o
-- Theorem.
substΓ
: ∀ {Γ₁ Γ₂} {φ}
→ Γ₁ ≡ Γ₂
→ Γ₁ ⊢ φ
→ Γ₂ ⊢ φ
substΓ refl o = o
| 27.949721
| 78
| 0.41715
|
1a796c9bfdc15dc94d53d24daa3d43c197ffcebb
| 3,234
|
agda
|
Agda
|
src/Examples/Sorting/Parallel.agda
|
jonsterling/agda-calf
|
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
|
[
"Apache-2.0"
] | 29
|
2021-07-14T03:18:28.000Z
|
2022-03-22T20:35:11.000Z
|
src/Examples/Sorting/Parallel.agda
|
jonsterling/agda-calf
|
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
|
[
"Apache-2.0"
] | null | null | null |
src/Examples/Sorting/Parallel.agda
|
jonsterling/agda-calf
|
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
|
[
"Apache-2.0"
] | 2
|
2021-10-06T10:28:24.000Z
|
2022-01-29T08:12:01.000Z
|
{-# OPTIONS --prop --rewriting #-}
module Examples.Sorting.Parallel where
open import Examples.Sorting.Parallel.Comparable
open import Calf costMonoid
open import Calf.Types.Nat
open import Calf.Types.List
open import Relation.Binary.PropositionalEquality as Eq using (_≡_)
open import Data.Product using (_,_)
open import Data.Nat using (z≤n; s≤s)
test/forward = 1 ∷ 2 ∷ 3 ∷ 4 ∷ 5 ∷ 6 ∷ 7 ∷ 8 ∷ 9 ∷ 10 ∷ 11 ∷ 12 ∷ 13 ∷ 14 ∷ 15 ∷ 16 ∷ []
test/backward = 16 ∷ 15 ∷ 14 ∷ 13 ∷ 12 ∷ 11 ∷ 10 ∷ 9 ∷ 8 ∷ 7 ∷ 6 ∷ 5 ∷ 4 ∷ 3 ∷ 2 ∷ 1 ∷ []
test/shuffled = 4 ∷ 8 ∷ 12 ∷ 16 ∷ 13 ∷ 3 ∷ 5 ∷ 14 ∷ 9 ∷ 6 ∷ 7 ∷ 10 ∷ 11 ∷ 1 ∷ 2 ∷ 15 ∷ []
module Ex/InsertionSort where
import Examples.Sorting.Parallel.InsertionSort NatComparable as Sort
list' = list nat
ex/insert : cmp (F list')
ex/insert = Sort.insert 3 (1 ∷ 2 ∷ 4 ∷ [])
ex/sort : cmp (F list')
ex/sort = Sort.sort (1 ∷ 5 ∷ 3 ∷ 1 ∷ 2 ∷ [])
ex/sort/forward : cmp (F list')
ex/sort/forward = Sort.sort test/forward -- cost: 15 , 15
ex/sort/backward : cmp (F list')
ex/sort/backward = Sort.sort test/backward -- cost: 120 , 120
ex/sort/shuffled : cmp (F list')
ex/sort/shuffled = Sort.sort test/shuffled -- cost: 76 , 76
module Ex/MergeSort where
import Examples.Sorting.Parallel.MergeSort NatComparable as Sort
list' = list nat
ex/split : cmp (F Sort.pair)
ex/split = Sort.split (6 ∷ 2 ∷ 8 ∷ 3 ∷ 1 ∷ 8 ∷ 5 ∷ [])
ex/merge : cmp (F list')
ex/merge = Sort.merge (2 ∷ 3 ∷ 6 ∷ 8 ∷ [] , 1 ∷ 5 ∷ 8 ∷ [])
ex/sort : cmp (F list')
ex/sort = Sort.sort (1 ∷ 5 ∷ 3 ∷ 1 ∷ 2 ∷ [])
ex/sort/forward : cmp (F list')
ex/sort/forward = Sort.sort test/forward -- cost: 32, 15
ex/sort/backward : cmp (F list')
ex/sort/backward = Sort.sort test/backward -- cost: 32, 15
ex/sort/shuffled : cmp (F list')
ex/sort/shuffled = Sort.sort test/shuffled -- cost: 47, 26
module Ex/MergeSortPar where
import Examples.Sorting.Parallel.MergeSortPar NatComparable as Sort
list' = list nat
ex/split : cmp (F Sort.pair)
ex/split = Sort.split (6 ∷ 2 ∷ 8 ∷ 3 ∷ 1 ∷ 8 ∷ 5 ∷ [])
ex/splitMid : cmp (F Sort.triple)
ex/splitMid = Sort.splitMid test/forward (s≤s z≤n)
ex/splitBy : cmp (F Sort.pair)
ex/splitBy = Sort.splitBy test/forward 5
ex/merge : cmp (F list')
ex/merge = Sort.merge (2 ∷ 3 ∷ 6 ∷ 8 ∷ [] , 1 ∷ 5 ∷ 8 ∷ [])
ex/sort : cmp (F list')
ex/sort = Sort.sort (1 ∷ 5 ∷ 3 ∷ 1 ∷ 2 ∷ [])
ex/sort/forward : cmp (F list')
ex/sort/forward = Sort.sort test/forward -- cost: 40, 21
ex/sort/backward : cmp (F list')
ex/sort/backward = Sort.sort test/backward -- cost: 40, 21
ex/sort/shuffled : cmp (F list')
ex/sort/shuffled = Sort.sort test/shuffled -- cost: 43, 17
module SortEquivalence (M : Comparable) where
open Comparable M
open import Examples.Sorting.Parallel.Core M
import Examples.Sorting.Parallel.InsertionSort M as ISort
import Examples.Sorting.Parallel.MergeSort M as MSort
import Examples.Sorting.Parallel.MergeSortPar M as PSort
isort≡msort : ◯ (ISort.sort ≡ MSort.sort)
isort≡msort = IsSort⇒≡ ISort.sort ISort.sort/correct MSort.sort MSort.sort/correct
msort≡psort : ◯ (MSort.sort ≡ PSort.sort)
msort≡psort = IsSort⇒≡ MSort.sort MSort.sort/correct PSort.sort PSort.sort/correct
| 31.096154
| 89
| 0.639147
|
13a3440b21bb7718db82ade7d4b61136915f3a11
| 5,869
|
agda
|
Agda
|
src/Equality/Path/Univalence.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | 3
|
2020-05-21T22:58:50.000Z
|
2021-09-02T17:18:15.000Z
|
src/Equality/Path/Univalence.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | null | null | null |
src/Equality/Path/Univalence.agda
|
nad/equality
|
402b20615cfe9ca944662380d7b2d69b0f175200
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- A proof of univalence
------------------------------------------------------------------------
-- The code is based on code by Anders Mörtberg from Agda's reference
-- manual or the cubical library.
{-# OPTIONS --cubical --safe #-}
module Equality.Path.Univalence where
open import Agda.Builtin.Cubical.Glue as Glue hiding (_≃_)
open import Equality.Path
open import Prelude
open import Equivalence equality-with-J as Eq using (_≃_)
import Equivalence.Contractible-preimages equality-with-J as CP
import Equivalence.Half-adjoint equality-with-J as HA
open import Function-universe equality-with-J hiding (id)
open import Preimage equality-with-J
open import Univalence-axiom equality-with-J hiding (≃⇒≡)
private
variable
a b ℓ : Level
A : Type a
private
-- Conversions between CP._≃_ and Glue._≃_.
≃-CP⇒≃-Glue : {B : Type b} → A CP.≃ B → A Glue.≃ B
≃-CP⇒≃-Glue = Σ-map id (λ eq → record { equiv-proof = eq })
≃-Glue⇒≃-CP : {B : Type b} → A Glue.≃ B → A CP.≃ B
≃-Glue⇒≃-CP = Σ-map id Glue.isEquiv.equiv-proof
-- Equivalences can be converted to equalities (if the two types live
-- in the same universe).
≃-CP⇒≡ : {A B : Type ℓ} → A CP.≃ B → A ≡ B
≃-CP⇒≡ {A = A} {B = B} A≃B = λ i → primGlue B
(λ { (i = 0̲) → A
; (i = 1̲) → B
})
(λ { (i = 0̲) → ≃-CP⇒≃-Glue A≃B
; (i = 1̲) → ≃-CP⇒≃-Glue CP.id
})
-- If ≃-CP⇒≡ is applied to the identity equivalence, then the result
-- is equal to CP.id.
≃-CP⇒≡-id : ≃-CP⇒≡ CP.id ≡ refl {x = A}
≃-CP⇒≡-id {A = A} = λ i j → primGlue A
{φ = max i (max j (- j))}
(λ _ → A)
(λ _ → ≃-CP⇒≃-Glue CP.id)
-- ≃-CP⇒≡ is a left inverse of CP.≡⇒≃.
≃-CP⇒≡∘≡⇒≃ :
{A B : Type ℓ} (A≡B : A ≡ B) →
≃-CP⇒≡ (CP.≡⇒≃ A≡B) ≡ A≡B
≃-CP⇒≡∘≡⇒≃ = elim
(λ A≡B → ≃-CP⇒≡ (CP.≡⇒≃ A≡B) ≡ A≡B)
(λ A →
≃-CP⇒≡ (CP.≡⇒≃ refl) ≡⟨ cong ≃-CP⇒≡ CP.≡⇒≃-refl ⟩
≃-CP⇒≡ CP.id ≡⟨ ≃-CP⇒≡-id ⟩∎
refl ∎)
-- ≃-CP⇒≡ is a right inverse of CP.≡⇒≃.
≡⇒≃∘≃-CP⇒≡ :
{A B : Type ℓ} (A≃B : A CP.≃ B) →
CP.≡⇒≃ (≃-CP⇒≡ A≃B) ≡ A≃B
≡⇒≃∘≃-CP⇒≡ {A = A} {B = B} A≃B =
Σ-≡,≡→≡
(proj₁ (CP.≡⇒≃ (≃-CP⇒≡ A≃B)) ≡⟨⟩
proj₁ (transport (λ i → A CP.≃ ≃-CP⇒≡ A≃B i) 0̲ CP.id) ≡⟨⟩
transport (λ i → A → ≃-CP⇒≡ A≃B i) 0̲ id ≡⟨⟩
transport (λ _ → A → B) 0̲ (proj₁ A≃B) ≡⟨ cong (_$ proj₁ A≃B) $ transport-refl 0̲ ⟩∎
proj₁ A≃B ∎)
(CP.propositional ext _ _ _)
-- Univalence for CP._≃_.
univ-CP : CP.Univalence ℓ
univ-CP =
Is-equivalence≃Is-equivalence-CP _ $
_≃_.is-equivalence $
Eq.↔→≃ _ ≃-CP⇒≡ ≡⇒≃∘≃-CP⇒≡ ≃-CP⇒≡∘≡⇒≃
-- Univalence.
univ : ∀ {ℓ} → Univalence ℓ
univ {A = A} {B = B} = record
{ univalence = from , proofs
}
where
univ′ : Univalence′ A B
univ′ = _≃_.from (Univalence≃Univalence-CP ext) univ-CP
from : A ≃ B → A ≡ B
from = proj₁ (Univalence′.univalence univ′)
abstract
proofs : HA.Proofs ≡⇒≃ from
proofs = proj₂ (Univalence′.univalence univ′)
-- Equivalences can be converted to equalities (if the two types live
-- in the same universe).
≃⇒≡ : {A B : Type ℓ} → A ≃ B → A ≡ B
≃⇒≡ = _≃_.from Eq.⟨ _ , Univalence′.univalence univ ⟩
private
-- The type primGlue A B f is equivalent to A.
primGlue≃-CP :
(φ : I)
(B : Partial φ (Type ℓ))
(f : PartialP φ (λ x → B x Glue.≃ A)) →
primGlue A B f CP.≃ A
primGlue≃-CP {A = A} φ B f =
prim^unglue {φ = φ}
, λ x →
( prim^glue
(λ p → CP.inverse (proj₂ (f-CP p)) x)
(hcomp (lemma₁ x) x)
, (hcomp (lemma₁ x) x ≡⟨ sym $ hfill (lemma₁ x) (inˢ x) ⟩∎
x ∎)
)
, λ y i →
prim^glue (λ { (φ = 1̲) → proj₁ (lemma₂ is-one y i) })
(hcomp (lemma₃ y i) x)
, (hcomp (lemma₃ y i) x ≡⟨ sym $ hfill (lemma₃ y i) (inˢ x) ⟩∎
x ∎)
where
f-CP : PartialP φ (λ x → B x CP.≃ A)
f-CP p = ≃-Glue⇒≃-CP (f p)
lemma₁ : A → ∀ i → Partial φ A
lemma₁ x i (φ = 1̲) = (
x ≡⟨ sym (CP.right-inverse-of (proj₂ (f-CP is-one)) x) ⟩∎
proj₁ (f-CP _) (CP.inverse (proj₂ (f-CP _)) x) ∎) i
lemma₂ :
∀ {x} p (y : proj₁ (f-CP p) ⁻¹ x) →
( CP.inverse (proj₂ (f-CP p)) x
, CP.right-inverse-of (proj₂ (f-CP p)) x
) ≡
y
lemma₂ {x} p = CP.irrelevance (proj₂ (f-CP p)) x
lemma₃ : ∀ {x} → prim^unglue {e = f} ⁻¹ x →
∀ i → I → Partial (max φ (max i (- i))) A
lemma₃ y i j (φ = 1̲) = sym (proj₂ (lemma₂ is-one y i)) j
lemma₃ {x} _ i j (i = 0̲) = hfill (lemma₁ x) (inˢ x) j
lemma₃ y i j (i = 1̲) = sym (proj₂ y) j
-- An alternative formulation of univalence.
other-univ : Other-univalence ℓ
other-univ {ℓ = ℓ} {B = B} = $⟨ other-univ-CP ⟩
Contractible (∃ λ (A : Type ℓ) → A CP.≃ B) ↝⟨ (H-level-cong _ 0 $
∃-cong λ _ → inverse $
≃≃≃-CP {k = equivalence} ext) ⦂ (_ → _) ⟩□
Contractible (∃ λ (A : Type ℓ) → A ≃ B) □
where
other-univ-CP : Contractible (∃ λ (A : Type ℓ) → A CP.≃ B)
other-univ-CP =
(B , CP.id)
, λ (A , A≃B) i →
let C : ∀ i → Partial (max i (- i)) (Type ℓ)
C = λ { i (i = 0̲) → B
; i (i = 1̲) → A
}
f : ∀ i → PartialP (max i (- i)) (λ j → C i j Glue.≃ B)
f = λ { i (i = 0̲) → ≃-CP⇒≃-Glue CP.id
; i (i = 1̲) → ≃-CP⇒≃-Glue A≃B
}
in
primGlue _ _ (f i)
, primGlue≃-CP _ _ (f i)
| 31.05291
| 109
| 0.447436
|
13a7711e4f124b1618b713d99240a893e9c3747c
| 3,787
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Data/Product.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Product.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Product.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Products
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Product where
open import Function
open import Level
open import Relation.Nullary
open import Agda.Builtin.Equality
infixr 4 _,′_
infix 4 -,_
infixr 2 _×_ _-×-_ _-,-_
------------------------------------------------------------------------
-- Definition
open import Agda.Builtin.Sigma hiding (module Σ) public renaming (fst to proj₁; snd to proj₂)
module Σ = Agda.Builtin.Sigma.Σ renaming (fst to proj₁; snd to proj₂)
-- The syntax declaration below is attached to Σ-syntax, to make it
-- easy to import Σ without the special syntax.
infix 2 Σ-syntax
Σ-syntax : ∀ {a b} (A : Set a) → (A → Set b) → Set (a ⊔ b)
Σ-syntax = Σ
syntax Σ-syntax A (λ x → B) = Σ[ x ∈ A ] B
∃ : ∀ {a b} {A : Set a} → (A → Set b) → Set (a ⊔ b)
∃ = Σ _
∃-syntax : ∀ {a b} {A : Set a} → (A → Set b) → Set (a ⊔ b)
∃-syntax = ∃
syntax ∃-syntax (λ x → B) = ∃[ x ] B
∄ : ∀ {a b} {A : Set a} → (A → Set b) → Set (a ⊔ b)
∄ P = ¬ ∃ P
∄-syntax : ∀ {a b} {A : Set a} → (A → Set b) → Set (a ⊔ b)
∄-syntax = ∄
syntax ∄-syntax (λ x → B) = ∄[ x ] B
∃₂ : ∀ {a b c} {A : Set a} {B : A → Set b}
(C : (x : A) → B x → Set c) → Set (a ⊔ b ⊔ c)
∃₂ C = ∃ λ a → ∃ λ b → C a b
_×_ : ∀ {a b} (A : Set a) (B : Set b) → Set (a ⊔ b)
A × B = Σ[ x ∈ A ] B
_,′_ : ∀ {a b} {A : Set a} {B : Set b} → A → B → A × B
_,′_ = _,_
------------------------------------------------------------------------
-- Unique existence
-- Parametrised on the underlying equality.
∃! : ∀ {a b ℓ} {A : Set a} →
(A → A → Set ℓ) → (A → Set b) → Set (a ⊔ b ⊔ ℓ)
∃! _≈_ B = ∃ λ x → B x × (∀ {y} → B y → x ≈ y)
------------------------------------------------------------------------
-- Functions
-- Sometimes the first component can be inferred.
-,_ : ∀ {a b} {A : Set a} {B : A → Set b} {x} → B x → ∃ B
-, y = _ , y
<_,_> : ∀ {a b c} {A : Set a} {B : A → Set b} {C : ∀ {x} → B x → Set c}
(f : (x : A) → B x) → ((x : A) → C (f x)) →
((x : A) → Σ (B x) C)
< f , g > x = (f x , g x)
map : ∀ {a b p q}
{A : Set a} {B : Set b} {P : A → Set p} {Q : B → Set q} →
(f : A → B) → (∀ {x} → P x → Q (f x)) →
Σ A P → Σ B Q
map f g (x , y) = (f x , g y)
map₁ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} →
(A → B) → A × C → B × C
map₁ f = map f id
map₂ : ∀ {a b c} {A : Set a} {B : A → Set b} {C : A → Set c} →
(∀ {x} → B x → C x) → Σ A B → Σ A C
map₂ f = map id f
zip : ∀ {a b c p q r}
{A : Set a} {B : Set b} {C : Set c}
{P : A → Set p} {Q : B → Set q} {R : C → Set r} →
(_∙_ : A → B → C) →
(∀ {x y} → P x → Q y → R (x ∙ y)) →
Σ A P → Σ B Q → Σ C R
zip _∙_ _∘_ (a , p) (b , q) = ((a ∙ b) , (p ∘ q))
swap : ∀ {a b} {A : Set a} {B : Set b} → A × B → B × A
swap (x , y) = (y , x)
_-×-_ : ∀ {a b i j} {A : Set a} {B : Set b} →
(A → B → Set i) → (A → B → Set j) → (A → B → Set _)
f -×- g = f -[ _×_ ]- g
_-,-_ : ∀ {a b c d} {A : Set a} {B : Set b} {C : Set c} {D : Set d} →
(A → B → C) → (A → B → D) → (A → B → C × D)
f -,- g = f -[ _,_ ]- g
curry : ∀ {a b c} {A : Set a} {B : A → Set b} {C : Σ A B → Set c} →
((p : Σ A B) → C p) →
((x : A) → (y : B x) → C (x , y))
curry f x y = f (x , y)
curry′ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} →
(A × B → C) → (A → B → C)
curry′ = curry
uncurry : ∀ {a b c} {A : Set a} {B : A → Set b} {C : Σ A B → Set c} →
((x : A) → (y : B x) → C (x , y)) →
((p : Σ A B) → C p)
uncurry f (x , y) = f x y
uncurry′ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} →
(A → B → C) → (A × B → C)
uncurry′ = uncurry
| 28.051852
| 93
| 0.374175
|
3171b843d33d9e612be32cfa102d766bc60c5c3c
| 512
|
agda
|
Agda
|
list-test.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 29
|
2019-02-06T13:09:31.000Z
|
2022-03-04T15:05:12.000Z
|
list-test.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 8
|
2018-07-09T22:53:38.000Z
|
2022-03-22T03:43:34.000Z
|
list-test.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 17
|
2018-12-03T22:38:15.000Z
|
2021-11-28T20:13:21.000Z
|
module list-test where
open import bool
open import list
open import nat
open import list-to-string
open import bool-to-string
open import eq
test1 : 𝕃 𝔹
test1 = tt :: tt :: tt :: []
test2 : 𝕃 𝔹
test2 = ff :: ff :: []
test3 = test1 ++ test2
test-lem : test3 ≡ tt :: tt :: tt :: ff :: ff :: []
test-lem = refl
test-lem2 : reverse test3 ≡ ff :: ff :: tt :: tt :: tt :: []
test-lem2 = refl
test3-string = 𝕃-to-string 𝔹-to-string ", " test3
test4-even = filter is-even (1 :: 2 :: 3 :: 4 :: 5 :: 6 :: 7 :: [])
| 19.692308
| 67
| 0.589844
|
ad0d7315b3ce395e32e8db28346acd58ed00b3bc
| 2,573
|
agda
|
Agda
|
src/Categories/Category/Construction/Kleisli.agda
|
glittershark/agda-categories
|
2128fab9e8d341364cbf784bb17c547bf73891de
|
[
"MIT"
] | null | null | null |
src/Categories/Category/Construction/Kleisli.agda
|
glittershark/agda-categories
|
2128fab9e8d341364cbf784bb17c547bf73891de
|
[
"MIT"
] | null | null | null |
src/Categories/Category/Construction/Kleisli.agda
|
glittershark/agda-categories
|
2128fab9e8d341364cbf784bb17c547bf73891de
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
module Categories.Category.Construction.Kleisli where
open import Level
open import Categories.Category
open import Categories.Functor using (Functor; module Functor)
open import Categories.NaturalTransformation hiding (id)
open import Categories.Monad
import Categories.Morphism.Reasoning as MR
private
variable
o ℓ e : Level
Kleisli : {𝒞 : Category o ℓ e} → Monad 𝒞 → Category o ℓ e
Kleisli {𝒞 = 𝒞} M = record
{ Obj = Obj
; _⇒_ = λ A B → (A ⇒ F₀ B)
; _≈_ = _≈_
; _∘_ = λ f g → (μ.η _ ∘ F₁ f) ∘ g
; id = η.η _
; assoc = assoc′
; sym-assoc = Equiv.sym assoc′
; identityˡ = identityˡ′
; identityʳ = identityʳ′
; identity² = identity²′
; equiv = equiv
; ∘-resp-≈ = λ f≈h g≈i → ∘-resp-≈ (∘-resp-≈ʳ (F-resp-≈ f≈h)) g≈i
}
where
module M = Monad M
open M using (μ; η; F)
open Functor F
open Category 𝒞
open HomReasoning
open MR 𝒞
-- shorthands to make the proofs nicer
F≈ = F-resp-≈
assoc′ : ∀ {A B C D} {f : A ⇒ F₀ B} {g : B ⇒ F₀ C} {h : C ⇒ F₀ D}
→ (μ.η D ∘ (F₁ ((μ.η D ∘ F₁ h) ∘ g))) ∘ f ≈ (μ.η D ∘ F₁ h) ∘ ((μ.η C ∘ F₁ g) ∘ f)
assoc′ {A} {B} {C} {D} {f} {g} {h} =
begin
(μ.η D ∘ F₁ ((μ.η D ∘ F₁ h) ∘ g)) ∘ f ≈⟨ assoc ⟩
μ.η D ∘ (F₁ ((μ.η D ∘ F₁ h) ∘ g) ∘ f) ≈⟨ refl⟩∘⟨ (F≈ assoc ⟩∘⟨refl ) ⟩
μ.η D ∘ (F₁ (μ.η D ∘ (F₁ h ∘ g)) ∘ f) ≈⟨ refl⟩∘⟨ (homomorphism ⟩∘⟨refl) ⟩
μ.η D ∘ ((F₁ (μ.η D) ∘ F₁ (F₁ h ∘ g)) ∘ f) ≈⟨ refl⟩∘⟨ assoc ○ sym-assoc ⟩
(μ.η D ∘ F₁ (μ.η D)) ∘ (F₁ (F₁ h ∘ g) ∘ f) ≈⟨ M.assoc ⟩∘⟨refl ○ assoc ⟩
μ.η D ∘ (μ.η (F₀ D) ∘ F₁ (F₁ h ∘ g) ∘ f) ≈⟨ refl⟩∘⟨ refl⟩∘⟨ homomorphism ⟩∘⟨refl ⟩
μ.η D ∘ μ.η (F₀ D) ∘ (F₁ (F₁ h) ∘ F₁ g) ∘ f ≈⟨ refl⟩∘⟨ center⁻¹ (μ.commute h) Equiv.refl ⟩
μ.η D ∘ ((F₁ h ∘ μ.η C) ∘ F₁ g ∘ f) ≈⟨ refl⟩∘⟨ center Equiv.refl ⟩
μ.η D ∘ (F₁ h ∘ (μ.η C ∘ F₁ g) ∘ f) ≈⟨ sym-assoc ⟩
(μ.η D ∘ F₁ h) ∘ ((μ.η C ∘ F₁ g) ∘ f) ∎
identityˡ′ : ∀ {A B} {f : A ⇒ F₀ B} → (μ.η B ∘ F₁ (η.η B)) ∘ f ≈ f
identityˡ′ {A} {B} {f} = elimˡ M.identityˡ
identityʳ′ : ∀ {A B} {f : A ⇒ F₀ B} → (μ.η B ∘ F₁ f) ∘ η.η A ≈ f
identityʳ′ {A} {B} {f} =
begin
(μ.η B ∘ F₁ f) ∘ η.η A ≈⟨ assoc ⟩
μ.η B ∘ (F₁ f ∘ η.η A) ≈˘⟨ refl⟩∘⟨ η.commute f ⟩
μ.η B ∘ (η.η (F₀ B) ∘ f) ≈⟨ sym-assoc ⟩
(μ.η B ∘ η.η (F₀ B)) ∘ f ≈⟨ elimˡ M.identityʳ ⟩
f
∎
identity²′ : {A : Obj} → (μ.η A ∘ F₁ (η.η A)) ∘ η.η A ≈ η.η A
identity²′ = elimˡ M.identityˡ
| 35.736111
| 98
| 0.467936
|
2f0d3ee388ad2f7d5533ec83970bc8fc7eb05ad6
| 4,461
|
agda
|
Agda
|
Numbers/Modulo/Addition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 4
|
2019-08-08T12:44:19.000Z
|
2022-01-28T06:04:15.000Z
|
Numbers/Modulo/Addition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 14
|
2019-01-06T21:11:59.000Z
|
2020-04-11T11:03:39.000Z
|
Numbers/Modulo/Addition.agda
|
Smaug123/agdaproofs
|
0f4230011039092f58f673abcad8fb0652e6b562
|
[
"MIT"
] | 1
|
2021-11-29T13:23:07.000Z
|
2021-11-29T13:23:07.000Z
|
{-# OPTIONS --safe --warning=error --without-K #-}
-- These are explicitly with-K, because we currently encode an element of Zn as
-- a natural together with a proof that it is small.
open import LogicalFormulae
open import Numbers.Naturals.Semiring
open import Numbers.Naturals.Order
open import Semirings.Definition
open import Orders.Total.Definition
open import Numbers.Modulo.Definition
open import Numbers.Modulo.ModuloFunction
open import Numbers.Naturals.Order.Lemmas
module Numbers.Modulo.Addition where
open TotalOrder ℕTotalOrder
_+n_ : {n : ℕ} .(pr : 0 <N n) → ℤn n pr → ℤn n pr → ℤn n pr
_+n_ {n} pr a b = record { x = mod n pr (ℤn.x a +N ℤn.x b) ; xLess = mod<N pr _ }
plusZnIdentityRight : {n : ℕ} → .(pr : 0 <N n) → (a : ℤn n pr) → (_+n_ pr a record { x = 0 ; xLess = pr }) ≡ a
plusZnIdentityRight 0<n record { x = x ; xLess = xLess } rewrite Semiring.sumZeroRight ℕSemiring x = equalityZn (modIsMod 0<n x (<NProp xLess))
plusZnIdentityLeft : {n : ℕ} → .(pr : 0 <N n) → (a : ℤn n pr) → _+n_ pr (record { x = 0 ; xLess = pr }) a ≡ a
plusZnIdentityLeft 0<n record { x = x ; xLess = xLess } = equalityZn (modIsMod 0<n x (<NProp xLess))
plusZnCommutative : {n : ℕ} → .(pr : 0 <N n) → (a b : ℤn n pr) → _+n_ pr a b ≡ _+n_ pr b a
plusZnCommutative {n} 0<n a b = equalityZn (applyEquality (mod n 0<n) (Semiring.commutative ℕSemiring (ℤn.x a) _))
plusZnAssociative' : {n : ℕ} → .(pr : 0 <N n) → {a b c : ℕ} → (a <N n) → (b <N n) → (c <N n) → mod n pr ((mod n pr (a +N b)) +N c) ≡ mod n pr (a +N (mod n pr (b +N c)))
plusZnAssociative' 0<n {a} {b} {c} a<n b<n c<n with modAddition 0<n a<n b<n
plusZnAssociative' {n} 0<n {a} {b} {c} a<n b<n c<n | inl a+b=mod with modAddition 0<n b<n c<n
... | inl b+c=mod rewrite equalityCommutative (a+b=mod) | equalityCommutative (b+c=mod) = applyEquality (mod _ 0<n) (equalityCommutative (Semiring.+Associative ℕSemiring a b c))
... | inr b+c=n+mod rewrite equalityCommutative (a+b=mod) | equalityCommutative (modAnd+n 0<n (a +N mod _ 0<n (b +N c))) | Semiring.+Associative ℕSemiring n a (mod _ 0<n (b +N c)) | Semiring.commutative ℕSemiring n a | equalityCommutative (Semiring.+Associative ℕSemiring a n (mod _ 0<n (b +N c))) | equalityCommutative b+c=n+mod = applyEquality (mod _ 0<n) (equalityCommutative (Semiring.+Associative ℕSemiring a b c))
plusZnAssociative' 0<n {a} {b} {c} a<n b<n c<n | inr a+b=n+mod with modAddition 0<n b<n c<n
plusZnAssociative' {n} 0<n {a} {b} {c} a<n b<n c<n | inr a+b=n+mod | inl b+c=mod rewrite equalityCommutative b+c=mod | equalityCommutative (modAnd+n 0<n (mod _ 0<n (a +N b) +N c)) | Semiring.+Associative ℕSemiring n (mod _ 0<n (a +N b)) c | equalityCommutative a+b=n+mod = applyEquality (mod _ 0<n) (equalityCommutative (Semiring.+Associative ℕSemiring a b c))
plusZnAssociative' {n} 0<n {a} {b} {c} a<n b<n c<n | inr a+b=n+mod | inr b+c=n+mod rewrite equalityCommutative (modAnd+n 0<n ((mod _ 0<n (a +N b)) +N c)) | equalityCommutative (modAnd+n 0<n (a +N mod _ 0<n (b +N c))) | Semiring.+Associative ℕSemiring n (mod _ 0<n (a +N b)) c | equalityCommutative (a+b=n+mod) | Semiring.commutative ℕSemiring a (mod n 0<n (b +N c)) | Semiring.+Associative ℕSemiring n (mod n 0<n (b +N c)) a | equalityCommutative b+c=n+mod | Semiring.commutative ℕSemiring (b +N c) a = applyEquality (mod _ 0<n) (equalityCommutative (Semiring.+Associative ℕSemiring a b c))
plusZnAssociative : {n : ℕ} → .(pr : 0 <N n) → (a b c : ℤn n pr) → _+n_ pr (_+n_ pr a b) c ≡ _+n_ pr a (_+n_ pr b c)
plusZnAssociative {succ n} 0<sn record { x = a ; xLess = aLess } record { x = b ; xLess = bLess } record { x = c ; xLess = cLess } = equalityZn t
where
ma = mod (succ n) 0<sn a
mb = mod (succ n) 0<sn b
mc = mod (succ n) 0<sn c
v : mod (succ n) 0<sn ((mod (succ n) 0<sn (ma +N mb)) +N mc) ≡ mod (succ n) 0<sn (ma +N mod (succ n) 0<sn (mb +N mc))
v = plusZnAssociative' 0<sn (mod<N 0<sn a) (mod<N 0<sn b) (mod<N 0<sn c)
u : mod (succ n) 0<sn ((mod (succ n) 0<sn (mod (succ n) 0<sn a +N (mod (succ n) 0<sn b))) +N c) ≡ mod (succ n) 0<sn (a +N mod (succ n) 0<sn ((mod (succ n) 0<sn b) +N (mod (succ n) 0<sn c)))
u rewrite equalityCommutative (modIsMod 0<sn c (<NProp cLess)) | equalityCommutative (modIsMod 0<sn a (<NProp aLess)) | modIdempotent 0<sn a | modIdempotent 0<sn c = v
t : mod (succ n) 0<sn (mod (succ n) 0<sn (a +N b) +N c) ≡ mod (succ n) 0<sn (a +N mod (succ n) 0<sn (b +N c))
t rewrite modExtracts {succ n} 0<sn a b | modExtracts {succ n} 0<sn b c = u
| 89.22
| 590
| 0.643129
|
227a3fffe974f902edba3ffe9546b418a9e9022c
| 1,285
|
agda
|
Agda
|
Cubical/Algebra/CommRing/Instances/UnivariatePoly.agda
|
howsiyu/cubical
|
1b9c97a2140fe96fe636f4c66beedfd7b8096e8f
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/CommRing/Instances/UnivariatePoly.agda
|
howsiyu/cubical
|
1b9c97a2140fe96fe636f4c66beedfd7b8096e8f
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/CommRing/Instances/UnivariatePoly.agda
|
howsiyu/cubical
|
1b9c97a2140fe96fe636f4c66beedfd7b8096e8f
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe #-}
module Cubical.Algebra.CommRing.Instances.UnivariatePoly where
open import Cubical.Foundations.Prelude
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.Polynomials.Univariate.Base
open import Cubical.Algebra.Polynomials.Univariate.Properties
private
variable
ℓ : Level
UnivariatePoly : (CommRing ℓ) → CommRing ℓ
UnivariatePoly R = (PolyMod.Poly R) , str
where
open CommRingStr --(snd R)
str : CommRingStr (PolyMod.Poly R)
0r str = PolyModTheory.0P R
1r str = PolyModTheory.1P R
_+_ str = PolyModTheory._Poly+_ R
_·_ str = PolyModTheory._Poly*_ R
- str = PolyModTheory.Poly- R
isCommRing str = makeIsCommRing (PolyMod.isSetPoly R)
(PolyModTheory.Poly+Assoc R)
(PolyModTheory.Poly+Rid R)
(PolyModTheory.Poly+Inverses R)
(PolyModTheory.Poly+Comm R)
(PolyModTheory.Poly*Associative R)
(PolyModTheory.Poly*Rid R)
(PolyModTheory.Poly*LDistrPoly+ R)
(PolyModTheory.Poly*Commutative R)
| 37.794118
| 72
| 0.565759
|
57d63313a256a4144162edcd53e05b6366695dc3
| 798
|
agda
|
Agda
|
focus-formation.agda
|
hazelgrove/hazel-palette-agda
|
c3225acc3c94c56376c6842b82b8b5d76912df2a
|
[
"MIT"
] | 4
|
2020-10-04T06:45:06.000Z
|
2021-12-19T15:38:31.000Z
|
focus-formation.agda
|
hazelgrove/hazel-palette-agda
|
c3225acc3c94c56376c6842b82b8b5d76912df2a
|
[
"MIT"
] | 9
|
2020-09-30T20:27:56.000Z
|
2020-10-20T20:44:13.000Z
|
focus-formation.agda
|
hazelgrove/hazelnut-livelits-agda
|
c3225acc3c94c56376c6842b82b8b5d76912df2a
|
[
"MIT"
] | null | null | null |
open import core
module focus-formation where
-- every ε is an evaluation context -- trivially, here, since we don't
-- include any of the premises in red brackets about finality
focus-formation : ∀{d d' ε} → d == ε ⟦ d' ⟧ → ε evalctx
focus-formation FHOuter = ECDot
focus-formation (FHAp1 sub) = ECAp1 (focus-formation sub)
focus-formation (FHAp2 sub) = ECAp2 (focus-formation sub)
focus-formation (FHNEHole sub) = ECNEHole (focus-formation sub)
focus-formation (FHCast sub) = ECCast (focus-formation sub)
focus-formation (FHFailedCast x) = ECFailedCast (focus-formation x)
focus-formation (FHFst sub) = ECFst
focus-formation (FHSnd sub) = ECSnd
focus-formation (FHPair1 sub) = ECPair1 (focus-formation sub)
focus-formation (FHPair2 sub) = ECPair2 (focus-formation sub)
| 46.941176
| 72
| 0.72807
|
13880ea752bf3453125af2bb6d8bbb7328a46cdb
| 13,055
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Data/Product/Relation/Binary/Pointwise/NonDependent.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Product/Relation/Binary/Pointwise/NonDependent.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Product/Relation/Binary/Pointwise/NonDependent.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Pointwise products of binary relations
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Product.Relation.Binary.Pointwise.NonDependent where
open import Data.Product as Prod
open import Data.Sum
open import Data.Unit.Base using (⊤)
open import Function
open import Function.Equality as F using (_⟶_; _⟨$⟩_)
open import Function.Equivalence as Eq
using (Equivalence; _⇔_; module Equivalence)
open import Function.Injection as Inj
using (Injection; _↣_; module Injection)
open import Function.Inverse as Inv
using (Inverse; _↔_; module Inverse)
open import Function.LeftInverse as LeftInv
using (LeftInverse; _↞_; _LeftInverseOf_; module LeftInverse)
open import Function.Related
open import Function.Surjection as Surj
using (Surjection; _↠_; module Surjection)
import Relation.Nullary.Decidable as Dec
open import Relation.Nullary.Product
open import Relation.Binary
open import Relation.Binary.PropositionalEquality as P using (_≡_)
module _ {a₁ a₂ ℓ₁ ℓ₂} {A₁ : Set a₁} {A₂ : Set a₂} where
------------------------------------------------------------------------
-- Pointwise lifting
Pointwise : Rel A₁ ℓ₁ → Rel A₂ ℓ₂ → Rel (A₁ × A₂) _
Pointwise _∼₁_ _∼₂_ = (_∼₁_ on proj₁) -×- (_∼₂_ on proj₂)
------------------------------------------------------------------------
-- Pointwise preserves many relational properties
×-reflexive : ∀ {_≈₁_ _∼₁_ _≈₂_ _∼₂_} →
_≈₁_ ⇒ _∼₁_ → _≈₂_ ⇒ _∼₂_ →
(Pointwise _≈₁_ _≈₂_) ⇒ (Pointwise _∼₁_ _∼₂_)
×-reflexive refl₁ refl₂ (x∼y₁ , x∼y₂) = refl₁ x∼y₁ , refl₂ x∼y₂
×-refl : ∀ {_∼₁_ _∼₂_} →
Reflexive _∼₁_ → Reflexive _∼₂_ →
Reflexive (Pointwise _∼₁_ _∼₂_)
×-refl refl₁ refl₂ = refl₁ , refl₂
×-irreflexive₁ : ∀ {_≈₁_ _<₁_ _≈₂_ _<₂_} →
Irreflexive _≈₁_ _<₁_ →
Irreflexive (Pointwise _≈₁_ _≈₂_) (Pointwise _<₁_ _<₂_)
×-irreflexive₁ ir x≈y x<y = ir (proj₁ x≈y) (proj₁ x<y)
×-irreflexive₂ : ∀ {_≈₁_ _<₁_ _≈₂_ _<₂_} →
Irreflexive _≈₂_ _<₂_ →
Irreflexive (Pointwise _≈₁_ _≈₂_) (Pointwise _<₁_ _<₂_)
×-irreflexive₂ ir x≈y x<y = ir (proj₂ x≈y) (proj₂ x<y)
×-symmetric : ∀ {_∼₁_ _∼₂_} → Symmetric _∼₁_ → Symmetric _∼₂_ →
Symmetric (Pointwise _∼₁_ _∼₂_)
×-symmetric sym₁ sym₂ (x∼y₁ , x∼y₂) = sym₁ x∼y₁ , sym₂ x∼y₂
×-transitive : ∀ {_∼₁_ _∼₂_} → Transitive _∼₁_ → Transitive _∼₂_ →
Transitive (Pointwise _∼₁_ _∼₂_)
×-transitive trans₁ trans₂ x∼y y∼z =
trans₁ (proj₁ x∼y) (proj₁ y∼z) ,
trans₂ (proj₂ x∼y) (proj₂ y∼z)
×-antisymmetric : ∀ {_≈₁_ _≤₁_ _≈₂_ _≤₂_} →
Antisymmetric _≈₁_ _≤₁_ → Antisymmetric _≈₂_ _≤₂_ →
Antisymmetric (Pointwise _≈₁_ _≈₂_) (Pointwise _≤₁_ _≤₂_)
×-antisymmetric antisym₁ antisym₂ (x≤y₁ , x≤y₂) (y≤x₁ , y≤x₂) =
(antisym₁ x≤y₁ y≤x₁ , antisym₂ x≤y₂ y≤x₂)
×-asymmetric₁ : ∀ {_<₁_ _∼₂_} → Asymmetric _<₁_ →
Asymmetric (Pointwise _<₁_ _∼₂_)
×-asymmetric₁ asym₁ x<y y<x = asym₁ (proj₁ x<y) (proj₁ y<x)
×-asymmetric₂ : ∀ {_∼₁_ _<₂_} → Asymmetric _<₂_ →
Asymmetric (Pointwise _∼₁_ _<₂_)
×-asymmetric₂ asym₂ x<y y<x = asym₂ (proj₂ x<y) (proj₂ y<x)
×-respects₂ : ∀ {_≈₁_ _∼₁_ _≈₂_ _∼₂_} →
_∼₁_ Respects₂ _≈₁_ → _∼₂_ Respects₂ _≈₂_ →
(Pointwise _∼₁_ _∼₂_) Respects₂ (Pointwise _≈₁_ _≈₂_)
×-respects₂ {_≈₁_} {_∼₁_} {_≈₂_} {_∼₂_} resp₁ resp₂ = resp¹ , resp²
where
_∼_ = Pointwise _∼₁_ _∼₂_
_≈_ = Pointwise _≈₁_ _≈₂_
resp¹ : ∀ {x} → (x ∼_) Respects _≈_
resp¹ y≈y' x∼y = proj₁ resp₁ (proj₁ y≈y') (proj₁ x∼y) ,
proj₁ resp₂ (proj₂ y≈y') (proj₂ x∼y)
resp² : ∀ {y} → (_∼ y) Respects _≈_
resp² x≈x' x∼y = proj₂ resp₁ (proj₁ x≈x') (proj₁ x∼y) ,
proj₂ resp₂ (proj₂ x≈x') (proj₂ x∼y)
×-total : ∀ {_∼₁_ _∼₂_} → Symmetric _∼₁_ →
Total _∼₁_ → Total _∼₂_ →
Total (Pointwise _∼₁_ _∼₂_)
×-total sym₁ total₁ total₂ (x₁ , x₂) (y₁ , y₂)
with total₁ x₁ y₁ | total₂ x₂ y₂
... | inj₁ x₁∼y₁ | inj₁ x₂∼y₂ = inj₁ ( x₁∼y₁ , x₂∼y₂)
... | inj₁ x₁∼y₁ | inj₂ y₂∼x₂ = inj₂ (sym₁ x₁∼y₁ , y₂∼x₂)
... | inj₂ y₁∼x₁ | inj₂ y₂∼x₂ = inj₂ ( y₁∼x₁ , y₂∼x₂)
... | inj₂ y₁∼x₁ | inj₁ x₂∼y₂ = inj₁ (sym₁ y₁∼x₁ , x₂∼y₂)
×-decidable : ∀ {_∼₁_ _∼₂_} →
Decidable _∼₁_ → Decidable _∼₂_ →
Decidable (Pointwise _∼₁_ _∼₂_)
×-decidable _≟₁_ _≟₂_ (x₁ , x₂) (y₁ , y₂) =
(x₁ ≟₁ y₁) ×-dec (x₂ ≟₂ y₂)
-- Some collections of properties which are preserved by ×-Rel.
×-isEquivalence : ∀ {_≈₁_ _≈₂_} →
IsEquivalence _≈₁_ → IsEquivalence _≈₂_ →
IsEquivalence (Pointwise _≈₁_ _≈₂_)
×-isEquivalence {_≈₁_ = _≈₁_} {_≈₂_ = _≈₂_} eq₁ eq₂ = record
{ refl = ×-refl {_∼₁_ = _≈₁_} {_∼₂_ = _≈₂_}
(refl eq₁) (refl eq₂)
; sym = ×-symmetric {_∼₁_ = _≈₁_} {_∼₂_ = _≈₂_}
(sym eq₁) (sym eq₂)
; trans = ×-transitive {_∼₁_ = _≈₁_} {_∼₂_ = _≈₂_}
(trans eq₁) (trans eq₂)
}
where open IsEquivalence
×-isDecEquivalence : ∀ {_≈₁_ _≈₂_} →
IsDecEquivalence _≈₁_ → IsDecEquivalence _≈₂_ →
IsDecEquivalence (Pointwise _≈₁_ _≈₂_)
×-isDecEquivalence eq₁ eq₂ = record
{ isEquivalence = ×-isEquivalence
(isEquivalence eq₁) (isEquivalence eq₂)
; _≟_ = ×-decidable (_≟_ eq₁) (_≟_ eq₂)
}
where open IsDecEquivalence
×-isPreorder : ∀ {_≈₁_ _∼₁_ _≈₂_ _∼₂_} →
IsPreorder _≈₁_ _∼₁_ → IsPreorder _≈₂_ _∼₂_ →
IsPreorder (Pointwise _≈₁_ _≈₂_) (Pointwise _∼₁_ _∼₂_)
×-isPreorder {_∼₁_ = _∼₁_} {_∼₂_ = _∼₂_} pre₁ pre₂ = record
{ isEquivalence = ×-isEquivalence
(isEquivalence pre₁) (isEquivalence pre₂)
; reflexive = ×-reflexive {_∼₁_ = _∼₁_} {_∼₂_ = _∼₂_}
(reflexive pre₁) (reflexive pre₂)
; trans = ×-transitive {_∼₁_ = _∼₁_} {_∼₂_ = _∼₂_}
(trans pre₁) (trans pre₂)
}
where open IsPreorder
×-isPartialOrder : ∀ {_≈₁_ _≤₁_ _≈₂_ _≤₂_} →
IsPartialOrder _≈₁_ _≤₁_ → IsPartialOrder _≈₂_ _≤₂_ →
IsPartialOrder (Pointwise _≈₁_ _≈₂_) (Pointwise _≤₁_ _≤₂_)
×-isPartialOrder {_≤₁_ = _≤₁_} {_≤₂_ = _≤₂_} po₁ po₂ = record
{ isPreorder = ×-isPreorder (isPreorder po₁) (isPreorder po₂)
; antisym = ×-antisymmetric {_≤₁_ = _≤₁_} {_≤₂_ = _≤₂_}
(antisym po₁) (antisym po₂)
}
where open IsPartialOrder
×-isStrictPartialOrder : ∀ {_≈₁_ _<₁_ _≈₂_ _<₂_} →
IsStrictPartialOrder _≈₁_ _<₁_ → IsStrictPartialOrder _≈₂_ _<₂_ →
IsStrictPartialOrder (Pointwise _≈₁_ _≈₂_) (Pointwise _<₁_ _<₂_)
×-isStrictPartialOrder {_<₁_ = _<₁_} {_≈₂_ = _≈₂_} {_<₂_ = _<₂_}
spo₁ spo₂ =
record
{ isEquivalence = ×-isEquivalence
(isEquivalence spo₁) (isEquivalence spo₂)
; irrefl = ×-irreflexive₁ {_<₁_ = _<₁_} {_≈₂_} {_<₂_}
(irrefl spo₁)
; trans = ×-transitive {_∼₁_ = _<₁_} {_<₂_}
(trans spo₁) (trans spo₂)
; <-resp-≈ = ×-respects₂ (<-resp-≈ spo₁) (<-resp-≈ spo₂)
}
where open IsStrictPartialOrder
------------------------------------------------------------------------
-- "Packages" can also be combined.
module _ {ℓ₁ ℓ₂ ℓ₃ ℓ₄} where
×-preorder : Preorder ℓ₁ ℓ₂ _ → Preorder ℓ₃ ℓ₄ _ → Preorder _ _ _
×-preorder p₁ p₂ = record
{ isPreorder = ×-isPreorder (isPreorder p₁) (isPreorder p₂)
} where open Preorder
×-setoid : Setoid ℓ₁ ℓ₂ → Setoid ℓ₃ ℓ₄ → Setoid _ _
×-setoid s₁ s₂ = record
{ isEquivalence =
×-isEquivalence (isEquivalence s₁) (isEquivalence s₂)
} where open Setoid
×-decSetoid : DecSetoid ℓ₁ ℓ₂ → DecSetoid ℓ₃ ℓ₄ → DecSetoid _ _
×-decSetoid s₁ s₂ = record
{ isDecEquivalence =
×-isDecEquivalence (isDecEquivalence s₁) (isDecEquivalence s₂)
} where open DecSetoid
×-poset : Poset ℓ₁ ℓ₂ _ → Poset ℓ₃ ℓ₄ _ → Poset _ _ _
×-poset s₁ s₂ = record
{ isPartialOrder = ×-isPartialOrder (isPartialOrder s₁)
(isPartialOrder s₂)
} where open Poset
×-strictPartialOrder :
StrictPartialOrder ℓ₁ ℓ₂ _ → StrictPartialOrder ℓ₃ ℓ₄ _ →
StrictPartialOrder _ _ _
×-strictPartialOrder s₁ s₂ = record
{ isStrictPartialOrder = ×-isStrictPartialOrder
(isStrictPartialOrder s₁)
(isStrictPartialOrder s₂)
} where open StrictPartialOrder
-- A piece of infix notation for combining setoids
infix 4 _×ₛ_
_×ₛ_ : Setoid ℓ₁ ℓ₂ → Setoid ℓ₃ ℓ₄ → Setoid _ _
_×ₛ_ = ×-setoid
------------------------------------------------------------------------
-- The propositional equality setoid over products can be
-- decomposed using ×-Rel
module _ {a b} {A : Set a} {B : Set b} where
≡×≡⇒≡ : Pointwise _≡_ _≡_ ⇒ _≡_ {A = A × B}
≡×≡⇒≡ (P.refl , P.refl) = P.refl
≡⇒≡×≡ : _≡_ {A = A × B} ⇒ Pointwise _≡_ _≡_
≡⇒≡×≡ P.refl = (P.refl , P.refl)
Pointwise-≡↔≡ : Inverse (P.setoid A ×ₛ P.setoid B) (P.setoid (A × B))
Pointwise-≡↔≡ = record
{ to = record { _⟨$⟩_ = id; cong = ≡×≡⇒≡ }
; from = record { _⟨$⟩_ = id; cong = ≡⇒≡×≡ }
; inverse-of = record
{ left-inverse-of = λ _ → (P.refl , P.refl)
; right-inverse-of = λ _ → P.refl
}
}
≡?×≡?⇒≡? : Decidable {A = A} _≡_ → Decidable {A = B} _≡_ →
Decidable {A = A × B} _≡_
≡?×≡?⇒≡? ≟₁ ≟₂ p q = Dec.map′ ≡×≡⇒≡ ≡⇒≡×≡ (×-decidable ≟₁ ≟₂ p q)
------------------------------------------------------------------------
-- DEPRECATED NAMES
------------------------------------------------------------------------
-- Please use the new names as continuing support for the old names is
-- not guaranteed.
-- Version 0.15
infixr 2 _×-Rel_
_×-Rel_ = Pointwise
{-# WARNING_ON_USAGE _×-Rel_
"Warning: _×-Rel_ was deprecated in v0.15.
Please use Pointwise instead."
#-}
Rel↔≡ = Pointwise-≡↔≡
{-# WARNING_ON_USAGE Rel↔≡
"Warning: Rel↔≡ was deprecated in v0.15.
Please use Pointwise-≡↔≡ instead."
#-}
_×-reflexive_ = ×-reflexive
{-# WARNING_ON_USAGE _×-reflexive_
"Warning: _×-reflexive_ was deprecated in v0.15.
Please use ×-reflexive instead."
#-}
_×-refl_ = ×-refl
{-# WARNING_ON_USAGE _×-refl_
"Warning: _×-refl_ was deprecated in v0.15.
Please use ×-refl instead."
#-}
_×-symmetric_ = ×-symmetric
{-# WARNING_ON_USAGE _×-symmetric_
"Warning: _×-symmetric_ was deprecated in v0.15.
Please use ×-symmetric instead."
#-}
_×-transitive_ = ×-transitive
{-# WARNING_ON_USAGE _×-transitive_
"Warning: _×-transitive_ was deprecated in v0.15.
Please use ×-transitive instead."
#-}
_×-antisymmetric_ = ×-antisymmetric
{-# WARNING_ON_USAGE _×-antisymmetric_
"Warning: _×-antisymmetric_ was deprecated in v0.15.
Please use ×-antisymmetric instead."
#-}
_×-≈-respects₂_ = ×-respects₂
{-# WARNING_ON_USAGE _×-≈-respects₂_
"Warning: _×-≈-respects₂_ was deprecated in v0.15.
Please use ×-respects₂ instead."
#-}
_×-decidable_ = ×-decidable
{-# WARNING_ON_USAGE _×-decidable_
"Warning: _×-decidable_ was deprecated in v0.15.
Please use ×-decidable instead."
#-}
_×-isEquivalence_ = ×-isEquivalence
{-# WARNING_ON_USAGE _×-isEquivalence_
"Warning: _×-isEquivalence_ was deprecated in v0.15.
Please use ×-isEquivalence instead."
#-}
_×-isDecEquivalence_ = ×-isDecEquivalence
{-# WARNING_ON_USAGE _×-isDecEquivalence_
"Warning: _×-isDecEquivalence_ was deprecated in v0.15.
Please use ×-isDecEquivalence instead."
#-}
_×-isPreorder_ = ×-isPreorder
{-# WARNING_ON_USAGE _×-isPreorder_
"Warning: _×-isPreorder_ was deprecated in v0.15.
Please use ×-isPreorder instead."
#-}
_×-isPartialOrder_ = ×-isPartialOrder
{-# WARNING_ON_USAGE _×-isPartialOrder_
"Warning: _×-isPartialOrder_ was deprecated in v0.15.
Please use ×-isPartialOrder instead."
#-}
_×-isStrictPartialOrder_ = ×-isStrictPartialOrder
{-# WARNING_ON_USAGE _×-isStrictPartialOrder_
"Warning: _×-isStrictPartialOrder_ was deprecated in v0.15.
Please use ×-isStrictPartialOrder instead."
#-}
_×-preorder_ = ×-preorder
{-# WARNING_ON_USAGE _×-preorder_
"Warning: _×-preorder_ was deprecated in v0.15.
Please use ×-preorder instead."
#-}
_×-setoid_ = ×-setoid
{-# WARNING_ON_USAGE _×-setoid_
"Warning: _×-setoid_ was deprecated in v0.15.
Please use ×-setoid instead."
#-}
_×-decSetoid_ = ×-decSetoid
{-# WARNING_ON_USAGE _×-decSetoid_
"Warning: _×-decSetoid_ was deprecated in v0.15.
Please use ×-decSetoid instead."
#-}
_×-poset_ = ×-poset
{-# WARNING_ON_USAGE _×-poset_
"Warning: _×-poset_ was deprecated in v0.15.
Please use ×-poset instead."
#-}
_×-strictPartialOrder_ = ×-strictPartialOrder
{-# WARNING_ON_USAGE _×-strictPartialOrder_
"Warning: _×-strictPartialOrder_ was deprecated in v0.15.
Please use ×-strictPartialOrder instead."
#-}
_×-≟_ = ≡?×≡?⇒≡?
{-# WARNING_ON_USAGE _×-≟_
"Warning: _×-≟_ was deprecated in v0.15.
Please use ≡?×≡?⇒≡? instead."
#-}
| 36.263889
| 72
| 0.587744
|
3dcb82d10697c36d3f5ab1355a2d0a10a1dbffac
| 543
|
agda
|
Agda
|
test/Fail/Issue602.agda
|
vlopezj/agda
|
ff4d89e75970cf27599fb9f572bd43c9455cbb56
|
[
"BSD-3-Clause"
] | 2
|
2019-10-29T09:40:30.000Z
|
2020-09-20T00:28:57.000Z
|
test/Fail/Issue602.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Fail/Issue602.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 1
|
2015-09-15T14:36:15.000Z
|
2015-09-15T14:36:15.000Z
|
{-# OPTIONS --guardedness-preserving-type-constructors #-}
module Issue602 where
infix 1000 ♯_
postulate
∞ : ∀ {a} (A : Set a) → Set a
♯_ : ∀ {a} {A : Set a} → A → ∞ A
♭ : ∀ {a} {A : Set a} → ∞ A → A
{-# BUILTIN INFINITY ∞ #-}
{-# BUILTIN SHARP ♯_ #-}
{-# BUILTIN FLAT ♭ #-}
data CoNat : Set0 where
z : CoNat
s : ∞ CoNat → CoNat
record A : Set2 where
field
f : Set1
record B (a : ∞ A) : Set1 where
field
f : A.f (♭ a)
postulate
a : A
e : CoNat → A
e z = a
e (s n) = record
{ f = B (♯ e (♭ n))
}
| 15.083333
| 58
| 0.497238
|
a1b0b94f2c188784bd9bea34c7e109c38f49d218
| 2,929
|
agda
|
Agda
|
src/fot/GroupTheory/PropertiesATP.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
src/fot/GroupTheory/PropertiesATP.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
src/fot/GroupTheory/PropertiesATP.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
------------------------------------------------------------------------------
-- Group theory properties
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
module GroupTheory.PropertiesATP where
open import GroupTheory.Base
------------------------------------------------------------------------------
postulate leftCancellation : ∀ {a b c} → a · b ≡ a · c → b ≡ c
{-# ATP prove leftCancellation #-}
postulate rightIdentity : ∀ a → a · ε ≡ a
{-# ATP prove rightIdentity #-}
postulate rightInverse : ∀ a → a · a ⁻¹ ≡ ε
{-# ATP prove rightInverse #-}
postulate rightCancellation : ∀ {a b c} → b · a ≡ c · a → b ≡ c
{-# ATP prove rightCancellation #-}
postulate y≡x⁻¹[xy] : ∀ a b → b ≡ a ⁻¹ · (a · b)
{-# ATP prove y≡x⁻¹[xy] #-}
postulate x≡[xy]y⁻¹ : ∀ a b → a ≡ (a · b) · b ⁻¹
{-# ATP prove x≡[xy]y⁻¹ #-}
postulate rightIdentityUnique : ∀ r → (∀ a → a · r ≡ a) → r ≡ ε
{-# ATP prove rightIdentityUnique #-}
-- A more appropiate version to be used in the proofs.
postulate rightIdentityUnique' : ∀ a r → a · r ≡ a → r ≡ ε
{-# ATP prove rightIdentityUnique' #-}
postulate leftIdentityUnique : ∀ l → (∀ a → l · a ≡ a) → l ≡ ε
{-# ATP prove leftIdentityUnique #-}
-- A more appropiate version to be used in the proofs.
postulate leftIdentityUnique' : ∀ a l → l · a ≡ a → l ≡ ε
{-# ATP prove leftIdentityUnique' #-}
postulate
rightInverseUnique : ∀ {a} → ∃[ r ] (a · r ≡ ε) ∧ (∀ r' → a · r' ≡ ε → r ≡ r')
{-# ATP prove rightInverseUnique #-}
-- A more appropiate version to be used in the proofs.
postulate rightInverseUnique' : ∀ {a r} → a · r ≡ ε → a ⁻¹ ≡ r
{-# ATP prove rightInverseUnique' #-}
postulate
leftInverseUnique : ∀ {a} → ∃[ l ] (l · a ≡ ε) ∧ (∀ l' → l' · a ≡ ε → l ≡ l')
{-# ATP prove leftInverseUnique #-}
-- A more appropiate version to be used in the proofs.
postulate leftInverseUnique' : ∀ {a l} → l · a ≡ ε → a ⁻¹ ≡ l
{-# ATP prove leftInverseUnique' #-}
postulate ⁻¹-involutive : ∀ a → a ⁻¹ ⁻¹ ≡ a
{-# ATP prove ⁻¹-involutive #-}
postulate identityInverse : ε ⁻¹ ≡ ε
{-# ATP prove identityInverse #-}
postulate inverseDistributive : ∀ a b → (a · b) ⁻¹ ≡ b ⁻¹ · a ⁻¹
{-# ATP prove inverseDistributive #-}
-- The equation xa = b has an unique solution.
postulate
xa≡b-uniqueSolution : ∀ a b → ∃[ x ] (x · a ≡ b) ∧ (∀ x' → x' · a ≡ b → x ≡ x')
{-# ATP prove xa≡b-uniqueSolution #-}
-- The equation ax = b has an unique solution.
postulate
ax≡b-uniqueSolution : ∀ a b → ∃[ x ] (a · x ≡ b) ∧ (∀ x' → a · x' ≡ b → x ≡ x')
{-# ATP prove ax≡b-uniqueSolution #-}
-- If the square of every element is the identity, the system is
-- commutative. From: TPTP 6.4.0 problem GRP/GRP001-2.p.
postulate x²≡ε→comm : (∀ a → a · a ≡ ε) → ∀ {b c d} → b · c ≡ d → c · b ≡ d
{-# ATP prove x²≡ε→comm #-}
| 33.666667
| 81
| 0.538409
|
2e99df9de532ca0021bdb82c2ac3f6543e323c99
| 7,638
|
agda
|
Agda
|
Tutorials/Wednesday.agda
|
poncev/agda-bcam
|
ccd2a78642e93754011deffbe85e9ef5071e4cb7
|
[
"MIT"
] | 27
|
2021-09-23T17:59:21.000Z
|
2022-01-03T22:53:51.000Z
|
Tutorials/Wednesday.agda
|
poncev/agda-bcam
|
ccd2a78642e93754011deffbe85e9ef5071e4cb7
|
[
"MIT"
] | null | null | null |
Tutorials/Wednesday.agda
|
poncev/agda-bcam
|
ccd2a78642e93754011deffbe85e9ef5071e4cb7
|
[
"MIT"
] | 2
|
2021-11-23T08:50:13.000Z
|
2021-11-24T10:50:55.000Z
|
{-# OPTIONS --allow-unsolved-metas #-}
open import Tutorials.Monday-Complete
open import Tutorials.Tuesday
open List using (List; []; _∷_; _++_)
open Vec using (Vec; []; _∷_; _!_)
open Fin using (Fin; zero; suc)
module Tutorials.Wednesday where
-----------
-- Interfaces, isomorphisms
-----------
module Isomorphism where
-- Why can we import _,_ from both modules without resulting in a nameclash?
open Simple using (_⊎_; _×_; _,_; inl; inr)
open Product using (Σ-syntax; Σ-⊎; Σ-×; Π-×; Π-→; _,_)
infix 2 _≅_
record _≅_ (A B : Set) : Set where
constructor Mk≅
field
to : A → B
from : B → A
from∘to : ∀ a → from (to a) ≡ a
to∘from : ∀ b → to (from b) ≡ b
open _≅_
-- We can use copattern matching to construct a record by defining how to construct each of its fields
Σ-⊎-≅ : Σ-⊎ A B ≅ A ⊎ B
Σ-⊎-≅ = {!!}
Σ-×-≅ : Σ-× A B ≅ A × B
Σ-×-≅ = {!!}
Π-→-≅ : Π-→ A B ≅ (A → B)
to Π-→-≅ = {!!}
from Π-→-≅ = {!!}
-- Needs η laws for functions (∀ x → f x) ≡ f
from∘to Π-→-≅ = {!!}
to∘from Π-→-≅ = {!!}
-- The following isomorphism needs of function extensionality
-- Function extensionality claims that if two functions give the same output on the same input, then they are equal
-- This does not hold internally in Agda and we therefore need to postulate it as an axiom
postulate
extensionality : {P : A → Set} {f g : (a : A) → P a} → (∀ x → f x ≡ g x) → f ≡ g
Π-×-≅ : Π-× A B ≅ A × B
Π-×-≅ = {!!}
curry : Π-→ A (Π-→ B C) → Π-→ (Σ-× A B) C
curry f (a , b) = f a b
uncurry : Π-→ (Σ-× A B) C → Π-→ A (Π-→ B C)
uncurry f a b = f (a , b)
curry-uncurry : Π-→ A (Π-→ B C) ≅ Π-→ (Σ-× A B) C
curry-uncurry = {!!}
Fin-≤-≅ : Fin m ≅ Σ[ n ∈ ℕ ] n < m
Fin-≤-≅ = {!!}
_iso-∘_ : B ≅ C → A ≅ B → A ≅ C
x iso-∘ y = {!!}
-----------
-- Decidability
-----------
module Dec where
open Product using (_×_; _,_; fst; snd)
open Simple using (¬_)
data Dec (A : Set) : Set where
yes : A → Dec A
no : ¬ A → Dec A
DecEq : Set → Set
DecEq A = (x y : A) → Dec (x ≡ y)
map : (A → B) → (¬ A → B) → Dec A → B
map f g (yes x) = f x
map f g (no x) = g x
infix 5 _×-dec_
_×-dec_ : Dec A → Dec B → Dec (A × B)
yes x ×-dec yes y = yes (x , y)
yes x ×-dec no ¬y = no (¬y ∘ snd)
no ¬x ×-dec B? = no (¬x ∘ fst)
_ℕ-≟_ : (n m : ℕ) → Dec (n ≡ m)
n ℕ-≟ m = {!!}
suc-injective : {i j : Fin n} → _≡_ {A = Fin (suc n)} (suc i) (suc j) → i ≡ j
suc-injective refl = refl
_Fin-≟_ : (i j : Fin n) → Dec (i ≡ j)
zero Fin-≟ zero = yes refl
zero Fin-≟ suc j = no λ ()
suc i Fin-≟ zero = no λ ()
suc i Fin-≟ suc j = map
(yes ∘ cong suc)
(no ∘ (λ neq → neq ∘ suc-injective))
(i Fin-≟ j)
∷-injective : {x y : A} {xs ys : List A} → _≡_ {A = List A} (x ∷ xs) (y ∷ ys) → x ≡ y × xs ≡ ys
∷-injective refl = refl , refl
List-≟ : (_A-≟_ : (x y : A) → Dec (x ≡ y)) → (xs ys : List A) → Dec (xs ≡ ys)
List-≟ _A-≟_ [] [] = yes refl
List-≟ _A-≟_ [] (y ∷ ys) = no λ ()
List-≟ _A-≟_ (x ∷ xs) [] = no λ ()
List-≟ _A-≟_ (x ∷ xs) (y ∷ ys) = map
(yes ∘ Isomorphism.curry (cong₂ _∷_))
(no ∘ (λ neq → neq ∘ ∷-injective))
(x A-≟ y ×-dec List-≟ _A-≟_ xs ys)
-----------
-- Interfaces
-----------
-- We define what it is to be a monoid on a carrier set C
record Monoid (C : Set) : Set where
constructor MkMonoid
field
ε : C
_∙_ : C → C → C
-- Including the algebraic laws
idˡ : (x : C) → ε ∙ x ≡ x
idʳ : (x : C) → x ∙ ε ≡ x
assoc : (x y z : C) → (x ∙ y) ∙ z ≡ x ∙ (y ∙ z)
module MonoidSolver (Symbol : Set) (symbol-≟ : Dec.DecEq Symbol) where
-- The syntax for an expression tree of symbolic monoidal operations
infixl 20 _‵∙_
infix 25 ‵_
data Expr : Set where
‵ε : Expr
‵_ : Symbol → Expr
_‵∙_ : Expr → Expr → Expr
-- And define equations on monoids
infix 10 _‵≡_
record Eqn : Set where
constructor _‵≡_
field
lhs : Expr
rhs : Expr
-- The canonical normal form for expression trees
NormalForm : Set
NormalForm = List Symbol
normalise : Expr → NormalForm
normalise ‵ε = []
normalise (‵ x) = x ∷ []
normalise (xs ‵∙ ys) = normalise xs ++ normalise ys
module Eval (M : Monoid C) where
open Monoid M
-- An environment maps symbols to values in the carrier set
Env : Set
Env = Symbol → C
-- Evaluate the syntax in a given environment
⟦_⟧ : Expr → Env → C
⟦ ‵ε ⟧ Γ = ε
⟦ ‵ x ⟧ Γ = Γ x
⟦ x ‵∙ y ⟧ Γ = ⟦ x ⟧ Γ ∙ ⟦ y ⟧ Γ
-- Evaluate the normal form in a given environment
⟦_⟧⇓ : NormalForm → Env → C
⟦ [] ⟧⇓ Γ = ε
⟦ x ∷ xs ⟧⇓ Γ = Γ x ∙ ⟦ xs ⟧⇓ Γ
-- The evaluation of normal forms distributes over list concatenation
++-homo : ∀ Γ (xs ys : NormalForm) → ⟦ xs ++ ys ⟧⇓ Γ ≡ ⟦ xs ⟧⇓ Γ ∙ ⟦ ys ⟧⇓ Γ
++-homo Γ [] ys = sym (idˡ _)
++-homo Γ (x ∷ xs) ys = begin
Γ x ∙ ⟦ xs ++ ys ⟧⇓ Γ
≡⟨ cong (_ ∙_) (++-homo Γ xs ys) ⟩
Γ x ∙ (⟦ xs ⟧⇓ Γ ∙ ⟦ ys ⟧⇓ Γ)
≡⟨ sym (assoc _ _ _) ⟩
(Γ x ∙ ⟦ xs ⟧⇓ Γ) ∙ ⟦ ys ⟧⇓ Γ
∎
-- Normalising and then evaluating the normal form is equal to evaluating the original expression
correct : ∀ Γ (expr : Expr) → ⟦ normalise expr ⟧⇓ Γ ≡ ⟦ expr ⟧ Γ
correct Γ ‵ε = refl
correct Γ (‵ x) = idʳ _
correct Γ (le ‵∙ re) = begin
⟦ normalise le ++ normalise re ⟧⇓ Γ ≡⟨ ++-homo Γ (normalise le) (normalise re) ⟩
⟦ normalise le ⟧⇓ Γ ∙ ⟦ normalise re ⟧⇓ Γ ≡⟨ cong₂ _∙_ (correct Γ le) (correct Γ re) ⟩
⟦ le ⟧ Γ ∙ ⟦ re ⟧ Γ ∎
-- We describe what it is to be a solution to an equation
-- If both sides normalise to the same symbols in the same order,
-- we claim that the monoid laws make the equations hold in any environment
Solution : Eqn → Set
Solution (lhs ‵≡ rhs) =
Dec.map
-- Both sides normalise to a common list of symbols, we must now show that the equation holds under any environment
(λ _ → ∀ (Γ : Env) → ⟦ lhs ⟧ Γ ≡ ⟦ rhs ⟧ Γ)
-- Both sides do *not* normalise to a common list of symbols, we claim only the trivial
(λ _ → ⊤)
(Dec.List-≟ symbol-≟ (normalise lhs) (normalise rhs))
-- Now that we have described what a solution is, we show that we can provide one
solve : (eqn : Eqn) → Solution eqn
-- Pattern matching using with makes the goal type compute
solve (lhs ‵≡ rhs) with Dec.List-≟ symbol-≟ (normalise lhs) (normalise rhs)
solve (lhs ‵≡ rhs) | Dec.no _ = tt
solve (lhs ‵≡ rhs) | Dec.yes lhs⇓≡rhs⇓ = λ Γ → begin
⟦ lhs ⟧ Γ ≡⟨ sym (correct Γ lhs) ⟩
⟦ normalise lhs ⟧⇓ Γ ≡⟨ cong (λ ● → ⟦ ● ⟧⇓ Γ) lhs⇓≡rhs⇓ ⟩
⟦ normalise rhs ⟧⇓ Γ ≡⟨ correct Γ rhs ⟩
⟦ rhs ⟧ Γ ∎
open MonoidSolver
-- An example instance of a monoid: natural numbers with addition
NAT-MONOID : Monoid ℕ
Monoid.ε NAT-MONOID = zero
Monoid._∙_ NAT-MONOID = _+_
Monoid.idˡ NAT-MONOID = +-idˡ
Monoid.idʳ NAT-MONOID = +-idʳ
Monoid.assoc NAT-MONOID = +-assoc
-- An example usage of the monoid solver
-- We first need to "quote" the goal, i.e. describe it in terms of the expression language / syntax
-- NAT-MONOID describes how to interpret the syntax back and evaluate the expression into a value of the carrier set
eqn₁-auto : (x y z : ℕ) → (0 + x) + y + (y + z) ≡ x + (0 + y + 0) + (y + z + 0)
eqn₁-auto x y z =
let
‵x = zero
‵y = suc zero
‵z = suc (suc zero)
lhs = (‵ε ‵∙ ‵ ‵x) ‵∙ ‵ ‵y ‵∙ (‵ ‵y ‵∙ ‵ ‵z)
rhs = ‵ ‵x ‵∙ (‵ε ‵∙ ‵ ‵y ‵∙ ‵ε) ‵∙ (‵ ‵y ‵∙ ‵ ‵z ‵∙ ‵ε)
in
Eval.solve (Fin 3) Dec._Fin-≟_ NAT-MONOID (lhs ‵≡ rhs) λ where
zero → x
(suc zero) → y
(suc (suc zero)) → z
| 30.798387
| 123
| 0.530505
|
41f42ed873a385ff888472abc6b590d3b833a364
| 1,659
|
agda
|
Agda
|
src/Constants.agda
|
nad/chi
|
30966769b8cbd46aa490b6964a4aa0e67a7f9ab1
|
[
"MIT"
] | 2
|
2020-05-21T22:58:07.000Z
|
2020-10-20T16:27:00.000Z
|
src/Constants.agda
|
nad/chi
|
30966769b8cbd46aa490b6964a4aa0e67a7f9ab1
|
[
"MIT"
] | 1
|
2020-05-21T23:29:54.000Z
|
2020-06-08T11:08:25.000Z
|
src/Constants.agda
|
nad/chi
|
30966769b8cbd46aa490b6964a4aa0e67a7f9ab1
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- Various constants
------------------------------------------------------------------------
open import Atom
module Constants (atoms : χ-atoms) where
open χ-atoms atoms
c-zero : Const
c-zero = C.name 0
c-suc : Const
c-suc = C.name 1
c-nil : Const
c-nil = C.name 2
c-cons : Const
c-cons = C.name 3
c-apply : Const
c-apply = C.name 4
c-case : Const
c-case = C.name 5
c-rec : Const
c-rec = C.name 6
c-lambda : Const
c-lambda = C.name 7
c-const : Const
c-const = C.name 8
c-var : Const
c-var = C.name 9
c-branch : Const
c-branch = C.name 10
c-true : Const
c-true = C.name 11
c-false : Const
c-false = C.name 12
c-pair : Const
c-pair = C.name 13
v-equal : Var
v-equal = V.name 0
v-m : Var
v-m = V.name 1
v-n : Var
v-n = V.name 2
v-x : Var
v-x = V.name 3
v-new : Var
v-new = V.name 4
v-e : Var
v-e = V.name 5
v-subst : Var
v-subst = V.name 6
v-e₁ : Var
v-e₁ = V.name 7
v-e₂ : Var
v-e₂ = V.name 8
v-bs : Var
v-bs = V.name 9
v-y : Var
v-y = V.name 10
v-c : Var
v-c = V.name 11
v-es : Var
v-es = V.name 12
v-ys : Var
v-ys = V.name 13
v-member : Var
v-member = V.name 14
v-xs : Var
v-xs = V.name 15
v-lookup : Var
v-lookup = V.name 16
v-b : Var
v-b = V.name 17
v-c′ : Var
v-c′ = V.name 18
v-underscore : Var
v-underscore = V.name 19
v-substs : Var
v-substs = V.name 20
v-e′ : Var
v-e′ = V.name 21
v-map : Var
v-map = V.name 22
v-p : Var
v-p = V.name 23
v-eval : Var
v-eval = V.name 24
v-internal-code : Var
v-internal-code = V.name 25
v-halts : Var
v-halts = V.name 26
v-z : Var
v-z = V.name 27
v-f : Var
v-f = V.name 28
v-g : Var
v-g = V.name 29
| 11.683099
| 72
| 0.548523
|
1a88fcac52ff4a1d1e16b18c37ceaa27ea838897
| 3,274
|
agda
|
Agda
|
test/Succeed/Issue2226.agda
|
vlopezj/agda
|
ff4d89e75970cf27599fb9f572bd43c9455cbb56
|
[
"BSD-3-Clause"
] | 2
|
2019-10-29T09:40:30.000Z
|
2020-09-20T00:28:57.000Z
|
test/Succeed/Issue2226.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Succeed/Issue2226.agda
|
vikfret/agda
|
49ad0b3f0d39c01bc35123478b857e702b29fb9d
|
[
"BSD-3-Clause"
] | 1
|
2019-03-05T20:02:38.000Z
|
2019-03-05T20:02:38.000Z
|
-- Andreas, 2018-03-12
-- The fix for #2963 introduced a change in the quotation behavior
-- of method definitions inside a record.
open import Agda.Builtin.Float
open import Agda.Builtin.Reflection
open import Agda.Builtin.List
open import Agda.Builtin.Unit
open import Agda.Builtin.Equality
infixl 6 _>>=_
_>>=_ = bindTC
macro
getDef : Name → Term → TC ⊤
getDef x a = getDefinition x >>= quoteTC >>= unify a
record Foo (A : Set) : Set where
constructor mkFoo
field foo : A
foo₁ : A
foo₁ = foo
open module FooI = Foo {{...}}
postulate
A : Set
instance FooA : Foo A
-- Projection-like
foo₂ : {A : Set} {r : Foo A} → A
foo₂ {r = mkFoo x} = x
bar : A
bar = foo
bar₁ : A
bar₁ = foo₁
bar₂ : A
bar₂ = foo₂ {r = FooA}
pattern rArg v x = arg (arg-info v relevant) x
pattern vArg x = rArg visible x
pattern hArg x = rArg hidden x
pattern iArg x = rArg instance′ x
pattern `? = hArg unknown
pattern fun₀ b = function (clause [] b ∷ [])
pattern fun₁ p b = function (clause (p ∷ []) b ∷ [])
pattern fun₂ p q b = function (clause (p ∷ q ∷ []) b ∷ [])
-- foo {{r}} = Foo.foo {_} r
foo-def : getDef foo ≡ fun₁ (iArg (var "r")) (def (quote Foo.foo) (`? ∷ vArg (var 0 []) ∷ []))
foo-def = refl
-- Andreas, 2018-03-12: Behavior before fix of #2963:
-- foo₁ {{r}} = Foo.foo₁ {_} r
-- foo₁-def : getDef foo₁ ≡ fun₁ (iArg (var "r")) (def (quote Foo.foo₁) (`? ∷ vArg (var 0 []) ∷ []))
-- NOW:
-- foo₁ {A} {{r}} = Foo.foo₁ {A} r
foo₁-def : getDef foo₁ ≡ fun₂ (hArg (var "A")) (iArg (var "r")) (def (quote Foo.foo₁) (hArg (var 1 []) ∷ vArg (var 0 []) ∷ []))
foo₁-def = refl
-- bar = foo {_} FooA
bar-def : getDef bar ≡ fun₀ (def (quote Foo.foo) (`? ∷ vArg (def (quote FooA) []) ∷ []))
bar-def = refl
-- bar₁ = foo {_} FooA
bar₁-def : getDef bar₁ ≡ fun₀ (def (quote Foo.foo) (`? ∷ vArg (def (quote FooA) []) ∷ []))
bar₁-def = refl
-- bar₂ = foo₂ {_} {FooA}
bar₂-def : getDef bar₂ ≡ fun₀ (def (quote foo₂) (`? ∷ hArg (def (quote FooA) []) ∷ []))
bar₂-def = refl
--- Originally reported test case ---
defToTerm : Name → Definition → List (Arg Term) → Term
defToTerm _ (function cs) as = pat-lam cs as
defToTerm _ (data-cons d) as = con d as
defToTerm _ _ _ = unknown
derefImmediate : Term → TC Term
derefImmediate (def f args) = getDefinition f >>= λ f' → returnTC (defToTerm f f' args)
derefImmediate x = returnTC x
reflectTerm : Name → TC Term
reflectTerm n = getType n >>= λ ty → getDefinition n >>= λ x →
derefImmediate (defToTerm n x []) >>= λ x → checkType x ty
macro
reflect : Name → Term → TC ⊤
reflect n a = reflectTerm n >>= quoteTC >>= unify a
{- Define typeclass Semigroup a => Plus a -}
record SemigroupLaws {ℓ} (t : Set ℓ) : Set ℓ where
infixr 5 _++_
field
_++_ : t → t → t
-- associative : ∀ {a b c} → (a ++ b) ++ c ≡ a ++ b ++ c
record PlusOp {ℓ} (t : Set ℓ) : Set ℓ where
field
semigroup : SemigroupLaws t
infixr 6 _+_
_+_ = SemigroupLaws._++_ semigroup
instance
floatPlus : PlusOp Float
floatPlus = record { semigroup = record { _++_ = Agda.Builtin.Float.primFloatPlus } }
open PlusOp {{...}}
-- The issue:
works : Float
works = PlusOp._+_ floatPlus 3.0 5.0
resultWorks : Term
resultWorks = reflect works
fails : Float
fails = 3.0 + 5.0
resultFails : Term
resultFails = reflect fails
| 25.184615
| 127
| 0.619731
|
13d563b0813f0de7325af21af9c2fb894d6c28bc
| 5,028
|
agda
|
Agda
|
core/lib/types/Pushout.agda
|
timjb/HoTT-Agda
|
66f800adef943afdf08c17b8ecfba67340fead5e
|
[
"MIT"
] | null | null | null |
core/lib/types/Pushout.agda
|
timjb/HoTT-Agda
|
66f800adef943afdf08c17b8ecfba67340fead5e
|
[
"MIT"
] | null | null | null |
core/lib/types/Pushout.agda
|
timjb/HoTT-Agda
|
66f800adef943afdf08c17b8ecfba67340fead5e
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --rewriting #-}
open import lib.Basics
open import lib.types.Pi
open import lib.types.Pointed
open import lib.types.Sigma
open import lib.types.Span
open import lib.types.Paths
import lib.types.Generic1HIT as Generic1HIT
module lib.types.Pushout where
module _ {i j k} where
postulate -- HIT
Pushout : (d : Span {i} {j} {k}) → Type (lmax (lmax i j) k)
module _ {d : Span} where
postulate -- HIT
left : Span.A d → Pushout d
right : Span.B d → Pushout d
glue : (c : Span.C d) → left (Span.f d c) == right (Span.g d c)
module PushoutElim {d : Span} {l} {P : Pushout d → Type l}
(left* : (a : Span.A d) → P (left a))
(right* : (b : Span.B d) → P (right b))
(glue* : (c : Span.C d) → left* (Span.f d c) == right* (Span.g d c) [ P ↓ glue c ]) where
postulate -- HIT
f : Π (Pushout d) P
left-β : ∀ a → f (left a) ↦ left* a
right-β : ∀ b → f (right b) ↦ right* b
{-# REWRITE left-β #-}
{-# REWRITE right-β #-}
postulate -- HIT
glue-β : (c : Span.C d) → apd f (glue c) == glue* c
Pushout-elim = PushoutElim.f
module PushoutRec {i j k} {d : Span {i} {j} {k}} {l} {D : Type l}
(left* : Span.A d → D) (right* : Span.B d → D)
(glue* : (c : Span.C d) → left* (Span.f d c) == right* (Span.g d c)) where
private
module M = PushoutElim left* right* (λ c → ↓-cst-in (glue* c))
f : Pushout d → D
f = M.f
glue-β : (c : Span.C d) → ap f (glue c) == glue* c
glue-β c = apd=cst-in {f = f} (M.glue-β c)
Pushout-rec = PushoutRec.f
Pushout-rec-η : ∀ {i j k} {d : Span {i} {j} {k}} {l} {D : Type l} (f : Pushout d → D)
→ Pushout-rec (f ∘ left) (f ∘ right) (ap f ∘ glue) ∼ f
Pushout-rec-η f = Pushout-elim (λ _ → idp) (λ _ → idp)
(λ c → ↓-='-in' $ ! $ PushoutRec.glue-β (f ∘ left) (f ∘ right) (ap f ∘ glue) c)
module PushoutGeneric {i j k} {d : Span {i} {j} {k}} where
open Span d renaming (f to g; g to h)
open Generic1HIT (Coprod A B) C (inl ∘ g) (inr ∘ h) public
module _ where
module To = PushoutRec (cc ∘ inl) (cc ∘ inr) pp
to : Pushout d → T
to = To.f
from-cc : Coprod A B → Pushout d
from-cc (inl a) = left a
from-cc (inr b) = right b
module From = Rec from-cc glue
from : T → Pushout d
from = From.f
abstract
to-from : (x : T) → to (from x) == x
to-from = elim to-from-cc to-from-pp where
to-from-cc : (x : Coprod A B)
→ to (from (cc x)) == cc x
to-from-cc (inl a) = idp
to-from-cc (inr b) = idp
to-from-pp :
(c : C) → idp == idp [ (λ z → to (from z) == z) ↓ pp c ]
to-from-pp c = ↓-∘=idf-in' to from
(ap to (ap from (pp c)) =⟨ From.pp-β c |in-ctx ap to ⟩
ap to (glue c) =⟨ To.glue-β c ⟩
pp c =∎)
from-to : (x : Pushout d) → from (to x) == x
from-to = Pushout-elim (λ a → idp) (λ b → idp) (λ c → ↓-∘=idf-in' from to
(ap from (ap to (glue c)) =⟨ To.glue-β c |in-ctx ap from ⟩
ap from (pp c) =⟨ From.pp-β c ⟩
glue c =∎))
generic-pushout : Pushout d ≃ T
generic-pushout = equiv to from to-from from-to
_⊔^[_]_/_ : ∀ {i j k} (A : Type i) (C : Type k) (B : Type j)
(fg : (C → A) × (C → B)) → Type (lmax (lmax i j) k)
A ⊔^[ C ] B / (f , g) = Pushout (span A B C f g)
⊙Pushout : ∀ {i j k} (d : ⊙Span {i} {j} {k}) → Ptd _
⊙Pushout d = ⊙[ Pushout (⊙Span-to-Span d) , left (pt (⊙Span.X d)) ]
module _ {i j k} (d : ⊙Span {i} {j} {k}) where
open ⊙Span d
⊙left : X ⊙→ ⊙Pushout d
⊙left = (left , idp)
⊙right : Y ⊙→ ⊙Pushout d
⊙right =
(right , ap right (! (snd g)) ∙ ! (glue (pt Z)) ∙' ap left (snd f))
⊙glue : (⊙left ⊙∘ f) == (⊙right ⊙∘ g)
⊙glue = pair=
(λ= glue)
(↓-app=cst-in $
ap left (snd f) ∙ idp
=⟨ ∙-unit-r _ ⟩
ap left (snd f)
=⟨ lemma (glue (pt Z)) (ap right (snd g)) (ap left (snd f)) ⟩
glue (pt Z) ∙ ap right (snd g)
∙ ! (ap right (snd g)) ∙ ! (glue (pt Z)) ∙' ap left (snd f)
=⟨ !-ap right (snd g)
|in-ctx (λ w → glue (pt Z) ∙ ap right (snd g) ∙ w
∙ ! (glue (pt Z)) ∙' ap left (snd f)) ⟩
glue (pt Z) ∙ ap right (snd g)
∙ ap right (! (snd g)) ∙ ! (glue (pt Z)) ∙' ap left (snd f)
=⟨ ! (app=-β glue (pt Z))
|in-ctx (λ w → w ∙ ap right (snd g) ∙ ap right (! (snd g))
∙ ! (glue (pt Z)) ∙' ap left (snd f)) ⟩
app= (λ= glue) (pt Z) ∙ ap right (snd g)
∙ ap right (! (snd g)) ∙ ! (glue (pt Z)) ∙' ap left (snd f) =∎)
where
lemma : ∀ {i} {A : Type i} {x y z w : A}
(p : x == y) (q : y == z) (r : x == w)
→ r == p ∙ q ∙ ! q ∙ ! p ∙' r
lemma idp idp idp = idp
⊙pushout-J : ∀ {i j k l} (P : ⊙Span → Type l)
→ ({A : Type i} {B : Type j} (Z : Ptd k) (f : de⊙ Z → A) (g : de⊙ Z → B)
→ P (⊙span ⊙[ A , f (pt Z) ] ⊙[ B , g (pt Z) ] Z (f , idp) (g , idp)))
→ ((ps : ⊙Span) → P ps)
⊙pushout-J P t (⊙span ⊙[ _ , ._ ] ⊙[ _ , ._ ] Z (f , idp) (g , idp)) = t Z f g
| 31.822785
| 93
| 0.478321
|
127cb1435e528310bf3be317fce0ffd83094544e
| 248
|
agda
|
Agda
|
test/Succeed/Issue1383.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue1383.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue1383.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --exact-split #-}
module Issue1383 where
data Bool : Set where
true false : Bool
xor : Bool → Bool → Bool
xor = \ { true true -> false ;
false false -> false ;
{-# CATCHALL #-}
_ _ -> true }
| 20.666667
| 32
| 0.508065
|
4ab8757edd84eceb0a2a29f4459e03822d325249
| 4,874
|
agda
|
Agda
|
Cubical/Relation/Binary/Base.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | 1
|
2021-10-31T17:32:49.000Z
|
2021-10-31T17:32:49.000Z
|
Cubical/Relation/Binary/Base.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
Cubical/Relation/Binary/Base.agda
|
guilhermehas/cubical
|
ce3120d3f8d692847b2744162bcd7a01f0b687eb
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe #-}
module Cubical.Relation.Binary.Base where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.Fiberwise
open import Cubical.Data.Sigma
open import Cubical.HITs.SetQuotients.Base
open import Cubical.HITs.PropositionalTruncation.Base
private
variable
ℓA ℓ≅A ℓA' ℓ≅A' : Level
Rel : ∀ {ℓ} (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))
Rel A B ℓ' = A → B → Type ℓ'
PropRel : ∀ {ℓ} (A B : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))
PropRel A B ℓ' = Σ[ R ∈ Rel A B ℓ' ] ∀ a b → isProp (R a b)
idPropRel : ∀ {ℓ} (A : Type ℓ) → PropRel A A ℓ
idPropRel A .fst a a' = ∥ a ≡ a' ∥₁
idPropRel A .snd _ _ = squash₁
invPropRel : ∀ {ℓ ℓ'} {A B : Type ℓ}
→ PropRel A B ℓ' → PropRel B A ℓ'
invPropRel R .fst b a = R .fst a b
invPropRel R .snd b a = R .snd a b
compPropRel : ∀ {ℓ ℓ' ℓ''} {A B C : Type ℓ}
→ PropRel A B ℓ' → PropRel B C ℓ'' → PropRel A C (ℓ-max ℓ (ℓ-max ℓ' ℓ''))
compPropRel R S .fst a c = ∥ Σ[ b ∈ _ ] (R .fst a b × S .fst b c) ∥₁
compPropRel R S .snd _ _ = squash₁
graphRel : ∀ {ℓ} {A B : Type ℓ} → (A → B) → Rel A B ℓ
graphRel f a b = f a ≡ b
module BinaryRelation {ℓ ℓ' : Level} {A : Type ℓ} (R : Rel A A ℓ') where
isRefl : Type (ℓ-max ℓ ℓ')
isRefl = (a : A) → R a a
isSym : Type (ℓ-max ℓ ℓ')
isSym = (a b : A) → R a b → R b a
isAntisym : Type (ℓ-max ℓ ℓ')
isAntisym = (a b : A) → R a b → R b a → a ≡ b
isTrans : Type (ℓ-max ℓ ℓ')
isTrans = (a b c : A) → R a b → R b c → R a c
record isEquivRel : Type (ℓ-max ℓ ℓ') where
constructor equivRel
field
reflexive : isRefl
symmetric : isSym
transitive : isTrans
isPropValued : Type (ℓ-max ℓ ℓ')
isPropValued = (a b : A) → isProp (R a b)
isSetValued : Type (ℓ-max ℓ ℓ')
isSetValued = (a b : A) → isSet (R a b)
isEffective : Type (ℓ-max ℓ ℓ')
isEffective =
(a b : A) → isEquiv (eq/ {R = R} a b)
impliesIdentity : Type _
impliesIdentity = {a a' : A} → (R a a') → (a ≡ a')
-- the total space corresponding to the binary relation w.r.t. a
relSinglAt : (a : A) → Type (ℓ-max ℓ ℓ')
relSinglAt a = Σ[ a' ∈ A ] (R a a')
-- the statement that the total space is contractible at any a
contrRelSingl : Type (ℓ-max ℓ ℓ')
contrRelSingl = (a : A) → isContr (relSinglAt a)
isUnivalent : Type (ℓ-max ℓ ℓ')
isUnivalent = (a a' : A) → (R a a') ≃ (a ≡ a')
contrRelSingl→isUnivalent : isRefl → contrRelSingl → isUnivalent
contrRelSingl→isUnivalent ρ c a a' = isoToEquiv i
where
h : isProp (relSinglAt a)
h = isContr→isProp (c a)
aρa : relSinglAt a
aρa = a , ρ a
Q : (y : A) → a ≡ y → _
Q y _ = R a y
i : Iso (R a a') (a ≡ a')
Iso.fun i r = cong fst (h aρa (a' , r))
Iso.inv i = J Q (ρ a)
Iso.rightInv i = J (λ y p → cong fst (h aρa (y , J Q (ρ a) p)) ≡ p)
(J (λ q _ → cong fst (h aρa (a , q)) ≡ refl)
(J (λ α _ → cong fst α ≡ refl) refl
(isProp→isSet h _ _ refl (h _ _)))
(sym (JRefl Q (ρ a))))
Iso.leftInv i r = J (λ w β → J Q (ρ a) (cong fst β) ≡ snd w)
(JRefl Q (ρ a)) (h aρa (a' , r))
isUnivalent→contrRelSingl : isUnivalent → contrRelSingl
isUnivalent→contrRelSingl u a = q
where
abstract
f : (x : A) → a ≡ x → R a x
f x p = invEq (u a x) p
t : singl a → relSinglAt a
t (x , p) = x , f x p
q : isContr (relSinglAt a)
q = isOfHLevelRespectEquiv 0 (t , totalEquiv _ _ f λ x → invEquiv (u a x) .snd)
(isContrSingl a)
EquivRel : ∀ {ℓ} (A : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))
EquivRel A ℓ' = Σ[ R ∈ Rel A A ℓ' ] BinaryRelation.isEquivRel R
EquivPropRel : ∀ {ℓ} (A : Type ℓ) (ℓ' : Level) → Type (ℓ-max ℓ (ℓ-suc ℓ'))
EquivPropRel A ℓ' = Σ[ R ∈ PropRel A A ℓ' ] BinaryRelation.isEquivRel (R .fst)
record RelIso {A : Type ℓA} (_≅_ : Rel A A ℓ≅A)
{A' : Type ℓA'} (_≅'_ : Rel A' A' ℓ≅A') : Type (ℓ-max (ℓ-max ℓA ℓA') (ℓ-max ℓ≅A ℓ≅A')) where
constructor reliso
field
fun : A → A'
inv : A' → A
rightInv : (a' : A') → fun (inv a') ≅' a'
leftInv : (a : A) → inv (fun a) ≅ a
open BinaryRelation
RelIso→Iso : {A : Type ℓA} {A' : Type ℓA'}
(_≅_ : Rel A A ℓ≅A) (_≅'_ : Rel A' A' ℓ≅A')
(uni : impliesIdentity _≅_) (uni' : impliesIdentity _≅'_)
(f : RelIso _≅_ _≅'_)
→ Iso A A'
Iso.fun (RelIso→Iso _ _ _ _ f) = RelIso.fun f
Iso.inv (RelIso→Iso _ _ _ _ f) = RelIso.inv f
Iso.rightInv (RelIso→Iso _ _ uni uni' f) a'
= uni' (RelIso.rightInv f a')
Iso.leftInv (RelIso→Iso _ _ uni uni' f) a
= uni (RelIso.leftInv f a)
| 32.711409
| 106
| 0.547189
|
1a23e56ba958c034c5bcaef49e3f3de1a540a9e6
| 1,320
|
agda
|
Agda
|
src/STLC/Properties/Determinism.agda
|
johnyob/agda-types
|
aeb2be63381d891fabe5317e3c27553deb6bca6d
|
[
"MIT"
] | null | null | null |
src/STLC/Properties/Determinism.agda
|
johnyob/agda-types
|
aeb2be63381d891fabe5317e3c27553deb6bca6d
|
[
"MIT"
] | null | null | null |
src/STLC/Properties/Determinism.agda
|
johnyob/agda-types
|
aeb2be63381d891fabe5317e3c27553deb6bca6d
|
[
"MIT"
] | null | null | null |
module STLC.Properties.Determinism where
open import STLC.Term
open import STLC.Term.Reduction
open import Data.Nat using (ℕ; _+_)
open import Relation.Nullary using (¬_)
open import Relation.Nullary.Negation using (contradiction)
open import Data.Product using (Σ; _,_; ∃; Σ-syntax; ∃-syntax)
open import Relation.Binary.PropositionalEquality as Eq
using (refl; _≡_; cong₂)
open Eq.≡-Reasoning using (begin_; _≡⟨⟩_; _∎)
infix 4 _¬—→
_¬—→ : ∀ { n : ℕ } -> Term n -> Set
t₁ ¬—→ = ¬ (∃[ t₂ ] (t₁ —→ t₂))
¬—→-value : ∀ { n : ℕ } { t : Term n }
-> Value t
-- --------
-> t ¬—→
¬—→-value {_} {ƛ _} v = λ ()
—→-¬value : ∀ { n : ℕ } { t₁ t₂ : Term n }
-> t₁ —→ t₂
-- ---------
-> ¬ Value t₁
—→-¬value { _ } { _ } { t₂ } s v = ¬—→-value v (t₂ , s)
determinism : ∀ { n : ℕ } { t₁ t₂ t₃ : Term n }
-> t₁ —→ t₂
-> t₁ —→ t₃
-- --------
-> t₂ ≡ t₃
determinism (β-·₁ s₁) (β-·₁ s₂) = cong₂ (_·_) (determinism s₁ s₂) refl
determinism (β-·₂ _ s₁) (β-·₂ _ s₂) = cong₂ (_·_) refl (determinism s₁ s₂)
determinism (β-ƛ _) (β-ƛ _) = refl
determinism (β-·₁ s) (β-·₂ v _) = contradiction v (—→-¬value s)
determinism (β-·₂ v _) (β-·₁ s) = contradiction v (—→-¬value s)
determinism (β-·₂ _ s) (β-ƛ v) = contradiction v (—→-¬value s)
determinism (β-ƛ v) (β-·₂ _ s) = contradiction v (—→-¬value s)
| 26.4
| 75
| 0.551515
|
57a8b8e2c0920ed035bb69bc78b745728dcca12c
| 7,440
|
agda
|
Agda
|
theorems/groups/HomSequence.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
theorems/groups/HomSequence.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
theorems/groups/HomSequence.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 50
|
2015-01-10T01:48:08.000Z
|
2022-02-14T03:03:25.000Z
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
module groups.HomSequence where
infix 15 _⊣|ᴳ
infixr 10 _→⟨_⟩ᴳ_
data HomSequence {i} : (G : Group i) (H : Group i) → Type (lsucc i) where
_⊣|ᴳ : (G : Group i) → HomSequence G G
_→⟨_⟩ᴳ_ : (G : Group i) {H K : Group i}
→ (G →ᴳ H) → HomSequence H K
→ HomSequence G K
HomSeq-++ : ∀ {i} {G H K : Group i}
→ HomSequence G H → HomSequence H K → HomSequence G K
HomSeq-++ (_ ⊣|ᴳ) seq = seq
HomSeq-++ (_ →⟨ φ ⟩ᴳ seq₁) seq₂ = _ →⟨ φ ⟩ᴳ HomSeq-++ seq₁ seq₂
HomSeq-snoc : ∀ {i} {G H K : Group i}
→ HomSequence G H → (H →ᴳ K) → HomSequence G K
HomSeq-snoc seq φ = HomSeq-++ seq (_ →⟨ φ ⟩ᴳ _ ⊣|ᴳ)
{- maps between two hom sequences -}
infix 15 _↓|ᴳ
infixr 10 _↓⟨_⟩ᴳ_
data HomSeqMap {i₀ i₁} : {G₀ H₀ : Group i₀} {G₁ H₁ : Group i₁}
→ HomSequence G₀ H₀ → HomSequence G₁ H₁
→ (G₀ →ᴳ G₁) → (H₀ →ᴳ H₁) → Type (lsucc (lmax i₀ i₁)) where
_↓|ᴳ : {G₀ : Group i₀} {G₁ : Group i₁} (ξ : G₀ →ᴳ G₁) → HomSeqMap (G₀ ⊣|ᴳ) (G₁ ⊣|ᴳ) ξ ξ
_↓⟨_⟩ᴳ_ : {G₀ H₀ K₀ : Group i₀} {G₁ H₁ K₁ : Group i₁}
→ {φ : G₀ →ᴳ H₀} {seq₀ : HomSequence H₀ K₀}
→ {ψ : G₁ →ᴳ H₁} {seq₁ : HomSequence H₁ K₁}
→ (ξG : G₀ →ᴳ G₁) {ξH : H₀ →ᴳ H₁} {ξK : K₀ →ᴳ K₁}
→ CommSquareᴳ φ ψ ξG ξH
→ HomSeqMap seq₀ seq₁ ξH ξK
→ HomSeqMap (G₀ →⟨ φ ⟩ᴳ seq₀) (G₁ →⟨ ψ ⟩ᴳ seq₁) ξG ξK
HomSeqMap-snoc : ∀ {i₀ i₁} {G₀ H₀ K₀ : Group i₀} {G₁ H₁ K₁ : Group i₁}
{seq₀ : HomSequence G₀ H₀} {seq₁ : HomSequence G₁ H₁}
{φ₀ : H₀ →ᴳ K₀} {φ₁ : H₁ →ᴳ K₁}
{ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁} {ξK : K₀ →ᴳ K₁}
→ HomSeqMap seq₀ seq₁ ξG ξH
→ CommSquareᴳ φ₀ φ₁ ξH ξK
→ HomSeqMap (HomSeq-snoc seq₀ φ₀) (HomSeq-snoc seq₁ φ₁) ξG ξK
HomSeqMap-snoc (ξG ↓|ᴳ) □ = ξG ↓⟨ □ ⟩ᴳ _ ↓|ᴳ
HomSeqMap-snoc (ξG ↓⟨ □₁ ⟩ᴳ seq) □₂ = ξG ↓⟨ □₁ ⟩ᴳ HomSeqMap-snoc seq □₂
{- equivalences between two hom sequences -}
is-seqᴳ-equiv : ∀ {i₀ i₁} {G₀ H₀ : Group i₀} {G₁ H₁ : Group i₁}
{seq₀ : HomSequence G₀ H₀} {seq₁ : HomSequence G₁ H₁}
{ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁}
→ HomSeqMap seq₀ seq₁ ξG ξH
→ Type (lmax i₀ i₁)
is-seqᴳ-equiv (ξ ↓|ᴳ) = is-equiv (GroupHom.f ξ)
is-seqᴳ-equiv (ξ ↓⟨ _ ⟩ᴳ seq) = is-equiv (GroupHom.f ξ) × is-seqᴳ-equiv seq
is-seqᴳ-equiv-snoc : ∀ {i₀ i₁} {G₀ H₀ K₀ : Group i₀} {G₁ H₁ K₁ : Group i₁}
{seq₀ : HomSequence G₀ H₀} {seq₁ : HomSequence G₁ H₁}
{φ₀ : H₀ →ᴳ K₀} {φ₁ : H₁ →ᴳ K₁}
{ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁} {ξK : K₀ →ᴳ K₁}
{seq-map : HomSeqMap seq₀ seq₁ ξG ξH}
{cs : CommSquareᴳ φ₀ φ₁ ξH ξK}
→ is-seqᴳ-equiv seq-map → is-equiv (GroupHom.f ξK)
→ is-seqᴳ-equiv (HomSeqMap-snoc seq-map cs)
is-seqᴳ-equiv-snoc {seq-map = ξG ↓|ᴳ} ξG-is-equiv ξH-is-equiv = ξG-is-equiv , ξH-is-equiv
is-seqᴳ-equiv-snoc {seq-map = ξG ↓⟨ _ ⟩ᴳ seq} (ξG-is-equiv , seq-is-equiv) ξH-is-equiv =
ξG-is-equiv , is-seqᴳ-equiv-snoc seq-is-equiv ξH-is-equiv
private
is-seqᴳ-equiv-head : ∀ {i₀ i₁} {G₀ H₀ : Group i₀} {G₁ H₁ : Group i₁}
{seq₀ : HomSequence G₀ H₀} {seq₁ : HomSequence G₁ H₁}
{ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁}
{seq-map : HomSeqMap seq₀ seq₁ ξG ξH}
→ is-seqᴳ-equiv seq-map → is-equiv (GroupHom.f ξG)
is-seqᴳ-equiv-head {seq-map = ξ ↓|ᴳ} ise = ise
is-seqᴳ-equiv-head {seq-map = ξ ↓⟨ _ ⟩ᴳ _} ise = fst ise
is-seqᴳ-equiv-last : ∀ {i₀ i₁} {G₀ H₀ : Group i₀} {G₁ H₁ : Group i₁}
{seq₀ : HomSequence G₀ H₀} {seq₁ : HomSequence G₁ H₁}
{ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁}
{seq-map : HomSeqMap seq₀ seq₁ ξG ξH}
→ is-seqᴳ-equiv seq-map → is-equiv (GroupHom.f ξH)
is-seqᴳ-equiv-last {seq-map = ξ ↓|ᴳ} ise = ise
is-seqᴳ-equiv-last {seq-map = _ ↓⟨ _ ⟩ᴳ rest} (_ , rest-ise) = is-seqᴳ-equiv-last rest-ise
module is-seqᴳ-equiv {i₀ i₁} {G₀ H₀ : Group i₀} {G₁ H₁ : Group i₁}
{seq₀ : HomSequence G₀ H₀} {seq₁ : HomSequence G₁ H₁}
{ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁}
{seq-map : HomSeqMap seq₀ seq₁ ξG ξH}
(seq-map-is-equiv : is-seqᴳ-equiv seq-map) where
head = is-seqᴳ-equiv-head seq-map-is-equiv
last = is-seqᴳ-equiv-last seq-map-is-equiv
HomSeqEquiv : ∀ {i₀ i₁} {G₀ H₀ : Group i₀} {G₁ H₁ : Group i₁}
(seq₀ : HomSequence G₀ H₀) (seq₁ : HomSequence G₁ H₁)
(ξG : G₀ →ᴳ G₁) (ξH : H₀ →ᴳ H₁) → Type (lsucc (lmax i₀ i₁))
HomSeqEquiv seq₀ seq₁ ξG ξH = Σ (HomSeqMap seq₀ seq₁ ξG ξH) is-seqᴳ-equiv
HomSeqEquiv-inverse : ∀ {i₀ i₁} {G₀ H₀ : Group i₀} {G₁ H₁ : Group i₁}
{seq₀ : HomSequence G₀ H₀} {seq₁ : HomSequence G₁ H₁}
{ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁}
(equiv : HomSeqEquiv seq₀ seq₁ ξG ξH)
→ HomSeqEquiv seq₁ seq₀
(GroupIso.g-hom (ξG , is-seqᴳ-equiv-head (snd equiv)))
(GroupIso.g-hom (ξH , is-seqᴳ-equiv-last (snd equiv)))
HomSeqEquiv-inverse ((ξ ↓|ᴳ) , ξ-ise) =
(GroupIso.g-hom (ξ , ξ-ise) ↓|ᴳ) , is-equiv-inverse ξ-ise
HomSeqEquiv-inverse ((ξ ↓⟨ □ ⟩ᴳ rest) , (ξ-ise , rest-ise)) =
(GroupIso.g-hom (ξ , ξ-ise)
↓⟨ CommSquareᴳ-inverse-v □ ξ-ise (is-seqᴳ-equiv-head rest-ise) ⟩ᴳ
fst rest-inverse-equiv) ,
is-equiv-inverse ξ-ise , snd rest-inverse-equiv
where
rest-inverse-equiv = HomSeqEquiv-inverse (rest , rest-ise)
{- Doesn't seem useful.
infix 15 _↕|ᴳ
infixr 10 _↕⟨_⟩ᴳ_
_↕|ᴳ : ∀ {i} {G₀ G₁ : Group i} (iso : G₀ ≃ᴳ G₁)
→ HomSeqEquiv (G₀ ⊣|ᴳ) (G₁ ⊣|ᴳ) (fst iso) (fst iso)
iso ↕|ᴳ = (fst iso ↓|ᴳ) , snd iso
_↕⟨_⟩ᴳ_ : ∀ {i} {G₀ G₁ H₀ H₁ K₀ K₁ : Group i}
→ {φ : G₀ →ᴳ H₀} {seq₀ : HomSequence H₀ K₀}
→ {ψ : G₁ →ᴳ H₁} {seq₁ : HomSequence H₁ K₁}
→ (isoG : G₀ ≃ᴳ G₁) {isoH : H₀ ≃ᴳ H₁} {isoK : K₀ ≃ᴳ K₁}
→ HomCommSquare φ ψ (fst isoG) (fst isoH)
→ HomSeqEquiv seq₀ seq₁ (fst isoH) (fst isoK)
→ HomSeqEquiv (G₀ →⟨ φ ⟩ᴳ seq₀) (G₁ →⟨ ψ ⟩ᴳ seq₁) (fst isoG) (fst isoK)
(ξG , hG-is-equiv) ↕⟨ sqr ⟩ᴳ (seq-map , seq-map-is-equiv) =
(ξG ↓⟨ sqr ⟩ᴳ seq-map) , hG-is-equiv , seq-map-is-equiv
-}
private
hom-seq-map-index-type : ∀ {i₀ i₁} {G₀ H₀ : Group i₀} {G₁ H₁ : Group i₁}
{seq₀ : HomSequence G₀ H₀} {seq₁ : HomSequence G₁ H₁}
{ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁}
→ ℕ → HomSeqMap seq₀ seq₁ ξG ξH → Type (lmax i₀ i₁)
hom-seq-map-index-type _ (_ ↓|ᴳ) = Lift ⊤
hom-seq-map-index-type O (_↓⟨_⟩ᴳ_ {φ = φ} {ψ = ψ} ξG {ξH} _ _)
= CommSquareᴳ φ ψ ξG ξH
hom-seq-map-index-type (S n) (_ ↓⟨ _ ⟩ᴳ seq-map)
= hom-seq-map-index-type n seq-map
abstract
hom-seq-map-index : ∀ {i₀ i₁} {G₀ H₀ : Group i₀} {G₁ H₁ : Group i₁}
{seq₀ : HomSequence G₀ H₀} {seq₁ : HomSequence G₁ H₁}
{ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁}
(n : ℕ) (seq-map : HomSeqMap seq₀ seq₁ ξG ξH)
→ hom-seq-map-index-type n seq-map
hom-seq-map-index _ (_ ↓|ᴳ) = lift tt
hom-seq-map-index O (_ ↓⟨ □ ⟩ᴳ _) = □
hom-seq-map-index (S n) (_ ↓⟨ _ ⟩ᴳ seq-map)
= hom-seq-map-index n seq-map
private
hom-seq-equiv-index-type : ∀ {i₀ i₁} {G₀ H₀ : Group i₀} {G₁ H₁ : Group i₁}
{seq₀ : HomSequence G₀ H₀} {seq₁ : HomSequence G₁ H₁}
{ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁}
→ ℕ → HomSeqMap seq₀ seq₁ ξG ξH → Type (lmax i₀ i₁)
hom-seq-equiv-index-type {ξG = ξG} O _ = is-equiv (GroupHom.f ξG)
hom-seq-equiv-index-type (S _) (_ ↓|ᴳ) = Lift ⊤
hom-seq-equiv-index-type (S n) (_ ↓⟨ _ ⟩ᴳ seq-map)
= hom-seq-equiv-index-type n seq-map
abstract
hom-seq-equiv-index : ∀ {i₀ i₁} {G₀ H₀ : Group i₀} {G₁ H₁ : Group i₁}
{seq₀ : HomSequence G₀ H₀} {seq₁ : HomSequence G₁ H₁}
{ξG : G₀ →ᴳ G₁} {ξH : H₀ →ᴳ H₁}
(n : ℕ) (seq-equiv : HomSeqEquiv seq₀ seq₁ ξG ξH)
→ hom-seq-equiv-index-type n (fst seq-equiv)
hom-seq-equiv-index O (seq-map , ise) = is-seqᴳ-equiv-head ise
hom-seq-equiv-index (S _) ((_ ↓|ᴳ) , _) = lift tt
hom-seq-equiv-index (S n) ((_ ↓⟨ _ ⟩ᴳ seq-map) , ise)
= hom-seq-equiv-index n (seq-map , snd ise)
| 40.434783
| 92
| 0.592742
|
295f82d6b64c8b8473f8c21ffe921b10f095baeb
| 12,318
|
agda
|
Agda
|
LibraBFT/Abstract/RecordChain/Properties.agda
|
cwjnkins/bft-consensus-agda
|
71aa2168e4875ffdeece9ba7472ee3cee5fa9084
|
[
"UPL-1.0"
] | null | null | null |
LibraBFT/Abstract/RecordChain/Properties.agda
|
cwjnkins/bft-consensus-agda
|
71aa2168e4875ffdeece9ba7472ee3cee5fa9084
|
[
"UPL-1.0"
] | null | null | null |
LibraBFT/Abstract/RecordChain/Properties.agda
|
cwjnkins/bft-consensus-agda
|
71aa2168e4875ffdeece9ba7472ee3cee5fa9084
|
[
"UPL-1.0"
] | null | null | null |
{- Byzantine Fault Tolerant Consensus Verification in Agda, version 0.9.
Copyright (c) 2020, 2021, Oracle and/or its affiliates.
Licensed under the Universal Permissive License v 1.0 as shown at https://opensource.oracle.com/licenses/upl
-}
open import LibraBFT.Prelude
open import LibraBFT.Lemmas
open import LibraBFT.Abstract.Types
open import LibraBFT.Abstract.Types.EpochConfig
open WithAbsVote
-- This module contains properties about RecordChains, culminating in
-- theorem S5, which is the main per-epoch correctness condition. The
-- properties are based on the original version of the LibraBFT paper,
-- which was current when they were developed:
-- https://developers.diem.com/docs/assets/papers/diem-consensus-state-machine-replication-in-the-diem-blockchain/2019-06-28.pdf
-- Even though the implementation has changed since that version of the
-- paper, we do not need to redo these proofs because that affects only
-- the concrete implementation. This demonstrates one advantage of
-- separating these proofs into abstract and concrete pieces.
module LibraBFT.Abstract.RecordChain.Properties
(UID : Set)
(_≟UID_ : (u₀ u₁ : UID) → Dec (u₀ ≡ u₁))
(NodeId : Set)
(𝓔 : EpochConfig UID NodeId)
(𝓥 : VoteEvidence UID NodeId 𝓔)
where
open import LibraBFT.Abstract.Types UID NodeId 𝓔
open import LibraBFT.Abstract.System UID _≟UID_ NodeId 𝓔 𝓥
open import LibraBFT.Abstract.Records UID _≟UID_ NodeId 𝓔 𝓥
open import LibraBFT.Abstract.Records.Extends UID _≟UID_ NodeId 𝓔 𝓥
open import LibraBFT.Abstract.RecordChain UID _≟UID_ NodeId 𝓔 𝓥
open import LibraBFT.Abstract.RecordChain.Assumptions UID _≟UID_ NodeId 𝓔 𝓥
open EpochConfig 𝓔
module WithInvariants {ℓ}
(InSys : Record → Set ℓ)
(votes-only-once : VotesOnlyOnceRule InSys)
(preferred-round-rule : PreferredRoundRule InSys)
where
open All-InSys-props InSys
----------------------
-- Lemma 2
-- Lemma 2 states that there can be at most one certified block per
-- round. If two blocks have a quorum certificate for the same round,
-- then they are equal or their unique identifier is not
-- injective. This is required because, on the concrete side, this bId
-- will be a hash function which might yield collisions.
lemmaS2 : {b₀ b₁ : Block}{q₀ q₁ : QC}
→ InSys (Q q₀) → InSys (Q q₁)
→ (p₀ : B b₀ ← Q q₀)
→ (p₁ : B b₁ ← Q q₁)
→ getRound b₀ ≡ getRound b₁
→ NonInjective-≡ bId ⊎ b₀ ≡ b₁
lemmaS2 {b₀} {b₁} {q₀} {q₁} ex₀ ex₁ (B←Q refl h₀) (B←Q refl h₁) refl
with b₀ ≟Block b₁
...| yes done = inj₂ done
...| no imp
with bft-assumption (qVotes-C1 q₀) (qVotes-C1 q₁)
...| (a , (a∈q₀mem , a∈q₁mem , honest))
with Any-sym (Any-map⁻ a∈q₀mem) | Any-sym (Any-map⁻ a∈q₁mem)
...| a∈q₀ | a∈q₁
with All-lookup (qVotes-C3 q₀) (∈QC-Vote-correct q₀ a∈q₀) |
All-lookup (qVotes-C3 q₁) (∈QC-Vote-correct q₁ a∈q₁)
...| a∈q₀rnd≡ | a∈q₁rnd≡
with <-cmp (abs-vRound (∈QC-Vote q₀ a∈q₀)) (abs-vRound (∈QC-Vote q₁ a∈q₁))
...| tri< va<va' _ _ = ⊥-elim (<⇒≢ (subst₂ _<_ a∈q₀rnd≡ a∈q₁rnd≡ va<va') refl)
...| tri> _ _ va'<va = ⊥-elim (<⇒≢ (subst₂ _≤_ (cong suc a∈q₁rnd≡) a∈q₀rnd≡ va'<va) refl)
...| tri≈ _ v₀≡v₁ _ =
let v₀∈q₀ = ∈QC-Vote-correct q₀ a∈q₀
v₁∈q₁ = ∈QC-Vote-correct q₁ a∈q₁
ppp = trans h₀ (trans (vote≡⇒QPrevId≡ {q₀} {q₁} v₀∈q₀ v₁∈q₁ (votes-only-once a honest ex₀ ex₁ a∈q₀ a∈q₁ v₀≡v₁))
(sym h₁))
in inj₁ ((b₀ , b₁) , (imp , ppp))
----------------
-- Lemma S3
lemmaS3 : ∀{r₂ q'}
{rc : RecordChain r₂} → InSys r₂
→ (rc' : RecordChain (Q q')) → InSys (Q q') -- Immediately before a (Q q), we have the certified block (B b), which is the 'B' in S3
→ (c3 : 𝕂-chain Contig 3 rc) -- This is B₀ ← C₀ ← B₁ ← C₁ ← B₂ ← C₂ in S3
→ round r₂ < getRound q'
→ NonInjective-≡ bId ⊎ (getRound (kchainBlock (suc (suc zero)) c3) ≤ prevRound rc')
lemmaS3 {r₂} {q'} ex₀ (step rc' b←q') ex₁ (s-chain {rc = rc} {b = b₂} {q₂} r←b₂ _ b₂←q₂ c2) hyp
with bft-assumption (qVotes-C1 q₂) (qVotes-C1 q')
...| (a , (a∈q₂mem , a∈q'mem , honest))
with Any-sym (Any-map⁻ a∈q₂mem) | Any-sym (Any-map⁻ a∈q'mem)
...| a∈q₂ | a∈q'
-- TODO-1: We have done similar reasoning on the order of votes for
-- lemmaS2. We should factor out a predicate that analyzes the rounds
-- of QC's and returns us a judgement about the order of the votes.
with All-lookup (qVotes-C3 q') (∈QC-Vote-correct q' a∈q') |
All-lookup (qVotes-C3 q₂) (∈QC-Vote-correct q₂ a∈q₂)
...| a∈q'rnd≡ | a∈q₂rnd≡
with <-cmp (round r₂) (abs-vRound (∈QC-Vote q' a∈q'))
...| tri> _ _ va'<va₂
with subst₂ _<_ a∈q'rnd≡ a∈q₂rnd≡ (≤-trans va'<va₂ (≤-reflexive (sym a∈q₂rnd≡)))
...| res = ⊥-elim (n≮n (getRound q') (≤-trans res (≤-unstep hyp)))
lemmaS3 {q' = q'} ex₀ (step rc' b←q') ex₁ (s-chain {rc = rc} {b = b₂} {q₂} r←b₂ P b₂←q₂ c2) hyp
| (a , (a∈q₂mem , a∈q'mem , honest))
| a∈q₂ | a∈q'
| a∈q'rnd≡ | a∈q₂rnd≡
| tri≈ _ v₂≡v' _ =
let v₂∈q₂ = ∈QC-Vote-correct q₂ a∈q₂
v'∈q' = ∈QC-Vote-correct q' a∈q'
in ⊥-elim (<⇒≢ hyp (vote≡⇒QRound≡ {q₂} {q'} v₂∈q₂ v'∈q'
(votes-only-once a honest {q₂} {q'} ex₀ ex₁ a∈q₂ a∈q'
(trans a∈q₂rnd≡ v₂≡v'))))
lemmaS3 {r} {q'} ex₀ (step rc' b←q') ex₁ (s-chain {rc = rc} {b = b₂} {q₂} r←b₂ P b₂←q₂ c2) hyp
| (a , (a∈q₂mem , a∈q'mem , honest))
| a∈q₂ | a∈q'
| a∈q'rnd≡ | a∈q₂rnd≡
| tri< va₂<va' _ _
with b←q'
...| B←Q rrr xxx
= preferred-round-rule a honest {q₂} {q'} ex₀ ex₁ (s-chain r←b₂ P b₂←q₂ c2) a∈q₂
(step rc' (B←Q rrr xxx)) a∈q'
(≤-trans (≤-reflexive (cong suc a∈q₂rnd≡))
va₂<va')
------------------
-- Proposition S4
-- The base case for lemma S4 resorts to a pretty simple
-- arithmetic statement.
propS4-base-arith
: ∀ n r
→ n ≤ r → r ≤ (suc (suc n))
→ r ∈ (suc (suc n) ∷ suc n ∷ n ∷ [])
propS4-base-arith .0 .0 z≤n z≤n = there (there (here refl))
propS4-base-arith .0 .1 z≤n (s≤s z≤n) = there (here refl)
propS4-base-arith .0 .2 z≤n (s≤s (s≤s z≤n)) = here refl
propS4-base-arith (suc r) (suc n) (s≤s h0) (s≤s h1)
= ∈-cong suc (propS4-base-arith r n h0 h1)
-- Which is then translated to LibraBFT lingo
propS4-base-lemma-1
: ∀{q}{rc : RecordChain (Q q)}
→ (c3 : 𝕂-chain Contig 3 rc) -- This is B₀ ← C₀ ← B₁ ← C₁ ← B₂ ← C₂ in S4
→ (r : ℕ)
→ getRound (c3 b⟦ suc (suc zero) ⟧) ≤ r
→ r ≤ getRound (c3 b⟦ zero ⟧)
→ r ∈ ( getRound (c3 b⟦ zero ⟧)
∷ getRound (c3 b⟦ (suc zero) ⟧)
∷ getRound (c3 b⟦ (suc (suc zero)) ⟧)
∷ [])
propS4-base-lemma-1 (s-chain {b = b0} _ p0 (B←Q refl b←q0)
(s-chain {b = b1} r←b1 p1 (B←Q refl b←q1)
(s-chain {r = R} {b = b2} r←b2 p2 (B←Q refl b←q2)
0-chain))) r hyp0 hyp1
rewrite p0 | p1 = propS4-base-arith (bRound b2) r hyp0 hyp1
propS4-base-lemma-2
: ∀{k r}
{rc : RecordChain r} → All-InSys rc
→ (q' : QC) → InSys (Q q')
→ {b' : Block}
→ (rc' : RecordChain (B b')) → (ext : (B b') ← (Q q'))
→ (c : 𝕂-chain Contig k rc)
→ (ix : Fin k)
→ getRound (kchainBlock ix c) ≡ getRound b'
→ NonInjective-≡ bId ⊎ (kchainBlock ix c ≡ b')
propS4-base-lemma-2 {rc = rc} prev∈sys q' q'∈sys rc' ext (s-chain r←b prf b←q c) zero hyp
= lemmaS2 (All-InSys⇒last-InSys prev∈sys) q'∈sys b←q ext hyp
propS4-base-lemma-2 prev∈sys q' q'∈sys rc' ext (s-chain r←b prf b←q c) (suc ix)
= propS4-base-lemma-2 (All-InSys-unstep (All-InSys-unstep prev∈sys)) q' q'∈sys rc' ext c ix
propS4-base : ∀{q q'}
→ {rc : RecordChain (Q q)} → All-InSys rc
→ (rc' : RecordChain (Q q')) → InSys (Q q')
→ (c3 : 𝕂-chain Contig 3 rc) -- This is B₀ ← C₀ ← B₁ ← C₁ ← B₂ ← C₂ in S4
→ getRound (c3 b⟦ suc (suc zero) ⟧) ≤ getRound q'
→ getRound q' ≤ getRound (c3 b⟦ zero ⟧)
→ NonInjective-≡ bId ⊎ B (c3 b⟦ suc (suc zero) ⟧) ∈RC rc'
propS4-base {q' = q'} prev∈sys (step {B b} rc'@(step rc'' q←b) b←q@(B←Q refl _)) q'∈sys c3 hyp0 hyp1
with propS4-base-lemma-1 c3 (getRound b) hyp0 hyp1
...| here r
with propS4-base-lemma-2 prev∈sys q' q'∈sys rc' b←q c3 zero (sym r)
...| inj₁ hb = inj₁ hb
...| inj₂ res
with 𝕂-chain-∈RC c3 zero (suc (suc zero)) z≤n res rc'
...| inj₁ hb = inj₁ hb
...| inj₂ res' = inj₂ (there b←q res')
propS4-base {q} {q'} prev∈sys (step rc' (B←Q refl x₀)) q'∈sys c3 hyp0 hyp1
| there (here r)
with propS4-base-lemma-2 prev∈sys q' q'∈sys rc' (B←Q refl x₀) c3 (suc zero) (sym r)
...| inj₁ hb = inj₁ hb
...| inj₂ res
with 𝕂-chain-∈RC c3 (suc zero) (suc (suc zero)) (s≤s z≤n) res rc'
...| inj₁ hb = inj₁ hb
...| inj₂ res' = inj₂ (there (B←Q refl x₀) res')
propS4-base {q' = q'} prev∈sys (step rc' (B←Q refl x₀)) q'∈sys c3 hyp0 hyp1
| there (there (here r))
with propS4-base-lemma-2 prev∈sys q' q'∈sys rc' (B←Q refl x₀) c3 (suc (suc zero)) (sym r)
...| inj₁ hb = inj₁ hb
...| inj₂ res
with 𝕂-chain-∈RC c3 (suc (suc zero)) (suc (suc zero)) (s≤s (s≤s z≤n)) res rc'
...| inj₁ hb = inj₁ hb
...| inj₂ res' = inj₂ (there (B←Q refl x₀) res')
propS4 : ∀{q q'}
→ {rc : RecordChain (Q q)} → All-InSys rc
→ (rc' : RecordChain (Q q')) → All-InSys rc'
→ (c3 : 𝕂-chain Contig 3 rc) -- This is B₀ ← C₀ ← B₁ ← C₁ ← B₂ ← C₂ in S4
→ getRound (c3 b⟦ suc (suc zero) ⟧) ≤ getRound q'
-- In the paper, the proposition states that B₀ ←⋆ B, yet, B is the block preceding
-- C, which in our case is 'prevBlock rc''. Hence, to say that B₀ ←⋆ B is
-- to say that B₀ is a block in the RecordChain that goes all the way to C.
→ NonInjective-≡ bId ⊎ B (c3 b⟦ suc (suc zero) ⟧) ∈RC rc'
propS4 {q' = q'} {rc} prev∈sys (step rc' b←q') prev∈sys' c3 hyp
with getRound q' ≤?ℕ getRound (c3 b⟦ zero ⟧)
...| yes rq≤rb₂ = propS4-base {q' = q'} prev∈sys (step rc' b←q') (All-InSys⇒last-InSys prev∈sys') c3 hyp rq≤rb₂
propS4 {q' = q'} prev∈sys (step rc' b←q') all∈sys c3 hyp
| no rb₂<rq
with lemmaS3 (All-InSys⇒last-InSys prev∈sys) (step rc' b←q')
(All-InSys⇒last-InSys all∈sys) c3
(subst (_< getRound q') (kchainBlockRoundZero-lemma c3) (≰⇒> rb₂<rq))
...| inj₁ hb = inj₁ hb
...| inj₂ ls3
with rc' | b←q'
...| step rc'' q←b | (B←Q {b} rx x)
with rc'' | q←b
...| empty | (I←B _ _)
= contradiction (n≤0⇒n≡0 ls3)
(¬bRound≡0 (kchain-to-RecordChain-at-b⟦⟧ c3 (suc (suc zero))))
...| step {r = r} rc''' (B←Q {q = q''} refl bid≡) | (Q←B ry y)
with propS4 {q' = q''} prev∈sys (step rc''' (B←Q refl bid≡)) (All-InSys-unstep (All-InSys-unstep all∈sys)) c3 ls3
...| inj₁ hb' = inj₁ hb'
...| inj₂ final = inj₂ (there (B←Q rx x) (there (Q←B ry y) final))
-------------------
-- Theorem S5
thmS5 : ∀{q q'}
→ {rc : RecordChain (Q q )} → All-InSys rc
→ {rc' : RecordChain (Q q')} → All-InSys rc'
→ {b b' : Block}
→ CommitRule rc b
→ CommitRule rc' b'
→ NonInjective-≡ bId ⊎ ((B b) ∈RC rc' ⊎ (B b') ∈RC rc) -- Not conflicting means one extends the other.
thmS5 {rc = rc} prev∈sys {rc'} prev∈sys' (commit-rule c3 refl) (commit-rule c3' refl)
with <-cmp (getRound (c3 b⟦ suc (suc zero) ⟧)) (getRound (c3' b⟦ suc (suc zero) ⟧))
...| tri≈ _ r≡r' _ = inj₁ <⊎$> (propS4 prev∈sys rc' prev∈sys' c3 (≤-trans (≡⇒≤ r≡r') (kchain-round-≤-lemma' c3' (suc (suc zero)))))
...| tri< r<r' _ _ = inj₁ <⊎$> (propS4 prev∈sys rc' prev∈sys' c3 (≤-trans (≤-unstep r<r') (kchain-round-≤-lemma' c3' (suc (suc zero)))))
...| tri> _ _ r'<r = inj₂ <⊎$> (propS4 prev∈sys' rc prev∈sys c3' (≤-trans (≤-unstep r'<r) (kchain-round-≤-lemma' c3 (suc (suc zero)))))
| 49.272
| 144
| 0.547816
|
1a38e91cc2ea9ffc047bcafb388e8ec25af2e608
| 399
|
agda
|
Agda
|
Cubical/Algebra/Magma/Construct/Unit.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/Magma/Construct/Unit.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/Magma/Construct/Unit.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.Magma.Construct.Unit where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Algebra.Magma
open import Cubical.Data.Unit
_◯_ : Op₂ ⊤
_ ◯ _ = tt
⊤-isMagma : IsMagma ⊤ _◯_
⊤-isMagma = record { is-set = isSet⊤ }
⊤-Magma : Magma ℓ-zero
⊤-Magma = record { isMagma = ⊤-isMagma }
| 21
| 50
| 0.706767
|
57860659d90c656b49d44a830718e16156fc3768
| 945
|
agda
|
Agda
|
test/fail/Issue118Comment9.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2019-11-27T04:41:05.000Z
|
2019-11-27T04:41:05.000Z
|
test/fail/Issue118Comment9.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/fail/Issue118Comment9.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --universe-polymorphism #-} -- coinduction require this
module Issue118Comment9 where
open import Imports.Level
infix 1000 ♯_
postulate
∞ : ∀ {a} (A : Set a) → Set a
♯_ : ∀ {a} {A : Set a} → A → ∞ A
♭ : ∀ {a} {A : Set a} → ∞ A → A
{-# BUILTIN INFINITY ∞ #-}
{-# BUILTIN SHARP ♯_ #-}
{-# BUILTIN FLAT ♭ #-}
data Box (A : Set) : Set where
[_] : A → Box A
postulate I : Set
data P : I → Set where
c : ∀ {i} → Box (∞ (P i)) → P i
F : ∀ {i} → P i → I
F (c x) = _
G : ∀ {i} → Box (∞ (P i)) → I
G [ x ] = _
mutual
f : ∀ {i} (x : P i) → P (F x)
f (c x) = c (g x)
g : ∀ {i} (x : Box (∞ (P i))) → Box (∞ (P (G x)))
g [ x ] = [ ♯ f (♭ x) ]
-- The code above type checks, but the termination checker should
-- complain because the inferred definitions of F and G are
-- F (c x) = G x and G [ x ] = F (♭ x), respectively.
-- 2011-04-12 freezing: now the meta-variables remain uninstantiated.
-- good.
| 20.543478
| 69
| 0.512169
|
22829cea626e9d90069058f76001070928b5deda
| 143
|
agda
|
Agda
|
Cubical/Data/HomotopyGroup.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/Data/HomotopyGroup.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2022-01-27T02:07:48.000Z
|
2022-01-27T02:07:48.000Z
|
Cubical/Data/HomotopyGroup.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2021-11-22T02:02:01.000Z
|
2021-11-22T02:02:01.000Z
|
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Data.HomotopyGroup where
open import Cubical.Data.HomotopyGroup.Base public
| 28.6
| 50
| 0.769231
|
5921223fb5fac4f403f9c3e122a6b21f0de96b89
| 135
|
agda
|
Agda
|
src/index.agda
|
jonsterling/agda-calf
|
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
|
[
"Apache-2.0"
] | 29
|
2021-07-14T03:18:28.000Z
|
2022-03-22T20:35:11.000Z
|
src/index.agda
|
jonsterling/agda-calf
|
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
|
[
"Apache-2.0"
] | null | null | null |
src/index.agda
|
jonsterling/agda-calf
|
e51606f9ca18d8b4cf9a63c2d6caa2efc5516146
|
[
"Apache-2.0"
] | 2
|
2021-10-06T10:28:24.000Z
|
2022-01-29T08:12:01.000Z
|
{-# OPTIONS --prop --rewriting #-}
module index where
-- Calf language implementation:
import Calf
-- Case studies:
import Examples
| 13.5
| 34
| 0.718519
|
Subsets and Splits
HTML Code Excluding Scripts
The query retrieves a limited set of HTML content entries that are longer than 8 characters and do not contain script tags, offering only basic filtering with minimal analytical value.