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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0b72621fba214cef5eed336f6837ec83ad1b40f0
| 14,893
|
agda
|
Agda
|
Cubical/HITs/Hopf.agda
|
hyleIndex/cubical
|
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
|
[
"MIT"
] | 301
|
2018-10-17T18:00:24.000Z
|
2022-03-24T02:10:47.000Z
|
Cubical/HITs/Hopf.agda
|
hyleIndex/cubical
|
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
|
[
"MIT"
] | 584
|
2018-10-15T09:49:02.000Z
|
2022-03-30T12:09:17.000Z
|
Cubical/HITs/Hopf.agda
|
hyleIndex/cubical
|
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
|
[
"MIT"
] | 134
|
2018-11-16T06:11:03.000Z
|
2022-03-23T16:22:13.000Z
|
{-# OPTIONS --safe #-}
module Cubical.HITs.Hopf where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Data.Int hiding (_·_)
open import Cubical.Data.Sigma
open import Cubical.Foundations.Function
open import Cubical.HITs.S1
open import Cubical.HITs.S2
open import Cubical.HITs.S3
open import Cubical.HITs.Sn
open import Cubical.HITs.Susp
open import Cubical.HITs.Join
open import Cubical.HITs.Interval
renaming ( zero to I0 ; one to I1 )
Border : (x : S¹) → (j : I) → Partial (j ∨ ~ j) (Σ Type₀ (λ T → T ≃ S¹))
Border x j (j = i0) = S¹ , (x ·_) , rotIsEquiv x
Border x j (j = i1) = S¹ , idEquiv S¹
-- Hopf fibration using SuspS¹
HopfSuspS¹ : SuspS¹ → Type₀
HopfSuspS¹ north = S¹
HopfSuspS¹ south = S¹
HopfSuspS¹ (merid x j) = Glue S¹ (Border x j)
-- Hopf fibration using S²
-- TODO : prove that it is equivalent to HopfSuspS¹
HopfS² : S² → Type₀
HopfS² base = S¹
HopfS² (surf i j) = Glue S¹ (λ { (i = i0) → _ , idEquiv S¹
; (i = i1) → _ , idEquiv S¹
; (j = i0) → _ , idEquiv S¹
; (j = i1) → _ , _ , rotIsEquiv (loop i) } )
-- Hopf fibration using more direct definition of the rot equivalence
-- TODO : prove that it is equivalent to HopfSuspS¹
HopfS²' : S² → Type₀
HopfS²' base = S¹
HopfS²' (surf i j) = Glue S¹ (λ { (i = i0) → _ , rotLoopEquiv i0
; (i = i1) → _ , rotLoopEquiv i0
; (j = i0) → _ , rotLoopEquiv i0
; (j = i1) → _ , rotLoopEquiv i } )
-- Total space of the fibration
TotalHopf : Type₀
TotalHopf = Σ SuspS¹ HopfSuspS¹
-- Forward direction
filler-1 : I → (j : I) → (y : S¹) → Glue S¹ (Border y j) → join S¹ S¹
filler-1 i j y x = hfill (λ t → λ { (j = i0) → inl (rotInv-1 x y t)
; (j = i1) → inr x })
(inS (push ((unglue (j ∨ ~ j) x) · invLooper y) (unglue (j ∨ ~ j) x) j)) i
TotalHopf→JoinS¹S¹ : TotalHopf → join S¹ S¹
TotalHopf→JoinS¹S¹ (north , x) = inl x
TotalHopf→JoinS¹S¹ (south , x) = inr x
TotalHopf→JoinS¹S¹ (merid y j , x) = filler-1 i1 j y x
-- Backward direction
JoinS¹S¹→TotalHopf : join S¹ S¹ → TotalHopf
JoinS¹S¹→TotalHopf (inl x) = (north , x)
JoinS¹S¹→TotalHopf (inr x) = (south , x)
JoinS¹S¹→TotalHopf (push y x j) =
(merid (invLooper y · x) j
, glue (λ { (j = i0) → y ; (j = i1) → x }) (rotInv-2 x y j))
-- Now for the homotopies, we will need to fill squares indexed by x y : S¹ with value in S¹
-- Some will be extremeley tough, but happen to be easy when x = y = base
-- therefore, we fill them for x = y = base and then use the connectedness of S¹ × S¹ and
-- the discreteness of ΩS¹ to get general fillers.
-- To proceed with that strategy, we first need a lemma :
-- the sections of the trivial fibration λ (_ : S¹) (_ : S¹) → Int are constant
-- this should be generalized to a constant fibration over a connected space with
-- discrete fiber
fibℤ : S¹ → S¹ → Type₀
fibℤ _ _ = ℤ
S¹→HSet : (A : Type₀) (p : isSet A) (F : S¹ → A) (x : S¹) → F base ≡ F x
S¹→HSet A p F base = refl {x = F base}
S¹→HSet A p F (loop i) = f' i
where
f : PathP (λ i → F base ≡ F (loop i)) refl (cong F loop)
f i = λ j → F (loop (i ∧ j))
L : cong F loop ≡ refl
L = p (F base) (F base) (f i1) refl
f' : PathP (λ i → F base ≡ F (loop i)) (refl {x = F base}) (refl {x = F base})
f' = transport (λ i → PathP (λ j → F base ≡ F (loop j)) refl (L i)) f
constant-loop : (F : S¹ → S¹ → ℤ) → (x y : S¹) → F base base ≡ F x y
constant-loop F x y = L0 ∙ L1
where
p : isSet (S¹ → ℤ)
p = isSetΠ (λ _ → isSetℤ)
L : F base ≡ F x
L = S¹→HSet (S¹ → ℤ) p F x
L0 : F base base ≡ F x base
L0 i = L i base
L1 : F x base ≡ F x y
L1 = S¹→HSet ℤ isSetℤ (F x) y
discretefib : (F : S¹ → S¹ → Type₀) → Type₀
discretefib F = (a : (x y : S¹) → F x y) →
(b : (x y : S¹) → F x y) →
(a base base ≡ b base base) →
(x y : S¹) → a x y ≡ b x y
discretefib-fibℤ : discretefib fibℤ
discretefib-fibℤ a b h x y i =
hcomp (λ t → λ { (i = i0) → constant-loop a x y t
; (i = i1) → constant-loop b x y t })
(h i)
-- first homotopy
assocFiller-3-aux : I → I → I → I → S¹
assocFiller-3-aux x y j i =
hfill (λ t → λ { (i = i0) → rotInv-1 (loop y) (loop (~ y) · loop x) t
; (i = i1) → rotInv-3 (loop y) (loop x) t
; (x = i0) (y = i0) → base
; (x = i0) (y = i1) → base
; (x = i1) (y = i0) → base
; (x = i1) (y = i1) → base })
(inS ((rotInv-2 (loop x) (loop y) i) · (invLooper (loop (~ y) · loop x)))) j
-- assocFiller-3-endpoint is used only in the type of the next function, to specify the
-- second endpoint.
-- However, I only need the first endpoint, but I cannot specify only one of them as is.
-- TODO : use cubical extension types when available to remove assocFiller-3-endpoint
assocFiller-3-endpoint : (x : S¹) → (y : S¹) → y ≡ y
assocFiller-3-endpoint base base i = base
assocFiller-3-endpoint (loop x) base i = assocFiller-3-aux x i0 i1 i
assocFiller-3-endpoint base (loop y) i = assocFiller-3-aux i0 y i1 i
assocFiller-3-endpoint (loop x) (loop y) i = assocFiller-3-aux x y i1 i
assocFiller-3 : (x : S¹) → (y : S¹) →
PathP (λ j → rotInv-1 y (invLooper y · x) j ≡ rotInv-3 y x j)
(λ i → ((rotInv-2 x y i) · (invLooper (invLooper y · x))))
(assocFiller-3-endpoint x y)
assocFiller-3 base base j i = base
assocFiller-3 (loop x) base j i = assocFiller-3-aux x i0 j i
assocFiller-3 base (loop y) j i = assocFiller-3-aux i0 y j i
assocFiller-3 (loop x) (loop y) j i = assocFiller-3-aux x y j i
assoc-3 : (_ y : S¹) → basedΩS¹ y
assoc-3 x y i = assocFiller-3 x y i1 i
fibℤ≡fibAssoc-3 : fibℤ ≡ (λ _ y → basedΩS¹ y)
fibℤ≡fibAssoc-3 i = λ x y → basedΩS¹≡ℤ y (~ i)
discretefib-fibAssoc-3 : discretefib (λ _ y → basedΩS¹ y)
discretefib-fibAssoc-3 =
transp (λ i → discretefib (fibℤ≡fibAssoc-3 i)) i0 discretefib-fibℤ
assocConst-3 : (x y : S¹) → assoc-3 x y ≡ refl
assocConst-3 x y = discretefib-fibAssoc-3 assoc-3 (λ _ _ → refl) refl x y
assocSquare-3 : I → I → S¹ → S¹ → S¹
assocSquare-3 i j x y = hcomp (λ t → λ { (i = i0) → assocFiller-3 x y j i0
; (i = i1) → assocFiller-3 x y j i1
; (j = i0) → assocFiller-3 x y i0 i
; (j = i1) → assocConst-3 x y t i })
(assocFiller-3 x y j i)
filler-3 : I → I → S¹ → S¹ → join S¹ S¹
filler-3 i j y x =
hcomp (λ t → λ { (i = i0) → filler-1 t j (invLooper y · x)
(glue (λ { (j = i0) → y ; (j = i1) → x })
(rotInv-2 x y j))
; (i = i1) → push (rotInv-3 y x t) x j
; (j = i0) → inl (assocSquare-3 i t x y)
; (j = i1) → inr x })
(push ((rotInv-2 x y (i ∨ j)) · (invLooper (invLooper y · x))) (rotInv-2 x y (i ∨ j)) j)
JoinS¹S¹→TotalHopf→JoinS¹S¹ : ∀ x → TotalHopf→JoinS¹S¹ (JoinS¹S¹→TotalHopf x) ≡ x
JoinS¹S¹→TotalHopf→JoinS¹S¹ (inl x) i = inl x
JoinS¹S¹→TotalHopf→JoinS¹S¹ (inr x) i = inr x
JoinS¹S¹→TotalHopf→JoinS¹S¹ (push y x j) i = filler-3 i j y x
-- Second homotopy
-- This HIT is the total space of the Hopf fibration but the ends of SuspS¹ have not been
-- glued together yet — which makes it into a cylinder.
-- This allows to write compositions that do not properly match at the endpoints. However,
-- I suspect it is unnecessary. TODO : do without PseudoHopf
PseudoHopf : Type₀
PseudoHopf = (S¹ × Interval) × S¹
PseudoHopf-π1 : PseudoHopf → S¹
PseudoHopf-π1 ((y , _) , _) = y
PseudoHopf-π2 : PseudoHopf → S¹
PseudoHopf-π2 (_ , x) = x
assocFiller-4-aux : I → I → I → I → S¹
assocFiller-4-aux x y j i =
hfill (λ t → λ { (i = i0) → ((invLooper (loop y · loop x · loop (~ y))) · (loop y · loop x))
· (rotInv-1 (loop x) (loop y) t)
; (i = i1) → (rotInv-4 (loop y) (loop y · loop x) (~ t)) · loop x
; (x = i0) (y = i0) → base
; (x = i0) (y = i1) → base
; (x = i1) (y = i0) → base
; (x = i1) (y = i1) → base })
(inS (rotInv-2 (loop y · loop x) (loop y · loop x · loop (~ y)) i)) j
-- See assocFiller-3-endpoint
-- TODO : use cubical extension types when available to remove assocFiller-4-endpoint
assocFiller-4-endpoint : (x y : S¹) → basedΩS¹ (((invLooper (y · x · invLooper y)) · (y · x)) · x)
assocFiller-4-endpoint base base i = base
assocFiller-4-endpoint (loop x) base i = assocFiller-4-aux x i0 i1 i
assocFiller-4-endpoint base (loop y) i = assocFiller-4-aux i0 y i1 i
assocFiller-4-endpoint (loop x) (loop y) i = assocFiller-4-aux x y i1 i
assocFiller-4 : (x y : S¹) →
PathP (λ j → ((invLooper (y · x · invLooper y)) · (y · x)) · (rotInv-1 x y j) ≡ (rotInv-4 y (y · x) (~ j)) · x)
(λ i → (rotInv-2 (y · x) (y · x · invLooper y) i))
(assocFiller-4-endpoint x y)
assocFiller-4 base base j i = base
assocFiller-4 (loop x) base j i = assocFiller-4-aux x i0 j i
assocFiller-4 base (loop y) j i = assocFiller-4-aux i0 y j i
assocFiller-4 (loop x) (loop y) j i = assocFiller-4-aux x y j i
assoc-4 : (x y : S¹) → basedΩS¹ (((invLooper (y · x · invLooper y)) · (y · x)) · x)
assoc-4 x y i = assocFiller-4 x y i1 i
fibℤ≡fibAssoc-4 : fibℤ ≡ (λ x y → basedΩS¹ (((invLooper (y · x · invLooper y)) · (y · x)) · x))
fibℤ≡fibAssoc-4 i = λ x y → basedΩS¹≡ℤ (((invLooper (y · x · invLooper y)) · (y · x)) · x) (~ i)
discretefib-fibAssoc-4 : discretefib (λ x y → basedΩS¹ (((invLooper (y · x · invLooper y)) · (y · x)) · x))
discretefib-fibAssoc-4 =
transp (λ i → discretefib (fibℤ≡fibAssoc-4 i)) i0 discretefib-fibℤ
assocConst-4 : (x y : S¹) → assoc-4 x y ≡ refl
assocConst-4 x y = discretefib-fibAssoc-4 assoc-4 (λ _ _ → refl) refl x y
assocSquare-4 : I → I → S¹ → S¹ → S¹
assocSquare-4 i j x y =
hcomp (λ t → λ { (i = i0) → assocFiller-4 x y j i0
; (i = i1) → assocFiller-4 x y j i1
; (j = i0) → assocFiller-4 x y i0 i
; (j = i1) → assocConst-4 x y t i })
(assocFiller-4 x y j i)
filler-4-0 : (_ j : I) → (y : S¹) → Glue S¹ (Border y j) → PseudoHopf
filler-4-0 i j y x =
let x' = unglue (j ∨ ~ j) x in
hfill (λ t → λ { (j = i0) → ((invLooper (y · x · invLooper y) · (y · x) , I0)
, invLooper (y · x · invLooper y) · (y · x) · (rotInv-1 x y t))
; (j = i1) → ((invLooper (x · invLooper y) · x , I1) , x) })
(inS ((invLooper (x' · invLooper y) · x' , seg j) , rotInv-2 x' (x' · invLooper y) j)) i
filler-4-1 : (_ j : I) → (y : S¹) → Glue S¹ (Border y j) → PseudoHopf
filler-4-1 i j y x =
let x' = unglue (j ∨ ~ j) x in
hfill (λ t → λ { (j = i0) → ((invLooper (y · x · invLooper y) · (y · x) , I0)
, (rotInv-4 y (y · x) (~ t)) · x)
; (j = i1) → ((invLooper (x · invLooper y) · x , I1) , x) })
(inS ((invLooper (x' · invLooper y) · x' , seg j) , unglue (j ∨ ~ j) x)) i
filler-4-2 : (_ j : I) → (y : S¹) → Glue S¹ (Border y j) → TotalHopf
filler-4-2 i j y x =
let x' = unglue (j ∨ ~ j) x in
hcomp (λ t → λ { (i = i0) → JoinS¹S¹→TotalHopf (filler-1 t j y x)
; (i = i1) → (merid (PseudoHopf-π1 (filler-4-0 t j y x)) j
, glue (λ { (j = i0) → rotInv-1 x y t ; (j = i1) → x })
(PseudoHopf-π2 (filler-4-0 t j y x)))
; (j = i0) → (north , rotInv-1 x y t)
; (j = i1) → (south , x) })
(merid (invLooper (x' · invLooper y) · x') j
, glue (λ { (j = i0) → y · x · invLooper y ; (j = i1) → x }) (rotInv-2 x' (x' · invLooper y) j))
filler-4-3 : (_ j : I) → (y : S¹) → Glue S¹ (Border y j) → PseudoHopf
filler-4-3 i j y x =
let x' = unglue (j ∨ ~ j) x in
hcomp (λ t → λ { (i = i0) → filler-4-0 t j y x
; (i = i1) → filler-4-1 t j y x
; (j = i0) → ((invLooper (y · x · invLooper y) · (y · x) , I0) , assocSquare-4 i t x y)
; (j = i1) → ((invLooper (x · invLooper y) · x , I1) , x) })
((invLooper (x' · invLooper y) · x' , seg j) , rotInv-2 x' (x' · invLooper y) (i ∨ j))
filler-4-4 : (_ j : I) → (y : S¹) → Glue S¹ (Border y j) → PseudoHopf
filler-4-4 i j y x =
let x' = unglue (j ∨ ~ j) x in
hcomp (λ t → λ { (i = i0) → filler-4-1 t j y x
; (i = i1) → ((y , seg j) , unglue (j ∨ ~ j) x)
; (j = i0) → ((rotInv-4 y (y · x) i , I0)
, (rotInv-4 y (y · x) (i ∨ ~ t)) · x)
; (j = i1) → ((rotInv-4 y x i , I1) , x) })
((rotInv-4 y x' i , seg j) , x')
filler-4-5 : (_ j : I) → (y : S¹) → Glue S¹ (Border y j) → TotalHopf
filler-4-5 i j y x =
hcomp (λ t → λ { (i = i0) → filler-4-2 (~ t) j y x
; (i = i1) → (merid (PseudoHopf-π1 (filler-4-4 t j y x)) j
, glue (λ { (j = i0) → x ; (j = i1) → x })
(PseudoHopf-π2 (filler-4-4 t j y x)))
; (j = i0) → (north , x)
; (j = i1) → (south , x) })
(merid (PseudoHopf-π1 (filler-4-3 i j y x)) j
, glue (λ { (j = i0) → x ; (j = i1) → x }) (PseudoHopf-π2 (filler-4-3 i j y x)))
TotalHopf→JoinS¹S¹→TotalHopf : ∀ x → JoinS¹S¹→TotalHopf (TotalHopf→JoinS¹S¹ x) ≡ x
TotalHopf→JoinS¹S¹→TotalHopf (north , x) i = (north , x)
TotalHopf→JoinS¹S¹→TotalHopf (south , x) i = (south , x)
TotalHopf→JoinS¹S¹→TotalHopf (merid y j , x) i = filler-4-5 i j y x
JoinS¹S¹≡TotalHopf : join S¹ S¹ ≡ TotalHopf
JoinS¹S¹≡TotalHopf = isoToPath (iso JoinS¹S¹→TotalHopf
TotalHopf→JoinS¹S¹
TotalHopf→JoinS¹S¹→TotalHopf
JoinS¹S¹→TotalHopf→JoinS¹S¹)
S³≡TotalHopf : S³ ≡ TotalHopf
S³≡TotalHopf = S³≡joinS¹S¹ ∙ JoinS¹S¹≡TotalHopf
open Iso
IsoS³TotalHopf : Iso (S₊ 3) TotalHopf
fun IsoS³TotalHopf x = JoinS¹S¹→TotalHopf (S³→joinS¹S¹ (inv IsoS³S3 x))
inv IsoS³TotalHopf x = fun IsoS³S3 (joinS¹S¹→S³ (TotalHopf→JoinS¹S¹ x))
rightInv IsoS³TotalHopf x =
cong (JoinS¹S¹→TotalHopf ∘ S³→joinS¹S¹)
(leftInv IsoS³S3 (joinS¹S¹→S³ (TotalHopf→JoinS¹S¹ x)))
∙∙ cong JoinS¹S¹→TotalHopf
(joinS¹S¹→S³→joinS¹S¹ (TotalHopf→JoinS¹S¹ x))
∙∙ TotalHopf→JoinS¹S¹→TotalHopf x
leftInv IsoS³TotalHopf x =
cong (fun IsoS³S3 ∘ joinS¹S¹→S³)
(JoinS¹S¹→TotalHopf→JoinS¹S¹ (S³→joinS¹S¹ (inv IsoS³S3 x)))
∙∙ cong (fun IsoS³S3) (S³→joinS¹S¹→S³ (inv IsoS³S3 x))
∙∙ Iso.rightInv IsoS³S3 x
| 43.674487
| 127
| 0.540992
|
fbc24df8882f29570016b331441d6dacb85441ce
| 1,599
|
agda
|
Agda
|
Cubical/Structures/Transfer.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/Structures/Transfer.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2022-01-27T02:07:48.000Z
|
2022-01-27T02:07:48.000Z
|
Cubical/Structures/Transfer.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
{-
Transferring properties of terms between equivalent structures
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Structures.Transfer where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.SIP
open import Cubical.Foundations.Transport
open import Cubical.Structures.Product
private
variable
ℓ ℓ₀ ℓ₁ ℓ₂ ℓ₂' : Level
transfer : {ℓ₂' ℓ₀ : Level} {S : Type ℓ → Type ℓ₁} {H : Type ℓ → Type ℓ₂}
(P : ∀ X → S X → H X → Type ℓ₀)
(α : EquivAction H) (τ : TransportStr α)
(ι : StrEquiv S ℓ₂') (θ : UnivalentStr S ι)
{X Y : Type ℓ} {s : S X} {t : S Y}
(e : (X , s) ≃[ ι ] (Y , t))
→ (h : H Y) → P X s (invEq (α (e .fst)) h) → P Y t h
transfer P α τ ι θ {X} {Y} {s} {t} e h =
subst (λ {(Z , u , h) → P Z u h})
(sip
(productUnivalentStr ι θ (EquivAction→StrEquiv α) (TransportStr→UnivalentStr α τ))
(X , s , invEq (α (e .fst)) h)
(Y , t , h)
(e .fst , e .snd , retEq (α (e .fst)) h))
transfer⁻ : {ℓ₂' ℓ₀ : Level} {S : Type ℓ → Type ℓ₁} {H : Type ℓ → Type ℓ₂}
(P : ∀ X → S X → H X → Type ℓ₀)
(α : EquivAction H) (τ : TransportStr α)
(ι : StrEquiv S ℓ₂') (θ : UnivalentStr S ι)
{X Y : Type ℓ} {s : S X} {t : S Y}
(e : (X , s) ≃[ ι ] (Y , t))
→ (h : H X) → P Y t (equivFun (α (e .fst)) h) → P X s h
transfer⁻ P α τ ι θ {X} {Y} {s} {t} e h =
subst⁻ (λ {(Z , u , h) → P Z u h})
(sip
(productUnivalentStr ι θ (EquivAction→StrEquiv α) (TransportStr→UnivalentStr α τ))
(X , s , h)
(Y , t , equivFun (α (e .fst)) h)
(e .fst , e .snd , refl))
| 33.3125
| 89
| 0.555972
|
313615c0c4915d4a4f774b3bca9232b022c84c86
| 1,882
|
agda
|
Agda
|
src/Data/Real/Properties.agda
|
cspollard/reals
|
a193aeebf1326f960975b19d3e31b46fddbbfaa2
|
[
"CC0-1.0"
] | null | null | null |
src/Data/Real/Properties.agda
|
cspollard/reals
|
a193aeebf1326f960975b19d3e31b46fddbbfaa2
|
[
"CC0-1.0"
] | null | null | null |
src/Data/Real/Properties.agda
|
cspollard/reals
|
a193aeebf1326f960975b19d3e31b46fddbbfaa2
|
[
"CC0-1.0"
] | null | null | null |
module Data.Real.Properties where
open import Data.Real.Base as ℝ
open import Data.Real.Order
open import Data.Real.Abstract.Structures
using (IsOrderedHeytingField; IsArchimedanHeytingField)
open import Assume
open import Algebra using (IsCommutativeRing; CommutativeRing)
open import Algebra.Module using (Module)
open import Algebra.Module.Construct.TensorUnit using (⟨module⟩)
open import Algebra.Module.Normed using (IsNormedModule; NormedModule)
open import Algebra.Apartness using (IsHeytingField; HeytingField)
open import Level using (0ℓ)
open import Data.Product using (_,_)
+-*-isCommutativeRing : IsCommutativeRing _≈_ _+_ _*_ -_ 0.0 1.0
+-*-isCommutativeRing = assume
+-*-commutativeRing : CommutativeRing 0ℓ 0ℓ
+-*-commutativeRing = record { isCommutativeRing = +-*-isCommutativeRing }
+-*-module : Module +-*-commutativeRing 0ℓ 0ℓ
+-*-module = ⟨module⟩
+-*-isHeytingField : IsHeytingField _≈_ _≉_ _+_ _*_ -_ 0.0 1.0
+-*-isHeytingField = assume
+-*-heytingField : HeytingField 0ℓ 0ℓ 0ℓ
+-*-heytingField = record { isHeytingField = +-*-isHeytingField }
+-*-isOrderedHeytingField : IsOrderedHeytingField +-*-heytingField _<_
+-*-isOrderedHeytingField =
record
{ isStrictTotalOrder = <-isStrictTotalOrder
; ordered = assume
}
+-*-isArchimedanHeytingField : IsArchimedanHeytingField +-*-heytingField _<_
+-*-isArchimedanHeytingField =
record
{ dense = λ a b a<b → ((a + b) ÷ 2.0) , assume
; archimedan = λ a b a<0 b<0 → ∣ unsafeM ⌈ b ÷ a ⌉ ∣ , assume
}
where
open import Data.Integer using (∣_∣)
open import Data.Maybe
unsafeM : ∀ {a} {A : Set a} → Maybe A → A
unsafeM (just x) = x
unsafeM nothing = assume
abs-isNormedModule : IsNormedModule +-*-module _≤_ abs
abs-isNormedModule = assume
abs-normedModule : NormedModule +-*-commutativeRing _≤_ 0ℓ 0ℓ
abs-normedModule = record { isNormedModule = abs-isNormedModule }
| 32.448276
| 76
| 0.727418
|
4dba1b778b155dca3d1ffb370adc9d4780dc60c2
| 2,002
|
agda
|
Agda
|
examples/AIM6/HelloAgda/Datatypes.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
examples/AIM6/HelloAgda/Datatypes.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
examples/AIM6/HelloAgda/Datatypes.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
{-
Agda Implementors' Meeting VI
Göteborg
May 24 - 30, 2007
Hello Agda!
Ulf Norell
-}
-- This is where the fun begins.
-- Unleashing datatypes, pattern matching and recursion.
module Datatypes where
{-
Simple datatypes.
-}
-- Now which datatype should we start with...?
data Nat : Set where
zero : Nat
suc : Nat -> Nat
-- Let's start simple.
pred : Nat -> Nat
pred zero = zero
pred (suc n) = n
-- Now let's do recursion.
_+_ : Nat -> Nat -> Nat
zero + m = m
suc n + m = suc (n + m)
-- An aside on infix operators:
-- Any name containing _ can be used as a mixfix operator.
-- The arguments simply go in place of the _. For instance:
data Bool : Set where
true : Bool
false : Bool
if_then_else_ : {A : Set} -> Bool -> A -> A -> A
if true then x else y = x
if false then x else y = y
-- To declare the associativity and precedence of an operator
-- we write. In this case we need parenthesis around the else branch
-- if its precedence is lower than 10. For the condition and the then
-- branch we only need parenthesis for things like λs.
infix 10 if_then_else_
{-
Parameterised datatypes
-}
data List (A : Set) : Set where
[] : List A
_::_ : A -> List A -> List A
infixr 50 _::_
-- The parameters are implicit arguments to the constructors.
nil : (A : Set) -> List A
nil A = [] {A}
map : {A B : Set} -> (A -> B) -> List A -> List B
map f [] = []
map f (x :: xs) = f x :: map f xs
{-
Empty datatypes
-}
-- A very useful guy is the empty datatype.
data False : Set where
-- When pattern matching on an element of an empty type, something
-- interesting happens:
elim-False : {A : Set} -> False -> A
elim-False () -- Look Ma, no right hand side!
-- The pattern () is called an absurd pattern and matches elements
-- of an empty type.
{-
What's next?
-}
-- Fun as they are, eventually you'll get bored with
-- inductive datatypes.
-- Move on to: Families.agda
| 18.537037
| 69
| 0.624376
|
4a966495072dadfb6318540ee3912379ca515496
| 11,358
|
agda
|
Agda
|
04-cubical-type-theory/material/Part4.agda
|
HoTT/EPIT-2020
|
0502db788d6d2b3950e44f362cdb7d4da3ebce82
|
[
"MIT"
] | 97
|
2021-03-19T14:13:37.000Z
|
2022-03-15T13:58:25.000Z
|
04-cubical-type-theory/material/Part4.agda
|
HoTT/EPIT-2020
|
0502db788d6d2b3950e44f362cdb7d4da3ebce82
|
[
"MIT"
] | 2
|
2021-03-31T18:27:23.000Z
|
2021-04-13T09:03:56.000Z
|
04-cubical-type-theory/material/Part4.agda
|
HoTT/EPIT-2020
|
0502db788d6d2b3950e44f362cdb7d4da3ebce82
|
[
"MIT"
] | 14
|
2021-03-19T12:36:53.000Z
|
2022-03-22T19:37:21.000Z
|
{-
Part 4: Higher inductive types
• Set quotients via HITs
• Propositional truncation
• A little synthetic homotopy theory
-}
{-# OPTIONS --cubical #-}
module Part4 where
open import Cubical.Foundations.Isomorphism
open import Cubical.Data.Int hiding (_+_)
open import Cubical.Data.Nat hiding (elim)
open import Cubical.Data.Prod hiding (map)
open import Part1
open import Part2
open import Part3
-- Another thing that Cubical Agda adds is the possibility to define
-- higher inductive types. These are just like normal Agda datatypes,
-- but they have also "higher" constructors specifying non-trivial
-- paths, square, cubes, etc. in the type. These give a nice way of
-- defining set quotiented types as well as higher dimensional types
-- quotiented by some arbitrary relation.
-- Let's start by looking at some set quotient examples. The following
-- definition of finite multisets is due to Vikraman Choudhury and
-- Marcelo Fiore.
infixr 5 _∷_
data FMSet (A : Type ℓ) : Type ℓ where
[] : FMSet A
_∷_ : (x : A) → (xs : FMSet A) → FMSet A
comm : (x y : A) (xs : FMSet A) → x ∷ y ∷ xs ≡ y ∷ x ∷ xs
trunc : (xs ys : FMSet A) (p q : xs ≡ ys) → p ≡ q
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) (λ k → p k ++ ys) (λ k → q k ++ ys) i j
unitl-++ : (xs : FMSet A) → [] ++ xs ≡ xs
unitl-++ xs = refl
unitr-++ : (xs : FMSet A) → xs ++ [] ≡ xs
unitr-++ [] = refl
unitr-++ (x ∷ xs) = cong (x ∷_) (unitr-++ xs)
unitr-++ (comm x y xs i) j = comm x y (unitr-++ xs j) i
unitr-++ (trunc xs ys p q i k) j =
trunc (unitr-++ xs j) (unitr-++ ys j)
(λ k → unitr-++ (p k) j) (λ k → unitr-++ (q k) j) i k
-- Filling the goals for comm and trunc quickly gets tiresome and
-- useful lemmas about eliminating into propositions are proved in
-- Cubical.HITs.FiniteMultiset. As we're proving an equality of a set
-- truncated type we can prove the trunc and comm cases once and for
-- all so that we only have to give cases for [] and _∷_ when
-- constructing a family of propositions. This is a very common
-- pattern when working with set truncated HITs: first define the HIT,
-- then prove special purpose recursors and eliminators for
-- eliminating into types of different h-levels. All definitions are
-- then written using these recursors and eliminators and one get very
-- short proofs.
-- A more efficient version of finite multisets based on association
-- lists can be found in Cubical.HITs.AssocList.Base. It looks like
-- this:
data AssocList (A : Type ℓ) : Type ℓ where
⟨⟩ : AssocList A
⟨_,_⟩∷_ : (a : A) (n : ℕ) (xs : AssocList A) → AssocList A
per : (a b : A) (m n : ℕ) (xs : AssocList A)
→ ⟨ a , m ⟩∷ ⟨ b , n ⟩∷ xs ≡ ⟨ b , n ⟩∷ ⟨ a , m ⟩∷ xs
agg : (a : A) (m n : ℕ) (xs : AssocList A)
→ ⟨ a , m ⟩∷ ⟨ a , n ⟩∷ xs ≡ ⟨ a , m + n ⟩∷ xs
del : (a : A) (xs : AssocList A) → ⟨ a , 0 ⟩∷ xs ≡ xs
trunc : (xs ys : AssocList A) (p q : xs ≡ ys) → p ≡ q
-- Programming and proving is more complicated with AssocList compared
-- to FMSet. This kind of example occurs everywhere in programming and
-- mathematics: one representation is easier to work with, but not
-- efficient, while another is efficient but difficult to work with.
-- Using the SIP we can get the best of both worlds (see
-- https://arxiv.org/abs/2009.05547 for details).
-- Another nice CS example of a HIT can be found in Cubical.Data.Queue
-- where we define a queue datastructure based on two lists. These
-- examples are all special cases of set quotients and are very useful
-- for programming and set level mathematics. We can define the
-- general form as:
data _/_ (A : Type ℓ) (R : A → A → Type ℓ') : Type (ℓ-max ℓ ℓ') where
[_] : A → A / R
eq/ : (a b : A) → R a b → [ a ] ≡ [ b ]
trunc : (a b : A / R) (p q : a ≡ b) → p ≡ q
-- It's sometimes easier to work directly with _/_ instead of defining
-- special HITs as one can reuse lemmas for _/_ instead of reproving
-- things. For example, general lemmas about eliminating into
-- propositions have already been proved for _/_.
-- Proving that _/_ is "effective" (for prop-valued relation), i.e. that
--
-- ((a b : A) → [ a ] ≡ [ b ] → R a b)
--
-- requires univalence for propositions (hPropExt).
-- Set quotients let us define things like in normal math:
ℤ' : Type₀
ℤ' = (ℕ × ℕ) / rel
where
rel : (ℕ × ℕ) → (ℕ × ℕ) → Type₀
rel (x₀ , y₀) (x₁ , y₁) = x₀ + y₁ ≡ x₁ + y₀
-- Another useful class of HITs are truncations, especially
-- propositional truncation:
data ∥_∥ (A : Type ℓ) : Type ℓ where
∣_∣ : A → ∥ A ∥
squash : ∀ (x y : ∥ A ∥) → x ≡ y
-- This lets us define mere existence:
∃ : ∀ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') → Type (ℓ-max ℓ ℓ')
∃ A B = ∥ Σ A B ∥
-- This is very useful to specify things where existence is weaker
-- than Σ. This lets us define things like surjective functions or the
-- image of a map which we cannot define properly in pre-HoTT type
-- theory.
-- We can define the recursor by pattern-matching
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
-- And the eliminator then follows easily:
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 → transport (λ i → P (squash ∣ x ∣ a i)) (f x)) a
-- A very important point is that propositional truncation is proof
-- relevant, so even though the elements are all equal one can still
-- extract interesting information from them. A fun example is the
-- "cost monad" which can be found in Cubical.HITs.Cost. There we pair
-- A with ∥ ℕ ∥ and use the truncated number to count the number of
-- recursive calls in various functions. As the number is truncated it
-- doesn't affect any properties of the functions, but by running
-- concrete computations we can extract the number of calls.
-------------------------------------------------------------------------
-- Another source of HITs are inspired by topology
-- We can define the circle as the following simple data declaration:
data S¹ : Type₀ where
base : S¹
loop : base ≡ base
-- We can write functions on S¹ using pattern-matching:
double : S¹ → S¹
double base = base
double (loop i) = (loop ∙ loop) i
-- Note that loop takes an i : I argument. This is not very surprising
-- as it's a path base ≡ base, but it's an important difference to
-- HoTT. Having the native notion of equality be heterogeneous makes
-- it possible to quite directly define a general schema for a large
-- class of HITs (more or less all in the HoTT book, with the
-- exception for the Cauchy reals (I think?)).
-- Let's use univalence to compute some winding numbers on the
-- circle. We first define a family of types over the circle whos
-- fibers are the integers.
helix : S¹ → Type₀
helix base = ℤ
helix (loop i) = sucPath i
-- The loopspace of the circle
ΩS¹ : Type₀
ΩS¹ = base ≡ base
-- We can then define a function computing how many times we've looped
-- around the circle by:
winding : ΩS¹ → ℤ
winding p = subst helix p (pos 0)
-- This reduces just fine:
_ : winding (λ i → double ((loop ∙ loop) i)) ≡ pos 4
_ = refl
-- This would not reduce in HoTT as univalence is an axiom. Having
-- things compute makes it possible to substantially simplify many
-- proofs from HoTT in Cubical Agda, more about this later.
-- We can in fact prove that winding is an equivalence, this relies on
-- the encode-decode method and Egbert will go through the proof in
-- detail. For details about how this proof looks in Cubical Agda see:
--
-- Cubical.HITs.S1.Base
-- Complex multiplication on S¹, used in the Hopf fibration
_⋆_ : S¹ → S¹ → S¹
base ⋆ x = x
loop i ⋆ base = loop i
loop i ⋆ loop j =
hcomp (λ k → λ { (i = i0) → loop (j ∨ ~ k)
; (i = i1) → loop (j ∧ k)
; (j = i0) → loop (i ∨ ~ k)
; (j = i1) → loop (i ∧ k) })
base
-- We can define the Torus as:
data Torus : Type₀ where
point : Torus
line1 : point ≡ point
line2 : point ≡ point
square : PathP (λ i → line1 i ≡ line1 i) line2 line2
-- The square corresponds to the usual folding diagram from topology:
--
-- line1
-- p ----------> p
-- ^ ^
-- ¦ ¦
-- line2 ¦ ¦ line2
-- ¦ ¦
-- p ----------> p
-- line1
-- Proving that it is equivalent to two circles is pretty much trivial:
t2c : Torus → S¹ × S¹
t2c point = (base , base)
t2c (line1 i) = (loop i , base)
t2c (line2 j) = (base , loop j)
t2c (square i j) = (loop i , loop j)
c2t : S¹ × S¹ → Torus
c2t (base , base) = point
c2t (loop i , base) = line1 i
c2t (base , loop j) = line2 j
c2t (loop i , loop j) = square i j
c2t-t2c : (t : Torus) → c2t (t2c t) ≡ t
c2t-t2c point = refl
c2t-t2c (line1 _) = refl
c2t-t2c (line2 _) = refl
c2t-t2c (square _ _) = refl
t2c-c2t : (p : S¹ × S¹) → t2c (c2t p) ≡ p
t2c-c2t (base , base) = refl
t2c-c2t (base , loop _) = refl
t2c-c2t (loop _ , base) = refl
t2c-c2t (loop _ , loop _) = refl
-- Using univalence we get the following equality:
Torus≡S¹×S¹ : Torus ≡ S¹ × S¹
Torus≡S¹×S¹ = isoToPath (iso t2c c2t t2c-c2t c2t-t2c)
-- We can also directly compute winding numbers on the torus
windingTorus : point ≡ point → ℤ × ℤ
windingTorus l = ( winding (λ i → proj₁ (t2c (l i)))
, winding (λ i → proj₂ (t2c (l i))))
_ : windingTorus (line1 ∙ sym line2) ≡ (pos 1 , negsuc 0)
_ = refl
-- This proof turned out to be much more complicated in HoTT as
-- eliminators out of HITs don't compute definitionally for higher
-- constructors. In Cubical Agda this is not a problem as all cases
-- reduce definitionally.
-- We have many more topological examples in the library, including
-- Klein bottle, RP^n, higher spheres, suspensions, join, wedges,
-- smash product:
-- open import Cubical.HITs.KleinBottle
-- open import Cubical.HITs.RPn
-- open import Cubical.HITs.S2
-- open import Cubical.HITs.S3
-- open import Cubical.HITs.Susp
-- open import Cubical.HITs.Join
-- open import Cubical.HITs.Wedge
-- open import Cubical.HITs.SmashProduct
-- There's also a proof of the "3x3 lemma" for pushouts in less than
-- 200LOC. In HoTT-Agda this took about 3000LOC. For details see:
-- https://github.com/HoTT/HoTT-Agda/tree/master/theorems/homotopy/3x3
-- open import Cubical.HITs.Pushout
-- We also defined the Hopf fibration and proved that its total space
-- is S³ in about 300LOC:
-- open import Cubical.HITs.Hopf
-- There is also some integer cohomology:
-- open import Cubical.ZCohomology.Everything
-- To compute cohomology groups of various spaces we need a bunch of
-- interesting theorems: Freudenthal suspension theorem,
-- Mayer-Vietoris sequence...
-- For further references about doing synthetic algebraic topology in
-- Cubical Agda see:
-- Cubical Synthetic Homotopy Theory
-- Anders Mörtberg, Loïc Pujet
-- https://staff.math.su.se/anders.mortberg/papers/cubicalsynthetic.pdf
-- Synthetic Cohomology Theory in Cubical Agda
-- Guillaume Brunerie, Anders Mörtberg, Axel Ljungström.
-- https://staff.math.su.se/anders.mortberg/papers/zcohomology.pdf
--- The end! ---
| 34.840491
| 73
| 0.647913
|
fbb4c9e8cba9d4a3c1e71cff9c756bfc823e5c51
| 2,228
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Function/Injection.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/Function/Injection.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Function/Injection.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Injections
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Function.Injection where
open import Function as Fun using () renaming (_∘_ to _⟨∘⟩_)
open import Level
open import Relation.Binary
open import Function.Equality as F
using (_⟶_; _⟨$⟩_ ; Π) renaming (_∘_ to _⟪∘⟫_)
open import Relation.Binary.PropositionalEquality as P using (_≡_)
------------------------------------------------------------------------
-- Injective functions
Injective : ∀ {a₁ a₂ b₁ b₂} {A : Setoid a₁ a₂} {B : Setoid b₁ b₂} →
A ⟶ B → Set _
Injective {A = A} {B} f = ∀ {x y} → f ⟨$⟩ x ≈₂ f ⟨$⟩ y → x ≈₁ y
where
open Setoid A renaming (_≈_ to _≈₁_)
open Setoid B renaming (_≈_ to _≈₂_)
------------------------------------------------------------------------
-- The set of all injections between two setoids
record Injection {f₁ f₂ t₁ t₂}
(From : Setoid f₁ f₂) (To : Setoid t₁ t₂) :
Set (f₁ ⊔ f₂ ⊔ t₁ ⊔ t₂) where
field
to : From ⟶ To
injective : Injective to
open Π to public
------------------------------------------------------------------------
-- The set of all injections from one set to another (i.e. injections
-- with propositional equality)
infix 3 _↣_
_↣_ : ∀ {f t} → Set f → Set t → Set _
From ↣ To = Injection (P.setoid From) (P.setoid To)
injection : ∀ {f t} {From : Set f} {To : Set t} → (to : From → To) →
(∀ {x y} → to x ≡ to y → x ≡ y) → From ↣ To
injection to injective = record
{ to = P.→-to-⟶ to
; injective = injective
}
------------------------------------------------------------------------
-- Identity and composition.
infixr 9 _∘_
id : ∀ {s₁ s₂} {S : Setoid s₁ s₂} → Injection S S
id = record
{ to = F.id
; injective = Fun.id
}
_∘_ : ∀ {f₁ f₂ m₁ m₂ t₁ t₂}
{F : Setoid f₁ f₂} {M : Setoid m₁ m₂} {T : Setoid t₁ t₂} →
Injection M T → Injection F M → Injection F T
f ∘ g = record
{ to = to f ⟪∘⟫ to g
; injective = (λ {_} → injective g) ⟨∘⟩ injective f
} where open Injection
| 30.108108
| 72
| 0.460952
|
a1a865a7319f6a4f09f4cbf6bfc1de75dce829b0
| 1,244
|
agda
|
Agda
|
src/Categories/Examples/Functor/Sets.agda
|
bond15/categories-examples
|
adfa1dee4f27286a2943863d7a0302e6ba26fffd
|
[
"MIT"
] | null | null | null |
src/Categories/Examples/Functor/Sets.agda
|
bond15/categories-examples
|
adfa1dee4f27286a2943863d7a0302e6ba26fffd
|
[
"MIT"
] | null | null | null |
src/Categories/Examples/Functor/Sets.agda
|
bond15/categories-examples
|
adfa1dee4f27286a2943863d7a0302e6ba26fffd
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --safe --without-K #-}
module Categories.Examples.Functor.Sets where
import Data.List as List
import Data.List.Properties
open import Data.Nat using (ℕ)
import Data.Product as Product
import Data.Vec as Vec
import Data.Vec.Properties
open import Function using (id; λ-; _$-)
open import Relation.Binary.PropositionalEquality using (refl)
open import Categories.Category.Discrete using (Discrete)
open import Categories.Category.Instance.Sets
open import Categories.Functor using (Endofunctor)
open import Categories.Functor.Bifunctor using (Bifunctor; appʳ)
List : ∀ {o} → Endofunctor (Sets o)
List = record
{ F₀ = List.List
; F₁ = List.map
; identity = map-id $-
; homomorphism = map-compose $-
; F-resp-≈ = λ f≈g → map-cong (λ- f≈g) $-
}
where
open Data.List.Properties
Vec′ : ∀ {o} → Bifunctor (Sets o) (Discrete ℕ) (Sets o)
Vec′ = record
{ F₀ = Product.uncurry Vec.Vec
; F₁ = λ { (f , refl) → Vec.map f }
; identity = map-id $-
; homomorphism = λ { {_} {_} {_} {f , refl} {g , refl} → map-∘ g f _}
; F-resp-≈ = λ { {_} {_} {_} {_ , refl} (g , refl) → map-cong (λ- g) _}
}
where
open Product using (_,_)
open Data.Vec.Properties
Vec : ∀ {o} → ℕ → Endofunctor (Sets o)
Vec = appʳ Vec′
| 28.930233
| 73
| 0.656752
|
5033e93236024db121737029deab4ae6eb93ef3b
| 85
|
agda
|
Agda
|
test/Fail/Sections-15.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Sections-15.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Sections-15.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
open import Common.Prelude
test : Bool → Nat
test = if_then 4 Common.Prelude.else 5
| 17
| 38
| 0.752941
|
cb7b1e8b90a7b2dd7ab0cbe9420322a6ddb0166d
| 3,913
|
agda
|
Agda
|
test/succeed/builtin.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2019-11-27T04:41:05.000Z
|
2019-11-27T04:41:05.000Z
|
test/succeed/builtin.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/succeed/builtin.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
module builtin where
data Bool : Set where
false : Bool
true : Bool
not : Bool -> Bool
not true = false
not false = true
_||_ : Bool -> Bool -> Bool
true || _ = true
false || x = x
_&&_ : Bool -> Bool -> Bool
true && x = x
false && _ = false
{-# BUILTIN BOOL Bool #-}
{-# BUILTIN TRUE true #-}
{-# BUILTIN FALSE false #-}
data Nat : Set where
zero : Nat
suc : Nat -> Nat
{-# BUILTIN NATURAL Nat #-}
{-# BUILTIN SUC suc #-}
{-# BUILTIN ZERO zero #-}
postulate
Int : Set
String : Set
Float : Set
Char : Set
{-# BUILTIN INTEGER Int #-}
{-# BUILTIN STRING String #-}
{-# BUILTIN FLOAT Float #-}
{-# BUILTIN CHAR Char #-}
infixr 10 _::_
data List (A : Set) : Set where
nil : List A
_::_ : A -> List A -> List A
{-# BUILTIN LIST List #-}
{-# BUILTIN NIL nil #-}
{-# BUILTIN CONS _::_ #-}
primitive
-- Integer functions
primIntegerPlus : Int -> Int -> Int
primIntegerMinus : Int -> Int -> Int
primIntegerTimes : Int -> Int -> Int
primIntegerDiv : Int -> Int -> Int
primIntegerMod : Int -> Int -> Int
primIntegerEquality : Int -> Int -> Bool
primIntegerLess : Int -> Int -> Bool
primNatToInteger : Nat -> Int
primShowInteger : Int -> String
-- Floating point functions
primIntegerToFloat : Int -> Float
primFloatPlus : Float -> Float -> Float
primFloatMinus : Float -> Float -> Float
primFloatTimes : Float -> Float -> Float
primFloatDiv : Float -> Float -> Float
primFloatLess : Float -> Float -> Bool
primRound : Float -> Int
primFloor : Float -> Int
primCeiling : Float -> Int
primExp : Float -> Float
primLog : Float -> Float
primSin : Float -> Float
primShowFloat : Float -> String
-- Character functions
primCharEquality : Char -> Char -> Bool
primIsLower : Char -> Bool
primIsDigit : Char -> Bool
primIsAlpha : Char -> Bool
primIsSpace : Char -> Bool
primIsAscii : Char -> Bool
primIsLatin1 : Char -> Bool
primIsPrint : Char -> Bool
primIsHexDigit : Char -> Bool
primToUpper : Char -> Char
primToLower : Char -> Char
primCharToNat : Char -> Nat
primNatToChar : Nat -> Char -- partial
primShowChar : Char -> String
-- String functions
primStringToList : String -> List Char
primStringFromList : List Char -> String
primStringAppend : String -> String -> String
primStringEquality : String -> String -> Bool
primShowString : String -> String
isLower : Char -> Bool
isLower = primIsLower
isAlpha : Char -> Bool
isAlpha = primIsAlpha
isUpper : Char -> Bool
isUpper c = isAlpha c && not (isLower c)
infixl 14 _*_ _/_
infix 12 -_
infixl 12 _+_ _-_
infixl 8 _==_
nat0 = primCharToNat '\0'
int0 = primNatToInteger nat0
_+_ = primIntegerPlus
_*_ = primIntegerTimes
_-_ = primIntegerMinus
-_ = \(x : Int) -> int0 - x
_==_ = primIntegerEquality
_/_ = primFloatDiv
pi = 3.141592653589793
sin = primSin
cos : Float -> Float
cos x = sin (primFloatMinus (pi / 2.0) x)
tan : Float -> Float
tan x = sin x / cos x
reverse : {A : Set} -> List A -> List A
reverse xs = rev xs nil
where
rev : {A : Set} -> List A -> List A -> List A
rev nil ys = ys
rev (x :: xs) ys = rev xs (x :: ys)
infixr 20 _∘_
_∘_ : {A B C : Set} -> (B -> C) -> (A -> B) -> A -> C
f ∘ g = \x -> f (g x)
map : {A B : Set} -> (A -> B) -> List A -> List B
map f nil = nil
map f (x :: xs) = f x :: map f xs
stringAsList : (List Char -> List Char) -> String -> String
stringAsList f = primStringFromList ∘ f ∘ primStringToList
revStr : String -> String
revStr = stringAsList reverse
mapStr : (Char -> Char) -> String -> String
mapStr f = stringAsList (map f)
-- Testing unicode literals
uString = "åäö⊢ξ∀"
uChar = '∀'
| 23.859756
| 59
| 0.581395
|
1c22c798621cd2a0da031aad2e8ba3d770fb73cd
| 6,107
|
agda
|
Agda
|
fracGC/BackwardsEval.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 14
|
2015-08-18T21:40:15.000Z
|
2021-05-05T01:07:57.000Z
|
fracGC/BackwardsEval.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 4
|
2018-06-07T16:27:41.000Z
|
2021-10-29T20:41:23.000Z
|
fracGC/BackwardsEval.agda
|
JacquesCarette/pi-dual
|
003835484facfde0b770bc2b3d781b42b76184c1
|
[
"BSD-2-Clause"
] | 3
|
2016-05-29T01:56:33.000Z
|
2019-09-10T09:47:13.000Z
|
{-# OPTIONS --without-K --safe #-}
-- Backwards evaluator and the fact that with eval, forms a reversible evaluator
module BackwardsEval where
open import Data.Unit using (tt)
open import Data.Sum using (inj₁; inj₂)
open import Data.Product using (_,_; proj₁; proj₂)
open import Relation.Binary.PropositionalEquality
using (_≡_; refl; sym; trans; cong; cong₂; subst)
open import Singleton
open import PiFrac
bwd : {A B : 𝕌} → (A ⟷ B) → ⟦ B ⟧ → ⟦ A ⟧
bwd-eval : {A B : 𝕌} → (c : A ⟷ B) → (v : ⟦ A ⟧) → bwd c (eval c v) ≡ v
bwd unite₊l v = inj₂ v
bwd uniti₊l (inj₂ v) = v
bwd unite₊r v = inj₁ v
bwd uniti₊r (inj₁ v) = v
bwd swap₊ (inj₁ v) = inj₂ v
bwd swap₊ (inj₂ v) = inj₁ v
bwd assocl₊ (inj₁ (inj₁ v)) = inj₁ v
bwd assocl₊ (inj₁ (inj₂ v)) = inj₂ (inj₁ v)
bwd assocl₊ (inj₂ v) = inj₂ (inj₂ v)
bwd assocr₊ (inj₁ v) = inj₁ (inj₁ v)
bwd assocr₊ (inj₂ (inj₁ v)) = inj₁ (inj₂ v)
bwd assocr₊ (inj₂ (inj₂ v)) = inj₂ v
bwd unite⋆l v = (tt , v)
bwd uniti⋆l (tt , v) = v
bwd unite⋆r v = (v , tt)
bwd uniti⋆r (v , tt) = v
bwd swap⋆ (v₁ , v₂) = (v₂ , v₁)
bwd assocl⋆ ((v₁ , v₂) , v₃) = (v₁ , (v₂ , v₃))
bwd assocr⋆ (v₁ , (v₂ , v₃)) = ((v₁ , v₂) , v₃)
bwd dist (inj₁ (v₁ , v₂)) = (inj₁ v₁ , v₂)
bwd dist (inj₂ (v₂ , v₃)) = (inj₂ v₂ , v₃)
bwd factor (inj₁ v₁ , v₃) = inj₁ (v₁ , v₃)
bwd factor (inj₂ v₂ , v₃) = inj₂ (v₂ , v₃)
bwd distl (inj₁ (v₁ , v₂)) = (v₁ , inj₁ v₂)
bwd distl (inj₂ (v₁ , v₃)) = (v₁ , inj₂ v₃)
bwd factorl (v₁ , inj₁ v₂) = inj₁ (v₁ , v₂)
bwd factorl (v₁ , inj₂ v₃) = inj₂ (v₁ , v₃)
bwd id⟷ v = v
bwd (c₁ ⊚ c₂) v = bwd c₁ (bwd c₂ v)
bwd (c₁ ⊕ c₂) (inj₁ v) = inj₁ (bwd c₁ v)
bwd (c₁ ⊕ c₂) (inj₂ v) = inj₂ (bwd c₂ v)
bwd (c₁ ⊗ c₂) (v₁ , v₂) = (bwd c₁ v₁ , bwd c₂ v₂)
bwd (lift {_} {_} {v₁} c) (●₁ , v≡●₁) = (bwd c ●₁) , (trans (sym (bwd-eval c v₁)) (cong (bwd c) v≡●₁))
bwd tensorl ((w₁ , p₁) , (w₂ , p₂)) = (w₁ , w₂) , (cong₂ _,_ p₁ p₂)
bwd tensorr ((v₁ , v₂) , p) = (v₁ , cong proj₁ p) , (v₂ , cong proj₂ p)
bwd plusll (w , p) = (inj₁ w) , (cong inj₁ p)
bwd pluslr (inj₁ w₁ , refl) = w₁ , refl
bwd plusrl (w , p) = (inj₂ w) , (cong inj₂ p)
bwd plusrr (inj₂ w₂ , refl) = w₂ , refl
bwd fracl (f₁ , f₂) ((w₁ , w₂) , refl) = let _ = f₁ (w₁ , refl) ; _ = f₂ (w₂ , refl) in tt
bwd (fracr {v₁ = v₁} {v₂ = v₂}) f = (λ _ → f ((v₁ , v₂) , refl)) , (λ _ → f ((v₁ , v₂) , refl))
bwd (η v) p = tt
bwd (ε v) tt = (v , refl) , λ _ → tt
bwd (ll {t} {v} {w}) (v , refl) = w , refl
bwd (== c eq) v = bwd c (subst (Singleton ⟦ _ ⟧) (sym eq) v)
bwd-eval unite₊l (inj₂ v) = refl
bwd-eval uniti₊l v = refl
bwd-eval unite₊r (inj₁ v) = refl
bwd-eval uniti₊r v = refl
bwd-eval swap₊ (inj₁ v) = refl
bwd-eval swap₊ (inj₂ v) = refl
bwd-eval assocl₊ (inj₁ v) = refl
bwd-eval assocl₊ (inj₂ (inj₁ v)) = refl
bwd-eval assocl₊ (inj₂ (inj₂ v)) = refl
bwd-eval assocr₊ (inj₁ (inj₁ v)) = refl
bwd-eval assocr₊ (inj₁ (inj₂ v)) = refl
bwd-eval assocr₊ (inj₂ v) = refl
bwd-eval unite⋆l (tt , v) = refl
bwd-eval uniti⋆l v = refl
bwd-eval unite⋆r (v , tt) = refl
bwd-eval uniti⋆r v = refl
bwd-eval swap⋆ (v₁ , v₂) = refl
bwd-eval assocl⋆ (v₁ , (v₂ , v₃)) = refl
bwd-eval assocr⋆ ((v₁ , v₂) , v₃) = refl
bwd-eval dist (inj₁ v₁ , v₃) = refl
bwd-eval dist (inj₂ v₂ , v₃) = refl
bwd-eval factor (inj₁ (v₁ , v₃)) = refl
bwd-eval factor (inj₂ (v₂ , v₃)) = refl
bwd-eval distl (v₁ , inj₁ v₂) = refl
bwd-eval distl (v₁ , inj₂ v₃) = refl
bwd-eval factorl (inj₁ (v₁ , v₂)) = refl
bwd-eval factorl (inj₂ (v₁ , v₃)) = refl
bwd-eval id⟷ v = refl
bwd-eval (c₁ ⊚ c₂) v = trans (cong (bwd c₁) (bwd-eval c₂ (eval c₁ v))) (bwd-eval c₁ v)
bwd-eval (c₁ ⊕ c₂) (inj₁ v₁) = cong inj₁ (bwd-eval c₁ v₁)
bwd-eval (c₁ ⊕ c₂) (inj₂ v₂) = cong inj₂ (bwd-eval c₂ v₂)
bwd-eval (c₁ ⊗ c₂) (v₁ , v₂) = cong₂ _,_ (bwd-eval c₁ v₁) (bwd-eval c₂ v₂)
bwd-eval (lift c) v = pointed-all-paths
bwd-eval tensorl p = pointed-all-paths
bwd-eval tensorr (p₁ , p₂) = cong₂ _,_ pointed-all-paths pointed-all-paths
bwd-eval plusll p = pointed-all-paths
bwd-eval pluslr p = pointed-all-paths
bwd-eval plusrl p = pointed-all-paths
bwd-eval plusrr p = pointed-all-paths
bwd-eval fracl f = {!!} -- needs recip-all-paths
bwd-eval fracr (f₁ , f₂) = {!!}
bwd-eval (η v) tt = refl
bwd-eval (ε v) (p , r) = cong₂ _,_ pointed-all-paths refl
bwd-eval (ll {t} {v} {.w}) (w , refl) = refl
bwd-eval (== c eq) p = pointed-all-paths
eval-bwd : {A B : 𝕌} → (c : A ⟷ B) → (v : ⟦ B ⟧) → eval c (bwd c v) ≡ v
eval-bwd unite₊l v = refl
eval-bwd uniti₊l (inj₂ v) = refl
eval-bwd unite₊r v = refl
eval-bwd uniti₊r (inj₁ v) = refl
eval-bwd swap₊ (inj₁ v) = refl
eval-bwd swap₊ (inj₂ v) = refl
eval-bwd assocl₊ (inj₁ (inj₁ v)) = refl
eval-bwd assocl₊ (inj₁ (inj₂ v)) = refl
eval-bwd assocl₊ (inj₂ v) = refl
eval-bwd assocr₊ (inj₁ v) = refl
eval-bwd assocr₊ (inj₂ (inj₁ v)) = refl
eval-bwd assocr₊ (inj₂ (inj₂ v)) = refl
eval-bwd unite⋆l v = refl
eval-bwd uniti⋆l (tt , v) = refl
eval-bwd unite⋆r v = refl
eval-bwd uniti⋆r (v , tt) = refl
eval-bwd swap⋆ (v₂ , v₁) = refl
eval-bwd assocl⋆ ((v₁ , v₂) , v₃) = refl
eval-bwd assocr⋆ (v₁ , (v₂ , v₃)) = refl
eval-bwd dist (inj₁ (v₁ , v₂)) = refl
eval-bwd dist (inj₂ (v₂ , v₃)) = refl
eval-bwd factor (inj₁ v₁ , v₃) = refl
eval-bwd factor (inj₂ v₂ , v₃) = refl
eval-bwd distl (inj₁ (v₁ , v₂)) = refl
eval-bwd distl (inj₂ (v₁ , v₃)) = refl
eval-bwd factorl (v₁ , inj₁ v₂) = refl
eval-bwd factorl (v₁ , inj₂ v₃) = refl
eval-bwd id⟷ v = refl
eval-bwd (c₁ ⊚ c₂) v = trans (cong (eval c₂) (eval-bwd c₁ (bwd c₂ v))) (eval-bwd c₂ v)
eval-bwd (c₁ ⊕ c₂) (inj₁ v) = cong inj₁ (eval-bwd c₁ v)
eval-bwd (c₁ ⊕ c₂) (inj₂ v) = cong inj₂ (eval-bwd c₂ v)
eval-bwd (c₁ ⊗ c₂) (v₃ , v₄) = cong₂ _,_ (eval-bwd c₁ v₃) (eval-bwd c₂ v₄)
eval-bwd (lift c) x = pointed-all-paths
eval-bwd tensorl p = cong₂ _,_ pointed-all-paths pointed-all-paths
eval-bwd tensorr p = pointed-all-paths
eval-bwd plusll p = pointed-all-paths
eval-bwd pluslr p = pointed-all-paths
eval-bwd plusrl p = pointed-all-paths
eval-bwd plusrr p = pointed-all-paths
eval-bwd fracl (f₁ , f₂) = {!!} -- needs recip-all-paths
eval-bwd fracr f = {!!}
eval-bwd (η v) (p , r) = cong₂ _,_ pointed-all-paths refl
eval-bwd (ε v) tt = refl
eval-bwd (ll {t} {.v} {w}) (v , refl) = refl
eval-bwd (== c eq) p = pointed-all-paths
| 38.898089
| 102
| 0.607663
|
dcdc65115ed4906e693a1f5eb431addbede43340
| 5,452
|
agda
|
Agda
|
test/Succeed/Issue473-1606.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Succeed/Issue473-1606.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/Issue473-1606.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | null | null | null |
-- Andreas, 2015-07-07 continuation of issue 665
-- Jesper, 2015-12-18 some of these don't work anymore with the new unifier,
-- but a few others that weren't accepted are now.
{-# OPTIONS --show-implicit #-}
-- {-# OPTIONS -v tc.with.strip:10 #-}
-- {-# OPTIONS -v tc.with.strip:60 -v tc.lhs:20 -v tc.lhs.unify:20 #-}
postulate
C : Set
anything : C
record I : Set where
constructor c
field
{f} : C
data Wrap : (i : I) → Set where
wrap : ∀ {i} → Wrap i
-- Test 0: first argument not given
test0 : ∀ {j} → Wrap j → C
test0 wrap with anything
test0 wrap | z = z
test0a : ∀ {j} → Wrap j → C
test0a (wrap {c {x}}) with anything
test0a wrap | z = z
test0b : ∀ {j} → Wrap j → C
test0b (wrap {c {_}}) with anything
test0b wrap | z = z
test0c : ∀ {j} → Wrap j → C
test0c (wrap {c}) with anything
test0c wrap | z = z
test0d : ∀ {j} → Wrap j → C
test0d (wrap {c {._}}) with anything
test0d wrap | z = z
test0e : ∀ {j} → Wrap j → C
test0e (wrap .{c}) with anything
test0e wrap | z = z
test0f : ∀ {j} → Wrap j → C
test0f (wrap .{c {_}}) with anything
test0f wrap | z = z
--test00 : ∀ {j} → Wrap j → C
--test00 wrap with anything
--test00 {.c} wrap | z = z
-- test00a : ∀ {j} → Wrap j → C
-- test00a (wrap {c {x}}) with anything
-- test00a {.c} wrap | z = z
--test00b : ∀ {j} → Wrap j → C
--test00b (wrap {c {_}}) with anything
--test00b {.c} wrap | z = z
--test00c : ∀ {j} → Wrap j → C
--test00c (wrap {c}) with anything
--test00c {.c} wrap | z = z
--test00d : ∀ {j} → Wrap j → C
--test00d (wrap {c {._}}) with anything
--test00d {.c} wrap | z = z
--test00e : ∀ {j} → Wrap j → C
--test00e (wrap .{c}) with anything
--test00e {.c} wrap | z = z
--test00f : ∀ {j} → Wrap j → C
--test00f (wrap .{c {_}}) with anything
--test00f {.c} wrap | z = z
--test000 : ∀ {j} → Wrap j → C
--test000 wrap with anything
--test000 .{c {_}} wrap | z = z
-- test000a : ∀ {j} → Wrap j → C
-- test000a (wrap {c {x}}) with anything
-- test000a .{c {_}} wrap | z = z
--test000b : ∀ {j} → Wrap j → C
--test000b (wrap {c {_}}) with anything
--test000b .{c {_}} wrap | z = z
--test000c : ∀ {j} → Wrap j → C
--test000c (wrap {c}) with anything
--test000c .{c {_}} wrap | z = z
--test000d : ∀ {j} → Wrap j → C
--test000d (wrap {c {._}}) with anything
--test000d .{c {_}} wrap | z = z
--test000e : ∀ {j} → Wrap j → C
--test000e (wrap .{c}) with anything
--test000e .{c {_}} wrap | z = z
--test000f : ∀ {j} → Wrap j → C
--test000f (wrap .{c {_}}) with anything
--test000f .{c {_}} wrap | z = z
-- Test 1: first argument is dot pattern
test1a : ∀ {j} → Wrap j → C
test1a .{c} (wrap {c {x}}) with anything
test1a .{c} wrap | z = z
test1b : ∀ {j} → Wrap j → C
test1b .{c} (wrap {c {_}}) with anything
test1b .{c} wrap | z = z
test1c : ∀ {j} → Wrap j → C
test1c .{c} (wrap {c}) with anything
test1c .{c} wrap | z = z
test11a : ∀ {j} → Wrap j → C
test11a .{c} (wrap {c {x}}) with anything
test11a wrap | z = z
test11b : ∀ {j} → Wrap j → C
test11b .{c} (wrap {c {_}}) with anything
test11b wrap | z = z
test11c : ∀ {j} → Wrap j → C
test11c .{c} (wrap {c}) with anything
test11c wrap | z = z
-- test111a : ∀ {j} → Wrap j → C
-- test111a (wrap {c {x}}) with anything
-- test111a .{c} wrap | z = z
--test111b : ∀ {j} → Wrap j → C
--test111b (wrap {c {_}}) with anything
--test111b .{c} wrap | z = z
--test111c : ∀ {j} → Wrap j → C
--test111c (wrap {c}) with anything
--test111c .{c} wrap | z = z
-- Test 2: First argument is record pattern
test2a : ∀ {j} → Wrap j → C
test2a {c} wrap with anything
test2a {c} wrap | z = z
test2b : ∀ {j} → Wrap j → C
test2b {c} wrap with anything
test2b wrap | z = z
test2c : ∀ {j} → Wrap j → C
test2c {c} (wrap {c}) with anything
test2c {c} wrap | z = z
test2d : ∀ {j} → Wrap j → C
test2d {c} (wrap {c}) with anything
test2d wrap | z = z
test2e : ∀ {j} → Wrap j → C
test2e {c} (wrap {c {._}}) with anything
test2e {c} wrap | z = z
test2f : ∀ {j} → Wrap j → C
test2f {c} (wrap {c {._}}) with anything
test2f wrap | z = z
test2g : ∀ {j} → Wrap j → C
test2g {c} (wrap {c {x}}) with anything
test2g {c} wrap | z = z
test2h : ∀ {j} → Wrap j → C
test2h {c} (wrap {c {x}}) with anything
test2h wrap | z = z
test2i : ∀ {j} → Wrap j → C
test2i {c} (wrap {c {_}}) with anything
test2i {c} wrap | z = z
test2j : ∀ {j} → Wrap j → C
test2j {c} (wrap {c {_}}) with anything
test2j wrap | z = z
-- Test 3: First argument is record of dot pattern, second is record pattern
-- The commented-out ones fail due to issue 1608
-- test3a : ∀ {j} → Wrap j → C
-- test3a {c {._}} wrap with anything
-- test3a {c {._}} wrap | z = z
test3b : ∀ {j} → Wrap j → C
test3b {c {._}} wrap with anything
test3b wrap | z = z
-- test3c : ∀ {j} → Wrap j → C
-- test3c {c {._}} (wrap {c}) with anything
-- test3c {c {._}} wrap | z = z
test3d : ∀ {j} → Wrap j → C
test3d {c {._}} (wrap {c}) with anything
test3d wrap | z = z
-- test3e : ∀ {j} → Wrap j → C
-- test3e {c {._}} (wrap {c {._}}) with anything
-- test3e {c {._}} wrap | z = z
-- test3f : ∀ {j} → Wrap j → C
-- test3f {c {._}} (wrap {c {._}}) with anything
-- test3f wrap | z = z
test3g : ∀ {j} → Wrap j → C
test3g {c {_}} (wrap {c {x}}) with anything
test3g {c {_}} wrap | z = z
test3h : ∀ {j} → Wrap j → C
test3h {c {_}} (wrap {c {x}}) with anything
test3h wrap | z = z
-- test3i : ∀ {j} → Wrap j → C
-- test3i {c {_}} (wrap {c {_}}) with anything
-- test3i {c {_}} wrap | z = z
test3j : ∀ {j} → Wrap j → C
test3j {c {_}} (wrap {c {_}}) with anything
test3j wrap | z = z
| 23.704348
| 76
| 0.561996
|
a103ec1b80fab591c16915223676ba6de16f46c8
| 925
|
agda
|
Agda
|
Cubical/Codata/Everything.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | 1
|
2020-03-23T23:52:11.000Z
|
2020-03-23T23:52:11.000Z
|
Cubical/Codata/Everything.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
Cubical/Codata/Everything.agda
|
ryanorendorff/cubical
|
c67854d2e11aafa5677e25a09087e176fafd3e43
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical #-}
module Cubical.Codata.Everything where
open import Cubical.Codata.EverythingSafe public
--- Modules making assumptions that might be incompatible with other
-- flags or make use of potentially unsafe features.
-- Assumes --guardedness
open import Cubical.Codata.Stream public
open import Cubical.Codata.Conat public
open import Cubical.Codata.M public
-- Also uses {-# TERMINATING #-}.
open import Cubical.Codata.M.Bisimilarity public
{-
-- Alternative M type implemetation, based on
-- https://arxiv.org/pdf/1504.02949.pdf
-- "Non-wellfounded trees in Homotopy Type Theory"
-- Benedikt Ahrens, Paolo Capriotti, Régis Spadotti
-}
open import Cubical.Codata.M.AsLimit.M
open import Cubical.Codata.M.AsLimit.Coalg
open import Cubical.Codata.M.AsLimit.helper
open import Cubical.Codata.M.AsLimit.Container
open import Cubical.Codata.M.AsLimit.itree
open import Cubical.Codata.M.AsLimit.stream
| 28.90625
| 68
| 0.787027
|
310141321a2fd5a9dc6d1f5b94bb175a3836e9de
| 12,135
|
agda
|
Agda
|
src/data/lib/prim/Agda/Builtin/Reflection.agda
|
shlevy/agda
|
ed8ac6f4062ea8a20fa0f62d5db82d4e68278338
|
[
"BSD-3-Clause"
] | null | null | null |
src/data/lib/prim/Agda/Builtin/Reflection.agda
|
shlevy/agda
|
ed8ac6f4062ea8a20fa0f62d5db82d4e68278338
|
[
"BSD-3-Clause"
] | null | null | null |
src/data/lib/prim/Agda/Builtin/Reflection.agda
|
shlevy/agda
|
ed8ac6f4062ea8a20fa0f62d5db82d4e68278338
|
[
"BSD-3-Clause"
] | null | null | null |
{-# OPTIONS --without-K --safe --no-sized-types --no-guardedness
--no-subtyping #-}
module Agda.Builtin.Reflection 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.Int
open import Agda.Builtin.Sigma
open import Agda.Primitive
-- Names --
postulate Name : Set
{-# BUILTIN QNAME Name #-}
primitive
primQNameEquality : Name → Name → Bool
primQNameLess : Name → Name → Bool
primShowQName : Name → String
-- Fixity --
data Associativity : Set where
left-assoc : Associativity
right-assoc : Associativity
non-assoc : Associativity
data Precedence : Set where
related : Float → Precedence
unrelated : Precedence
data Fixity : Set where
fixity : Associativity → Precedence → Fixity
{-# BUILTIN ASSOC Associativity #-}
{-# BUILTIN ASSOCLEFT left-assoc #-}
{-# BUILTIN ASSOCRIGHT right-assoc #-}
{-# BUILTIN ASSOCNON non-assoc #-}
{-# BUILTIN PRECEDENCE Precedence #-}
{-# BUILTIN PRECRELATED related #-}
{-# BUILTIN PRECUNRELATED unrelated #-}
{-# BUILTIN FIXITY Fixity #-}
{-# BUILTIN FIXITYFIXITY fixity #-}
{-# COMPILE GHC Associativity = data MAlonzo.RTE.Assoc (MAlonzo.RTE.LeftAssoc | MAlonzo.RTE.RightAssoc | MAlonzo.RTE.NonAssoc) #-}
{-# COMPILE GHC Precedence = data MAlonzo.RTE.Precedence (MAlonzo.RTE.Related | MAlonzo.RTE.Unrelated) #-}
{-# COMPILE GHC Fixity = data MAlonzo.RTE.Fixity (MAlonzo.RTE.Fixity) #-}
{-# COMPILE JS Associativity = function (x,v) { return v[x](); } #-}
{-# COMPILE JS left-assoc = "left-assoc" #-}
{-# COMPILE JS right-assoc = "right-assoc" #-}
{-# COMPILE JS non-assoc = "non-assoc" #-}
{-# COMPILE JS Precedence =
function (x,v) {
if (x === "unrelated") { return v[x](); } else { return v["related"](x); }} #-}
{-# COMPILE JS related = function(x) { return x; } #-}
{-# COMPILE JS unrelated = "unrelated" #-}
{-# COMPILE JS Fixity = function (x,v) { return v["fixity"](x["assoc"], x["prec"]); } #-}
{-# COMPILE JS fixity = function (x) { return function (y) { return { "assoc": x, "prec": y}; }; } #-}
primitive
primQNameFixity : Name → Fixity
primQNameToWord64s : Name → Σ Word64 (λ _ → Word64)
-- Metavariables --
postulate Meta : Set
{-# BUILTIN AGDAMETA Meta #-}
primitive
primMetaEquality : Meta → Meta → Bool
primMetaLess : Meta → Meta → Bool
primShowMeta : Meta → String
primMetaToNat : Meta → Nat
-- 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 #-}
data ArgInfo : Set where
arg-info : (v : Visibility) (r : Relevance) → ArgInfo
data Arg {a} (A : Set a) : Set a 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} (A : Set a) : Set a 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 #-}
-- Terms and patterns --
data Term : Set
data Sort : Set
data Pattern : Set
data Clause : Set
Type = Term
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
unknown : Sort
data Pattern 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 : Pattern
data Clause where
clause : (tel : List (Σ String λ _ → Arg Type)) (ps : List (Arg Pattern)) (t : Term) → Clause
absurd-clause : (tel : List (Σ String λ _ → Arg Type)) (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 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
reduce : 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
quoteωTC : ∀ {A : Setω} → A → TC Term
getContext : TC (List (Arg Type))
extendContext : ∀ {a} {A : Set a} → Arg Type → TC A → TC A
inContext : ∀ {a} {A : Set a} → List (Arg Type) → TC A → TC A
freshName : String → TC Name
declareDef : Arg Name → Type → TC ⊤
declarePostulate : 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 ⊤
isMacro : Name → TC Bool
-- If the argument is 'true' makes the following primitives also normalise
-- their results: inferType, checkType, quoteTC, getType, and getContext
withNormalisation : ∀ {a} {A : Set a} → Bool → TC A → TC A
-- Prints the third argument if the corresponding verbosity level is turned
-- on (with the -v flag to Agda).
debugPrint : String → Nat → List ErrorPart → TC ⊤
-- Only allow reduction of specific definitions while executing the TC computation
onlyReduceDefs : ∀ {a} {A : Set a} → List Name → TC A → TC A
-- Don't allow reduction of specific definitions while executing the TC computation
dontReduceDefs : ∀ {a} {A : Set a} → List Name → TC A → TC A
-- Fail if the given computation gives rise to new, unsolved
-- "blocking" constraints.
noConstraints : ∀ {a} {A : Set a} → TC A → TC A
-- Run the given TC action and return the first component. Resets to
-- the old TC state if the second component is 'false', or keep the
-- new TC state if it is 'true'.
runSpeculative : ∀ {a} {A : Set a} → TC (Σ A λ _ → Bool) → TC A
{-# 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 AGDATCMREDUCE reduce #-}
{-# BUILTIN AGDATCMCATCHERROR catchTC #-}
{-# BUILTIN AGDATCMQUOTETERM quoteTC #-}
{-# BUILTIN AGDATCMUNQUOTETERM unquoteTC #-}
{-# BUILTIN AGDATCMQUOTEOMEGATERM quoteωTC #-}
{-# BUILTIN AGDATCMGETCONTEXT getContext #-}
{-# BUILTIN AGDATCMEXTENDCONTEXT extendContext #-}
{-# BUILTIN AGDATCMINCONTEXT inContext #-}
{-# BUILTIN AGDATCMFRESHNAME freshName #-}
{-# BUILTIN AGDATCMDECLAREDEF declareDef #-}
{-# BUILTIN AGDATCMDECLAREPOSTULATE declarePostulate #-}
{-# BUILTIN AGDATCMDEFINEFUN defineFun #-}
{-# BUILTIN AGDATCMGETTYPE getType #-}
{-# BUILTIN AGDATCMGETDEFINITION getDefinition #-}
{-# BUILTIN AGDATCMBLOCKONMETA blockOnMeta #-}
{-# BUILTIN AGDATCMCOMMIT commitTC #-}
{-# BUILTIN AGDATCMISMACRO isMacro #-}
{-# BUILTIN AGDATCMWITHNORMALISATION withNormalisation #-}
{-# BUILTIN AGDATCMDEBUGPRINT debugPrint #-}
{-# BUILTIN AGDATCMONLYREDUCEDEFS onlyReduceDefs #-}
{-# BUILTIN AGDATCMDONTREDUCEDEFS dontReduceDefs #-}
{-# BUILTIN AGDATCMNOCONSTRAINTS noConstraints #-}
{-# BUILTIN AGDATCMRUNSPECULATIVE runSpeculative #-}
| 37.223926
| 130
| 0.563
|
4d4b7d3db539bf2aba1f58d63df9aa3d9a1e2bea
| 12,819
|
agda
|
Agda
|
Cubical/HITs/Ints/BiInvInt/Base.agda
|
limemloh/cubical
|
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Ints/BiInvInt/Base.agda
|
limemloh/cubical
|
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
|
[
"MIT"
] | null | null | null |
Cubical/HITs/Ints/BiInvInt/Base.agda
|
limemloh/cubical
|
df4ef7edffd1c1deb3d4ff342c7178e9901c44f1
|
[
"MIT"
] | null | null | null |
{-
Definition of the integers as a HIT ported from the redtt library:
https://github.com/RedPRL/redtt/blob/master/library/cool/biinv-int.red
For the naive, but incorrect, way to define the integers as a HIT, see HITs.IsoInt
This file contains:
- definition of BiInvInt
- proof that Int ≡ BiInvInt
- [discreteBiInvInt] and [isSetBiInvInt]
- versions of the point constructors of BiInvInt which satisfy the path constructors judgmentally
-}
{-# OPTIONS --cubical --safe #-}
module Cubical.HITs.Ints.BiInvInt.Base where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Data.Nat
open import Cubical.Data.Int
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.BiInvEquiv
open import Cubical.Foundations.HAEquiv
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.Properties
open import Cubical.Relation.Nullary
data BiInvInt : Type₀ where
zero : BiInvInt
suc : BiInvInt -> BiInvInt
-- suc is a bi-invertible equivalence:
predr : BiInvInt -> BiInvInt
suc-predr : ∀ z -> suc (predr z) ≡ z
predl : BiInvInt -> BiInvInt
predl-suc : ∀ z -> predl (suc z) ≡ z
suc-biinvequiv : BiInvEquiv BiInvInt BiInvInt
suc-biinvequiv = record { fun = suc ; invr = predr ; invr-rightInv = suc-predr
; invl = predl ; invl-leftInv = predl-suc }
predr-suc : ∀ z -> predr (suc z) ≡ z
predr-suc = BiInvEquiv.invr-leftInv suc-biinvequiv
-- since we want to use suc-adj and pred-adj (defined below) later on, we will need the
-- definition of suc-predl taken from HAEquiv instead of from BiInvEquiv
suc-haequiv : HAEquiv BiInvInt BiInvInt
suc-haequiv = biInvEquiv→HAEquiv suc-biinvequiv
suc-predl : ∀ z -> suc (predl z) ≡ z
suc-predl = isHAEquiv.ret (snd suc-haequiv)
-- predr and predl (as well as suc-predr and suc-predl - up to a path) are indistinguishable,
-- so we can safely define 'pred' to just be predl
predl≡predr : ∀ z -> predl z ≡ predr z
predl≡predr z i = cong fst (isContr→isProp (isContr-section (biInvEquiv→Equiv-left suc-biinvequiv))
(predl , suc-predl) (predr , suc-predr)) i z
suc-predl≡predr : ∀ z -> PathP (λ j → suc (predl≡predr z j) ≡ z) (suc-predl z) (suc-predr z)
suc-predl≡predr z i = cong snd (isContr→isProp (isContr-section (biInvEquiv→Equiv-left suc-biinvequiv))
(predl , suc-predl) (predr , suc-predr)) i z
pred : BiInvInt -> BiInvInt
pred = predl
suc-pred = suc-predl
pred-suc = predl-suc
-- these paths from HAEquiv will be useful later
suc-adj : ∀ z → (λ i → suc (pred-suc z i)) ≡ suc-pred (suc z)
pred-adj : ∀ z → (λ i → pred (suc-pred z i)) ≡ pred-suc (pred z)
suc-adj z = isHAEquiv.com (snd suc-haequiv) z
pred-adj z = isHAEquiv.com-op (snd suc-haequiv) z
-- Int ≡ BiInvInt
fwd : Int -> BiInvInt
fwd (pos zero) = zero
fwd (pos (suc n)) = suc (fwd (pos n))
fwd (negsuc zero) = pred zero
fwd (negsuc (suc n)) = pred (fwd (negsuc n))
bwd : BiInvInt -> Int
bwd zero = pos zero
bwd (suc z) = sucInt (bwd z)
bwd (predr z) = predInt (bwd z)
bwd (suc-predr z i) = sucPred (bwd z) i
bwd (predl z) = predInt (bwd z)
bwd (predl-suc z i) = predSuc (bwd z) i
bwd-fwd : ∀ (x : Int) -> bwd (fwd x) ≡ x
bwd-fwd (pos zero) = refl
bwd-fwd (pos (suc n)) = cong sucInt (bwd-fwd (pos n))
bwd-fwd (negsuc zero) = refl
bwd-fwd (negsuc (suc n)) = cong predInt (bwd-fwd (negsuc n))
fwd-sucInt : ∀ (x : Int) → fwd (sucInt x) ≡ suc (fwd x)
fwd-sucInt (pos n) = refl
fwd-sucInt (negsuc zero) = sym (suc-pred (fwd (pos zero)))
fwd-sucInt (negsuc (suc n)) = sym (suc-pred (fwd (negsuc n)))
fwd-predInt : ∀ (x : Int) → fwd (predInt x) ≡ pred (fwd x)
fwd-predInt (pos zero) = refl
fwd-predInt (pos (suc n)) = sym (predl-suc (fwd (pos n)))
fwd-predInt (negsuc n) = refl
private
sym-filler : ∀ {ℓ} {A : Type ℓ} {x y : A} (p : x ≡ y)
→ Square {- (i = i0) -} (sym p)
{- (i = i1) -} refl
{- (j = i0) -} refl
{- (j = i1) -} p
sym-filler {y = y} p i j = hcomp (λ k → λ { (j = i0) → y
; (i = i0) → p ((~ j) ∨ (~ k))
; (i = i1) → y
; (j = i1) → p (i ∨ (~ k)) }) y
fwd-sucPred : ∀ (x : Int)
→ Square {- (i = i0) -} (fwd-sucInt (predInt x) ∙ (λ i → suc (fwd-predInt x i)))
{- (i = i1) -} (λ _ → fwd x)
{- (j = i0) -} (λ i → fwd (sucPred x i))
{- (j = i1) -} (suc-pred (fwd x))
fwd-sucPred (pos zero) i j
= hcomp (λ k → λ { (j = i0) → fwd (pos zero)
; (i = i0) → rUnit (sym (suc-pred (fwd (pos zero)))) k j
-- because fwd-sucInt (predInt (pos zero)) ≡ sym (suc-pred (fwd (pos zero)))
; (i = i1) → fwd (pos zero)
; (j = i1) → suc-pred (fwd (pos zero)) i
})
(sym-filler (suc-pred (fwd (pos zero))) i j)
fwd-sucPred (pos (suc n)) i j
= hcomp (λ k → λ { (j = i0) → suc (fwd (pos n))
; (i = i0) → lUnit (λ i → suc (sym (predl-suc (fwd (pos n))) i)) k j
-- because fwd-predInt (pos (suc n)) ≡ sym (predl-suc (fwd (pos n)))
; (i = i1) → suc (fwd (pos n))
; (j = i1) → suc-adj (fwd (pos n)) k i
})
(suc (sym-filler (pred-suc (fwd (pos n))) i j))
fwd-sucPred (negsuc n) i j
= hcomp (λ k → λ { (j = i0) → fwd (negsuc n)
; (i = i0) → rUnit (sym (suc-pred (fwd (negsuc n)))) k j
-- because fwd-sucInt (predInt (negsuc n)) ≡ sym (suc-pred (fwd (negsuc n)))
; (i = i1) → fwd (negsuc n)
; (j = i1) → suc-pred (fwd (negsuc n)) i
})
(sym-filler (suc-pred (fwd (negsuc n))) i j)
fwd-predSuc : ∀ (x : Int)
→ Square {- (i = i0) -} (fwd-predInt (sucInt x) ∙ (λ i → pred (fwd-sucInt x i)))
{- (i = i1) -} (λ _ → fwd x)
{- (j = i0) -} (λ i → fwd (predSuc x i))
{- (j = i1) -} (pred-suc (fwd x))
fwd-predSuc (pos n) i j
= hcomp (λ k → λ { (j = i0) → fwd (pos n)
; (i = i0) → rUnit (sym (pred-suc (fwd (pos n)))) k j
-- because fwd-predInt (sucInt (pos n)) ≡ sym (pred-suc (fwd (pos n)))
; (i = i1) → fwd (pos n)
; (j = i1) → pred-suc (fwd (pos n)) i
})
(sym-filler (pred-suc (fwd (pos n))) i j)
fwd-predSuc (negsuc zero) i j
= hcomp (λ k → λ { (j = i0) → fwd (negsuc zero)
; (i = i0) → lUnit (λ i → pred (sym (suc-pred (fwd (pos zero))) i)) k j
-- because fwd-sucInt (negsuc zero) ≡ sym (suc-pred (fwd (pos zero)))
; (i = i1) → fwd (negsuc zero)
; (j = i1) → pred-adj (fwd (pos zero)) k i
})
(pred (sym-filler (suc-pred (fwd (pos zero))) i j))
fwd-predSuc (negsuc (suc n)) i j
= hcomp (λ k → λ { (j = i0) → fwd (negsuc (suc n))
; (i = i0) → lUnit (λ i → pred (sym (suc-pred (fwd (negsuc n))) i)) k j
-- because fwd-sucInt (negsuc (suc n)) ≡ sym (suc-pred (fwd (negsuc n)))
; (i = i1) → fwd (negsuc (suc n))
; (j = i1) → pred-adj (fwd (negsuc n)) k i
})
(pred (sym-filler (suc-pred (fwd (negsuc n))) i j))
fwd-bwd : ∀ (z : BiInvInt) -> fwd (bwd z) ≡ z
fwd-bwd zero = refl
fwd-bwd (suc z) = fwd-sucInt (bwd z) ∙ (λ i → suc (fwd-bwd z i))
fwd-bwd (predr z) = fwd-predInt (bwd z) ∙ (λ i → predl≡predr (fwd-bwd z i) i)
fwd-bwd (predl z) = fwd-predInt (bwd z) ∙ (λ i → pred (fwd-bwd z i))
fwd-bwd (suc-predr z i) j
= hcomp (λ k → λ { (j = i0) → fwd (sucPred (bwd z) i)
; (i = i0) → (fwd-sucInt (predInt (bwd z))
∙ (λ i → suc (compPath-filler (fwd-predInt (bwd z))
(λ i' → predl≡predr (fwd-bwd z i') i')
k i))) j
; (i = i1) → fwd-bwd z (j ∧ k)
; (j = i1) → suc-predl≡predr (fwd-bwd z k) k i })
(fwd-sucPred (bwd z) i j)
fwd-bwd (predl-suc z i) j
= hcomp (λ k → λ { (j = i0) → fwd (predSuc (bwd z) i)
; (i = i0) → (fwd-predInt (sucInt (bwd z))
∙ (λ i → pred (compPath-filler (fwd-sucInt (bwd z))
(λ i' → suc (fwd-bwd z i'))
k i))) j
; (i = i1) → fwd-bwd z (j ∧ k)
; (j = i1) → pred-suc (fwd-bwd z k) i })
(fwd-predSuc (bwd z) i j)
Int≡BiInvInt : Int ≡ BiInvInt
Int≡BiInvInt = isoToPath (iso fwd bwd fwd-bwd bwd-fwd)
discreteBiInvInt : Discrete BiInvInt
discreteBiInvInt = subst Discrete Int≡BiInvInt discreteInt
isSetBiInvInt : isSet BiInvInt
isSetBiInvInt = subst isSet Int≡BiInvInt isSetInt
-- suc' is equal to suc (suc≡suc') but cancels pred *exactly* (see suc'-pred)
suc'ᵖ : (z : BiInvInt) -> Σ BiInvInt (suc z ≡_)
suc' = fst ∘ suc'ᵖ
suc≡suc' = snd ∘ suc'ᵖ
suc'ᵖ zero = suc zero , refl
suc'ᵖ (suc z) = suc (suc z) , refl
suc'ᵖ (predr z) = z , suc-predr z
suc'ᵖ (suc-predr z i) = let filler : I → I → BiInvInt
filler j i = hfill (λ j → λ { (i = i0) → suc (suc (predr z))
; (i = i1) → suc≡suc' z j })
(inS (suc (suc-predr z i))) j
in filler i1 i , λ j → filler j i
suc'ᵖ (predl z) = z , suc-predl z
suc'ᵖ (predl-suc z i) = let filler : I → I → BiInvInt
filler j i = hfill (λ j → λ { (i = i0) → suc-predl (suc z) j
; (i = i1) → suc≡suc' z j })
(inS (suc (predl-suc z i))) j
in filler i1 i , λ j → filler j i
private
suc'-pred : ∀ z → suc' (pred z) ≡ z
suc'-pred z = refl
-- pred' is equal to pred (pred≡pred') but cancels suc *exactly* (see pred'-suc)
predr'ᵖ : (z : BiInvInt) -> Σ BiInvInt (predr z ≡_)
predr' = fst ∘ predr'ᵖ
predr≡predr' = snd ∘ predr'ᵖ
predr'ᵖ zero = predr zero , refl
predr'ᵖ (suc z) = z , predr-suc z
predr'ᵖ (predr z) = predr (predr z) , refl
predr'ᵖ (suc-predr z i) = let filler : I → I → BiInvInt
filler j i = hfill (λ j → λ { (i = i0) → predr-suc (predr z) j
; (i = i1) → predr≡predr' z j })
(inS (predr (suc-predr z i))) j
in filler i1 i , λ j → filler j i
predr'ᵖ (predl z) = predr (predl z) , refl
predr'ᵖ (predl-suc z i) = let filler : I → I → BiInvInt
filler j i = hfill (λ j → λ { (i = i0) → predr (predl (suc z))
; (i = i1) → predr≡predr' z j })
(inS (predr (predl-suc z i))) j
in filler i1 i , λ j → filler j i
predl'ᵖ : (z : BiInvInt) -> Σ BiInvInt (predl z ≡_)
predl' = fst ∘ predl'ᵖ
predl≡predl' = snd ∘ predl'ᵖ
predl'ᵖ zero = predl zero , refl
predl'ᵖ (suc z) = z , predl-suc z
predl'ᵖ (predr z) = predl (predr z) , refl
predl'ᵖ (suc-predr z i) = let filler : I → I → BiInvInt
filler j i = hfill (λ j → λ { (i = i0) → predl-suc (predr z) j
; (i = i1) → predl≡predl' z j })
(inS (predl (suc-predr z i))) j
in filler i1 i , λ j → filler j i
predl'ᵖ (predl z) = predl (predl z) , refl
predl'ᵖ (predl-suc z i) = let filler : I → I → BiInvInt
filler j i = hfill (λ j → λ { (i = i0) → predl (predl (suc z))
; (i = i1) → predl≡predl' z j })
(inS (predl (predl-suc z i))) j
in filler i1 i , λ j → filler j i
private
predr'-suc : ∀ z → predr' (suc z) ≡ z
predr'-suc z = refl
predl'-suc : ∀ z → predl' (suc z) ≡ z
predl'-suc z = refl
| 41.21865
| 108
| 0.478196
|
129068ffb6b5086c5f9c5f495f642a3aa85a7944
| 3,966
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Data/Rational/Base.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Rational/Base.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Rational/Base.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Rational numbers
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Rational.Base where
open import Function using (id)
open import Data.Integer as ℤ using (ℤ; ∣_∣; +_; -[1+_])
open import Data.Nat.GCD
open import Data.Nat.Divisibility as ℕDiv using (divides; 0∣⇒≡0)
open import Data.Nat.Coprimality as C using (Coprime; Bézout-coprime)
open import Data.Nat as ℕ using (ℕ; zero; suc)
open import Data.Product
open import Level using (0ℓ)
open import Relation.Nullary.Decidable using (False)
open import Relation.Nullary.Negation using (contradiction)
open import Relation.Binary using (Rel)
open import Relation.Binary.PropositionalEquality
using (_≡_; refl; subst; cong; cong₂; module ≡-Reasoning)
open ≡-Reasoning
------------------------------------------------------------------------
-- Rational numbers in reduced form. Note that there is exactly one
-- way to represent every rational number.
record ℚ : Set where
constructor mkℚ
field
numerator : ℤ
denominator-1 : ℕ
.isCoprime : Coprime ∣ numerator ∣ (suc denominator-1)
denominatorℕ : ℕ
denominatorℕ = suc denominator-1
denominator : ℤ
denominator = + denominatorℕ
open ℚ public using ()
renaming
( numerator to ↥_
; denominator to ↧_
; denominatorℕ to ↧ₙ_
)
------------------------------------------------------------------------
-- Equality of rational numbers (coincides with _≡_)
infix 4 _≃_
_≃_ : Rel ℚ 0ℓ
p ≃ q = (↥ p ℤ.* ↧ q) ≡ (↥ q ℤ.* ↧ p)
------------------------------------------------------------------------
-- Ordering of rationals
infix 4 _≤_
data _≤_ : Rel ℚ 0ℓ where
*≤* : ∀ {p q} → (↥ p ℤ.* ↧ q) ℤ.≤ (↥ q ℤ.* ↧ p) → p ≤ q
------------------------------------------------------------------------
-- Negation
pattern +0 = + 0
pattern +[1+_] n = + suc n
-_ : ℚ → ℚ
- mkℚ -[1+ n ] d prf = mkℚ +[1+ n ] d prf
- mkℚ +0 d prf = mkℚ +0 d prf
- mkℚ +[1+ n ] d prf = mkℚ -[1+ n ] d prf
------------------------------------------------------------------------
-- Constructing rationals
infix 4 _≢0
_≢0 : ℕ → Set
n ≢0 = False (n ℕ.≟ 0)
-- A constructor for ℚ that takes two natural numbers, say 6 and 21,
-- and returns them in a normalized form, e.g. say 2 and 7
normalize : ∀ m n .{m≢0 : m ≢0} .{n≢0 : n ≢0} → ℚ
normalize (suc m) (suc n) with gcd (suc m) (suc n)
... | zero , GCD.is (1+m∣0 , _) _ = contradiction (0∣⇒≡0 1+m∣0) λ()
... | suc g , G@(GCD.is (divides (suc p) refl , divides (suc q) refl) _)
= mkℚ (+ suc p) q (Bézout-coprime (Bézout.identity G))
-- A constructor for ℚ that (unlike mkℚ) automatically normalises it's
-- arguments. See the constants section below for how to use this operator.
infixl 7 _/_
_/_ : (n : ℤ) (d : ℕ) → .{d≢0 : d ≢0} → ℚ
_/_ +0 d {d≢0} = mkℚ +0 0 (C.sym (C.1-coprimeTo 0))
_/_ +[1+ n ] d {d≢0} = normalize (suc n) d {_} {d≢0}
_/_ -[1+ n ] d {d≢0} = - normalize (suc n) d {_} {d≢0}
------------------------------------------------------------------------------
-- Some constants
0ℚ : ℚ
0ℚ = + 0 / 1
1ℚ : ℚ
1ℚ = + 1 / 1
½ : ℚ
½ = + 1 / 2
-½ : ℚ
-½ = - ½
------------------------------------------------------------------------------
-- Operations on rationals
infix 8 -_ 1/_
infixl 7 _*_ _÷_
infixl 6 _-_ _+_
-- addition
_+_ : ℚ → ℚ → ℚ
p + q = (↥ p ℤ.* ↧ q ℤ.+ ↥ q ℤ.* ↧ p) / (↧ₙ p ℕ.* ↧ₙ q)
-- multiplication
_*_ : ℚ → ℚ → ℚ
p * q = (↥ p ℤ.* ↥ q) / (↧ₙ p ℕ.* ↧ₙ q)
-- subtraction
_-_ : ℚ → ℚ → ℚ
p - q = p + (- q)
-- reciprocal: requires a proof that the numerator is not zero
1/_ : (p : ℚ) → .{n≢0 : ∣ ↥ p ∣ ≢0} → ℚ
1/ mkℚ +[1+ n ] d prf = mkℚ +[1+ d ] n (C.sym prf)
1/ mkℚ -[1+ n ] d prf = mkℚ -[1+ d ] n (C.sym prf)
-- division: requires a proof that the denominator is not zero
_÷_ : (p q : ℚ) → .{n≢0 : ∣ ↥ q ∣ ≢0} → ℚ
(p ÷ q) {n≢0} = p * (1/_ q {n≢0})
| 26.264901
| 78
| 0.489662
|
0618751cb8ce3ae092a085b160e5ea70622dce2f
| 245
|
agda
|
Agda
|
test/Fail/UselessAbstractField.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Fail/UselessAbstractField.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | null | null | null |
test/Fail/UselessAbstractField.agda
|
Blaisorblade/Agda
|
802a28aa8374f15fe9d011ceb80317fdb1ec0949
|
[
"BSD-3-Clause"
] | null | null | null |
-- Andreas, 2016-07-17
record R : Set₁ where
abstract
field T : Set
-- Expected error:
--
-- Using abstract here has no effect. Abstract applies only
-- definitions like data definitions, record type definitions and
-- function clauses.
| 20.416667
| 65
| 0.722449
|
312b39f3ce807a901ffad003a0037c20e0c90cdf
| 126
|
agda
|
Agda
|
src/Magma/Properties.agda
|
Akshobhya1234/agda-NonAssociativeAlgebra
|
443e831e536b756acbd1afd0d6bae7bc0d288048
|
[
"MIT"
] | 2
|
2021-08-15T06:16:13.000Z
|
2021-08-17T09:14:03.000Z
|
src/Magma/Properties.agda
|
Akshobhya1234/agda-NonAssociativeAlgebra
|
443e831e536b756acbd1afd0d6bae7bc0d288048
|
[
"MIT"
] | 2
|
2021-10-04T05:30:30.000Z
|
2021-10-09T08:24:56.000Z
|
src/Magma/Properties.agda
|
Akshobhya1234/agda-NonAssociativeAlgebra
|
443e831e536b756acbd1afd0d6bae7bc0d288048
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Algebra
module Magma.Properties
{a ℓ} (M : Magma a ℓ) where
open Magma M
| 12.6
| 34
| 0.650794
|
5073339a3b30821e9fea28092bdfea3e2359aedd
| 3,548
|
agda
|
Agda
|
Cubical/Categories/Functor/Properties.agda
|
hyleIndex/cubical
|
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
|
[
"MIT"
] | 301
|
2018-10-17T18:00:24.000Z
|
2022-03-24T02:10:47.000Z
|
Cubical/Categories/Functor/Properties.agda
|
hyleIndex/cubical
|
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
|
[
"MIT"
] | 584
|
2018-10-15T09:49:02.000Z
|
2022-03-30T12:09:17.000Z
|
Cubical/Categories/Functor/Properties.agda
|
hyleIndex/cubical
|
ce5c2820ecb2e0fd8dce74fb0247856cdbf034c4
|
[
"MIT"
] | 134
|
2018-11-16T06:11:03.000Z
|
2022-03-23T16:22:13.000Z
|
{-# OPTIONS --safe #-}
module Cubical.Categories.Functor.Properties where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function renaming (_∘_ to _◍_)
open import Cubical.Foundations.GroupoidLaws using (lUnit; rUnit; assoc; cong-∙)
open import Cubical.Categories.Category
open import Cubical.Categories.Functor.Base
private
variable
ℓ ℓ' ℓ'' : Level
B C D E : Precategory ℓ ℓ'
open Precategory
open Functor
{-
x ---p--- x'
⇓ᵍ
g x' ---q--- y
⇓ʰ
h y ---r--- z
The path from `h (g x) ≡ z` obtained by
1. first applying cong to p and composing with q; then applying cong again and composing with r
2. first applying cong to q and composing with r; then applying a double cong to p and precomposing
are path equal.
-}
congAssoc : ∀ {X : Type ℓ} {Y : Type ℓ'} {Z : Type ℓ''} (g : X → Y) (h : Y → Z) {x x' : X} {y : Y} {z : Z}
→ (p : x ≡ x') (q : g x' ≡ y) (r : h y ≡ z)
→ cong (h ◍ g) p ∙ (cong h q ∙ r) ≡ cong h (cong g p ∙ q) ∙ r
congAssoc g h p q r
= cong (h ◍ g) p ∙ (cong h q ∙ r)
≡⟨ assoc _ _ _ ⟩
((cong (h ◍ g) p) ∙ (cong h q)) ∙ r
≡⟨ refl ⟩
(cong h (cong g p) ∙ (cong h q)) ∙ r
≡⟨ cong (_∙ r) (sym (cong-∙ h _ _)) ⟩
cong h (cong g p ∙ q) ∙ r
∎
-- composition is associative
F-assoc : {F : Functor B C} {G : Functor C D} {H : Functor D E}
→ H ∘F (G ∘F F) ≡ (H ∘F G) ∘F F
F-assoc {F = F} {G} {H} i .F-ob x = H ⟅ G ⟅ F ⟅ x ⟆ ⟆ ⟆
F-assoc {F = F} {G} {H} i .F-hom f = H ⟪ G ⟪ F ⟪ f ⟫ ⟫ ⟫
F-assoc {F = F} {G} {H} i .F-id {x} = congAssoc (G ⟪_⟫) (H ⟪_⟫) (F .F-id {x}) (G .F-id {F ⟅ x ⟆}) (H .F-id) (~ i)
F-assoc {F = F} {G} {H} i .F-seq f g = congAssoc (G ⟪_⟫) (H ⟪_⟫) (F .F-seq f g) (G .F-seq _ _) (H .F-seq _ _) (~ i)
-- Results about functors
module _ {F : Functor C D} where
-- the identity is the identity
F-lUnit : F ∘F 𝟙⟨ C ⟩ ≡ F
F-lUnit i .F-ob x = F ⟅ x ⟆
F-lUnit i .F-hom f = F ⟪ f ⟫
F-lUnit i .F-id {x} = lUnit (F .F-id) (~ i)
F-lUnit i .F-seq f g = lUnit (F .F-seq f g) (~ i)
F-rUnit : 𝟙⟨ D ⟩ ∘F F ≡ F
F-rUnit i .F-ob x = F ⟅ x ⟆
F-rUnit i .F-hom f = F ⟪ f ⟫
F-rUnit i .F-id {x} = rUnit (F .F-id) (~ i)
F-rUnit i .F-seq f g = rUnit (F .F-seq f g) (~ i)
-- functors preserve commutative diagrams (specificallysqures here)
preserveCommF : ∀ {x y z w} {f : C [ x , y ]} {g : C [ y , w ]} {h : C [ x , z ]} {k : C [ z , w ]}
→ f ⋆⟨ C ⟩ g ≡ h ⋆⟨ C ⟩ k
→ (F ⟪ f ⟫) ⋆⟨ D ⟩ (F ⟪ g ⟫) ≡ (F ⟪ h ⟫) ⋆⟨ D ⟩ (F ⟪ k ⟫)
preserveCommF {f = f} {g = g} {h = h} {k = k} eq
= (F ⟪ f ⟫) ⋆⟨ D ⟩ (F ⟪ g ⟫)
≡⟨ sym (F .F-seq _ _) ⟩
F ⟪ f ⋆⟨ C ⟩ g ⟫
≡⟨ cong (F ⟪_⟫) eq ⟩
F ⟪ h ⋆⟨ C ⟩ k ⟫
≡⟨ F .F-seq _ _ ⟩
(F ⟪ h ⟫) ⋆⟨ D ⟩ (F ⟪ k ⟫)
∎
-- functors preserve isomorphisms
preserveIsosF : ∀ {x y} → CatIso {C = C} x y → CatIso {C = D} (F ⟅ x ⟆) (F ⟅ y ⟆)
preserveIsosF {x} {y} (catiso f f⁻¹ sec' ret') =
catiso
g g⁻¹
-- sec
( (g⁻¹ ⋆⟨ D ⟩ g)
≡⟨ sym (F .F-seq f⁻¹ f) ⟩
F ⟪ f⁻¹ ⋆⟨ C ⟩ f ⟫
≡⟨ cong (F .F-hom) sec' ⟩
F ⟪ C .id y ⟫
≡⟨ F .F-id ⟩
D .id y'
∎ )
-- ret
( (g ⋆⟨ D ⟩ g⁻¹)
≡⟨ sym (F .F-seq f f⁻¹) ⟩
F ⟪ f ⋆⟨ C ⟩ f⁻¹ ⟫
≡⟨ cong (F .F-hom) ret' ⟩
F ⟪ C .id x ⟫
≡⟨ F .F-id ⟩
D .id x'
∎ )
where
x' : D .ob
x' = F ⟅ x ⟆
y' : D .ob
y' = F ⟅ y ⟆
g : D [ x' , y' ]
g = F ⟪ f ⟫
g⁻¹ : D [ y' , x' ]
g⁻¹ = F ⟪ f⁻¹ ⟫
| 30.324786
| 116
| 0.444476
|
10c75a554c1efe786a6d1ad13c0734bb7a497375
| 372
|
agda
|
Agda
|
test/Succeed/Issue1701/ModParamsToLose.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue1701/ModParamsToLose.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue1701/ModParamsToLose.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Issue1701.ModParamsToLose where
module Param (A : Set) where
module R (B : Set) (G : A → B) where
F = G
private
module Tmp (B : Set) (G : A → B) where
module r = R B G
open Tmp public
module Works (A : Set) where
module ParamA = Param A
open ParamA
works : (A → A) → A → A
works G = S.F
module works where
module S = r A G
| 16.173913
| 41
| 0.586022
|
1d3254a1b1c7631e1c1d0de4294470d51e6f507d
| 4,590
|
agda
|
Agda
|
src/FRP/LTL/Time/Bound.agda
|
agda/agda-frp-ltl
|
e88107d7d192cbfefd0a94505e6a5793afe1a7a5
|
[
"MIT"
] | 21
|
2015-07-02T20:25:05.000Z
|
2020-06-15T02:51:13.000Z
|
src/FRP/LTL/Time/Bound.agda
|
agda/agda-frp-ltl
|
e88107d7d192cbfefd0a94505e6a5793afe1a7a5
|
[
"MIT"
] | 2
|
2015-03-01T07:01:31.000Z
|
2015-03-02T15:23:53.000Z
|
src/FRP/LTL/Time/Bound.agda
|
agda/agda-frp-ltl
|
e88107d7d192cbfefd0a94505e6a5793afe1a7a5
|
[
"MIT"
] | 3
|
2015-03-01T07:33:00.000Z
|
2022-03-12T11:39:04.000Z
|
open import Data.Nat using ( ℕ ; zero ; suc )
open import Data.Product using ( ∃ ; _×_ ; _,_ )
open import Data.Sum using ( _⊎_ ; inj₁ ; inj₂ )
open import Relation.Binary.PropositionalEquality using ( _≡_ ; _≢_ ; refl ; cong )
open import Relation.Nullary using ( ¬_ )
open import FRP.LTL.Time using
( Time ; _<_ ; _≤_ ; _≥_ ; ≤-refl ; _≤-trans_ ; _≤-asym_ ; _≤-total_ ; ≤-proof-irrel ; ≡-impl-≥
; _∸_ ; _+_ ; t≤u+t∸u ; +-unit ; +-assoc ; +-resp-≤ ; <-impl-+1≤ ; t<t+1
; _≤-case_ ; lt ; eq ; gt )
open import FRP.LTL.Util using ( ⊥-elim )
module FRP.LTL.Time.Bound where
infixr 2 _≼_ _≺_ _⋠_
infixr 4 _,_
infixr 5 _≼-trans_ _≼-asym_ _≼-total_ _≺-transˡ_ _≺-transʳ_ _≺-trans_
-- Time bounds, which extend Time with least and greatest elements
data Time∞ : Set where
+∞ : Time∞
fin : Time → Time∞
-- Order on time, generated by s ≺ t ≺ +∞ when s < t
data _≼_ : Time∞ → Time∞ → Set where
+∞-top : ∀ {t} → (t ≼ +∞)
≤-impl-≼ : ∀ {t u} → (t ≤ u) → (fin t ≼ fin u)
_⋠_ : Time∞ → Time∞ → Set
s ⋠ t = ¬(s ≼ t)
_≺_ : Time∞ → Time∞ → Set
s ≺ t = (s ≼ t) × (t ⋠ s)
≼-impl-≤ : ∀ {t u} → (fin t ≼ fin u) → (t ≤ u)
≼-impl-≤ (≤-impl-≼ t≤u) = t≤u
-- Axioms for ≺
t≺+∞ : ∀ {t} → fin t ≺ +∞
t≺+∞ = (+∞-top , λ ())
<-impl-≺ : ∀ {t u} → (t < u) → (fin t ≺ fin u)
<-impl-≺ (t≤u , u≰t) = (≤-impl-≼ t≤u , λ u≼t → u≰t (≼-impl-≤ u≼t))
≺-impl-< : ∀ {t u} → (fin t ≺ fin u) → (t < u)
≺-impl-< (t≼u , u⋠t) = (≼-impl-≤ t≼u , λ u≤t → u⋠t (≤-impl-≼ u≤t))
t≺t+1 : ∀ {t} → (fin t ≺ fin (t + 1))
t≺t+1 = <-impl-≺ t<t+1
-- ≼ is a decidable total order
≼-refl : ∀ {t} → (t ≼ t)
≼-refl {+∞} = +∞-top
≼-refl {fin t} = ≤-impl-≼ ≤-refl
_≼-trans_ : ∀ {s t u} → (s ≼ t) → (t ≼ u) → (s ≼ u)
s≼t ≼-trans +∞-top = +∞-top
≤-impl-≼ s≤t ≼-trans ≤-impl-≼ t≤u = ≤-impl-≼ (s≤t ≤-trans t≤u)
_≼-asym_ : ∀ {s t} → (s ≼ t) → (t ≼ s) → (s ≡ t)
+∞-top ≼-asym +∞-top = refl
≤-impl-≼ s≤t ≼-asym ≤-impl-≼ t≤s = cong fin (s≤t ≤-asym t≤s)
_≼-total_ : ∀ s t → (s ≼ t) ⊎ (t ≺ s)
+∞ ≼-total +∞ = inj₁ +∞-top
+∞ ≼-total fin t = inj₂ t≺+∞
fin s ≼-total +∞ = inj₁ +∞-top
fin s ≼-total fin t with s ≤-total t
... | inj₁ s≤t = inj₁ (≤-impl-≼ s≤t)
... | inj₂ t<s = inj₂ (<-impl-≺ t<s)
data _≼-Case_ (t u : Time∞) : Set where
lt : .(t ≺ u) → (t ≼-Case u)
eq : .(t ≡ u) → (t ≼-Case u)
gt : .(u ≺ t) → (t ≼-Case u)
_≼-case_ : ∀ t u → (t ≼-Case u)
+∞ ≼-case +∞ = eq refl
+∞ ≼-case fin u = gt t≺+∞
fin t ≼-case +∞ = lt t≺+∞
fin t ≼-case fin u with t ≤-case u
fin t ≼-case fin u | lt t<u = lt (<-impl-≺ t<u)
fin t ≼-case fin u | eq t≡u = eq (cong fin t≡u)
fin t ≼-case fin u | gt t>u = gt (<-impl-≺ t>u)
≡-impl-≼ : ∀ {s t} → (s ≡ t) → (s ≼ t)
≡-impl-≼ refl = ≼-refl
≡-impl-≽ : ∀ {s t} → (s ≡ t) → (t ≼ s)
≡-impl-≽ refl = ≼-refl
≼-proof-irrel : ∀ {t u} → (p q : t ≼ u) → (p ≡ q)
≼-proof-irrel +∞-top +∞-top = refl
≼-proof-irrel (≤-impl-≼ t≤₁u) (≤-impl-≼ t≤₂u) = cong ≤-impl-≼ (≤-proof-irrel t≤₁u t≤₂u)
≺-impl-≼ : ∀ {t u} → (t ≺ u) → (t ≼ u)
≺-impl-≼ (t≼u , u⋠t) = t≼u
≺-impl-⋡ : ∀ {t u} → (t ≺ u) → (u ⋠ t)
≺-impl-⋡ (t≼u , u⋠t) = u⋠t
≺-impl-≢ : ∀ {t u} → (t ≺ u) → (t ≢ u)
≺-impl-≢ (t≼u , u⋠t) refl = u⋠t ≼-refl
_≺-transˡ_ : ∀ {t u v} → (t ≺ u) → (u ≼ v) → (t ≺ v)
(t≼u , u⋠t) ≺-transˡ u≼v = (t≼u ≼-trans u≼v , λ v≼t → u⋠t (u≼v ≼-trans v≼t))
_≺-transʳ_ : ∀ {t u v} → (t ≼ u) → (u ≺ v) → (t ≺ v)
t≼u ≺-transʳ (u≼v , v⋠u) = (t≼u ≼-trans u≼v , λ v≼t → v⋠u (v≼t ≼-trans t≼u))
_≺-trans_ : ∀ {t u v} → (t ≺ u) → (u ≺ v) → (t ≺ v)
(t≼u , u⋠t) ≺-trans (u≼v , v⋠u) = (t≼u ≼-trans u≼v , λ v≼t → v⋠u (v≼t ≼-trans t≼u))
∞≼-impl-≡∞ : ∀ {t} → (+∞ ≼ t) → (t ≡ +∞)
∞≼-impl-≡∞ +∞-top = refl
src : ∀ {s t} → .(s ≼ t) → Time∞
src {s} {t} s≼t = s
tgt : ∀ {s t} → .(s ≼ t) → Time∞
tgt {s} {t} s≼t = t
-- An induction scheme for time bounds
_+_≻_ : Time∞ → ℕ → Time∞ → Set
s + zero ≻ u = u ≺ s
s + suc n ≻ u = ∀ {t} → (s ≺ t) → (t + n ≻ u)
data ≺-Indn (s u : Time∞) : Set where
_,_ : ∀ n → .(s + n ≻ u) → ≺-Indn s u
≺-indn : ∀ {s u} → .(u ≺ +∞) → ≺-Indn s u
≺-indn {s} {+∞} u≺∞ = ⊥-elim (≺-impl-≢ u≺∞ refl)
≺-indn {+∞} {fin u} u≺∞ = (zero , t≺+∞)
≺-indn {fin s} {fin u} u≺∞ = (suc (u ∸ s) , lemma s u (u ∸ s) t≤u+t∸u) where
lemma : ∀ s u n → (s + n ≥ u) → (fin s + suc n ≻ fin u)
lemma s u zero s+0≥u s≺t =
(≤-impl-≼ s+0≥u ≼-trans ≡-impl-≼ (cong fin (+-unit s))) ≺-transʳ s≺t
lemma s u (suc n) s+1+n≥u {fin t} s≺t = lemma t u n
(s+1+n≥u ≤-trans ≡-impl-≥ (+-assoc s 1 n) ≤-trans +-resp-≤ (<-impl-+1≤ (≺-impl-< s≺t)) n)
lemma s u (suc n) s+1+n≥u {+∞} s≺t =
λ ∞≺v → ⊥-elim (≺-impl-⋡ ∞≺v +∞-top)
| 31.22449
| 97
| 0.439651
|
31938b3085d821d10682e974e9ce965293cc10a5
| 328
|
agda
|
Agda
|
src/plfa-code/Reasoning-legacy.agda
|
chirsz-ever/plfa-code
|
ec5b359a8c22bf5268cae3c36a97e6737c75d5f3
|
[
"MIT"
] | null | null | null |
src/plfa-code/Reasoning-legacy.agda
|
chirsz-ever/plfa-code
|
ec5b359a8c22bf5268cae3c36a97e6737c75d5f3
|
[
"MIT"
] | null | null | null |
src/plfa-code/Reasoning-legacy.agda
|
chirsz-ever/plfa-code
|
ec5b359a8c22bf5268cae3c36a97e6737c75d5f3
|
[
"MIT"
] | null | null | null |
module plfa-code.Reasoning-legacy where
import Relation.Binary.PropositionalEquality as Eq
open Eq using (_≡_; refl; trans)
infixr 2 _≡⟨_⟩_
infix 3 _∎
_≡⟨_⟩_ : ∀ {A : Set} (x : A) {y z : A}
→ x ≡ y
→ y ≡ z
-------
→ x ≡ z
x ≡⟨ x≡y ⟩ y≡z = trans x≡y y≡z
_∎ : ∀ {A : Set} (x : A)
------
→ x ≡ x
x ∎ = refl
| 16.4
| 50
| 0.5
|
fb54d9a18d0347188e9c5fb2cf6dec1de0771c0f
| 1,248
|
agda
|
Agda
|
test/Succeed/Issue365.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue365.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue365.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS -v impossible:100 #-}
-- {-# OPTIONS -v tc.cover.cover:10 -v tc.cover.splittree:100 -v tc.cover.strategy:100 -v tc.cc:100 #-}
module Issue365 where
import Common.Level
{- Basic data types -}
data Nat : Set where
zero : Nat
succ : Nat -> Nat
data Fin : Nat -> Set where
fzero : {n : Nat} -> Fin (succ n)
fsucc : {n : Nat} -> Fin n -> Fin (succ n)
data Vec (A : Set) : Nat -> Set where
[] : Vec A zero
_::_ : {n : Nat} -> A -> Vec A n -> Vec A (succ n)
data _==_ {A : Set} (x : A) : A -> Set where
refl : x == x
{- Function composition -}
_◦_ : {A : Set} {B : A -> Set} {C : (x : A) -> B x -> Set}
(f : {x : A} (y : B x) -> C x y) (g : (x : A) -> B x)
(x : A) -> C x (g x)
(f ◦ g) x = f (g x)
{- Indexing and tabulating -}
_!_ : {n : Nat} {A : Set} -> Vec A n -> Fin n -> A
[] ! ()
(x :: xs) ! fzero = x
(x :: xs) ! (fsucc i) = xs ! i
tabulate : {n : Nat} {A : Set} -> (Fin n -> A) -> Vec A n
tabulate {zero} f = []
tabulate {succ n} f = f fzero :: tabulate (f ◦ fsucc)
lem-tab-! : forall {A n} (xs : Vec A n) -> tabulate (_!_ xs) == xs
lem-tab-! {A} {zero} [] = refl
lem-tab-! {A} {succ n} (x :: xs) with tabulate (_!_ xs) | lem-tab-! xs
lem-tab-! {A} {succ _} (x :: xs) | .xs | refl = refl
| 27.130435
| 103
| 0.495994
|
1d80e50517c60a72585d58151bfe9f3b345ee36c
| 292
|
agda
|
Agda
|
test/Succeed/Issue155.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue155.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue155.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- There was a bug with module application in a let in a
-- parameterised module.
module Issue155 (A : Set) where
module M (Y : Set) where
postulate F : Set → Set
Foo : Set₁
Foo = let module M′ = M A in (B : Set) → M′.F B
record R : Set₁ where
open M A
field
B : Set
C : F A
| 18.25
| 56
| 0.619863
|
2390016b7f8598620612b6776b01138ddcdad131
| 568
|
agda
|
Agda
|
src/Generic/Test/Data/Product.agda
|
iblech/Generic
|
380554b20e0991290d1864ddf81f0587ec1647ed
|
[
"MIT"
] | 30
|
2016-07-19T21:10:54.000Z
|
2022-02-05T10:19:38.000Z
|
src/Generic/Test/Data/Product.agda
|
iblech/Generic
|
380554b20e0991290d1864ddf81f0587ec1647ed
|
[
"MIT"
] | 9
|
2017-04-06T18:58:09.000Z
|
2022-01-04T15:43:14.000Z
|
src/Generic/Test/Data/Product.agda
|
iblech/Generic
|
380554b20e0991290d1864ddf81f0587ec1647ed
|
[
"MIT"
] | 4
|
2017-07-17T07:23:39.000Z
|
2021-01-27T12:57:09.000Z
|
module Generic.Test.Data.Product where
open import Generic.Main as Main hiding (Σ; proj₁; proj₂; _,′_) renaming (_,_ to _,′_)
infixr 4 _,_
Σ : ∀ {α β} -> (A : Set α) -> (A -> Set β) -> Set (α ⊔ β)
Σ = readData Main.Σ
pattern _,_ x y = !#₀ (relv x ,′ relv y ,′ lrefl)
proj₁ : ∀ {α β} {A : Set α} {B : A -> Set β} -> Σ A B -> A
proj₁ (x , y) = x
proj₂ : ∀ {α β} {A : Set α} {B : A -> Set β} -> (p : Σ A B) -> B (proj₁ {B = B} p)
proj₂ (x , y) = y
ηo : ∀ {α β} {A : Set α} {B : A -> Set β} -> (p : Σ A B) -> p ≡ proj₁ {B = B} p , proj₂ {B = B} p
ηo (x , y) = refl
| 28.4
| 97
| 0.482394
|
4de291d84bf8863170d6ff044b4e7af5444955d4
| 5,517
|
agda
|
Agda
|
Data/List/Proofs/Length.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Data/List/Proofs/Length.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Data/List/Proofs/Length.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
module Data.List.Proofs.Length where
import Lvl
open import Functional
open import Function.Names as Names using (_⊜_)
open import Data.Boolean
open import Data.List as List
open import Data.List.Functions
open import Logic
open import Logic.Propositional
open import Numeral.Finite
open import Numeral.Natural
open import Numeral.Natural.Oper
open import Numeral.Natural.Oper.Proofs
open import Relator.Equals
open import Relator.Equals.Proofs
open import Structure.Function.Multi
open import Structure.Operator.Properties
open import Structure.Operator
open import Structure.Relator.Properties
open import Syntax.Transitivity
open import Type
private variable ℓ ℓₑ : Lvl.Level
private variable T A B : Type{ℓ}
private variable l l₁ l₂ : List(T)
private variable a b x : T
private variable n : ℕ
private variable f : A → B
private variable P : List(T) → Stmt{ℓ}
-- TODO: Almost all of these can use Preserving instead
length-[∅] : (length(∅ {T = T}) ≡ 0)
length-[∅] = [≡]-intro
length-singleton : (length{T = T}(singleton(a)) ≡ 1)
length-singleton = [≡]-intro
instance
length-preserves-prepend : Preserving₁(length)(a ⊰_)(𝐒)
Preserving.proof (length-preserves-prepend {a = a}) {x} = [≡]-intro
length-postpend : ((length ∘ postpend a) ⊜ (𝐒 ∘ length))
length-postpend {x = l} = List.elim [≡]-intro (\x l → [≡]-with(𝐒) {length(postpend _ l)}{𝐒(length l)}) l
instance
length-preserves-postpend : Preserving₁(length)(postpend a)(𝐒)
Preserving.proof (length-preserves-postpend {a = a}) {x} = length-postpend {a = a}{x = x}
length-[++] : (length{T = T}(l₁ ++ l₂) ≡ length(l₁) + length(l₂))
length-[++] {T = T} {l₁ = l₁} {l₂} = List.elim base next l₁ where
base : length(∅ ++ l₂) ≡ length{T = T}(∅) + length(l₂)
base = symmetry(_≡_) (identityₗ(_+_)(0))
next : ∀(x)(l) → (length(l ++ l₂) ≡ length(l) + length(l₂)) → (length((x ⊰ l) ++ l₂) ≡ length(x ⊰ l) + length(l₂))
next x l stmt =
length((x ⊰ l) ++ l₂) 🝖[ _≡_ ]-[]
length(x ⊰ (l ++ l₂)) 🝖[ _≡_ ]-[]
𝐒(length(l ++ l₂)) 🝖[ _≡_ ]-[ [≡]-with(𝐒) stmt ]
𝐒(length(l) + length(l₂)) 🝖[ _≡_ ]-[ [+]-stepₗ {length(l)} {length(l₂)} ]
𝐒(length(l)) + length(l₂) 🝖[ _≡_ ]-[]
length(x ⊰ l) + length(l₂) 🝖-end
instance
length-preserves-[++] : Preserving₂(length{T = T})(_++_)(_+_)
Preserving.proof length-preserves-[++] {l₁} {l₂} = length-[++] {l₁ = l₁} {l₂ = l₂}
length-reverse : ((length{T = T} ∘ reverse) ⊜ length)
length-reverse {x = ∅} = [≡]-intro
length-reverse {x = x ⊰ l} = length-postpend{a = x}{x = reverse l} 🝖 [≡]-with(𝐒) (length-reverse {x = l})
instance
length-preserves-reverse : Preserving₁(length{T = T})(reverse)(id)
Preserving.proof length-preserves-reverse {l} = length-reverse {x = l}
length-repeat : ((length{T = T} ∘ repeat(a)) ⊜ id)
length-repeat{T = T}{x = 𝟎} = [≡]-intro
length-repeat{T = T}{x = 𝐒(n)} = [≡]-with(𝐒) (length-repeat{T = T}{x = n})
length-tail : ((length{T = T} ∘ tail) ⊜ (𝐏 ∘ length))
length-tail{x = ∅} = [≡]-intro
length-tail{x = _ ⊰ l} = [≡]-intro
instance
length-preserves-tail : Preserving₁(length{T = T})(tail)(𝐏)
Preserving.proof length-preserves-tail {l} = length-tail {x = l}
length-map : ∀{f : A → B} → ((length ∘ map f) ⊜ length)
length-map {f = f}{x = ∅} = [≡]-intro
length-map {f = f}{x = x ⊰ l} = [≡]-with(𝐒) (length-map {f = f}{x = l})
instance
length-preserves-map : Preserving₁(length{T = T})(map f)(id)
Preserving.proof (length-preserves-map {f = f}) {l} = length-map {f = f}{x = l}
length-foldᵣ : ∀{init}{f}{g} → (∀{x}{l} → (length(f x l) ≡ g x (length l))) → (length{T = T}(foldᵣ f init l) ≡ foldᵣ g (length init) l)
length-foldᵣ {l = ∅} _ = [≡]-intro
length-foldᵣ {l = x ⊰ l} {init} {f} {g} p =
length(foldᵣ f init (x ⊰ l)) 🝖[ _≡_ ]-[]
length(f(x) (foldᵣ f init l)) 🝖[ _≡_ ]-[ p ]
g(x) (length(foldᵣ f init l)) 🝖[ _≡_ ]-[ [≡]-with(g(x)) (length-foldᵣ {l = l} {init} {f} {g} p) ]
g(x) (foldᵣ g (length init) l) 🝖[ _≡_ ]-[]
foldᵣ g (length init) (x ⊰ l) 🝖-end
length-concatMap : ∀{f} → (length{T = T}(concatMap f l) ≡ foldᵣ((_+_) ∘ length ∘ f) 𝟎 l)
length-concatMap {l = l} {f} = length-foldᵣ{l = l}{init = ∅}{f = (_++_) ∘ f} \{x l} → length-[++] {l₁ = f(x)}{l₂ = l}
length-accumulateIterate₀ : ∀{n}{f}{init : T} → (length(accumulateIterate₀ n f init) ≡ n)
length-accumulateIterate₀ {n = 𝟎} = [≡]-intro
length-accumulateIterate₀ {n = 𝐒 n}{f} = [≡]-with(𝐒) (length-accumulateIterate₀ {n = n}{f})
length-[++^] : (length(l ++^ n) ≡ length(l) ⋅ n)
length-[++^] {l = l}{𝟎} = [≡]-intro
length-[++^] {l = l}{𝐒(n)} =
length-[++] {l₁ = l}{l ++^ n}
🝖 [≡]-with(expr ↦ length(l) + expr) (length-[++^] {l = l}{n})
length-isEmpty : (length(l) ≡ 0) ↔ (isEmpty(l) ≡ 𝑇)
length-isEmpty {l = ∅} = [↔]-intro (const [≡]-intro) (const [≡]-intro)
length-isEmpty {l = x ⊰ L} = [↔]-intro (\()) (\())
instance
length-preserves-insert : Preserving₁(length)(insert n x)(𝐒)
Preserving.proof (length-preserves-insert {n = n}) = proof{n = n} where
proof : ∀{n} → (length(insert n x l) ≡ 𝐒(length l))
proof {l = _} {n = 𝟎} = [≡]-intro
proof {l = ∅} {n = 𝐒 n} = [≡]-intro
proof {x = x} {l = y ⊰ l} {n = 𝐒 n} rewrite proof {x = x} {l = l} {n = n} = [≡]-intro
length-insertIn : ∀{n} → (length(insertIn x l n) ≡ 𝐒(length l))
length-insertIn {l = _} {n = 𝟎} = [≡]-intro
length-insertIn {l = ∅} {n = 𝐒 n} = [≡]-intro
length-insertIn {x = x} {l = y ⊰ l} {n = 𝐒 n} rewrite length-insertIn {x = x} {l = l} {n = n} = [≡]-intro
| 40.866667
| 135
| 0.580569
|
cba2af89148bc43f973f694b31fadf1b738def7e
| 1,305
|
agda
|
Agda
|
src/fot/FOTC/Program/SortList/CorrectnessProofATP.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 11
|
2015-09-03T20:53:42.000Z
|
2021-09-12T16:09:54.000Z
|
src/fot/FOTC/Program/SortList/CorrectnessProofATP.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 2
|
2016-10-12T17:28:16.000Z
|
2017-01-01T14:34:26.000Z
|
src/fot/FOTC/Program/SortList/CorrectnessProofATP.agda
|
asr/fotc
|
2fc9f2b81052a2e0822669f02036c5750371b72d
|
[
"MIT"
] | 3
|
2016-09-19T14:18:30.000Z
|
2018-03-14T08:50:00.000Z
|
------------------------------------------------------------------------------
-- The program to sort a list is correct
------------------------------------------------------------------------------
{-# OPTIONS --exact-split #-}
{-# OPTIONS --no-sized-types #-}
{-# OPTIONS --no-universe-polymorphism #-}
{-# OPTIONS --without-K #-}
-- This module proves the correctness of a program which sorts a list
-- by converting it into an ordered tree and then back to a list
-- (Burstall, 1969, p. 45).
module FOTC.Program.SortList.CorrectnessProofATP where
open import FOTC.Base
open import FOTC.Data.Nat.List.Type
open import FOTC.Program.SortList.PropertiesATP
open import FOTC.Program.SortList.Properties.Totality.TreeATP
open import FOTC.Program.SortList.SortList
------------------------------------------------------------------------------
-- Main theorem: The sort program generates an ordered list.
postulate sortCorrect : ∀ {is} → ListN is → OrdList (sort is)
{-# ATP prove sortCorrect flatten-OrdList makeTree-Tree makeTree-OrdTree #-}
------------------------------------------------------------------------------
-- References
--
-- Burstall, R. M. (1969). Proving properties of programs by
-- structural induction. The Computer Journal 12.1, pp. 41–48.
| 40.78125
| 78
| 0.540996
|
398be791f0e705877464bf352e83caf8fc168743
| 67
|
agda
|
Agda
|
test/Fail/UnknownNameInFixityDecl.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/fail/UnknownNameInFixityDecl.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/fail/UnknownNameInFixityDecl.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
module UnknownNameInFixityDecl where
infix 40 _+_
infixr 60 _*_
| 9.571429
| 36
| 0.791045
|
1c07c86a8cf521a3443549b005f3728f98836e00
| 1,424
|
agda
|
Agda
|
theorems/homotopy/PropJoinProp.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
theorems/homotopy/PropJoinProp.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | null | null | null |
theorems/homotopy/PropJoinProp.agda
|
mikeshulman/HoTT-Agda
|
e7d663b63d89f380ab772ecb8d51c38c26952dbb
|
[
"MIT"
] | 1
|
2018-12-26T21:31:57.000Z
|
2018-12-26T21:31:57.000Z
|
{-# OPTIONS --without-K --rewriting #-}
open import HoTT
{- Proof that if [A] and [B] are two propositions, then so is [A * B]. -}
module homotopy.PropJoinProp
{i} {A : Type i} (pA : is-prop A)
{j} {B : Type j} (pB : is-prop B) where
contr-left : (a : A) → is-contr (A * B)
contr-left a = left a , Pushout-elim
(λ a' → ap left (prop-has-all-paths pA a a'))
(λ b' → glue (a , b'))
(λ {(a' , b') → ↓-cst=idf-in' $ ! $
↓-app=cst-out (apd (λ a → glue (a , b')) (prop-has-all-paths pA a a'))})
contr-right : (b : B) → is-contr (A * B)
contr-right b = right b , Pushout-elim
(λ a' → ! (glue (a' , b)))
(λ b' → ap right (prop-has-all-paths pB b b'))
(λ {(a' , b') → ↓-cst=idf-in' $
! (glue (a' , b)) ∙ glue (a' , b')
=⟨ ! (↓-cst=app-out' $ apd (λ b → glue (a' , b)) (prop-has-all-paths pB b b'))
|in-ctx ! (glue (a' , b)) ∙_ ⟩
! (glue (a' , b)) ∙ glue (a' , b) ∙ ap right (prop-has-all-paths pB b b')
=⟨ ! $ ∙-assoc (! (glue (a' , b))) (glue (a' , b)) (ap right (prop-has-all-paths pB b b')) ⟩
(! (glue (a' , b)) ∙ glue (a' , b)) ∙ ap right (prop-has-all-paths pB b b')
=⟨ !-inv-l (glue (a' , b)) |in-ctx _∙ ap right (prop-has-all-paths pB b b') ⟩
ap right (prop-has-all-paths pB b b')
=∎})
prop*prop-is-prop : is-prop (A * B)
prop*prop-is-prop = inhab-to-contr-is-prop $
Pushout-rec contr-left contr-right (λ _ → prop-has-all-paths is-contr-is-prop _ _)
| 39.555556
| 98
| 0.517556
|
1c91cdf988fe14c50e4e57426fcc5160fbedae3d
| 1,030
|
agda
|
Agda
|
src/Dodo/Binary/Flip.agda
|
sourcedennis/agda-dodo
|
376f0ccee1e1aa31470890e494bcb534324f598a
|
[
"BSD-3-Clause"
] | null | null | null |
src/Dodo/Binary/Flip.agda
|
sourcedennis/agda-dodo
|
376f0ccee1e1aa31470890e494bcb534324f598a
|
[
"BSD-3-Clause"
] | null | null | null |
src/Dodo/Binary/Flip.agda
|
sourcedennis/agda-dodo
|
376f0ccee1e1aa31470890e494bcb534324f598a
|
[
"BSD-3-Clause"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
module Dodo.Binary.Flip where
-- Stdlib imports
open import Level using (Level; _⊔_)
open import Function.Base using (flip)
open import Relation.Binary using (Rel; REL)
open import Relation.Binary using (Symmetric)
-- Local imports
open import Dodo.Binary.Equality
-- # Operations
-- ## Operations: ⊆₂
module _ {a b ℓ₁ ℓ₂ : Level} {A : Set a} {B : Set b}
{P : REL A B ℓ₁} {Q : REL A B ℓ₂} where
flip-⊆₂ : P ⊆₂ Q → flip P ⊆₂ flip Q
flip-⊆₂ (⊆: P⊆Q) = ⊆: (flip P⊆Q)
module _ {a ℓ₁ : Level} {A : Set a} {P : Rel A ℓ₁} where
flip-sym-⊆₂ : Symmetric P → P ⊆₂ flip P
flip-sym-⊆₂ symP = ⊆: (λ _ _ → symP)
-- ## Operations: ⇔₂
module _ {a b ℓ₁ ℓ₂ : Level} {A : Set a} {B : Set b}
{P : REL A B ℓ₁} {Q : REL A B ℓ₂} where
flip-⇔₂ : P ⇔₂ Q → flip P ⇔₂ flip Q
flip-⇔₂ = ⇔₂-compose flip-⊆₂ flip-⊆₂
module _ {a ℓ₁ : Level} {A : Set a} {P : Rel A ℓ₁} where
flip-sym-⇔₂ : Symmetric P → P ⇔₂ flip P
flip-sym-⇔₂ symP = ⇔₂-intro (flip-sym-⊆₂ symP) (flip-sym-⊆₂ symP)
| 23.409091
| 67
| 0.58932
|
cb3f8ef4cb8b33eda4dbd94d1319bf90dbd7d504
| 493
|
agda
|
Agda
|
test/Succeed/Issue2727-1.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue2727-1.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue2727-1.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
open import Agda.Builtin.Equality using (_≡_; refl)
record ⊤ : Set where
no-eta-equality
constructor tt
data Box (A : Set) : Set where
[_] : A → Box A
Unit : Set
Unit = Box ⊤
F : Unit → Set → Set
F [ _ ] x = x
G : {P : Unit → Set} → ((x : ⊤) → P [ x ]) → ((x : Unit) → P x)
G f [ x ] = f x
record R : Set₁ where
no-eta-equality
field
f : (x : Unit) → Box (F x ⊤)
data ⊥ : Set where
r : R
r = record { f = G [_] }
open R r
H : ⊥ → Set₁
H _ rewrite refl {x = tt} = Set
| 14.939394
| 63
| 0.521298
|
df90d73942af7797d1fc66d2d4786c8a5fcd1687
| 294
|
agda
|
Agda
|
test/Succeed/IgnoreWarnings.agda
|
zgrannan/agda
|
5953ce337eb6b77b29ace7180478f49c541aea1c
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/IgnoreWarnings.agda
|
zgrannan/agda
|
5953ce337eb6b77b29ace7180478f49c541aea1c
|
[
"BSD-3-Clause"
] | null | null | null |
test/Succeed/IgnoreWarnings.agda
|
zgrannan/agda
|
5953ce337eb6b77b29ace7180478f49c541aea1c
|
[
"BSD-3-Clause"
] | null | null | null |
module IgnoreWarnings where
-- all of the following files have warnings, which should be ignored
-- because of the command-line flag
import Issue2243
import Issue708quote
import OldCompilerPragmas
import RewritingEmptyPragma
import Unreachable
-- this should also be ignored
{-# REWRITE #-}
| 21
| 68
| 0.806122
|
d0e168068c0be7f0c3803fabc2ef853d5517ddf7
| 228
|
agda
|
Agda
|
test/Succeed/Issue3779.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue3779.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue3779.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
open import Agda.Builtin.Equality
variable
A B : Set
f g : A
postulate
F : Set → Set
map : (A → B) → F A → F B
lemma : (x : F A) → map (λ x → f (g x)) x ≡ map f (map g x) → F A
lemma {A = A} {f = f} {g = g} x _ = x
| 17.538462
| 65
| 0.491228
|
128fe84107a14d9e75be69bf0356938e0b1a91fb
| 407
|
agda
|
Agda
|
test/Succeed/Issue253.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue253.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue253.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --universe-polymorphism --allow-unsolved-metas #-}
module Issue253 where
open import Common.Level
data Id l (X : Set l)(x : X) : X → Set where
refl : Id l X x x
resp : (A B : Set _) → Id _ (Set _) A B → Set
resp _ _ eq with eq
resp ._ _ eq | refl = Level
{-
An internal error has occurred. Please report this as a bug.
Location of the error: src/full/Agda/TypeChecking/Telescope.hs:51
-}
| 23.941176
| 65
| 0.670762
|
dcd474bf834f389f776539f848f3a78ff5a73950
| 2,450
|
agda
|
Agda
|
prototyping/Luau/OpSem.agda
|
FreakingBarbarians/luau
|
5187e64f88953f34785ffe58acd0610ee5041f5f
|
[
"MIT"
] | 1
|
2022-02-11T21:30:17.000Z
|
2022-02-11T21:30:17.000Z
|
prototyping/Luau/OpSem.agda
|
FreakingBarbarians/luau
|
5187e64f88953f34785ffe58acd0610ee5041f5f
|
[
"MIT"
] | null | null | null |
prototyping/Luau/OpSem.agda
|
FreakingBarbarians/luau
|
5187e64f88953f34785ffe58acd0610ee5041f5f
|
[
"MIT"
] | null | null | null |
module Luau.OpSem where
open import Agda.Builtin.Equality using (_≡_)
open import FFI.Data.Maybe using (just)
open import Luau.Heap using (Heap; _≡_⊕_↦_; lookup; function_⟨_⟩_end)
open import Luau.Substitution using (_[_/_]ᴮ)
open import Luau.Syntax using (Expr; Stat; Block; nil; addr; var; function⟨_⟩_end; _$_; block_is_end; local_←_; _∙_; done; function_⟨_⟩_end; return)
open import Luau.Value using (addr; val)
data _⊢_⟶ᴮ_⊣_ : Heap → Block → Block → Heap → Set
data _⊢_⟶ᴱ_⊣_ : Heap → Expr → Expr → Heap → Set
data _⊢_⟶ᴱ_⊣_ where
nil : ∀ {H} →
-------------------
H ⊢ nil ⟶ᴱ nil ⊣ H
function : ∀ {H H′ a x B} →
H′ ≡ H ⊕ a ↦ (function "anon" ⟨ x ⟩ B end) →
-------------------------------------------
H ⊢ (function⟨ x ⟩ B end) ⟶ᴱ (addr a) ⊣ H′
app : ∀ {H H′ M M′ N} →
H ⊢ M ⟶ᴱ M′ ⊣ H′ →
-----------------------------
H ⊢ (M $ N) ⟶ᴱ (M′ $ N) ⊣ H′
beta : ∀ {H M a f x B} →
(lookup H a) ≡ just(function f ⟨ x ⟩ B end) →
-----------------------------------------------------
H ⊢ (addr a $ M) ⟶ᴱ (block f is local x ← M ∙ B end) ⊣ H
block : ∀ {H H′ B B′ b} →
H ⊢ B ⟶ᴮ B′ ⊣ H′ →
----------------------------------------------------
H ⊢ (block b is B end) ⟶ᴱ (block b is B′ end) ⊣ H′
return : ∀ {H V B b} →
--------------------------------------------------------
H ⊢ (block b is return (val V) ∙ B end) ⟶ᴱ (val V) ⊣ H
done : ∀ {H b} →
---------------------------------
H ⊢ (block b is done end) ⟶ᴱ nil ⊣ H
data _⊢_⟶ᴮ_⊣_ where
local : ∀ {H H′ x M M′ B} →
H ⊢ M ⟶ᴱ M′ ⊣ H′ →
-------------------------------------------------
H ⊢ (local x ← M ∙ B) ⟶ᴮ (local x ← M′ ∙ B) ⊣ H′
subst : ∀ {H x v B} →
-------------------------------------------------
H ⊢ (local x ← val v ∙ B) ⟶ᴮ (B [ v / x ]ᴮ) ⊣ H
function : ∀ {H H′ a f x B C} →
H′ ≡ H ⊕ a ↦ (function f ⟨ x ⟩ C end) →
--------------------------------------------------------------
H ⊢ (function f ⟨ x ⟩ C end ∙ B) ⟶ᴮ (B [ addr a / f ]ᴮ) ⊣ H′
return : ∀ {H H′ M M′ B} →
H ⊢ M ⟶ᴱ M′ ⊣ H′ →
--------------------------------------------
H ⊢ (return M ∙ B) ⟶ᴮ (return M′ ∙ B) ⊣ H′
data _⊢_⟶*_⊣_ : Heap → Block → Block → Heap → Set where
refl : ∀ {H B} →
----------------
H ⊢ B ⟶* B ⊣ H
step : ∀ {H H′ H″ B B′ B″} →
H ⊢ B ⟶ᴮ B′ ⊣ H′ →
H′ ⊢ B′ ⟶* B″ ⊣ H″ →
------------------
H ⊢ B ⟶* B″ ⊣ H″
| 26.344086
| 148
| 0.358776
|
06281ff4a3b24df6b720b8c6673f9ed66ec9906f
| 4,473
|
agda
|
Agda
|
archive/agda-3/src/Oscar/Class/Thickandthin.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
archive/agda-3/src/Oscar/Class/Thickandthin.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | 1
|
2019-04-29T00:35:04.000Z
|
2019-05-11T23:33:04.000Z
|
archive/agda-3/src/Oscar/Class/Thickandthin.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
open import Oscar.Prelude
open import Oscar.Class.Successor₀
open import Oscar.Class.Successor₁
open import Oscar.Class.Injectivity
open import Oscar.Class.Pure
module Oscar.Class.Thickandthin where
module _
{x} {X : Ø x} {a} (A : X → Ø a) {b} (B : X → Ø b)
where
record [𝓣hin] : Ø₀ where
no-eta-equality
constructor ∁
module _
⦃ _ : 𝓢uccessor₀ X ⦄
where
𝔱hin : ∀ (m : X) → A (⇑₀ m) → B m → Ø b
𝔱hin m = λ _ _ → B (⇑₀ m)
𝓽hin = ∀ {m : X} → A (⇑₀ m) → B m → B (⇑₀ m)
record 𝓣hin ⦃ _ : [𝓣hin] ⦄ : Ø x ∙̂ a ∙̂ b where
field
thin : 𝓽hin
instance `𝓘njection₂ : ∀ {m} → 𝓘njection₂ (𝔱hin m)
`𝓘njection₂ = ∁ thin
open 𝓣hin ⦃ … ⦄ public
module _
{x} {X : Ø x} {a} (A : X → Ø a) {b} (B : X → Ø b)
where
record [𝓣hick] : Ø₀ where
no-eta-equality
constructor ∁
module _
⦃ _ : 𝓢uccessor₀ X ⦄
where
𝓽hick = ∀ {m} → A m → B (⇑₀ m) → B m
record 𝓣hick ⦃ _ : [𝓣hick] ⦄ : Ø x ∙̂ a ∙̂ b where field thick : 𝓽hick
open 𝓣hick ⦃ … ⦄ public
module _
{x} {X : Ø x}
{a} (A : X → Ø a)
{b} (B : X → Ø b)
{ℓ} (_≈_ : ∀ {x} → B x → B x → Ø ℓ)
where
record [𝓣hick/thin=1] : Ø₀ where
no-eta-equality
constructor ∁
module _
⦃ _ : 𝓢uccessor₀ X ⦄
⦃ _ : [𝓢uccessor₁] A ⦄
⦃ _ : 𝓢uccessor₁ A ⦄
⦃ _ : [𝓣hin] A B ⦄
⦃ _ : 𝓣hin A B ⦄
⦃ _ : [𝓣hick] A B ⦄
⦃ _ : 𝓣hick A B ⦄
where
𝓽hick/thin=1 = ∀ {m} (x : A m) (y : B m) → thick x (thin (⇑₁ x) y) ≈ y
record 𝓣hick/thin=1 : Ø x ∙̂ a ∙̂ b ∙̂ ℓ where field thick/thin=1 : 𝓽hick/thin=1
open 𝓣hick/thin=1 ⦃ … ⦄ public
module _
{x} {X : Ø x}
{a} (A : X → Ø a)
{b} (B : X → Ø b)
{c} (C : Ø b → Ø c)
where
record [𝓒heck] : Ø₀ where
no-eta-equality
constructor ∁
module _
⦃ _ : 𝓢uccessor₀ X ⦄
where
𝓬heck = ∀ {m} → A (⇑₀ m) → B (⇑₀ m) → C (B m)
record 𝓒heck ⦃ _ : [𝓒heck] ⦄ : Ø x ∙̂ a ∙̂ b ∙̂ c where field check : 𝓬heck
open 𝓒heck ⦃ … ⦄ public
check[_] : ∀
{x} {X : Ø x}
{a} {A : X → Ø a}
{b} {B : X → Ø b}
{c} (C : Ø b → Ø c)
⦃ _ : [𝓒heck] A B C ⦄
⦃ _ : 𝓢uccessor₀ X ⦄
⦃ _ : 𝓒heck A B C ⦄
→ 𝓬heck A B C
check[ _ ] = check
module _
{x} {X : Ø x}
{a} (A : X → Ø a)
{b} (B : X → Ø b)
{c} (C : Ø b → Ø c)
{ℓ} (_≈_ : ∀ {x} → C (B x) → C (B x) → Ø ℓ)
where
record [𝓒heck/thin=1] : Ø₀ where
no-eta-equality
constructor ∁
module _
⦃ _ : 𝓢uccessor₀ X ⦄
⦃ _ : [𝓣hin] A B ⦄
⦃ _ : 𝓣hin A B ⦄
⦃ _ : [𝓒heck] A B C ⦄
⦃ _ : 𝓒heck A B C ⦄
⦃ _ : 𝓟ure C ⦄
where
𝓬heck/thin=1 = ∀ {n} (x : A (⇑₀ n)) (y : B n) → check x (thin x y) ≈ pure y
record 𝓒heck/thin=1 ⦃ _ : [𝓒heck/thin=1] ⦄ : Ø x ∙̂ a ∙̂ b ∙̂ c ∙̂ ℓ where field check/thin=1 : 𝓬heck/thin=1
open 𝓒heck/thin=1 ⦃ … ⦄ public
check/thin=1[_] : ∀
{x} {X : Ø x}
{a} {A : X → Ø a}
{b} {B : X → Ø b}
{c} {C : Ø b → Ø c}
{ℓ} (_≈_ : ∀ {x} → C (B x) → C (B x) → Ø ℓ)
⦃ _ : 𝓢uccessor₀ X ⦄
⦃ _ : [𝓣hin] A B ⦄
⦃ _ : 𝓣hin A B ⦄
⦃ _ : [𝓒heck] A B C ⦄
⦃ _ : 𝓒heck A B C ⦄
⦃ _ : 𝓟ure C ⦄
⦃ _ : [𝓒heck/thin=1] A B C _≈_ ⦄
⦃ _ : 𝓒heck/thin=1 A B C _≈_ ⦄
→ 𝓬heck/thin=1 A B C _≈_
check/thin=1[ _ ] = check/thin=1
record IsThickandthin
{x a b c ℓb ℓc}
{X : Ø x}
(A : X → Ø a)
(B : X → Ø b)
(_≈B_ : ∀ {x} → B x → B x → Ø ℓb)
(C : Ø b → Ø c)
(_≈C_ : ∀ {x} → C (B x) → C (B x) → Ø ℓc)
: Ø x ∙̂ a ∙̂ ↑̂ b ∙̂ ℓb ∙̂ c ∙̂ ℓc where
constructor ∁
field
overlap ⦃ `𝓢uccessor₀ ⦄ : 𝓢uccessor₀ X
overlap ⦃ `[𝓢uccessor₁] ⦄ : [𝓢uccessor₁] A
overlap ⦃ `𝓢uccessor₁ ⦄ : 𝓢uccessor₁ A
overlap ⦃ `[𝓣hick] ⦄ : [𝓣hick] A B
overlap ⦃ `𝓣hick ⦄ : 𝓣hick A B
overlap ⦃ `[𝓣hin] ⦄ : [𝓣hin] A B
overlap ⦃ `𝓣hin ⦄ : 𝓣hin A B
overlap ⦃ `[𝓘njectivity₂,₁] ⦄ : ∀ {m} → [𝓘njectivity₂,₁] (𝔱hin A B m) _≈B_ _≈B_
overlap ⦃ `𝓘njectivity₂,₁ ⦄ : ∀ {m} → 𝓘njectivity₂,₁ (𝔱hin A B m) _≈B_ _≈B_
overlap ⦃ `[𝓒heck] ⦄ : [𝓒heck] A B C
overlap ⦃ `𝓒heck ⦄ : 𝓒heck A B C
overlap ⦃ `[𝓣hick/thin=1] ⦄ : [𝓣hick/thin=1] A B _≈B_
overlap ⦃ `𝓣hick/thin=1 ⦄ : 𝓣hick/thin=1 A B _≈B_
overlap ⦃ `[𝓒heck/thin=1] ⦄ : [𝓒heck/thin=1] A B C _≈C_
overlap ⦃ `𝓟ure ⦄ : 𝓟ure C
overlap ⦃ `𝓒heck/thin=1 ⦄ : 𝓒heck/thin=1 A B C _≈C_
record Thickandthin x a b ℓb c ℓc : Ø ↑̂ (x ∙̂ a ∙̂ b ∙̂ ℓb ∙̂ c ∙̂ ℓc) where
constructor ∁
field
{X} : Ø x
A : X → Ø a
B : X → Ø b
_≈B_ : ∀ {x} → B x → B x → Ø ℓb
C : Ø b → Ø c
_≈C_ : ∀ {x} → C (B x) → C (B x) → Ø ℓc
⦃ `IsThickandthin ⦄ : IsThickandthin A B _≈B_ C _≈C_
| 26.625
| 112
| 0.484239
|
cb9a12dafe1220a44931aa8fda459e474b29705f
| 11,400
|
agda
|
Agda
|
agda/Syntax.agda
|
agda/agda-spec
|
7ef5f2fd8057b27fd3bc9d171283ccaeceec9c79
|
[
"Unlicense"
] | 24
|
2017-05-09T12:25:36.000Z
|
2021-08-15T09:09:08.000Z
|
agda/Syntax.agda
|
agda/agda-spec
|
7ef5f2fd8057b27fd3bc9d171283ccaeceec9c79
|
[
"Unlicense"
] | 4
|
2017-05-12T12:33:48.000Z
|
2019-01-13T13:00:20.000Z
|
agda/Syntax.agda
|
agda/agda-spec
|
7ef5f2fd8057b27fd3bc9d171283ccaeceec9c79
|
[
"Unlicense"
] | 3
|
2017-05-11T10:44:08.000Z
|
2022-03-12T11:40:50.000Z
|
-- TODO: use StrictTotalOrder for QName representation
module Syntax (QName : Set) where
open import Data.Nat.Base
open import Data.Nat.Properties using (+-suc; +-identityʳ)
open import Data.List.Base hiding (_∷ʳ_)
open import Relation.Binary.PropositionalEquality using (_≡_; refl; cong; sym; trans)
-- Well-scoped de Bruijn indices
-- n is the length of the context
data Var : ℕ → Set where
vzero : ∀{n} → Var (suc n)
vsuc : ∀{n} (x : Var n) → Var (suc n)
-- Example: in context x,y,z (so n = 3)
-- x is vsuc (vsuc vzero) : Var 3
-- y is vsuc vzero : Var 3
-- z is vzero : Var 3
-- Qualified names
DRName = QName -- datatype / record name
FuncName = QName -- function name
ProjName = QName -- projection name (overloaded)
ConsName = QName -- datatype / record constructor name (overloaded)
-- Data or record constructors
data ConHead : Set where
dataCon : DRName → ConHead
recCon : DRName → (fs : List ProjName) → ConHead
-- Sorts are Set₀, Set₁, ...
data Sort : Set where
uni : (ℓ : ℕ) → Sort
-- In the following definition of well-scoped syntax,
-- n is always the length of the context.
mutual
data Term (n : ℕ) : Set where
var : (x : Var n) (es : Elims n) → Term n
def : (f : FuncName) (es : Elims n) → Term n
con : (c : ConHead) (vs : Args n) → Term n -- Fully applied
lam : (v : Term (suc n)) → Term n
-- Types
dat : (d : DRName) (vs : Args n) → Term n -- Fully applied
sort : (s : Sort) → Term n
pi : (u : Term n) (v : Term (suc n)) → Term n
data Elim (n : ℕ) : Set where
apply : (u : Term n) → Elim n
proj : (π : ProjName) → Elim n
Elims : (n : ℕ) → Set
Elims n = List (Elim n)
Args : (n : ℕ) → Set
Args n = List (Term n)
-- Example: (A : Set) (x : A) → A
-- is represented by
exTyId : Term 0
exTyId = pi (sort (uni 0)) (pi (var vzero []) (var (vsuc vzero) []))
-- Looking up a field in a field-value collection
-- TODO: Do we want to ensure |fs| = |vs| ?
data LookupField {a} {A : Set a} : (fs : List ProjName) (vs : List A) (f : ProjName) (v : A) → Set where
here : ∀{f fs v vs}
→ LookupField (f ∷ fs) (v ∷ vs) f v
there : ∀{f f' fs v v' vs}
→ LookupField fs vs f v
→ LookupField (f' ∷ fs) (v' ∷ vs) f v
-- Renamings represented as functions
Renaming : (Γ Δ : ℕ) → Set
Renaming Γ Δ = Var Δ → Var Γ
weak : ∀{Γ} → Renaming (suc Γ) Γ
weak x = vsuc x
-- If Γ ⊢ ρ : Δ
-- then Γ,x ⊢ liftRen ρ : Δ,x.
liftRen : ∀{Γ Δ} → Renaming Γ Δ → Renaming (suc Γ) (suc Δ)
liftRen ρ vzero = vzero
liftRen ρ (vsuc x) = vsuc (ρ x)
-- We need sized types to show termination of rename.
{-# TERMINATING #-}
mutual
rename : ∀{Γ Δ} (ρ : Renaming Γ Δ) (t : Term Δ) → Term Γ
rename ρ (var x es) = var (ρ x) (map (renameElim ρ) es)
rename ρ (def f es) = def f (map (renameElim ρ) es)
rename ρ (con c vs) = con c (map (rename ρ) vs)
rename ρ (lam t) = lam (rename (liftRen ρ) t)
rename ρ (dat d vs) = dat d (map (rename ρ) vs)
rename ρ (sort s) = sort s
rename ρ (pi u v) = pi (rename ρ u) (rename (liftRen ρ) v)
renameElim : ∀{Γ Δ} (ρ : Renaming Γ Δ) (e : Elim Δ) → Elim Γ
renameElim ρ (apply u) = apply (rename ρ u)
renameElim ρ (proj π) = proj π
-- Substitutions represented as functions
-- σ : Subst Γ Δ applies to a term living in context Δ
-- and turns it into a term living in context Γ
Substitution : (Γ Δ : ℕ) → Set
Substitution Γ Δ = Var Δ → Term Γ
liftSub : ∀{Γ Δ} (σ : Substitution Γ Δ) → Substitution (suc Γ) (suc Δ)
liftSub σ vzero = var vzero []
liftSub σ (vsuc x) = rename weak (σ x)
-- Substitute for the last variable (vzero)
sg : ∀{Γ} (u : Term Γ) → Substitution Γ (suc Γ)
sg {Γ} u vzero = u
sg {Γ} u (vsuc x) = var x []
data All₂ {A B : Set} (R : A → B → Set) : List A → List B → Set where
nil : All₂ R [] []
cons : ∀{x y xs ys}
→ R x y
→ All₂ R xs ys
→ All₂ R (x ∷ xs) (y ∷ ys)
mutual
data Apply {Γ} : (t : Term Γ) (es : Elims Γ) (v : Term Γ) → Set where
empty : ∀{t}
→ Apply t [] t
var : ∀{x es es'}
→ Apply (var x es) es' (var x (es ++ es'))
def : ∀{f es es'}
→ Apply (def f es) es' (def f (es ++ es'))
proj : ∀{ c πs vs π es u v}
→ LookupField πs vs π u
→ Apply u es v
→ Apply (con (recCon c πs) vs) (proj π ∷ es) v
lam : ∀{t t' u v es}
→ SubstTerm (sg u) t t'
→ Apply t' es v
→ Apply (lam t) (apply u ∷ es) v
data SubstTerm {Γ Δ} (σ : Substitution Γ Δ) : Term Δ → Term Γ → Set where
var : ∀{x : Var Δ} {es : Elims Δ} {v : Term Γ} {es' : Elims Γ}
→ All₂ (SubstElim σ) es es'
→ Apply (σ x) es' v
→ SubstTerm σ (var x es) v
def : ∀{f : FuncName} {es : Elims Δ} {es' : Elims Γ}
→ All₂ (SubstElim σ) es es'
→ SubstTerm σ (def f es) (def f es')
con : ∀{c : ConHead} {vs : Args Δ} {vs' : Args Γ}
→ All₂ (SubstTerm σ) vs vs'
→ SubstTerm σ (con c vs) (con c vs')
lam : ∀{v : Term (suc Δ)} {v'}
→ SubstTerm (liftSub σ) v v'
→ SubstTerm σ (lam v) (lam v')
dat : ∀{d : DRName} {vs : Args Δ} {vs' : Args Γ}
→ All₂ (SubstTerm σ) vs vs'
→ SubstTerm σ (dat d vs) (dat d vs')
pi : ∀{U V U' V'}
→ SubstTerm σ U U'
→ SubstTerm (liftSub σ) V V'
→ SubstTerm σ (pi U V) (pi U' V')
sort : ∀{s : Sort}
→ SubstTerm σ (sort s) (sort s)
data SubstElim {Γ Δ} (σ : Substitution Γ Δ) : Elim Δ → Elim Γ → Set where
apply : ∀{u u'}
→ SubstTerm σ u u'
→ SubstElim σ (apply u) (apply u')
proj : ∀{π}
→ SubstElim σ (proj π) (proj π)
data FunctionApply {Γ} : (T : Term Γ) (us : Args Γ) (U : Term Γ) → Set where
empty : ∀{T}
→ FunctionApply T [] T
pi : ∀{u us T U V V'}
→ SubstTerm (sg u) V V'
→ FunctionApply V' us T
→ FunctionApply (pi U V) (u ∷ us) T
-- n is the length of the context
data Context : (n : ℕ) → Set where
[] : Context zero
_∷ʳ_ : ∀{n} → Context n → Term n → Context (suc n)
-- n is the size of the outer context; m is the size of the telescope
data Telescope (n : ℕ) : (m : ℕ) → Set where
[] : Telescope n zero
_∷_ : ∀{m} → Term n → Telescope (suc n) m → Telescope n (suc m)
telescopeSize : ∀{n m} → Telescope n m → ℕ
telescopeSize {m = m} _ = m
suc-move : (m n : ℕ) → m + suc n ≡ suc m + n
suc-move zero n = refl
suc-move (suc m) n = cong suc (+-suc m n)
-- Add a telescope to a compatible outer context.
addToContext : ∀{n m} → Context n → Telescope n m → Context (n + m)
addToContext {n} Γ [] rewrite +-identityʳ n = Γ
addToContext {n} {.(suc m)} Γ (_∷_ {m = m} x t) rewrite suc-move n m = addToContext (Γ ∷ʳ x) t
expandTelescope : ∀ {n m} → Telescope n m → Term (n + m) → Term n
expandTelescope {n} [] T rewrite +-identityʳ n = T
expandTelescope {n} {suc m} (U ∷ Δ) T rewrite suc-move n m =
pi U (expandTelescope Δ T)
data Pattern (n : ℕ) : Set where
pvariable : Var n → Pattern n
pconstructor : ConsName → List (Pattern n) → Pattern n
pinaccesssible : Term n → Pattern n
data Copattern (n : ℕ) : Set where
capply : Pattern n → Copattern n
cproj : ProjName → Copattern n
record ConsDeclaration (n : ℕ) : Set where
constructor mkConsDeclaration
field
consName : ConsName
consType : Term n
record ProjDeclaration (n : ℕ) : Set where
constructor mkProjDeclaration
field
projName : ProjName
projType : Term n
record DataSignature : Set where
constructor mkDataSignature
field
name : DRName
{numParams} : ℕ
{numIndices} : ℕ
params : Telescope zero numParams
indices : Telescope numParams numIndices
dsort : Sort
record DataDefinition : Set where
field
name : DRName
{numParams} : ℕ
params : Telescope zero numParams
constructors : List (ConsDeclaration numParams)
record RecordSignature : Set where
constructor mkRecordSignature
field
name : DRName
{numParams} : ℕ
params : Telescope zero numParams
dsort : Sort
record RecordDefinition : Set where
field
name : DRName
{numParams} : ℕ
params : Telescope zero numParams
fconstructor : ConsName
fields : List (ProjDeclaration numParams)
-- TODO: Update spec
record FuncClause : Set where
field
ctxSize : ℕ
ctx : Context ctxSize
name : FuncName
spine : List (Copattern ctxSize)
rhs : Term ctxSize
-- TODO: How to represent pattern variables?
data Declaration : Set where
typeSignature : FuncName → Term zero → Declaration
functionClause : FuncClause → Declaration
dataSignature : DataSignature → Declaration
dataDefinition : DataDefinition → Declaration
recordSignature : RecordSignature → Declaration
recordDefinition : RecordDefinition → Declaration
-- TODO: Update signature declarations
data SignatureDeclaration : Set where
dataSig : (D : DataSignature) → List (ConsDeclaration (DataSignature.numParams D)) →
SignatureDeclaration
recordSig : (R : RecordSignature) → ConsDeclaration (RecordSignature.numParams R) →
List (ProjDeclaration (RecordSignature.numParams R)) → SignatureDeclaration
functionSig : FuncName → Term zero → List FuncClause → SignatureDeclaration
Signature : Set
Signature = List SignatureDeclaration
data LookupSig : Signature → SignatureDeclaration → Set where
here : ∀{sd sds}
→ LookupSig (sd ∷ sds) sd
there : ∀{sd sd' sds}
→ LookupSig sds sd
→ LookupSig (sd' ∷ sds) sd
data LookupCons : ∀{m} → List (ConsDeclaration m) → ConsName → Term m → Set where
here : ∀{c m} {T : Term m} {cs : List (ConsDeclaration m)}
→ LookupCons {m} (mkConsDeclaration c T ∷ cs) c T
there : ∀{c c' m} {T : Term m} {T' : Term m} {cs : List (ConsDeclaration m)}
→ LookupCons cs c T
→ LookupCons (mkConsDeclaration c' T' ∷ cs) c T
data LookupProj : ∀{m} → List (ProjDeclaration m) → ProjName → Term m → Set where
here : ∀{π m} {T : Term m} {πs : List (ProjDeclaration m)}
→ LookupProj (mkProjDeclaration π T ∷ πs) π T
there : ∀ {π π' m} {πs : List (ProjDeclaration m)} {T : Term m} {T' : Term m}
→ LookupProj πs π T
→ LookupProj (mkProjDeclaration π' T' ∷ πs) π T
data SigLookup : ∀{m} → Signature → QName → Term m → Set where
func : ∀{Σ f T cls} → LookupSig Σ (functionSig f T cls) → SigLookup Σ f T
dat : ∀{Σ D m m' s cs} {Δ : Telescope zero m} {Δ' : Telescope m m'} →
LookupSig Σ (dataSig (mkDataSignature D {m} {m'} Δ Δ' s) cs) →
SigLookup Σ D (expandTelescope Δ (expandTelescope Δ' (sort s)))
con : ∀{Σ D m m' s cs c T} {Δ : Telescope zero m} {Δ' : Telescope m m'} →
LookupSig Σ (dataSig (mkDataSignature D {m} {m'} Δ Δ' s) cs) →
LookupCons cs c T →
SigLookup Σ c (expandTelescope Δ T)
rec : ∀{Σ R m s c ps} {Δ : Telescope zero m} →
LookupSig Σ (recordSig (mkRecordSignature R Δ s) c ps) →
SigLookup Σ R (expandTelescope Δ (sort s))
rcon : ∀{Σ R m s c T πs} {Δ : Telescope zero m} →
LookupSig Σ (recordSig (mkRecordSignature R Δ s) (mkConsDeclaration c T) πs) →
SigLookup Σ c (expandTelescope Δ T)
rproj : ∀{Σ R m s c π T πs} {Δ : Telescope zero m} →
LookupSig Σ (recordSig (mkRecordSignature R Δ s) (mkConsDeclaration c T) πs) →
LookupProj πs π T →
SigLookup Σ π (expandTelescope Δ T)
| 30.894309
| 104
| 0.593333
|
cb5a3be9fb4d595ad18327e46cb885b084cf6247
| 2,943
|
agda
|
Agda
|
Perm.agda
|
pigworker/InteriorDesign
|
454cdd18f56db0b0d1643a1fcf36951b5ece395c
|
[
"BSD-3-Clause"
] | 6
|
2018-06-18T15:25:39.000Z
|
2018-07-31T02:00:13.000Z
|
Perm.agda
|
pigworker/InteriorDesign
|
454cdd18f56db0b0d1643a1fcf36951b5ece395c
|
[
"BSD-3-Clause"
] | null | null | null |
Perm.agda
|
pigworker/InteriorDesign
|
454cdd18f56db0b0d1643a1fcf36951b5ece395c
|
[
"BSD-3-Clause"
] | null | null | null |
module Perm where
open import Basics
open import All
open import Splitting
data _~_ {X : Set} : List X -> List X -> Set where
[] : [] ~ []
_,-_ : forall {x xs ys zs} -> (x ,- []) <[ ys ]> zs -> xs ~ zs -> (x ,- xs) ~ ys
permute : {X : Set}{xs ys : List X} -> xs ~ ys ->
{P : X -> Set} -> All P xs -> All P ys
permute [] <> = <>
permute (i ,- is) (p , ps) = riffle i (p , <>) (permute is ps)
reflP : {X : Set}(xs : List X) -> xs ~ xs
reflP [] = []
reflP (x ,- xs) = sl (srs xs) ,- reflP xs
insP : forall {X : Set}{x : X}{xs xs' ys ys'} -> (x ,- []) <[ xs' ]> xs -> (x ,- []) <[ ys' ]> ys
-> xs ~ ys -> xs' ~ ys'
insP (sl i) j p with isSRS i
insP (sl .(srs _)) j p | mkSRS = j ,- p
insP (sr i) j (k ,- p) =
let _ , k' , j' = llswap (_ , j , k)
in k' ,- insP i j' p
l2r : forall {X : Set}{x : X}{xs xs' ys'}(i : (x ,- []) <[ xs' ]> xs)(p' : xs' ~ ys') ->
Sg (List X) \ ys -> Sg ((x ,- []) <[ ys' ]> ys) \ j -> xs ~ ys
l2r (sl i) (j ,- p) with isSRS i
l2r (sl .(srs _)) (j ,- p) | mkSRS = _ , j , p
l2r (sr i) (k' ,- p') with l2r i p'
... | _ , j' , p with llswap (_ , k' , j')
... | _ , j , k = _ , j , (k ,- p)
transP : {X : Set}{xs ys zs : List X} -> xs ~ ys -> ys ~ zs -> xs ~ zs
transP [] [] = []
transP (i ,- p) q' with l2r i q'
... | _ , j , q = j ,- transP p q
symP : {X : Set}{xs ys : List X} -> xs ~ ys -> ys ~ xs
symP [] = []
symP (i ,- p) = insP i (sl (srs _)) (symP p)
swapP : {X : Set}(xs ys : List X) -> (xs +L ys) ~ (ys +L xs)
swapP [] ys rewrite ys +L[] = reflP ys
swapP (x ,- xs) ys = insS ys x xs ,- swapP xs ys
catP : forall {X : Set}{as bs cs ds : List X} -> as ~ cs -> bs ~ ds -> (as +L bs) ~ (cs +L ds)
catP [] q = q
catP (x ,- p) q = catS x (srs _) ,- catP p q
permap : forall {X Y}(f : X -> Y){xs xs' : List X} -> xs ~ xs' -> list f xs ~ list f xs'
permap f [] = []
permap f (x ,- p) = splimap f x ,- permap f p
cartNil : forall {I}(is : List I){J} -> cart {J = J} is [] == []
cartNil [] = refl []
cartNil (i ,- is) = cartNil is
cartCons : forall {I J}(is : List I)(j : J)(js : List J) ->
cart is (j ,- js) ~ (list (_, j) is +L cart is js)
cartCons [] j js = []
cartCons (i ,- is) j js with catP (swapP (list (i ,_) js) (list (_, j) is)) (reflP (cart is js))
... | z rewrite assoc+L (list (i ,_) js) (list (_, j) is) (cart is js)
| assoc+L (list (_, j) is) (list (i ,_) js) (cart is js)
=
(sl (srs (list (_, j) is +L cart (i ,- is) js))) ,-
transP (catP (reflP (list (i ,_) js)) (cartCons is j js))
z
cartLemma : forall {I J}(is : List I)(js : List J) ->
cart is js ~ list swap (cart js is)
cartLemma {I}{J} [] js rewrite cartNil js {I} = []
cartLemma {I}{J} (i ,- is) js with catP (reflP (list (i ,_) js)) (cartLemma is js)
... | z rewrite sym (listlist swap (_, i) (i ,_) (\ j -> refl (i , j)) js)
| catNatural swap (list (_, i) js) (cart js is)
= transP
z
(symP (permap (\ ji -> snd ji , fst ji) (cartCons js i is)))
| 36.333333
| 97
| 0.475025
|
20a8a69b21353c71663d8e3e00ef2e7db10a4920
| 6,164
|
agda
|
Agda
|
bool-thms2.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 29
|
2019-02-06T13:09:31.000Z
|
2022-03-04T15:05:12.000Z
|
bool-thms2.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 8
|
2018-07-09T22:53:38.000Z
|
2022-03-22T03:43:34.000Z
|
bool-thms2.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 17
|
2018-12-03T22:38:15.000Z
|
2021-11-28T20:13:21.000Z
|
module bool-thms2 where
open import bool
open import eq
open import product
open import sum
ff-imp : ∀ (b : 𝔹) → ff imp b ≡ tt
ff-imp ff = refl
ff-imp tt = refl
imp-tt : ∀ (b : 𝔹) → b imp tt ≡ tt
imp-tt ff = refl
imp-tt tt = refl
imp-ff : ∀ (b : 𝔹) → b imp ff ≡ ~ b
imp-ff tt = refl
imp-ff ff = refl
tt-imp : ∀ (b : 𝔹) → tt imp b ≡ b
tt-imp tt = refl
tt-imp ff = refl
&&-tt : ∀ (b : 𝔹) → b && tt ≡ b
&&-tt tt = refl
&&-tt ff = refl
||-ff : ∀ (b : 𝔹) → b || ff ≡ b
||-ff tt = refl
||-ff ff = refl
&&-contra : ∀ (b : 𝔹) → b && ~ b ≡ ff
&&-contra ff = refl
&&-contra tt = refl
&&-comm : ∀ (b1 b2 : 𝔹) → b1 && b2 ≡ b2 && b1
&&-comm ff ff = refl
&&-comm ff tt = refl
&&-comm tt ff = refl
&&-comm tt tt = refl
||-comm : ∀ (b1 b2 : 𝔹) → b1 || b2 ≡ b2 || b1
||-comm ff ff = refl
||-comm ff tt = refl
||-comm tt ff = refl
||-comm tt tt = refl
&&-assoc : ∀ (b1 b2 b3 : 𝔹) → b1 && (b2 && b3) ≡ (b1 && b2) && b3
&&-assoc ff _ _ = refl
&&-assoc tt _ _ = refl
||-assoc : ∀ (b1 b2 b3 : 𝔹) → b1 || (b2 || b3) ≡ (b1 || b2) || b3
||-assoc tt _ _ = refl
||-assoc ff _ _ = refl
~-over-&& : ∀ (b1 b2 : 𝔹) → ~ ( b1 && b2 ) ≡ (~ b1 || ~ b2)
~-over-&& tt _ = refl
~-over-&& ff _ = refl
~-over-|| : ∀ (b1 b2 : 𝔹) → ~ ( b1 || b2 ) ≡ (~ b1 && ~ b2)
~-over-|| tt _ = refl
~-over-|| ff _ = refl
&&-over-||-l : ∀ (a b c : 𝔹) → a && (b || c) ≡ (a && b) || (a && c)
&&-over-||-l tt _ _ = refl
&&-over-||-l ff _ _ = refl
&&-over-||-r : ∀ (a b c : 𝔹) → (a || b) && c ≡ (a && c) || (b && c)
&&-over-||-r tt tt tt = refl
&&-over-||-r tt tt ff = refl
&&-over-||-r tt ff tt = refl
&&-over-||-r tt ff ff = refl
&&-over-||-r ff tt tt = refl
&&-over-||-r ff tt ff = refl
&&-over-||-r ff ff tt = refl
&&-over-||-r ff ff ff = refl
||-over-&&-l : ∀ (a b c : 𝔹) → a || (b && c) ≡ (a || b) && (a || c)
||-over-&&-l tt _ _ = refl
||-over-&&-l ff _ _ = refl
||-over-&&-r : ∀ (a b c : 𝔹) → (a && b) || c ≡ (a || c) && (b || c)
||-over-&&-r tt _ _ = refl
||-over-&&-r ff _ ff = refl
||-over-&&-r ff tt tt = refl
||-over-&&-r ff ff tt = refl
&&-cong₁ : ∀ {b1 b1' b2 : 𝔹} → b1 ≡ b1' → b1 && b2 ≡ b1' && b2
&&-cong₁ refl = refl
&&-cong₂ : ∀ {b1 b2 b2' : 𝔹} → b2 ≡ b2' → b1 && b2 ≡ b1 && b2'
&&-cong₂ refl = refl
&&-intro : ∀ {b1 b2 : 𝔹} → b1 ≡ tt → b2 ≡ tt → b1 && b2 ≡ tt
&&-intro{tt}{tt} _ _ = refl
&&-intro{tt}{ff} _ ()
&&-intro{ff}{tt} () _
&&-intro{ff}{ff} () _
||-intro1 : ∀ {b1 b2 : 𝔹} → b1 ≡ tt → b1 || b2 ≡ tt
||-intro1 {tt} p = refl
||-intro1 {ff} ()
&&-elim : ∀ {b1 b2 : 𝔹} → b1 && b2 ≡ tt → b1 ≡ tt ∧ b2 ≡ tt
&&-elim{tt}{tt} _ = refl , refl
&&-elim{ff}{_} ()
&&-elim{tt}{ff} ()
&&-elim1 : ∀ {b1 b2 : 𝔹} → b1 && b2 ≡ tt → b1 ≡ tt
&&-elim1 p with &&-elim p
&&-elim1 _ | p , _ = p
&&-elim2 : ∀ {b1 b2 : 𝔹} → b1 && b2 ≡ tt → b2 ≡ tt
&&-elim2{b1} p with &&-elim{b1} p
&&-elim2 _ | _ , p = p
||-elim : ∀ {b1 b2 : 𝔹} → b1 || b2 ≡ tt → b1 ≡ tt ∨ b2 ≡ tt
||-elim {tt} refl = inj₁ refl
||-elim {ff} refl = inj₂ refl
~-cong : ∀ {b b' : 𝔹} → b ≡ b' → ~ b ≡ ~ b'
~-cong refl = refl
ite-cong₁ : ∀{ℓ}{A : Set ℓ} {b b' : 𝔹}(x y : A) → b ≡ b' → (if b then x else y) ≡ (if b' then x else y)
ite-cong₁ x y refl = refl
ite-cong₂ : ∀{ℓ}{A : Set ℓ} (b : 𝔹){x x' : A}(y : A) → x ≡ x' → (if b then x else y) ≡ (if b then x' else y)
ite-cong₂ b y refl = refl
ite-cong₃ : ∀{ℓ}{A : Set ℓ} (b : 𝔹)(x : A){y y' : A} → y ≡ y' → (if b then x else y) ≡ (if b then x else y')
ite-cong₃ b x refl = refl
&&-split : ∀ {b b' : 𝔹} → b || b' ≡ ff → b ≡ ff ⊎ b' ≡ ff
&&-split {tt} ()
&&-split {ff}{tt} ()
&&-split {ff}{ff} p = inj₁ refl
-----------------------------------
-- Theorems about imp
-----------------------------------
imp-same : ∀ (b : 𝔹) → b imp b ≡ tt
imp-same ff = refl
imp-same tt = refl
imp-to-|| : ∀ (b1 b2 : 𝔹) → (b1 imp b2) ≡ (~ b1 || b2)
imp-to-|| ff _ = refl
imp-to-|| tt _ = refl
imp-mp : ∀ {b b' : 𝔹} → b imp b' ≡ tt → b ≡ tt → b' ≡ tt
imp-mp {tt} {tt} p refl = refl
imp-mp {ff} {ff} p q = q
imp-mp {tt} {ff} p q = p
imp-mp {ff} {tt} p q = refl
imp-antisymm : ∀ {b1 b2 : 𝔹} → b1 imp b2 ≡ tt → b2 imp b1 ≡ tt → b1 ≡ b2
imp-antisymm{tt}{tt} p q = refl
imp-antisymm{tt}{ff} () q
imp-antisymm{ff}{tt} p ()
imp-antisymm{ff}{ff} p q = refl
-----------------------------------
-- Theorems about xor
-----------------------------------
ff-xor : ∀ (b : 𝔹) → ff xor b ≡ b
ff-xor tt = refl
ff-xor ff = refl
tt-xor : ∀ (b : 𝔹) → tt xor b ≡ ~ b
tt-xor tt = refl
tt-xor ff = refl
~-xor-distrb : ∀ (a b : 𝔹) → ~ (a xor b) ≡ ~ a xor b
~-xor-distrb tt tt = refl
~-xor-distrb tt ff = refl
~-xor-distrb ff tt = refl
~-xor-distrb ff ff = refl
xor-distrib-&& : ∀ (x y : 𝔹) → x xor (y && x) ≡ ~ y && x
xor-distrib-&& tt tt = refl
xor-distrib-&& tt ff = refl
xor-distrib-&& ff tt = refl
xor-distrib-&& ff ff = refl
xor~hop : ∀ (a b : 𝔹) → ~ a xor b ≡ a xor ~ b
xor~hop tt tt = refl
xor~hop tt ff = refl
xor~hop ff tt = refl
xor~hop ff ff = refl
xor-comm : ∀ (b1 b2 : 𝔹) → b1 xor b2 ≡ b2 xor b1
xor-comm tt tt = refl
xor-comm tt ff = refl
xor-comm ff tt = refl
xor-comm ff ff = refl
xor-assoc : (b1 b2 b3 : 𝔹) → b1 xor (b2 xor b3) ≡ (b1 xor b2) xor b3
xor-assoc tt tt tt = refl
xor-assoc tt tt ff = refl
xor-assoc tt ff tt = refl
xor-assoc tt ff ff = refl
xor-assoc ff tt tt = refl
xor-assoc ff tt ff = refl
xor-assoc ff ff tt = refl
xor-assoc ff ff ff = refl
xor-anti-idem : (b : 𝔹) → b xor b ≡ ff
xor-anti-idem tt = refl
xor-anti-idem ff = refl
xor-≡ : {b1 b2 : 𝔹} → b1 xor b2 ≡ ff → b1 ≡ b2
xor-≡ {tt} {tt} p = refl
xor-≡ {tt} {ff} ()
xor-≡ {ff} {tt} ()
xor-≡ {ff} {ff} p = refl
-----------------------------------
-- Theorems about nor, nand
-----------------------------------
nor-not : ∀ (b : 𝔹) → b nor b ≡ ~ b
nor-not tt = refl
nor-not ff = refl
nor-or : ∀ (b1 b2 : 𝔹) → (b1 nor b2) nor (b1 nor b2) ≡ b1 || b2
nor-or tt b2 = refl
nor-or ff tt = refl
nor-or ff ff = refl
nor-and : ∀ (b1 b2 : 𝔹) → (b1 nor b1) nor (b2 nor b2) ≡ b1 && b2
nor-and tt tt = refl
nor-and tt ff = refl
nor-and ff b2 = refl
nor-comm : ∀ (b1 b2 : 𝔹) → b1 nor b2 ≡ b2 nor b1
nor-comm tt tt = refl
nor-comm tt ff = refl
nor-comm ff tt = refl
nor-comm ff ff = refl
nand-comm : ∀ (b1 b2 : 𝔹) → b1 nand b2 ≡ b2 nand b1
nand-comm tt tt = refl
nand-comm tt ff = refl
nand-comm ff tt = refl
nand-comm ff ff = refl
| 25.056911
| 108
| 0.482641
|
4a3ea03d92ba84874d98a5ac2169f34552095cd8
| 2,510
|
agda
|
Agda
|
test/Succeed/Issue2211.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue2211.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue2211.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2016-11-03, issue #2211
-- The occurs check did not take variables labeled as `UnusedArg`
-- on the left hand side into consideration.
-- {-# OPTIONS -v tc.check.term:40 #-}
-- {-# OPTIONS -v tc.meta:45 #-}
-- {-# OPTIONS -v tc.polarity:20 #-}
open import Agda.Builtin.Equality
open import Common.Nat
cong : ∀{A B : Set}(f : A → B) (x y : A) → x ≡ y → f x ≡ f y
cong _ _ _ refl = refl
data ⊥ : Set where
⊥-elim : ∀{A : Set} → ⊥ {- unused arg -} → A
⊥-elim ()
data Fin : Nat → Set where
zero : {n : Nat} → Fin (suc n)
suc : {n : Nat} (i : Fin n) → Fin (suc n)
toNat : ∀ {n} → Fin n → Nat
toNat zero = 0
toNat (suc i) = suc (toNat i)
tighten : ∀ n (x : Fin (suc n)) (neq : (toNat x ≡ n → ⊥) {- unused arg x-}) → Fin n
tighten zero zero neq = ⊥-elim (neq refl)
tighten (suc n) zero neq = zero
tighten zero (suc ())
tighten (suc n) (suc x) neq = suc (tighten n x (λ p → neq (cong suc _ _ p)))
tighten-correct : ∀ n (x : Fin (suc n)) (neq : toNat x ≡ n → ⊥) →
toNat (tighten n x neq) ≡ toNat x
tighten-correct zero zero neq = ⊥-elim (neq refl)
tighten-correct (suc n) zero neq = refl
tighten-correct zero (suc ())
tighten-correct (suc n) (suc x) neq =
cong suc _ _ (tighten-correct n x (λ p → neq (cong Nat.suc _ _ p)))
-- ERROR WAS:
-- Cannot instantiate ... because it contains the variable neg ...
-- Should succeed.
{-
term _62 n x neq
(toNat (tighten n x (λ p → neq (cong suc p)))) := suc
(toNat
(tighten n x (λ p → neq (cong suc p))))
term _62 n x neq (toNat x) := toNat (suc x)
after kill analysis
metavar = _62
kills = [False,False,True,False]
kills' = [ru(False),ru(False),ru(True),ru(False)]
oldType = (n₁ : Nat) (x₁ : Fin (suc n₁))
(neq₁ : toNat (suc x₁) ≡ suc n₁ → ⊥) →
Nat → Nat
newType = (n₁ : Nat) → Fin (suc n₁) → Nat → Nat
actual killing
new meta: _69
kills : [ru(False),ru(False),ru(True),ru(False)]
inst : _62 := _69 @3 n neq
term _69 n x (toNat (tighten n x (λ p → neq (cong suc p)))) := suc
(toNat
(tighten n x
(λ p → neq (cong suc p))))
Here, the variable neq on the lhs was not considered eligible for occurrence on the rhs
since it is contained in an unused arg only.
-}
| 33.466667
| 95
| 0.517928
|
1010e6175276654524de33021b215d27e60f4ee3
| 632
|
agda
|
Agda
|
test/Succeed/Issue1466.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue1466.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue1466.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
postulate
P : {A : Set} → A → A → Set
p : {A : Set} {x : A} → P x x
q : {A : Set} (x : A) {y : A} → P x y → P x y
A : Set
record R (F : Set → Set) : Set₁ where
field
f₁ : (A → A) → F A → F A
f₂ : P (f₁ (λ x → x)) (λ (x : F A) → x)
open R ⦃ … ⦄ public
instance
r : R (λ O → O → O)
r = record
{ f₁ = λ f g x → f (g x)
; f₂ = p
}
postulate
F : Set → Set
instance
rF : R F
Foo : P (f₁ (λ x → x)) (λ (x : F A) → x)
Foo = q (f₁ (λ x → x)) f₂
-- An internal error has occurred. Please report this as a bug.
-- Location of the error:
-- src/full/Agda/TypeChecking/InstanceArguments.hs:224
| 18.057143
| 63
| 0.482595
|
069cfd5e0c3344db44a5b6f8356b35b06be2859c
| 139
|
agda
|
Agda
|
Cubical/HITs/Sn.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 301
|
2018-10-17T18:00:24.000Z
|
2022-03-24T02:10:47.000Z
|
Cubical/HITs/Sn.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 584
|
2018-10-15T09:49:02.000Z
|
2022-03-30T12:09:17.000Z
|
Cubical/HITs/Sn.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 134
|
2018-11-16T06:11:03.000Z
|
2022-03-23T16:22:13.000Z
|
{-# OPTIONS --safe #-}
module Cubical.HITs.Sn where
open import Cubical.HITs.Sn.Base public
open import Cubical.HITs.Sn.Properties public
| 23.166667
| 45
| 0.769784
|
c57d92a875d6b3161416206d91b6a25b6289fbfc
| 795
|
agda
|
Agda
|
Definition/LogicalRelation/Substitution/Reflexivity.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
Definition/LogicalRelation/Substitution/Reflexivity.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
Definition/LogicalRelation/Substitution/Reflexivity.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Definition.Typed.EqualityRelation
module Definition.LogicalRelation.Substitution.Reflexivity {{eqrel : EqRelSet}} where
open EqRelSet {{...}}
open import Definition.LogicalRelation.Properties
open import Definition.LogicalRelation.Substitution
open import Tools.Product
-- Reflexivity of valid types.
reflᵛ : ∀ {A Γ l}
([Γ] : ⊩ᵛ Γ)
([A] : Γ ⊩ᵛ⟨ l ⟩ A / [Γ])
→ Γ ⊩ᵛ⟨ l ⟩ A ≡ A / [Γ] / [A]
reflᵛ [Γ] [A] ⊢Δ [σ] =
reflEq (proj₁ ([A] ⊢Δ [σ]))
-- Reflexivity of valid terms.
reflᵗᵛ : ∀ {A t Γ l}
([Γ] : ⊩ᵛ Γ)
([A] : Γ ⊩ᵛ⟨ l ⟩ A / [Γ])
([t] : Γ ⊩ᵛ⟨ l ⟩ t ∷ A / [Γ] / [A])
→ Γ ⊩ᵛ⟨ l ⟩ t ≡ t ∷ A / [Γ] / [A]
reflᵗᵛ [Γ] [A] [t] ⊢Δ [σ] =
reflEqTerm (proj₁ ([A] ⊢Δ [σ])) (proj₁ ([t] ⊢Δ [σ]))
| 26.5
| 85
| 0.532075
|
a13d4c6036ac96de759b6ca99e68ecbbe14f853d
| 5,488
|
agda
|
Agda
|
GSeTT/Dec-Type-Checking.agda
|
ThiBen/catt-formalization
|
ed45935b38d6a86fa662f561866140122ee3dcef
|
[
"MIT"
] | 2
|
2020-05-01T08:26:53.000Z
|
2020-05-20T00:41:09.000Z
|
GSeTT/Dec-Type-Checking.agda
|
ThiBen/catt-formalization
|
ed45935b38d6a86fa662f561866140122ee3dcef
|
[
"MIT"
] | null | null | null |
GSeTT/Dec-Type-Checking.agda
|
ThiBen/catt-formalization
|
ed45935b38d6a86fa662f561866140122ee3dcef
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K #-}
open import Agda.Primitive
open import Prelude
open import GSeTT.Syntax
open import GSeTT.Rules
{- Decidability of type cheking for the type theory for globular sets -}
module GSeTT.Dec-Type-Checking where
dec-⊢C : ∀ Γ → dec (Γ ⊢C)
dec-⊢T : ∀ Γ A → dec (Γ ⊢T A)
dec-⊢t : ∀ Γ A t → dec (Γ ⊢t t # A)
dec-⊢S : ∀ Δ Γ γ → dec (Δ ⊢S γ > Γ)
private
Γ+⊢→Γ⊢ : ∀ {Γ x A} → (Γ :: (x , A)) ⊢C → Γ ⊢C
Γ+⊢→Γ⊢ (cc Γ⊢ _ idp) = Γ⊢
Γ+⊢→x=l : ∀ {Γ x A} → (Γ :: (x , A)) ⊢C → x == length Γ
Γ+⊢→x=l (cc _ _ idp) = idp
Γ+⊢→Γ⊢A : ∀ {Γ x A} → (Γ :: (x , A)) ⊢C → Γ ⊢T A
Γ+⊢→Γ⊢A (cc _ Γ⊢A _) = Γ⊢A
Γ⊢x:A→x∈Γ : ∀ {Γ x A} → Γ ⊢t Var x # A → x # A ∈ Γ
Γ⊢x:A→x∈Γ (var _ x∈Γ) = x∈Γ
Δ⊢<>:Γ→Γ=nil : ∀ {Δ Γ} → Δ ⊢S nil > Γ → Γ == nil
Δ⊢<>:Γ→Γ=nil (es _) = idp
Δ⊢γ:⊘→γ=nil : ∀ {Δ γ} → Δ ⊢S γ > nil → γ == nil
Δ⊢γ:⊘→γ=nil (es _) = idp
Δ⊢γ+:Γ+→x=y : ∀ {Δ Γ x A γ y t} → Δ ⊢S (γ :: (y , t)) > (Γ :: (x , A)) → x == y
Δ⊢γ+:Γ+→x=y (sc _ _ _ idp) = idp
Δ⊢γ+:Γ+→Δ⊢t : ∀ {Δ Γ x A γ y t} → Δ ⊢S (γ :: (y , t)) > (Γ :: (x , A)) → Δ ⊢t t # (A [ γ ]Pre-Ty)
Δ⊢γ+:Γ+→Δ⊢t (sc _ _ Δ⊢t idp) = Δ⊢t
Δ⊢γ+:Γ+→Δ⊢γ : ∀ {Δ Γ x A γ y t} → Δ ⊢S (γ :: (y , t)) > (Γ :: (x , A)) → Δ ⊢S γ > Γ
Δ⊢γ+:Γ+→Δ⊢γ (sc Δ⊢γ:Γ _ _ idp) = Δ⊢γ:Γ
eqdec-Ty : eqdec Pre-Ty
eqdec-Tm : eqdec Pre-Tm
eqdec-Ty ∗ ∗ = inl idp
eqdec-Ty ∗ (_ ⇒[ _ ] _) = inr λ{()}
eqdec-Ty (_ ⇒[ _ ] _) ∗ = inr λ{()}
eqdec-Ty (t ⇒[ A ] u) (t' ⇒[ B ] u') with eqdec-Ty A B | eqdec-Tm t t' | eqdec-Tm u u'
... | inl idp | inl idp | inl idp = inl idp
... | inl idp | inl idp | inr u≠u' = inr λ p → u≠u' (snd (=⇒ p))
... | inl idp | inr t≠t' | _ = inr λ p → t≠t' (snd (fst (=⇒ p)))
... | inr A≠B | _ | _ = inr λ p → A≠B (fst (fst (=⇒ p)))
eqdec-Tm (Var x) (Var y) with eqdecℕ x y
... | inl idp = inl idp
... | inr x≠y = inr λ p → x≠y (=Var p)
dec-∈ : ∀ Γ x A → dec (x # A ∈ Γ)
dec-∈ nil x A = inr λ x → x
dec-∈ (Γ :: (y , B)) x A with (eqdecℕ y x) | (eqdec-Ty B A)
... | inl idp | inl idp = inl (inr (idp , idp))
... | inl idp | inr B≠A with dec-∈ Γ x A
... | inl x∈Γ = inl (inl x∈Γ)
... | inr x∉Γ = inr λ {(inl x∈Γ) → x∉Γ x∈Γ ; (inr (_ , A=B)) → B≠A (A=B ^)}
dec-∈ (Γ :: (y , B)) x A | inr y≠x | _ with dec-∈ Γ x A
... | inl x∈Γ = inl (inl x∈Γ)
... | inr x∉Γ = inr λ{ (inl x∈Γ) → x∉Γ x∈Γ ; (inr (x=y , _)) → y≠x (x=y ^)}
dec-⊢C nil = inl ec
dec-⊢C (Γ :: (x , A)) with dec-⊢C Γ | eqdecℕ x (length Γ) | dec-⊢T Γ A
... | inl Γ⊢ | inl idp | inl Γ⊢A = inl (cc Γ⊢ Γ⊢A idp)
... | inl _ | inl idp | inr Γ⊬A = inr λ Γ+⊢ → Γ⊬A (Γ+⊢→Γ⊢A Γ+⊢)
... | inl Γ⊢ | inr n≠l | _ = inr λ Γ+⊢ → n≠l (Γ+⊢→x=l Γ+⊢)
... | inr Γ⊬ | _ | _ = inr λ Γ+⊢ → Γ⊬ (Γ+⊢→Γ⊢ Γ+⊢)
dec-⊢T Γ ∗ with dec-⊢C Γ
... | inl Γ⊢ = inl (ob Γ⊢)
... | inr Γ⊬ = inr λ Γ⊢* → Γ⊬ (Γ⊢A→Γ⊢ Γ⊢*)
dec-⊢T Γ (t ⇒[ A ] u) with dec-⊢t Γ A t | dec-⊢t Γ A u
... | inl Γ⊢t:A | inl Γ⊢u:A = inl (ar (Γ⊢t:A→Γ⊢A Γ⊢t:A) Γ⊢t:A Γ⊢u:A)
... | inl _ | inr Γ⊬u:A = inr λ Γ⊢t⇒u → Γ⊬u:A (Γ⊢tgt Γ⊢t⇒u)
... | inr Γ⊬t:A | _ = inr λ Γ⊢t⇒u → Γ⊬t:A (Γ⊢src Γ⊢t⇒u)
dec-⊢t Γ A (Var x) with dec-⊢C Γ | dec-∈ Γ x A
... | inl Γ⊢ | inl x∈Γ = inl (var Γ⊢ x∈Γ)
... | inl _ | inr x∉Γ = inr λ Γ⊢x:A → x∉Γ (Γ⊢x:A→x∈Γ Γ⊢x:A)
... | inr Γ⊬ | _ = inr λ Γ⊢x:A → Γ⊬ (Γ⊢t:A→Γ⊢ Γ⊢x:A)
dec-⊢S Δ nil nil with dec-⊢C Δ
... | inl Δ⊢ = inl (es Δ⊢)
... | inr Δ⊬ = inr λ Δ⊢<>:⊘ → Δ⊬ (Δ⊢γ:Γ→Δ⊢ Δ⊢<>:⊘)
dec-⊢S Δ (Γ :: _) nil = inr λ Δ⊢<>:Γ → cons≠nil (Δ⊢<>:Γ→Γ=nil Δ⊢<>:Γ)
dec-⊢S Δ nil (γ :: a) = inr λ Δ⊢γ:⊘ → cons≠nil (Δ⊢γ:⊘→γ=nil Δ⊢γ:⊘)
dec-⊢S Δ (Γ :: (x , A)) (γ :: (y , t)) with dec-⊢S Δ Γ γ | dec-⊢C (Γ :: (x , A)) | dec-⊢t Δ (A [ γ ]Pre-Ty) t | eqdecℕ x y
... | inl Δ⊢γ:Γ | inl Γ+⊢ | inl Δ⊢t | inl idp = inl (sc Δ⊢γ:Γ Γ+⊢ Δ⊢t idp)
... | inl _ | inl _ | inl _ | inr x≠y = inr λ Δ⊢γ+:Γ+ → x≠y (Δ⊢γ+:Γ+→x=y Δ⊢γ+:Γ+)
... | inl _ | inl _ | inr Δ⊬t | _ = inr λ Δ⊢γ+:Γ+ → Δ⊬t (Δ⊢γ+:Γ+→Δ⊢t Δ⊢γ+:Γ+)
... | inl _ | inr Γ+⊬ | _ | _ = inr λ Δ⊢γ+:Γ+ → Γ+⊬ (Δ⊢γ:Γ→Γ⊢ Δ⊢γ+:Γ+)
... | inr Δ⊬γ | _ | _ | _ = inr λ Δ⊢γ+:Γ+ → Δ⊬γ (Δ⊢γ+:Γ+→Δ⊢γ Δ⊢γ+:Γ+)
| 54.336634
| 168
| 0.307945
|
dc61078c247d82e863749eca1c842d0244acb52a
| 2,683
|
agda
|
Agda
|
Cats/Util/SetoidMorphism.agda
|
JLimperg/cats
|
1ad7b243acb622d46731e9ae7029408db6e561f1
|
[
"MIT"
] | 24
|
2017-11-03T15:18:57.000Z
|
2021-08-06T05:00:46.000Z
|
Cats/Util/SetoidMorphism.agda
|
JLimperg/cats
|
1ad7b243acb622d46731e9ae7029408db6e561f1
|
[
"MIT"
] | null | null | null |
Cats/Util/SetoidMorphism.agda
|
JLimperg/cats
|
1ad7b243acb622d46731e9ae7029408db6e561f1
|
[
"MIT"
] | 1
|
2019-03-18T15:35:07.000Z
|
2019-03-18T15:35:07.000Z
|
{-# OPTIONS --without-K --safe #-}
module Cats.Util.SetoidMorphism where
open import Data.Product using (∃-syntax ; _,_ ; proj₁ ; proj₂)
open import Level using (_⊔_ ; suc)
open import Relation.Binary using (Rel ; Setoid ; IsEquivalence ; _Preserves_⟶_)
open import Relation.Binary.Reasoning.MultiSetoid
open import Cats.Util.Function using () renaming (_∘_ to _⊚_)
open Setoid renaming (_≈_ to eq)
infixr 9 _∘_
record _⇒_ {l l≈} (A : Setoid l l≈) {l′ l≈′} (B : Setoid l′ l≈′)
: Set (l ⊔ l′ ⊔ l≈ ⊔ l≈′)
where
field
arr : Carrier A → Carrier B
resp : arr Preserves eq A ⟶ eq B
open _⇒_ public using (arr ; resp)
module _ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′} where
infixr 4 _≈_
record _≈_ (f g : A ⇒ B) : Set (l ⊔ l≈ ⊔ l≈′) where
constructor ≈-intro
field
≈-elim : ∀ {x y} → eq A x y → eq B (arr f x) (arr g y)
≈-elim′ : ∀ {x} → eq B (arr f x) (arr g x)
≈-elim′ = ≈-elim (refl A)
open _≈_ public
equiv : IsEquivalence _≈_
equiv = record
{ refl = λ {f} → ≈-intro (resp f)
; sym = λ eq → ≈-intro λ x≈y → sym B (≈-elim eq (sym A x≈y))
; trans = λ eq₁ eq₂ → ≈-intro (λ x≈y → trans B (≈-elim eq₁ x≈y) (≈-elim′ eq₂))
}
setoid : Setoid (l ⊔ l≈ ⊔ l′ ⊔ l≈′) (l ⊔ l≈ ⊔ l≈′)
setoid = record
{ Carrier = A ⇒ B
; _≈_ = _≈_
; isEquivalence = equiv
}
id : ∀ {l l≈} {A : Setoid l l≈} → A ⇒ A
id = record { arr = λ x → x ; resp = λ x → x }
_∘_ : ∀ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′}
→ ∀ {l″ l≈″} {C : Setoid l″ l≈″}
→ B ⇒ C → A ⇒ B → A ⇒ C
_∘_ f g = record
{ arr = arr f ⊚ arr g
; resp = resp f ⊚ resp g
}
∘-resp : ∀ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′}
→ ∀ {l″ l≈″} {C : Setoid l″ l≈″}
→ {f f′ : B ⇒ C} {g g′ : A ⇒ B}
→ f ≈ f′ → g ≈ g′ → f ∘ g ≈ f′ ∘ g′
∘-resp f≈f′ g≈g′ = ≈-intro (≈-elim f≈f′ ⊚ ≈-elim g≈g′)
id-l : ∀ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′}
→ {f : A ⇒ B}
→ id ∘ f ≈ f
id-l {f = f} = ≈-intro (resp f)
id-r : ∀ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′}
→ {f : A ⇒ B}
→ f ∘ id ≈ f
id-r {f = f} = ≈-intro (resp f)
assoc : ∀ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′}
→ ∀ {l″ l≈″} {C : Setoid l″ l≈″} {l‴ l≈‴} {D : Setoid l‴ l≈‴}
→ {f : C ⇒ D} {g : B ⇒ C} {h : A ⇒ B}
→ (f ∘ g) ∘ h ≈ f ∘ (g ∘ h)
assoc {f = f} {g} {h} = ≈-intro (resp f ⊚ resp g ⊚ resp h)
module _ {l l≈} {A : Setoid l l≈} {l′ l≈′} {B : Setoid l′ l≈′} where
IsInjective : A ⇒ B → Set (l ⊔ l≈ ⊔ l≈′)
IsInjective f = ∀ {a b} → eq B (arr f a) (arr f b) → eq A a b
IsSurjective : A ⇒ B → Set (l ⊔ l′ ⊔ l≈′)
IsSurjective f = ∀ b → ∃[ a ] (eq B b (arr f a))
| 25.311321
| 84
| 0.469251
|
50e4eccb1bbe32d4822f42a7c144f1e976f96b0a
| 4,466
|
agda
|
Agda
|
agda-stdlib/src/Data/Vec/Recursive.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/Vec/Recursive.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/Vec/Recursive.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- Vectors defined by recursion
------------------------------------------------------------------------
-- What is the point of this module? The n-ary products below are intended
-- to be used with a fixed n, in which case the nil constructor can be
-- avoided: pairs are represented as pairs (x , y), not as triples
-- (x , y , unit).
-- Additionally, vectors defined by recursion enjoy η-rules. That is to say
-- that two vectors of known length are definitionally equal whenever their
-- elements are.
{-# OPTIONS --without-K --safe #-}
module Data.Vec.Recursive where
open import Level using (Level; Lift; lift)
open import Data.Nat.Base as Nat using (ℕ; zero; suc)
open import Data.Empty
open import Data.Fin.Base as Fin using (Fin; zero; suc)
open import Data.Product as Prod using (_×_; _,_; proj₁; proj₂)
open import Data.Sum.Base as Sum using (_⊎_)
open import Data.Unit.Base
open import Data.Vec.Base as Vec using (Vec; _∷_)
open import Function
open import Relation.Unary
open import Agda.Builtin.Equality using (_≡_)
private
variable
a b c p : Level
A : Set a
B : Set b
C : Set c
-- Types and patterns
------------------------------------------------------------------------
pattern 2+_ n = suc (suc n)
infix 8 _^_
_^_ : Set a → ℕ → Set a
A ^ 0 = Lift _ ⊤
A ^ 1 = A
A ^ 2+ n = A × A ^ suc n
pattern [] = lift tt
infix 3 _∈[_]_
_∈[_]_ : {A : Set a} → A → ∀ n → A ^ n → Set a
a ∈[ 0 ] as = Lift _ ⊥
a ∈[ 1 ] a′ = a ≡ a′
a ∈[ 2+ n ] a′ , as = a ≡ a′ ⊎ a ∈[ suc n ] as
-- Basic operations
------------------------------------------------------------------------
cons : ∀ n → A → A ^ n → A ^ suc n
cons 0 a _ = a
cons (suc n) a as = a , as
uncons : ∀ n → A ^ suc n → A × A ^ n
uncons 0 a = a , lift tt
uncons (suc n) (a , as) = a , as
head : ∀ n → A ^ suc n → A
head n as = proj₁ (uncons n as)
tail : ∀ n → A ^ suc n → A ^ n
tail n as = proj₂ (uncons n as)
fromVec : ∀[ Vec A ⇒ (A ^_) ]
fromVec = Vec.foldr (_ ^_) (cons _) _
toVec : Π[ (A ^_) ⇒ Vec A ]
toVec 0 as = Vec.[]
toVec (suc n) as = head n as ∷ toVec n (tail n as)
lookup : ∀ {n} (k : Fin n) → A ^ n → A
lookup zero = head _
lookup (suc {n} k) = lookup k ∘′ tail n
replicate : ∀ n → A → A ^ n
replicate n a = fromVec (Vec.replicate a)
tabulate : ∀ n → (Fin n → A) → A ^ n
tabulate n f = fromVec (Vec.tabulate f)
append : ∀ m n → A ^ m → A ^ n → A ^ (m Nat.+ n)
append 0 n xs ys = ys
append 1 n x ys = cons n x ys
append (2+ m) n (x , xs) ys = x , append (suc m) n xs ys
splitAt : ∀ m n → A ^ (m Nat.+ n) → A ^ m × A ^ n
splitAt 0 n xs = [] , xs
splitAt (suc m) n xs =
let (ys , zs) = splitAt m n (tail (m Nat.+ n) xs) in
cons m (head (m Nat.+ n) xs) ys , zs
-- Manipulating N-ary products
------------------------------------------------------------------------
map : (A → B) → ∀ n → A ^ n → B ^ n
map f 0 as = lift tt
map f 1 a = f a
map f (2+ n) (a , as) = f a , map f (suc n) as
ap : ∀ n → (A → B) ^ n → A ^ n → B ^ n
ap 0 fs ts = []
ap 1 f t = f t
ap (2+ n) (f , fs) (t , ts) = f t , ap (suc n) fs ts
module _ {P : ℕ → Set p} where
foldr : P 0 → (A → P 1) → (∀ n → A → P (suc n) → P (2+ n)) →
∀ n → A ^ n → P n
foldr p0 p1 p2+ 0 as = p0
foldr p0 p1 p2+ 1 a = p1 a
foldr p0 p1 p2+ (2+ n) (a , as) = p2+ n a (foldr p0 p1 p2+ (suc n) as)
foldl : (P : ℕ → Set p) →
P 0 → (A → P 1) → (∀ n → A → P (suc n) → P (2+ n)) →
∀ n → A ^ n → P n
foldl P p0 p1 p2+ 0 as = p0
foldl P p0 p1 p2+ 1 a = p1 a
foldl P p0 p1 p2+ (2+ n) (a , as) = let p1′ = p1 a in
foldl (P ∘′ suc) p1′ (λ a → p2+ 0 a p1′) (p2+ ∘ suc) (suc n) as
reverse : ∀ n → A ^ n → A ^ n
reverse = foldl (_ ^_) [] id (λ n → _,_)
zipWith : (A → B → C) → ∀ n → A ^ n → B ^ n → C ^ n
zipWith f 0 as bs = []
zipWith f 1 a b = f a b
zipWith f (2+ n) (a , as) (b , bs) = f a b , zipWith f (suc n) as bs
unzipWith : (A → B × C) → ∀ n → A ^ n → B ^ n × C ^ n
unzipWith f 0 as = [] , []
unzipWith f 1 a = f a
unzipWith f (2+ n) (a , as) = Prod.zip _,_ _,_ (f a) (unzipWith f (suc n) as)
zip : ∀ n → A ^ n → B ^ n → (A × B) ^ n
zip = zipWith _,_
unzip : ∀ n → (A × B) ^ n → A ^ n × B ^ n
unzip = unzipWith id
| 29.773333
| 77
| 0.467532
|
3106d0ba190c48ddf107f64dfc5e09269a823266
| 2,529
|
agda
|
Agda
|
Cubical/Foundations/Equiv/Fiberwise.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Equiv/Fiberwise.agda
|
kiana-S/univalent-foundations
|
8bdb0766260489f9c89a14f4c0f2ad26e5190dec
|
[
"MIT"
] | 1
|
2022-01-27T02:07:48.000Z
|
2022-01-27T02:07:48.000Z
|
Cubical/Foundations/Equiv/Fiberwise.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.Foundations.Equiv.Fiberwise where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.HLevels
open import Cubical.Data.Sigma
module _ {a p q} {A : Type a} (P : A → Type p) (Q : A → Type q)
(f : ∀ x → P x → Q x)
where
private
total : (Σ A P) → (Σ A Q)
total = (\ p → p .fst , f (p .fst) (p .snd))
-- Thm 4.7.6
fibers-total : ∀ {xv} → Iso (fiber total (xv)) (fiber (f (xv .fst)) (xv .snd))
fibers-total {xv} = iso h g h-g g-h
where
h : ∀ {xv} → fiber total xv → fiber (f (xv .fst)) (xv .snd)
h {xv} (p , eq) = J (\ xv eq → fiber (f (xv .fst)) (xv .snd)) ((p .snd) , refl) eq
g : ∀ {xv} → fiber (f (xv .fst)) (xv .snd) → fiber total xv
g {xv} (p , eq) = (xv .fst , p) , (\ i → _ , eq i)
h-g : ∀ {xv} y → h {xv} (g {xv} y) ≡ y
h-g {x , v} (p , eq) = J (λ _ eq₁ → h (g (p , eq₁)) ≡ (p , eq₁)) (JRefl (λ xv₁ eq₁ → fiber (f (xv₁ .fst)) (xv₁ .snd)) ((p , refl))) (eq)
g-h : ∀ {xv} y → g {xv} (h {xv} y) ≡ y
g-h {xv} ((a , p) , eq) = J (λ _ eq₁ → g (h ((a , p) , eq₁)) ≡ ((a , p) , eq₁))
(cong g (JRefl (λ xv₁ eq₁ → fiber (f (xv₁ .fst)) (xv₁ .snd)) (p , refl)))
eq
-- Thm 4.7.7 (fiberwise equivalences)
fiberEquiv : ([tf] : isEquiv total)
→ ∀ x → isEquiv (f x)
fiberEquiv [tf] x .equiv-proof y = isContrRetract (fibers-total .Iso.inv) (fibers-total .Iso.fun) (fibers-total .Iso.rightInv)
([tf] .equiv-proof (x , y))
totalEquiv : (fx-equiv : ∀ x → isEquiv (f x))
→ isEquiv total
totalEquiv fx-equiv .equiv-proof (x , v) = isContrRetract (fibers-total .Iso.fun) (fibers-total .Iso.inv) (fibers-total .Iso.leftInv)
(fx-equiv x .equiv-proof v)
module _ {ℓ : Level} {U : Type ℓ} {ℓr} (_~_ : U → U → Type ℓr)
(idTo~ : ∀ {A B} → A ≡ B → A ~ B)
(c : ∀ A → ∃![ X ∈ U ] (A ~ X))
where
isContrToUniv : ∀ {A B} → isEquiv (idTo~ {A} {B})
isContrToUniv {A} {B}
= fiberEquiv (λ z → A ≡ z) (λ z → A ~ z) (\ B → idTo~ {A} {B})
(λ { .equiv-proof y
→ isContrΣ (isContrSingl _)
\ a → isContr→isContrPath (c A) _ _
})
B
| 43.603448
| 140
| 0.474496
|
1cfb8075577fbb8441d11a5b6cb78096beec8e2c
| 1,106
|
agda
|
Agda
|
test/Succeed/NoTerminationCheck.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/NoTerminationCheck.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/NoTerminationCheck.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- 2012-03-08 Andreas
-- 2014-09-09 Andreas, use NON_TERMINATING or TERMINATING instead
postulate A : Set
-- Skipping a single definition: before type signature
{-# NON_TERMINATING #-}
a : A
a = a
-- Skipping a single definition: before first clause
b : A
{-# NON_TERMINATING #-}
b = b
-- Skipping an old-style mutual block (placed before)
{-# NON_TERMINATING #-}
mutual
c : A
c = d
d : A
d = c
-- Skipping an old-style mutual block (placed within)
mutual
{-# TERMINATING #-} -- It's a lie!!
c1 : A
c1 = d1
d1 : A
d1 = c1
mutual
c2 : A
{-# NON_TERMINATING #-}
c2 = d2
d2 : A
d2 = c2
mutual
c3 : A
c3 = d3
{-# NON_TERMINATING #-}
d3 : A
d3 = c3
-- Skipping a new-style mutual block
{-# NON_TERMINATING #-}
e : A
f : A
e = f
f = e
-- Skipping a new-style mutual block, variant 2
g : A
{-# TERMINATING #-} -- Beware of lies!!
h : A
g = h
h = g
-- Skipping a new-style mutual block, variant 4
i : A
j : A
i = j
{-# NON_TERMINATING #-}
j = i
private
{-# NON_TERMINATING #-}
k : A
k = k
abstract
{-# NON_TERMINATING #-}
l : A
l = l
| 12.021739
| 65
| 0.59132
|
06cf8fb070139a08c022b9939e1a66d673ed3a3e
| 109
|
agda
|
Agda
|
examples/outdated-and-incorrect/Alonzo/RTN.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/Alonzo/RTN.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/Alonzo/RTN.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module RTN where
data Nat : Set where
zero : Nat
suc : Nat -> Nat
{-# BUILTIN NATURAL Nat #-}
| 13.625
| 29
| 0.568807
|
31243912f68f5da76375f7f0822db4f69e8367b0
| 329
|
agda
|
Agda
|
RefactorAgdaEngine/Test/Tests/output/ImportTests/ExtractDependent.agda
|
omega12345/RefactorAgda
|
52d1034aed14c578c9e077fb60c3db1d0791416b
|
[
"BSD-3-Clause"
] | 5
|
2019-01-31T14:10:18.000Z
|
2019-05-03T10:03:36.000Z
|
RefactorAgdaEngine/Test/Tests/output/ImportTests/ExtractDependent.agda
|
omega12345/RefactorAgda
|
52d1034aed14c578c9e077fb60c3db1d0791416b
|
[
"BSD-3-Clause"
] | 3
|
2019-01-31T08:03:07.000Z
|
2019-02-05T12:53:36.000Z
|
RefactorAgdaEngine/Test/Tests/output/ImportTests/ExtractDependent.agda
|
omega12345/RefactorAgda
|
52d1034aed14c578c9e077fb60c3db1d0791416b
|
[
"BSD-3-Clause"
] | 1
|
2019-01-31T08:40:41.000Z
|
2019-01-31T08:40:41.000Z
|
module ImportTests.ExtractDependent where
open import Data.Bool
open import Data.Nat
open import ExtractDependent
f : ℕ -> Bool
f 0 = false
f _ = true
testApply : Bool
testApply = apply _ _ f 5
testApplyImp : Bool
testApplyImp = applyImp f 6
testApplyImpSameName : Bool
testApplyImpSameName = applyImpSameName {ℕ} Bool f 3
| 16.45
| 52
| 0.772036
|
4daf49118700d03a4a444d9972030d1970d95eac
| 674
|
agda
|
Agda
|
Lvl/Decidable.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Lvl/Decidable.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Lvl/Decidable.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
module Lvl.Decidable where
open import Data.Boolean.Stmt
open import Logic.Propositional
open import Logic.Propositional.Theorems
import Lvl
open import Type.Properties.Decidable
open import Type.Properties.Decidable.Proofs
open import Type
private variable ℓ ℓ₁ : Lvl.Level
-- Changing classical propositions' universe levels by using their boolean representation.
module _ (P : Type{ℓ}) ⦃ dec : Decidable(0)(P) ⦄ where
Convert : Type{ℓ₁}
Convert = Lvl.Up(IsTrue(decide(0)(P)))
-- LvlConvert is satisfied whenever its proposition is.
Convert-correctness : P ↔ Convert{ℓ₁}
Convert-correctness = [↔]-transitivity decider-true ([↔]-intro Lvl.Up.obj Lvl.up)
| 32.095238
| 90
| 0.759644
|
06ab8a8a37baeb942095a2ba130ac23ad4341791
| 388
|
agda
|
Agda
|
test/Fail/Issue1615.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/Fail/Issue1615.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 3
|
2018-11-14T15:31:44.000Z
|
2019-04-01T19:39:26.000Z
|
test/Fail/Issue1615.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1
|
2019-03-05T20:02:38.000Z
|
2019-03-05T20:02:38.000Z
|
-- Andreas, 2015-07-22
-- {-# OPTIONS -v tc.term:20 -v tc.meta.assign:10 -v tc.conv.coerce:10 #-}
open import Common.Size
data Nat (i : Size) : Set where
suc : (j : Size< i) → Nat j → Nat i
min : ∀ i → Nat i → Nat i → Nat i
min i (suc j n) (suc k m) = suc i' (min i' n m)
where i' = _
-- Size consistency check should not be circumvented
-- by putting the meta in a definition.
| 24.25
| 74
| 0.610825
|
396f75c2824c15c09bc45cef7a4bf21a88530976
| 2,038
|
agda
|
Agda
|
agda-stdlib-0.9/src/Category/Monad/Continuation.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | 1
|
2016-10-20T15:52:05.000Z
|
2016-10-20T15:52:05.000Z
|
agda-stdlib-0.9/src/Category/Monad/Continuation.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
agda-stdlib-0.9/src/Category/Monad/Continuation.agda
|
qwe2/try-agda
|
9d4c43b1609d3f085636376fdca73093481ab882
|
[
"Apache-2.0"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- A delimited continuation monad
------------------------------------------------------------------------
module Category.Monad.Continuation where
open import Category.Applicative
open import Category.Applicative.Indexed
open import Category.Monad
open import Category.Monad.Identity
open import Category.Monad.Indexed
open import Function
open import Level
------------------------------------------------------------------------
-- Delimited continuation monads
DContT : ∀ {i f} {I : Set i} → (I → Set f) → (Set f → Set f) → IFun I f
DContT K M r₂ r₁ a = (a → M (K r₁)) → M (K r₂)
DCont : ∀ {i f} {I : Set i} → (I → Set f) → IFun I f
DCont K = DContT K Identity
DContTIMonad : ∀ {i f} {I : Set i} (K : I → Set f) {M} →
RawMonad M → RawIMonad (DContT K M)
DContTIMonad K Mon = record
{ return = λ a k → k a
; _>>=_ = λ c f k → c (flip f k)
}
where open RawMonad Mon
DContIMonad : ∀ {i f} {I : Set i} (K : I → Set f) → RawIMonad (DCont K)
DContIMonad K = DContTIMonad K IdentityMonad
------------------------------------------------------------------------
-- Delimited continuation operations
record RawIMonadDCont {i f} {I : Set i} (K : I → Set f)
(M : IFun I f) : Set (i ⊔ suc f) where
field
monad : RawIMonad M
reset : ∀ {r₁ r₂ r₃} → M r₁ r₂ (K r₂) → M r₃ r₃ (K r₁)
shift : ∀ {a r₁ r₂ r₃ r₄} →
((a → M r₁ r₁ (K r₂)) → M r₃ r₄ (K r₄)) → M r₃ r₂ a
open RawIMonad monad public
DContTIMonadDCont : ∀ {i f} {I : Set i} (K : I → Set f) {M} →
RawMonad M → RawIMonadDCont K (DContT K M)
DContTIMonadDCont K Mon = record
{ monad = DContTIMonad K Mon
; reset = λ e k → e return >>= k
; shift = λ e k → e (λ a k' → (k a) >>= k') return
}
where
open RawIMonad Mon
DContIMonadDCont : ∀ {i f} {I : Set i}
(K : I → Set f) → RawIMonadDCont K (DCont K)
DContIMonadDCont K = DContTIMonadDCont K IdentityMonad
| 32.349206
| 72
| 0.513248
|
dc1037f8af33f940d9bb721a224ab9caa073d193
| 79
|
agda
|
Agda
|
test/Fail/Issue2442-postulate.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue2442-postulate.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue2442-postulate.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-# OPTIONS --safe #-}
module Issue2442-postulate where
postulate
A : Set
| 9.875
| 32
| 0.670886
|
31580d2c0771090906e797c1d5b353bebdf0d44a
| 311
|
agda
|
Agda
|
tree-test.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 29
|
2019-02-06T13:09:31.000Z
|
2022-03-04T15:05:12.000Z
|
tree-test.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 8
|
2018-07-09T22:53:38.000Z
|
2022-03-22T03:43:34.000Z
|
tree-test.agda
|
rfindler/ial
|
f3f0261904577e930bd7646934f756679a6cbba6
|
[
"MIT"
] | 17
|
2018-12-03T22:38:15.000Z
|
2021-11-28T20:13:21.000Z
|
module tree-test where
open import tree
open import nat
open import bool
open import bool-to-string
open import list
test-tree = node 2 ( (leaf 3) :: (node 4 ( (leaf 5) :: (leaf 7) :: [] )) :: (leaf 6) :: (leaf 7) :: [])
perfect3 = perfect-binary-tree 3 tt
perfect3-string = 𝕋-to-string 𝔹-to-string perfect3
| 23.923077
| 103
| 0.665595
|
4d0fc4f3a9e57ec24290c80a972bad445367cc28
| 1,394
|
agda
|
Agda
|
test/asset/agda-stdlib-1.0/Data/Table.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Table.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
test/asset/agda-stdlib-1.0/Data/Table.agda
|
omega12345/agda-mode
|
0debb886eb5dbcd38dbeebd04b34cf9d9c5e0e71
|
[
"MIT"
] | null | null | null |
------------------------------------------------------------------------
-- The Agda standard library
--
-- Fixed-size tables of values, implemented as functions from 'Fin n'.
-- Similar to 'Data.Vec', but focusing on ease of retrieval instead of
-- ease of adding and removing elements.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.Table where
open import Data.Table.Base public
open import Data.Bool using (true; false)
open import Data.Fin using (Fin; _≟_)
open import Function.Equality using (_⟨$⟩_)
open import Function.Inverse using (Inverse; _↔_)
open import Relation.Nullary using (yes; no)
open import Relation.Nullary.Decidable using (⌊_⌋)
--------------------------------------------------------------------------------
-- Combinators
--------------------------------------------------------------------------------
-- Changes the order of elements in the table according to a permutation (i.e.
-- an 'Inverse' object on the indices).
permute : ∀ {m n a} {A : Set a} → Fin m ↔ Fin n → Table A n → Table A m
permute π = rearrange (Inverse.to π ⟨$⟩_)
-- The result of 'select z i t' takes the value of 'lookup t i' at index 'i',
-- and 'z' everywhere else.
select : ∀ {n} {a} {A : Set a} → A → Fin n → Table A n → Table A n
lookup (select z i t) j with j ≟ i
... | yes _ = lookup t i
... | no _ = z
| 35.74359
| 80
| 0.52726
|
4db4704446bb53544eaa4cb7d6e75a9124425b2c
| 6,309
|
agda
|
Agda
|
examples/DTP08/conor/Talk.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
examples/DTP08/conor/Talk.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
examples/DTP08/conor/Talk.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
{-
Data, Deliberately
Conor McBride
Workshop in Dependently Typed Programming
Nottingham, 2008
(Agda rendering by Ulf Norell)
-}
module Talk where
open import SomeBasicStuff
-- Codes for (first order) inductive families.
data Code (I : Set) : Set1 where
arg : (A : Set) -> (A -> Code I) -> Code I
rec : I -> Code I -> Code I
out : I -> Code I
-- The semantics of a code is a functor.
⟦_⟧ : {I : Set} -> Code I -> (I -> Set) -> I -> Set
⟦ out i ⟧ X j = i == j
⟦ arg A B ⟧ X j = Σ A \a -> ⟦ B a ⟧ X j
⟦ rec i C ⟧ X j = X i × ⟦ C ⟧ X j
map : {I : Set}{X Y : I -> Set}(C : Code I) ->
({i : I} -> X i -> Y i) ->
{i : I} -> ⟦ C ⟧ X i -> ⟦ C ⟧ Y i
map (out i) f x = x
map (arg A B) f (a , b) = a , map (B a) f b
map (rec i C) f (a , b) = f a , map C f b
-- Tying the recursive knot. The positivity checker won't spot that
-- ⟦ C ⟧ X i is strictly positive i X, so we've switched it off.
-- ASR (08 August 2014): It's not necessary disable the strictly
-- positive checher.
data μ {I : Set}(C : Code I) : I -> Set where
<_> : forall {i} -> ⟦ C ⟧ (μ C) i -> μ C i
-- Who needs a primitive case-construct anyway?
infix 0 case_of_
case_of_ : {A : Set1}{ts : Enumeration} -> Enum ts -> Table A ts -> A
case t of tbl = lookup tbl t
-- The code for lists
`List` : Set -> Code True
`List` X = arg _ \t ->
case t of
"nil" ↦ out _
∣ "cons" ↦ arg X (\_ -> rec _ (out _))
∣ []
-- The actual list type
List : Set -> Set
List A = μ (`List` A) _
-- We can define the code for vectors directly. However, the point is
-- that we won't have to.
`VecD` : Set -> Code Nat
`VecD` X = arg _ \t ->
case t of
"nil" ↦ out zero
∣ "cons" ↦ ( arg Nat \n ->
arg X \_ ->
rec n (out (suc n))
)
∣ []
-- An ornamentation of a datatype adds some new indexing.
data Orn {I : Set}(J : I -> Set) : Code I -> Set1 where
arg : forall {A B} -> ((a : A) -> Orn J (B a)) -> Orn J (arg A B)
rec : forall {i C} -> J i -> Orn J C -> Orn J (rec i C)
out : forall {i} -> J i -> Orn J (out i)
new : forall {C} -> (A : Set) -> (A -> Orn J C) -> Orn J C
-- An ornamented datatype is indexed by pairs of the old and the new index.
orn : {I : Set}{J : I -> Set}{C : Code I} -> Orn J C -> Code (Σ I J)
orn (out j) = out (_ , j)
orn (arg B) = arg _ \a -> orn (B a)
orn (new A B) = arg A \a -> orn (B a)
orn (rec j C) = rec (_ , j) (orn C)
-- We can forget the ornamentation and recover an element of the original type.
forget' : {I : Set}{J : I -> Set}{C : Code I}{i : I}{j : J i}
{X : Σ I J -> Set}{Y : I -> Set} ->
({i : I}{j : J i} -> X (i , j) -> Y i) ->
(ΔC : Orn J C) -> ⟦ orn ΔC ⟧ X (i , j) -> ⟦ C ⟧ Y i
forget' φ (out j) refl = refl
forget' φ (arg B) (a , b) = a , forget' φ (B a) b
forget' φ (new A B) (a , b) = forget' φ (B a) b
forget' φ (rec j C) (a , b) = φ a , forget' φ C b
-- The termination checker runs into the same problem as the positivity
-- checker--it can't tell that forget' φ C x is only applying φ to
-- things smaller than x.
-- ASR (08 August 2014): Added the {-# TERMINATING #-} pragma.
{-# TERMINATING #-}
forget : {I : Set}{J : I -> Set}{C : Code I}{i : I}{j : J i}
(ΔC : Orn J C) -> μ (orn ΔC) (i , j) -> μ C i
forget ΔC < x > = < forget' (forget ΔC) ΔC x >
-- A C-algebra over X takes us from ⟦ C ⟧ X i to X i.
Alg : {I : Set} -> Code I -> (I -> Set) -> Set
Alg C X = forall i -> ⟦ C ⟧ X i -> X i
-- We can fold by an algebra.
-- ASR (08 August 2014): Added the {-# TERMINATING #-} pragma.
{-# TERMINATING #-}
fold : {I : Set}{X : I -> Set}{C : Code I} ->
Alg C X -> {i : I} -> μ C i -> X i
fold {C = C} φ < x > = φ _ (map C (fold φ) x)
-- A type can be ornamented an arbitrary algebra over its functor.
decorate : {I : Set}{X : I -> Set}(C : Code I)
(φ : Alg C X) -> Orn X C
decorate (out i) φ = out (φ i refl)
decorate (arg A B) φ = arg \a -> decorate (B a) (\i b -> φ i (a , b))
decorate {X = X} (rec i C) φ = new (X i) \x -> rec x (decorate C \i b -> φ i (x , b))
-- Main theorem: If you have an element in a type decorated by φ, you
-- can recover forgotten decorations by folding with φ. Specialised to
-- lists and vectors we get
-- ∀ xs : Vec A n. length (forget xs) == n.
-- Two-level definition as usual.
thm' : {I : Set}{X J : I -> Set}{Y : Σ I J -> Set}
(C : Code I){i : I}{j : J i}(φ : Alg C J)
(F : {i : I} -> X i -> J i)
(ψ : {i : I}{j : J i} -> Y (i , j) -> X i) ->
({i : I}{j : J i}(z : Y (i , j)) -> F (ψ z) == j) ->
let ΔC = decorate C φ in
(x : ⟦ orn ΔC ⟧ Y (i , j)) ->
φ i (map C F (forget' ψ ΔC x)) == j
thm' (out i) φ F ψ ih refl = refl
thm' (arg A B) φ F ψ ih (a , b) = thm' (B a) (\i b -> φ i (a , b)) F ψ ih b
thm' (rec i C) {i = i0}{j = j0} φ F ψ ih (j , x , c)
with F (ψ x) | ih x | thm' C (\i b -> φ i (j , b)) F ψ ih c
... | .j | refl | rest = rest
-- ASR (08 August 2014): Added the {-# TERMINATING #-}
-- pragma.
{-# TERMINATING #-}
thm : {I : Set}{J : I -> Set}(C : Code I){i : I}{j : J i}(φ : Alg C J) ->
(x : μ (orn (decorate C φ)) (i , j)) ->
fold φ (forget (decorate C φ) x) == j
thm C φ < x > = thm' C φ (fold φ) (forget (decorate C φ)) (thm C φ) x
-- Vectors as decorated lists.
lengthAlg : {A : Set} -> Alg (`List` A) (\_ -> Nat)
lengthAlg _ (enum ."nil" zero , _) = zero
lengthAlg _ (enum ."cons" (suc zero) , x , n , _) = suc n
lengthAlg _ (enum _ (suc (suc ())) , _)
length : {A : Set} -> List A -> Nat
length = fold lengthAlg
-- Now vectors are really lists decorated by their length.
`Vec` : (A : Set) -> Orn (\_ -> Nat) (`List` A)
`Vec` A = decorate (`List` A) lengthAlg
Vec : Set -> Nat -> Set
Vec A n = μ (orn (`Vec` A)) (_ , n)
nil : {A : Set} -> Vec A zero
nil = < enum "nil" zero , refl >
cons : {A : Set}{n : Nat} -> A -> Vec A n -> Vec A (suc n)
cons {n = n} x xs = < enum "cons" (suc zero) , x , n , xs , refl >
-- The proof that the index of the vector is really the length follows directly
-- from our main theorem.
corollary : {A : Set}{n : Nat}(xs : Vec A n) ->
length (forget (`Vec` _) xs) == n
corollary = thm (`List` _) lengthAlg
| 33.919355
| 85
| 0.507529
|
06e9924320ecb29c1f64a5e28f66532d71f9679e
| 127
|
agda
|
Agda
|
test/interaction/Issue620.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Issue620.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Issue620.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Issue620 where
module A where
postulate _+_*_ : Set → Set → Set → Set
postulate X : Set
2X : Set
2X = X A.+ X * X
| 11.545455
| 41
| 0.622047
|
c590af0fad3bdb605cbfb3fdec8ae8a5dafa9578
| 271
|
agda
|
Agda
|
test/interaction/Issue1325.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Issue1325.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Issue1325.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Reported by stevan.andjelkovic, 2014-10-23
-- Case splitting on n in the goal g produces the wrong output, it
-- seems like {n} in f is the problem...
data ℕ : Set where
zero : ℕ
suc : ℕ → ℕ
f : {_ : ℕ} → Set₁
f {n} = Set
where
g : ℕ → Set
g n = {!n!}
| 16.9375
| 66
| 0.583026
|
1dc02a9ff5e1f8632e5d03e50e920e86fb78af4f
| 152
|
agda
|
Agda
|
test/Succeed/Issue4088.agda
|
cagix/agda
|
cc026a6a97a3e517bb94bafa9d49233b067c7559
|
[
"BSD-2-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue4088.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue4088.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
open import Agda.Builtin.Bool
works : Bool → Bool
works b with b | true
... | b′ | _ = b′
fails : Bool → Bool
fails b with b′ ← b | true
... | _ = b′
| 15.2
| 29
| 0.572368
|
a121546e099b4d0ad86d20fc5de2c6eb2788274f
| 670
|
agda
|
Agda
|
vendor/stdlib/src/Relation/Binary/EqReasoning.agda
|
isabella232/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 56
|
2015-01-20T02:11:42.000Z
|
2021-12-21T17:02:19.000Z
|
vendor/stdlib/src/Relation/Binary/EqReasoning.agda
|
larrytheliquid/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 1
|
2022-03-12T12:17:51.000Z
|
2022-03-12T12:17:51.000Z
|
vendor/stdlib/src/Relation/Binary/EqReasoning.agda
|
isabella232/Lemmachine
|
8ef786b40e4a9ab274c6103dc697dcb658cf3db3
|
[
"MIT"
] | 3
|
2015-07-21T16:37:58.000Z
|
2022-03-12T11:54:10.000Z
|
------------------------------------------------------------------------
-- Convenient syntax for equational reasoning
------------------------------------------------------------------------
-- Example use:
-- n*0≡0 : ∀ n → n * 0 ≡ 0
-- n*0≡0 zero = refl
-- n*0≡0 (suc n) =
-- begin
-- suc n * 0
-- ≈⟨ byDef ⟩
-- n * 0 + 0
-- ≈⟨ n+0≡n _ ⟩
-- n * 0
-- ≈⟨ n*0≡0 n ⟩
-- 0
-- ∎
open import Relation.Binary
module Relation.Binary.EqReasoning (s : Setoid) where
open Setoid s
import Relation.Binary.PreorderReasoning as PreR
open PreR preorder public
renaming ( _∼⟨_⟩_ to _≈⟨_⟩_
; _≈⟨_⟩_ to _≡⟨_⟩_
)
| 22.333333
| 72
| 0.401493
|
0bfefcf221636760d53f4e2dc4cdf59fd3f295db
| 13,664
|
agda
|
Agda
|
04-cubical-type-theory/material/Part1.agda
|
bafain/EPIT-2020
|
34742c0409818f8fe581ffc92992d1b5f29f6b47
|
[
"MIT"
] | 97
|
2021-03-19T14:13:37.000Z
|
2022-03-15T13:58:25.000Z
|
04-cubical-type-theory/material/Part1.agda
|
bafain/EPIT-2020
|
34742c0409818f8fe581ffc92992d1b5f29f6b47
|
[
"MIT"
] | 2
|
2021-03-31T18:27:23.000Z
|
2021-04-13T09:03:56.000Z
|
04-cubical-type-theory/material/Part1.agda
|
bafain/EPIT-2020
|
34742c0409818f8fe581ffc92992d1b5f29f6b47
|
[
"MIT"
] | 14
|
2021-03-19T12:36:53.000Z
|
2022-03-22T19:37:21.000Z
|
{-
Part 1: The interval and path types
• The interval in Cubical Agda
• Path and PathP types
• Function extensionality
• Equality in Σ-types
-}
-- To make Agda cubical add the following option
{-# OPTIONS --cubical #-}
module Part1 where
-- To load an Agda file type "C-c C-l" in emacs (the notation "C-c"
-- means that one should hold "CTRL" and press "c", for general
-- documentation about emacs keybindings see:
-- https://www.gnu.org/software/emacs/manual/html_node/efaq/Basic-keys.html)
-- The "Core" package of the agda/cubical library sets things for us
open import Cubical.Core.Primitives public
-- The "Foundations" package of agda/cubical contains a lot of
-- important results (in particular the univalence theorem). As we
-- will develop many things from scratch we don't import it here, but
-- a typical file in the library would import various files from
-- Foundations. To get everything in Foundations write:
--
-- open import Cubical.Foundations.Everything
-- To search for something among the imported files press C-s C-z and
-- then write what you want to search for.
-- Documentation of the Cubical Agda mode can be found at:
-- https://agda.readthedocs.io/en/v2.6.1.3/language/cubical.html
------------------------------------------------------------------------------
-- Agda Basics --
------------------------------------------------------------------------------
-- We parametrize everything by some universe levels (as opposed to
-- Coq we always have to give these explicitly unless we work with the
-- lowest universe)
variable
ℓ ℓ' ℓ'' : Level
-- Universes in Agda are called "Set", but in order to avoid confusion
-- with h-sets we rename them to "Type" in agda/cubical.
-- Functions in Agda are written using equations:
id : {A : Type ℓ} → A → A
id x = x
-- The {A : Type ℓ} notation says that A is an implicit argument of Type ℓ.
-- The notation (x : A) → B and {x : A} → B denotes dependent
-- functions (so B might mention x : A), in other words, Π-types
-- We could also write this using λ-abstraction:
id' : {A : Type ℓ} → A → A
id' = λ x → x
-- To write the nice symbol for the lambda type in "\lambda". To write
-- "ℓ" type in "\ell"
-- Agda supports Unicode symbols natively:
-- https://agda.readthedocs.io/en/latest/tools/emacs-mode.html#unicode-input
-- Agda has no tactics (as opposed to Coq), but we can build Agda
-- terms interactively in emacs by writing a ? as RHS:
--
-- id'' : {A : Type ℓ} → A → A
-- id'' = ?
--
-- Try uncommenting this and pressing "C-c C-l". This will give us a
-- hole and by entering it with the cursor we can get information
-- about what Agda expects us to provide and get help from Agda in
-- providing this.
--
-- By pressing "C-c C-," while having the cursor in the goal Agda
-- shows us the current context and goal. As we're trying to write a
-- function we can press "C-c C-r" (for refine) to have Agda write the
-- λ-abstraction "λ x → ?" automatically for us. If one presses "C-c C-,"
-- in the hole again "x : A" will now be in the context. If we type
-- "x" in the hole and press "C-c C-." Agda will show us that we have
-- an A, which is exactly what we want to provide to fill the goal. By
-- pressing "C-c C-SPACE" Agda will then fill the hole with "x" for us.
--
-- Agda has lots of handy commands like this for manipulating goals:
--
-- https://agda.readthedocs.io/en/latest/tools/emacs-mode.html#commands-in-context-of-a-goal
-- A good resource to get start with Agda is the documentation:
--
-- https://agda.readthedocs.io/en/latest/getting-started/index.html
------------------------------------------------------------------------------
-- The interval and path types --
------------------------------------------------------------------------------
-- The interval in Cubical Agda is written I and the endpoints are
--
-- i0 : I
-- i1 : I
--
-- These stand for "interval 0" and "interval 1".
-- We can apply a function out of the interval to an endpoint just
-- like we would apply any Agda function:
apply0 : (A : Type ℓ) (p : I → A) → A
apply0 A p = p i0
-- The equality type _≡_ is not inductively defined in Cubical Agda,
-- instead it's a builtin primitive. An element of x ≡ y consists of a
-- function p : I → A such that p i0 is definitionally x and p i1 is
-- definitionally y. The check that the endpoints are correct when we
-- provide a p : I → A is automatically performed by Agda during
-- typechecking, so introducing an element of x ≡ y is done just like
-- how we introduce elements of I → A but Agda will check the side
-- conditions.
--
-- We can hence write paths using λ-abstraction:
path1 : {A : Type ℓ} (x : A) → x ≡ x
path1 x = λ i → x
-- As explained above Agda checks that whatever we write as definition
-- matches the path that we have written (so the endpoints have to be
-- correct). In this case everything is fine and path1 can be thought
-- of as a proof reflexivity. Let's give it a nicer name and more
-- implicit arguments:
refl : {A : Type ℓ} {x : A} → x ≡ x
refl {x = x} = λ i → x
-- The notation {x = x} lets us access the implicit argument x (the x
-- in the LHS of x = x) and rename it to x (the x in the RHS x = x) in
-- the body of refl. We could just as well have written:
--
-- refl : {A : Type ℓ} {x : A} → x ≡ x
-- refl {x = y} = λ i → y
-- Note that we cannot pattern-match on interval variables as I is not
-- inductively defined:
--
-- foo : {A : Type} → I → A
-- foo r = {!r!} -- Try typing C-c C-c
-- It often gets tiring to write {A : Type ℓ} everywhere, so let's
-- assume that we have some types:
variable
A B : Type ℓ
-- This will make A and B elements of different universes (all
-- arguments is maximally generalized) and all definitions that use
-- them will have them as implicit arguments.
-- We can now implement some basic operations on _≡_. Let's start with
-- cong (called "ap" in the HoTT book):
cong : (f : A → B) {x y : A} → x ≡ y → f x ≡ f y
cong f p i = f (p i)
-- Note that the definition differs from the HoTT definition in that
-- it is not defined by J or pattern-matching on p, but rather it's
-- just a direct definition as a composition of functions. Agda treats
-- p : x ≡ y like any function, so we can apply it to i to get an
-- element of A which at i0 is x and at i1 is y. By applying f to this
-- element we hence get an element of B which at i0 is f x and at i1
-- is f y.
-- As this is just function composition it satisfies lots of nice
-- definitional equalities, see the Warmup.agda file. Some of these
-- are not satisfied by the HoTT definition of cong/ap.
-- In HoTT function extensionality is proved as a consequence of
-- univalence using a rather ingenious proof due to Voevodsky, but in
-- cubical systems it has a much more direct proof. As paths are just
-- functions we can get it by swapping the arguments to p:
funExt : {f g : A → B} (p : (x : A) → f x ≡ g x) → f ≡ g
funExt p i x = p x i
-- To see that this has the correct type, note that when i is i0 we
-- have "p x i0 = f x" and when i is i1 we have "p x i1 = g x", so by
-- η for function types we have a path f ≡ g as desired.
-- The interval has additional operations:
--
-- Minimum: _∧_ : I → I → I (corresponds to min(i,j))
-- Maximum: _∨_ : I → I → I (corresponds to max(i,j))
-- Symmetry: ~_ : I → I (corresponds to 1 - i)
--
-- Agda remark: the _ in the operator names indicates where arguments
-- should go.
--
-- These satisfy the equations of a De Morgan algebra (i.e. a
-- distributive lattice (_∧_ , _∨_ , i0 , i1) with an "De Morgan"
-- involution ~). This just means that we have the following kinds of
-- equations definitionally:
--
-- i0 ∨ i = i
-- i ∨ i1 = i1
-- i ∨ j = j ∨ i
-- i0 ∧ i = i0
-- i1 ∧ i = i
-- i ∧ j = j ∧ i
-- ~ (~ i) = i
-- i0 = ~ i1
-- ~ (i ∨ j) = ~ i ∧ ~ j
-- ~ (i ∧ j) = ~ i ∨ ~ j
--
-- However, we do not have i ∨ ~ i = i1 and i ∧ ~ i = i0. The reason
-- is that I represents an abstract interval, so we if we think of it
-- as the real interval [0,1] ⊂ ℝ we clearly don't always have
-- "max(i,1-i) = 1" or "min(i,1-i) = 0)" for all i ∈ [0,1].
-- These operations on I are very useful as they let us define even
-- more things directly. For example symmetry of paths is easily
-- defined using ~_
sym : {x y : A} → x ≡ y → y ≡ x
sym p i = p (~ i)
-- The operations _∧_ and _∨_ are called "connections" and let us
-- build higher dimensional cubes from lower dimensional ones, for
-- example if we have a path p : x ≡ y then
--
-- sq i j = p (i ∧ j)
--
-- is a square (as we've parametrized by i and j) with the following
-- boundary:
--
-- sq i0 j = p (i0 ∧ j) = p i0 = x
-- sq i1 j = p (i1 ∧ j) = p j
-- sq i i0 = p (i ∧ i0) = p i0 = x
-- sq i i1 = p (i ∧ i1) = p i
--
-- If we draw this we get:
--
-- p
-- x --------> y
-- ^ ^
-- ¦ ¦
-- refl ¦ sq ¦ p
-- ¦ ¦
-- ¦ ¦
-- x --------> x
-- refl
--
-- Being able to make this square directly is very useful. It for
-- example let's prove that singletons are contractible (aka based
-- path induction).
--
-- We first need the notion of contractible types. For this we need
-- to use a Σ-type:
isContr : Type ℓ → Type ℓ
isContr A = Σ[ x ∈ A ] ((y : A) → x ≡ y)
-- Σ-types are introduced in the file Agda.Builtin.Sigma as the record
--
-- record Σ {ℓ ℓ'} (A : Type ℓ) (B : A → Type ℓ') : Type (ℓ-max ℓ ℓ') where
-- constructor _,_
-- field
-- fst : A
-- snd : B fst
--
-- So the projections are fst/snd and the constructor is _,_. We
-- also define non-dependent product as a special case of Σ-types in
-- Cubical.Data.Sigma.Base as:
--
-- _×_ : ∀ {ℓ ℓ'} (A : Type ℓ) (B : Type ℓ') → Type (ℓ-max ℓ ℓ')
-- A × B = Σ A (λ _ → B)
--
-- The notation ∀ {ℓ ℓ'} lets us omit the type of ℓ and ℓ' in the
-- definition.
-- We define the type of singletons as follows
singl : {A : Type ℓ} (a : A) → Type ℓ
singl {A = A} a = Σ[ x ∈ A ] a ≡ x
-- To show that this type is contractible we need to provide a center
-- of contraction and the fact that any element of it is path-equal to
-- the center
isContrSingl : (x : A) → isContr (singl x)
isContrSingl x = ctr , prf
where
-- The center is just a pair with x and refl
ctr : singl x
ctr = x , refl
-- We then need to prove that ctr is equal to any element s : singl x.
-- This is an equality in a Σ-type, so the first component is a path
-- and the second is a path over the path we pick as first argument,
-- i.e. the second component is a square. In fact, we need a square
-- relating refl and pax over a path between refl and pax, so we can
-- use an _∧_ connection.
prf : (s : singl x) → ctr ≡ s
prf (y , pax) i = (pax i) , λ j → pax (i ∧ j)
-- Agda tip: in order to automatically destruct an argument x
-- (like (y , pax) in prf) write x in the hole and type
-- C-c C-c. Agda might pick silly names, but it's still very
-- convenient.
-- As we saw in the second component of prf we often need squares when
-- proving things. In fact, pax (i ∧ j) is a path relating refl to pax
-- *over* another path "λ j → x ≡ pax j". This notion of path over a
-- path is very useful when working in HoTT as well as cubically. In
-- HoTT these are called path-overs and are defined using transport,
-- but in Cubical Agda they are a primitive notion called PathP ("Path
-- over a Path"). In general PathP A x y has
--
-- A : I → Type ℓ
-- x : A i0
-- y : A i1
--
-- So PathP lets us natively define heteorgeneous paths, i.e. paths
-- where the endpoints are in different types. This allows us to
-- specify the type of the second component of prf:
prf' : (x : A) (s : singl x) → (x , refl) ≡ s
prf' x (y , pax) i = (pax i) , λ j → goal i j
where
goal : PathP (λ j → x ≡ pax j) refl pax
goal i j = pax (i ∧ j)
-- Just like _×_ is a special case of Σ-types we have that _≡_ is a
-- special case of PathP. In fact, x ≡ y is just short for PathP (λ _ → A) x y:
reflP : {x : A} → PathP (λ _ → A) x x
reflP = refl
-- Having the primitive notion of equality be heterogeneous is an
-- easily overlooked, but very important, strength of cubical type
-- theory. This allows us to work directly with equality in Σ-types
-- without using transport:
module _ {A : Type ℓ} {B : A → Type ℓ'} {x y : Σ A B} where
ΣPathP : Σ[ p ∈ fst x ≡ fst y ] PathP (λ i → B (p i)) (snd x) (snd y)
→ x ≡ y
ΣPathP eq i = fst eq i , snd eq i
PathPΣ : x ≡ y
→ Σ[ p ∈ fst x ≡ fst y ] PathP (λ i → B (p i)) (snd x) (snd y)
PathPΣ eq = (λ i → fst (eq i)) , (λ i → snd (eq i))
-- The fact that these cancel is proved by refl
-- If one looks carefully the proof of prf uses ΣPathP inlined, in
-- fact this is used all over the place when working cubically and
-- simplifies many proofs which in HoTT requires long complicated
-- reasoning about transport.
isContrΠ : {B : A → Type ℓ'} (h : (x : A) → isContr (B x))
→ isContr ((x : A) → B x)
isContrΠ h = (λ x → fst (h x)) , (λ f i x → snd (h x) (f x) i)
-- Let us end this session with defining propositions and sets
isProp : Type ℓ → Type ℓ
isProp A = (x y : A) → x ≡ y
isSet : Type ℓ → Type ℓ
isSet A = (x y : A) → isProp (x ≡ y)
-- In the agda/cubical library we call these h-levels following
-- Voevodsky instead of n-types and index by natural numbers instead
-- of ℕ₋₂. So isContr is isOfHLevel 0, isProp is isOfHLevel 1, isSet
-- is isOfHLevel 2, etc. For details see Cubical/Foundations/HLevels.agda
| 36.731183
| 92
| 0.625585
|
0e141fea7a1792714762e3c127daed21cf34e9ca
| 1,404
|
agda
|
Agda
|
Cubical/HITs/GroupoidQuotients/Base.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 301
|
2018-10-17T18:00:24.000Z
|
2022-03-24T02:10:47.000Z
|
Cubical/HITs/GroupoidQuotients/Base.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 584
|
2018-10-15T09:49:02.000Z
|
2022-03-30T12:09:17.000Z
|
Cubical/HITs/GroupoidQuotients/Base.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 134
|
2018-11-16T06:11:03.000Z
|
2022-03-23T16:22:13.000Z
|
{-
This file contains:
- Definition of groupoid quotients
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.HITs.GroupoidQuotients.Base where
open import Cubical.Foundations.Prelude
open import Cubical.Relation.Binary.Base
-- Groupoid quotients as a higher inductive type:
-- For the definition, only transitivity is needed
data _//_ {ℓ ℓ'} (A : Type ℓ) {R : A → A → Type ℓ'}
(Rt : BinaryRelation.isTrans R) : Type (ℓ-max ℓ ℓ') where
[_] : (a : A) → A // Rt
eq// : {a b : A} → (r : R a b) → [ a ] ≡ [ b ]
comp// : {a b c : A} → (r : R a b) → (s : R b c)
→ PathP (λ j → [ a ] ≡ eq// s j) (eq// r) (eq// (Rt a b c r s))
squash// : ∀ (x y : A // Rt) (p q : x ≡ y) (r s : p ≡ q) → r ≡ s
{- The comp// constructor fills the square:
eq// (Rt a b c r s)
[a]— — — >[c]
‖ ^
‖ | eq// s ^
‖ | j |
[a]— — — >[b] ∙ — >
eq// r i
We use this to give another constructor-like construction:
-}
comp'// : {ℓ ℓ' : Level} (A : Type ℓ) {R : A → A → Type ℓ'}
(Rt : BinaryRelation.isTrans R)
{a b c : A} → (r : R a b) → (s : R b c)
→ eq// {Rt = Rt} (Rt a b c r s) ≡ eq// r ∙ eq// s
comp'// A Rt r s i = compPath-unique refl (eq// r) (eq// s)
(eq// {Rt = Rt} (Rt _ _ _ r s) , comp// r s)
(eq// r ∙ eq// s , compPath-filler (eq// r) (eq// s)) i .fst
| 31.909091
| 73
| 0.478632
|
204aca68e92a50a869b23ed561d2c359e9c7e7d7
| 4,074
|
agda
|
Agda
|
Formalization/ClassicalPropositionalLogic/NaturalDeduction.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | 6
|
2020-04-07T17:58:13.000Z
|
2022-02-05T06:53:22.000Z
|
Formalization/ClassicalPropositionalLogic/NaturalDeduction.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
Formalization/ClassicalPropositionalLogic/NaturalDeduction.agda
|
Lolirofle/stuff-in-agda
|
70f4fba849f2fd779c5aaa5af122ccb6a5b271ba
|
[
"MIT"
] | null | null | null |
module Formalization.ClassicalPropositionalLogic.NaturalDeduction where
open import Data.Either as Either using (Left ; Right)
open import Formalization.ClassicalPropositionalLogic.Syntax
open import Functional
import Lvl
import Logic.Propositional as Meta
open import Logic
open import Relator.Equals
open import Relator.Equals.Proofs.Equiv
open import Sets.PredicateSet using (PredSet ; _∈_ ; _∉_ ; _∪_ ; _∪•_ ; _∖_ ; _⊆_ ; _⊇_ ; ∅ ; [≡]-to-[⊆] ; [≡]-to-[⊇]) renaming (•_ to singleton ; _≡_ to _≡ₛ_)
open import Type
private variable ℓₚ ℓ ℓ₁ ℓ₂ : Lvl.Level
data _⊢_ {ℓ ℓₚ} {P : Type{ℓₚ}} : Formulas(P){ℓ} → Formula(P) → Stmt{Lvl.𝐒(ℓₚ Lvl.⊔ ℓ)} where
direct : ∀{Γ} → (Γ ⊆ (Γ ⊢_))
[⊤]-intro : ∀{Γ} → (Γ ⊢ ⊤)
[⊥]-intro : ∀{Γ}{φ} → (Γ ⊢ φ) → (Γ ⊢ (¬ φ)) → (Γ ⊢ ⊥)
[⊥]-elim : ∀{Γ}{φ} → (Γ ⊢ ⊥) → (Γ ⊢ φ)
[¬]-intro : ∀{Γ}{φ} → ((Γ ∪ singleton(φ)) ⊢ ⊥) → (Γ ⊢ (¬ φ))
[¬]-elim : ∀{Γ}{φ} → ((Γ ∪ singleton(¬ φ)) ⊢ ⊥) → (Γ ⊢ φ)
[∧]-intro : ∀{Γ}{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ ψ) → (Γ ⊢ (φ ∧ ψ))
[∧]-elimₗ : ∀{Γ}{φ ψ} → (Γ ⊢ (φ ∧ ψ)) → (Γ ⊢ φ)
[∧]-elimᵣ : ∀{Γ}{φ ψ} → (Γ ⊢ (φ ∧ ψ)) → (Γ ⊢ ψ)
[∨]-introₗ : ∀{Γ}{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ (φ ∨ ψ))
[∨]-introᵣ : ∀{Γ}{φ ψ} → (Γ ⊢ ψ) → (Γ ⊢ (φ ∨ ψ))
[∨]-elim : ∀{Γ}{φ ψ χ} → ((Γ ∪ singleton(φ)) ⊢ χ) → ((Γ ∪ singleton(ψ)) ⊢ χ) → (Γ ⊢ (φ ∨ ψ)) → (Γ ⊢ χ)
[⟶]-intro : ∀{Γ}{φ ψ} → ((Γ ∪ singleton(φ)) ⊢ ψ) → (Γ ⊢ (φ ⟶ ψ))
[⟶]-elim : ∀{Γ}{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ (φ ⟶ ψ)) → (Γ ⊢ ψ)
[⟷]-intro : ∀{Γ}{φ ψ} → ((Γ ∪ singleton(ψ)) ⊢ φ) → ((Γ ∪ singleton(φ)) ⊢ ψ) → (Γ ⊢ (φ ⟷ ψ))
[⟷]-elimₗ : ∀{Γ}{φ ψ} → (Γ ⊢ ψ) → (Γ ⊢ (φ ⟷ ψ)) → (Γ ⊢ φ)
[⟷]-elimᵣ : ∀{Γ}{φ ψ} → (Γ ⊢ φ) → (Γ ⊢ (φ ⟷ ψ)) → (Γ ⊢ ψ)
module _ where
private variable P : Type{ℓₚ}
private variable Γ Γ₁ Γ₂ : Formulas(P){ℓ}
private variable φ ψ : Formula(P)
_⊬_ : Formulas(P){ℓ} → Formula(P) → Stmt
_⊬_ = Meta.¬_ ∘₂ (_⊢_)
weaken-union-singleton : (Γ₁ ⊆ Γ₂) → (((Γ₁ ∪ singleton(φ)) ⊢_) ⊆ ((Γ₂ ∪ singleton(φ)) ⊢_))
weaken : (Γ₁ ⊆ Γ₂) → ((Γ₁ ⊢_) ⊆ (Γ₂ ⊢_))
weaken Γ₁Γ₂ {φ} (direct p) = direct (Γ₁Γ₂ p)
weaken Γ₁Γ₂ {.⊤} [⊤]-intro = [⊤]-intro
weaken Γ₁Γ₂ {.⊥} ([⊥]-intro p q) = [⊥]-intro (weaken Γ₁Γ₂ p) (weaken Γ₁Γ₂ q)
weaken Γ₁Γ₂ {φ} ([⊥]-elim p) = [⊥]-elim (weaken Γ₁Γ₂ p)
weaken Γ₁Γ₂ {.(¬ _)} ([¬]-intro p) = [¬]-intro (weaken-union-singleton Γ₁Γ₂ p)
weaken Γ₁Γ₂ {φ} ([¬]-elim p) = [¬]-elim (weaken-union-singleton Γ₁Γ₂ p)
weaken Γ₁Γ₂ {.(_ ∧ _)} ([∧]-intro p q) = [∧]-intro (weaken Γ₁Γ₂ p) (weaken Γ₁Γ₂ q)
weaken Γ₁Γ₂ {φ} ([∧]-elimₗ p) = [∧]-elimₗ (weaken Γ₁Γ₂ p)
weaken Γ₁Γ₂ {φ} ([∧]-elimᵣ p) = [∧]-elimᵣ (weaken Γ₁Γ₂ p)
weaken Γ₁Γ₂ {.(_ ∨ _)} ([∨]-introₗ p) = [∨]-introₗ (weaken Γ₁Γ₂ p)
weaken Γ₁Γ₂ {.(_ ∨ _)} ([∨]-introᵣ p) = [∨]-introᵣ (weaken Γ₁Γ₂ p)
weaken Γ₁Γ₂ {φ} ([∨]-elim p q r) = [∨]-elim (weaken-union-singleton Γ₁Γ₂ p) (weaken-union-singleton Γ₁Γ₂ q) (weaken Γ₁Γ₂ r)
weaken Γ₁Γ₂ {.(_ ⟶ _)} ([⟶]-intro p) = [⟶]-intro (weaken-union-singleton Γ₁Γ₂ p)
weaken Γ₁Γ₂ {φ} ([⟶]-elim p q) = [⟶]-elim (weaken Γ₁Γ₂ p) (weaken Γ₁Γ₂ q)
weaken Γ₁Γ₂ {.(_ ⟷ _)} ([⟷]-intro p q) = [⟷]-intro (weaken-union-singleton Γ₁Γ₂ p) (weaken-union-singleton Γ₁Γ₂ q)
weaken Γ₁Γ₂ {φ} ([⟷]-elimₗ p q) = [⟷]-elimₗ (weaken Γ₁Γ₂ p) (weaken Γ₁Γ₂ q)
weaken Γ₁Γ₂ {φ} ([⟷]-elimᵣ p q) = [⟷]-elimᵣ (weaken Γ₁Γ₂ p) (weaken Γ₁Γ₂ q)
weaken-union-singleton Γ₁Γ₂ p = weaken (Either.mapLeft Γ₁Γ₂) p
weaken-union : (Γ₁ ⊢_) ⊆ ((Γ₁ ∪ Γ₂) ⊢_)
weaken-union = weaken Either.Left
[⟵]-intro : ((Γ ∪ singleton(φ)) ⊢ ψ) → (Γ ⊢ (ψ ⟵ φ))
[⟵]-intro = [⟶]-intro
[⟵]-elim : (Γ ⊢ φ) → (Γ ⊢ (ψ ⟵ φ)) → (Γ ⊢ ψ)
[⟵]-elim = [⟶]-elim
[¬¬]-elim : (Γ ⊢ ¬(¬ φ)) → (Γ ⊢ φ)
[¬¬]-elim nnφ =
([¬]-elim
([⊥]-intro
(direct(Right [≡]-intro))
(weaken-union nnφ)
)
)
[¬¬]-intro : (Γ ⊢ φ) → (Γ ⊢ ¬(¬ φ))
[¬¬]-intro Γφ =
([¬]-intro
([⊥]-intro
(weaken-union Γφ)
(direct (Right [≡]-intro))
)
)
| 40.74
| 159
| 0.476436
|
0e0b30442d3498a0d2177ebb8aa17e203e178a2e
| 612
|
agda
|
Agda
|
agda-stdlib/src/Algebra/FunctionProperties.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Algebra/FunctionProperties.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Algebra/FunctionProperties.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 `Algebra` or
-- `Algebra.Definitions` instead.
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
open import Relation.Binary.Core using (Rel)
module Algebra.FunctionProperties {a ℓ} {A : Set a} (_≈_ : Rel A ℓ) where
{-# WARNING_ON_IMPORT
"Algebra.FunctionProperties was deprecated in v1.2.
Use Algebra.Definitions instead."
#-}
open import Algebra.Core public
open import Algebra.Definitions _≈_ public
| 29.142857
| 73
| 0.560458
|
1dc00c0e89b3d9eb33593835750b2a2981210699
| 427
|
agda
|
Agda
|
Cats/Util/Function.agda
|
alessio-b-zak/cats
|
a3b69911c4c6ec380ddf6a0f4510d3a755734b86
|
[
"MIT"
] | null | null | null |
Cats/Util/Function.agda
|
alessio-b-zak/cats
|
a3b69911c4c6ec380ddf6a0f4510d3a755734b86
|
[
"MIT"
] | null | null | null |
Cats/Util/Function.agda
|
alessio-b-zak/cats
|
a3b69911c4c6ec380ddf6a0f4510d3a755734b86
|
[
"MIT"
] | null | null | null |
module Cats.Util.Function where
open import Relation.Binary using (Rel ; IsEquivalence ; _Preserves₂_⟶_⟶_)
open import Relation.Binary.PropositionalEquality as ≡
open import Function as Fun public using (id ; _on_)
open import Relation.Binary.Construct.On public
renaming (isEquivalence to on-isEquivalence)
infixr 9 _∘_
_∘_ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} → (B → C) → (A → B) → A → C
f ∘ g = f Fun.∘ g
| 26.6875
| 79
| 0.688525
|
50e8b091cc4666b4fb34c02034c931a032d8a1d5
| 6,405
|
agda
|
Agda
|
RW/RW.agda
|
VictorCMiraldo/agda-rw
|
2856afd12b7dbbcc908482975638d99220f38bf2
|
[
"MIT"
] | 16
|
2015-02-09T15:43:38.000Z
|
2019-10-24T17:38:20.000Z
|
RW/RW.agda
|
VictorCMiraldo/agda-rw
|
2856afd12b7dbbcc908482975638d99220f38bf2
|
[
"MIT"
] | 4
|
2015-02-06T15:03:33.000Z
|
2015-05-28T14:48:03.000Z
|
RW/RW.agda
|
VictorCMiraldo/agda-rw
|
2856afd12b7dbbcc908482975638d99220f38bf2
|
[
"MIT"
] | null | null | null |
open import Prelude
open import Reflection renaming (Term to AgTerm; Type to AgType)
open import Data.String using (String)
open import RW.Language.RTerm
open import RW.Language.RTermUtils
open import RW.Language.FinTerm
open import RW.Language.GoalGuesser 1
open import RW.Strategy
module RW.RW (db : TStratDB) where
open import RW.Utils.Monads
open import RW.Utils.Error
open Monad {{...}}
open IsError {{...}}
------------------
-- Housekeeping --
------------------
-- We need to bring our instances into scope explicitely,
-- to make Agda happy.
private
instance
ErrErr = IsError-StratErr
ErrMonad = MonadError
unarg : {A : Set} → Arg A → A
unarg (arg _ x) = x
-- We need to translate types to FinTerms, so we know how many variables
-- we're expecting to guess from instantiation.
Ag2RTypeFin : AgType → ∃ FinTerm
Ag2RTypeFin = R2FinType ∘ lift-ivar ∘ η ∘ Ag2RType
-- TODO: fix the duality: "number of ivar's lifted to ovar's vs. parameters we need to guess"
make-RWData : Name → AgTerm → List (Arg AgType) → Err StratErr RWData
make-RWData act goal ctx with η (Ag2RTerm goal) | Ag2RTypeFin (type act) | map (Ag2RType ∘ unarg) ctx
...| g' | tyℕ , ty | ctx' with forceBinary g' | forceBinary (typeResult ty)
...| just g | just a = return (rw-data g tyℕ a ctx')
...| just _ | nothing = throwError (Custom "Something strange happened with the action")
...| nothing | just _ = throwError (Custom "Something strange happened with the goal")
...| nothing | nothing = throwError (Custom "My brain just exploded.")
-- Given a goal and a list of actions to apply to such goal, return
-- a list l₁ ⋯ lₙ such that ∀ 0 < i ≤ n . tyᵢ : p1 lᵢ → p1 lᵢ₊₁
Ag2RTypeFin* : RTerm ⊥ → List AgType → Maybe (List (RBinApp ⊥ × ∃ (RBinApp ∘ Fin)))
Ag2RTypeFin* (rapp n (g₁ ∷ g₂ ∷ [])) tys
= mapM (return ∘ Ag2RTypeFin) tys
>>= mapM (λ v → forceBinary (typeResult (p2 v)) >>= (return ∘ (_,_ $ p1 v)))
>>= λ tys' → (divideGoal (n , g₁ , g₂) tys' >>= assemble)
>>= λ gs → return (zip gs tys')
where
assemble : {A : Set} → List (RTerm A) → Maybe (List (RBinApp A))
assemble (x1 ∷ x2 ∷ []) = just ((n , x1 , x2) ∷ [])
assemble (x1 ∷ x2 ∷ l) = assemble (x2 ∷ l) >>= return ∘ (_∷_ (n , x1 , x2))
assemble _ = nothing
Ag2RTypeFin* _ _ = nothing
-- Produces a list of RWData, one for each 'guessed' step.
make-RWData* : List Name → AgTerm → List (Arg AgType) → Err StratErr (List RWData)
make-RWData* acts goal ctx with Ag2RTerm goal | map type acts | map (Ag2RType ∘ unarg) ctx
...| g' | tys | ctx' with Ag2RTypeFin* g' tys
...| nothing = throwError (Custom "Are you sure you can apply those steps?")
...| just r = i2 (map (λ x → rw-data (p1 x) (p1 (p2 x)) (p2 (p2 x)) ctx') r)
postulate
RW-error : ∀{a}{A : Set a} → String → A
RWerr : Name → RWData → Err StratErr (RWData × UData × RTerm ⊥)
RWerr act d
= runUStrats d
>>= λ u → runTStrats db d act u
>>= λ v → return (d , u , v)
-- A variant with less information, more suitable to be map'ed.
RWerr-less : Name → RWData → Err StratErr (RTerm ⊥)
RWerr-less act d = RWerr act d >>= return ∘ p2 ∘ p2
----------------
-- By Tactics --
----------------
-- Standard debugging version.
by' : Name → List (Arg AgType) → AgTerm → (RWData × UData × RTerm ⊥)
by' act ctx goal with runErr (make-RWData act goal ctx >>= RWerr act)
...| i1 err = RW-error err
...| i2 term = term
-- This function is only beeing used to pass the context
-- given by the 'tactic' keyword around.
by : Name → List (Arg AgType) → AgTerm → AgTerm
by act ctx goal = R2AgTerm ∘ p2 ∘ p2 $ (by' act ctx goal)
-- Handling multiple actions, naive way.
-- by+ is pretty much foldM (<|>) error (by ⋯),
-- where (<|>) is the usual alternative from Error Monad.
by+ : List Name → List (Arg AgType) → AgTerm → AgTerm
by+ [] _ _ = RW-error "No suitable action"
by+ (a ∷ as) ctx goal with runErr (make-RWData a goal ctx >>= RWerr a)
...| i1 _ = by+ as ctx goal
...| i2 t = R2AgTerm ∘ p2 ∘ p2 $ t
join-tr : Name → List (RTerm ⊥) → RTerm ⊥
join-tr _ [] = ivar 0
join-tr tr (x ∷ l) = foldr (λ h r → rapp (rdef tr) (r ∷ h ∷ [])) x l
-- Handling multiple goals.
by*-err : Name → List Name → List (Arg AgType) → AgTerm → Err StratErr AgTerm
by*-err tr acts ctx goal
= make-RWData* acts goal ctx
>>= λ l → mapM (uncurry RWerr-less) (zip acts l)
>>= return ∘ R2AgTerm ∘ join-tr tr
where
unzip : {A B : Set} → List (A × B) → List A × List B
unzip [] = [] , []
unzip ((a , b) ∷ l) with unzip l
...| la , lb = a ∷ la , b ∷ lb
by*-tactic : Set
by*-tactic = List Name → List (Arg AgType) → AgTerm → AgTerm
by* : Name → by*-tactic
by* tr acts ctx goal with runErr (by*-err tr acts ctx goal)
...| i1 err = RW-error err
...| i2 res = res
------------------------------
-- Adding Tries to the cake --
------------------------------
-- The proper way to handle multiple actions.
open import RW.Data.RTrie
module Auto
(bt : RTrie) -- which trie to use,
(newHd : RTermName → RTermName) -- given the goal head, how to build the head for the action.
where
open import RW.Language.RTermTrie
our-strategy : RTermName → Name → UData → Err StratErr (RTerm ⊥)
our-strategy goal
= maybe
TStrat.how
(const $ const $ i1 no-strat)
$ filter-db db
where
no-strat : StratErr
no-strat = NoTStrat goal (newHd goal)
filter-db : TStratDB → Maybe TStrat
filter-db [] = nothing
filter-db (s ∷ ss) with TStrat.when s goal (newHd goal)
...| false = filter-db ss
...| true = just s
auto-internal : List (Arg AgType) → AgTerm → Err StratErr AgTerm
auto-internal _ goal with forceBinary $ Ag2RTerm goal
...| nothing = i1 $ Custom "non-binary goal"
...| just (hd , g₁ , g₂)
= let
options = search-action (newHd hd) (hd , g₁ , g₂) bt
strat = uncurry $ our-strategy hd
err = Custom "No option was succesful"
in try-all strat err options >>= return ∘ R2AgTerm
auto : List (Arg AgType) → AgTerm → AgTerm
auto ctx goal with runErr (auto-internal ctx goal)
...| i1 err = RW-error err
...| i2 r = r
| 36.392045
| 103
| 0.587822
|
0b2f9926d1b82b7faa7b727f9e66c1757b0b90f7
| 9,090
|
agda
|
Agda
|
Cubical/Algebra/Group/Algebra.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/Group/Algebra.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/Group/Algebra.agda
|
knrafto/cubical
|
f6771617374bfe65a7043d00731fed5a673aa729
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Algebra.Group.Algebra where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Function using (_∘_)
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Data.Sigma
open import Cubical.Data.Unit
open import Cubical.Algebra.Group.Base
open import Cubical.Algebra.Group.Properties
open import Cubical.Algebra.Group.Morphism
open import Cubical.Algebra.Group.MorphismProperties
open import Cubical.HITs.PropositionalTruncation hiding (map)
-- open import Cubical.Data.Group.Base
open Iso
open Group
open GroupHom
private
variable
ℓ ℓ₁ ℓ₂ ℓ₃ : Level
------- elementary properties of morphisms --------
-- (- 0) = 0
-0≡0 : ∀ {ℓ} {G : Group {ℓ}} → (- G) (0g G) ≡ (0g G) -- - 0 ≡ 0
-0≡0 {G = G} = sym (IsGroup.lid (isGroup G) _) ∙ fst (IsGroup.inverse (isGroup G) _)
-- ϕ(0) ≡ 0
morph0→0 : ∀ {ℓ ℓ'} (G : Group {ℓ}) (H : Group {ℓ'}) (f : GroupHom G H)
→ fun f (0g G) ≡ 0g H
morph0→0 G H f =
(fun f) (0g G) ≡⟨ sym (IsGroup.rid (isGroup H) _) ⟩
(f' (0g G) H.+ 0g H) ≡⟨ (λ i → f' (0g G) H.+ invr H (f' (0g G)) (~ i)) ⟩
(f' (0g G) H.+ (f' (0g G) H.+ (H.- f' (0g G)))) ≡⟨ (Group.assoc H (f' (0g G)) (f' (0g G)) (H.- (f' (0g G)))) ⟩
((f' (0g G) H.+ f' (0g G)) H.+ (H.- f' (0g G))) ≡⟨ sym (cong (λ x → x H.+ (H.- f' (0g G))) (sym (cong f' (IsGroup.lid (isGroup G) _)) ∙ isHom f (0g G) (0g G))) ⟩
(f' (0g G)) H.+ (H.- (f' (0g G))) ≡⟨ invr H (f' (0g G)) ⟩
0g H ∎
where
module G = Group G
module H = Group H
f' = fun f
-- ϕ(- x) = - ϕ(x)
morphMinus : ∀ {ℓ ℓ'} (G : Group {ℓ}) (H : Group {ℓ'}) → (ϕ : GroupHom G H)
→ (g : ⟨ G ⟩) → fun ϕ ((- G) g) ≡ (- H) (fun ϕ g)
morphMinus G H ϕ g =
f (G.- g) ≡⟨ sym (IsGroup.rid (isGroup H) (f (G.- g))) ⟩
(f (G.- g) H.+ 0g H) ≡⟨ cong (f (G.- g) H.+_) (sym (invr H (f g))) ⟩
(f (G.- g) H.+ (f g H.+ (H.- f g))) ≡⟨ Group.assoc H (f (G.- g)) (f g) (H.- f g) ⟩
((f (G.- g) H.+ f g) H.+ (H.- f g)) ≡⟨ cong (H._+ (H.- f g)) helper ⟩
(0g H H.+ (H.- f g)) ≡⟨ IsGroup.lid (isGroup H) (H.- (f g))⟩
H.- (f g) ∎
where
module G = Group G
module H = Group H
f = fun ϕ
helper : (f (G.- g) H.+ f g) ≡ 0g H
helper = sym (isHom ϕ (G.- g) g) ∙∙ cong f (invl G g) ∙∙ morph0→0 G H ϕ
-- ----------- Alternative notions of isomorphisms --------------
record GroupIso {ℓ ℓ'} (G : Group {ℓ}) (H : Group {ℓ'}) : Type (ℓ-max ℓ ℓ') where
no-eta-equality
constructor iso
field
map : GroupHom G H
inv : ⟨ H ⟩ → ⟨ G ⟩
rightInv : section (GroupHom.fun map) inv
leftInv : retract (GroupHom.fun map) inv
record BijectionIso {ℓ ℓ'} (A : Group {ℓ}) (B : Group {ℓ'}) : Type (ℓ-max ℓ ℓ') where
constructor bij-iso
field
map' : GroupHom A B
inj : isInjective A B map'
surj : isSurjective A B map'
-- "Very" short exact sequences
-- i.e. an exact sequence A → B → C → D where A and D are trivial
record vSES {ℓ ℓ' ℓ'' ℓ'''} (A : Group {ℓ}) (B : Group {ℓ'}) (leftGr : Group {ℓ''}) (rightGr : Group {ℓ'''})
: Type (ℓ-suc (ℓ-max ℓ (ℓ-max ℓ' (ℓ-max ℓ'' ℓ''')))) where
constructor ses
field
isTrivialLeft : isProp ⟨ leftGr ⟩
isTrivialRight : isProp ⟨ rightGr ⟩
left : GroupHom leftGr A
right : GroupHom B rightGr
ϕ : GroupHom A B
Ker-ϕ⊂Im-left : (x : ⟨ A ⟩)
→ isInKer A B ϕ x
→ isInIm leftGr A left x
Ker-right⊂Im-ϕ : (x : ⟨ B ⟩)
→ isInKer B rightGr right x
→ isInIm A B ϕ x
open BijectionIso
open GroupIso
open vSES
compGroupIso : {G : Group {ℓ}} {H : Group {ℓ₁}} {A : Group {ℓ₂}} → GroupIso G H → GroupIso H A → GroupIso G A
map (compGroupIso iso1 iso2) = compGroupHom (map iso1) (map iso2)
inv (compGroupIso iso1 iso2) = inv iso1 ∘ inv iso2
rightInv (compGroupIso iso1 iso2) a = cong (fun (map iso2)) (rightInv iso1 _) ∙ rightInv iso2 a
leftInv (compGroupIso iso1 iso2) a = cong (inv iso1) (leftInv iso2 _) ∙ leftInv iso1 a
isGroupHomInv' : {G : Group {ℓ}} {H : Group {ℓ₁}} (f : GroupIso G H) → isGroupHom H G (inv f)
isGroupHomInv' {G = G} {H = H} f h h' = isInj-f _ _ (
f' (g (h ⋆² h')) ≡⟨ (rightInv f) _ ⟩
(h ⋆² h') ≡⟨ sym (cong₂ _⋆²_ (rightInv f h) (rightInv f h')) ⟩
(f' (g h) ⋆² f' (g h')) ≡⟨ sym (isHom (map f) _ _) ⟩ -- sym (isHom (hom f) _ _) ⟩
f' (g h ⋆¹ g h') ∎)
where
f' = fun (map f)
_⋆¹_ = Group._+_ G
_⋆²_ = Group._+_ H
g = inv f -- invEq (eq f)
isInj-f : (x y : ⟨ G ⟩) → f' x ≡ f' y → x ≡ y
isInj-f x y p = sym (leftInv f _) ∙∙ cong g p ∙∙ leftInv f _
invGroupIso : {G : Group {ℓ}} {H : Group {ℓ₁}} → GroupIso G H → GroupIso H G
fun (map (invGroupIso iso1)) = inv iso1
isHom (map (invGroupIso iso1)) = isGroupHomInv' iso1
inv (invGroupIso iso1) = fun (map iso1)
rightInv (invGroupIso iso1) = leftInv iso1
leftInv (invGroupIso iso1) = rightInv iso1
dirProdGroupIso : {G : Group {ℓ}} {H : Group {ℓ₁}} {A : Group {ℓ₂}} {B : Group {ℓ₃}}
→ GroupIso G H → GroupIso A B → GroupIso (dirProd G A) (dirProd H B)
fun (map (dirProdGroupIso iso1 iso2)) prod = fun (map iso1) (fst prod) , fun (map iso2) (snd prod)
isHom (map (dirProdGroupIso iso1 iso2)) a b = ΣPathP (isHom (map iso1) (fst a) (fst b) , isHom (map iso2) (snd a) (snd b))
inv (dirProdGroupIso iso1 iso2) prod = (inv iso1) (fst prod) , (inv iso2) (snd prod)
rightInv (dirProdGroupIso iso1 iso2) a = ΣPathP (rightInv iso1 (fst a) , (rightInv iso2 (snd a)))
leftInv (dirProdGroupIso iso1 iso2) a = ΣPathP (leftInv iso1 (fst a) , (leftInv iso2 (snd a)))
GrIsoToGrEquiv : {G : Group {ℓ}} {H : Group {ℓ₂}} → GroupIso G H → GroupEquiv G H
GroupEquiv.eq (GrIsoToGrEquiv i) = isoToEquiv (iso (fun (map i)) (inv i) (rightInv i) (leftInv i))
GroupEquiv.isHom (GrIsoToGrEquiv i) = isHom (map i)
--- Proofs that BijectionIso and vSES both induce isomorphisms ---
BijectionIsoToGroupIso : {A : Group {ℓ}} {B : Group {ℓ₂}} → BijectionIso A B → GroupIso A B
BijectionIsoToGroupIso {A = A} {B = B} i = grIso
where
module A = Group A
module B = Group B
f = fun (map' i)
helper : (b : _) → isProp (Σ[ a ∈ ⟨ A ⟩ ] f a ≡ b)
helper _ a b =
Σ≡Prop (λ _ → isSetCarrier B _ _)
(fst a ≡⟨ sym (IsGroup.rid (isGroup A) (fst a)) ⟩
((fst a) A.+ 0g A) ≡⟨ cong ((fst a) A.+_) (sym (invl A (fst b))) ⟩
((fst a) A.+ ((A.- fst b) A.+ fst b)) ≡⟨ Group.assoc A _ _ _ ⟩
(((fst a) A.+ (A.- fst b)) A.+ fst b) ≡⟨ cong (A._+ fst b) idHelper ⟩
(0g A A.+ fst b) ≡⟨ IsGroup.lid (isGroup A) (fst b) ⟩
fst b ∎)
where
idHelper : fst a A.+ (A.- fst b) ≡ 0g A
idHelper =
inj i _
(isHom (map' i) (fst a) (A.- (fst b))
∙ (cong (f (fst a) B.+_) (morphMinus A B (map' i) (fst b))
∙∙ cong (B._+ (B.- f (fst b))) (snd a ∙ sym (snd b))
∙∙ invr B (f (fst b))))
grIso : GroupIso A B
map grIso = map' i
inv grIso b = (rec (helper b) (λ a → a) (surj i b)) .fst
rightInv grIso b = (rec (helper b) (λ a → a) (surj i b)) .snd
leftInv grIso b j = rec (helper (f b)) (λ a → a) (propTruncIsProp (surj i (f b)) ∣ b , refl ∣ j) .fst
BijectionIsoToGroupEquiv : {A : Group {ℓ}} {B : Group {ℓ₂}} → BijectionIso A B → GroupEquiv A B
BijectionIsoToGroupEquiv i = GrIsoToGrEquiv (BijectionIsoToGroupIso i)
vSES→GroupIso : ∀ {ℓ ℓ' ℓ'' ℓ'''} {A : Group {ℓ}} {B : Group {ℓ'}} (leftGr : Group {ℓ''}) (rightGr : Group {ℓ'''})
→ vSES A B leftGr rightGr
→ GroupIso A B
vSES→GroupIso {A = A} lGr rGr vses = BijectionIsoToGroupIso theIso
where
theIso : BijectionIso _ _
map' theIso = vSES.ϕ vses
inj theIso a inker = rec (isSetCarrier A _ _)
(λ (a , p) → sym p
∙∙ cong (fun (left vses)) (isTrivialLeft vses a _)
∙∙ morph0→0 lGr A (left vses))
(Ker-ϕ⊂Im-left vses a inker)
surj theIso a = Ker-right⊂Im-ϕ vses a (isTrivialRight vses _ _)
vSES→GroupEquiv : {A : Group {ℓ}} {B : Group {ℓ₁}} (leftGr : Group {ℓ₂}) (rightGr : Group {ℓ₃})
→ vSES A B leftGr rightGr
→ GroupEquiv A B
vSES→GroupEquiv {A = A} lGr rGr vses = GrIsoToGrEquiv (vSES→GroupIso lGr rGr vses)
-- The trivial group is a unit.
lUnitGroupIso : ∀ {ℓ} {G : Group {ℓ}} → GroupEquiv (dirProd trivialGroup G) G
lUnitGroupIso =
GrIsoToGrEquiv
(iso (grouphom snd (λ a b → refl))
(λ g → tt , g)
(λ _ → refl)
λ _ → refl)
rUnitGroupIso : ∀ {ℓ} {G : Group {ℓ}} → GroupEquiv (dirProd G trivialGroup) G
rUnitGroupIso =
GrIsoToGrEquiv
(iso
(grouphom fst λ _ _ → refl)
(λ g → g , tt)
(λ _ → refl)
λ _ → refl)
contrGroup≅trivialGroup : {G : Group {ℓ}} → isContr ⟨ G ⟩ → GroupEquiv G trivialGroup
GroupEquiv.eq (contrGroup≅trivialGroup contr) = isContr→≃Unit contr
GroupEquiv.isHom (contrGroup≅trivialGroup contr) _ _ = refl
| 40.4
| 169
| 0.554455
|
a1b3b41ff17c811c4f843efb74a7b79346d70bf1
| 133
|
agda
|
Agda
|
test/interaction/Issue5392.agda
|
cagix/agda
|
cc026a6a97a3e517bb94bafa9d49233b067c7559
|
[
"BSD-2-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/interaction/Issue5392.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/interaction/Issue5392.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
open import Agda.Primitive
record R (a : Level) : Set (lsuc a) where
field
A : Set a
_ : ∀ a → R {!a!} → Set a
_ = λ _ → R.A
| 14.777778
| 41
| 0.541353
|
23d20c03380a2c2a3b35dab4612ecc1a007b0de9
| 2,554
|
agda
|
Agda
|
BasicIPC/Metatheory/Gentzen-TarskiConcreteGluedGentzen.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | 29
|
2016-07-03T18:51:56.000Z
|
2022-01-01T10:29:18.000Z
|
BasicIPC/Metatheory/Gentzen-TarskiConcreteGluedGentzen.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | 1
|
2018-06-10T09:11:22.000Z
|
2018-06-10T09:11:22.000Z
|
BasicIPC/Metatheory/Gentzen-TarskiConcreteGluedGentzen.agda
|
mietek/hilbert-gentzen
|
fcd187db70f0a39b894fe44fad0107f61849405c
|
[
"X11"
] | null | null | null |
module BasicIPC.Metatheory.Gentzen-TarskiConcreteGluedGentzen where
open import BasicIPC.Syntax.Gentzen public
open import BasicIPC.Semantics.TarskiConcreteGluedGentzen public
-- Internalisation of syntax as syntax representation in a particular model.
module _ {{_ : Model}} where
[_] : ∀ {A Γ} → Γ ⊢ A → Γ [⊢] A
[ var i ] = [var] i
[ lam t ] = [lam] [ t ]
[ app t u ] = [app] [ t ] [ u ]
[ pair t u ] = [pair] [ t ] [ u ]
[ fst t ] = [fst] [ t ]
[ snd t ] = [snd] [ t ]
[ unit ] = [unit]
-- Soundness with respect to all models, or evaluation.
eval : ∀ {A Γ} → Γ ⊢ A → Γ ⊨ A
eval (var i) γ = lookup i γ
eval (lam t) γ = [multicut] (reifyʳ⋆ γ) [ lam t ] ⅋ λ a →
eval t (γ , a)
eval (app t u) γ = eval t γ ⟪$⟫ eval u γ
eval (pair t u) γ = eval t γ , eval u γ
eval (fst t) γ = π₁ (eval t γ)
eval (snd t) γ = π₂ (eval t γ)
eval unit γ = ∙
-- TODO: Correctness of evaluation with respect to conversion.
-- The canonical model.
private
instance
canon : Model
canon = record
{ _⊩ᵅ_ = λ w P → unwrap w ⊢ α P
; _[⊢]_ = _⊢_
; mono[⊢] = mono⊢
; [var] = var
; [lam] = lam
; [app] = app
; [pair] = pair
; [fst] = fst
; [snd] = snd
; [unit] = unit
}
-- Soundness and completeness with respect to the canonical model.
mutual
reflectᶜ : ∀ {A w} → unwrap w ⊢ A → w ⊩ A
reflectᶜ {α P} t = t ⅋ t
reflectᶜ {A ▻ B} t = t ⅋ λ a → reflectᶜ (app t (reifyᶜ a))
reflectᶜ {A ∧ B} t = reflectᶜ (fst t) , reflectᶜ (snd t)
reflectᶜ {⊤} t = ∙
reifyᶜ : ∀ {A w} → w ⊩ A → unwrap w ⊢ A
reifyᶜ {α P} s = syn s
reifyᶜ {A ▻ B} s = syn s
reifyᶜ {A ∧ B} s = pair (reifyᶜ (π₁ s)) (reifyᶜ (π₂ s))
reifyᶜ {⊤} s = unit
reflectᶜ⋆ : ∀ {Ξ w} → unwrap w ⊢⋆ Ξ → w ⊩⋆ Ξ
reflectᶜ⋆ {∅} ∙ = ∙
reflectᶜ⋆ {Ξ , A} (ts , t) = reflectᶜ⋆ ts , reflectᶜ t
reifyᶜ⋆ : ∀ {Ξ w} → w ⊩⋆ Ξ → unwrap w ⊢⋆ Ξ
reifyᶜ⋆ {∅} ∙ = ∙
reifyᶜ⋆ {Ξ , A} (ts , t) = reifyᶜ⋆ ts , reifyᶜ t
-- Reflexivity and transitivity.
refl⊩⋆ : ∀ {w} → w ⊩⋆ unwrap w
refl⊩⋆ = reflectᶜ⋆ refl⊢⋆
trans⊩⋆ : ∀ {w w′ w″} → w ⊩⋆ unwrap w′ → w′ ⊩⋆ unwrap w″ → w ⊩⋆ unwrap w″
trans⊩⋆ ts us = reflectᶜ⋆ (trans⊢⋆ (reifyᶜ⋆ ts) (reifyᶜ⋆ us))
-- Completeness with respect to all models, or quotation.
quot : ∀ {A Γ} → Γ ⊨ A → Γ ⊢ A
quot s = reifyᶜ (s refl⊩⋆)
-- Normalisation by evaluation.
norm : ∀ {A Γ} → Γ ⊢ A → Γ ⊢ A
norm = quot ∘ eval
-- TODO: Correctness of normalisation with respect to conversion.
| 25.287129
| 76
| 0.525059
|
0ed9f1b419b0843ce6afa499ffa5bc2fb1797756
| 1,356
|
agda
|
Agda
|
agda-stdlib/src/Data/These.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 5
|
2020-10-07T12:07:53.000Z
|
2020-10-10T21:41:32.000Z
|
agda-stdlib/src/Data/These.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | null | null | null |
agda-stdlib/src/Data/These.agda
|
DreamLinuxer/popl21-artifact
|
fb380f2e67dcb4a94f353dbaec91624fcb5b8933
|
[
"MIT"
] | 1
|
2021-11-04T06:54:45.000Z
|
2021-11-04T06:54:45.000Z
|
------------------------------------------------------------------------
-- The Agda standard library
--
-- An either-or-both data type
------------------------------------------------------------------------
{-# OPTIONS --without-K --safe #-}
module Data.These where
open import Level
open import Data.Maybe.Base using (Maybe; just; nothing; maybe′)
open import Data.Sum.Base using (_⊎_; [_,_]′)
open import Function
------------------------------------------------------------------------
-- Re-exporting the datatype and its operations
open import Data.These.Base public
private
variable
a b : Level
A : Set a
B : Set b
------------------------------------------------------------------------
-- Additional operations
-- projections
fromThis : These A B → Maybe A
fromThis = fold just (const nothing) (const ∘′ just)
fromThat : These A B → Maybe B
fromThat = fold (const nothing) just (const just)
leftMost : These A A → A
leftMost = fold id id const
rightMost : These A A → A
rightMost = fold id id (flip const)
mergeThese : (A → A → A) → These A A → A
mergeThese = fold id id
-- deletions
deleteThis : These A B → Maybe (These A B)
deleteThis = fold (const nothing) (just ∘′ that) (const (just ∘′ that))
deleteThat : These A B → Maybe (These A B)
deleteThat = fold (just ∘′ this) (const nothing) (const ∘′ just ∘′ this)
| 24.654545
| 72
| 0.531711
|
a1f9004cfcbb9c8e569aadf52935f6f0fc870dda
| 98
|
agda
|
Agda
|
test/Fail/Issue2788b.agda
|
caryoscelus/agda
|
98d6f195fe672e54ef0389b4deb62e04e3e98327
|
[
"BSD-3-Clause"
] | null | null | null |
test/Fail/Issue2788b.agda
|
caryoscelus/agda
|
98d6f195fe672e54ef0389b4deb62e04e3e98327
|
[
"BSD-3-Clause"
] | null | null | null |
test/Fail/Issue2788b.agda
|
caryoscelus/agda
|
98d6f195fe672e54ef0389b4deb62e04e3e98327
|
[
"BSD-3-Clause"
] | null | null | null |
module _ where
open import Agda.Builtin.Cubical.Glue hiding (primGlue)
primitive
primGlue : _
| 14
| 55
| 0.77551
|
2087b73b991e29a01718384eddf7a8b384a4ebda
| 1,882
|
agda
|
Agda
|
lib/Haskell/Prim/Eq.agda
|
flupe/agda2hs
|
4cb28f1b5032948b19b977b390fa260be292abf6
|
[
"MIT"
] | null | null | null |
lib/Haskell/Prim/Eq.agda
|
flupe/agda2hs
|
4cb28f1b5032948b19b977b390fa260be292abf6
|
[
"MIT"
] | null | null | null |
lib/Haskell/Prim/Eq.agda
|
flupe/agda2hs
|
4cb28f1b5032948b19b977b390fa260be292abf6
|
[
"MIT"
] | null | null | null |
module Haskell.Prim.Eq where
open import Agda.Builtin.Nat as Nat hiding (_==_)
open import Agda.Builtin.Char
open import Agda.Builtin.Unit
open import Agda.Builtin.List
open import Haskell.Prim
open import Haskell.Prim.Bool
open import Haskell.Prim.Integer
open import Haskell.Prim.Int
open import Haskell.Prim.Word
open import Haskell.Prim.Double
open import Haskell.Prim.Tuple
open import Haskell.Prim.Maybe
open import Haskell.Prim.Either
--------------------------------------------------
-- Eq
record Eq (a : Set) : Set where
infix 4 _==_ _/=_
field
_==_ : a → a → Bool
_/=_ : a → a → Bool
x /= y = not (x == y)
open Eq ⦃ ... ⦄ public
instance
iEqNat : Eq Nat
iEqNat ._==_ = Nat._==_
iEqInteger : Eq Integer
iEqInteger ._==_ = eqInteger
iEqInt : Eq Int
iEqInt ._==_ = eqInt
iEqWord : Eq Word
iEqWord ._==_ = eqWord
iEqDouble : Eq Double
iEqDouble ._==_ = primFloatNumericalEquality
iEqBool : Eq Bool
iEqBool ._==_ false false = true
iEqBool ._==_ true true = true
iEqBool ._==_ _ _ = false
iEqChar : Eq Char
iEqChar ._==_ = primCharEquality
iEqUnit : Eq ⊤
iEqUnit ._==_ _ _ = true
iEqTuple₀ : Eq (Tuple [])
iEqTuple₀ ._==_ _ _ = true
iEqTuple : ∀ {as} → ⦃ Eq a ⦄ → ⦃ Eq (Tuple as) ⦄ → Eq (Tuple (a ∷ as))
iEqTuple ._==_ (x ∷ xs) (y ∷ ys) = x == y && xs == ys
iEqList : ⦃ Eq a ⦄ → Eq (List a)
iEqList ._==_ [] [] = false
iEqList ._==_ (x ∷ xs) (y ∷ ys) = x == y && xs == ys
iEqList ._==_ _ _ = false
iEqMaybe : ⦃ Eq a ⦄ → Eq (Maybe a)
iEqMaybe ._==_ Nothing Nothing = true
iEqMaybe ._==_ (Just x) (Just y) = x == y
iEqMaybe ._==_ _ _ = false
iEqEither : ⦃ Eq a ⦄ → ⦃ Eq b ⦄ → Eq (Either a b)
iEqEither ._==_ (Left x) (Left y) = x == y
iEqEither ._==_ (Right x) (Right y) = x == y
iEqEither ._==_ _ _ = false
| 23.822785
| 72
| 0.57492
|
50de09183049f52ea7140dd0a8fe00ea5efb98c4
| 16,780
|
agda
|
Agda
|
Cubical/Algebra/CommRing/Localisation/UniversalProperty.agda
|
thomas-lamiaux/cubical
|
58c0b83bb0fed0dc683f3d29b1709effe51c1689
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/CommRing/Localisation/UniversalProperty.agda
|
thomas-lamiaux/cubical
|
58c0b83bb0fed0dc683f3d29b1709effe51c1689
|
[
"MIT"
] | null | null | null |
Cubical/Algebra/CommRing/Localisation/UniversalProperty.agda
|
thomas-lamiaux/cubical
|
58c0b83bb0fed0dc683f3d29b1709effe51c1689
|
[
"MIT"
] | null | null | null |
-- We define what it means to satisfy the universal property
-- of localisation and show that the localisation in Base satisfies
-- it. We will also show that the localisation is uniquely determined
-- by the universal property, and give sufficient criteria for
-- satisfying the universal property.
{-# OPTIONS --safe #-}
module Cubical.Algebra.CommRing.Localisation.UniversalProperty where
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.Univalence
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.Powerset
open import Cubical.Foundations.Transport
open import Cubical.Functions.FunExtEquiv
open import Cubical.Functions.Surjection
open import Cubical.Functions.Embedding
import Cubical.Data.Empty as ⊥
open import Cubical.Data.Bool
open import Cubical.Data.Nat renaming ( _+_ to _+ℕ_ ; _·_ to _·ℕ_ ; _^_ to _^ℕ_
; +-comm to +ℕ-comm ; +-assoc to +ℕ-assoc
; ·-assoc to ·ℕ-assoc ; ·-comm to ·ℕ-comm)
open import Cubical.Data.Vec
open import Cubical.Data.Sigma.Base
open import Cubical.Data.Sigma.Properties
open import Cubical.Data.FinData
open import Cubical.Relation.Nullary
open import Cubical.Relation.Binary
open import Cubical.Algebra.Ring
open import Cubical.Algebra.CommRingSolver.Reflection
open import Cubical.Algebra.CommRing
open import Cubical.Algebra.CommRing.Localisation.Base
open import Cubical.HITs.SetQuotients as SQ
open import Cubical.HITs.PropositionalTruncation as PT
open Iso
private
variable
ℓ ℓ' : Level
module _ (R' : CommRing ℓ) (S' : ℙ (fst R')) (SMultClosedSubset : isMultClosedSubset R' S') where
open isMultClosedSubset
private R = fst R'
open CommRingStr (snd R') hiding (is-set)
open RingTheory (CommRing→Ring R')
open IsRingHom
hasLocUniversalProp : (A : CommRing ℓ) (φ : CommRingHom R' A)
→ (∀ s → s ∈ S' → fst φ s ∈ A ˣ)
→ Type (ℓ-suc ℓ)
hasLocUniversalProp A φ _ = (B : CommRing ℓ) (ψ : CommRingHom R' B)
→ (∀ s → s ∈ S' → fst ψ s ∈ B ˣ)
→ ∃![ χ ∈ CommRingHom A B ] (fst χ) ∘ (fst φ) ≡ (fst ψ)
isPropUniversalProp : (A : CommRing ℓ) (φ : CommRingHom R' A)
→ (φS⊆Aˣ : ∀ s → s ∈ S' → fst φ s ∈ A ˣ)
→ isProp (hasLocUniversalProp A φ φS⊆Aˣ)
isPropUniversalProp A φ φS⊆Aˣ = isPropΠ3 (λ _ _ _ → isPropIsContr)
-- S⁻¹R has the universal property
module S⁻¹RUniversalProp where
open Loc R' S' SMultClosedSubset
_/1 : R → S⁻¹R
r /1 = [ r , 1r , SMultClosedSubset .containsOne ]
/1AsCommRingHom : CommRingHom R' S⁻¹RAsCommRing
fst /1AsCommRingHom = _/1
snd /1AsCommRingHom =
makeIsRingHom
refl
(λ r r' → cong [_] (≡-× (cong₂ (_+_) (sym (·IdR r)) (sym (·IdR r')))
(Σ≡Prop (λ x → S' x .snd) (sym (·IdL 1r)))))
(λ _ _ → cong [_] (≡-× refl (Σ≡Prop (λ x → S' x .snd) (sym (·IdL 1r)))))
S⁻¹Rˣ = S⁻¹RAsCommRing ˣ
S/1⊆S⁻¹Rˣ : ∀ s → s ∈ S' → (s /1) ∈ S⁻¹Rˣ
S/1⊆S⁻¹Rˣ s s∈S' = [ 1r , s , s∈S' ] , eq/ _ _ ((1r , SMultClosedSubset .containsOne) , path s)
where
path : ∀ s → 1r · (s · 1r) · 1r ≡ 1r · 1r · (1r · s)
path = solve R'
S⁻¹RHasUniversalProp : hasLocUniversalProp S⁻¹RAsCommRing /1AsCommRingHom S/1⊆S⁻¹Rˣ
S⁻¹RHasUniversalProp B' ψ ψS⊆Bˣ = (χ , funExt χcomp) , χunique
where
B = fst B'
open CommRingStr (snd B') renaming ( is-set to Bset ; _·_ to _·B_ ; 1r to 1b
; _+_ to _+B_
; ·Assoc to ·B-assoc ; ·Comm to ·B-comm
; ·IdL to ·B-lid ; ·IdR to ·B-rid
; ·DistL+ to ·B-ldist-+)
open Units B' renaming (Rˣ to Bˣ ; RˣMultClosed to BˣMultClosed ; RˣContainsOne to BˣContainsOne)
open RingTheory (CommRing→Ring B') renaming (·-assoc2 to ·B-assoc2)
open CommRingTheory B' renaming (·CommAssocl to ·B-commAssocl ; ·CommAssocSwap to ·B-commAssocSwap)
ψ₀ = fst ψ
module ψ = IsRingHom (snd ψ)
χ : CommRingHom S⁻¹RAsCommRing B'
fst χ = SQ.rec Bset fχ fχcoh
where
fχ : R × S → B
fχ (r , s , s∈S') = (fst ψ r) ·B ((fst ψ s) ⁻¹) ⦃ ψS⊆Bˣ s s∈S' ⦄
fχcoh : (a b : R × S) → a ≈ b → fχ a ≡ fχ b
fχcoh (r , s , s∈S') (r' , s' , s'∈S') ((u , u∈S') , p) = instancepath
⦃ ψS⊆Bˣ s s∈S' ⦄ ⦃ ψS⊆Bˣ s' s'∈S' ⦄ ⦃ ψS⊆Bˣ (u · s · s')
(SMultClosedSubset .multClosed (SMultClosedSubset .multClosed u∈S' s∈S') s'∈S') ⦄
⦃ BˣMultClosed _ _ ⦃ ψS⊆Bˣ (u · s) (SMultClosedSubset .multClosed u∈S' s∈S') ⦄
⦃ ψS⊆Bˣ s' s'∈S' ⦄ ⦄
⦃ ψS⊆Bˣ (u · s) (SMultClosedSubset .multClosed u∈S' s∈S') ⦄
where
-- only a few individual steps can be solved by the ring solver yet
instancepath : ⦃ _ : ψ₀ s ∈ Bˣ ⦄ ⦃ _ : ψ₀ s' ∈ Bˣ ⦄
⦃ _ : ψ₀ (u · s · s') ∈ Bˣ ⦄ ⦃ _ : ψ₀ (u · s) ·B ψ₀ s' ∈ Bˣ ⦄
⦃ _ : ψ₀ (u · s) ∈ Bˣ ⦄
→ ψ₀ r ·B ψ₀ s ⁻¹ ≡ ψ₀ r' ·B ψ₀ s' ⁻¹
instancepath = ψ₀ r ·B ψ₀ s ⁻¹
≡⟨ sym (·B-rid _) ⟩
ψ₀ r ·B ψ₀ s ⁻¹ ·B 1b
≡⟨ cong (ψ₀ r ·B ψ₀ s ⁻¹ ·B_) (sym (·-rinv _)) ⟩
ψ₀ r ·B ψ₀ s ⁻¹ ·B (ψ₀ (u · s · s') ·B ψ₀ (u · s · s') ⁻¹)
≡⟨ ·B-assoc _ _ _ ⟩
ψ₀ r ·B ψ₀ s ⁻¹ ·B ψ₀ (u · s · s') ·B ψ₀ (u · s · s') ⁻¹
≡⟨ cong (λ x → ψ₀ r ·B ψ₀ s ⁻¹ ·B x ·B ψ₀ (u · s · s') ⁻¹) (ψ.pres· _ _) ⟩
ψ₀ r ·B ψ₀ s ⁻¹ ·B (ψ₀ (u · s) ·B ψ₀ s') ·B ψ₀ (u · s · s') ⁻¹
≡⟨ cong (_·B ψ₀ (u · s · s') ⁻¹) (·B-assoc _ _ _) ⟩
ψ₀ r ·B ψ₀ s ⁻¹ ·B ψ₀ (u · s) ·B ψ₀ s' ·B ψ₀ (u · s · s') ⁻¹
≡⟨ cong (λ x → ψ₀ r ·B ψ₀ s ⁻¹ ·B x ·B ψ₀ s' ·B ψ₀ (u · s · s') ⁻¹)
(ψ.pres· _ _) ⟩
ψ₀ r ·B ψ₀ s ⁻¹ ·B (ψ₀ u ·B ψ₀ s) ·B ψ₀ s' ·B ψ₀ (u · s · s') ⁻¹
≡⟨ cong (λ x → x ·B ψ₀ s' ·B ψ₀ (u · s · s') ⁻¹) (·B-commAssocSwap _ _ _ _) ⟩
ψ₀ r ·B ψ₀ u ·B (ψ₀ s ⁻¹ ·B ψ₀ s) ·B ψ₀ s' ·B ψ₀ (u · s · s') ⁻¹
≡⟨ (λ i → ·B-comm (ψ₀ r) (ψ₀ u) i ·B (·-linv (ψ₀ s) i)
·B ψ₀ s' ·B ψ₀ (u · s · s') ⁻¹) ⟩
ψ₀ u ·B ψ₀ r ·B 1b ·B ψ₀ s' ·B ψ₀ (u · s · s') ⁻¹
≡⟨ (λ i → (·B-rid (sym (ψ.pres· u r) i) i) ·B ψ₀ s' ·B ψ₀ (u · s · s') ⁻¹) ⟩
ψ₀ (u · r) ·B ψ₀ s' ·B ψ₀ (u · s · s') ⁻¹
≡⟨ cong (_·B ψ₀ (u · s · s') ⁻¹) (sym (ψ.pres· _ _)) ⟩
ψ₀ (u · r · s') ·B ψ₀ (u · s · s') ⁻¹
≡⟨ cong (λ x → ψ₀ x ·B ψ₀ (u · s · s') ⁻¹) p ⟩
ψ₀ (u · r' · s) ·B ψ₀ (u · s · s') ⁻¹
≡⟨ cong (_·B ψ₀ (u · s · s') ⁻¹) (ψ.pres· _ _) ⟩
ψ₀ (u · r') ·B ψ₀ s ·B ψ₀ (u · s · s') ⁻¹
≡⟨ cong (λ x → x ·B ψ₀ s ·B ψ₀ (u · s · s') ⁻¹) (ψ.pres· _ _) ⟩
ψ₀ u ·B ψ₀ r' ·B ψ₀ s ·B ψ₀ (u · s · s') ⁻¹
≡⟨ cong (_·B ψ₀ (u · s · s') ⁻¹) (sym (·B-assoc _ _ _)) ⟩
ψ₀ u ·B (ψ₀ r' ·B ψ₀ s) ·B ψ₀ (u · s · s') ⁻¹
≡⟨ cong (_·B ψ₀ (u · s · s') ⁻¹) (·B-commAssocl _ _ _) ⟩
ψ₀ r' ·B (ψ₀ u ·B ψ₀ s) ·B ψ₀ (u · s · s') ⁻¹
≡⟨ cong (λ x → ψ₀ r' ·B x ·B ψ₀ (u · s · s') ⁻¹) (sym (ψ.pres· _ _)) ⟩
ψ₀ r' ·B ψ₀ (u · s) ·B ψ₀ (u · s · s') ⁻¹
≡⟨ cong (ψ₀ r' ·B ψ₀ (u · s) ·B_) (unitCong (ψ.pres· _ _)) ⟩
ψ₀ r' ·B ψ₀ (u · s) ·B (ψ₀ (u · s) ·B ψ₀ s') ⁻¹
≡⟨ cong (ψ₀ r' ·B ψ₀ (u · s) ·B_) (⁻¹-dist-· _ _) ⟩
ψ₀ r' ·B ψ₀ (u · s) ·B (ψ₀ (u · s) ⁻¹ ·B ψ₀ s' ⁻¹)
≡⟨ ·B-assoc2 _ _ _ _ ⟩
ψ₀ r' ·B (ψ₀ (u · s) ·B ψ₀ (u · s) ⁻¹) ·B ψ₀ s' ⁻¹
≡⟨ cong (λ x → ψ₀ r' ·B x ·B ψ₀ s' ⁻¹) (·-rinv _) ⟩
ψ₀ r' ·B 1b ·B ψ₀ s' ⁻¹
≡⟨ cong (_·B ψ₀ s' ⁻¹) (·B-rid _) ⟩
ψ₀ r' ·B ψ₀ s' ⁻¹ ∎
snd χ =
makeIsRingHom
(instancepres1χ ⦃ ψS⊆Bˣ 1r (SMultClosedSubset .containsOne) ⦄ ⦃ BˣContainsOne ⦄)
(elimProp2 (λ _ _ _ _ → Bset _ _ _ _) pres+[])
(elimProp2 (λ _ _ _ _ → Bset _ _ _ _) pres·[])
where
instancepres1χ : ⦃ _ : ψ₀ 1r ∈ Bˣ ⦄ ⦃ _ : 1b ∈ Bˣ ⦄
→ ψ₀ 1r ·B (ψ₀ 1r) ⁻¹ ≡ 1b
instancepres1χ = (λ i → (ψ.pres1 i) ·B (unitCong (ψ.pres1) i))
∙ (λ i → ·B-lid (1⁻¹≡1 i) i)
pres+[] : (a b : R × S) → fst χ ([ a ] +ₗ [ b ]) ≡ (fst χ [ a ]) +B (fst χ [ b ])
pres+[] (r , s , s∈S') (r' , s' , s'∈S') = instancepath
⦃ ψS⊆Bˣ s s∈S' ⦄ ⦃ ψS⊆Bˣ s' s'∈S' ⦄ ⦃ ψS⊆Bˣ (s · s') (SMultClosedSubset .multClosed s∈S' s'∈S') ⦄
⦃ BˣMultClosed _ _ ⦃ ψS⊆Bˣ s s∈S' ⦄ ⦃ ψS⊆Bˣ s' s'∈S' ⦄ ⦄
where
-- only a few individual steps can be solved by the ring solver yet
instancepath : ⦃ _ : ψ₀ s ∈ Bˣ ⦄ ⦃ _ : ψ₀ s' ∈ Bˣ ⦄
⦃ _ : ψ₀ (s · s') ∈ Bˣ ⦄ ⦃ _ : ψ₀ s ·B ψ₀ s' ∈ Bˣ ⦄
→ ψ₀ (r · s' + r' · s) ·B ψ₀ (s · s') ⁻¹ ≡ ψ₀ r ·B ψ₀ s ⁻¹ +B ψ₀ r' ·B ψ₀ s' ⁻¹
instancepath =
ψ₀ (r · s' + r' · s) ·B ψ₀ (s · s') ⁻¹
≡⟨ (λ i → ψ.pres+ (r · s') (r' · s) i ·B unitCong (ψ.pres· s s') i) ⟩
(ψ₀ (r · s') +B ψ₀ (r' · s)) ·B (ψ₀ s ·B ψ₀ s') ⁻¹
≡⟨ (λ i → (ψ.pres· r s' i +B ψ.pres· r' s i) ·B ⁻¹-dist-· (ψ₀ s) (ψ₀ s') i) ⟩
(ψ₀ r ·B ψ₀ s' +B ψ₀ r' ·B ψ₀ s) ·B (ψ₀ s ⁻¹ ·B ψ₀ s' ⁻¹)
≡⟨ ·B-ldist-+ _ _ _ ⟩
ψ₀ r ·B ψ₀ s' ·B (ψ₀ s ⁻¹ ·B ψ₀ s' ⁻¹) +B ψ₀ r' ·B ψ₀ s ·B (ψ₀ s ⁻¹ ·B ψ₀ s' ⁻¹)
≡⟨ (λ i → ·B-commAssocSwap (ψ₀ r) (ψ₀ s') (ψ₀ s ⁻¹) (ψ₀ s' ⁻¹) i
+B ·B-assoc2 (ψ₀ r') (ψ₀ s) (ψ₀ s ⁻¹) (ψ₀ s' ⁻¹) i) ⟩
ψ₀ r ·B ψ₀ s ⁻¹ ·B (ψ₀ s' ·B ψ₀ s' ⁻¹) +B ψ₀ r' ·B (ψ₀ s ·B ψ₀ s ⁻¹) ·B ψ₀ s' ⁻¹
≡⟨ (λ i → ψ₀ r ·B ψ₀ s ⁻¹ ·B (·-rinv (ψ₀ s') i)
+B ψ₀ r' ·B (·-rinv (ψ₀ s) i) ·B ψ₀ s' ⁻¹) ⟩
ψ₀ r ·B ψ₀ s ⁻¹ ·B 1b +B ψ₀ r' ·B 1b ·B ψ₀ s' ⁻¹
≡⟨ (λ i → ·B-rid (ψ₀ r ·B ψ₀ s ⁻¹) i +B ·B-rid (ψ₀ r') i ·B ψ₀ s' ⁻¹) ⟩
ψ₀ r ·B ψ₀ s ⁻¹ +B ψ₀ r' ·B ψ₀ s' ⁻¹ ∎
pres·[] : (a b : R × S) → fst χ ([ a ] ·ₗ [ b ]) ≡ (fst χ [ a ]) ·B (fst χ [ b ])
pres·[] (r , s , s∈S') (r' , s' , s'∈S') = instancepath
⦃ ψS⊆Bˣ s s∈S' ⦄ ⦃ ψS⊆Bˣ s' s'∈S' ⦄ ⦃ ψS⊆Bˣ (s · s') (SMultClosedSubset .multClosed s∈S' s'∈S') ⦄
⦃ BˣMultClosed _ _ ⦃ ψS⊆Bˣ s s∈S' ⦄ ⦃ ψS⊆Bˣ s' s'∈S' ⦄ ⦄
where
-- only a few individual steps can be solved by the ring solver yet
instancepath : ⦃ _ : ψ₀ s ∈ Bˣ ⦄ ⦃ _ : ψ₀ s' ∈ Bˣ ⦄
⦃ _ : ψ₀ (s · s') ∈ Bˣ ⦄ ⦃ _ : ψ₀ s ·B ψ₀ s' ∈ Bˣ ⦄
→ ψ₀ (r · r') ·B ψ₀ (s · s') ⁻¹ ≡ (ψ₀ r ·B ψ₀ s ⁻¹) ·B (ψ₀ r' ·B ψ₀ s' ⁻¹)
instancepath = ψ₀ (r · r') ·B ψ₀ (s · s') ⁻¹
≡⟨ (λ i → ψ.pres· r r' i ·B unitCong (ψ.pres· s s') i) ⟩
ψ₀ r ·B ψ₀ r' ·B (ψ₀ s ·B ψ₀ s') ⁻¹
≡⟨ cong (ψ₀ r ·B ψ₀ r' ·B_) (⁻¹-dist-· _ _) ⟩
ψ₀ r ·B ψ₀ r' ·B (ψ₀ s ⁻¹ ·B ψ₀ s' ⁻¹)
≡⟨ ·B-commAssocSwap _ _ _ _ ⟩
ψ₀ r ·B ψ₀ s ⁻¹ ·B (ψ₀ r' ·B ψ₀ s' ⁻¹) ∎
χcomp : (r : R) → fst χ (r /1) ≡ ψ₀ r
χcomp = instanceχcomp ⦃ ψS⊆Bˣ 1r (SMultClosedSubset .containsOne) ⦄ ⦃ Units.RˣContainsOne B' ⦄
where
instanceχcomp : ⦃ _ : ψ₀ 1r ∈ Bˣ ⦄ ⦃ _ : 1b ∈ Bˣ ⦄
(r : R) → ψ₀ r ·B (ψ₀ 1r) ⁻¹ ≡ ψ₀ r
instanceχcomp r = ψ₀ r ·B (ψ₀ 1r) ⁻¹ ≡⟨ cong (ψ₀ r ·B_) (unitCong (ψ.pres1)) ⟩
ψ₀ r ·B 1b ⁻¹ ≡⟨ cong (ψ₀ r ·B_) 1⁻¹≡1 ⟩
ψ₀ r ·B 1b ≡⟨ ·B-rid _ ⟩
ψ₀ r ∎
χunique : (y : Σ[ χ' ∈ CommRingHom S⁻¹RAsCommRing B' ] fst χ' ∘ _/1 ≡ ψ₀)
→ (χ , funExt χcomp) ≡ y
χunique (χ' , χ'/1≡ψ) = Σ≡Prop (λ x → isSetΠ (λ _ → Bset) _ _) (RingHom≡ fχ≡fχ')
where
open CommRingHomTheory {A' = S⁻¹RAsCommRing} {B' = B'} χ'
renaming (φ[x⁻¹]≡φ[x]⁻¹ to χ'[x⁻¹]≡χ'[x]⁻¹)
module χ' = IsRingHom (χ' .snd)
[]-path : (a : R × S) → fst χ [ a ] ≡ fst χ' [ a ]
[]-path (r , s , s∈S') = instancepath ⦃ ψS⊆Bˣ s s∈S' ⦄ ⦃ S/1⊆S⁻¹Rˣ s s∈S' ⦄
⦃ RingHomRespInv _ ⦃ S/1⊆S⁻¹Rˣ s s∈S' ⦄ ⦄
where
open Units S⁻¹RAsCommRing renaming (_⁻¹ to _⁻¹ˡ ; inverseUniqueness to S⁻¹RInverseUniqueness)
hiding (unitCong)
s-inv : ⦃ s/1∈S⁻¹Rˣ : s /1 ∈ S⁻¹Rˣ ⦄ → s /1 ⁻¹ˡ ≡ [ 1r , s , s∈S' ]
s-inv ⦃ s/1∈S⁻¹Rˣ ⦄ = PathPΣ (S⁻¹RInverseUniqueness (s /1) s/1∈S⁻¹Rˣ
(_ , eq/ _ _ ((1r , SMultClosedSubset .containsOne) , path s))) .fst
where
path : ∀ s → 1r · (s · 1r) · 1r ≡ 1r · 1r · (1r · s)
path = solve R'
·ₗ-path : [ r , s , s∈S' ] ≡ [ r , 1r , SMultClosedSubset .containsOne ]
·ₗ [ 1r , s , s∈S' ]
·ₗ-path = cong [_] (≡-× (sym (·IdR r)) (Σ≡Prop (λ x → S' x .snd) (sym (·IdL s))))
instancepath : ⦃ _ : ψ₀ s ∈ Bˣ ⦄ ⦃ _ : s /1 ∈ S⁻¹Rˣ ⦄ ⦃ _ : fst χ' (s /1) ∈ Bˣ ⦄
→ ψ₀ r ·B ψ₀ s ⁻¹ ≡ fst χ' [ r , s , s∈S' ]
instancepath = ψ₀ r ·B ψ₀ s ⁻¹
≡⟨ cong (ψ₀ r ·B_) (unitCong (cong (λ φ → φ s) (sym χ'/1≡ψ))) ⟩
ψ₀ r ·B fst χ' (s /1) ⁻¹
≡⟨ cong (ψ₀ r ·B_) (sym (χ'[x⁻¹]≡χ'[x]⁻¹ _)) ⟩
ψ₀ r ·B fst χ' (s /1 ⁻¹ˡ)
≡⟨ cong (λ x → ψ₀ r ·B fst χ' x) s-inv ⟩
ψ₀ r ·B fst χ' [ 1r , s , s∈S' ]
≡⟨ cong (_·B fst χ' [ 1r , s , s∈S' ]) (cong (λ φ → φ r) (sym χ'/1≡ψ)) ⟩
fst χ' [ r , 1r , SMultClosedSubset .containsOne ] ·B fst χ' [ 1r , s , s∈S' ]
≡⟨ sym (χ'.pres· _ _) ⟩
fst χ' ([ r , 1r , SMultClosedSubset .containsOne ] ·ₗ [ 1r , s , s∈S' ])
≡⟨ cong (fst χ') (sym ·ₗ-path) ⟩
fst χ' [ r , s , s∈S' ] ∎
fχ≡fχ' : fst χ ≡ fst χ'
fχ≡fχ' = funExt (SQ.elimProp (λ _ → Bset _ _) []-path)
-- sufficient conditions for having the universal property
-- used as API in the leanprover-community/mathlib
-- Corollary 3.2 in Atiyah-McDonald
open S⁻¹RUniversalProp
open Loc R' S' SMultClosedSubset
record PathToS⁻¹R (A' : CommRing ℓ) (φ : CommRingHom R' A') : Type ℓ where
constructor
pathtoS⁻¹R
open Units A' renaming (Rˣ to Aˣ)
open CommRingStr (snd A') renaming (is-set to Aset ; 0r to 0a ; _·_ to _·A_)
field
φS⊆Aˣ : ∀ s → s ∈ S' → fst φ s ∈ Aˣ
kerφ⊆annS : ∀ r → fst φ r ≡ 0a → ∃[ s ∈ S ] (s .fst) · r ≡ 0r
surχ : ∀ a → ∃[ x ∈ R × S ] fst φ (x .fst) ·A (fst φ (x .snd .fst) ⁻¹) ⦃ φS⊆Aˣ _ (x .snd .snd) ⦄ ≡ a
S⁻¹RCharEquiv : (A' : CommRing ℓ) (φ : CommRingHom R' A')
→ PathToS⁻¹R A' φ
→ CommRingEquiv S⁻¹RAsCommRing A'
S⁻¹RCharEquiv A' φ cond = S⁻¹R≃A , χ .snd
where
open CommRingStr (snd A') renaming ( is-set to Aset ; 0r to 0a ; _·_ to _·A_ ; 1r to 1a
; ·IdR to ·A-rid)
open Units A' renaming (Rˣ to Aˣ ; RˣInvClosed to AˣInvClosed)
open PathToS⁻¹R ⦃...⦄
private
A = fst A'
instance
_ = cond
χ = (S⁻¹RHasUniversalProp A' φ φS⊆Aˣ .fst .fst)
open RingHomTheory χ
S⁻¹R≃A : S⁻¹R ≃ A
S⁻¹R≃A = fst χ , isEmbedding×isSurjection→isEquiv (Embχ , Surχ)
where
Embχ : isEmbedding (fst χ)
Embχ = injEmbedding squash/ Aset (ker≡0→inj λ {x} → kerχ≡0 x)
where
kerχ≡0 : (r/s : S⁻¹R) → fst χ r/s ≡ 0a → r/s ≡ 0ₗ
kerχ≡0 = SQ.elimProp (λ _ → isPropΠ λ _ → squash/ _ _) kerχ≡[]
where
kerχ≡[] : (a : R × S) → fst χ [ a ] ≡ 0a → [ a ] ≡ 0ₗ
kerχ≡[] (r , s , s∈S') p = PT.rec (squash/ _ _) Σhelper
(kerφ⊆annS r (UnitsAreNotZeroDivisors _ _ p))
where
instance
_ : fst φ s ∈ Aˣ
_ = φS⊆Aˣ s s∈S'
_ : fst φ s ⁻¹ ∈ Aˣ
_ = AˣInvClosed (fst φ s)
Σhelper : Σ[ s ∈ S ] (s .fst) · r ≡ 0r → [ r , s , s∈S' ] ≡ 0ₗ
Σhelper ((u , u∈S') , q) = eq/ _ _ ((u , u∈S') , path)
where
path : u · r · 1r ≡ u · 0r · s
path = (λ i → ·IdR (q i) i) ∙∙ sym (0LeftAnnihilates _)
∙∙ cong (_· s) (sym (0RightAnnihilates _))
Surχ : isSurjection (fst χ)
Surχ a = PT.rec isPropPropTrunc (λ x → PT.∣ [ x .fst ] , x .snd ∣₁) (surχ a)
S⁻¹RChar : (A' : CommRing ℓ) (φ : CommRingHom R' A')
→ PathToS⁻¹R A' φ
→ S⁻¹RAsCommRing ≡ A'
S⁻¹RChar A' φ cond = uaCommRing (S⁻¹RCharEquiv A' φ cond)
| 39.669031
| 103
| 0.455721
|
062577b2443231d4c09f56a3c7077796ce4df15e
| 5,953
|
agda
|
Agda
|
agda/course/2017-conor_mcbride_cs410/CS410-17-master/exercises/CS410-Prelude.agda
|
haroldcarr/learn-haskell-coq-ml-etc
|
3dc7abca7ad868316bb08f31c77fbba0d3910225
|
[
"Unlicense"
] | 36
|
2015-01-29T14:37:15.000Z
|
2021-07-30T06:55:03.000Z
|
agda/course/2017-conor_mcbride_cs410/CS410-17-master/exercises/CS410-Prelude.agda
|
haroldcarr/learn-haskell-coq-ml-etc
|
3dc7abca7ad868316bb08f31c77fbba0d3910225
|
[
"Unlicense"
] | null | null | null |
agda/course/2017-conor_mcbride_cs410/CS410-17-master/exercises/CS410-Prelude.agda
|
haroldcarr/learn-haskell-coq-ml-etc
|
3dc7abca7ad868316bb08f31c77fbba0d3910225
|
[
"Unlicense"
] | 8
|
2015-04-13T21:40:15.000Z
|
2021-09-21T15:58:10.000Z
|
module CS410-Prelude where
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Standard Equipment for use in Exercises
------------------------------------------------------------------------------
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- functional equipment (types may be generalized later)
------------------------------------------------------------------------------
-- the polymorphic identity function
id : {X : Set} -> X -> X
id x = x
-- standard composition: f << g is "f after g"
_<<_ : {X Y Z : Set} -> (Y -> Z) -> (X -> Y) -> (X -> Z)
(f << g) x = f (g x)
-- diagrammatic composition: f >> g is "f then g"
_>>_ : {X Y Z : Set} -> (X -> Y) -> (Y -> Z) -> (X -> Z)
-- ^^^^^^^^ dominoes!
(f >> g) x = g (f x)
infixr 5 _>>_
-- infix application
_$_ : {S : Set}{T : S -> Set}(f : (x : S) -> T x)(s : S) -> T s
f $ s = f s
infixl 2 _$_
------------------------------------------------------------------------------
-- some basic "logical" types
------------------------------------------------------------------------------
data Zero : Set where
-- to give a value in a data, choose one constructor
-- there are no constructors
-- so that's impossible
record One : Set where
-- to give a value in a record type, fill all its fields
-- there are no fields
-- so that's trivial
-- (can we have a constructor, for convenience?)
constructor <>
data _+_ (S : Set)(T : Set) : Set where -- "where" wants an indented block
-- to offer a choice of constructors, list them with their types
inl : S -> S + T -- constructors can pack up stuff
inr : T -> S + T
-- in Haskell, this was called "Either S T"
record Sg (S : Set)(T : S -> Set) : Set where -- Sg is short for "Sigma"
constructor _,_
field -- introduces a bunch of fields, listed with their types
fst : S
snd : T fst
-- make _*_ from Sg ?
open Sg public
_*_ : Set -> Set -> Set
S * T = Sg S \ _ -> T
infixr 4 _,_ _*_
------------------------------------------------------------------------------
-- natural numbers and addition
------------------------------------------------------------------------------
data Nat : Set where
zero : Nat
suc : Nat -> Nat -- recursive data type
{-# BUILTIN NATURAL Nat #-}
-- ^^^^^^^^^^^^^^^^^^^ this pragma lets us use decimal notation
_+N_ : Nat -> Nat -> Nat
zero +N y = y
suc x +N y = suc (x +N y) -- there are other choices
------------------------------------------------------------------------------
-- equality
------------------------------------------------------------------------------
data _==_ {X : Set} : X -> X -> Set where
refl : (x : X) -> x == x -- the relation that's "only reflexive"
{-# BUILTIN EQUALITY _==_ #-} -- we'll see what that's for, later
_=$=_ : {X Y : Set}{f f' : X -> Y}{x x' : X} ->
f == f' -> x == x' -> f x == f' x'
refl f =$= refl x = refl (f x)
_=$_ : {S : Set}{T : S -> Set}{f g : (x : S) -> T x} -> (f == g) -> (x : S) -> f x == g x
refl f =$ x = refl (f x)
infixl 2 _=$=_ _=$_
sym : {X : Set}{x y : X} -> x == y -> y == x
sym (refl x) = refl x
_[QED] : {X : Set}(x : X) -> x == x
x [QED] = refl x
_=[_>=_ : {X : Set}(x : X){y z : X} -> x == y -> y == z -> x == z
x =[ refl .x >= q = q
_=<_]=_ : {X : Set}(x : X){y z : X} -> y == x -> y == z -> x == z
x =< refl .x ]= q = q
infixr 1 _=[_>=_ _=<_]=_
infixr 2 _[QED]
------------------------------------------------------------------------------
-- greater-than-or-equals
------------------------------------------------------------------------------
_>=_ : Nat -> Nat -> Set
x >= zero = One
zero >= suc y = Zero
suc x >= suc y = x >= y
refl->= : (n : Nat) -> n >= n
refl->= zero = record {}
refl->= (suc n) = refl->= n
trans->= : (x y z : Nat) -> x >= y -> y >= z -> x >= z
trans->= x y zero x>=y y>=z = record {}
trans->= x zero (suc z) x>=y ()
trans->= zero (suc y) (suc z) () y>=z
trans->= (suc x) (suc y) (suc z) x>=y y>=z = trans->= x y z x>=y y>=z
suc->= : (x : Nat) -> suc x >= x
suc->= zero = <>
suc->= (suc x) = suc->= x
----------------------------------------------------------------------------
-- Two -- the type of Boolean values
----------------------------------------------------------------------------
data Two : Set where tt ff : Two
{-# BUILTIN BOOL Two #-}
{-# BUILTIN TRUE tt #-}
{-# BUILTIN FALSE ff #-}
-- nondependent conditional with traditional syntax
if_then_else_ : forall {l}{X : Set l} -> Two -> X -> X -> X
if tt then t else e = t
if ff then t else e = e
-- dependent conditional cooked for partial application
caseTwo : forall {l}{P : Two -> Set l} -> P tt -> P ff -> (b : Two) -> P b
caseTwo t f tt = t
caseTwo t f ff = f
----------------------------------------------------------------------------
-- lists
----------------------------------------------------------------------------
data List (X : Set) : Set where
[] : List X
_,-_ : (x : X)(xs : List X) -> List X
infixr 4 _,-_
{-# COMPILE GHC List = data [] ([] | (:)) #-}
{-# BUILTIN LIST List #-}
--{-# BUILTIN NIL [] #-}
--{-# BUILTIN CONS _,-_ #-}
----------------------------------------------------------------------------
-- chars and strings
----------------------------------------------------------------------------
postulate -- this means that we just suppose the following things exist...
Char : Set
String : Set
{-# BUILTIN CHAR Char #-}
{-# BUILTIN STRING String #-}
primitive -- these are baked in; they even work!
primCharEquality : Char -> Char -> Two
primStringAppend : String -> String -> String
primStringToList : String -> List Char
primStringFromList : List Char -> String
| 30.84456
| 89
| 0.38804
|
232dec506d65e172b0332e4f020b67b2d4833d37
| 259
|
agda
|
Agda
|
test/Succeed/Issue327.agda
|
mdimjasevic/agda
|
8fb548356b275c7a1e79b768b64511ae937c738b
|
[
"BSD-3-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue327.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue327.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
module Issue327 where
open import Common.Prelude
open import Common.Reflection
_==_ : QName → QName → Bool
_==_ = primQNameEquality
postulate
Dec : Bool → Set
_≟_ : (x y : QName) → Dec (x == y)
Foo : Set₁
Foo with quote Foo ≟ quote Foo
... | _ = Set
| 15.235294
| 36
| 0.656371
|
cb4d744b482df06a13228608fedc24ae4b2e425e
| 543
|
agda
|
Agda
|
archive/agda-1/Foreword.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
archive/agda-1/Foreword.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | 1
|
2019-04-29T00:35:04.000Z
|
2019-05-11T23:33:04.000Z
|
archive/agda-1/Foreword.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
module Foreword where
open import Relation.Binary
--open Setoid ⦃ … ⦄
--open IsEquivalence ⦃ … ⦄
open import Level
record HasEquivalence (A : Set) ℓ : Set (suc ℓ) where
field
_≈_ : Rel A ℓ
⦃ isEquivalence ⦄ : IsEquivalence _≈_
setoid : Setoid _ _
Setoid.Carrier setoid = A
Setoid._≈_ setoid = _≈_
Setoid.isEquivalence setoid = isEquivalence
open HasEquivalence ⦃ … ⦄
module TestEquivalence (A : Set) (B : Set) ⦃ _ : HasEquivalence A zero ⦄ ⦃ _ : HasEquivalence B zero ⦄ where
testA : (x : A) → x ≈ x
testA = {!!}
| 20.884615
| 108
| 0.655617
|
dc8cd2fb2f65dab5377307fbe9196079bc72d32d
| 2,832
|
agda
|
Agda
|
Cats/Category/Setoids/Facts/Products.agda
|
alessio-b-zak/cats
|
a3b69911c4c6ec380ddf6a0f4510d3a755734b86
|
[
"MIT"
] | null | null | null |
Cats/Category/Setoids/Facts/Products.agda
|
alessio-b-zak/cats
|
a3b69911c4c6ec380ddf6a0f4510d3a755734b86
|
[
"MIT"
] | null | null | null |
Cats/Category/Setoids/Facts/Products.agda
|
alessio-b-zak/cats
|
a3b69911c4c6ec380ddf6a0f4510d3a755734b86
|
[
"MIT"
] | null | null | null |
module Cats.Category.Setoids.Facts.Products where
open import Data.Product as P using (_,_ ; <_,_>)
open import Relation.Binary using (Setoid)
open import Relation.Binary.Product.Pointwise using (×-setoid)
open import Cats.Category
open import Cats.Category.Setoids as Setoids using (Setoids ; ≈-intro ; ≈-elim)
open import Cats.Util.Conv
open Setoid using (Carrier ; refl ; sym ; trans) renaming (_≈_ to _≣_)
-- The existence of binary products, proven below, already follows from the
-- existence of general products, proven further below. We still construct them
-- explicitly because the definitions in this module are much easier to work
-- with.
module BuildBinary l l≈ where
infixr 2 _×_
open Category (Setoids l l≈)
open Setoids._⇒_ using (resp)
_×_ : Obj → Obj → Obj
_×_ = ×-setoid
projl : ∀ {A B} → A × B ⇒ A
projl {A} {B} = record
{ arr = P.proj₁
; resp = λ { (eq₁ , eq₂) → eq₁ }
}
projr : ∀ {A B} → A × B ⇒ B
projr {A} {B} = record
{ arr = P.proj₂
; resp = λ { (eq₁ , eq₂) → eq₂ }
}
⟨_,_⟩ : ∀ {X A B} → X ⇒ A → X ⇒ B → X ⇒ A × B
⟨_,_⟩ {A = A} {B} xl xr = record
{ arr = < xl ⃗ , xr ⃗ >
; resp = λ eq → resp xl eq , resp xr eq
}
isBinaryProduct : ∀ {A B} → IsBinaryProduct (A × B) projl projr
isBinaryProduct xl xr = record
{ arr = ⟨ xl , xr ⟩
; prop = (≈-intro λ eq → resp xl eq) , (≈-intro λ eq → resp xr eq)
; unique = λ { (eq₁ , eq₂) → ≈-intro λ x≈y → ≈-elim eq₁ x≈y , ≈-elim eq₂ x≈y }
}
_×′_ : ∀ A B → BinaryProduct A B
A ×′ B = mkBinaryProduct projl projr isBinaryProduct
instance
hasBinaryProducts : ∀ l l≈ → HasBinaryProducts (Setoids l l≈)
hasBinaryProducts l l≈ .HasBinaryProducts._×′_ = BuildBinary._×′_ l l≈
module Build l {I : Set l} where
open Category (Setoids l l)
open Setoids._⇒_ using (resp)
Π : (O : I → Obj) → Obj
Π O = record
{ Carrier = ∀ i → Carrier (O i)
; _≈_ = λ f g → ∀ i → _≣_ (O i) (f i) (g i)
; isEquivalence = record
{ refl = λ i → refl (O i)
; sym = λ eq i → sym (O i) (eq i)
; trans = λ eq₁ eq₂ i → trans (O i) (eq₁ i) (eq₂ i)
}
}
proj : ∀ {O : I → Obj} i → Π O ⇒ O i
proj i = record
{ arr = λ f → f i
; resp = λ eq → eq i
}
isProduct : ∀ {O : I → Obj} → IsProduct O (Π O) proj
isProduct x = record
{ arr = record
{ arr = λ a i → (x i ⃗) a
; resp = λ eq i → resp (x i) eq
}
; prop = λ i → ≈-intro λ eq → resp (x i) eq
; unique = λ x-candidate → ≈-intro λ eq i → ≈-elim (x-candidate i) eq
}
Π′ : (O : I → Obj) → Product O
Π′ O = record { prod = Π O ; proj = proj ; isProduct = isProduct }
instance
hasProducts : ∀ l → HasProducts l (Setoids l l)
hasProducts l = record { Π′ = Build.Π′ l }
| 25.285714
| 82
| 0.550847
|
d0f31e6b1aef204686363a5b778e1c3d2f86f445
| 13,436
|
agda
|
Agda
|
src/STLC/Coquand/Soundness.agda
|
mietek/coquand-kovacs
|
bd626509948fbf8503ec2e31c1852e1ac6edcc79
|
[
"X11"
] | null | null | null |
src/STLC/Coquand/Soundness.agda
|
mietek/coquand-kovacs
|
bd626509948fbf8503ec2e31c1852e1ac6edcc79
|
[
"X11"
] | null | null | null |
src/STLC/Coquand/Soundness.agda
|
mietek/coquand-kovacs
|
bd626509948fbf8503ec2e31c1852e1ac6edcc79
|
[
"X11"
] | null | null | null |
module STLC.Coquand.Soundness where
open import STLC.Coquand.Completeness public
--------------------------------------------------------------------------------
-- Un⟦_⟧
postulate
⟦_⟧Un : ∀ {Γ Ξ A} → {ρ : Γ ⊩⋆ Ξ}
→ (M : Ξ ⊢ A) → Un⋆ ρ
→ Un (⟦ M ⟧ ρ)
-- 𝒰⋆⟦_⟧ₛ
postulate
⟦_⟧Un⋆ : ∀ {Γ Ξ Φ} → {ρ : Γ ⊩⋆ Ξ}
→ (σ : Ξ ⊢⋆ Φ) → Un⋆ ρ
→ Un⋆ (⟦ σ ⟧⋆ ρ)
postulate
⟦_⟧Eq : ∀ {Γ Ξ A} → {ρ₁ ρ₂ : Γ ⊩⋆ Ξ}
→ (M : Ξ ⊢ A) → Eq⋆ ρ₁ ρ₂ → Un⋆ ρ₁ → Un⋆ ρ₂
→ Eq (⟦ M ⟧ ρ₁) (⟦ M ⟧ ρ₂)
-- Eq⋆⟦_⟧ₛ
postulate
⟦_⟧Eq⋆ : ∀ {Γ Ξ Φ} → {ρ₁ ρ₂ : Γ ⊩⋆ Ξ}
→ (σ : Ξ ⊢⋆ Φ) → Eq⋆ ρ₁ ρ₂ → Un⋆ ρ₁ → Un⋆ ρ₂
→ Eq⋆ (⟦ σ ⟧⋆ ρ₁) (⟦ σ ⟧⋆ ρ₂)
--------------------------------------------------------------------------------
-- ⟦_⟧⬗Eq = symEq ∘ ↑⟨_⟩Eq⟦_⟧
⟦_⟧⬗Eq : ∀ {Γ Γ′ Ξ A} → {ρ : Γ ⊩⋆ Ξ}
→ (M : Ξ ⊢ A) (η : Γ′ ∋⋆ Γ) → Un⋆ ρ
→ Eq (⟦ M ⟧ (η ⬗ ρ))
(acc η (⟦ M ⟧ ρ))
⟦_⟧⬗Eq (𝓋 i) η υ = get⬗Eq η i υ
⟦_⟧⬗Eq (ƛ M) η υ = eq⊃ (λ η′ u →
⟦ M ⟧Eq (comp⬗◇Eq⋆ η′ η υ , reflEq u)
(cong⬗Un⋆ η′ (cong⬗Un⋆ η υ) , u)
(cong⬗Un⋆ (η′ ○ η) υ , u))
⟦_⟧⬗Eq (M ∙ N) η υ =
cong⟦∙⟧Eq idᵣ (⟦ M ⟧⬗Eq η υ) (⟦ M ⟧Un (cong⬗Un⋆ η υ)) (congaccUn η (⟦ M ⟧Un υ))
(⟦ N ⟧⬗Eq η υ) (⟦ N ⟧Un (cong⬗Un⋆ η υ)) (congaccUn η (⟦ N ⟧Un υ))
⦙ acc⟦∙⟧idEq η (⟦ M ⟧Un υ) (congaccUn η (⟦ N ⟧Un υ))
⦙ (cong⟦∙⟧Eq η ((lidaccEq (⟦ M ⟧Un υ)) ⁻¹) (⟦ M ⟧Un υ) (congaccUn idᵣ (⟦ M ⟧Un υ))
(reflEq (congaccUn η (⟦ N ⟧Un υ))) (congaccUn η (⟦ N ⟧Un υ)) (congaccUn η (⟦ N ⟧Un υ))
⦙ acc⟦∙⟧Eq idᵣ η (⟦ M ⟧Un υ) (⟦ N ⟧Un υ))
-- ⟦_⟧⬗Eq⋆ = symEq ∘ ↑⟨_⟩Eq⋆⟦_⟧ₛ
⟦_⟧⬗Eq⋆ : ∀ {Γ Γ′ Ξ Φ} → {ρ : Γ ⊩⋆ Ξ}
→ (σ : Ξ ⊢⋆ Φ) (η : Γ′ ∋⋆ Γ) → Un⋆ ρ
→ Eq⋆ (⟦ σ ⟧⋆ (η ⬗ ρ))
(η ⬗ ⟦ σ ⟧⋆ ρ)
⟦_⟧⬗Eq⋆ ∅ η υ = ∅
⟦_⟧⬗Eq⋆ (σ , M) η υ = ⟦ σ ⟧⬗Eq⋆ η υ , ⟦ M ⟧⬗Eq η υ
--------------------------------------------------------------------------------
-- TODO: Generalise to zap⬖
postulate
aux₄₈₁ : ∀ {Γ Ξ A} → {ρ : Γ ⊩⋆ Ξ} {a : Γ ⊩ A}
→ Un⋆ ρ
→ Eq⋆ ((ρ , a) ⬖ wkᵣ idᵣ) ρ
-- TODO
-- Basic properties of _◇_
-- Advanced properties of _◇_
-- Basic properties of _⬗_
-- Basic properties of _◆_
-- Advanced properties of _⬗_
-- Advanced properties of _◆_
-- TODO: Fix the instance argument problem; abstract over models; rename η to ξ…
--------------------------------------------------------------------------------
renlift⟦_⟧Eq : ∀ {Γ Γ′ A B w w′} → {ρ : w ⊩⋆ Γ′} {a : w′ ⊩ A}
→ (M : Γ , A ⊢ B) (η₁ : Γ′ ∋⋆ Γ) (η₂ : w′ ∋⋆ w) → Un⋆ ρ → Un a
→ Eq (⟦ ren (liftᵣ {A} η₁) M ⟧ (η₂ ⬗ ρ , a))
(⟦ M ⟧ (η₂ ⬗ (ρ ⬖ η₁) , a))
renlift⟦_⟧Eq (𝓋 zero) η₁ η₂ υ u = reflEq u
renlift⟦_⟧Eq {ρ = ρ} {a} (𝓋 (suc i)) η₁ η₂ υ u =
≡→Eq ((getᵥ (η₂ ⬗ ρ , a)) & natgetᵣ η₁ i)
(conggetUn (getᵣ (wkᵣ η₁) i) (cong⬗Un⋆ η₂ υ , u))
⦙ get⬖Eq η₁ (getᵣ η₁ i) i (cong⬗Un⋆ η₂ υ) ⁻¹
⦙ conggetEq i (comp⬗⬖Eq⋆ η₂ η₁ υ ⁻¹)
renlift⟦_⟧Eq (ƛ M) η₁ η₂ υ u =
eq⊃ (λ η′ u′ → renlift⟦ M ⟧Eq (liftᵣ η₁) η′ (cong⬗Un⋆ η₂ υ , u) u′
⦙ ⟦ M ⟧Eq ( ( cong⬗Eq⋆ η′ (( comp⬗⬖Eq⋆ η₂ η₁ υ
⦙ zap⬖Eq⋆ (wkᵣ η₁) η₁ (cong⬗Un⋆ η₂ υ) ⁻¹
) ⁻¹)
, reflEq (congaccUn η′ u)
)
, reflEq u′
)
((cong⬗Un⋆ η′ (cong⬖Un⋆ (wkᵣ η₁) (cong⬗Un⋆ η₂ υ , u)) , congaccUn η′ u) , u′)
((cong⬗Un⋆ η′ (cong⬗Un⋆ η₂ (cong⬖Un⋆ η₁ υ)) , congaccUn η′ u) , u′))
renlift⟦_⟧Eq (M ∙ N) η₁ η₂ υ u =
cong⟦∙⟧Eq idᵣ (renlift⟦ M ⟧Eq η₁ η₂ υ u) (⟦ ren (liftᵣ η₁) M ⟧Un (cong⬗Un⋆ η₂ υ , u)) (⟦ M ⟧Un (cong⬗Un⋆ η₂ (cong⬖Un⋆ η₁ υ) , u))
(renlift⟦ N ⟧Eq η₁ η₂ υ u) (⟦ ren (liftᵣ η₁) N ⟧Un (cong⬗Un⋆ η₂ υ , u)) (⟦ N ⟧Un (cong⬗Un⋆ η₂ (cong⬖Un⋆ η₁ υ) , u))
--------------------------------------------------------------------------------
renwk⟦_⟧Eq : ∀ {Γ Γ′ A C w} → {ρ : w ⊩⋆ Γ′} {a : w ⊩ A}
→ (M : Γ ⊢ C) (η : Γ′ ∋⋆ Γ) → Un⋆ ρ → Un a
→ Eq (⟦ ren (wkᵣ {A} η) M ⟧ (ρ , a))
(⟦ M ⟧ (ρ ⬖ η))
renwk⟦_⟧Eq (𝓋 i) η υ u =
get⬖Eq (wkᵣ η) (getᵣ (wkᵣ η) i) i (υ , u) ⁻¹
⦙ conggetEq i (zap⬖Eq⋆ (wkᵣ η) η υ)
renwk⟦_⟧Eq (ƛ M) η υ u =
eq⊃ (λ η′ u′ → renlift⟦ M ⟧Eq (wkᵣ η) η′ (υ , u) u′
⦙ ⟦ M ⟧Eq (cong⬗Eq⋆ η′ (zap⬖Eq⋆ (wkᵣ η) η υ) , reflEq u′)
(cong⬗Un⋆ η′ (cong⬖Un⋆ (wkᵣ η) (υ , u)) , u′)
(cong⬗Un⋆ η′ (cong⬖Un⋆ η υ) , u′))
renwk⟦_⟧Eq (M ∙ N) η υ u =
cong⟦∙⟧Eq idᵣ (renwk⟦ M ⟧Eq η υ u) (⟦ ren (wkᵣ η) M ⟧Un (υ , u)) (⟦ M ⟧Un (cong⬖Un⋆ η υ))
(renwk⟦ N ⟧Eq η υ u) (⟦ ren (wkᵣ η) N ⟧Un (υ , u)) (⟦ N ⟧Un (cong⬖Un⋆ η υ))
--------------------------------------------------------------------------------
wk⟦_⟧Eq : ∀ {Γ A C w} → {ρ : w ⊩⋆ Γ} {a : w ⊩ A}
→ (M : Γ ⊢ C) → Un⋆ ρ → Un a
→ Eq (⟦ wk {A} M ⟧ (ρ , a))
(⟦ M ⟧ ρ)
wk⟦_⟧Eq M υ u = renwk⟦ M ⟧Eq idᵣ υ u
⦙ ⟦ M ⟧Eq (rid⬖Eq⋆ υ) (cong⬖Un⋆ idᵣ υ) υ
wk⟦_⟧Eq⋆ : ∀ {Γ Ξ A w} → {ρ : w ⊩⋆ Γ} {a : w ⊩ A}
→ (σ : Γ ⊢⋆ Ξ) → Un⋆ ρ → Un a
→ Eq⋆ (⟦ wkₛ {A} σ ⟧⋆ (ρ , a))
(⟦ σ ⟧⋆ ρ)
wk⟦_⟧Eq⋆ ∅ υ u = ∅
wk⟦_⟧Eq⋆ (σ , M) υ u = wk⟦ σ ⟧Eq⋆ υ u , wk⟦ M ⟧Eq υ u
--------------------------------------------------------------------------------
get⟦_⟧Eq : ∀ {Γ Ξ A w} → {ρ : w ⊩⋆ Γ}
→ (σ : Γ ⊢⋆ Ξ) (i : Ξ ∋ A) → Un⋆ ρ
→ Eq (⟦ getₛ σ i ⟧ ρ)
(getᵥ (⟦ σ ⟧⋆ ρ) i)
get⟦_⟧Eq (σ , M) zero υ = reflEq (⟦ M ⟧Un υ)
get⟦_⟧Eq (σ , M) (suc i) υ = get⟦ σ ⟧Eq i υ
--------------------------------------------------------------------------------
sublift⟦_⟧Eq : ∀ {Γ Ξ A B w} → {ρ : w ⊩⋆ Γ} {a : w ⊩ A}
→ (M : Ξ , A ⊢ B) (σ : Γ ⊢⋆ Ξ) → Un⋆ ρ → Un a
→ Eq (⟦ sub (liftₛ {A} σ) M ⟧ (ρ , a))
(⟦ M ⟧ (⟦ σ ⟧⋆ ρ , a))
sublift⟦_⟧Eq (𝓋 zero) σ υ u = reflEq u
sublift⟦_⟧Eq {ρ = ρ} {a} (𝓋 (suc i)) σ υ u =
≡→Eq ((λ M′ → ⟦ M′ ⟧ (ρ , a)) & natgetₛ σ i)
(⟦ getₛ (wkₛ σ) i ⟧Un (υ , u))
⦙ wk⟦ getₛ σ i ⟧Eq υ u
⦙ get⟦ σ ⟧Eq i υ
sublift⟦_⟧Eq (ƛ M) σ υ u =
eq⊃ (λ η′ u′ → sublift⟦ M ⟧Eq (liftₛ σ) (cong⬗Un⋆ η′ υ , congaccUn η′ u) u′
⦙ ⟦ M ⟧Eq ((⟦ wkₛ σ ⟧⬗Eq⋆ η′ (υ , u) , reflEq (congaccUn η′ u)) , reflEq u′)
((⟦ wkₛ σ ⟧Un⋆ (cong⬗Un⋆ η′ υ , congaccUn η′ u) , congaccUn η′ u) , u′)
((cong⬗Un⋆ η′ (⟦ wkₛ σ ⟧Un⋆ (υ , u)) , congaccUn η′ u) , u′)
⦙ ⟦ M ⟧Eq ((cong⬗Eq⋆ η′ (wk⟦ σ ⟧Eq⋆ υ u) , reflEq (congaccUn η′ u)) , reflEq u′)
((cong⬗Un⋆ η′ (⟦ wkₛ σ ⟧Un⋆ (υ , u)) , congaccUn η′ u) , u′)
((cong⬗Un⋆ η′ (⟦ σ ⟧Un⋆ υ) , congaccUn η′ u) , u′))
sublift⟦_⟧Eq (M ∙ N) σ υ u =
cong⟦∙⟧Eq idᵣ (sublift⟦ M ⟧Eq σ υ u) (⟦ sub (liftₛ σ) M ⟧Un (υ , u)) (⟦ M ⟧Un (⟦ σ ⟧Un⋆ υ , u))
(sublift⟦ N ⟧Eq σ υ u) (⟦ sub (liftₛ σ) N ⟧Un (υ , u)) (⟦ N ⟧Un (⟦ σ ⟧Un⋆ υ , u))
--------------------------------------------------------------------------------
subliftwk⟦_⟧Eq : ∀ {Γ Ξ A A′ B w w′} → {ρ : w ⊩⋆ Γ} {a : w ⊩ A} {a′ : w′ ⊩ A′}
→ (M : Ξ , A′ ⊢ B) (σ : Γ ⊢⋆ Ξ) (η : w′ ∋⋆ w) → Un⋆ ρ → Un a → Un a′
→ Eq (⟦ sub (liftₛ (wkₛ σ)) M ⟧ (η ⬗ ρ , acc η a , a′))
(⟦ sub (liftₛ σ) M ⟧ (η ⬗ ρ , a′))
subliftwk⟦_⟧Eq M σ η υ u u′ = sublift⟦ M ⟧Eq (wkₛ σ) (cong⬗Un⋆ η υ , congaccUn η u) u′
⦙ ⟦ M ⟧Eq (wk⟦ σ ⟧Eq⋆ (cong⬗Un⋆ η υ) (congaccUn η u) , reflEq u′)
(⟦ wkₛ σ ⟧Un⋆ (cong⬗Un⋆ η υ , congaccUn η u) , u′)
(⟦ σ ⟧Un⋆ (cong⬗Un⋆ η υ) , u′)
⦙ sublift⟦ M ⟧Eq σ (cong⬗Un⋆ η υ) u′ ⁻¹
--------------------------------------------------------------------------------
subwk⟦_⟧Eq : ∀ {Γ Ξ A C w} → {ρ : w ⊩⋆ Γ} {a : w ⊩ A}
→ (M : Ξ ⊢ C) (σ : Γ ⊢⋆ Ξ) → Un⋆ ρ → Un a
→ Eq (⟦ sub (wkₛ {A} σ) M ⟧ (ρ , a))
(⟦ sub σ M ⟧ ρ)
subwk⟦_⟧Eq {ρ = ρ} {a} (𝓋 i) σ υ u =
≡→Eq ((λ M′ → ⟦ M′ ⟧ (ρ , a)) & (natgetₛ σ i))
(⟦ getₛ (wkₛ σ) i ⟧Un (υ , u))
⦙ wk⟦ getₛ σ i ⟧Eq υ u
subwk⟦_⟧Eq (ƛ {A = A′} M) σ υ u =
eq⊃ (λ η u′ → subliftwk⟦ M ⟧Eq σ η υ u u′)
subwk⟦_⟧Eq (M ∙ N) σ υ u =
cong⟦∙⟧Eq idᵣ (subwk⟦ M ⟧Eq σ υ u) (⟦ sub (wkₛ σ) M ⟧Un (υ , u)) (⟦ sub σ M ⟧Un υ)
(subwk⟦ N ⟧Eq σ υ u) (⟦ sub (wkₛ σ) N ⟧Un (υ , u)) (⟦ sub σ N ⟧Un υ)
--------------------------------------------------------------------------------
sub⟦_⟧Eq : ∀ {Γ Ξ A w} → {ρ : w ⊩⋆ Γ}
→ (M : Ξ ⊢ A) (σ : Γ ⊢⋆ Ξ) → Un⋆ ρ
→ Eq (⟦ sub σ M ⟧ ρ)
(⟦ M ⟧ (⟦ σ ⟧⋆ ρ))
sub⟦_⟧Eq (𝓋 i) σ υ = get⟦ σ ⟧Eq i υ
sub⟦_⟧Eq (ƛ M) σ υ =
eq⊃ (λ η u → sublift⟦ M ⟧Eq σ (cong⬗Un⋆ η υ) u
⦙ ⟦ M ⟧Eq (⟦ σ ⟧⬗Eq⋆ η υ , reflEq u)
(⟦ σ ⟧Un⋆ (cong⬗Un⋆ η υ) , u)
(cong⬗Un⋆ η (⟦ σ ⟧Un⋆ υ) , u))
sub⟦_⟧Eq (M ∙ N) σ υ =
cong⟦∙⟧Eq idᵣ (sub⟦ M ⟧Eq σ υ) (⟦ sub σ M ⟧Un υ) (⟦ M ⟧Un (⟦ σ ⟧Un⋆ υ))
(sub⟦ N ⟧Eq σ υ) (⟦ sub σ N ⟧Un υ) (⟦ N ⟧Un (⟦ σ ⟧Un⋆ υ))
--------------------------------------------------------------------------------
-- TODO: Rename this
sublift⟦⟧Eq⁈ : ∀ {Γ Ξ A B w} → {ρ : w ⊩⋆ Γ}
→ (σ : Γ ⊢⋆ Ξ) (M : Ξ , A ⊢ B) (N : Γ ⊢ A) → Un⋆ ρ
→ Eq (⟦ sub (liftₛ {A} σ) M ⟧ (ρ , ⟦ N ⟧ ρ))
(⟦ sub (σ , N) M ⟧ ρ)
sublift⟦⟧Eq⁈ {ρ = ρ} σ M N υ = sublift⟦ M ⟧Eq σ υ (⟦ N ⟧Un υ)
⦙ sub⟦ M ⟧Eq (σ , N) υ ⁻¹
--------------------------------------------------------------------------------
-- TODO: Generalise theorem 4 over models
module _ where
open 𝔐 canon
mutual
lemƛ : ∀ {Γ A B w} → {ρ : w ⊩⋆ Γ} {M M′ : Γ , A ⊢ B}
→ M ∼ M′ → Un⋆ ρ
→ Eq (⟦ ƛ M ⟧ ρ) (⟦ ƛ M′ ⟧ ρ)
lemƛ p υ = eq⊃ (λ xs u → cong⟦ p ⟧Eq (cong⬗Un⋆ xs υ , u))
lem∙ : ∀ {Γ A B w} → {ρ : w ⊩⋆ Γ} {M M′ : Γ ⊢ A ⇒ B} {N N′ : Γ ⊢ A}
→ M ∼ M′ → N ∼ N′ → Un⋆ ρ
→ Eq (⟦ M ∙ N ⟧ ρ) (⟦ M′ ∙ N′ ⟧ ρ)
lem∙ {M = M} {M′} {N} {N′} p q υ = cong⟦∙⟧Eq idᵣ (cong⟦ p ⟧Eq υ) (⟦ M ⟧Un υ) (⟦ M′ ⟧Un υ)
(cong⟦ q ⟧Eq υ) (⟦ N ⟧Un υ) (⟦ N′ ⟧Un υ)
lemred⇒ : ∀ {Γ Ξ A B w} → {ρ : w ⊩⋆ Γ}
→ (σ : Γ ⊢⋆ Ξ) (M : Ξ , A ⊢ B) (N : Γ ⊢ A) → Un⋆ ρ
→ Eq (⟦ sub σ (ƛ M) ∙ N ⟧ ρ) (⟦ sub (σ , N) M ⟧ ρ)
lemred⇒ {ρ = ρ} σ M N υ =
⟦ sub (liftₛ σ) M ⟧Eq (lid⬗Eq⋆ υ , reflEq (⟦ N ⟧Un υ))
(cong⬗Un⋆ idᵣ υ , ⟦ N ⟧Un υ)
(υ , ⟦ N ⟧Un υ)
⦙ sublift⟦⟧Eq⁈ σ M N υ
lemexp⇒ : ∀ {Γ A B w} → {ρ : w ⊩⋆ Γ}
→ (M : Γ ⊢ A ⇒ B) → Un⋆ ρ
→ Eq (⟦ M ⟧ ρ) (⟦ ƛ (wk M ∙ 0) ⟧ ρ)
lemexp⇒ {ρ = ρ} M υ =
eq⊃ (λ η {a} u → acc⟦∙⟧idEq η (⟦ M ⟧Un υ) u ⁻¹
⦙ cong⟦∙⟧Eq idᵣ (⟦ M ⟧⬗Eq η υ ⁻¹) (congaccUn η (⟦ M ⟧Un υ)) (⟦ M ⟧Un (cong⬗Un⋆ η υ))
(reflEq u) u u
⦙ cong⟦∙⟧Eq idᵣ (wk⟦ M ⟧Eq (cong⬗Un⋆ η υ) u ⁻¹) (⟦ M ⟧Un (cong⬗Un⋆ η υ)) (⟦ wk M ⟧Un (cong⬗Un⋆ η υ , u))
(reflEq u) u u)
-- Theorem 4.
cong⟦_⟧Eq : ∀ {Γ A w} → {M M′ : Γ ⊢ A} {ρ : w ⊩⋆ Γ}
→ M ∼ M′ → Un⋆ ρ
→ Eq (⟦ M ⟧ ρ) (⟦ M′ ⟧ ρ)
cong⟦ refl∼ {M = M} ⟧Eq υ = reflEq (⟦ M ⟧Un υ)
cong⟦ p ⁻¹∼ ⟧Eq υ = cong⟦ p ⟧Eq υ ⁻¹
cong⟦ p ⦙∼ q ⟧Eq υ = cong⟦ p ⟧Eq υ ⦙ cong⟦ q ⟧Eq υ
cong⟦ ƛ∼ p ⟧Eq υ = lemƛ p υ
cong⟦ p ∙∼ q ⟧Eq υ = lem∙ p q υ
cong⟦ red⇒ σ M N ⟧Eq υ = lemred⇒ σ M N υ
cong⟦ exp⇒ M ⟧Eq υ = lemexp⇒ M υ
--------------------------------------------------------------------------------
-- Theorem 5.
thm₅ : ∀ {Γ A} → (M M′ : Γ ⊢ A) → nf M ≡ nf M′
→ M ∼ M′
thm₅ M M′ p = thm₂ M
⦙ ≡→∼ p
⦙ (thm₂ M′ ⁻¹)
--------------------------------------------------------------------------------
-- proj⟨_⟩𝒰⋆
⌊_⌋ᵤ : ∀ {Γ Γ′} → (η : Γ′ ∋⋆ Γ)
→ Un⋆ ⌊ η ⌋ᵥ
⌊ ∅ ⌋ᵤ = ∅
⌊ η , i ⌋ᵤ = ⌊ η ⌋ᵤ , ⟪𝓋 i ⟫ᵤ
-- refl𝒰⋆
idᵤ : ∀ {Γ} → Un⋆ (idᵥ {Γ})
idᵤ = ⌊ idᵣ ⌋ᵤ
-- Theorem 6.
thm₆ : ∀ {Γ A} → (M M′ : Γ ⊢ A) → M ∼ M′
→ nf M ≡ nf M′
thm₆ M M′ p = cor₁ M M′ (cong⟦ p ⟧Eq idᵤ)
--------------------------------------------------------------------------------
| 37.847887
| 131
| 0.295698
|
06a08ba9862731a9ae77d15a9df058acf412901b
| 400
|
agda
|
Agda
|
test/Succeed/ForallForParameters.agda
|
pthariensflame/agda
|
222c4c64b2ccf8e0fc2498492731c15e8fef32d4
|
[
"BSD-3-Clause"
] | 3
|
2015-03-28T14:51:03.000Z
|
2015-12-07T20:14:00.000Z
|
test/succeed/ForallForParameters.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
test/succeed/ForallForParameters.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | 1
|
2019-03-05T20:02:38.000Z
|
2019-03-05T20:02:38.000Z
|
module ForallForParameters
(F : Set -> Set -> Set) X {Y} (Z : F X Y) where
data List A : Set where
[] : List A
_::_ : A -> List A -> List A
module M A {B} (C : F A B) where
data D : Set -> Set where
d : A -> D A
data P A : D A -> Set where
data Q {A} X : P A X -> Set where
module N I J K = M I {J} K
open module O I J K = N I J K
record R {I J} (K : F I J) : Set where
| 19.047619
| 56
| 0.515
|
4d4fe49170379f518f51cadcef8b16be267ecdbc
| 5,663
|
agda
|
Agda
|
Cubical/Foundations/Isomorphism.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
Cubical/Foundations/Isomorphism.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | 1
|
2022-01-27T02:07:48.000Z
|
2022-01-27T02:07:48.000Z
|
Cubical/Foundations/Isomorphism.agda
|
L-TChen/cubical
|
60226aacd7b386aef95d43a0c29c4eec996348a8
|
[
"MIT"
] | null | null | null |
{-
Theory about isomorphisms
- Definitions of [section] and [retract]
- Definition of isomorphisms ([Iso])
- Any isomorphism is an equivalence ([isoToEquiv])
-}
{-# OPTIONS --cubical --no-import-sorts --safe #-}
module Cubical.Foundations.Isomorphism where
open import Cubical.Core.Everything
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Function
open import Cubical.Foundations.Equiv.Base
open import Cubical.Foundations.Function
private
variable
ℓ ℓ' : Level
A B C : Type ℓ
-- Section and retract
module _ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} where
section : (f : A → B) → (g : B → A) → Type ℓ'
section f g = ∀ b → f (g b) ≡ b
-- NB: `g` is the retraction!
retract : (f : A → B) → (g : B → A) → Type ℓ
retract f g = ∀ a → g (f a) ≡ a
record Iso {ℓ ℓ'} (A : Type ℓ) (B : Type ℓ') : Type (ℓ-max ℓ ℓ') where
no-eta-equality
constructor iso
field
fun : A → B
inv : B → A
rightInv : section fun inv
leftInv : retract fun inv
isIso : (A → B) → Type _
isIso {A = A} {B = B} f = Σ[ g ∈ (B → A) ] Σ[ _ ∈ section f g ] retract f g
isoFunInjective : (f : Iso A B) → (x y : A) → Iso.fun f x ≡ Iso.fun f y → x ≡ y
isoFunInjective f x y h = sym (Iso.leftInv f x) ∙∙ cong (Iso.inv f) h ∙∙ Iso.leftInv f y
isoInvInjective : (f : Iso A B) → (x y : B) → Iso.inv f x ≡ Iso.inv f y → x ≡ y
isoInvInjective f x y h = sym (Iso.rightInv f x) ∙∙ cong (Iso.fun f) h ∙∙ Iso.rightInv f y
-- Any iso is an equivalence
module _ (i : Iso A B) where
open Iso i renaming ( fun to f
; inv to g
; rightInv to s
; leftInv to t)
private
module _ (y : B) (x0 x1 : A) (p0 : f x0 ≡ y) (p1 : f x1 ≡ y) where
fill0 : I → I → A
fill0 i = hfill (λ k → λ { (i = i1) → t x0 k
; (i = i0) → g y })
(inS (g (p0 (~ i))))
fill1 : I → I → A
fill1 i = hfill (λ k → λ { (i = i1) → t x1 k
; (i = i0) → g y })
(inS (g (p1 (~ i))))
fill2 : I → I → A
fill2 i = hfill (λ k → λ { (i = i1) → fill1 k i1
; (i = i0) → fill0 k i1 })
(inS (g y))
p : x0 ≡ x1
p i = fill2 i i1
sq : I → I → A
sq i j = hcomp (λ k → λ { (i = i1) → fill1 j (~ k)
; (i = i0) → fill0 j (~ k)
; (j = i1) → t (fill2 i i1) (~ k)
; (j = i0) → g y })
(fill2 i j)
sq1 : I → I → B
sq1 i j = hcomp (λ k → λ { (i = i1) → s (p1 (~ j)) k
; (i = i0) → s (p0 (~ j)) k
; (j = i1) → s (f (p i)) k
; (j = i0) → s y k })
(f (sq i j))
lemIso : (x0 , p0) ≡ (x1 , p1)
lemIso i .fst = p i
lemIso i .snd = λ j → sq1 i (~ j)
isoToIsEquiv : isEquiv f
isoToIsEquiv .equiv-proof y .fst .fst = g y
isoToIsEquiv .equiv-proof y .fst .snd = s y
isoToIsEquiv .equiv-proof y .snd z = lemIso y (g y) (fst z) (s y) (snd z)
isoToEquiv : Iso A B → A ≃ B
isoToEquiv i .fst = _
isoToEquiv i .snd = isoToIsEquiv i
isoToPath : Iso A B → A ≡ B
isoToPath {A = A} {B = B} f i =
Glue B (λ { (i = i0) → (A , isoToEquiv f)
; (i = i1) → (B , idEquiv B) })
open Iso
invIso : Iso A B → Iso B A
fun (invIso f) = inv f
inv (invIso f) = fun f
rightInv (invIso f) = leftInv f
leftInv (invIso f) = rightInv f
compIso : Iso A B → Iso B C → Iso A C
fun (compIso i j) = fun j ∘ fun i
inv (compIso i j) = inv i ∘ inv j
rightInv (compIso i j) b = cong (fun j) (rightInv i (inv j b)) ∙ rightInv j b
leftInv (compIso i j) a = cong (inv i) (leftInv j (fun i a)) ∙ leftInv i a
composesToId→Iso : (G : Iso A B) (g : B → A) → G .fun ∘ g ≡ idfun B → Iso B A
fun (composesToId→Iso _ g _) = g
inv (composesToId→Iso j _ _) = fun j
rightInv (composesToId→Iso i g path) b =
sym (leftInv i (g (fun i b))) ∙∙ cong (λ g → inv i (g (fun i b))) path ∙∙ leftInv i b
leftInv (composesToId→Iso _ _ path) b i = path i b
idIso : Iso A A
fun idIso = idfun _
inv idIso = idfun _
rightInv idIso _ = refl
leftInv idIso _ = refl
LiftIso : Iso A (Lift {i = ℓ} {j = ℓ'} A)
fun LiftIso = lift
inv LiftIso = lower
rightInv LiftIso _ = refl
leftInv LiftIso _ = refl
isContr→Iso : isContr A → isContr B → Iso A B
fun (isContr→Iso _ Bctr) _ = Bctr .fst
inv (isContr→Iso Actr _) _ = Actr .fst
rightInv (isContr→Iso _ Bctr) = Bctr .snd
leftInv (isContr→Iso Actr _) = Actr .snd
isProp→Iso : (Aprop : isProp A) (Bprop : isProp B) (f : A → B) (g : B → A) → Iso A B
fun (isProp→Iso _ _ f _) = f
inv (isProp→Iso _ _ _ g) = g
rightInv (isProp→Iso _ Bprop f g) b = Bprop (f (g b)) b
leftInv (isProp→Iso Aprop _ f g) a = Aprop (g (f a)) a
domIso : ∀ {ℓ} {C : Type ℓ} → Iso A B → Iso (A → C) (B → C)
fun (domIso e) f b = f (inv e b)
inv (domIso e) f a = f (fun e a)
rightInv (domIso e) f i x = f (rightInv e x i)
leftInv (domIso e) f i x = f (leftInv e x i)
-- Helpful notation
_Iso⟨_⟩_ : ∀ {ℓ ℓ' ℓ''} {B : Type ℓ'} {C : Type ℓ''} (X : Type ℓ) → Iso X B → Iso B C → Iso X C
_ Iso⟨ f ⟩ g = compIso f g
_∎Iso : ∀ {ℓ} (A : Type ℓ) → Iso A A
A ∎Iso = idIso {A = A}
infixr 0 _Iso⟨_⟩_
infix 1 _∎Iso
codomainIso : ∀ {ℓ ℓ' ℓ''} {A : Type ℓ} {B : Type ℓ'} {C : Type ℓ''}
→ Iso B C
→ Iso (A → B) (A → C)
Iso.fun (codomainIso is) f a = Iso.fun is (f a)
Iso.inv (codomainIso is) f a = Iso.inv is (f a)
Iso.rightInv (codomainIso is) f = funExt λ a → Iso.rightInv is (f a)
Iso.leftInv (codomainIso is) f = funExt λ a → Iso.leftInv is (f a)
| 31.287293
| 95
| 0.515098
|
1d8080ab44a38bbbfa32aab73e9e2ef4d74d52b0
| 9,104
|
agda
|
Agda
|
Definition/Conversion/Stability.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
Definition/Conversion/Stability.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
Definition/Conversion/Stability.agda
|
Vtec234/logrel-mltt
|
4746894adb5b8edbddc8463904ee45c2e9b29b69
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
module Definition.Conversion.Stability where
open import Definition.Untyped
open import Definition.Untyped.Properties
open import Definition.Typed
open import Definition.Typed.Weakening
open import Definition.Conversion
open import Definition.Conversion.Soundness
open import Definition.Typed.Consequences.Syntactic
open import Definition.Typed.Consequences.Substitution
open import Tools.Product
import Tools.PropositionalEquality as PE
-- Equality of contexts.
data ⊢_≡_ : (Γ Δ : Con Term) → Set where
ε : ⊢ ε ≡ ε
_∙_ : ∀ {Γ Δ A B} → ⊢ Γ ≡ Δ → Γ ⊢ A ≡ B → ⊢ Γ ∙ A ≡ Δ ∙ B
mutual
-- Syntactic validity and conversion substitution of a context equality.
contextConvSubst : ∀ {Γ Δ} → ⊢ Γ ≡ Δ → ⊢ Γ × ⊢ Δ × Δ ⊢ˢ idSubst ∷ Γ
contextConvSubst ε = ε , ε , id
contextConvSubst (_∙_ {Γ} {Δ} {A} {B} Γ≡Δ A≡B) =
let ⊢Γ , ⊢Δ , [σ] = contextConvSubst Γ≡Δ
⊢A , ⊢B = syntacticEq A≡B
Δ⊢B = stability Γ≡Δ ⊢B
in ⊢Γ ∙ ⊢A , ⊢Δ ∙ Δ⊢B
, (wk1Subst′ ⊢Γ ⊢Δ Δ⊢B [σ]
, conv (var (⊢Δ ∙ Δ⊢B) here)
(PE.subst (λ x → _ ⊢ _ ≡ x)
(wk1-tailId A)
(wkEq (step id) (⊢Δ ∙ Δ⊢B) (stabilityEq Γ≡Δ (sym A≡B)))))
-- Stability of types under equal contexts.
stability : ∀ {A Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ A → Δ ⊢ A
stability Γ≡Δ A =
let ⊢Γ , ⊢Δ , σ = contextConvSubst Γ≡Δ
q = substitution A σ ⊢Δ
in PE.subst (λ x → _ ⊢ x) (subst-id _) q
-- Stability of type equality.
stabilityEq : ∀ {A B Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ A ≡ B → Δ ⊢ A ≡ B
stabilityEq Γ≡Δ A≡B =
let ⊢Γ , ⊢Δ , σ = contextConvSubst Γ≡Δ
q = substitutionEq A≡B (substRefl σ) ⊢Δ
in PE.subst₂ (λ x y → _ ⊢ x ≡ y) (subst-id _) (subst-id _) q
-- Reflexivity of context equality.
reflConEq : ∀ {Γ} → ⊢ Γ → ⊢ Γ ≡ Γ
reflConEq ε = ε
reflConEq (⊢Γ ∙ ⊢A) = reflConEq ⊢Γ ∙ refl ⊢A
-- Symmetry of context equality.
symConEq : ∀ {Γ Δ} → ⊢ Γ ≡ Δ → ⊢ Δ ≡ Γ
symConEq ε = ε
symConEq (Γ≡Δ ∙ A≡B) = symConEq Γ≡Δ ∙ stabilityEq Γ≡Δ (sym A≡B)
-- Stability of terms.
stabilityTerm : ∀ {t A Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ t ∷ A → Δ ⊢ t ∷ A
stabilityTerm Γ≡Δ t =
let ⊢Γ , ⊢Δ , σ = contextConvSubst Γ≡Δ
q = substitutionTerm t σ ⊢Δ
in PE.subst₂ (λ x y → _ ⊢ x ∷ y) (subst-id _) (subst-id _) q
-- Stability of term reduction.
stabilityRedTerm : ∀ {t u A Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ t ⇒ u ∷ A → Δ ⊢ t ⇒ u ∷ A
stabilityRedTerm Γ≡Δ (conv d x) =
conv (stabilityRedTerm Γ≡Δ d) (stabilityEq Γ≡Δ x)
stabilityRedTerm Γ≡Δ (app-subst d x) =
app-subst (stabilityRedTerm Γ≡Δ d) (stabilityTerm Γ≡Δ x)
stabilityRedTerm Γ≡Δ (fst-subst ⊢F ⊢G t⇒) =
fst-subst (stability Γ≡Δ ⊢F)
(stability (Γ≡Δ ∙ refl ⊢F) ⊢G)
(stabilityRedTerm Γ≡Δ t⇒)
stabilityRedTerm Γ≡Δ (snd-subst ⊢F ⊢G t⇒) =
snd-subst (stability Γ≡Δ ⊢F)
(stability (Γ≡Δ ∙ refl ⊢F) ⊢G)
(stabilityRedTerm Γ≡Δ t⇒)
stabilityRedTerm Γ≡Δ (Σ-β₁ ⊢F ⊢G ⊢t ⊢u) =
Σ-β₁ (stability Γ≡Δ ⊢F)
(stability (Γ≡Δ ∙ refl ⊢F) ⊢G)
(stabilityTerm Γ≡Δ ⊢t)
(stabilityTerm Γ≡Δ ⊢u)
stabilityRedTerm Γ≡Δ (Σ-β₂ ⊢F ⊢G ⊢t ⊢u) =
Σ-β₂ (stability Γ≡Δ ⊢F)
(stability (Γ≡Δ ∙ refl ⊢F) ⊢G)
(stabilityTerm Γ≡Δ ⊢t)
(stabilityTerm Γ≡Δ ⊢u)
stabilityRedTerm Γ≡Δ (β-red x x₁ x₂) =
β-red (stability Γ≡Δ x) (stabilityTerm (Γ≡Δ ∙ refl x) x₁)
(stabilityTerm Γ≡Δ x₂)
stabilityRedTerm Γ≡Δ (natrec-subst x x₁ x₂ d) =
let ⊢Γ , _ , _ = contextConvSubst Γ≡Δ
in natrec-subst (stability (Γ≡Δ ∙ refl (ℕⱼ ⊢Γ)) x) (stabilityTerm Γ≡Δ x₁)
(stabilityTerm Γ≡Δ x₂) (stabilityRedTerm Γ≡Δ d)
stabilityRedTerm Γ≡Δ (natrec-zero x x₁ x₂) =
let ⊢Γ , _ , _ = contextConvSubst Γ≡Δ
in natrec-zero (stability (Γ≡Δ ∙ refl (ℕⱼ ⊢Γ)) x) (stabilityTerm Γ≡Δ x₁)
(stabilityTerm Γ≡Δ x₂)
stabilityRedTerm Γ≡Δ (natrec-suc x x₁ x₂ x₃) =
let ⊢Γ , _ , _ = contextConvSubst Γ≡Δ
in natrec-suc (stabilityTerm Γ≡Δ x) (stability (Γ≡Δ ∙ refl (ℕⱼ ⊢Γ)) x₁)
(stabilityTerm Γ≡Δ x₂) (stabilityTerm Γ≡Δ x₃)
stabilityRedTerm Γ≡Δ (Emptyrec-subst x d) =
Emptyrec-subst (stability Γ≡Δ x) (stabilityRedTerm Γ≡Δ d)
-- Stability of type reductions.
stabilityRed : ∀ {A B Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ A ⇒ B → Δ ⊢ A ⇒ B
stabilityRed Γ≡Δ (univ x) = univ (stabilityRedTerm Γ≡Δ x)
-- Stability of type reduction closures.
stabilityRed* : ∀ {A B Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ A ⇒* B → Δ ⊢ A ⇒* B
stabilityRed* Γ≡Δ (id x) = id (stability Γ≡Δ x)
stabilityRed* Γ≡Δ (x ⇨ D) = stabilityRed Γ≡Δ x ⇨ stabilityRed* Γ≡Δ D
-- Stability of term reduction closures.
stabilityRed*Term : ∀ {t u A Γ Δ} → ⊢ Γ ≡ Δ → Γ ⊢ t ⇒* u ∷ A → Δ ⊢ t ⇒* u ∷ A
stabilityRed*Term Γ≡Δ (id x) = id (stabilityTerm Γ≡Δ x)
stabilityRed*Term Γ≡Δ (x ⇨ d) = stabilityRedTerm Γ≡Δ x ⇨ stabilityRed*Term Γ≡Δ d
mutual
-- Stability of algorithmic equality of neutrals.
stability~↑ : ∀ {k l A Γ Δ}
→ ⊢ Γ ≡ Δ
→ Γ ⊢ k ~ l ↑ A
→ Δ ⊢ k ~ l ↑ A
stability~↑ Γ≡Δ (var-refl x x≡y) =
var-refl (stabilityTerm Γ≡Δ x) x≡y
stability~↑ Γ≡Δ (app-cong k~l x) =
app-cong (stability~↓ Γ≡Δ k~l) (stabilityConv↑Term Γ≡Δ x)
stability~↑ Γ≡Δ (fst-cong p~r) =
fst-cong (stability~↓ Γ≡Δ p~r)
stability~↑ Γ≡Δ (snd-cong p~r) =
snd-cong (stability~↓ Γ≡Δ p~r)
stability~↑ Γ≡Δ (natrec-cong x₁ x₂ x₃ k~l) =
let ⊢Γ , _ , _ = contextConvSubst Γ≡Δ
in natrec-cong (stabilityConv↑ (Γ≡Δ ∙ (refl (ℕⱼ ⊢Γ))) x₁)
(stabilityConv↑Term Γ≡Δ x₂)
(stabilityConv↑Term Γ≡Δ x₃)
(stability~↓ Γ≡Δ k~l)
stability~↑ Γ≡Δ (Emptyrec-cong x₁ k~l) =
Emptyrec-cong (stabilityConv↑ Γ≡Δ x₁)
(stability~↓ Γ≡Δ k~l)
-- Stability of algorithmic equality of neutrals of types in WHNF.
stability~↓ : ∀ {k l A Γ Δ}
→ ⊢ Γ ≡ Δ
→ Γ ⊢ k ~ l ↓ A
→ Δ ⊢ k ~ l ↓ A
stability~↓ Γ≡Δ ([~] A D whnfA k~l) =
[~] A (stabilityRed* Γ≡Δ D) whnfA (stability~↑ Γ≡Δ k~l)
-- Stability of algorithmic equality of types.
stabilityConv↑ : ∀ {A B Γ Δ}
→ ⊢ Γ ≡ Δ
→ Γ ⊢ A [conv↑] B
→ Δ ⊢ A [conv↑] B
stabilityConv↑ Γ≡Δ ([↑] A′ B′ D D′ whnfA′ whnfB′ A′<>B′) =
[↑] A′ B′ (stabilityRed* Γ≡Δ D) (stabilityRed* Γ≡Δ D′) whnfA′ whnfB′
(stabilityConv↓ Γ≡Δ A′<>B′)
-- Stability of algorithmic equality of types in WHNF.
stabilityConv↓ : ∀ {A B Γ Δ}
→ ⊢ Γ ≡ Δ
→ Γ ⊢ A [conv↓] B
→ Δ ⊢ A [conv↓] B
stabilityConv↓ Γ≡Δ (U-refl x) =
let _ , ⊢Δ , _ = contextConvSubst Γ≡Δ
in U-refl ⊢Δ
stabilityConv↓ Γ≡Δ (ℕ-refl x) =
let _ , ⊢Δ , _ = contextConvSubst Γ≡Δ
in ℕ-refl ⊢Δ
stabilityConv↓ Γ≡Δ (Empty-refl x) =
let _ , ⊢Δ , _ = contextConvSubst Γ≡Δ
in Empty-refl ⊢Δ
stabilityConv↓ Γ≡Δ (Unit-refl x) =
let _ , ⊢Δ , _ = contextConvSubst Γ≡Δ
in Unit-refl ⊢Δ
stabilityConv↓ Γ≡Δ (ne x) =
ne (stability~↓ Γ≡Δ x)
stabilityConv↓ Γ≡Δ (Π-cong F A<>B A<>B₁) =
Π-cong (stability Γ≡Δ F) (stabilityConv↑ Γ≡Δ A<>B)
(stabilityConv↑ (Γ≡Δ ∙ refl F) A<>B₁)
stabilityConv↓ Γ≡Δ (Σ-cong F A<>B A<>B₁) =
Σ-cong (stability Γ≡Δ F) (stabilityConv↑ Γ≡Δ A<>B)
(stabilityConv↑ (Γ≡Δ ∙ refl F) A<>B₁)
-- Stability of algorithmic equality of terms.
stabilityConv↑Term : ∀ {t u A Γ Δ}
→ ⊢ Γ ≡ Δ
→ Γ ⊢ t [conv↑] u ∷ A
→ Δ ⊢ t [conv↑] u ∷ A
stabilityConv↑Term Γ≡Δ ([↑]ₜ B t′ u′ D d d′ whnfB whnft′ whnfu′ t<>u) =
[↑]ₜ B t′ u′ (stabilityRed* Γ≡Δ D) (stabilityRed*Term Γ≡Δ d)
(stabilityRed*Term Γ≡Δ d′) whnfB whnft′ whnfu′
(stabilityConv↓Term Γ≡Δ t<>u)
-- Stability of algorithmic equality of terms in WHNF.
stabilityConv↓Term : ∀ {t u A Γ Δ}
→ ⊢ Γ ≡ Δ
→ Γ ⊢ t [conv↓] u ∷ A
→ Δ ⊢ t [conv↓] u ∷ A
stabilityConv↓Term Γ≡Δ (ℕ-ins x) =
ℕ-ins (stability~↓ Γ≡Δ x)
stabilityConv↓Term Γ≡Δ (Empty-ins x) =
Empty-ins (stability~↓ Γ≡Δ x)
stabilityConv↓Term Γ≡Δ (Unit-ins x) =
Unit-ins (stability~↓ Γ≡Δ x)
stabilityConv↓Term Γ≡Δ (ne-ins t u neN x) =
ne-ins (stabilityTerm Γ≡Δ t) (stabilityTerm Γ≡Δ u) neN (stability~↓ Γ≡Δ x)
stabilityConv↓Term Γ≡Δ (univ x x₁ x₂) =
univ (stabilityTerm Γ≡Δ x) (stabilityTerm Γ≡Δ x₁) (stabilityConv↓ Γ≡Δ x₂)
stabilityConv↓Term Γ≡Δ (zero-refl x) =
let _ , ⊢Δ , _ = contextConvSubst Γ≡Δ
in zero-refl ⊢Δ
stabilityConv↓Term Γ≡Δ (suc-cong t<>u) = suc-cong (stabilityConv↑Term Γ≡Δ t<>u)
stabilityConv↓Term Γ≡Δ (η-eq x x₁ y y₁ t<>u) =
let ⊢F , ⊢G = syntacticΠ (syntacticTerm x)
in η-eq (stabilityTerm Γ≡Δ x) (stabilityTerm Γ≡Δ x₁)
y y₁ (stabilityConv↑Term (Γ≡Δ ∙ refl ⊢F) t<>u)
stabilityConv↓Term Γ≡Δ (Σ-η ⊢p ⊢r pProd rProd fstConv sndConv) =
Σ-η (stabilityTerm Γ≡Δ ⊢p) (stabilityTerm Γ≡Δ ⊢r)
pProd rProd
(stabilityConv↑Term Γ≡Δ fstConv) (stabilityConv↑Term Γ≡Δ sndConv)
stabilityConv↓Term Γ≡Δ (η-unit [t] [u] tUnit uUnit) =
let [t] = stabilityTerm Γ≡Δ [t]
[u] = stabilityTerm Γ≡Δ [u]
in η-unit [t] [u] tUnit uUnit
| 39.072961
| 82
| 0.564477
|
39f267993556ab7f39f70882b16b61889cf6c3b8
| 5,137
|
agda
|
Agda
|
src/FairSubtyping.agda
|
boystrange/FairSubtypingAgda
|
c4b78e70c3caf68d509f4360b9171d9f80ecb825
|
[
"MIT"
] | 4
|
2021-07-29T14:32:30.000Z
|
2022-01-24T14:38:47.000Z
|
src/FairSubtyping.agda
|
boystrange/FairSubtypingAgda
|
c4b78e70c3caf68d509f4360b9171d9f80ecb825
|
[
"MIT"
] | null | null | null |
src/FairSubtyping.agda
|
boystrange/FairSubtypingAgda
|
c4b78e70c3caf68d509f4360b9171d9f80ecb825
|
[
"MIT"
] | null | null | null |
-- MIT License
-- Copyright (c) 2021 Luca Ciccone and Luca Padovani
-- Permission is hereby granted, free of charge, to any person
-- obtaining a copy of this software and associated documentation
-- files (the "Software"), to deal in the Software without
-- restriction, including without limitation the rights to use,
-- copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the
-- Software is furnished to do so, subject to the following
-- conditions:
-- The above copyright notice and this permission notice shall be
-- included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-- OTHER DEALINGS IN THE SOFTWARE.
{-# OPTIONS --guardedness --sized-types #-}
open import Size
open import Data.Empty
open import Data.Product
open import Data.Sum
open import Data.List using ([]; _∷_; _∷ʳ_; _++_)
open import Codata.Thunk
open import Relation.Nullary
open import Relation.Nullary.Negation using (contraposition)
open import Relation.Unary using (_∈_; _⊆_)
open import Relation.Binary.PropositionalEquality using (_≡_; _≢_; refl)
open import Relation.Binary.Construct.Closure.ReflexiveTransitive using (Star; ε; _◅_; return)
open import Function.Base using (case_of_)
open import Common
module FairSubtyping {ℙ : Set} (message : Message ℙ) where
open import Trace message
open import SessionType message
open import Transitions message
open import Session message
open import Compliance message
open import HasTrace message
open import TraceInclusion message
open import Convergence message
open import FairCompliance message
data FairSub : SessionType -> SessionType -> Size -> Set where
nil<|any : ∀{T i} -> FairSub nil T i
end<|def : ∀{T S i} (e : End T) (def : Defined S) -> FairSub T S i
inp<|inp :
∀{f g i}
(con : inp f ↓ inp g)
(inc : dom f ⊆ dom g)
(F : (x : ℙ) -> Thunk (FairSub (f x .force) (g x .force)) i) ->
FairSub (inp f) (inp g) i
out<|out :
∀{f g i}
(con : out f ↓ out g)
(W : Witness g)
(inc : dom g ⊆ dom f)
(F : ∀{x} (!x : x ∈ dom g) -> Thunk (FairSub (f x .force) (g x .force)) i) ->
FairSub (out f) (out g) i
_<|_ : SessionType -> SessionType -> Set
_<|_ T S = FairSub T S ∞
-- sub-defined : ∀{T S} -> T <| S -> Defined T -> Defined S
-- sub-defined (end<|def _ def) _ = def
-- sub-defined (inp<|inp _ _) _ = inp
-- sub-defined (out<|out _ _ _) _ = out
fs->convergence : ∀{T S} -> T <| S -> T ↓ S
fs->convergence nil<|any = inclusion->convergence nil<=any
fs->convergence (end<|def e def) = inclusion->convergence (end<=def e def)
fs->convergence (inp<|inp con inc F) = con
fs->convergence (out<|out con W inc F) = con
fc-not-transition+end :
∀{R R' T α} ->
FairComplianceS (R # T) ->
Transition R α R' ->
End T ->
⊥
fc-not-transition+end comp inp (inp U) with comp ε
... | _ , ε , win#def () _
... | _ , sync () inp ◅ _ , _
fc-not-transition+end comp inp (out U) with comp ε
... | _ , ε , win#def () _
... | _ , sync _ (out fx) ◅ _ , _ = ⊥-elim (U _ fx)
fc-not-transition+end comp (out fx) (inp V) with comp ε
... | _ , ε , win#def (out U) _ = ⊥-elim (U _ fx)
... | _ , sync (out _) inp ◅ reds , win#def w def =
let _ , rr , tr = unzip-red* reds in
⊥-elim (V _ (transitions+defined->defined tr def))
fc-not-transition+end comp (out fx) (out _) with comp ε
... | _ , ε , win#def (out U) _ = ⊥-elim (U _ fx)
... | _ , sync () (out _) ◅ _ , _
sub-red :
∀{T S S' R R' α} ->
FairComplianceS (R # T) ->
T <| S ->
Transition R (co-action α) R' ->
Transition S α S' ->
∃[ T' ] (Transition T α T' × T' <| S')
sub-red comp nil<|any _ _ with comp ε
... | _ , ε , win#def _ ()
... | _ , sync _ () ◅ _ , _
sub-red comp (end<|def e _) r _ = ⊥-elim (fc-not-transition+end comp r e)
sub-red comp (inp<|inp con inc F) (out {h} hx) (inp {f}) = _ , inp , F _ .force
sub-red comp (out<|out con W inc F) inp (out fx) = _ , out (inc fx) , F fx .force
sub-red* :
∀{T S S' R R' φ} ->
FairComplianceS (R # T) ->
T <| S ->
Transitions R (co-trace φ) R' ->
Transitions S φ S' ->
∃[ T' ] (Transitions T φ T' × T' <| S')
sub-red* comp sub refl refl = _ , refl , sub
sub-red* comp sub (step r rr) (step s sr) =
let _ , t , sub' = sub-red comp sub r s in
let comp' = fc-transitions (step r refl) (step t refl) comp in
let _ , tr , sub'' = sub-red* comp' sub' rr sr in
_ , step t tr , sub''
sub-sound : ∀{T S R} -> FairComplianceS (R # T) -> T <| S -> FairComplianceS (R # S)
sub-sound comp sub {_ # _} reds =
let _ , rr , sr = unzip-red* reds in
let _ , tr , sub' = sub-red* comp sub rr sr in
let comp' = fair-compliance-red* comp (zip-red* rr tr) in
con-sound (fs->convergence sub') comp'
| 35.184932
| 94
| 0.640062
|
2f30f271df46533d1b5574e1c6bf8ac088408770
| 9,671
|
agda
|
Agda
|
Everything.agda
|
Taneb/agda-categories
|
6ebc1349ee79669c5c496dcadd551d5bbefd1972
|
[
"MIT"
] | null | null | null |
Everything.agda
|
Taneb/agda-categories
|
6ebc1349ee79669c5c496dcadd551d5bbefd1972
|
[
"MIT"
] | null | null | null |
Everything.agda
|
Taneb/agda-categories
|
6ebc1349ee79669c5c496dcadd551d5bbefd1972
|
[
"MIT"
] | null | null | null |
import Categories.2-Category
import Categories.2-Functor
import Categories.Adjoint
import Categories.Adjoint.Construction.EilenbergMoore
import Categories.Adjoint.Construction.Kleisli
import Categories.Adjoint.Equivalence
import Categories.Adjoint.Instance.0-Truncation
import Categories.Adjoint.Instance.01-Truncation
import Categories.Adjoint.Instance.Core
import Categories.Adjoint.Instance.Discrete
import Categories.Adjoint.Instance.PosetCore
import Categories.Adjoint.Instance.StrictCore
import Categories.Adjoint.Mate
import Categories.Adjoint.Properties
import Categories.Adjoint.RAPL
import Categories.Bicategory
import Categories.Bicategory.Bigroupoid
import Categories.Bicategory.Construction.1-Category
import Categories.Bicategory.Instance.Cats
import Categories.Bicategory.Instance.EnrichedCats
import Categories.Category
import Categories.Category.BicartesianClosed
import Categories.Category.Cartesian
import Categories.Category.Cartesian.Properties
import Categories.Category.CartesianClosed
import Categories.Category.CartesianClosed.Canonical
import Categories.Category.CartesianClosed.Locally
import Categories.Category.CartesianClosed.Locally.Properties
import Categories.Category.Closed
import Categories.Category.Cocartesian
import Categories.Category.Cocomplete
import Categories.Category.Cocomplete.Finitely
import Categories.Category.Complete
import Categories.Category.Complete.Finitely
import Categories.Category.Construction.0-Groupoid
import Categories.Category.Construction.Arrow
import Categories.Category.Construction.Cocones
import Categories.Category.Construction.Comma
import Categories.Category.Construction.Cones
import Categories.Category.Construction.Coproduct
import Categories.Category.Construction.Core
import Categories.Category.Construction.EilenbergMoore
import Categories.Category.Construction.Elements
import Categories.Category.Construction.EnrichedFunctors
import Categories.Category.Construction.F-Algebras
import Categories.Category.Construction.Fin
import Categories.Category.Construction.Functors
import Categories.Category.Construction.Graphs
import Categories.Category.Construction.Grothendieck
import Categories.Category.Construction.Kleisli
import Categories.Category.Construction.Path
import Categories.Category.Construction.Presheaves
import Categories.Category.Construction.Properties.Comma
import Categories.Category.Construction.Pullbacks
import Categories.Category.Construction.Thin
import Categories.Category.Core
import Categories.Category.Discrete
import Categories.Category.Equivalence
import Categories.Category.Finite
import Categories.Category.Groupoid
import Categories.Category.Groupoid.Properties
import Categories.Category.Indiscrete
import Categories.Category.Instance.Cats
import Categories.Category.Instance.EmptySet
import Categories.Category.Instance.FamilyOfSets
import Categories.Category.Instance.Globe
import Categories.Category.Instance.Groupoids
import Categories.Category.Instance.One
import Categories.Category.Instance.PointedSets
import Categories.Category.Instance.Posets
import Categories.Category.Instance.Properties.Cats
import Categories.Category.Instance.Properties.Posets
import Categories.Category.Instance.Properties.Setoids
import Categories.Category.Instance.Setoids
import Categories.Category.Instance.Sets
import Categories.Category.Instance.Simplex
import Categories.Category.Instance.SimplicialSet
import Categories.Category.Instance.SingletonSet
import Categories.Category.Instance.Span
import Categories.Category.Instance.StrictCats
import Categories.Category.Instance.StrictGroupoids
import Categories.Category.Instance.Zero
import Categories.Category.Monoidal
import Categories.Category.Monoidal.Braided
import Categories.Category.Monoidal.Braided.Properties
import Categories.Category.Monoidal.Closed
import Categories.Category.Monoidal.Closed.IsClosed
import Categories.Category.Monoidal.Closed.IsClosed.Diagonal
import Categories.Category.Monoidal.Closed.IsClosed.Dinatural
import Categories.Category.Monoidal.Closed.IsClosed.Identity
import Categories.Category.Monoidal.Closed.IsClosed.L
import Categories.Category.Monoidal.Closed.IsClosed.Pentagon
import Categories.Category.Monoidal.Construction.Minus2
import Categories.Category.Monoidal.Core
import Categories.Category.Monoidal.Instance.Cats
import Categories.Category.Monoidal.Instance.One
import Categories.Category.Monoidal.Instance.Setoids
import Categories.Category.Monoidal.Instance.Sets
import Categories.Category.Monoidal.Instance.StrictCats
import Categories.Category.Monoidal.Properties
import Categories.Category.Monoidal.Reasoning
import Categories.Category.Monoidal.Symmetric
import Categories.Category.Monoidal.Traced
import Categories.Category.Monoidal.Utilities
import Categories.Category.Product
import Categories.Category.Product.Properties
import Categories.Category.RigCategory
import Categories.Category.SetoidDiscrete
import Categories.Category.Site
import Categories.Category.Slice
import Categories.Category.Slice.Properties
import Categories.Category.SubCategory
import Categories.Category.Topos
import Categories.Category.WithFamilies
import Categories.Comonad
import Categories.Diagram.Cocone
import Categories.Diagram.Cocone.Properties
import Categories.Diagram.Coend
import Categories.Diagram.Coequalizer
import Categories.Diagram.Coequalizer.Properties
import Categories.Diagram.Colimit
import Categories.Diagram.Colimit.DualProperties
import Categories.Diagram.Colimit.Lan
import Categories.Diagram.Colimit.Properties
import Categories.Diagram.Cone
import Categories.Diagram.Cone.Properties
import Categories.Diagram.Duality
import Categories.Diagram.End
import Categories.Diagram.End.Properties
import Categories.Diagram.Equalizer
import Categories.Diagram.Finite
import Categories.Diagram.Limit
import Categories.Diagram.Limit.Properties
import Categories.Diagram.Limit.Ran
import Categories.Diagram.Pullback
import Categories.Diagram.Pullback.Limit
import Categories.Diagram.Pullback.Properties
import Categories.Diagram.Pushout
import Categories.Diagram.Pushout.Properties
import Categories.Diagram.SubobjectClassifier
import Categories.Enriched.Category
import Categories.Enriched.Functor
import Categories.Enriched.NaturalTransformation
import Categories.Enriched.NaturalTransformation.NaturalIsomorphism
import Categories.Enriched.Over.One
import Categories.Functor
import Categories.Functor.Algebra
import Categories.Functor.Bifunctor
import Categories.Functor.Bifunctor.Properties
import Categories.Functor.Coalgebra
import Categories.Functor.Cocontinuous
import Categories.Functor.Construction.Constant
import Categories.Functor.Construction.Diagonal
import Categories.Functor.Construction.LiftSetoids
import Categories.Functor.Construction.Limit
import Categories.Functor.Construction.Zero
import Categories.Functor.Continuous
import Categories.Functor.Core
import Categories.Functor.Equivalence
import Categories.Functor.Fibration
import Categories.Functor.Groupoid
import Categories.Functor.Hom
import Categories.Functor.Instance.0-Truncation
import Categories.Functor.Instance.01-Truncation
import Categories.Functor.Instance.Core
import Categories.Functor.Instance.Discrete
import Categories.Functor.Instance.SetoidDiscrete
import Categories.Functor.Instance.StrictCore
import Categories.Functor.Monoidal
import Categories.Functor.Power
import Categories.Functor.Power.Functorial
import Categories.Functor.Power.NaturalTransformation
import Categories.Functor.Presheaf
import Categories.Functor.Profunctor
import Categories.Functor.Properties
import Categories.Functor.Representable
import Categories.Functor.Slice
import Categories.GlobularSet
import Categories.Kan
import Categories.Kan.Duality
import Categories.Minus2-Category
import Categories.Minus2-Category.Construction.Indiscrete
import Categories.Minus2-Category.Instance.One
import Categories.Minus2-Category.Properties
import Categories.Monad
import Categories.Monad.Duality
import Categories.Monad.Idempotent
import Categories.Monad.Strong
import Categories.Morphism
import Categories.Morphism.Cartesian
import Categories.Morphism.Duality
import Categories.Morphism.HeterogeneousIdentity
import Categories.Morphism.HeterogeneousIdentity.Properties
import Categories.Morphism.IsoEquiv
import Categories.Morphism.Isomorphism
import Categories.Morphism.Properties
import Categories.Morphism.Reasoning
import Categories.Morphism.Reasoning.Core
import Categories.Morphism.Reasoning.Iso
import Categories.Morphism.Universal
import Categories.NaturalTransformation
import Categories.NaturalTransformation.Core
import Categories.NaturalTransformation.Dinatural
import Categories.NaturalTransformation.Equivalence
import Categories.NaturalTransformation.Hom
import Categories.NaturalTransformation.NaturalIsomorphism
import Categories.NaturalTransformation.NaturalIsomorphism.Equivalence
import Categories.NaturalTransformation.NaturalIsomorphism.Functors
import Categories.NaturalTransformation.NaturalIsomorphism.Properties
import Categories.NaturalTransformation.Properties
import Categories.Object.Coproduct
import Categories.Object.Duality
import Categories.Object.Exponential
import Categories.Object.Initial
import Categories.Object.Product
import Categories.Object.Product.Construction
import Categories.Object.Product.Core
import Categories.Object.Product.Morphisms
import Categories.Object.Terminal
import Categories.Object.Zero
import Categories.Pseudofunctor
import Categories.Pseudofunctor.Instance.EnrichedUnderlying
import Categories.Utils.EqReasoning
import Categories.Utils.Product
import Categories.Yoneda
import Categories.Yoneda.Properties
import Relation.Binary.Construct.Symmetrize
| 42.416667
| 70
| 0.891221
|
50351e5e07be3e3c974411ecb99e04981e23ad17
| 2,779
|
agda
|
Agda
|
test/Succeed/Issue3889.agda
|
favonia/agda
|
8d433b967567c08afe15d04a5cb63b6f6d8884ee
|
[
"BSD-2-Clause"
] | null | null | null |
test/Succeed/Issue3889.agda
|
favonia/agda
|
8d433b967567c08afe15d04a5cb63b6f6d8884ee
|
[
"BSD-2-Clause"
] | 6
|
2021-10-18T08:12:24.000Z
|
2021-11-24T08:31:10.000Z
|
test/Succeed/Issue3889.agda
|
antoinevanmuylder/agda
|
bd59d5b07ffe02a43b28d186d95e1747aac5bc8c
|
[
"BSD-2-Clause"
] | null | null | null |
-- Andreas, 2019-07-05, during work on issue #3889
-- Test-case for with extracted from the standard library
{-# OPTIONS --cubical-compatible #-}
open import Agda.Primitive
open import Agda.Builtin.Equality
open import Agda.Builtin.List
open import Common.Equality
open import Common.Product
data Any {a}{A : Set a} {p} (P : A → Set p) : List A → Set (a ⊔ p) where
here : ∀ {x xs} (px : P x) → Any P (x ∷ xs)
there : ∀ {x xs} (pxs : Any P xs) → Any P (x ∷ xs)
_∈_ : ∀{a}{A : Set a} → A → List A → Set _
x ∈ xs = Any (x ≡_) xs
map : ∀ {a} {A : Set a} {p q} {P : A → Set p} {Q : A → Set q} → (∀{x} → P x → Q x) → ∀{xs} → Any P xs → Any Q xs
map g (here px) = here (g px)
map g (there pxs) = there (map g pxs)
map₁ : ∀ {a b c} {A : Set a} {B : Set b} {C : Set c} →
(A → B) → A × C → B × C
map₁ f (x , y)= f x , y
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 (x , y) = (x , f y)
find : ∀ {a} {p} {A : Set a} {P : A → Set p} {xs} → Any P xs → Σ _ λ x → x ∈ xs × P x
find (here px) = (_ , here refl , px)
find (there pxs) = map₂ (map₁ there) (find pxs)
lose : ∀ {a} {p} {A : Set a} {P : A → Set p} {x xs} → x ∈ xs → P x → Any P xs
lose x∈xs px = map (λ eq → subst _ eq px) x∈xs
map∘find : ∀ {a p} {A : Set a} {P : A → Set p} {xs}
(p : Any P xs) → let p′ = find p in
{f : ∀{x} → proj₁ p′ ≡ x → P x} →
f refl ≡ proj₂ (proj₂ p′) →
map f (proj₁ (proj₂ p′)) ≡ p
map∘find (here p) hyp = cong here hyp
map∘find (there p) hyp = cong there (map∘find p hyp)
find∘map : ∀ {a p q} {A : Set a} {P : A → Set p} {Q : A → Set q}
{xs : List A} (p : Any P xs) (f : ∀{x} → P x → Q x) →
find (map f p) ≡ map₂ (map₂ f) (find p)
find∘map (here p) f = refl
find∘map (there p) f rewrite find∘map p f = refl
lose∘find : ∀ {a p} {A : Set a} {P : A → Set p} {xs : List A}
(p : Any P xs) →
(let (y , z) = proj₂ (find p)) →
lose y z ≡ p
lose∘find p = map∘find p refl
postulate
a b ℓ : Level
A : Set a
B : Set b
P : A → Set ℓ
Q : B → Set ℓ -- Level needed
Any-×⁺ : ∀ {xs ys} → Any P xs × Any Q ys →
Any (λ x → Any (λ y → P x × Q y) ys) xs
Any-×⁺ (p , q) = map (λ p → map (λ q → (p , q)) q) p
Any-×⁻ : ∀ {xs ys} → Any (λ x → Any (λ y → P x × Q y) ys) xs →
Any P xs × Any Q ys
Any-×⁻ pq with map₂ (map₂ find) (find pq)
... | (x , x∈xs , y , y∈ys , p , q) = (lose x∈xs p , lose y∈ys q)
module _ where
from∘to : ∀{xs ys} (pq : Any P xs × Any Q ys) → Any-×⁻ (Any-×⁺ pq) ≡ pq
-- from∘to (p , q) = {!!}
from∘to (p , q) rewrite
find∘map p (λ p → map (λ q → (p , q)) q)
| find∘map q (λ q → proj₂ (proj₂ (find p)) , q)
| lose∘find p
| lose∘find q
= refl
| 33.083333
| 112
| 0.475711
|
39414f23c878d0735f114992c534ef0d74f5a1f4
| 3,917
|
agda
|
Agda
|
complete-elaboration.agda
|
hazelgrove/hazel-palette-agda
|
c3225acc3c94c56376c6842b82b8b5d76912df2a
|
[
"MIT"
] | 4
|
2020-10-04T06:45:06.000Z
|
2021-12-19T15:38:31.000Z
|
complete-elaboration.agda
|
hazelgrove/hazel-palette-agda
|
c3225acc3c94c56376c6842b82b8b5d76912df2a
|
[
"MIT"
] | 9
|
2020-09-30T20:27:56.000Z
|
2020-10-20T20:44:13.000Z
|
complete-elaboration.agda
|
hazelgrove/hazelnut-livelits-agda
|
c3225acc3c94c56376c6842b82b8b5d76912df2a
|
[
"MIT"
] | null | null | null |
open import Nat
open import Prelude
open import core
open import contexts
open import typed-elaboration
open import lemmas-gcomplete
open import lemmas-complete
module complete-elaboration where
mutual
complete-elaboration-synth : ∀{e τ Γ Δ d} →
Γ gcomplete →
e ecomplete →
Γ ⊢ e ⇒ τ ~> d ⊣ Δ →
(d dcomplete × τ tcomplete × Δ == ∅)
complete-elaboration-synth gc ec ESConst = DCConst , TCBase , refl
complete-elaboration-synth gc ec (ESVar x₁) = DCVar , gc _ _ x₁ , refl
complete-elaboration-synth gc (ECLam2 ec x₁) (ESLam x₂ exp)
with complete-elaboration-synth (gcomp-extend gc x₁ x₂) ec exp
... | ih1 , ih2 , ih3 = DCLam ih1 x₁ , TCArr x₁ ih2 , ih3
complete-elaboration-synth gc (ECAp ec ec₁) (ESAp _ _ x MAHole x₂ x₃)
with comp-synth gc ec x
... | ()
complete-elaboration-synth gc (ECAp ec ec₁) (ESAp {Δ1 = Δ1} {Δ2 = Δ2} _ _ x MAArr x₂ x₃)
with comp-synth gc ec x
... | TCArr t1 t2
with complete-elaboration-ana gc ec (TCArr t1 t2) x₂ | complete-elaboration-ana gc ec₁ t1 x₃
... | ih1 , _ , ih4 | ih2 , _ , ih3 = DCAp (DCCast ih1 (comp-ana gc x₂ ih1) (TCArr t1 t2)) (DCCast ih2 (comp-ana gc x₃ ih2) t1) ,
t2 ,
tr (λ qq → (qq ∪ Δ2) == ∅) (! ih4) (tr (λ qq → (∅ ∪ qq) == ∅) (! ih3) refl)
complete-elaboration-synth gc () ESEHole
complete-elaboration-synth gc () (ESNEHole _ exp)
complete-elaboration-synth gc (ECAsc x ec) (ESAsc x₁)
with complete-elaboration-ana gc ec x x₁
... | ih1 , _ , ih2 = DCCast ih1 (comp-ana gc x₁ ih1) x , x , ih2
complete-elaboration-synth gc (ECFst ec) (ESFst x x₁ x₂)
with comp-synth gc ec x
complete-elaboration-synth gc (ECFst ec) (ESFst x () x₂) | TCBase
complete-elaboration-synth gc (ECFst ec) (ESFst x () x₂) | TCArr _ _
complete-elaboration-synth gc (ECFst ec) (ESFst x MPProd x₂) | tc with complete-elaboration-ana gc ec tc x₂
complete-elaboration-synth gc (ECFst ec) (ESFst x MPProd x₂) | tc | ih1 , ih2 , ih3 = DCFst (DCCast ih1 ih2 tc) , lem-comp-prod1 tc , ih3
complete-elaboration-synth gc (ECSnd ec) (ESSnd x x₁ x₂)
with comp-synth gc ec x
complete-elaboration-synth gc (ECSnd ec) (ESSnd x () x₂) | TCBase
complete-elaboration-synth gc (ECSnd ec) (ESSnd x () x₂) | TCArr _ _
complete-elaboration-synth gc (ECSnd ec) (ESSnd x MPProd x₂) | tc with complete-elaboration-ana gc ec tc x₂
complete-elaboration-synth gc (ECSnd ec) (ESSnd x MPProd x₂) | tc | ih1 , ih2 , ih3 = DCSnd (DCCast ih1 ih2 tc) , lem-comp-prod2 tc , ih3
complete-elaboration-synth gc (ECPair ec1 ec2) (ESPair _ _ es1 es2)
with complete-elaboration-synth gc ec1 es1 | complete-elaboration-synth gc ec2 es2
... | dc1 , tc1 , refl | dc2 , tc2 , refl = DCPair dc1 dc2 , TCProd tc1 tc2 , refl
complete-elaboration-ana : ∀{e τ τ' Γ Δ d} →
Γ gcomplete →
e ecomplete →
τ tcomplete →
Γ ⊢ e ⇐ τ ~> d :: τ' ⊣ Δ →
(d dcomplete × τ' tcomplete × Δ == ∅)
complete-elaboration-ana gc (ECLam1 ec) () (EALam x₁ MAHole exp)
complete-elaboration-ana gc (ECLam1 ec) (TCArr t1 t2) (EALam x₁ MAArr exp)
with complete-elaboration-ana (gcomp-extend gc t1 x₁) ec t2 exp
... | ih , ih3 , ih2 = DCLam ih t1 , TCArr t1 ih3 , ih2
complete-elaboration-ana gc ec tc (EASubsume x x₁ x₂ x₃) = complete-elaboration-synth gc ec x₂
-- this is just a convenience since it shows up a few times above
comp-ana : ∀{Γ e τ d τ' Δ} →
Γ gcomplete →
Γ ⊢ e ⇐ τ ~> d :: τ' ⊣ Δ →
d dcomplete →
τ' tcomplete
comp-ana gc ex dc = complete-ta gc (π2 (typed-elaboration-ana ex)) dc
| 55.169014
| 141
| 0.591014
|
1d85d66dfac15f9f6f4b08dae5a3c670b87e3868
| 971
|
agda
|
Agda
|
src/API/Theorems.agda
|
algebraic-graphs/alga-theory
|
0fdb96c0233d9be83eba637f0434d0fd22aefb1d
|
[
"MIT"
] | 60
|
2017-12-27T14:57:04.000Z
|
2022-03-22T23:05:29.000Z
|
src/API/Theorems.agda
|
algebraic-graphs/alga-theory
|
0fdb96c0233d9be83eba637f0434d0fd22aefb1d
|
[
"MIT"
] | 3
|
2018-04-12T16:25:13.000Z
|
2018-06-23T13:54:02.000Z
|
src/API/Theorems.agda
|
algebraic-graphs/alga-theory
|
0fdb96c0233d9be83eba637f0434d0fd22aefb1d
|
[
"MIT"
] | 6
|
2017-12-17T20:48:20.000Z
|
2019-05-09T23:53:28.000Z
|
module API.Theorems where
open import Algebra.Graph
open import Algebra.Graph.Theorems
open import Algebra.Graph.Reasoning
open import API
open import Prelude
-- vertices [x] == vertex x
vertices-vertex : ∀ {A} {x : A} -> vertices [ x ] ≡ vertex x
vertices-vertex = +identity >> reflexivity
-- edge x y == clique [x, y]
edge-clique : ∀ {A} {x y : A} -> edge x y ≡ clique (x :: [ y ])
edge-clique = symmetry (R *right-identity)
-- vertices xs ⊆ clique xs
vertices-clique : ∀ {A} {xs : List A} -> vertices xs ⊆ clique xs
vertices-clique {_} {[]} = ⊆reflexivity
vertices-clique {a} {_ :: t} = ⊆transitivity (⊆right-monotony (vertices-clique {a} {t})) ⊆connect
-- clique (xs ++ ys) == connect (clique xs) (clique ys)
connect-clique : ∀ {A} {xs ys : List A} -> clique (xs ++ ys) ≡ connect (clique xs) (clique ys)
connect-clique {_} {[]} = symmetry *left-identity
connect-clique {a} {_ :: t} = R (connect-clique {a} {t}) >> *associativity
| 37.346154
| 98
| 0.626159
|
cb379832565deac837c97cf191402c20caeca16c
| 6,290
|
agda
|
Agda
|
src/Categories/Category/Equivalence/Properties.agda
|
jaykru/agda-categories
|
a4053cf700bcefdf73b857c3352f1eae29382a60
|
[
"MIT"
] | 279
|
2019-06-01T14:36:40.000Z
|
2022-03-22T00:40:14.000Z
|
src/Categories/Category/Equivalence/Properties.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 236
|
2019-06-01T14:53:54.000Z
|
2022-03-28T14:31:43.000Z
|
src/Categories/Category/Equivalence/Properties.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 64
|
2019-06-02T16:58:15.000Z
|
2022-03-14T02:00:59.000Z
|
{-# OPTIONS --without-K --safe #-}
-- A Categorical WeakInverse induces an Adjoint Equivalence
module Categories.Category.Equivalence.Properties where
open import Level
open import Data.Product using (Σ-syntax; _,_; proj₁)
open import Categories.Adjoint.Equivalence using (⊣Equivalence)
open import Categories.Adjoint
open import Categories.Adjoint.TwoSided using (_⊣⊢_; withZig)
open import Categories.Category
open import Categories.Category.Equivalence using (WeakInverse; StrongEquivalence)
open import Categories.Morphism
import Categories.Morphism.Reasoning as MR
import Categories.Morphism.Properties as MP
open import Categories.Functor renaming (id to idF)
open import Categories.Functor.Properties using ([_]-resp-Iso)
open import Categories.NaturalTransformation using (ntHelper; _∘ᵥ_; _∘ˡ_; _∘ʳ_)
open import Categories.NaturalTransformation.NaturalIsomorphism as ≃
using (NaturalIsomorphism ; unitorˡ; unitorʳ; associator; _ⓘᵥ_; _ⓘˡ_; _ⓘʳ_)
open import Categories.NaturalTransformation.NaturalIsomorphism.Properties using (pointwise-iso)
private
variable
o ℓ e : Level
C D E : Category o ℓ e
module _ {F : Functor C D} {G : Functor D C} (W : WeakInverse F G) where
open WeakInverse W
private
module C = Category C
module D = Category D
module F = Functor F
module G = Functor G
-- adjoint equivalence
F⊣⊢G : F ⊣⊢ G
F⊣⊢G = withZig record
{ unit = ≃.sym G∘F≈id
; counit =
let open D
open HomReasoning
open MR D
open MP D
in record
{ F⇒G = ntHelper record
{ η = λ X → F∘G≈id.⇒.η X ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ X)) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X))
; commute = λ {X Y} f → begin
(F∘G≈id.⇒.η Y ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ Y)) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ Y))) ∘ F.F₁ (G.F₁ f)
≈⟨ pull-last (F∘G≈id.⇐.commute (F.F₁ (G.F₁ f))) ⟩
F∘G≈id.⇒.η Y ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ Y)) ∘ (F.F₁ (G.F₁ (F.F₁ (G.F₁ f))) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X)))
≈˘⟨ refl⟩∘⟨ pushˡ F.homomorphism ⟩
F∘G≈id.⇒.η Y ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ Y) C.∘ G.F₁ (F.F₁ (G.F₁ f))) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X))
≈⟨ refl⟩∘⟨ F.F-resp-≈ (G∘F≈id.⇒.commute (G.F₁ f)) ⟩∘⟨refl ⟩
F∘G≈id.⇒.η Y ∘ F.F₁ (G.F₁ f C.∘ G∘F≈id.⇒.η (G.F₀ X)) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X))
≈⟨ refl⟩∘⟨ F.homomorphism ⟩∘⟨refl ⟩
F∘G≈id.⇒.η Y ∘ (F.F₁ (G.F₁ f) ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ X))) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X))
≈⟨ center⁻¹ (F∘G≈id.⇒.commute f) Equiv.refl ⟩
(f ∘ F∘G≈id.⇒.η X) ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ X)) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X))
≈⟨ assoc ⟩
f ∘ F∘G≈id.⇒.η X ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ X)) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ X))
∎
}
; F⇐G = ntHelper record
{ η = λ X → (F∘G≈id.⇒.η (F.F₀ (G.F₀ X)) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ X))) ∘ F∘G≈id.⇐.η X
; commute = λ {X Y} f → begin
((F∘G≈id.⇒.η (F.F₀ (G.F₀ Y)) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ Y))) ∘ F∘G≈id.⇐.η Y) ∘ f
≈⟨ pullʳ (F∘G≈id.⇐.commute f) ⟩
(F∘G≈id.⇒.η (F.F₀ (G.F₀ Y)) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ Y))) ∘ F.F₁ (G.F₁ f) ∘ F∘G≈id.⇐.η X
≈⟨ center (⟺ F.homomorphism) ⟩
F∘G≈id.⇒.η (F.F₀ (G.F₀ Y)) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ Y) C.∘ G.F₁ f) ∘ F∘G≈id.⇐.η X
≈⟨ refl⟩∘⟨ F.F-resp-≈ (G∘F≈id.⇐.commute (G.F₁ f)) ⟩∘⟨refl ⟩
F∘G≈id.⇒.η (F.F₀ (G.F₀ Y)) ∘ F.F₁ (G.F₁ (F.F₁ (G.F₁ f)) C.∘ G∘F≈id.⇐.η (G.F₀ X)) ∘ F∘G≈id.⇐.η X
≈⟨ refl⟩∘⟨ F.homomorphism ⟩∘⟨refl ⟩
F∘G≈id.⇒.η (F.F₀ (G.F₀ Y)) ∘ (F.F₁ (G.F₁ (F.F₁ (G.F₁ f))) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ X))) ∘ F∘G≈id.⇐.η X
≈⟨ center⁻¹ (F∘G≈id.⇒.commute _) Equiv.refl ⟩
(F.F₁ (G.F₁ f) ∘ F∘G≈id.⇒.η (F.F₀ (G.F₀ X))) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ X)) ∘ F∘G≈id.⇐.η X
≈⟨ center Equiv.refl ⟩
F.F₁ (G.F₁ f) ∘ (F∘G≈id.⇒.η (F.F₀ (G.F₀ X)) ∘ F.F₁ (G∘F≈id.⇐.η (G.F₀ X))) ∘ F∘G≈id.⇐.η X
∎
}
; iso = λ X → Iso-∘ (Iso-∘ (Iso-swap (F∘G≈id.iso _)) ([ F ]-resp-Iso (G∘F≈id.iso _)))
(F∘G≈id.iso X)
}
; zig = λ {A} →
let open D
open HomReasoning
open MR D
in begin
(F∘G≈id.⇒.η (F.F₀ A) ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ (F.F₀ A))) ∘ F∘G≈id.⇐.η (F.F₀ (G.F₀ (F.F₀ A))))
∘ F.F₁ (G∘F≈id.⇐.η A)
≈⟨ pull-last (F∘G≈id.⇐.commute (F.F₁ (G∘F≈id.⇐.η A))) ⟩
F∘G≈id.⇒.η (F.F₀ A) ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ (F.F₀ A))) ∘
F.F₁ (G.F₁ (F.F₁ (G∘F≈id.⇐.η A))) ∘ F∘G≈id.⇐.η (F.F₀ A)
≈˘⟨ refl⟩∘⟨ pushˡ F.homomorphism ⟩
F∘G≈id.⇒.η (F.F₀ A) ∘ F.F₁ (G∘F≈id.⇒.η (G.F₀ (F.F₀ A)) C.∘ G.F₁ (F.F₁ (G∘F≈id.⇐.η A))) ∘ F∘G≈id.⇐.η (F.F₀ A)
≈⟨ refl⟩∘⟨ F.F-resp-≈ (G∘F≈id.⇒.commute (G∘F≈id.⇐.η A)) ⟩∘⟨refl ⟩
F∘G≈id.⇒.η (F.F₀ A) ∘ F.F₁ (G∘F≈id.⇐.η A C.∘ G∘F≈id.⇒.η A) ∘ F∘G≈id.⇐.η (F.F₀ A)
≈⟨ refl⟩∘⟨ elimˡ ((F.F-resp-≈ (G∘F≈id.iso.isoˡ _)) ○ F.identity) ⟩
F∘G≈id.⇒.η (F.F₀ A) ∘ F∘G≈id.⇐.η (F.F₀ A)
≈⟨ F∘G≈id.iso.isoʳ _ ⟩
id
∎
}
module F⊣⊢G = _⊣⊢_ F⊣⊢G
module _ {o ℓ e o′ ℓ′ e′} {C : Category o ℓ e} {D : Category o′ ℓ′ e′} (SE : StrongEquivalence C D) where
open StrongEquivalence SE
C≅D : ⊣Equivalence C D
C≅D = record
{ L = F
; R = G
; L⊣⊢R = F⊣⊢G weak-inverse
}
module C≅D = ⊣Equivalence C≅D
module _ {F : Functor C D} {G : Functor D C} (F⊣G : F ⊣ G) where
private
module C = Category C
module D = Category D
module F = Functor F
module G = Functor G
open Adjoint F⊣G
-- If the unit and the counit of an adjuction are pointwise isomorphisms, then they form an equivalence of categories.
pointwise-iso-equivalence : (∀ X → Σ[ f ∈ D [ X , F.F₀ (G.F₀ X) ] ] Iso D (counit.η X) f) → (∀ X → Σ[ f ∈ C [ G.F₀ (F.F₀ X) , X ] ] Iso C (unit.η X) f) → WeakInverse F G
pointwise-iso-equivalence counit-iso unit-iso = record
{ F∘G≈id =
let iso X =
let (to , is-iso) = counit-iso X
in record { from = counit.η X ; to = to ; iso = is-iso }
in pointwise-iso iso counit.commute
; G∘F≈id =
let iso X =
let (to , is-iso) = unit-iso X
in record { from = unit.η X ; to = to ; iso = is-iso }
in ≃.sym (pointwise-iso iso unit.commute)
}
| 42.789116
| 172
| 0.499682
|
a1c09b122b71b3dda7a04be6ded3b367e6ccb894
| 2,609
|
agda
|
Agda
|
src/Web/Semantic/DL/TBox/Model.agda
|
agda/agda-web-semantic
|
8ddbe83965a616bff6fc7a237191fa261fa78bab
|
[
"MIT"
] | 9
|
2015-09-13T17:46:41.000Z
|
2020-03-14T14:21:08.000Z
|
src/Web/Semantic/DL/TBox/Model.agda
|
bblfish/agda-web-semantic
|
38fbc3af7062ba5c3d7d289b2b4bcfb995d99057
|
[
"MIT"
] | 4
|
2018-11-14T02:32:28.000Z
|
2021-01-04T20:57:19.000Z
|
src/Web/Semantic/DL/TBox/Model.agda
|
bblfish/agda-web-semantic
|
38fbc3af7062ba5c3d7d289b2b4bcfb995d99057
|
[
"MIT"
] | 3
|
2017-12-03T14:52:09.000Z
|
2022-03-12T11:40:03.000Z
|
open import Data.Product using ( _×_ ; _,_ )
open import Data.Sum using ( inj₁ ; inj₂ )
open import Relation.Binary.PropositionalEquality using ( refl )
open import Relation.Unary using ( _∈_ ; _∉_ ; _⊆_ )
open import Web.Semantic.DL.Concept.Model using
( _⟦_⟧₁ ; ⟦⟧₁-resp-≈ ; ⟦⟧₁-resp-≃; ⟦⟧₁-refl-≃ )
open import Web.Semantic.DL.Role.Model using
( _⟦_⟧₂ ; ⟦⟧₂-resp-≈ ; ⟦⟧₂-resp-≃ ; ⟦⟧₂-refl-≃ )
open import Web.Semantic.DL.Signature using ( Signature )
open import Web.Semantic.DL.TBox using
( TBox ; Axioms ; ε ; _,_ ;_⊑₁_ ; _⊑₂_ ; Dis ; Ref ; Irr ; Tra )
open import Web.Semantic.DL.TBox.Interp using ( Interp )
open import Web.Semantic.DL.TBox.Interp.Morphism using ( _≃_ ; ≃-sym )
open import Web.Semantic.Util using ( True ; tt ; _∘_ )
module Web.Semantic.DL.TBox.Model {Σ : Signature} where
infixr 2 _⊨t_
_⊨t_ : Interp Σ → TBox Σ → Set
I ⊨t ε = True
I ⊨t (T , U) = (I ⊨t T) × (I ⊨t U)
I ⊨t (C ⊑₁ D) = I ⟦ C ⟧₁ ⊆ I ⟦ D ⟧₁
I ⊨t (Q ⊑₂ R) = I ⟦ Q ⟧₂ ⊆ I ⟦ R ⟧₂
I ⊨t (Dis Q R) = ∀ {xy} → (xy ∈ I ⟦ Q ⟧₂) → (xy ∉ I ⟦ R ⟧₂)
I ⊨t (Ref R) = ∀ x → ((x , x) ∈ I ⟦ R ⟧₂)
I ⊨t (Irr R) = ∀ x → ((x , x) ∉ I ⟦ R ⟧₂)
I ⊨t (Tra R) = ∀ {x y z} →
((x , y) ∈ I ⟦ R ⟧₂) → ((y , z) ∈ I ⟦ R ⟧₂) → ((x , z) ∈ I ⟦ R ⟧₂)
Axioms✓ : ∀ I T {t} → (t ∈ Axioms T) → (I ⊨t T) → (I ⊨t t)
Axioms✓ I ε () I⊨T
Axioms✓ I (T , U) (inj₁ t∈T) (I⊨T , I⊨U) = Axioms✓ I T t∈T I⊨T
Axioms✓ I (T , U) (inj₂ t∈U) (I⊨T , I⊨U) = Axioms✓ I U t∈U I⊨U
Axioms✓ I (C ⊑₁ D) refl I⊨T = I⊨T
Axioms✓ I (Q ⊑₂ R) refl I⊨T = I⊨T
Axioms✓ I (Dis Q R) refl I⊨T = I⊨T
Axioms✓ I (Ref R) refl I⊨T = I⊨T
Axioms✓ I (Irr R) refl I⊨T = I⊨T
Axioms✓ I (Tra R) refl I⊨T = I⊨T
⊨t-resp-≃ : ∀ {I J : Interp Σ} → (I ≃ J) → ∀ T → (I ⊨t T) → (J ⊨t T)
⊨t-resp-≃ {I} {J} I≃J ε _ =
tt
⊨t-resp-≃ {I} {J} I≃J (T , U) (I⊨T , I⊨U) =
(⊨t-resp-≃ I≃J T I⊨T , ⊨t-resp-≃ I≃J U I⊨U)
⊨t-resp-≃ {I} {J} I≃J (C ⊑₁ D) I⊨C⊑D =
⟦⟧₁-refl-≃ I≃J D ∘ I⊨C⊑D ∘ ⟦⟧₁-resp-≃ (≃-sym I≃J) C
⊨t-resp-≃ {I} {J} I≃J (Q ⊑₂ R) I⊨Q⊑R = ⟦⟧₂-refl-≃ I≃J R ∘ I⊨Q⊑R ∘
⟦⟧₂-resp-≃ (≃-sym I≃J) Q
⊨t-resp-≃ {I} {J} I≃J (Dis Q R) I⊨DisQR = λ xy∈⟦Q⟧ xy∈⟦R⟧ →
I⊨DisQR (⟦⟧₂-resp-≃ (≃-sym I≃J) Q xy∈⟦Q⟧) (⟦⟧₂-resp-≃ (≃-sym I≃J) R xy∈⟦R⟧)
⊨t-resp-≃ {I} {J} I≃J (Ref R) I⊨RefR = λ x → ⟦⟧₂-refl-≃ I≃J R (I⊨RefR _)
⊨t-resp-≃ {I} {J} I≃J (Irr R) I⊨IrrR = λ x xx∈⟦R⟧ →
I⊨IrrR _ (⟦⟧₂-resp-≃ (≃-sym I≃J) R xx∈⟦R⟧)
⊨t-resp-≃ {I} {J} I≃J (Tra R) I⊨TraR = λ xy∈⟦R⟧ yz∈⟦R⟧ →
⟦⟧₂-refl-≃ I≃J R (I⊨TraR
(⟦⟧₂-resp-≃ (≃-sym I≃J) R xy∈⟦R⟧)
(⟦⟧₂-resp-≃ (≃-sym I≃J) R yz∈⟦R⟧))
| 43.483333
| 77
| 0.474128
|
0ba2690dcc8d6b793a16dc58b7c7f3b00d68a194
| 705
|
agda
|
Agda
|
test/succeed/Issue860.agda
|
larrytheliquid/agda
|
477c8c37f948e6038b773409358fd8f38395f827
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
test/succeed/Issue860.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | null | null | null |
test/succeed/Issue860.agda
|
masondesu/agda
|
70c8a575c46f6a568c7518150a1a64fcd03aa437
|
[
"MIT"
] | 1
|
2022-03-12T11:35:18.000Z
|
2022-03-12T11:35:18.000Z
|
open import Common.Prelude
pattern [_] x = x ∷ []
pattern tail {x} xs = x ∷ xs
length : ∀ {A} → List A → Nat
length [] = 0
length [ _ ] = 1
length (tail [ _ ]) = 2
length (tail (tail xs)) = 2 + length xs
data Vec (A : Set) : Nat → Set where
nil : Vec A 0
cons : ∀ n → A → Vec A n → Vec A (suc n)
pattern _∷v_ {n} x xs = cons n x xs
map : ∀ {A B n} → (A → B) → Vec A n → Vec B n
map f nil = nil
map f (x ∷v xs) = f x ∷v map f xs
data SomeVec (A : Set) : Set where
someVec : ∀ n → Vec A n → SomeVec A
pattern some {n} xs = someVec n xs
null : ∀ {A} → SomeVec A → Bool
null (some nil) = true
null (some (_ ∷v _)) = false -- check that the hidden arg can be instantiated to a dot pattern
| 22.741935
| 95
| 0.567376
|
200bba6fb29fcf7952b65d5d4a03c459cbfaa718
| 17,802
|
agda
|
Agda
|
src/Categories/Adjoint/Properties.agda
|
yourboynico/agda-categories
|
6a087c592dbe58fc4bd9d02e1be9b94a9e138aca
|
[
"MIT"
] | 279
|
2019-06-01T14:36:40.000Z
|
2022-03-22T00:40:14.000Z
|
src/Categories/Adjoint/Properties.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 236
|
2019-06-01T14:53:54.000Z
|
2022-03-28T14:31:43.000Z
|
src/Categories/Adjoint/Properties.agda
|
seanpm2001/agda-categories
|
d9e4f578b126313058d105c61707d8c8ae987fa8
|
[
"MIT"
] | 64
|
2019-06-02T16:58:15.000Z
|
2022-03-14T02:00:59.000Z
|
{-# OPTIONS --without-K --safe #-}
module Categories.Adjoint.Properties where
open import Level
open import Data.Product using (Σ; _,_; -,_; proj₂; uncurry)
open import Function.Base using (_$_)
open import Categories.Adjoint using (_⊣_; Adjoint)
open import Categories.Adjoint.Equivalents using (Hom-NI′⇒Adjoint)
open import Categories.Adjoint.RAPL using (rapl)
open import Categories.Category using (Category; _[_,_]; _[_≈_]; _[_∘_])
open import Categories.Category.Product using (_⁂_; _⁂ⁿⁱ_)
open import Categories.Category.Construction.Comma using (CommaObj; Comma⇒; _↙_)
open import Categories.Diagram.Limit using (Limit)
open import Categories.Diagram.Colimit using (Colimit)
open import Categories.Functor using (Functor; _∘F_) renaming (id to idF)
open import Categories.Functor.Hom using (Hom[_][-,-])
open import Categories.Functor.Construction.Constant using (const!)
open import Categories.Functor.Construction.LiftSetoids using (LiftSetoids)
open import Categories.Functor.Properties using ([_]-resp-square; [_]-resp-∘)
open import Categories.Functor.Limits using (Continuous; Cocontinuous)
open import Categories.Functor.Bifunctor using (Bifunctor; appʳ; appˡ)
open import Categories.Functor.Bifunctor.Properties using ([_]-decompose₁; [_]-decompose₂; [_]-commute)
open import Categories.NaturalTransformation using (NaturalTransformation; _∘ˡ_; _∘ʳ_; ntHelper)
open import Categories.NaturalTransformation.NaturalIsomorphism using (NaturalIsomorphism; _≃_; _ⓘₕ_; _ⓘˡ_; module ≃)
open import Categories.NaturalTransformation.NaturalIsomorphism.Properties using (unlift-≃)
open import Categories.Monad using (Monad)
open import Categories.Monad.Duality using (coMonad⇒Comonad)
open import Categories.Comonad using (Comonad)
open import Categories.Morphism.Universal using (UniversalMorphism)
import Categories.Yoneda.Properties as YP using (yoneda-NI)
import Categories.Diagram.Duality as Duality using (coLimit⇒Colimit; Colimit⇒coLimit)
import Categories.Morphism.Reasoning as MR using (pushʳ; pullˡ; pushˡ; elimʳ; center; center⁻¹;
elimˡ; cancelˡ; pullʳ; cancelʳ; id-comm-sym)
private
variable
o ℓ e : Level
C D E J : Category o ℓ e
-- if the left adjoint functor is a partial application of bifunctor, then it uniquely
-- determines a bifunctor compatible with the right adjoint functor.
module _ {C : Category o ℓ e}
(L : Bifunctor C E D) {R : ∀ (X : Category.Obj E) → Functor D C}
(LR : ∀ (X : Category.Obj E) → appʳ L X ⊣ R X) where
private
module C = Category C using (id; _⇒_; _≈_; _∘_; assoc; sym-assoc; ∘-resp-≈ˡ; module HomReasoning)
module D = Category D using (_∘_; id; _≈_; _⇒_; module HomReasoning; ∘-resp-≈ʳ; sym-assoc)
module E = Category E using (_⇒_; id; module Equiv; _∘_; op)
module L = Functor L using (F₁; F-resp-≈; identity)
module R X = Functor (R X) using (F₀; F₁; identity; homomorphism; F-resp-≈)
module LR X = Adjoint (LR X) using (Ladjunct; module unit; module counit; RLadjunct≈id; zag)
open C using (assoc; sym-assoc; _⇒_; _∘_; _≈_; ∘-resp-≈ˡ)
F′ : ∀ {A X B Y} f g → R.F₀ A X ⇒ R.F₀ B Y
F′ {A} {X} {B} {Y} f g = LR.Ladjunct B (LR.counit.η A Y D.∘ L.F₁ (R.F₁ A g , f))
-- R.F₁ B (LR.counit.η A Y) ∘ R.F₁ B (L.F₁ (R.F₁ A g , f)) ∘ LR.unit.η B (R.F₀ A X)
commute′ : ∀ {A B X} (f : A E.⇒ B) → LR.counit.η A X D.∘ L.F₁ (F′ f D.id , E.id) D.≈ LR.counit.η B X D.∘ L.F₁ (C.id , f)
commute′ {A} {B} {X} f = begin
LR.counit.η A X D.∘ L.F₁ (F′ f D.id , E.id) ≈⟨ LR.RLadjunct≈id A ⟩
LR.counit.η B X D.∘ L.F₁ (R.F₁ B D.id , f) ≈⟨ refl⟩∘⟨ L.F-resp-≈ (R.identity B , E.Equiv.refl) ⟩
LR.counit.η B X D.∘ L.F₁ (C.id , f) ∎
where open D.HomReasoning
open C.HomReasoning
decompose₁ : ∀ {A B X Y} {f : A E.⇒ B} {g : X D.⇒ Y} → F′ f g ≈ R.F₁ A g ∘ F′ f D.id
decompose₁ {A} {B} {X} {Y} {f} {g} = begin
F′ f g
≈⟨ R.F-resp-≈ A (D.∘-resp-≈ʳ [ L ]-decompose₁) ⟩∘⟨refl ⟩
R.F₁ A (LR.counit.η B Y D.∘ L.F₁ (R.F₁ B g , E.id) D.∘ L.F₁ (C.id , f)) ∘ LR.unit.η A (R.F₀ B X)
≈⟨ R.F-resp-≈ A (pullˡ (LR.counit.commute B g)) ⟩∘⟨refl ⟩
R.F₁ A ((g D.∘ LR.counit.η B X) D.∘ L.F₁ (C.id , f)) ∘ LR.unit.η A (R.F₀ B X)
≈˘⟨ R.F-resp-≈ A (pushʳ (D.∘-resp-≈ʳ (L.F-resp-≈ (R.identity B , E.Equiv.refl)))) ⟩∘⟨refl ⟩
R.F₁ A (g D.∘ LR.counit.η B X D.∘ L.F₁ (R.F₁ B D.id , f)) ∘ LR.unit.η A (R.F₀ B X)
≈⟨ R.homomorphism A ⟩∘⟨refl ⟩
(R.F₁ A g ∘ R.F₁ A (LR.counit.η B X D.∘ L.F₁ (R.F₁ B D.id , f))) ∘ LR.unit.η A (R.F₀ B X)
≈⟨ assoc ⟩
R.F₁ A g ∘ F′ f D.id
∎
where open MR D
decompose₂ : ∀ {A B X Y} {f : A E.⇒ B} {g : X D.⇒ Y} → F′ f g ≈ F′ f D.id ∘ R.F₁ B g
decompose₂ {A} {B} {X} {Y} {f} {g} = begin
F′ f g
≈⟨ R.F-resp-≈ A (D.∘-resp-≈ʳ [ L ]-decompose₂) ⟩∘⟨refl ⟩
R.F₁ A (LR.counit.η B Y D.∘ L.F₁ (C.id , f) D.∘ L.F₁ (R.F₁ B g , E.id)) ∘ LR.unit.η A (R.F₀ B X)
≈˘⟨ R.F-resp-≈ A (pushˡ (D.∘-resp-≈ʳ (L.F-resp-≈ (R.identity B , E.Equiv.refl)))) ⟩∘⟨refl ⟩
R.F₁ A ((LR.counit.η B Y D.∘ L.F₁ (R.F₁ B D.id , f)) D.∘ L.F₁ (R.F₁ B g , E.id)) ∘ LR.unit.η A (R.F₀ B X)
≈⟨ R.homomorphism A ⟩∘⟨refl ⟩
(R.F₁ A (LR.counit.η B Y D.∘ L.F₁ (R.F₁ B D.id , f)) ∘ R.F₁ A (L.F₁ (R.F₁ B g , E.id))) ∘ LR.unit.η A (R.F₀ B X)
≈˘⟨ MR.pushʳ C (LR.unit.commute A (R.F₁ B g)) ⟩
R.F₁ A (LR.counit.η B Y D.∘ L.F₁ (R.F₁ B D.id , f)) ∘ LR.unit.η A (R.F₀ B Y) ∘ R.F₁ B g
≈⟨ sym-assoc ⟩
F′ f D.id ∘ R.F₁ B g
∎
where open MR D
swap : ∀ {A B X Y} {f : A E.⇒ B} {g : X D.⇒ Y} → R.F₁ A g ∘ F′ f D.id ≈ F′ f D.id ∘ R.F₁ B g
swap = ⟺ decompose₁ ○ decompose₂
commute″ : ∀ {X Y Z A} {f : Y E.⇒ Z} {g : X E.⇒ Y} → F′ (f E.∘ g) (D.id {A}) ≈ F′ g D.id ∘ F′ f D.id
commute″ {X} {Y} {Z} {A} {f} {g} = begin
F′ (f E.∘ g) D.id
≈⟨ R.F-resp-≈ X (D.∘-resp-≈ʳ (L.F-resp-≈ (R.identity Z , E.Equiv.refl))) ⟩∘⟨refl ⟩
R.F₁ X (LR.counit.η Z A D.∘ L.F₁ (C.id , f E.∘ g)) ∘ LR.unit.η X (R.F₀ Z A)
≈⟨ R.F-resp-≈ X (D.∘-resp-≈ʳ (Functor.homomorphism (appˡ L (R.F₀ Z A)))) ⟩∘⟨refl ⟩
R.F₁ X (LR.counit.η Z A D.∘ L.F₁ (C.id , f) D.∘ L.F₁ (C.id , g)) ∘ LR.unit.η X (R.F₀ Z A)
≈˘⟨ R.F-resp-≈ X (MR.pushˡ D (commute′ f)) ⟩∘⟨refl ⟩
R.F₁ X ((LR.counit.η Y A D.∘ L.F₁ (F′ f D.id , E.id)) D.∘ L.F₁ (C.id , g)) ∘ LR.unit.η X (R.F₀ Z A)
≈˘⟨ R.F-resp-≈ X (MR.pushʳ D [ L ]-commute) ⟩∘⟨refl ⟩
R.F₁ X (LR.counit.η Y A D.∘ L.F₁ (C.id , g) D.∘ L.F₁ (F′ f D.id , E.id)) ∘ LR.unit.η X (R.F₀ Z A)
≈⟨ R.F-resp-≈ X D.sym-assoc ⟩∘⟨refl ⟩
R.F₁ X ((LR.counit.η Y A D.∘ L.F₁ (C.id , g)) D.∘ L.F₁ (F′ f D.id , E.id)) ∘ LR.unit.η X (R.F₀ Z A)
≈⟨ R.homomorphism X ⟩∘⟨refl ⟩
(R.F₁ X (LR.counit.η Y A D.∘ L.F₁ (C.id , g)) ∘ R.F₁ X (L.F₁ (F′ f D.id , E.id))) ∘ LR.unit.η X (R.F₀ Z A)
≈˘⟨ MR.pushʳ C (LR.unit.commute X (F′ f D.id)) ⟩
R.F₁ X (LR.counit.η Y A D.∘ L.F₁ (C.id , g)) ∘ LR.unit.η X (R.F₀ Y A) ∘ F′ f D.id
≈˘⟨ R.F-resp-≈ X (D.∘-resp-≈ʳ (L.F-resp-≈ (R.identity Y , E.Equiv.refl))) ⟩∘⟨refl ⟩
R.F₁ X (LR.counit.η Y A D.∘ L.F₁ (R.F₁ Y D.id , g)) ∘ LR.unit.η X (R.F₀ Y A) ∘ F′ f D.id
≈⟨ sym-assoc ⟩
F′ g D.id ∘ F′ f D.id
∎
induced-bifunctorʳ : Bifunctor E.op D C
induced-bifunctorʳ = record
{ F₀ = uncurry R.F₀
; F₁ = uncurry F′
; identity = λ where
{e , d} →
let open MR D
in begin
F′ E.id D.id
≈⟨ R.F-resp-≈ e (D.∘-resp-≈ʳ (L.F-resp-≈ (R.identity e , E.Equiv.refl))) ⟩∘⟨refl ⟩
R.F₁ e (LR.counit.η e d D.∘ L.F₁ (C.id , E.id)) ∘ LR.unit.η e (R.F₀ e d)
≈⟨ R.F-resp-≈ e (elimʳ L.identity) ⟩∘⟨refl ⟩
R.F₁ e (LR.counit.η e d) ∘ LR.unit.η e (R.F₀ e d)
≈⟨ LR.zag e ⟩
C.id
∎
; homomorphism = λ where
{A , X} {B , Y} {W , Z} {f , h} {g , i} →
let open MR C
in begin
F′ (f E.∘ g) (i D.∘ h)
≈⟨ decompose₁ ⟩
R.F₁ W (i D.∘ h) ∘ F′ (f E.∘ g) D.id
≈˘⟨ center⁻¹ (⟺ (R.homomorphism W)) (⟺ commute″) ⟩
R.F₁ W i ∘ (R.F₁ W h ∘ F′ g D.id) ∘ F′ f D.id
≈˘⟨ center (⟺ swap) ⟩
(R.F₁ W i ∘ F′ g D.id) ∘ R.F₁ B h ∘ F′ f D.id
≈˘⟨ decompose₁ ⟩∘⟨ decompose₁ ⟩
F′ g i ∘ F′ f h
∎
; F-resp-≈ = λ where
{A , X} {B , Y} (eq , eq′) →
∘-resp-≈ˡ (R.F-resp-≈ B (D.∘-resp-≈ʳ (L.F-resp-≈ (R.F-resp-≈ A eq′ , eq))))
}
-- LAPC: left adjoint preserves colimits.
module _ {L : Functor C D} {R : Functor D C} (L⊣R : L ⊣ R) (F : Functor J C) where
private
module F = Functor F
lapc : Colimit F → Colimit (L ∘F F)
lapc col = Duality.coLimit⇒Colimit D (rapl (Adjoint.op L⊣R) F.op (Duality.Colimit⇒coLimit C col))
-- adjoint functors induce monads and comonads
module _ {L : Functor C D} {R : Functor D C} (L⊣R : L ⊣ R) where
private
module C = Category C using (id; _∘_; module HomReasoning)
module D = Category D using (id)
module L = Functor L using (F₁)
module R = Functor R using (F₁; identity)
open Adjoint L⊣R using (unit; counit; zig; zag)
rapl′ : ∀ {o ℓ e} → Continuous o ℓ e R
rapl′ lim = terminal.⊤-is-terminal
where open Limit (rapl L⊣R _ lim) using (module terminal)
lapc′ : ∀ {o ℓ e} → Cocontinuous o ℓ e L
lapc′ col = initial.⊥-is-initial
where open Colimit (lapc L⊣R _ col) using (module initial)
adjoint⇒monad : Monad C
adjoint⇒monad = record
{ F = R ∘F L
; η = unit
; μ = record
{ η = μ′.η
; commute = μ′.commute
; sym-commute = μ′.sym-commute
}
; assoc = [ R ]-resp-square (counit.commute _)
; sym-assoc = [ R ]-resp-square (counit.sym-commute _)
; identityˡ = λ {X} → begin
μ′.η X C.∘ R.F₁ (L.F₁ (unit.η X)) ≈⟨ [ R ]-resp-∘ zig ⟩
R.F₁ D.id ≈⟨ R.identity ⟩
C.id ∎
; identityʳ = zag
}
where open C.HomReasoning
μ′ : NaturalTransformation (R ∘F (L ∘F R) ∘F L) (R ∘F Categories.Functor.id ∘F L)
μ′ = R ∘ˡ counit ∘ʳ L
module μ′ = NaturalTransformation μ′ using (η; commute; sym-commute)
module _ {L : Functor C D} {R : Functor D C} (L⊣R : L ⊣ R) where
adjoint⇒comonad : Comonad D
adjoint⇒comonad = coMonad⇒Comonad D (adjoint⇒monad (Adjoint.op L⊣R))
-- adjoint functors are the same as universal morphisms
module _ {R : Functor D C} where
private
module C = Category C -- all of the structure is needed
module D = Category D using (Obj; _⇒_; _∘_; id; module HomReasoning)
module R = Functor R using (F₀; F₁; identity; homomorphism)
adjoint⇒universalMorphisms : ∀ {L : Functor C D} → L ⊣ R → ∀ (X : C.Obj) → UniversalMorphism X R
adjoint⇒universalMorphisms {L} L⊣R X = record
{ initial = record
{ ⊥ = record { f = unit.η X }
; ⊥-is-initial = record
{ ! =
let open C.HomReasoning
in record { commute = LRadjunct≈id ○ ⟺ C.identityʳ }
; !-unique = λ {A} g →
let open D.HomReasoning
in -, (begin
Radjunct (f A) ≈⟨ Radjunct-resp-≈ (C.Equiv.sym (C.Equiv.trans (commute g) (C.identityʳ {f = f A}))) ⟩
Radjunct (Ladjunct (h g)) ≈⟨ RLadjunct≈id ⟩
h g ∎)
}
}
}
where open Adjoint L⊣R using (Radjunct; Ladjunct; LRadjunct≈id; RLadjunct≈id; Radjunct-resp-≈; module unit)
open Comma⇒ using (h; commute)
open CommaObj using (f)
universalMophisms⇒adjoint : (∀ (X : C.Obj) → UniversalMorphism X R) → Σ (Functor C D) (λ L → L ⊣ R)
universalMophisms⇒adjoint umors = L , record
{ unit = ntHelper record
{ η = λ c → f (umors.⊥ c)
; commute = λ i → let open C.HomReasoning in ⟺ (commute (⊥X⇒⊥Y i) ○ C.identityʳ )
}
; counit = ntHelper record
{ η = ε
; commute = λ {X Y} i →
let open C.HomReasoning
open MR C using (pullʳ; cancelˡ; cancelʳ)
in proj₂ $ umors.!-unique₂ (R.F₀ X)
{record { f = R.F₁ i }}
(record
{ h = ε Y D.∘ L₁ (R.F₁ i)
; commute = begin
R.F₁ (ε Y D.∘ L₁ (R.F₁ i)) C.∘ f (⊥Rd X) ≈⟨ R.homomorphism ⟩∘⟨refl ⟩
(R.F₁ (ε Y) C.∘ R.F₁ (L₁ (R.F₁ i))) C.∘ f (⊥Rd X) ≈⟨ pullʳ (commute (⊥X⇒⊥Y (R.F₁ i)) ○ C.identityʳ) ⟩
R.F₁ (ε Y) C.∘ f (⊥Rd Y) C.∘ R.F₁ i ≈⟨ cancelˡ (commute (⊥Rd⇒id Y) ○ C.identityˡ) ⟩
R.F₁ i ≈˘⟨ C.identityʳ ⟩
R.F₁ i C.∘ C.id ∎
})
(record
{ h = i D.∘ ε X
; commute = begin
R.F₁ (i D.∘ ε X) C.∘ f (⊥Rd X) ≈⟨ R.homomorphism ⟩∘⟨refl ⟩
(R.F₁ i C.∘ R.F₁ (ε X)) C.∘ f (⊥Rd X) ≈⟨ cancelʳ (commute (⊥Rd⇒id X) ○ C.identityˡ) ⟩
R.F₁ i ≈˘⟨ C.identityʳ ⟩
R.F₁ i C.∘ C.id ∎
})
}
; zig = λ {c} →
let open C.HomReasoning
open MR C using (pullʳ; cancelˡ; id-comm-sym)
α = f (umors.⊥ c)
in proj₂ $ umors.!-unique₂ c
{record { f = α }}
(record
{ h = ε (L₀ c) D.∘ L₁ α
; commute = begin
R.F₁ (ε (L₀ c) D.∘ L₁ α) C.∘ α ≈⟨ R.homomorphism ⟩∘⟨refl ⟩
(R.F₁ (ε (L₀ c)) C.∘ R.F₁ (L₁ α)) C.∘ α ≈⟨ pullʳ (commute (⊥X⇒⊥Y α) ○ C.identityʳ) ⟩
R.F₁ (ε (L₀ c)) C.∘ f (⊥Rd (L₀ c)) C.∘ α ≈⟨ cancelˡ (commute (⊥Rd⇒id (L₀ c)) ○ C.identityˡ) ⟩
α ≈˘⟨ C.identityʳ ⟩
α C.∘ C.id ∎
})
(record
{ h = D.id
; commute = C.∘-resp-≈ˡ R.identity ○ id-comm-sym
})
; zag = λ {d} → C.Equiv.trans (commute (⊥Rd⇒id d)) C.identityˡ
}
where module umors X = UniversalMorphism (umors X)
open CommaObj
open Comma⇒
commaObj∘g : ∀ {X Y} → X C.⇒ Y → CommaObj (const! X) R
commaObj∘g {X} {Y} g = record { f = f (umors.⊥ Y) C.∘ g }
⊥X⇒⊥Y : ∀ {X Y} (g : X C.⇒ Y) → (X ↙ R) [ umors.⊥ X , commaObj∘g g ]
⊥X⇒⊥Y {X} {Y} g = umors.! X {commaObj∘g g}
L₀ : ∀ X → D.Obj
L₀ X = β (umors.⊥ X)
L₁ : ∀ {X Y} → X C.⇒ Y → β (umors.⊥ X) D.⇒ β (umors.⊥ Y)
L₁ {X} {Y} g = h (⊥X⇒⊥Y g)
L-Hom : ∀ {X Y Z} {i : X C.⇒ Y} {j : Y C.⇒ Z} → D [ L₁ (C [ j ∘ i ]) ≈ (D [ L₁ j ∘ L₁ i ]) ]
L-Hom {X} {Y} {Z} {i} {j} = proj₂ $ umors.!-unique₂ X (umors.! X) $
record { commute = begin
R.F₁ (h (umors.! Y) D.∘ h (umors.! X)) C.∘ f (umors.⊥ X)
≈⟨ (C.∘-resp-≈ˡ R.homomorphism) ○ C.assoc ⟩
R.F₁ (h (umors.! Y)) C.∘ R.F₁ (h (umors.! X)) C.∘ f (umors.⊥ X)
≈⟨ (C.∘-resp-≈ʳ (commute (⊥X⇒⊥Y i) ○ C.identityʳ)) ○ C.sym-assoc ⟩
(R.F₁ (h (umors.! Y)) C.∘ f (umors.⊥ Y)) C.∘ i
≈⟨ pushˡ (commute (⊥X⇒⊥Y j) ○ C.identityʳ) ⟩
f (umors.⊥ Z) C.∘ j C.∘ i
≈˘⟨ C.identityʳ ⟩
(f (umors.⊥ Z) C.∘ j C.∘ i) C.∘ C.id
∎ }
where open C.HomReasoning
open MR C using (pushˡ)
L : Functor C D
L = record
{ F₀ = L₀
; F₁ = L₁
; identity = λ {X} → proj₂ $ umors.!-unique X $
record { commute = elimˡ R.identity ○ ⟺ C.identityʳ ○ ⟺ C.identityʳ }
; homomorphism = L-Hom
; F-resp-≈ = λ {X} eq → proj₂ $ umors.!-unique₂ X (umors.! X) $
record { commute = commute (umors.! X) ○ C.∘-resp-≈ˡ (C.∘-resp-≈ʳ (⟺ eq)) }
}
where open C.HomReasoning using (_○_; ⟺)
open MR C using (elimˡ)
⊥Rd : (d : D.Obj) → CommaObj (const! (R.F₀ d)) R
⊥Rd d = umors.⊥ (R.F₀ d)
⊥Rd⇒id : (d : D.Obj) → (R.F₀ d ↙ R) [ ⊥Rd d , record { f = C.id } ]
⊥Rd⇒id d = umors.! (R.F₀ d) {record { f = C.id }}
ε : ∀ d → L₀ (R.F₀ d) D.⇒ d
ε d = h (⊥Rd⇒id d)
-- adjoint functors of a functor are isomorphic
module _ (L : Functor C D) where
R≃R′ : ∀ {R R′} → L ⊣ R → L ⊣ R′ → R ≃ R′
R≃R′ {R} {R′} L⊣R L⊣R′ = YP.yoneda-NI C R R′ (unlift-≃ Hom[-,R-]≃Hom[-,R′-])
where module ⊣₁ = Adjoint L⊣R using (Hom[-,R-]′; Hom-NI)
module ⊣₂ = Adjoint L⊣R′ using (Hom[-,R-]′; Hom-NI)
Hom[-,R-]≃Hom[-,R′-] : ⊣₁.Hom[-,R-]′ ≃ ⊣₂.Hom[-,R-]′
Hom[-,R-]≃Hom[-,R′-] = ≃.trans (≃.sym ⊣₁.Hom-NI) ⊣₂.Hom-NI
module _ {R : Functor D C} where
L≃L′ : ∀ {L L′} → L ⊣ R → L′ ⊣ R → L ≃ L′
L≃L′ L⊣R L′⊣R = NaturalIsomorphism.op (R≃R′ (Functor.op R) ⊣₂.op ⊣₁.op)
where module ⊣₁ = Adjoint L⊣R using (op)
module ⊣₂ = Adjoint L′⊣R using (op)
-- adjoint functors are preserved by natural isomorphisms
module _ {L L′ : Functor C D} {R R′ : Functor D C} where
⊣×≃⇒⊣ : L ⊣ R → L ≃ L′ → R ≃ R′ → L′ ⊣ R′
⊣×≃⇒⊣ L⊣R L≃L′ R≃R′ = Hom-NI′⇒Adjoint (≃.trans (LiftSetoids _ _ ⓘˡ Hom[L′-,-]≃Hom[L-,-])
(≃.trans (Adjoint.Hom-NI L⊣R)
(LiftSetoids _ _ ⓘˡ Hom[-,R-]≃Hom[-,R′-])))
where Hom[L′-,-]≃Hom[L-,-] : Hom[ D ][-,-] ∘F (Functor.op L′ ⁂ idF) ≃ Hom[ D ][-,-] ∘F (Functor.op L ⁂ idF)
Hom[L′-,-]≃Hom[L-,-] = Hom[ D ][-,-] ⓘˡ (NaturalIsomorphism.op L≃L′ ⁂ⁿⁱ ≃.refl)
Hom[-,R-]≃Hom[-,R′-] : Hom[ C ][-,-] ∘F (idF ⁂ R) ≃ Hom[ C ][-,-] ∘F (idF ⁂ R′)
Hom[-,R-]≃Hom[-,R′-] = Hom[ C ][-,-] ⓘˡ (≃.refl ⁂ⁿⁱ R≃R′)
| 47.983827
| 124
| 0.49545
|
df9db6d4aa8d7194f181591437946aacad07c90a
| 3,116
|
agda
|
Agda
|
theorems/stash/NConnected.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 294
|
2015-01-09T16:23:23.000Z
|
2022-03-20T13:54:45.000Z
|
theorems/stash/NConnected.agda
|
AntoineAllioux/HoTT-Agda
|
1037d82edcf29b620677a311dcfd4fc2ade2faa6
|
[
"MIT"
] | 31
|
2015-03-05T20:09:00.000Z
|
2021-10-03T19:15:25.000Z
|
theorems/stash/NConnected.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 experimental.NConnected where
lemma₁ : ∀ {i j} {A : Type i} {B : Type j} (f : A → B) {n : ℕ₋₂}
→ is-connected n A → is-connected (S n) B
→ has-conn-fibers n f
lemma₁ f cA cB = λ b → Σ-conn cA (λ a → path-conn cB)
lemma₂ : ∀ {i} {A B C : Type i}
→ (f : A → B) (g : B → C) {n : ℕ₋₂}
→ has-conn-fibers n (g ∘ f)
→ has-conn-fibers (S n) g
→ has-conn-fibers n f
lemma₂ f g {n} cA cB b =
equiv-preserves-conn (eqv b idp ⁻¹) (lemma₁-f′ (g b) (b , idp))
where
f′ : ∀ c → hfiber (g ∘ f) c → hfiber g c
f′ c (a , p) = (f a , p)
-- We first show [∀ b → is-connected n (hfiber (f′ (g b) (b , idp))) ]
lemma₁-f′ : ∀ c → has-conn-fibers n (f′ c)
lemma₁-f′ c = lemma₁ (f′ c) (cA c) (cB c)
-- The remaining shows [hfiber (f′ (g b) (b , idp))]
-- is the same as [hfiber f b]
to : ∀ b p → hfiber f b → hfiber (f′ (g b)) (b , p)
to ._ p (a , idp) = ((a , p) , idp)
from′ : ∀ b a → f a == b → hfiber f b
from′ ._ a idp = (a , idp)
from : ∀ b p → hfiber (f′ (g b)) (b , p) → hfiber f b
from b p ((a , q) , r) = from′ b a (fst= r)
from-to : ∀ b p x → from b p (to b p x) == x
from-to ._ p (a , idp) = idp
to-from : ∀ b p x → to b p (from b p x) == x
to-from b p ((a , q) , r) =
to b p (from b p ((a , q) , r))
=⟨ pair=-η r |in-ctx (λ r → to b p (from b p ((a , q) , r))) ⟩
to b p (from b p ((a , q) , pair= (fst= r) (snd= r)))
=⟨ lemma b p a q (fst= r) (snd= r) ⟩
((a , q) , pair= (fst= r) (snd= r))
=⟨ ! (pair=-η r) |in-ctx (λ r → ((a , q) , r)) ⟩
((a , q) , r)
∎
where
lemma : ∀ b p a (q : g (f a) == g b)
→ (r : f a == b) (s : q == p [ (λ b′ → g b′ == g b) ↓ r ])
→ to b p (from b p ((a , q) , pair= r s)) == ((a , q) , pair= r s)
lemma ._ ._ a q idp idp = idp
eqv : ∀ b p → hfiber f b ≃ hfiber (f′ (g b)) (b , p)
eqv b p = equiv (to b p) (from b p) (to-from b p) (from-to b p)
lemma₃ : ∀ {i j} {A : Type i} {B : Type j} (f : A → B)
→ A ≃ Σ B (hfiber f)
lemma₃ {A = A} {B} f = equiv to from to-from from-to
where
to : A → Σ B (hfiber f)
to a = (f a , (a , idp))
from : Σ B (hfiber f) → A
from (_ , (a , p)) = a
to-from : ∀ s → to (from s) == s
to-from (._ , (a , idp)) = idp
from-to : ∀ a → from (to a) == a
from-to a = idp
{-
∘-conn : ∀ {i j k} {A : Type i} {B : Type j} {C : Type k}
→ (f : A → B) → (g : B → C) → {n : ℕ₋₂}
→ has-conn-fibers n f
→ has-conn-fibers n g
→ has-conn-fibers n (g ∘ f)
∘-conn f g {⟨-2⟩} cf cg c = -2-conn _
∘-conn f g {S n } cf cg c =
Trunc-rec
{P = is-connected (hfiber (g ∘ f) c)}
(prop-has-level-S n (is-connected-is-prop n A))
(λ c )
(cg c)
-}
{-
lemma₃-path : ∀ {i j} {A : Type i} {B : Type j} (f : A → B)
→ A == Σ B (hfiber f)
lemma₃-path = λ f → ua (lemma₃ f)
-}
| 31.795918
| 80
| 0.413992
|
50fc40fbd27301798899163254b37bff654c6097
| 2,139
|
agda
|
Agda
|
src/MLib/Fin/Parts/Nat/Simple/Properties.agda
|
bch29/agda-matrices
|
e26ae2e0aa7721cb89865aae78625a2f3fd2b574
|
[
"MIT"
] | null | null | null |
src/MLib/Fin/Parts/Nat/Simple/Properties.agda
|
bch29/agda-matrices
|
e26ae2e0aa7721cb89865aae78625a2f3fd2b574
|
[
"MIT"
] | null | null | null |
src/MLib/Fin/Parts/Nat/Simple/Properties.agda
|
bch29/agda-matrices
|
e26ae2e0aa7721cb89865aae78625a2f3fd2b574
|
[
"MIT"
] | null | null | null |
module MLib.Fin.Parts.Nat.Simple.Properties where
open import MLib.Prelude
open import MLib.Fin.Parts.Nat
import MLib.Fin.Parts.Nat.Simple as S
module P a b = Partsℕ (S.repl a b)
open Nat using (_*_; _+_; _<_)
open Fin using (toℕ; fromℕ≤)
open List
fromAny : ∀ a b → Any Fin (S.repl a b) → ℕ × ℕ
fromAny zero b ()
fromAny (suc a) b (here j) = 0 , Fin.toℕ j
fromAny (suc a) b (there js) =
let i , j = fromAny a b js
in suc i , j
intoPart-prop : ∀ a b {ps : Any Fin (S.repl a b)} → P.intoPart a b ps ≡ S.intoPart a b (fromAny a b ps)
intoPart-prop zero b {()}
intoPart-prop (suc a) b {here px} = ≡.sym (Nat.+-identityʳ _)
intoPart-prop (suc a) b {there ps} =
let ind = intoPart-prop a b {ps}
i , j = fromAny a b ps
open ≡.Reasoning
open Nat.SemiringSolver
in begin
b + Impl.intoPart ps ≡⟨ ≡.cong₂ _+_ ≡.refl ind ⟩
b + (j + i * b) ≡⟨ solve 3 (λ b j ib → b :+ (j :+ ib) := j :+ (b :+ ib)) ≡.refl b j (i * b) ⟩
j + (b + i * b) ∎
lem : ∀ a b {k} → k < a * b → k < sum (S.repl a b)
lem a b p = Nat.≤-trans p (Nat.≤-reflexive (≡.sym (S.sum-replicate-* a b)))
fromPart-prop : ∀ a b {k} → k < a * b → Maybe.map (fromAny a b) (Impl.fromPart (S.repl a b) k) ≡ just (S.fromPart a b k)
fromPart-prop zero b ()
fromPart-prop (suc a) b {k} p with Impl.compare′ k b
fromPart-prop (suc a) .(suc (m + k)) {.m} p | Impl.less m k = ≡.cong just (Σ.≡×≡⇒≡ (≡.refl , Fin.toℕ-fromℕ≤ _))
fromPart-prop (suc a) b {.(b + k)} p | Impl.gte .b k with Impl.fromPart (S.repl a b) k | fromPart-prop a b {k} (Nat.+-cancelˡ-< b p)
fromPart-prop (suc a) b {.(b + k)} p | Impl.gte .b k | just x | ind =
let e1 , e2 = Σ.≡⇒≡×≡ (Maybe.just-injective ind)
in ≡.cong just (Σ.≡×≡⇒≡ (≡.cong suc e1 , e2))
fromPart-prop (suc a) b {.(b + k)} p | Impl.gte .b k | nothing | ()
fromPart′-prop : ∀ a b {k} (p : k < a * b) → fromAny a b (P.fromPart a b {k} (lem a b p)) ≡ S.fromPart a b k
fromPart′-prop a b {k} p with Impl.fromPart (S.repl a b) k | Impl.fromPart-prop (S.repl a b) (lem a b p) | fromPart-prop a b p
fromPart′-prop a b {k} p | just x | y | z = Maybe.just-injective z
fromPart′-prop a b {k} p | nothing | () | z
| 41.941176
| 132
| 0.57597
|
dc3187c9ca4a90b97cedf2102015af2a03a5385f
| 749
|
agda
|
Agda
|
test/Fail/Issue4560NoPatternMatchingWithoutEta.agda
|
cagix/agda
|
cc026a6a97a3e517bb94bafa9d49233b067c7559
|
[
"BSD-2-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Fail/Issue4560NoPatternMatchingWithoutEta.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Fail/Issue4560NoPatternMatchingWithoutEta.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2020-04-19, issue #4560, raised by Andrea
-- Having both matching on constructor and copattern matching
-- for non-eta records leads to loss of subject reduction.
open import Agda.Builtin.Equality
postulate
A : Set
a : A
record R : Set where
constructor con
no-eta-equality
field
X Y : A
foo : R → A
foo (con x y) = x
-- Expected error here:
--
-- Pattern matching on no-eta record type R
-- (defined at ...)
-- is not allowed
-- (to activate, add declaration `pattern` to record definition)
-- when checking that the pattern con x y has type R
bar : R
bar .R.X = a
bar .R.Y = a
test : foo bar ≡ a
test = refl
-- Problem was:
-- foo bar != a of type A
-- when checking that the expression refl has type foo bar ≡ a
| 19.710526
| 64
| 0.676903
|
0b1321cdee65f44fb01d233f67f2d769f008ea23
| 1,772
|
agda
|
Agda
|
test/Succeed/Issue2046.agda
|
cagix/agda
|
cc026a6a97a3e517bb94bafa9d49233b067c7559
|
[
"BSD-2-Clause"
] | 1,989
|
2015-01-09T23:51:16.000Z
|
2022-03-30T18:20:48.000Z
|
test/Succeed/Issue2046.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 4,066
|
2015-01-10T11:24:51.000Z
|
2022-03-31T21:14:49.000Z
|
test/Succeed/Issue2046.agda
|
Seanpm2001-languages/agda
|
9911f73061e21a87fad76c662463257afe02c861
|
[
"BSD-2-Clause"
] | 371
|
2015-01-03T14:04:08.000Z
|
2022-03-30T19:00:30.000Z
|
-- Andreas, 2016-12-12, issue #2046, reported by Nad
-- Parameter refinement broke the size solver.
-- {-# OPTIONS -v tc.size.solve:100 #-}
-- {-# OPTIONS -v tc.constr.cast:100 #-}
-- -- {-# OPTIONS -v tc.sig.param:60 #-}
-- -- {-# OPTIONS -v tc.check.internal:100 #-}
-- -- {-# OPTIONS -v interaction.give:100 #-}
{-# OPTIONS --sized-types #-}
open import Agda.Builtin.Size using (Size; Size<_)
data _×_ (A B : Set) : Set where
_,_ : A → B → A × B
record Always {A : Set} (P : A → Set) : Set where
field
always : ∀ x → P x
postulate
A : Set
module M (P : A → Set) where
record R₁ (i : Size) (x : A) : Set where
coinductive
field
force : {j : Size< i} → R₁ j x
record R₂ (i : Size) (x : A) : Set where
inductive
constructor ⟨_,_⟩
field
f₁ : P x
f₂ : P x → R₁ i x
data P : A → Set where
c : (y : A) → P y → P y
postulate
p : (x : A) → P x
a : (i : Size) → Always (M.R₁ P i)
module _ (Unused : Set) where
open M P
rejected : ∀ i z → R₂ i z
rejected i z =
⟨ p z
, (λ { (c y q) → Always.always (a _) z })
⟩
-- Should succeed
{-
Solving constraints (DontDefaultToInfty)
i =< _i_31 Unused i z : Size
_i_31 Unused i z =< _i_35 z Unused i q : Size
converting size constraint i =< _i_31 Unused i z : Size
converting size constraint
_i_31 Unused i z =< _i_35 z Unused i q : Size
Solving constraint cluster
[Unused, i, z] i ≤ _i_31 Unused i z
[z, Unused, i, q] _i_31 Unused i z ≤ _i_35 z Unused i q
Size hypotheses
Canonicalized constraints
[z, Unused, i, q] Unused ≤ _i_31 z Unused i
[z, Unused, i, q] _i_31 Unused i z ≤ _i_35 z Unused i q
solution _i_31 z Unused i := Unused
xs = [3,2,1]
u = Var 2 []
solution _i_35 z Unused i q := Unused
xs = [3,2,1,0]
u = Var 2 []
-}
| 22.717949
| 55
| 0.586907
|
4d08af6fce367c02c9be2b5e4f00810d9fcad85d
| 1,507
|
agda
|
Agda
|
src/Categories/Category/Instance/Zero.agda
|
glittershark/agda-categories
|
2128fab9e8d341364cbf784bb17c547bf73891de
|
[
"MIT"
] | null | null | null |
src/Categories/Category/Instance/Zero.agda
|
glittershark/agda-categories
|
2128fab9e8d341364cbf784bb17c547bf73891de
|
[
"MIT"
] | null | null | null |
src/Categories/Category/Instance/Zero.agda
|
glittershark/agda-categories
|
2128fab9e8d341364cbf784bb17c547bf73891de
|
[
"MIT"
] | null | null | null |
{-# OPTIONS --without-K --safe #-}
open import Level
-- ⊥ is Initial
module Categories.Category.Instance.Zero where
open import Data.Empty using (⊥; ⊥-elim)
open import Function renaming (id to idf)
open import Categories.Category
open import Categories.Functor
open import Categories.Category.Instance.Cats
import Categories.Object.Initial as Init
-- Unlike for ⊤ being Terminal, Agda can't deduce these, need to be explicit
module _ {o ℓ e : Level} where
open Init (Cats o ℓ e)
Zero : Category o ℓ e
Zero = record
{ Obj = Lift o ⊥
; _⇒_ = λ _ _ → Lift ℓ ⊥
; _≈_ = λ _ _ → Lift e ⊥
; id = λ { { lift () } }
; _∘_ = λ a _ → a -- left-biased rather than strict
; assoc = λ { {lift () } }
; sym-assoc = λ { {lift () } }
; identityˡ = λ { {()} }
; identityʳ = λ { {()} }
; identity² = λ { {()} }
; ∘-resp-≈ = λ { () }
; equiv = record
{ refl = λ { {()} }
; sym = idf
; trans = λ a _ → a
}
}
Zero-⊥ : Initial
Zero-⊥ = record
{ ⊥ = Zero
; ! = record
{ F₀ = λ { (lift x) → ⊥-elim x }
; F₁ = λ { (lift ()) }
; identity = λ { {lift ()} }
; homomorphism = λ { {lift ()} }
; F-resp-≈ = λ { () }
}
; !-unique = λ f → record
{ F⇒G = record { η = λ { () } ; commute = λ { () } ; sym-commute = λ { () } }
; F⇐G = record { η = λ { () } ; commute = λ { () } ; sym-commute = λ { () } }
; iso = λ { (lift ()) }
}
}
| 26.438596
| 83
| 0.474453
|
a1a8e42c3cd6a403004da25e0dd3bc4da2ddd289
| 2,513
|
agda
|
Agda
|
examples/outdated-and-incorrect/Alonzo/PrintFloat.agda
|
asr/agda-kanso
|
aa10ae6a29dc79964fe9dec2de07b9df28b61ed5
|
[
"MIT"
] | 1
|
2018-10-10T17:08:44.000Z
|
2018-10-10T17:08:44.000Z
|
examples/outdated-and-incorrect/Alonzo/PrintFloat.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
examples/outdated-and-incorrect/Alonzo/PrintFloat.agda
|
np/agda-git-experiment
|
20596e9dd9867166a64470dd24ea68925ff380ce
|
[
"MIT"
] | null | null | null |
module PrintFloat where
import AlonzoPrelude
import PreludeShow
import PreludeList
import PreludeString
import PreludeNat
open AlonzoPrelude
open PreludeShow
open PreludeList, hiding(_++_)
open PreludeString
open PreludeNat
typeS : Char -> Set
typeS 'f' = Float
show : (c : Char) -> (typeS c) -> String
show 'f' f = showFloat f
data Unit : Set where
unit : Unit
data Format : Set where
stringArg : Format
natArg : Format
intArg : Format
floatArg : Format
charArg : Format
litChar : Char -> Format
badFormat : Char -> Format
data BadFormat (c:Char) : Set where
format' : List Char -> List Format
format' ('%' :: 's' :: fmt) = stringArg :: format' fmt
format' ('%' :: 'n' :: fmt) = natArg :: format' fmt
-- format' ('%' :: 'd' :: fmt) = intArg :: format' fmt
format' ('%' :: 'f' :: fmt) = floatArg :: format' fmt
format' ('%' :: 'c' :: fmt) = charArg :: format' fmt
format' ('%' :: '%' :: fmt) = litChar '%' :: format' fmt
format' ('%' :: c :: fmt) = badFormat c :: format' fmt
format' (c :: fmt) = litChar c :: format' fmt
format' [] = []
format : String -> List Format
format s = format' (toList s)
-- Printf1 : Format -> Set
-- Printf1 floatArg = Float
Printf' : List Format -> Set
Printf' (stringArg :: fmt) = String × Printf' fmt
Printf' (natArg :: fmt) = Nat × Printf' fmt
Printf' (intArg :: fmt) = Int × Printf' fmt
Printf' (floatArg :: fmt) = Float × Printf' fmt
Printf' (charArg :: fmt) = Char × Printf' fmt
Printf' (badFormat c :: fmt) = BadFormat c
Printf' (litChar _ :: fmt) = Printf' fmt
Printf' [] = Unit × Unit
Printf : String -> Set
Printf fmt = Printf' (format fmt)
printf' : (fmt : List Format) -> Printf' fmt -> String
printf' (stringArg :: fmt) < s | args > = s ++ printf' fmt args
printf' (natArg :: fmt) < n | args > = showNat n ++ printf' fmt args
printf' (intArg :: fmt) < n | args > = showInt n ++ printf' fmt args
printf' (floatArg :: fmt) < x | args > = showFloat x ++ printf' fmt args
printf' (charArg :: fmt) < c | args > = showChar c ++ printf' fmt args
printf' (litChar c :: fmt) args = fromList (c :: []) ++ printf' fmt args
printf' (badFormat _ :: fmt) ()
printf' [] < unit | unit > = ""
printf : (fmt : String) -> Printf fmt -> String
printf fmt = printf' (format fmt)
-- mainS = show 'f' 3.14
-- mainS = printf' (format "%f") < 3.14 | < unit | unit > >
mainS = printf "pi = %f" < 3.14159 | < unit | unit > >
-- mainS = fromList ( 'p' :: [] )
| 31.024691
| 75
| 0.58655
|
cb9c1d567807cc2e3375051883aeec957dc7e49f
| 3,485
|
agda
|
Agda
|
archive/agda-2/Oscar/Property/Preservativity.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
archive/agda-2/Oscar/Property/Preservativity.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | 1
|
2019-04-29T00:35:04.000Z
|
2019-05-11T23:33:04.000Z
|
archive/agda-2/Oscar/Property/Preservativity.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
module Oscar.Property.Preservativity where
open import Oscar.Level
open import Oscar.Relation
record Preservativity
{a} {A : Set a} {b} {B : A → Set b} {c} {C : (x : A) → B x → Set c}
(_▻₁_ : (x : A) → (y : B x) → C x y)
{d} {D : Set d} {e} {E : D → Set e} {f} {F : (x : D) → E x → Set f}
(_▻₂_ : (x : D) → (y : E x) → F x y)
{ℓ}
(_≤_ : ∀ {x y} → F x y → F x y → Set ℓ)
(◽ : A → D)
(◻ : ∀ {x} → B x → E (◽ x))
(□ : ∀ {x y} → C x y → F (◽ x) (◻ y))
: Set (a ⊔ b ⊔ c ⊔ d ⊔ e ⊔ f ⊔ ℓ) where
field
preservativity : ∀ (x : A) (y : B x) → □ (x ▻₁ y) ≤ (◽ x ▻₂ ◻ y)
open Preservativity ⦃ … ⦄ public
-- -- record Preservativity
-- -- {𝔞₁} {𝔄₁ : Set 𝔞₁} {𝔰₁} {_►₁_ : 𝔄₁ → 𝔄₁ → Set 𝔰₁}
-- -- (_◅₁_ : ∀ {m n} → m ►₁ n → ∀ {l} → m ⟨ l ►₁_ ⟩→ n)
-- -- {𝔞₂} {𝔄₂ : Set 𝔞₂} {𝔰₂} (_►₂_ : 𝔄₂ → 𝔄₂ → Set 𝔰₂)
-- -- (_◅₂_ : ∀ {m n} → m ►₂ n → ∀ {l} → m ⟨ l ►₂_ ⟩→ n)
-- -- {ℓ}
-- -- (_≤_ : ∀ {m n} → m ►₂ n → m ►₂ n → Set ℓ)
-- -- {μ : 𝔄₁ → 𝔄₂}
-- -- (◽ : ∀ {m n} → m ►₁ n → μ m ►₂ μ n)
-- -- : Set (𝔞₁ ⊔ 𝔰₁ ⊔ 𝔞₂ ⊔ 𝔰₂ ⊔ ℓ) where
-- -- field
-- -- preservativity : ∀ {l m} (f : l ►₁ m) {n} (g : m ►₁ n) → ◽ (g ◅₁ f) ≤ (◽ g ◅₂ ◽ f)
-- -- open Preservativity ⦃ … ⦄ public
-- -- -- record Preservativity
-- -- -- {𝔞₁} {𝔄₁ : Set 𝔞₁} {𝔰₁}
-- -- -- (_►₁_ : 𝔄₁ → 𝔄₁ → Set 𝔰₁) {𝔱₁}
-- -- -- {▸₁ : 𝔄₁ → Set 𝔱₁}
-- -- -- (_◃₁_ : ∀ {m n} → m ►₁ n → m ⟨ ▸₁ ⟩→ n)
-- -- -- {𝔞₂} {𝔄₂ : Set 𝔞₂} {𝔰₂}
-- -- -- (_►₂_ : 𝔄₂ → 𝔄₂ → Set 𝔰₂) {𝔱₂}
-- -- -- {▸₂ : 𝔄₂ → Set 𝔱₂}
-- -- -- (_◃₂_ : ∀ {m n} → m ►₂ n → m ⟨ ▸₂ ⟩→ n)
-- -- -- {ℓ}
-- -- -- (_≤_ : ∀ {n} → ▸₂ n → ▸₂ n → Set ℓ)
-- -- -- {μ : 𝔄₁ → 𝔄₂}
-- -- -- (◽ : ∀ {n} → ▸₁ n → ▸₂ (μ n))
-- -- -- (□ : ∀ {m n} → m ►₁ n → μ m ►₂ μ n)
-- -- -- : Set (𝔞₁ ⊔ 𝔰₁ ⊔ 𝔱₁ ⊔ 𝔞₂ ⊔ 𝔰₂ ⊔ 𝔱₂ ⊔ ℓ) where
-- -- -- field
-- -- -- preservativity : ∀ {m n} (f : ▸₁ m) (g : m ►₁ n) → ◽ (g ◃₁ f) ≤ (□ g ◃₂ ◽ f)
-- -- -- open Preservativity ⦃ … ⦄ public
-- -- -- open import Oscar.Class.Associativity
-- -- -- open import Oscar.Class.Symmetry
-- -- -- open import Oscar.Function
-- -- -- instance
-- -- -- Preservativity⋆ : ∀
-- -- -- {𝔞} {𝔄 : Set 𝔞} {𝔰} {_►_ : 𝔄 → 𝔄 → Set 𝔰}
-- -- -- {_◅_ : ∀ {m n} → m ► n → ∀ {l} → m ⟨ l ►_ ⟩→ n}
-- -- -- {𝔱} {▸ : 𝔄 → Set 𝔱}
-- -- -- {_◃_ : ∀ {m n} → m ► n → m ⟨ ▸ ⟩→ n}
-- -- -- {ℓ}
-- -- -- {_≤_ : ∀ {n} → ▸ n → ▸ n → Set ℓ}
-- -- -- ⦃ _ : Associativity _◅_ _◃_ _≤_ ⦄
-- -- -- → ∀ {n} {x : ▸ n}
-- -- -- → Preservativity _►_ (λ ⋆ → _◅_ ⋆) _►_ _◃_ (flip _≤_) (_◃ x) id
-- -- -- Preservativity.preservativity (Preservativity⋆ {_◅_ = _◅_} {_◃_ = _◃_} {_≤_ = _≤_} ⦃ ′associativity ⦄ {x = x}) f = associativity {_◅_ = _◅_} {_◃_ = _◃_} {_≤_ = _≤_} ⦃ {-′associativity-}_ ⦄ x f
-- -- -- preservation : ∀
-- -- -- {𝔞₁} {𝔄₁ : Set 𝔞₁} {𝔰₁} {_►₁_ : 𝔄₁ → 𝔄₁ → Set 𝔰₁} {𝔱₁} {▸₁ : 𝔄₁ → Set 𝔱₁}
-- -- -- (_◃₁_ : ∀ {m n} → m ►₁ n → m ⟨ ▸₁ ⟩→ n)
-- -- -- {𝔞₂} {𝔄₂ : Set 𝔞₂} {𝔰₂} {_►₂_ : 𝔄₂ → 𝔄₂ → Set 𝔰₂} {𝔱₂} {▸₂ : 𝔄₂ → Set 𝔱₂}
-- -- -- (_◃₂_ : ∀ {m n} → m ►₂ n → m ⟨ ▸₂ ⟩→ n)
-- -- -- {ℓ}
-- -- -- (_≤_ : ∀ {n} → ▸₂ n → ▸₂ n → Set ℓ)
-- -- -- {μ : 𝔄₁ → 𝔄₂}
-- -- -- {◽ : ∀ {n} → ▸₁ n → ▸₂ (μ n)}
-- -- -- {□ : ∀ {m n} → m ►₁ n → μ m ►₂ μ n}
-- -- -- ⦃ _ : Preservativity _►₁_ _◃₁_ _►₂_ _◃₂_ _≤_ ◽ □ ⦄
-- -- -- {m n} (f : ▸₁ m) (g : m ►₁ n) → ◽ (g ◃₁ f) ≤ (□ g ◃₂ ◽ f)
-- -- -- preservation _◃₁_ _◃₂_ _≤_ f g = preservativity {_◃₁_ = _◃₁_} {_◃₂_ = _◃₂_} {_≤_ = _≤_} f g
| 39.157303
| 203
| 0.356671
|
39af21e3b951dc7c7323e68f809d9a92ea480e53
| 396
|
agda
|
Agda
|
Cubical/Data/FinSet/Binary/Small/Base.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 301
|
2018-10-17T18:00:24.000Z
|
2022-03-24T02:10:47.000Z
|
Cubical/Data/FinSet/Binary/Small/Base.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 584
|
2018-10-15T09:49:02.000Z
|
2022-03-30T12:09:17.000Z
|
Cubical/Data/FinSet/Binary/Small/Base.agda
|
FernandoLarrain/cubical
|
9acdecfa6437ec455568be4e5ff04849cc2bc13b
|
[
"MIT"
] | 134
|
2018-11-16T06:11:03.000Z
|
2022-03-23T16:22:13.000Z
|
{-# OPTIONS --safe #-}
module Cubical.Data.FinSet.Binary.Small.Base where
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Univalence
open import Cubical.Data.Bool hiding (isSetBool)
data Binary : Type₀
El : Binary → Type₀
data Binary where
ℕ₂ : Binary
un : ∀ x y → El x ≃ El y → x ≡ y
El ℕ₂ = Bool
El (un _ _ e i) = ua e i
| 18.857143
| 50
| 0.714646
|
dc9f89657b1f8dfad1923912f3cb0cd0efe31749
| 665
|
agda
|
Agda
|
archive/agda-1/IsLiteralFormula.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
archive/agda-1/IsLiteralFormula.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | 1
|
2019-04-29T00:35:04.000Z
|
2019-05-11T23:33:04.000Z
|
archive/agda-1/IsLiteralFormula.agda
|
m0davis/oscar
|
52e1cdbdee54d9a8eaee04ee518a0d7f61d25afb
|
[
"RSA-MD"
] | null | null | null |
module IsLiteralFormula where
open import OscarPrelude
open import PredicateName
open import Term
open import Formula
open import HasNegation
data IsLiteralFormula : Formula → Set
where
atomic : (𝑃 : PredicateName) → (τs : Terms) → IsLiteralFormula $ 𝑃[ 𝑃 ♭ τs ]
logical : (𝑃 : PredicateName) → (τs : Terms) → IsLiteralFormula ∘ ~ $ 𝑃[ 𝑃 ♭ τs ]
eqIsLiteralFormula : ∀ {φ} → (lf₁ lf₂ : IsLiteralFormula φ) → lf₁ ≡ lf₂
eqIsLiteralFormula (atomic _ _) (atomic _ _) = refl
eqIsLiteralFormula (logical _ _) (logical _ _) = refl
instance EqIsLiteralFormula : ∀ {φ} → Eq (IsLiteralFormula φ)
Eq._==_ EqIsLiteralFormula lf₁ lf₂ = yes $ eqIsLiteralFormula lf₁ lf₂
| 31.666667
| 83
| 0.723308
|
4a6b6f7977435f850e3fdcc0f63ee0ef18c27d40
| 6,243
|
agda
|
Agda
|
canonical-boxed-forms.agda
|
hazelgrove/hazel-palette-agda
|
c3225acc3c94c56376c6842b82b8b5d76912df2a
|
[
"MIT"
] | 4
|
2020-10-04T06:45:06.000Z
|
2021-12-19T15:38:31.000Z
|
canonical-boxed-forms.agda
|
hazelgrove/hazel-palette-agda
|
c3225acc3c94c56376c6842b82b8b5d76912df2a
|
[
"MIT"
] | 9
|
2020-09-30T20:27:56.000Z
|
2020-10-20T20:44:13.000Z
|
canonical-boxed-forms.agda
|
hazelgrove/hazelnut-livelits-agda
|
c3225acc3c94c56376c6842b82b8b5d76912df2a
|
[
"MIT"
] | null | null | null |
open import Nat
open import Prelude
open import contexts
open import core
open import canonical-value-forms
module canonical-boxed-forms where
canonical-boxed-forms-b : ∀{Δ d} →
Δ , ∅ ⊢ d :: b →
d boxedval →
d == c
canonical-boxed-forms-b (TAVar _) (BVVal ())
canonical-boxed-forms-b wt (BVVal v) = canonical-value-forms-b wt v
-- this type gives somewhat nicer syntax for the output of the canonical
-- forms lemma for boxed values at arrow type
data cbf-arr : (Δ : hctx) (d : iexp) (τ1 τ2 : typ) → Set where
CBFLam : ∀{Δ d τ1 τ2} →
(Σ[ x ∈ Nat ] Σ[ d' ∈ iexp ]
(d == (·λ x [ τ1 ] d') × Δ , ■ (x , τ1) ⊢ d' :: τ2))
→ cbf-arr Δ d τ1 τ2
CBFCastArr : ∀{Δ d τ1 τ2} →
(Σ[ d' ∈ iexp ] Σ[ τ1' ∈ typ ] Σ[ τ2' ∈ typ ]
(d == (d' ⟨ τ1' ==> τ2' ⇒ τ1 ==> τ2 ⟩) ×
(τ1' ==> τ2' ≠ τ1 ==> τ2) ×
(Δ , ∅ ⊢ d' :: τ1' ==> τ2')))
→ cbf-arr Δ d τ1 τ2
data cbf-prod : (Δ : hctx) (d : iexp) (τ1 τ2 : typ) → Set where
CBFPairVal : ∀{Δ d τ1 τ2} →
(Σ[ d1 ∈ iexp ] Σ[ d2 ∈ iexp ]
(d == ⟨ d1 , d2 ⟩ ×
Δ , ∅ ⊢ d1 :: τ1 ×
Δ , ∅ ⊢ d2 :: τ2 ×
d1 val ×
d2 val))
→ cbf-prod Δ d τ1 τ2
CBFPairBV : ∀{Δ d τ1 τ2} →
(Σ[ d1 ∈ iexp ] Σ[ d2 ∈ iexp ]
(d == ⟨ d1 , d2 ⟩ ×
Δ , ∅ ⊢ d1 :: τ1 ×
Δ , ∅ ⊢ d2 :: τ2 ×
d1 boxedval ×
d2 boxedval ))
→ cbf-prod Δ d τ1 τ2
CBFCastProd : ∀{Δ d τ1 τ2} →
(Σ[ d' ∈ iexp ] Σ[ τ1' ∈ typ ] Σ[ τ2' ∈ typ ]
(d == (d' ⟨ τ1' ⊗ τ2' ⇒ τ1 ⊗ τ2 ⟩) ×
(τ1' ⊗ τ2' ≠ τ1 ⊗ τ2) ×
(τ1' ⊗ τ2' ~ τ1 ⊗ τ2) ×
(d' boxedval) ×
(Δ , ∅ ⊢ d' :: τ1' ⊗ τ2')))
→ cbf-prod Δ d τ1 τ2
canonical-boxed-forms-arr : ∀{Δ d τ1 τ2 } →
Δ , ∅ ⊢ d :: (τ1 ==> τ2) →
d boxedval →
cbf-arr Δ d τ1 τ2
canonical-boxed-forms-arr (TAVar x₁) (BVVal ())
canonical-boxed-forms-arr (TALam f wt) (BVVal v) = CBFLam (canonical-value-forms-arr (TALam f wt) v)
canonical-boxed-forms-arr (TAAp wt wt₁) (BVVal ())
canonical-boxed-forms-arr (TAEHole x x₁) (BVVal ())
canonical-boxed-forms-arr (TANEHole x wt x₁) (BVVal ())
canonical-boxed-forms-arr (TACast wt x) (BVVal ())
canonical-boxed-forms-arr (TACast wt x) (BVArrCast x₁ bv) = CBFCastArr (_ , _ , _ , refl , x₁ , wt)
canonical-boxed-forms-arr (TAFailedCast x x₁ x₂ x₃) (BVVal ())
canonical-boxed-forms-arr (TAFst wt) (BVVal ())
canonical-boxed-forms-arr (TASnd wt) (BVVal ())
canonical-boxed-forms-hole : ∀{Δ d} →
Δ , ∅ ⊢ d :: ⦇·⦈ →
d boxedval →
Σ[ d' ∈ iexp ] Σ[ τ' ∈ typ ]
((d == d' ⟨ τ' ⇒ ⦇·⦈ ⟩) ×
(τ' ground) ×
(Δ , ∅ ⊢ d' :: τ'))
canonical-boxed-forms-hole (TAVar x₁) (BVVal ())
canonical-boxed-forms-hole (TAAp wt wt₁) (BVVal ())
canonical-boxed-forms-hole (TAEHole x x₁) (BVVal ())
canonical-boxed-forms-hole (TANEHole x wt x₁) (BVVal ())
canonical-boxed-forms-hole (TACast wt x) (BVVal ())
canonical-boxed-forms-hole (TACast wt x) (BVHoleCast x₁ bv) = _ , _ , refl , x₁ , wt
canonical-boxed-forms-hole (TAFailedCast x x₁ x₂ x₃) (BVVal ())
canonical-boxed-forms-hole (TAFst wt) (BVVal ())
canonical-boxed-forms-hole (TASnd wt) (BVVal ())
canonical-boxed-forms-prod : ∀{Δ d τ1 τ2 } →
Δ , ∅ ⊢ d :: (τ1 ⊗ τ2) →
d boxedval →
cbf-prod Δ d τ1 τ2
canonical-boxed-forms-prod (TAVar x₁) (BVVal ())
canonical-boxed-forms-prod (TAAp wt wt₁) (BVVal ())
canonical-boxed-forms-prod (TAEHole x x₁) (BVVal ())
canonical-boxed-forms-prod (TANEHole x wt x₁) (BVVal ())
canonical-boxed-forms-prod (TACast wt x) (BVVal ())
canonical-boxed-forms-prod (TACast wt x) (BVProdCast x₁ bv) = CBFCastProd (_ , _ , _ , refl , x₁ , x , bv , wt)
canonical-boxed-forms-prod (TAFailedCast wt x x₁ x₂) (BVVal ())
canonical-boxed-forms-prod (TAFst wt) (BVVal ())
canonical-boxed-forms-prod (TASnd wt) (BVVal ())
canonical-boxed-forms-prod (TAPair wt wt₁) (BVVal (VPair x x₁)) = CBFPairVal (_ , _ , refl , wt , wt₁ , x , x₁)
canonical-boxed-forms-prod (TAPair wt wt₁) (BVPair bv bv₁) = CBFPairBV (_ , _ , refl , wt , wt₁ , bv , bv₁)
canonical-boxed-forms-coverage : ∀{Δ d τ} →
Δ , ∅ ⊢ d :: τ →
d boxedval →
τ ≠ b →
((τ1 : typ) (τ2 : typ) → τ ≠ (τ1 ==> τ2)) →
τ ≠ ⦇·⦈ →
((τ1 : typ) (τ2 : typ) → τ ≠ (τ1 ⊗ τ2)) →
⊥
canonical-boxed-forms-coverage TAConst (BVVal x) nb na nh = λ _ → nb refl
canonical-boxed-forms-coverage (TAVar x₁) (BVVal ()) nb na nh
canonical-boxed-forms-coverage (TALam _ wt) (BVVal x₁) nb na nh = λ _ → na _ _ refl
canonical-boxed-forms-coverage (TAAp wt wt₁) (BVVal ()) nb na nh
canonical-boxed-forms-coverage (TAEHole x x₁) (BVVal ()) nb na nh
canonical-boxed-forms-coverage (TANEHole x wt x₁) (BVVal ()) nb na nh
canonical-boxed-forms-coverage (TACast wt x) (BVVal ()) nb na nh
canonical-boxed-forms-coverage (TACast wt x) (BVArrCast x₁ bv) nb na nh = λ _ → na _ _ refl
canonical-boxed-forms-coverage (TACast wt x) (BVHoleCast x₁ bv) nb na nh = λ _ → nh refl
canonical-boxed-forms-coverage (TAFailedCast x x₁ x₂ x₃) (BVVal ())
canonical-boxed-forms-coverage (TACast wt x) (BVProdCast x₁ bv) nb na nh = λ z → z _ _ refl
canonical-boxed-forms-coverage (TAFst wt) (BVVal ()) nb na nh
canonical-boxed-forms-coverage (TASnd wt) (BVVal ()) nb na nh
canonical-boxed-forms-coverage (TAPair wt wt₁) (BVVal x) nb na nh = λ z → z _ _ refl
canonical-boxed-forms-coverage (TAPair wt wt₁) (BVPair bv bv₁) nb na nh = λ z → z _ _ refl
| 49.15748
| 113
| 0.50024
|
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.